From: Jiada Wang <jiada_wang@mentor.com>
To: <nick@shmanahar.org>, <dmitry.torokhov@gmail.com>,
<robh+dt@kernel.org>, <digetx@gmail.com>
Cc: <linux-input@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<andy.shevchenko@gmail.com>, <erosca@de.adit-jv.com>,
<Andrew_Gabbasov@mentor.com>, <jiada_wang@mentor.com>
Subject: [PATCH v2 2/2] Input: atmel_mxt_ts - wake mXT1386 from deep-sleep mode
Date: Fri, 18 Sep 2020 21:56:01 +0900 [thread overview]
Message-ID: <20200918125601.8210-2-jiada_wang@mentor.com> (raw)
In-Reply-To: <20200918125601.8210-1-jiada_wang@mentor.com>
According to datasheet, mXT1386 chip has a WAKE line, it is used
to wake the chip up from deep sleep mode before communicating with
it via the I2C-compatible interface.
if the WAKE line is connected to a GPIO line, the line must be
asserted 25 ms before the host attempts to communicate with the mXT1386.
If the WAKE line is connected to the SCL pin, the mXT1386 will send a
NACK on the first attempt to address it, the host must then retry 25 ms
later.
This patch introduces mxt_wake() which does a dummy i2c read, follows
with a 25 ms sleep for mXT1386 chip. mxt_wake() is added to
mxt_initialize(), mxt_load_fw() and mxt_start() to ensure before any
actual i2c transfer, mxt_wake() can be executed.
Added new compatible string "atmel,mXT1386".
Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
Suggested-by: Dmitry Osipenko <digetx@gmail.com>
---
drivers/input/touchscreen/atmel_mxt_ts.c | 27 ++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index a2189739e30f..d580050a237f 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -196,6 +196,7 @@ enum t100_type {
#define MXT_CRC_TIMEOUT 1000 /* msec */
#define MXT_FW_RESET_TIME 3000 /* msec */
#define MXT_FW_CHG_TIMEOUT 300 /* msec */
+#define MXT_WAKEUP_TIME 25 /* msec */
/* Command to unlock bootloader */
#define MXT_UNLOCK_CMD_MSB 0xaa
@@ -2099,12 +2100,33 @@ static void mxt_config_cb(const struct firmware *cfg, void *ctx)
release_firmware(cfg);
}
+static void mxt_wake(struct mxt_data *data)
+{
+ struct i2c_client *client = data->client;
+ struct device *dev = &data->client->dev;
+ struct device_node *np = dev->of_node;
+ union i2c_smbus_data dummy;
+
+ if (!of_device_is_compatible(np, "atmel,mXT1386"))
+ return;
+
+ /* TODO: add WAKE-GPIO support */
+
+ i2c_smbus_xfer(client->adapter, client->addr,
+ 0, I2C_SMBUS_READ, 0, I2C_SMBUS_BYTE,
+ &dummy);
+
+ msleep(MXT_WAKEUP_TIME);
+}
+
static int mxt_initialize(struct mxt_data *data)
{
struct i2c_client *client = data->client;
int recovery_attempts = 0;
int error;
+ mxt_wake(data);
+
while (1) {
error = mxt_read_info_block(data);
if (!error)
@@ -2787,6 +2809,8 @@ static int mxt_load_fw(struct device *dev, const char *fn)
if (ret)
goto release_firmware;
+ mxt_wake(data);
+
if (!data->in_bootloader) {
/* Change to the bootloader mode */
data->in_bootloader = true;
@@ -2928,6 +2952,7 @@ static const struct attribute_group mxt_attr_group = {
static void mxt_start(struct mxt_data *data)
{
+ mxt_wake(data);
switch (data->suspend_mode) {
case MXT_SUSPEND_T9_CTRL:
mxt_soft_reset(data);
@@ -3185,6 +3210,7 @@ static SIMPLE_DEV_PM_OPS(mxt_pm_ops, mxt_suspend, mxt_resume);
static const struct of_device_id mxt_of_match[] = {
{ .compatible = "atmel,maxtouch", },
+ { .compatible = "atmel,mXT1386", },
/* Compatibles listed below are deprecated */
{ .compatible = "atmel,qt602240_ts", },
{ .compatible = "atmel,atmel_mxt_ts", },
@@ -3209,6 +3235,7 @@ static const struct i2c_device_id mxt_id[] = {
{ "atmel_mxt_tp", 0 },
{ "maxtouch", 0 },
{ "mXT224", 0 },
+ { "mXT1386", 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, mxt_id);
--
2.17.1
next prev parent reply other threads:[~2020-09-18 13:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-18 12:56 [PATCH v1 1/2] dt-bindings: input: atmel: add compatible for mXT1386 Jiada Wang
2020-09-18 12:56 ` Jiada Wang [this message]
2020-09-18 13:32 ` [PATCH v2 2/2] Input: atmel_mxt_ts - wake mXT1386 from deep-sleep mode Dmitry Osipenko
2020-09-18 15:55 ` Wang, Jiada
2020-09-19 19:49 ` Dmitry Osipenko
2020-09-20 5:28 ` Wang, Jiada
2020-09-20 6:02 ` Dmitry Torokhov
2020-09-20 13:13 ` Wang, Jiada
2020-09-20 14:21 ` Dmitry Osipenko
2020-09-20 14:36 ` Wang, Jiada
2020-09-20 15:49 ` Dmitry Osipenko
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=20200918125601.8210-2-jiada_wang@mentor.com \
--to=jiada_wang@mentor.com \
--cc=Andrew_Gabbasov@mentor.com \
--cc=andy.shevchenko@gmail.com \
--cc=digetx@gmail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=erosca@de.adit-jv.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nick@shmanahar.org \
--cc=robh+dt@kernel.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).