From patchwork Wed Sep 30 15:12:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 293914 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7AA02C47426 for ; Wed, 30 Sep 2020 15:15:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2E46420789 for ; Wed, 30 Sep 2020 15:15:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728805AbgI3PNL (ORCPT ); Wed, 30 Sep 2020 11:13:11 -0400 Received: from esa2.mentor.iphmx.com ([68.232.141.98]:9476 "EHLO esa2.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725872AbgI3PNI (ORCPT ); Wed, 30 Sep 2020 11:13:08 -0400 IronPort-SDR: Si8hhObSrCUiU9nSLmOb2bU4M/8kqAy/HW8DdQCC1U/Lc1aXvjHRfPpkR+EhOq9V6DvHk96vrA RVup3f+NNH4kUZu7ph9YWr5/UEIHyNdqw43tlWCXvrHTZJFj+oOrWzHsWuRn6xUXUXdSE0431q DL8es37AT+Im3xUQhrhbqp65kpXHSlmb5XzstTbc9f5V9qIa9+yk2f52ZuHT1XXXE4/kXZerbv 4KY/TleDWeUdYjF4930g4IP3dzJSlBecCWYf6ATLpPU+xM9HIIA/DsCMj0XeD6dzaB7iI+mpBJ rc4= X-IronPort-AV: E=Sophos;i="5.77,322,1596528000"; d="scan'208";a="53484663" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa2.mentor.iphmx.com with ESMTP; 30 Sep 2020 07:13:07 -0800 IronPort-SDR: xggCLPVr10q4CRzAx6ntAx7Q/0wW2gfsDmfWcT9s9w15k6wr9Daz9F0Z0BODG4tQgpgA4B2vi3 mkOpWna+DD7k7LxX0GArhyLII6xIS60ZhtE1J/U5UIbOu3e8zCOSsqoyMG5kg+JMVA8Dm2lxnD OMUMa2VNfGumQU+rQYOeVYq9NMyT/LRYWR/LUXSzVIsCKQvJT/vgAVIh0qfHA67+BqnGVPeekp MFT0mxjyNXho9G9imXoiPYpNQepeVHtQUglVQVZQx0iz7WKVU5fMeeGK+CLeadR+VJrPTBpi/E jeA= From: Jiada Wang To: , , , , CC: , , , , , , Subject: [PATCH v3 1/3] dt-bindings: input: atmel: add compatible for mXT1386 Date: Thu, 1 Oct 2020 00:12:57 +0900 Message-ID: <20200930151259.18119-2-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200930151259.18119-1-jiada_wang@mentor.com> References: <20200930151259.18119-1-jiada_wang@mentor.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Document the mXT1386 compatible string. Signed-off-by: Jiada Wang --- Documentation/devicetree/bindings/input/atmel,maxtouch.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/input/atmel,maxtouch.txt b/Documentation/devicetree/bindings/input/atmel,maxtouch.txt index c88919480d37..fdff8a4cf5c0 100644 --- a/Documentation/devicetree/bindings/input/atmel,maxtouch.txt +++ b/Documentation/devicetree/bindings/input/atmel,maxtouch.txt @@ -3,6 +3,7 @@ Atmel maXTouch touchscreen/touchpad Required properties: - compatible: atmel,maxtouch + atmel,mxt1386 The following compatibles have been used in various products but are deprecated: From patchwork Wed Sep 30 15:12:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 254944 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 887F9C4727E for ; Wed, 30 Sep 2020 15:15:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2392D20789 for ; Wed, 30 Sep 2020 15:15:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730674AbgI3PNO (ORCPT ); Wed, 30 Sep 2020 11:13:14 -0400 Received: from esa2.mentor.iphmx.com ([68.232.141.98]:9476 "EHLO esa2.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728880AbgI3PNM (ORCPT ); Wed, 30 Sep 2020 11:13:12 -0400 IronPort-SDR: 8oo4SkgycAqRXEkpbU2tbNe9QeQXDdG7x56WPiI4WTQfSTf+Bq0AcFTfNYnsJVaKVFHoOV4H8E sPWaZEB47ZstYb0iHIihD4PDRCbryflrL17P453La0x0MJ+DHqzl43okirZrD/dDZseKFbRpPD XMSJXvj09ow9iS3verLRLYgIzZiZBc69Vih9QY5otKV/Zibp+Qd6f8lr5YLAZx+k/njV1Lyxoc 51gbm2pyHQCcohpGM/SgUwmynMcwALyjYWN5uCsVdRjoPfxzM7vlyP0ygn+4MtwQci2f+dSqkK AfI= X-IronPort-AV: E=Sophos;i="5.77,322,1596528000"; d="scan'208";a="53484673" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa2.mentor.iphmx.com with ESMTP; 30 Sep 2020 07:13:11 -0800 IronPort-SDR: Vu/rZCj4dojSKM3hnbl5lI44gUaYlOTMAYCTH/3uR1eCAkOocWURz8f/MQhJqxzPycoE0eNG8m r4vbmUND07bv5dysUwHRdt0a7ln6gSLiXZvLPrjM1PqG2bXi2vaP25GH5x5fhBTaukwZIipLqd vwlz+ZFx24hDuE4+itbIBWwSWLRl8SoZgPecK14a2a7lEyIBlZOODOc+xfJ3Gfehq9LwAYrZDw JjfBIIBR3nXNY4q6Vo8PhcXz/aIG0n/c1V3jal5lKyIqpoX4rbz1FL9n9YeUearKJTdofoy6P/ 5Xo= From: Jiada Wang To: , , , , CC: , , , , , , Subject: [PATCH v3 2/3] Input: atmel_mxt_ts - implement I2C retries for mXT1368 Date: Thu, 1 Oct 2020 00:12:58 +0900 Message-ID: <20200930151259.18119-3-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200930151259.18119-1-jiada_wang@mentor.com> References: <20200930151259.18119-1-jiada_wang@mentor.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org 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 adds compatible string "atmel,mxt1386" for mXT1386 controller, when I2C transfer on mXT1386 fails, retry the transfer once after a 25 ms sleep. Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 62 +++++++++++++++++++----- 1 file changed, 50 insertions(+), 12 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 98f17fa3a892..103c3359f3df 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -198,6 +198,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 @@ -340,6 +341,9 @@ struct mxt_data { unsigned int t19_num_keys; enum mxt_suspend_mode suspend_mode; + + /* Indicates whether retry is needed when i2c transfer fails */ + bool retry_i2c_transfers; }; struct mxt_vb2_buffer { @@ -627,7 +631,9 @@ static int mxt_send_bootloader_cmd(struct mxt_data *data, bool unlock) static int __mxt_read_reg(struct i2c_client *client, u16 reg, u16 len, void *val) { + struct mxt_data *data = i2c_get_clientdata(client); struct i2c_msg xfer[2]; + bool retried = false; u8 buf[2]; int ret; @@ -646,22 +652,30 @@ static int __mxt_read_reg(struct i2c_client *client, xfer[1].len = len; xfer[1].buf = val; - ret = i2c_transfer(client->adapter, xfer, 2); - if (ret == 2) { - ret = 0; - } else { - if (ret >= 0) - ret = -EIO; +retry_read: + ret = i2c_transfer(client->adapter, xfer, ARRAY_SIZE(xfer)); + if (ret != ARRAY_SIZE(xfer)) { + if (data->retry_i2c_transfers && !retried) { + dev_dbg(&client->dev, "i2c retry\n"); + /* TODO: add WAKE-GPIO support */ + msleep(MXT_WAKEUP_TIME); + retried = true; + goto retry_read; + } + ret = ret < 0 ? ret : -EIO; dev_err(&client->dev, "%s: i2c transfer failed (%d)\n", __func__, ret); + return ret; } - return ret; + return 0; } static int __mxt_write_reg(struct i2c_client *client, u16 reg, u16 len, const void *val) { + struct mxt_data *data = i2c_get_clientdata(client); + bool retried = false; u8 *buf; size_t count; int ret; @@ -675,14 +689,21 @@ static int __mxt_write_reg(struct i2c_client *client, u16 reg, u16 len, buf[1] = (reg >> 8) & 0xff; memcpy(&buf[2], val, len); +retry_write: ret = i2c_master_send(client, buf, count); - if (ret == count) { - ret = 0; - } else { - if (ret >= 0) - ret = -EIO; + if (ret != count) { + if (data->retry_i2c_transfers && !retried) { + dev_dbg(&client->dev, "i2c retry\n"); + /* TODO: add WAKE-GPIO support */ + msleep(MXT_WAKEUP_TIME); + retried = true; + goto retry_write; + } + ret = ret < 0 ? ret : -EIO; dev_err(&client->dev, "%s: i2c send failed (%d)\n", __func__, ret); + } else { + ret = 0; } kfree(buf); @@ -3084,6 +3105,7 @@ static const struct dmi_system_id chromebook_T9_suspend_dmi[] = { static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) { + struct device_node *np = client->dev.of_node; struct mxt_data *data; int error; @@ -3158,6 +3180,20 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) msleep(MXT_RESET_INVALID_CHG); } + /* + * The mXT1386 has a dedicated WAKE-line that could be connected to a + * dedicated GPIO, or to the I2C SCL pin, or permanently asserted LOW. + * It's used for waking controller from a deep-sleep and it needs to be + * asserted LOW for 25 milliseconds before issuing I2C transfer if controller + * was in a deep-sleep mode. If WAKE-line is connected to I2C SCL pin, then + * the first I2C transfer will get an instant NAK and transfer needs to be + * retried after 25ms. There are too many places in the code where the wake-up + * needs to be inserted, hence it's much easier to add a retry to the common + * I2C accessors, also given that the WAKE-GPIO is unsupported by the driver. + */ + if (of_device_is_compatible(np, "atmel,mxt1386")) + data->retry_i2c_transfers = true; + error = mxt_initialize(data); if (error) return error; @@ -3235,6 +3271,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", }, @@ -3259,6 +3296,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); From patchwork Wed Sep 30 15:12:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 293915 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A83BFC4727F for ; Wed, 30 Sep 2020 15:13:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5938A2071E for ; Wed, 30 Sep 2020 15:13:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728076AbgI3PNf (ORCPT ); Wed, 30 Sep 2020 11:13:35 -0400 Received: from esa2.mentor.iphmx.com ([68.232.141.98]:9476 "EHLO esa2.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728663AbgI3PNS (ORCPT ); Wed, 30 Sep 2020 11:13:18 -0400 IronPort-SDR: nSLQ961igttQQFDXguzwLhOQoqV+OJ5/NRMVroTHD56kizVKBIwc+0oNmhIPNQ7mW+MVfcf2t8 WxdYs3LjqCQtwOSv6urZPipKWzS4gY17MNrim2daIZghZ/O9narY7GoH73mbsFHgrk8SBC7vhl o5IYmM4M+fud6s+lD4eJm7WwCMXOH2TpGouXvMf9IEMRi7j+lv8ezbHSIva8sLIWe3KWiAx/KF yi5BOyvZFW8qoTX4cn/lmqGfwiCdghoO1trO9rxWiEgPRr0xBcV7UPSshp5i2sNjaxx/tBfwO7 ENQ= X-IronPort-AV: E=Sophos;i="5.77,322,1596528000"; d="scan'208";a="53484685" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa2.mentor.iphmx.com with ESMTP; 30 Sep 2020 07:13:16 -0800 IronPort-SDR: AhD9Pi2PvHyXGBdiXvnDQJCnZU0KZeP70Ol0MF3R+NbwGTd4NGhvoTiCkEETjpslS11JaScN5l d8qGYNkmdEsw/Z7Hu3ii5bJK6FNdHq1oz5I0NZHrkKOBqMVb1WWvVTaWUtDZcsd63bMdkDxfN9 rmvBDbowvTb7IsP3UO/kG6Ue97WMoaKDblImtA9qHJS1FRtnbidWAz2ykAb01irAKznV596fUC KZRypC5kGLkjOpMJ6mS9dy+rF56GFt0nGk+jqM6oMaLQhvlLvksajJ13dzdA5pO384zezuhvSJ Yos= From: Jiada Wang To: , , , , CC: , , , , , , Subject: [PATCH v3 3/3] ARM: tegra: add mXT1386 compatible Date: Thu, 1 Oct 2020 00:12:59 +0900 Message-ID: <20200930151259.18119-4-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200930151259.18119-1-jiada_wang@mentor.com> References: <20200930151259.18119-1-jiada_wang@mentor.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Add mXT1386 compatible for "touchscreen@4c". Signed-off-by: Jiada Wang --- arch/arm/boot/dts/tegra20-acer-a500-picasso.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/boot/dts/tegra20-acer-a500-picasso.dts b/arch/arm/boot/dts/tegra20-acer-a500-picasso.dts index 2d683c9a1a5d..a9eed5f6973b 100644 --- a/arch/arm/boot/dts/tegra20-acer-a500-picasso.dts +++ b/arch/arm/boot/dts/tegra20-acer-a500-picasso.dts @@ -428,7 +428,7 @@ }; touchscreen@4c { - compatible = "atmel,maxtouch"; + compatible = "atmel,mxt1386", "atmel,maxtouch"; reg = <0x4c>; atmel,cfg_name = "maxtouch-acer-iconia-tab-a500.cfg";