Skip to contentSkip to conversation

Input: ili210x - Special case ili251x sample read out

PATCH Applied Marek Vasut 2 participants 2 messages Nov 8, 2021 – Nov 10, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

Cc Dmitry Torokhov <[email protected]>
Cc Joe Hung <[email protected]>
Cc Luca Hsu <[email protected]>
---
 drivers/input/touchscreen/ili210x.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/input/touchscreen/ili210x.c +13 -5
index b2d9fe1e1c707..6dd5095be567f 100644
@@ -225,15 +225,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, &reg, 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)
@@ -245,12 +247,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);
Signature · 1 line
2.33.0
maintainer Applied
#1 lore raw
Quoted 11 lines · Marek Vasut

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.

Cc Dmitry Torokhov <[email protected]>
Cc Joe Hung <[email protected]>
Cc Luca Hsu <[email protected]>

Applied, thank you.

Signature · 1 line
Dmitry