From 7dded3d2412f6f1d1668034b3b2acc8ffa663ac3 Mon Sep 17 00:00:00 2001 From: Karel Balej Date: Mon, 25 Sep 2023 22:30:27 +0200 Subject: [PATCH] input: generalize the Imagis touchscreen driver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This driver works with other Imagis ICs of the IST30**C series. Make that apparent. Signed-off-by: Karel Balej Co-developed-by: Duje Mihanović Signed-off-by: Duje Mihanović --- drivers/input/touchscreen/imagis.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/input/touchscreen/imagis.c b/drivers/input/touchscreen/imagis.c index 07111ca24455..d61fbbe61bc8 100644 --- a/drivers/input/touchscreen/imagis.c +++ b/drivers/input/touchscreen/imagis.c @@ -18,7 +18,6 @@ #define IST3038C_REG_TOUCH_STATUS (IST3038C_REG_HIB_BASE | IST3038C_HIB_ACCESS) #define IST3038C_REG_TOUCH_COORD (IST3038C_REG_HIB_BASE | IST3038C_HIB_ACCESS | 0x8) #define IST3038C_REG_INTR_MESSAGE (IST3038C_REG_HIB_BASE | IST3038C_HIB_ACCESS | 0x4) -#define IST3038C_WHOAMI 0x38c #define IST3038C_CHIP_ON_DELAY_MS 60 #define IST3038C_I2C_RETRY_COUNT 3 #define IST3038C_MAX_FINGER_NUM 10 @@ -31,6 +30,8 @@ #define IST3038C_FINGER_COUNT_SHIFT 12 #define IST3038C_FINGER_STATUS_MASK GENMASK(9, 0) +#define IST3038C_WHOAMI 0x38c + struct imagis_ts { struct i2c_client *client; struct input_dev *input_dev; @@ -253,7 +254,7 @@ static int imagis_probe(struct i2c_client *i2c) { struct device *dev = &i2c->dev; struct imagis_ts *ts; - int chip_id, error; + int chip_id, dt_chip_id, error; ts = devm_kzalloc(dev, sizeof(*ts), GFP_KERNEL); if (!ts) @@ -261,6 +262,8 @@ static int imagis_probe(struct i2c_client *i2c) ts->client = i2c; + dt_chip_id = (int)(uintptr_t) device_get_match_data(&i2c->dev); + error = imagis_init_regulators(ts); if (error) { dev_err(dev, "regulator init error: %d\n", error); @@ -287,8 +290,8 @@ static int imagis_probe(struct i2c_client *i2c) return error; } - if (chip_id != IST3038C_WHOAMI) { - dev_err(dev, "unknown chip ID: 0x%x\n", chip_id); + if (chip_id != dt_chip_id) { + dev_err(dev, "unknown or misconfigured chip ID: 0x%x\n", chip_id); return -EINVAL; } @@ -345,12 +348,18 @@ static DEFINE_SIMPLE_DEV_PM_OPS(imagis_pm_ops, imagis_suspend, imagis_resume); #ifdef CONFIG_OF static const struct of_device_id imagis_of_match[] = { - { .compatible = "imagis,ist3038c", }, + { .compatible = "imagis,ist3038c", .data = (void *) IST3038C_WHOAMI, }, { }, }; MODULE_DEVICE_TABLE(of, imagis_of_match); #endif +static const struct i2c_device_id imagis_ts_i2c_id[] = { + { "ist3038c", IST3038C_WHOAMI, }, + { } +}; +MODULE_DEVICE_TABLE(i2c, imagis_ts_i2c_id); + static struct i2c_driver imagis_ts_driver = { .driver = { .name = "imagis-touchscreen", @@ -358,6 +367,7 @@ static struct i2c_driver imagis_ts_driver = { .of_match_table = of_match_ptr(imagis_of_match), }, .probe = imagis_probe, + .id_table = imagis_ts_i2c_id, }; module_i2c_driver(imagis_ts_driver); -- 2.42.0