diff mbox series

[03/10] input: iqs5xx: Accommodate bootloader latency

Message ID 1611002626-5889-4-git-send-email-jeff@labundy.com (mailing list archive)
State Accepted
Commit 1302c71a30615226838f3583028d122f6792d720
Headers show
Series input: iqs5xx: Minor enhancements and optimizations | expand

Commit Message

Jeff LaBundy Jan. 18, 2021, 8:43 p.m. UTC
The bootloader NAK's all I2C communication after the first 64-byte
bulk write if the bus frequency is equal to 400 kHz. This prevents
the platform from pushing updated firmware to the device.

The vendor's USB bootloader programming dongle appears to insert a
delay between the "open" command and the first 64-byte bulk write.
Adding a similar delay to the driver seems to eliminate the issue.

Furthermore, the dongle does not access the bootloader immediately
after powering up the device. Follow suit by adding a delay before
the "open" command to avoid wasted retries at 400 kHz.

Signed-off-by: Jeff LaBundy <jeff@labundy.com>
---
 drivers/input/touchscreen/iqs5xx.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Dmitry Torokhov Jan. 25, 2021, 4:19 a.m. UTC | #1
On Mon, Jan 18, 2021 at 02:43:39PM -0600, Jeff LaBundy wrote:
> The bootloader NAK's all I2C communication after the first 64-byte
> bulk write if the bus frequency is equal to 400 kHz. This prevents
> the platform from pushing updated firmware to the device.
> 
> The vendor's USB bootloader programming dongle appears to insert a
> delay between the "open" command and the first 64-byte bulk write.
> Adding a similar delay to the driver seems to eliminate the issue.
> 
> Furthermore, the dongle does not access the bootloader immediately
> after powering up the device. Follow suit by adding a delay before
> the "open" command to avoid wasted retries at 400 kHz.
> 
> Signed-off-by: Jeff LaBundy <jeff@labundy.com>

Applied, thank you.
diff mbox series

Patch

diff --git a/drivers/input/touchscreen/iqs5xx.c b/drivers/input/touchscreen/iqs5xx.c
index ff0a0e9..b2de8c67 100644
--- a/drivers/input/touchscreen/iqs5xx.c
+++ b/drivers/input/touchscreen/iqs5xx.c
@@ -336,11 +336,16 @@  static int iqs5xx_bl_open(struct i2c_client *client)
 	 */
 	for (i = 0; i < IQS5XX_BL_ATTEMPTS; i++) {
 		iqs5xx_reset(client);
+		usleep_range(350, 400);
 
 		for (j = 0; j < IQS5XX_NUM_RETRIES; j++) {
 			error = iqs5xx_bl_cmd(client, IQS5XX_BL_CMD_VER, 0);
-			if (!error || error == -EINVAL)
-				return error;
+			if (!error)
+				usleep_range(10000, 10100);
+			else if (error != -EINVAL)
+				continue;
+
+			return error;
 		}
 	}