linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] HID: i2c-hid: wait for i2c touchpad deep-sleep to power-up transition
@ 2024-03-25 10:54 Lukasz Majczak
  2024-03-25 23:12 ` Doug Anderson
  0 siblings, 1 reply; 4+ messages in thread
From: Lukasz Majczak @ 2024-03-25 10:54 UTC (permalink / raw)
  To: Jiri Kosina, Dmitry Torokhov, Benjamin Tissoires,
	Douglas Anderson, Hans de Goede, Maxime Ripard, Kai-Heng Feng,
	Johan Hovold, linux-input, linux-kernel
  Cc: Lukasz Majczak, Radoslaw Biernacki

This patch extends the early bailout for probing procedure introduced in
commit: b3a81b6c4fc6730ac49e20d789a93c0faabafc98, in order to cover devices
based on STM microcontrollers. For touchpads based on STM uC,
the probe sequence needs to take into account the increased response time
for i2c transaction if the device already entered a deep power state.
STM specify the wakeup time as 400us between positive strobe of
the clock line. Deep sleep is controlled by Touchpad FW,
though some devices enter it pretty early to conserve power
in case of lack of activity on the i2c bus.
Failing to follow this requirement will result in touchpad device not being
detected due initial transaction being dropped by STM i2c slave controller.
By adding additional try, first transaction will wake up the touchpad
STM controller, and the second will produce proper detection response.

Signed-off-by: Lukasz Majczak <lma@chromium.org>
Signed-off-by: Radoslaw Biernacki <rad@chromium.org>
---
 drivers/hid/i2c-hid/i2c-hid-core.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c
index 2df1ab3c31cc..69af0fad4f41 100644
--- a/drivers/hid/i2c-hid/i2c-hid-core.c
+++ b/drivers/hid/i2c-hid/i2c-hid-core.c
@@ -1013,9 +1013,15 @@ static int __i2c_hid_core_probe(struct i2c_hid *ihid)
 	struct i2c_client *client = ihid->client;
 	struct hid_device *hid = ihid->hid;
 	int ret;
+	int tries = 2;
+
+	do {
+		/* Make sure there is something at this address */
+		ret = i2c_smbus_read_byte(client);
+		if (tries > 0 && ret < 0)
+			usleep_range(400, 400);
+	} while (tries-- > 0 && ret < 0);
 
-	/* Make sure there is something at this address */
-	ret = i2c_smbus_read_byte(client);
 	if (ret < 0) {
 		i2c_hid_dbg(ihid, "nothing at this address: %d\n", ret);
 		return -ENXIO;
-- 
2.44.0.396.g6e790dbe36-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-03-26 13:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-25 10:54 [PATCH] HID: i2c-hid: wait for i2c touchpad deep-sleep to power-up transition Lukasz Majczak
2024-03-25 23:12 ` Doug Anderson
2024-03-26  8:58   ` Łukasz Majczak
2024-03-26 13:43     ` Doug Anderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).