From: Chen-Yu Tsai <wenst@chromium.org>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Chen-Yu Tsai <wenst@chromium.org>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mediatek@lists.infradead.org,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>
Subject: [PATCH] Input: elan_i2c - Wait for initialization after enabling regulator supply
Date: Tue, 1 Oct 2024 17:38:14 +0800 [thread overview]
Message-ID: <20241001093815.2481899-1-wenst@chromium.org> (raw)
Elan trackpad controllers require some delay after enabling power to
the controller for the hardware and firmware to initialize:
- 2ms for hardware initialization
- 100ms for firmware initialization
Until then, the hardware will not respond to I2C transfers. This was
observed on the MT8173 Chromebooks after the regulator supply for the
trackpad was changed to "not always on".
Add proper delays after regulator_enable() calls.
Fixes: 6696777c6506 ("Input: add driver for Elan I2C/SMbus touchpad")
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
---
This will unfortunately slightly slow down the driver probe and resume.
An optimization would be to check if the regulator is enabled already,
and shorten or skip the delay if it is. This would require a new API
though.
---
drivers/input/mouse/elan_i2c_core.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c
index ce96513b34f6..89556f61004e 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -46,6 +46,8 @@
#define ETP_FWIDTH_REDUCE 90
#define ETP_FINGER_WIDTH 15
#define ETP_RETRY_COUNT 3
+/* H/W init 2 ms + F/W init 100 ms w/ round up */
+#define ETP_POWER_ON_DELAY 110
/* quirks to control the device */
#define ETP_QUIRK_QUICK_WAKEUP BIT(0)
@@ -1237,6 +1239,8 @@ static int elan_probe(struct i2c_client *client)
return error;
}
+ msleep(ETP_POWER_ON_DELAY);
+
/* Make sure there is something at this address */
error = i2c_smbus_read_byte(client);
if (error < 0) {
@@ -1374,6 +1378,8 @@ static int elan_resume(struct device *dev)
dev_err(dev, "error %d enabling regulator\n", error);
goto err;
}
+
+ msleep(ETP_POWER_ON_DELAY);
}
error = elan_set_power(data, true);
--
2.46.1.824.gd892dcdcdd-goog
next reply other threads:[~2024-10-01 9:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-01 9:38 Chen-Yu Tsai [this message]
2024-10-01 9:57 ` [PATCH] Input: elan_i2c - Wait for initialization after enabling regulator supply Dmitry Torokhov
2024-10-01 11:07 ` Mark Brown
2024-10-01 12:58 ` Dmitry Torokhov
2024-10-01 13:06 ` Mark Brown
2024-10-01 13:11 ` Dmitry Torokhov
2024-10-01 13:13 ` Mark Brown
2024-10-04 3:57 ` Chen-Yu Tsai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241001093815.2481899-1-wenst@chromium.org \
--to=wenst@chromium.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).