From 505d19c1fdfe32972dbc389e40e43754ec318884 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sun, 7 Nov 2021 19:37:53 -0800 Subject: [PATCH] Input: ili210x - special case ili251x sample read out The ili251x touch controller needs 5ms delay between sending I2C device address and register address, and, writing or reading register data. According to downstream ili251x example code, this 5ms delay is not required when reading touch samples out of the controller. Implement such a special case. Signed-off-by: Marek Vasut Link: https://lore.kernel.org/r/20211108005259.480545-1-marex@denx.de Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/ili210x.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c index 867c13d3cb176..e1551cdc6e1a3 100644 --- a/drivers/input/touchscreen/ili210x.c +++ b/drivers/input/touchscreen/ili210x.c @@ -224,15 +224,17 @@ static const struct ili2xxx_chip ili212x_chip = { .has_calibrate_reg = true, }; -static int ili251x_read_reg(struct i2c_client *client, - u8 reg, void *buf, size_t len) +static int ili251x_read_reg_common(struct i2c_client *client, + u8 reg, void *buf, size_t len, + unsigned int delay) { int error; int ret; ret = i2c_master_send(client, ®, 1); if (ret == 1) { - usleep_range(5000, 5500); + if (delay) + usleep_range(delay, delay + 500); ret = i2c_master_recv(client, buf, len); if (ret == len) @@ -244,12 +246,18 @@ static int ili251x_read_reg(struct i2c_client *client, return ret; } +static int ili251x_read_reg(struct i2c_client *client, + u8 reg, void *buf, size_t len) +{ + return ili251x_read_reg_common(client, reg, buf, len, 5000); +} + static int ili251x_read_touch_data(struct i2c_client *client, u8 *data) { int error; - error = ili251x_read_reg(client, REG_TOUCHDATA, - data, ILI251X_DATA_SIZE1); + error = ili251x_read_reg_common(client, REG_TOUCHDATA, + data, ILI251X_DATA_SIZE1, 0); if (!error && data[0] == 2) { error = i2c_master_recv(client, data + ILI251X_DATA_SIZE1, ILI251X_DATA_SIZE2); -- 2.39.5