From patchwork Mon Sep 21 14:00:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 254967 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=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham 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 525AEC43465 for ; Mon, 21 Sep 2020 14:01:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2329B20756 for ; Mon, 21 Sep 2020 14:01:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726808AbgIUOBA (ORCPT ); Mon, 21 Sep 2020 10:01:00 -0400 Received: from esa1.mentor.iphmx.com ([68.232.129.153]:55479 "EHLO esa1.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726688AbgIUOBA (ORCPT ); Mon, 21 Sep 2020 10:01:00 -0400 IronPort-SDR: YqBQv/eA7RessGcWYZtqZJDPC77SPefAQ61LM53Cb+1haU4HZkTDsQHuSUb7tjnZJaX6TGXIvL w2vJCDyVOnYu6UPBCNCyz0sSin12R6X0ZwCDu9jHjVQDegh3pus3KurkxsFXlcHsjLAfEs8Kji GnqcR16p26x+1T8o+99IjqNyCCskz43sA0HGi6w1N4sKyK2H/xTKWar7DV1eCGtSER2CEFbsPL u5KGibz4hHNm2gm7IfkA/MIPoL1WvTkY+Urqam1nw5IhQiJiv5msWpwr/klRV5dANLdXJsxj9Z U34= X-IronPort-AV: E=Sophos;i="5.77,286,1596528000"; d="scan'208";a="55324397" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa1.mentor.iphmx.com with ESMTP; 21 Sep 2020 06:00:59 -0800 IronPort-SDR: H2DawD3NCdyoPkZsVFF2GiE++ULvq+D92chuTH4mdaA/mlQjVuDKIbkZWywmDebP2Pzwgn/vQL 5ZarG8uq1Bo/adXyyw9MTGmQmvUreHxXm5Tb/zsYZPbMkJuX1CXpjeQYNAqqitteYc8QaIi5gi GTC3/6z3EkgU2Dvyp6Ub4fnVDD8d2Q+ympOm0Xi2TnZo+XYqvzKVN+tc7Y5YZw3u75tBPo7Foy ZtXU7hB2qIxSA4oj84eyoz9QUdeXbDq8B0Ih0tea3b0B/ANcJlFY2kv47VP/HzH8MOWVMU+Jdo s1E= From: Jiada Wang To: , , , , CC: , , , , , , Subject: [PATCH v1 1/3] dt-bindings: input: atmel: add compatible for mXT1386 Date: Mon, 21 Sep 2020 23:00:52 +0900 Message-ID: <20200921140054.2389-1-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 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..c13fc0f3f00b 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 Mon Sep 21 14:00:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 254966 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=-12.8 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 5814EC43465 for ; Mon, 21 Sep 2020 14:01:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2AF1520756 for ; Mon, 21 Sep 2020 14:01:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727424AbgIUOBG (ORCPT ); Mon, 21 Sep 2020 10:01:06 -0400 Received: from esa1.mentor.iphmx.com ([68.232.129.153]:55479 "EHLO esa1.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727278AbgIUOBE (ORCPT ); Mon, 21 Sep 2020 10:01:04 -0400 IronPort-SDR: EDEfynIPo8BQ1myc8piFf/FNXmyHV/96Q6PUjZXd8PWDObxSuIOR6Ilg/QsArOnUzJM5jz+yfB /yQL7+iOM0pbHQGEkogP2NJn6t0M8UoAx1/2cQ8P64dbxAlvuUvjg/g0SyW53x5owkzk/sQAbN ro1HUX08sZHtFxn8ALcax9xOkU8CaVAyECgIv2Rdy+dFtMGNp4yhSkZ+6+F3FRUSZIAUPw8kSU KEMBTF0vEJ5/Ehcxhf2iEWZ7fgAmlAARN5iG5MWmVglDHS0nyVyclXyru+5/c2b8LLwUPTojvt txM= X-IronPort-AV: E=Sophos;i="5.77,286,1596528000"; d="scan'208";a="55324404" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa1.mentor.iphmx.com with ESMTP; 21 Sep 2020 06:01:03 -0800 IronPort-SDR: 6Jv8tg2LZPrFi05WR+y2c1rK/iPtWUT7s8N6/6w5chFfy9GsK9154o9FI7K0CcLJy2BtDn8q9V Zz//7YuU+d2qnXUsCFq9mHCHr8ovhfmopTcW9rRmT2uWzkT50VvxFnKMmOjeHU2oAtHxhNNVs1 9lRJgazpLEt5IsHN37ycYG29/Qaz69fApGtZNnqhzjOr9Dgc39Y4zZygGBl1ST1R5kxNqR5fuc KEL/lzxwOdZ6OaJDuicPAid3oLh5nDvaUXKKyWCthzEEHK05NfeXaa+a0lZWEsUVSmSMFm6sk4 GA8= From: Jiada Wang To: , , , , CC: , , , , , , Subject: [PATCH v1 2/3] Input: atmel_mxt_ts - implement I2C retries for mXT1368 Date: Mon, 21 Sep 2020 23:00:53 +0900 Message-ID: <20200921140054.2389-2-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200921140054.2389-1-jiada_wang@mentor.com> References: <20200921140054.2389-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 | 44 +++++++++++++++++------- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 98f17fa3a892..96d5f4d64cb0 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 @@ -627,7 +628,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 device_node *np = client->dev.of_node; struct i2c_msg xfer[2]; + bool retried = false; u8 buf[2]; int ret; @@ -646,22 +649,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 (of_device_is_compatible(np, "atmel,mXT1386") && !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 device_node *np = client->dev.of_node; + bool retried = false; u8 *buf; size_t count; int ret; @@ -675,14 +686,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 (of_device_is_compatible(np, "atmel,mXT1386") && !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); @@ -3235,6 +3253,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 +3278,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 Mon Sep 21 14:00:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 293938 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=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,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 D6F5BC43466 for ; Mon, 21 Sep 2020 14:01:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B047A20C09 for ; Mon, 21 Sep 2020 14:01:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727473AbgIUOBI (ORCPT ); Mon, 21 Sep 2020 10:01:08 -0400 Received: from esa1.mentor.iphmx.com ([68.232.129.153]:55479 "EHLO esa1.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727278AbgIUOBH (ORCPT ); Mon, 21 Sep 2020 10:01:07 -0400 IronPort-SDR: n8pD20GNLffWzboRLDbRzCVNE4W4pLX6WaB7dZcD9UZ4veeAqCMWjSQzRpOB3maAWYIoD0tXmj 0zcPqVIe1Fc0HTfVH7n4fiT1kWGB/KhPJRf78RnMPV0cNZidjPBWgILW9poFu52NlQtxcS8Avw P0T8Ge6gTIQ+pgZ9GA2/rSDeuKhdOidm/qMoO0y0+Zna18HKDzL+XMF9Nld/BE0wfVqOsX0u4t sFSM87J+qn6ec/uiV7VPmJFaOkFtQwirGGrVrZUnwV6CwM8I3U9r7RrhwNyf6lIMboqC+EefJG gOw= X-IronPort-AV: E=Sophos;i="5.77,286,1596528000"; d="scan'208";a="55324410" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa1.mentor.iphmx.com with ESMTP; 21 Sep 2020 06:01:06 -0800 IronPort-SDR: 6EZw5DvP9srZuzLxpq1xgqQ8Ucli4Lwnj9bIiu2OAO5DMPI5q2bKomkfweljQfQaMOto63AbBs quYizmIEq6xgNsBkdhY0kQFanejCQldWSiZpmfRI/qiv14qHd8sVq4OgnsNToXOGI8KNvyEJSv /mCCpCWcq+y1BYW7g+nXXR0AqY0WwEvB53FwmIoHkXW2bf5O1fT+V/5qQ8vAQ3icbM0d8FBiDa kuz+CVZfqAP/E6qoLMrJNn0n+HkIYN4N+YGpNRd8Ua8zOxEKsv6DGyRMPjCMCA4qhWNFpgI+oy gts= From: Jiada Wang To: , , , , CC: , , , , , , Subject: [PATCH v1 3/3] ARM: tegra: add mXT1386 compatible Date: Mon, 21 Sep 2020 23:00:54 +0900 Message-ID: <20200921140054.2389-3-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200921140054.2389-1-jiada_wang@mentor.com> References: <20200921140054.2389-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..7915b6e9190e 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";