Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: ektf2127 - add ektf2232 support

The chip is similar, but has status bits at different positions,
so use the correct bits.

Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
Link: https://lore.kernel.org/r/20240621224022.1620897-4-andreas@kemnade.info
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Andreas Kemnade and committed by
Dmitry Torokhov
f7b41baa a6550605

+30 -6
+30 -6
drivers/input/touchscreen/ektf2127.c
··· 13 13 * Hans de Goede <hdegoede@redhat.com> 14 14 */ 15 15 16 + #include <linux/bits.h> 16 17 #include <linux/gpio/consumer.h> 17 18 #include <linux/interrupt.h> 18 19 #include <linux/i2c.h> ··· 47 46 struct input_dev *input; 48 47 struct gpio_desc *power_gpios; 49 48 struct touchscreen_properties prop; 49 + int status_shift; 50 + }; 51 + 52 + struct ektf2127_i2c_chip_data { 53 + int status_shift; 50 54 }; 51 55 52 56 static void ektf2127_parse_coordinates(const u8 *buf, unsigned int touch_count, ··· 118 112 119 113 static void ektf2127_report2_event(struct ektf2127_ts *ts, const u8 *buf) 120 114 { 121 - ektf2127_report2_contact(ts, 0, &buf[1], !!(buf[7] & 2)); 122 - ektf2127_report2_contact(ts, 1, &buf[4], !!(buf[7] & 4)); 115 + ektf2127_report2_contact(ts, 0, &buf[1], !!(buf[7] & BIT(ts->status_shift))); 116 + ektf2127_report2_contact(ts, 1, &buf[4], !!(buf[7] & BIT(ts->status_shift + 1))); 123 117 124 118 input_mt_sync_frame(ts->input); 125 119 input_sync(ts->input); ··· 253 247 static int ektf2127_probe(struct i2c_client *client) 254 248 { 255 249 struct device *dev = &client->dev; 250 + const struct ektf2127_i2c_chip_data *chip_data; 256 251 struct ektf2127_ts *ts; 257 252 struct input_dev *input; 258 253 u8 buf[4]; ··· 310 303 return error; 311 304 312 305 ts->input = input; 306 + 307 + chip_data = i2c_get_match_data(client); 308 + if (!chip_data) 309 + return dev_err_probe(&client->dev, -EINVAL, "missing chip data\n"); 310 + 311 + ts->status_shift = chip_data->status_shift; 312 + 313 313 input_set_drvdata(input, ts); 314 314 315 315 error = devm_request_threaded_irq(dev, client->irq, ··· 339 325 return 0; 340 326 } 341 327 328 + static const struct ektf2127_i2c_chip_data ektf2127_data = { 329 + .status_shift = 1, 330 + }; 331 + 332 + static const struct ektf2127_i2c_chip_data ektf2232_data = { 333 + .status_shift = 0, 334 + }; 335 + 342 336 #ifdef CONFIG_OF 343 337 static const struct of_device_id ektf2127_of_match[] = { 344 - { .compatible = "elan,ektf2127" }, 345 - { .compatible = "elan,ektf2132" }, 338 + { .compatible = "elan,ektf2127", .data = &ektf2127_data}, 339 + { .compatible = "elan,ektf2132", .data = &ektf2127_data}, 340 + { .compatible = "elan,ektf2232", .data = &ektf2232_data}, 346 341 {} 347 342 }; 348 343 MODULE_DEVICE_TABLE(of, ektf2127_of_match); 349 344 #endif 350 345 351 346 static const struct i2c_device_id ektf2127_i2c_id[] = { 352 - { "ektf2127" }, 353 - { "ektf2132" }, 347 + { .name = "ektf2127", .driver_data = (long)&ektf2127_data }, 348 + { .name = "ektf2132", .driver_data = (long)&ektf2127_data }, 349 + { .name = "ektf2232", .driver_data = (long)&ektf2232_data }, 354 350 {} 355 351 }; 356 352 MODULE_DEVICE_TABLE(i2c, ektf2127_i2c_id);