From patchwork Mon May 1 11:30:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maximilian Weigand X-Patchwork-Id: 13227450 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63086C7EE21 for ; Mon, 1 May 2023 11:30:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229482AbjEALaz (ORCPT ); Mon, 1 May 2023 07:30:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232159AbjEALay (ORCPT ); Mon, 1 May 2023 07:30:54 -0400 Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B872510FA; Mon, 1 May 2023 04:30:53 -0700 (PDT) Received: from koko.localdomain ([213.196.213.13]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1N7iKo-1qNbbV2mws-014k2Q; Mon, 01 May 2023 13:30:43 +0200 From: Maximilian Weigand To: Linus Walleij , Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Maximilian Weigand , Alistair Francis Subject: [PATCH v2 1/6] Input: cyttsp5 - fix array length Date: Mon, 1 May 2023 13:30:05 +0200 Message-Id: <20230501113010.891786-2-mweigand@mweigand.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230501113010.891786-1-mweigand@mweigand.net> References: <20230501113010.891786-1-mweigand@mweigand.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:p/5GtVKUJPnHQuTfJuon7vGN4jRyuRUKN4lAKxXfbccB7EmDnaC 3KBBK8At5C65x/HXFnSQmx/Nrl322WQXn5iKsdvENkEbpQGOByUN+Kt2vx+hSzEP0gL8pg0 M6BmLjOPt0mNnx1qw+qemgDs049TLxzDBNCsE+AnampUPKQo1Z39sxj7E15SPMZZh5sd7ou S8pK4sHuSP3YBtA4n8Fvw== UI-OutboundReport: notjunk:1;M01:P0:sk8asawXIvw=;XQvol0O474AgmlBRt3WdtGpLEJo 2uHuXyIzIE9YLtQ3CFaWbHweOqriHM691A+gUdkwmZnzwhHyKipG+DTVx+Rj91ruz4sSGj5IT oxtnF7WQvm/TEIvl15fP78Hlj+E5NIndxwxWGOuVQpawfYdP3Boc4MLkAirMOkiSDl5L/bo86 lsxIYDQr7lpPMGzWACdEMuqsPAapHCSSpYC5QaUUkG+1e8023a35GuvwYBUVlzxwn88h0mA03 K7DIBFyrKmu2/jIYlJKeSZnUHSEokpFs/tFBY03Q55SVJfi65DLrxrgm5pKWvzwSiNXNpD//x sMNOx7gIliDMV0yTOqM0WwId4RkTkTZofQIN5sI/VQAnPe3cT0tIGITzWncto9SVlgsdd8Eoe DEiaHGtdaxhVQgExvNFoG8B7y2aZL5njjybfm+MDaSxnx28kAADDy7cXV2gZt3uRA6K94Bi1N hHSWyMKQsJl+jyfCPgH/KY01T9wH1rgFkPeACEbfgm9yZhWQzC337Vp5LmasUO0bD8ko8J5bH H98/3Jbj4bZUO3lBBPWfNuWTkqhGSEiF1em4j/63Od5iTh+G0RCXOXlGH9/WAbK/eNZ2Qd1yJ 3+pEC25KWjlf2TXfPQHEZNU4ZQ2fHD2r4GoGUjsvuQhw5GqVGh5g8HyS23uMv8d/G7PETFegc g7mpKDeY/gbJJvbQoqwoMebRMHIO3FSU2zeCNbOQAQ== Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org The cmd array should be initialized with the proper command size and not with the actual command value that is sent to the touchscreen. Signed-off-by: Maximilian Weigand Reviewed-by: Alistair Francis --- drivers/input/touchscreen/cyttsp5.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/cyttsp5.c b/drivers/input/touchscreen/cyttsp5.c index 30102cb80fac..3c9d07218f48 100644 --- a/drivers/input/touchscreen/cyttsp5.c +++ b/drivers/input/touchscreen/cyttsp5.c @@ -560,7 +560,7 @@ static int cyttsp5_hid_output_get_sysinfo(struct cyttsp5 *ts) static int cyttsp5_hid_output_bl_launch_app(struct cyttsp5 *ts) { int rc; - u8 cmd[HID_OUTPUT_BL_LAUNCH_APP]; + u8 cmd[HID_OUTPUT_BL_LAUNCH_APP_SIZE]; u16 crc; put_unaligned_le16(HID_OUTPUT_BL_LAUNCH_APP_SIZE, cmd); From patchwork Mon May 1 11:30:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maximilian Weigand X-Patchwork-Id: 13227451 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A9D3C7EE22 for ; Mon, 1 May 2023 11:31:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232323AbjEALbE (ORCPT ); Mon, 1 May 2023 07:31:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232291AbjEALbD (ORCPT ); Mon, 1 May 2023 07:31:03 -0400 Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 596BA10F7; Mon, 1 May 2023 04:30:59 -0700 (PDT) Received: from koko.localdomain ([213.196.213.13]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MRTEr-1pexnY2vAL-00NOGH; Mon, 01 May 2023 13:30:49 +0200 From: Maximilian Weigand To: Linus Walleij , Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Maximilian Weigand , Alistair Francis Subject: [PATCH v2 2/6] Input: cyttsp5 - remove unused code Date: Mon, 1 May 2023 13:30:06 +0200 Message-Id: <20230501113010.891786-3-mweigand@mweigand.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230501113010.891786-1-mweigand@mweigand.net> References: <20230501113010.891786-1-mweigand@mweigand.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:04GRXAHNNP3hfmZh/kzBFbrrSfrgqaJnyEVJ+MKgY/8gCoh7e5P ysf7d3bJD7UneJCt2k6QvYro6/B9Vc7OY/T5xzJ1cyUlpIjJg/YgYQOD5RAwyMYaHAjxEbJ TAV5T6F4p6ezacZM+0ggxDOvh1BJEfOIiYp4UYTwRoTGab+218eYFYRKHxTdbvSNARyGrJ9 eWMoyhUJHW195YQKGTJzw== UI-OutboundReport: notjunk:1;M01:P0:X21Tj8S84uk=;+iBO72prv/PwXlcCcUsw2W4eEzx bOT3BmWNSYlmYfjwnJvhd3ZMpvAiHY990RtWHySXswX0Ex6BY92WFYakpURd5vYKm7sTdlMGC kJUlbrskJwJ0SEDg8PmEaQQNn8bkC0MdDUX00WPLcKZX8p26QTX4vdyVnw2DJ2LtbGPso2gNN /qpMNfX3PuAxGDrhg5R0+3hD3Blx+eh7EFysVKkNjSkejJUVTJ5j4bbpWLyXP1AamgGlWdff7 v1rNN2TeYTVyLLi+rlRQz/D0QgtBqlgbEpKHHdC4qSNjYWOsdY+ObY2pLH+JuWZd7SKPdW2zH R05zEqRcDPufez9iIUWLvQq5fo7OHt8z9fqLs6d06eS8LuP8DMGmLbTy47MA7EgruYJqhl6D1 yy8ZsQKRn1waYJWXfrazh/P3RuKxMRfqLnm+wSeOKz+ItHpFTazx0LswVNk1UIdwMHkTKGbO4 GlxhO7hCjCcdRS+x8T/ZPm0RFjeuVopTj5FN3iUfIz1qkn3Z1bkEWa+fDNOtIcyOHs+oGR1gL OmWnd/X/n7FreZCQNFNKMv6EUAiQCotelNy8OnZ5xcP/zjnRaCGIfwoQ9nvkf9Chy+Xl9ZxU6 piDNxBO8ADr4wAVmKJV/IDtH6Pqqi23iHNewqzRajdQumLPlz0kA+/qNSsYKVOaiqMag6auC8 xNkbGEmwsTA14o64PfpgERDWIhLBZtNn4nHVBP0+QQ== Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org The removed lines are remnants of the vendor driver and are not used in the upstream driver. Signed-off-by: Maximilian Weigand Reviewed-by: Alistair Francis --- drivers/input/touchscreen/cyttsp5.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/input/touchscreen/cyttsp5.c b/drivers/input/touchscreen/cyttsp5.c index 3c9d07218f48..55abf568bdf6 100644 --- a/drivers/input/touchscreen/cyttsp5.c +++ b/drivers/input/touchscreen/cyttsp5.c @@ -601,12 +601,7 @@ static int cyttsp5_get_hid_descriptor(struct cyttsp5 *ts, struct cyttsp5_hid_desc *desc) { struct device *dev = ts->dev; - __le16 hid_desc_register = cpu_to_le16(HID_DESC_REG); int rc; - u8 cmd[2]; - - /* Set HID descriptor register */ - memcpy(cmd, &hid_desc_register, sizeof(hid_desc_register)); rc = cyttsp5_write(ts, HID_DESC_REG, NULL, 0); if (rc) { From patchwork Mon May 1 11:30:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maximilian Weigand X-Patchwork-Id: 13227452 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16B45C77B61 for ; Mon, 1 May 2023 11:31:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232214AbjEALbH (ORCPT ); Mon, 1 May 2023 07:31:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232331AbjEALbF (ORCPT ); Mon, 1 May 2023 07:31:05 -0400 Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50827172A; Mon, 1 May 2023 04:31:02 -0700 (PDT) Received: from koko.localdomain ([213.196.213.13]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MfHIZ-1qTuDu0fvf-00grO3; Mon, 01 May 2023 13:30:53 +0200 From: Maximilian Weigand To: Linus Walleij , Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Maximilian Weigand , Alistair Francis Subject: [PATCH v2 3/6] dt-bindings: input: cypress,tt21000 - fix interrupt type in dts example Date: Mon, 1 May 2023 13:30:07 +0200 Message-Id: <20230501113010.891786-4-mweigand@mweigand.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230501113010.891786-1-mweigand@mweigand.net> References: <20230501113010.891786-1-mweigand@mweigand.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:4skmoJaGKcxINrXaVpa0550kK2r50u4dFgDEnFRnenh8PTS0fl0 pHOOokYa8UhpVMfVhZbaRDjMH/oSyuzqfiLnnyvs4/xVI8b/qxnEv/Tym3UyY9PI63nKWz7 LihlEyDqqn5yrU1IPIi+ycppxUV2U13g1JXLsAt0iQrjLuwwHD8+m+WCTVHp/kR1XrBmjT8 Qc7Bwj3Ei09ECmT45ScFg== UI-OutboundReport: notjunk:1;M01:P0:BpfJcb7jkiw=;F6cKvf2fjVbXv9lF6nBsQsW1wtt P2a+QeD5BIVxesm073QbzQgwnNOWJ6S1b/ijblvaBhFq3tfCUZcp8T+s29FEMAErwV8JMBzdv T4amjDFC3MboQboY0CxVE7DFqxp+nGsXRtGPmzkSZWM2A4PxG49mb1LiENZ3gpTj7EVfXCjrr FHIyqwvhOrMHobJIRz5uR5uJHDsTvRsCV7sS3b3GlUGDQb2rC8pLIOaMqCD+1e7gBMpBqHkB7 Q8suPxb7GZuTBddRsDhsQpGmghI9h1CnL6CDyWX15kySLf34MOt/ltcp2E+2ik1UGWGAcMe0f iaY2IJS8GVqrVGm9PUfgviNf+SKW32gogD5EnBmwfHr44WE373OlZUhiFYSKptqexHxiiv4yF r/4LY8hEYiUUAYHTgGJdhjqumuLx2JbraF7K74vt0UmqrRkWCjWdWNE4kdB9pRUXUQcSVmQVr xK7TIqwmmc2MF7TPWYf6sxsAFrCSK+e14ey2muP/nfZ1rkGppVhAbiOimxb6Mkww/2yaKAg3b +VJ2o9ao9qsIJwFiosqOrB/MjTGI0tbmuf7FJOdwSSpk/Fq9PfsU325Q+YjMtdnEZsJ/fClLr Ekh/3ZJ0Ihq4CAgL7ELDCK95MZo0PrsJDdKQd3yZBQAYuSfjMe2gflMG5zmWtV4+MDZA13L7N YhXWv2LVt/CcnX43dx9niQl8nB4KdRXCaD3ZQyah5Q== Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Triggering the interrupt of the IRQ_TYPE_LEVEL_LOW type can lead to probing issues with the device for the current driver (encountered on the Pine64 PineNote). Basically the interrupt would be triggered before certain commands were sent to the device, leading to a race between the device responding fast enough and the irq handler fetching a data frame from it. Actually all devices currently using the driver already use a falling edge trigger. Signed-off-by: Maximilian Weigand Reviewed-by: Alistair Francis Reviewed-by: Linus Walleij --- .../devicetree/bindings/input/touchscreen/cypress,tt21000.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/input/touchscreen/cypress,tt21000.yaml b/Documentation/devicetree/bindings/input/touchscreen/cypress,tt21000.yaml index 1959ec394768..a77203c78d6e 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/cypress,tt21000.yaml +++ b/Documentation/devicetree/bindings/input/touchscreen/cypress,tt21000.yaml @@ -83,7 +83,7 @@ examples: pinctrl-names = "default"; pinctrl-0 = <&tp_reset_ds203>; interrupt-parent = <&pio>; - interrupts = <1 5 IRQ_TYPE_LEVEL_LOW>; + interrupts = <1 5 IRQ_TYPE_EDGE_FALLING>; reset-gpios = <&pio 7 1 GPIO_ACTIVE_LOW>; vdd-supply = <®_touch>; From patchwork Mon May 1 11:30:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maximilian Weigand X-Patchwork-Id: 13227453 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B31A8C7EE21 for ; Mon, 1 May 2023 11:31:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232364AbjEALbS (ORCPT ); Mon, 1 May 2023 07:31:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232340AbjEALbN (ORCPT ); Mon, 1 May 2023 07:31:13 -0400 Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8A2B1709; Mon, 1 May 2023 04:31:05 -0700 (PDT) Received: from koko.localdomain ([213.196.213.13]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MbAYi-1qQJaa1ZbE-00bcJw; Mon, 01 May 2023 13:30:56 +0200 From: Maximilian Weigand To: Linus Walleij , Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Maximilian Weigand , Alistair Francis Subject: [PATCH v2 4/6] Input: cyttsp5 - properly initialize the device as a pm wakeup device Date: Mon, 1 May 2023 13:30:08 +0200 Message-Id: <20230501113010.891786-5-mweigand@mweigand.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230501113010.891786-1-mweigand@mweigand.net> References: <20230501113010.891786-1-mweigand@mweigand.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:wfa4Bim49+9ZHMV6kgEjh/JopXEgYM9Shx9nCM4xZ0drjqVvbwV ZtGJYmqqbwX0zMuDKyTatjvCl2UoglmSHLkjSB4tom3uzCAcPAvv6kyuNGRcYEQIwnMucIY ErQ6LCMCGxcsHXL9yM0X765oQHJ2wBJwEJOZfXqEXVdXSe5bJ6wR0FgQ3VOaUpUkRqknTy0 noW/VbpVIhqx3896AdPVw== UI-OutboundReport: notjunk:1;M01:P0:Yx+pFtBIbTs=;9DC6+cxtWB0bVBKORgPv+KcC+Lx YoQmeEGDa7BT5jporOT4Pt8luHuHDhaqszuzyqXp3vYn3MhzdPwy7NxjNoA0Qa3sDgFfmEjZh y3Rc4n64mK6lnQ9AlNkw+Vh1ahvB2lQ8J6huplTyUWRBV0t0Tp2p0NEvJT/IaXhKBQzAEcQ3s zTG09W56PL7juLuZzk6/bu+dxEsVNsHj4VYjIR6a4iL5cx/PDOan+Stom1b7tW2ZF2CJ+ci9u RgZuYNUiqn+YXrFD7icYEwzHms2aRwhyYC4vjlqJUQ7mLkNbsPJmQ0m+bQdSFNuH2RE3YTznk 6WvrUiY3fgvcW1S9L3Cmk1X4pwRgvY8/gn355vOC+VJkqiG7YYwL9XgaXOFaO3yePeaZ0QRg/ FayLyRlhv8+WcADN7KcIXEJoPXm+/LLRVnXICA6Tte5zg2Cyt4IAIbe+DRt4p3nPdrgmd9rxp pqRFxhVWGFi5kxkw3KtKXtmjTUTXVLQE34OZcO5oC34PPk5FgPPFM24aUEVBM7s2cPLbUlPh9 2quOanF6OyedCJ51vcRa9u1WrgbLe6MrtICezbtYmU/G/KdHObRqKugPcNmkarDpY/Nw+Cris nMH5LkvAttfKmRGGzd7iiGwoCaKLgxUPFR/1E9qaToEMYWhpHrvJfJTZrGsWriPoWlHkhquUA aVK6kIxOqo8Q8R/sW+lXsBbHMMIGJfJHjbg8XkaWzw== Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org When used as a wakeup source the driver should be properly registered with the pm system using device_init_wakeup. Signed-off-by: Maximilian Weigand Reviewed-by: Alistair Francis --- drivers/input/touchscreen/cyttsp5.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/input/touchscreen/cyttsp5.c b/drivers/input/touchscreen/cyttsp5.c index 55abf568bdf6..f701125357f0 100644 --- a/drivers/input/touchscreen/cyttsp5.c +++ b/drivers/input/touchscreen/cyttsp5.c @@ -830,6 +830,9 @@ static int cyttsp5_probe(struct device *dev, struct regmap *regmap, int irq, return error; } + if (device_property_read_bool(dev, "wakeup-source")) + device_init_wakeup(dev, true); + error = cyttsp5_startup(ts); if (error) { dev_err(ts->dev, "Fail initial startup r=%d\n", error); From patchwork Mon May 1 11:30:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maximilian Weigand X-Patchwork-Id: 13227454 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D37FDC7EE22 for ; Mon, 1 May 2023 11:31:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232255AbjEALbV (ORCPT ); Mon, 1 May 2023 07:31:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232192AbjEALbS (ORCPT ); Mon, 1 May 2023 07:31:18 -0400 Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 381121731; Mon, 1 May 2023 04:31:07 -0700 (PDT) Received: from koko.localdomain ([213.196.213.13]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MOzKm-1pd2v041EK-00PKCW; Mon, 01 May 2023 13:30:59 +0200 From: Maximilian Weigand To: Linus Walleij , Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Maximilian Weigand , Alistair Francis Subject: [PATCH v2 5/6] dt-bindings: input: cypress,tt21000 - add wakeup-source entry to documentation Date: Mon, 1 May 2023 13:30:09 +0200 Message-Id: <20230501113010.891786-6-mweigand@mweigand.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230501113010.891786-1-mweigand@mweigand.net> References: <20230501113010.891786-1-mweigand@mweigand.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:K12RZay6xcOkocB4SCgqAg9ozfRV1XCB0ieaU5zXhREJ55ndb0W YABy3DAEGMpJYRlfBip2FVYbhlZLPaqfjn4oT1+73SMNth7FCE4KSRiVhp7Vsx24hpqWfKH HS2T8+WVjrQ3e7ATyhH1Z+PhQv7Ht8W4FoOJ6cxqUZmfe/PkuEzTK5/rQAdNZPIRAugs7Jn fgeHXLkROMwPKlyQRZ7Jg== UI-OutboundReport: notjunk:1;M01:P0:03PkLQoI9ZI=;IYEV2oX7Q9E3svd43HzMYF+xtsn gi2vcj3wCARtXcT1CY1EG22Yh+u/ft2Co74Kens6W0ZZylEZ9JQysdMvkC8E4/veR3hs63lS3 7JtP6/582ZdVX12SVd5SPHWiMtmeCHeDGW2xoUTVwHWNudQEKiYWNCzqRjaKvOeBTf6yc3Jky gr5lHBJ7wY/bR35fAv5rmQijvdokQpcu6KXIQ0VcYJb8MVea3/ddMocoYw9/C9kJBuMO3glAw Umgo/bQWn9KTj32780fXbsmIHHBH5vePW3G59rsmC4l3QCh8BuA9RlsoaYfmzWvSxPDXuJI5F lmRO93GjHu7HFCprE0TJRqFsJ6ww/vkPEpfmA8a02zlOR4lPCNW7cwMJoX3UZxcsUC1n1QPBV YfD7FbNFNReeTa5J8ZyTcudPH+1oJK6gNX0E4X5nTbn+dD8at+MdySuEpF8hSGLGK31OnNQIX EMkDGmNWoGknD39Ec2qe9R2aU3CaWvcNPGJJ9p8h+Jx5/gVRRYZbhqaDQ5Dxr9o+uuWGj/MyG /wOGB1ZLBRb4qAz2+GggfwwalzuAGhSaBKCNZ1Isba7TgaRfB8AACygcQ1+xq/mPR67MJvXA4 2LykuBKOSfP8/RBfWkvvukZp83e3kFWF4/Lw7LYTjQrhYta7mlJC1XB1i+Z+nlWjiH2CCORxV RCSpl+lH9Un0Nsf6ll6fax71cqrZi0e54NGFqml8bg== Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org The touchscreen can be used to wake up systems from sleep and therefore the wakeup-source entry should be included in the documentation. Signed-off-by: Maximilian Weigand Reviewed-by: Alistair Francis Reviewed-by: Linus Walleij --- .../devicetree/bindings/input/touchscreen/cypress,tt21000.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/input/touchscreen/cypress,tt21000.yaml b/Documentation/devicetree/bindings/input/touchscreen/cypress,tt21000.yaml index a77203c78d6e..e2da13b7991d 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/cypress,tt21000.yaml +++ b/Documentation/devicetree/bindings/input/touchscreen/cypress,tt21000.yaml @@ -40,6 +40,8 @@ properties: linux,keycodes: description: EV_ABS specific event code generated by the axis. + wakeup-source: true + patternProperties: "^button@[0-9]+$": type: object From patchwork Mon May 1 11:30:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maximilian Weigand X-Patchwork-Id: 13227455 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30EABC77B73 for ; Mon, 1 May 2023 11:31:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232380AbjEALba (ORCPT ); Mon, 1 May 2023 07:31:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232366AbjEALbZ (ORCPT ); Mon, 1 May 2023 07:31:25 -0400 Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E46081723; Mon, 1 May 2023 04:31:10 -0700 (PDT) Received: from koko.localdomain ([213.196.213.13]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MO9qz-1pdrrg0X7Z-00OVFt; Mon, 01 May 2023 13:31:01 +0200 From: Maximilian Weigand To: Linus Walleij , Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Maximilian Weigand , Alistair Francis Subject: [PATCH v2 6/6] Input: cyttsp5 - implement proper sleep and wakeup procedures Date: Mon, 1 May 2023 13:30:10 +0200 Message-Id: <20230501113010.891786-7-mweigand@mweigand.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230501113010.891786-1-mweigand@mweigand.net> References: <20230501113010.891786-1-mweigand@mweigand.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:XL0v2ES8g8q0dThN462agTUzufe9lz34rx0S/2pSjfd2vFBgOd/ LWrD7t7dCXLffsV9NaENe6slSJA+piuVgWIuLCDiUhoB7IREifmFfIe0vdajm4s9Fc9V6Yw OY9/49IzqNFxXuj14+aIOOklml4LIajqb3vTSAFyfhYxnsHCHz9nZb7JcqNXdqqc+0MWHbo 6tGROWV9xaLbpDBDLRueg== UI-OutboundReport: notjunk:1;M01:P0:tRmD21IPVUI=;mddkxV4mNxJWnERB80hQ9qDoLTM YDblznRvcy87R0Vo5XF4P88JMGGrgmzh9ItTLIwVVQowaSQLHEACLQeE7VcULTALKqEC3nwXF 5r/AwuKQDYqdCBVmgFLivGgHfGlfciL5n3zlDb41nllEaZtIXoV6RhmQ545nw4nWzR3h0RJH5 k6Yf3wsLk3hand2jymrk8GjXwFZo9fxu/8czTizW+9ZRLT3QY3eBtdjMylNzhHDdRa8D9DMYJ NURen27SDt7lfP1DkAO8WXiQdFAYSClrXYLLZol6ujiox4qnYxD0FXVKFFNTwMU8CF4AKvcKh W6VoJFT0ZUhWxWXwfDf6sUXrQvDvPVF6C8c0RxyLfXt/VegqgOzMhN3N8SDiemAPkIeg2Gg0X p9I0tNXzltUN3qqIQjkrnhXFhktZctVbmSgjMgvtGKYXCz3NG0YLymDzV/QX4kuur8DCCfSaL d45p+olGtkXFMAhNrz0YLyXxbDd5Xb/UpFDlWvjFvF+UpSz70jAh1xRmkHJX8bYTsOYO7Sb1i 4NE3uoM00BxsUNfgoHiDHMHefZ8e0YvVPUG4MBKe23qrGCKHt164dRe86HhWIFSNd7lic90QM SJgGsNKrxVg/dEm/6mbaIevcA+0DlbCHlgEMIQJRr1meWNTJwGMG9ie16RI8HZWFotjOU3zIw RjdmvQdTBKIoe7yHxcyzM1/wtXEV1dRHF46R2Sg3+A== Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org The touchscreen can be put into a deep sleep state that prevents it from emitting touch irqs. Put the touchscreen into deep sleep during suspend if it is not marked as a wakeup source. This also fixes a problem with the touchscreen getting unresponsive after system resume because it pulled the interrupt line low during sleep in response to a touch event, thereby effectively disabling the interrupt handling (which triggers on the falling edge). Signed-off-by: Maximilian Weigand Reviewed-by: Alistair Francis --- drivers/input/touchscreen/cyttsp5.c | 125 +++++++++++++++++++++++++++- 1 file changed, 124 insertions(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/cyttsp5.c b/drivers/input/touchscreen/cyttsp5.c index f701125357f0..54b1c9512e4d 100644 --- a/drivers/input/touchscreen/cyttsp5.c +++ b/drivers/input/touchscreen/cyttsp5.c @@ -43,6 +43,7 @@ #define HID_DESC_REG 0x1 #define HID_INPUT_REG 0x3 #define HID_OUTPUT_REG 0x4 +#define HID_COMMAND_REG 0x5 #define REPORT_ID_TOUCH 0x1 #define REPORT_ID_BTN 0x3 @@ -68,6 +69,7 @@ #define HID_APP_OUTPUT_REPORT_ID 0x2F #define HID_BL_RESPONSE_REPORT_ID 0x30 #define HID_BL_OUTPUT_REPORT_ID 0x40 +#define HID_RESPONSE_REPORT_ID 0xF0 #define HID_OUTPUT_RESPONSE_REPORT_OFFSET 2 #define HID_OUTPUT_RESPONSE_CMD_OFFSET 4 @@ -78,9 +80,15 @@ #define HID_SYSINFO_BTN_MASK GENMASK(7, 0) #define HID_SYSINFO_MAX_BTN 8 +#define HID_CMD_SET_POWER 0x8 + +#define HID_POWER_ON 0x0 +#define HID_POWER_SLEEP 0x1 + #define CY_HID_OUTPUT_TIMEOUT_MS 200 #define CY_HID_OUTPUT_GET_SYSINFO_TIMEOUT_MS 3000 #define CY_HID_GET_HID_DESCRIPTOR_TIMEOUT_MS 4000 +#define CY_HID_SET_POWER_TIMEOUT 500 /* maximum number of concurrent tracks */ #define TOUCH_REPORT_SIZE 10 @@ -100,6 +108,14 @@ #define TOUCH_REPORT_USAGE_PG_MIN 0xFF010063 #define TOUCH_COL_USAGE_PG 0x000D0022 +#define SET_CMD_LOW(byte, bits) \ + ((byte) = (((byte) & 0xF0) | ((bits) & 0x0F))) +#define SET_CMD_HIGH(byte, bits)\ + ((byte) = (((byte) & 0x0F) | ((bits) & 0xF0))) +#define SET_CMD_OPCODE(byte, opcode) SET_CMD_LOW(byte, opcode) +#define SET_CMD_REPORT_TYPE(byte, type) SET_CMD_HIGH(byte, ((type) << 4)) +#define SET_CMD_REPORT_ID(byte, id) SET_CMD_LOW(byte, id) + /* System Information interface definitions */ struct cyttsp5_sensing_conf_data_dev { u8 electrodes_x; @@ -180,6 +196,7 @@ struct cyttsp5_hid_desc { struct cyttsp5 { struct device *dev; struct completion cmd_done; + struct completion cmd_command_done; struct cyttsp5_sysinfo sysinfo; struct cyttsp5_hid_desc hid_desc; u8 cmd_buf[CYTTSP5_PREALLOCATED_CMD_BUFFER]; @@ -192,6 +209,7 @@ struct cyttsp5 { struct regmap *regmap; struct touchscreen_properties prop; struct regulator *vdd; + bool is_wakeup_source; }; /* @@ -557,6 +575,82 @@ static int cyttsp5_hid_output_get_sysinfo(struct cyttsp5 *ts) return cyttsp5_get_sysinfo_regs(ts); } +static int cyttsp5_enter_sleep(struct cyttsp5 *ts) +{ + int rc; + u8 cmd[2]; + + memset(cmd, 0, sizeof(cmd)); + + SET_CMD_REPORT_TYPE(cmd[0], 0); + SET_CMD_REPORT_ID(cmd[0], HID_POWER_SLEEP); + SET_CMD_OPCODE(cmd[1], HID_CMD_SET_POWER); + + rc = cyttsp5_write(ts, HID_COMMAND_REG, cmd, 2); + if (rc) { + dev_err(ts->dev, "Failed to write command %d", rc); + return rc; + } + + rc = wait_for_completion_interruptible_timeout(&ts->cmd_command_done, + msecs_to_jiffies(CY_HID_SET_POWER_TIMEOUT)); + if (rc <= 0) { + dev_err(ts->dev, "HID output cmd execution timed out\n"); + rc = -ETIMEDOUT; + return rc; + } + + /* validate */ + if ((ts->response_buf[2] != HID_RESPONSE_REPORT_ID) + || ((ts->response_buf[3] & 0x3) != HID_POWER_SLEEP) + || ((ts->response_buf[4] & 0xF) != HID_CMD_SET_POWER)) { + rc = -EINVAL; + dev_err(ts->dev, "Validation of the sleep response failed\n"); + return rc; + } + + return 0; + +} + +static int cyttsp5_wakeup(struct cyttsp5 *ts) +{ + int rc; + u8 cmd[2]; + + memset(cmd, 0, sizeof(cmd)); + + SET_CMD_REPORT_TYPE(cmd[0], 0); + SET_CMD_REPORT_ID(cmd[0], HID_POWER_ON); + SET_CMD_OPCODE(cmd[1], HID_CMD_SET_POWER); + + rc = cyttsp5_write(ts, HID_COMMAND_REG, cmd, 2); + if (rc) { + dev_err(ts->dev, "Failed to write command %d", rc); + return rc; + } + + rc = wait_for_completion_interruptible_timeout(&ts->cmd_command_done, + msecs_to_jiffies(CY_HID_SET_POWER_TIMEOUT)); + if (rc <= 0) { + dev_err(ts->dev, "HID output cmd execution timed out\n"); + rc = -ETIMEDOUT; + return rc; + } + + /* validate */ + if ((ts->response_buf[2] != HID_RESPONSE_REPORT_ID) + || ((ts->response_buf[3] & 0x3) != HID_POWER_ON) + || ((ts->response_buf[4] & 0xF) != HID_CMD_SET_POWER)) { + rc = -EINVAL; + dev_err(ts->dev, "Validation of the sleep response failed\n"); + return rc; + } + + return 0; + +} + static int cyttsp5_hid_output_bl_launch_app(struct cyttsp5 *ts) { int rc; @@ -670,6 +764,10 @@ static irqreturn_t cyttsp5_handle_irq(int irq, void *handle) case HID_BTN_REPORT_ID: cyttsp5_btn_attention(ts->dev); break; + case HID_RESPONSE_REPORT_ID: + memcpy(ts->response_buf, ts->input_buf, size); + complete(&ts->cmd_command_done); + break; default: /* It is not an input but a command response */ memcpy(ts->response_buf, ts->input_buf, size); @@ -784,6 +882,7 @@ static int cyttsp5_probe(struct device *dev, struct regmap *regmap, int irq, dev_set_drvdata(dev, ts); init_completion(&ts->cmd_done); + init_completion(&ts->cmd_command_done); /* Power up the device */ ts->vdd = devm_regulator_get(dev, "vdd"); @@ -830,8 +929,11 @@ static int cyttsp5_probe(struct device *dev, struct regmap *regmap, int irq, return error; } - if (device_property_read_bool(dev, "wakeup-source")) + if (device_property_read_bool(dev, "wakeup-source")) { device_init_wakeup(dev, true); + ts->is_wakeup_source = true; + } else + ts->is_wakeup_source = false; error = cyttsp5_startup(ts); if (error) { @@ -884,6 +986,27 @@ static const struct i2c_device_id cyttsp5_i2c_id[] = { }; MODULE_DEVICE_TABLE(i2c, cyttsp5_i2c_id); +static int __maybe_unused cyttsp5_suspend(struct device *dev) +{ + struct cyttsp5 *ts = dev_get_drvdata(dev); + + if (!ts->is_wakeup_source) + cyttsp5_enter_sleep(ts); + return 0; +} + +static int __maybe_unused cyttsp5_resume(struct device *dev) +{ + struct cyttsp5 *ts = dev_get_drvdata(dev); + + if (!ts->is_wakeup_source) + cyttsp5_wakeup(ts); + + return 0; +} + +static SIMPLE_DEV_PM_OPS(cyttsp5_pm, cyttsp5_suspend, cyttsp5_resume); + static struct i2c_driver cyttsp5_i2c_driver = { .driver = { .name = CYTTSP5_NAME,