From patchwork Thu Mar 23 13:52:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maximilian Weigand X-Patchwork-Id: 667105 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 E453AC7619A for ; Thu, 23 Mar 2023 13:58:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231819AbjCWN6A (ORCPT ); Thu, 23 Mar 2023 09:58:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231283AbjCWN57 (ORCPT ); Thu, 23 Mar 2023 09:57:59 -0400 Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 398C5469D; Thu, 23 Mar 2023 06:57:58 -0700 (PDT) Received: from koko.localdomain ([89.1.213.94]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MkpnF-1qL2AL0Tsd-00mIsU; Thu, 23 Mar 2023 14:52:46 +0100 From: Maximilian Weigand To: Linus Walleij , Dmitry Torokhov , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Maximilian Weigand , Alistair Francis Subject: [PATCH 1/6] Input: cyttsp5: fix array length Date: Thu, 23 Mar 2023 14:52:00 +0100 Message-Id: <20230323135205.1160879-2-mweigand@mweigand.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230323135205.1160879-1-mweigand@mweigand.net> References: <20230323135205.1160879-1-mweigand@mweigand.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:+1DhUNDo+nzdmkzCeHmfEL2un8XA8aBChZLaJgqifXsrgo4Te4B J5cBDz1wUTYE4+BoWAp0Ox3gGnMjI3r9ZvVSGaJzDcB1ggXnvLAg0wa4NMLW+xmJsjEFCG/ wLApC9WEG4fgdMidDvNzIgR4XJax7NARqji3olDNI9yjsPPcrbjCl9JITFpy9sgBhpYnxHu xdZxYy6nmkvdAYN4VfW8A== UI-OutboundReport: notjunk:1;M01:P0:H8F03Lc5QDc=;imrDxUuizjS7jnaLTI+DiXs7AMB Wg/llIbBSSsogOtz3A7aVAgd41Ir7eIk5gE/84XBo6B0G6y/RIQi/SUehXErAf4OSAyfJfc5E DW+9f+YJ7DtUzZOrhJ8V8orI+WVC92FqQ9XD6YResI+Yxo9qEktFocDLR6k6aLaSLlqZBKx7W jUSGiujp3IhQvyjY3qMCt7UQp7ildG+W9oI8bJV9hM46+3eiVjkrO/nc8xvYjCz/faup1e/NI i694ixXZQH/qMrTEw9ETm1mcJ9ug4XIbVrlhDJEU+sqoMlxd038E0b5cyohK80bQmqSsBEWzE 1m/s1ZnNkf5A1zp/KDIXB/yatpe0sENLae1AL2w6WldusmAa2eCxHkfBnA1oWAEtpTZ8AXXXk /ak06ztseW+vMM2ajcQh0zqI4ixJ4IGvrzbo8/jMqV7xD9TSZSn3Hjvhc3V+1bHTg+sj6BQeY OGGetF3c5u+1IPUTA4ENQPMfnqAgUz+hELAmCf1wE1e4lq9Nt/cZ6ux63Mi+QRKvpzF0WXr6Q x7M6UJ0ugI0wovZdR9L8gtIo3uS/AWVBvxKPyVxIbAF8v5f+n/yzHctQJbcfyTe2EFDuoXB/q p6BsZi7/mW8JZ0BjfEGOhoRAd03AgEq8AktUxYttFjo/BVww9qgKEQOJH076Dnr/4nKoCCdYX WvNqHLlBvNWCNQG9a+fyNkwyGNsOzU3z70cvPh+iHA== 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 16caffa35dd9..42c7b44e37f8 100644 --- a/drivers/input/touchscreen/cyttsp5.c +++ b/drivers/input/touchscreen/cyttsp5.c @@ -559,7 +559,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 Thu Mar 23 13:52:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maximilian Weigand X-Patchwork-Id: 667108 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 62888C6FD1C for ; Thu, 23 Mar 2023 13:52:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231846AbjCWNwy (ORCPT ); Thu, 23 Mar 2023 09:52:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231681AbjCWNwx (ORCPT ); Thu, 23 Mar 2023 09:52:53 -0400 Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28F9FB748; Thu, 23 Mar 2023 06:52:51 -0700 (PDT) Received: from koko.localdomain ([89.1.213.94]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MV6Bs-1q5AF61VWo-00S9OV; Thu, 23 Mar 2023 14:52:46 +0100 From: Maximilian Weigand To: Linus Walleij , Dmitry Torokhov , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Maximilian Weigand , Alistair Francis Subject: [PATCH 2/6] Input: cyttsp5: remove unused code Date: Thu, 23 Mar 2023 14:52:01 +0100 Message-Id: <20230323135205.1160879-3-mweigand@mweigand.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230323135205.1160879-1-mweigand@mweigand.net> References: <20230323135205.1160879-1-mweigand@mweigand.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:YUH5iMMLxAx7e4vsbCAz3PXdHSmfYWWG0GYRvSJUmzyU8xy+8Nc dh9EE38jxbmYYN2c+EjmnLv70tj981P1xIZdAQ5Xbr4tc+k7TfSXIe6tFIVaCeZphlv4WGw MluiAWwdCyasKeqjHXqrbD2uBt/QKQzUbusHVeGCtb3PNOHVt+NbFd6Xw+rabpGj/bMVX7W Ou84g6q+ktG6aN20xnrig== UI-OutboundReport: notjunk:1;M01:P0:QGfNrt1tYeU=;hDQe2Vd0r4SngaEZ4qXWTCPz9Y+ MQuGU59IIBTgYLlAZEu1mP5HG5yo3pqT9orTEACPX/VQWi/GguRSCu/4+lhpF1hpW7qScI/Po 3ZiSkk/PXlf7lGd28uPR6zX6qqehEHYRdTJHX9+feH+KcfDejl0Cs3REO1edQZ1h9wGfJ6NMq IwKhib49Y0ay7UE0AaY9bGmNZ/RqseNqMoTISFh4pqbJ6f8XnGEY7O/MZzR9Sm25oNL3hQfEJ BmhxNIMPWfHMmWVLbheqTQQVlqe1fLauT+fpa0f4nCvK6KFqukb1koJ2e/+a6izQIYsy5RVvn oI2VCGsguJUACIH8ScaQ2N1lEjTcDT7Ii7B3oLRL+61VKj80gb+C43eruQnSXSUUziYb5NBxI IbAioewwRx0MvQnQqJDAGz6PxvXqO4zZ54e3CBQ4trvrraDO0oyP5e+tHI9kuRBuyLeUghTHJ BOuPEJLcLggYy0pU35Wu3SR6/E8gdyQY03QPfeFWOiuq5BBx0BlLJ2rF0CC5PhPMJzB0R+hYw bOSltGIrniqQhaQtP4NV3H6gVGv2ReZ4oSR1hnDIjXzMnX678q/rNUKLHyw23BNZg86jD/h2K 6g2pU9bnV/Iz1CEOl/gULcJmq51T8HpOIo5Ny3UrDNExEgcUHLNGGsx3HhD4alwFAgLXHpyYs Pxob7DbDqCaKvrV7r25VCdPU/45fbLwJNWjy2cnkQA== Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org The removed lines were remnants of the android driver of the touch screen and are not used in the current driver. Signed-off-by: Maximilian Weigand Reviewed-by: Alistair Francis --- drivers/input/touchscreen/cyttsp5.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/input/touchscreen/cyttsp5.c b/drivers/input/touchscreen/cyttsp5.c index 42c7b44e37f8..8b0c6975c6ec 100644 --- a/drivers/input/touchscreen/cyttsp5.c +++ b/drivers/input/touchscreen/cyttsp5.c @@ -600,13 +600,9 @@ 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) { dev_err(dev, "Failed to get HID descriptor, rc=%d\n", rc); From patchwork Thu Mar 23 13:52:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maximilian Weigand X-Patchwork-Id: 666395 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 49C2BC6FD1D for ; Thu, 23 Mar 2023 13:52:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231863AbjCWNwz (ORCPT ); Thu, 23 Mar 2023 09:52:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231818AbjCWNwx (ORCPT ); Thu, 23 Mar 2023 09:52:53 -0400 Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6471A2685E; Thu, 23 Mar 2023 06:52:52 -0700 (PDT) Received: from koko.localdomain ([89.1.213.94]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1N4yyQ-1qdwlO2fga-010wFN; Thu, 23 Mar 2023 14:52:46 +0100 From: Maximilian Weigand To: Linus Walleij , Dmitry Torokhov , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Maximilian Weigand , Alistair Francis Subject: [PATCH 3/6] devicetree: input: cypress, tt21000: fix interrupt type in dts example Date: Thu, 23 Mar 2023 14:52:02 +0100 Message-Id: <20230323135205.1160879-4-mweigand@mweigand.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230323135205.1160879-1-mweigand@mweigand.net> References: <20230323135205.1160879-1-mweigand@mweigand.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:qIRHCx+hkbhXBze+r4iUxTBMWw945kE6YSiCOBHDhHvt3/3CrxR 94DoiYVCqgaI1UQyVpXt7mKk5kk23HsjbzE3DNgRtzqVamvxUamEONEYYGBI3shj6vXf5ZL xrcT+7+wzmE5UOBmOxpv0oThCR3ZN+8Z3c5q+Hphx05nuqbbHqn3QrA+KTofNo8QB0piNbQ Us2BGmt6tB4W14heshZ+w== UI-OutboundReport: notjunk:1;M01:P0:xiNu1U2d/3I=;porqCJZTOTHXiR9QWnkuS8fhmv3 X9I7SkTDuxJyVJ5wB2bZLuyXvRaOFrU6kSs5rdh/J2D8b4Ajqm0X8ox5b+LJ9hQK/4RcV2koG TWIInIt2ZKvnv4WPQgaqMpC4ulyxXKbI954AQMBAnXJzQqvdpF5xHTtOeGPREdoyluUw2bASA uK8SyWmc1FqdBega7XSoxer9xy3raN6wnzecR8dhtbkClyTmUJZ000kXHobAb3zfwQwurdSdT lGry9Arr3W4RCSyCx85D5UxjVj1PG0uGgb34tLYiKY8WV2oL4CN6hqGYjAZNqxwJ79C5NwPPX DskvydkJCo76tB4/IsMDA7x6LNgw2JrFp64nERRIJ4IePTz9x/Y9T7ASL4cX4TXUhAoC2LuKn x4ZriUSzGa4ag8dy7N3Ys5oBs3EuktIctaekd3Jnp0ECiso815HzcrA2SW2DcabOmitY/f4nA +gqt+XyZiU88dc1PoMTSRwhPjsj84V689XhMBlmaUl42U/RuinXcGpyNpmHHp+elodV71/mSB PPCxauBlwr6m3wkEM55vY3mhctThudx6AwAduxM8qiRsJqiZyIr8QRHgioxpl8qx/Ad4nAobZ Sy803tfbDEM6pWtvCUkoljwP2aCQwMn0eAqpZLZGflI5+aB7XyI6AidO61VEoL3W0dAE/3iqn DJjMQFZzC3VWHN4YqFZSNKltaEshSBQvSSI3SNj8ug== 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 Thu Mar 23 13:52:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maximilian Weigand X-Patchwork-Id: 667106 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 22C1FC6FD1C for ; Thu, 23 Mar 2023 13:58:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231639AbjCWN57 (ORCPT ); Thu, 23 Mar 2023 09:57:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229461AbjCWN56 (ORCPT ); Thu, 23 Mar 2023 09:57:58 -0400 Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0AE39001; Thu, 23 Mar 2023 06:57:57 -0700 (PDT) Received: from koko.localdomain ([89.1.213.94]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Mlf8e-1qO42W3fCk-00iiuN; Thu, 23 Mar 2023 14:52:46 +0100 From: Maximilian Weigand To: Linus Walleij , Dmitry Torokhov , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Maximilian Weigand , Alistair Francis Subject: [PATCH 4/6] Input: cyttsp5: properly initialize the device as a pm wakeup device Date: Thu, 23 Mar 2023 14:52:03 +0100 Message-Id: <20230323135205.1160879-5-mweigand@mweigand.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230323135205.1160879-1-mweigand@mweigand.net> References: <20230323135205.1160879-1-mweigand@mweigand.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:IukSdTMfV9ZkGrQVT2rC0B+Y/Pto+OPq5ITXNsFzFMoMUaCEDL1 LHmLGD0PnlwCPvPp6BhuEBKAgQ438yVOcZz0TG43belz6St65TbsbPtpmQeZrWtRqOongCN 3O8ALtKjxXrm30JqIt5O1CS9gyCRiUMQfGn4SqNsRZvK1Mkn4GWW5qYsX9jadAFjCizveWV KE2HZk3Om4rjmvLWj0zEA== UI-OutboundReport: notjunk:1;M01:P0:AbOjXQs477k=;CWtsoK34/JP8HKzCFveKNB0Zb+z 8h2cWw4QIgwsiqqCrLBA8GtoMYk91276u94KXw514ZjoHf+MJFHz+5VVjxUPFM9zpD0SOOdWg mxXYF2caE8zrn22f/JRTL7GdrRaFL2vHjuHiI5xmPH7Tfk0Hq97AJHeB/CoKmd4YbPMB1ftPg jP1kq5ViAHwudtOi/uUVtD2Bk9ltCGSFsk3ZGgVFmt0/XMi7WZP6q5u1IAvlhYvwL8OrX0grr SQCxB/7GToId9/7rOE1myZnkkckLVYHYqnm+MAaFwCa0ym6eGKkXq9B46nnQow62lleYRDskr oeew8eH1wGxWH0/UffJBJcUVO7VQW/BmfzsLV1GweKs5dwA6pjetZT73whRZKl2k8VqZSSi0c SWxPvLXu0/kTjkIvyN1iAh+Kz/74ZS+TTw0HRD78ByPA8MvTNGxyxQciVwpiGlK6BMrW/QZ/l rJPVFPHgndAMCnOuPShiG+jRRscPM4IRurb0qTp5hlGqxJBQupqPm6xFkxypWCa/NMIWa6sl2 RYjgvYeUR/yL62TBou84SBWt5oGz2tVwTy5HPgOsRhp8IAJCn1aN2c5tohw9iae5LswK8sq9s NooqeAi2N2J/d7WWtnpAPFnry/5UNIrJ0g+T2KuxxYg3iqkyxNpDqKfGoWlpfr0TGKnMW7b4X BX3umrEawAFezN31QgEdBm9+NMTUThlscyxjUp8ySA== 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 8b0c6975c6ec..01dd10a596ab 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 Thu Mar 23 13:52:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maximilian Weigand X-Patchwork-Id: 666394 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 9595BC76195 for ; Thu, 23 Mar 2023 13:53:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231908AbjCWNw7 (ORCPT ); Thu, 23 Mar 2023 09:52:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231868AbjCWNw4 (ORCPT ); Thu, 23 Mar 2023 09:52:56 -0400 Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15FDB26CC5; Thu, 23 Mar 2023 06:52:52 -0700 (PDT) Received: from koko.localdomain ([89.1.213.94]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MjjKf-1qM8600U0p-00lCww; Thu, 23 Mar 2023 14:52:47 +0100 From: Maximilian Weigand To: Linus Walleij , Dmitry Torokhov , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Maximilian Weigand , Alistair Francis Subject: [PATCH 5/6] devicetree: input: cypress,tt21000: add wakeup-source entry to documentation Date: Thu, 23 Mar 2023 14:52:04 +0100 Message-Id: <20230323135205.1160879-6-mweigand@mweigand.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230323135205.1160879-1-mweigand@mweigand.net> References: <20230323135205.1160879-1-mweigand@mweigand.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:b3r0ZYyInXa19U1aLlkg64sS922exnyPcnGdVPzW36yPBPehFUk y9ERr+Ts+4ZxNd+0QglLwufcGlwUbkaHRYjxX46/zkryfreRxUy0mwfd+YdFL2YS5SbciNZ I09CSXF5IWfdU4ODvY5VhlXRtokqArMIB6Gq2I0BTeYt1OJXZFOXluWWXVM33z61HOcDNa8 Rq8u5BNguDiLm9WMFboog== UI-OutboundReport: notjunk:1;M01:P0:iEAOO3st3Uc=;KYadPSUtVnzgubKGGqN25wMHyYM yqExI3Q1T1r9e6A9tBIQQUIzKh2Q7XJCFH4+HjjMCXeneypqL3AFyTZ6WrNOesvSIGwziaDlP X9Bm7ituvmj+fulOMXdvmsT1+HoQNq8gfFECsHovtSVRopjGvv0eSc7Dw9KE4O3sh5V94fMr4 oKKSMs3+amJzu/K8wJGCM3JMr32jOj0fHoA2O+NwjrjY7EqEba6U5Iu2Sjm09dAzja1GWpp6V 2ow4RlN6MZqkTrIV5NgBnOZtlBV147u9/I/R3h6z/v+3XNiXHeo2WcmpS4qb2StxARFeLBs63 HSTzwtLEMX6QrsAj05dlxyQdRrQWdqp7EUHS7AhZty8YWfHDTanWRades6IXfdh6iJISqYPQk iIM0Ln90Bs2L5anvzal1P9WruvPkWePwVwXNGJ3hHIypsBSt3MZ7+MkSuGYrKwCk1KohuPZgD Qx01+mCFOt8OpN3mqD228J9kNS+BM2cTaM0i0XLCqN8qGPrU/bTjuewA41S3G9SDSidwYVD3V eWlwSL2PGplqh5pksa6s3XnllB1ncF7ZTDqUEbXDFdVAEzJhSRXVyffPAvnGfk2Sq43s7i/Y+ L2Z9a0ZO37rjL41xW4s8Rqip4UlOg/YuM9SlGVptc6zftpWAmC5A414pBp6qJztgKn+P+Rs4F 12oY7+LtMrXE+uQ8VTsnzohBeisZaPRg7PzxT7k2ug== 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 Thu Mar 23 13:52: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: 667107 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 05D42C6FD1C for ; Thu, 23 Mar 2023 13:53:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231882AbjCWNw6 (ORCPT ); Thu, 23 Mar 2023 09:52:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231681AbjCWNw4 (ORCPT ); Thu, 23 Mar 2023 09:52:56 -0400 Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18FB428E63; Thu, 23 Mar 2023 06:52:52 -0700 (PDT) Received: from koko.localdomain ([89.1.213.94]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Mof1D-1qHA1O1nWz-00p4pQ; Thu, 23 Mar 2023 14:52:47 +0100 From: Maximilian Weigand To: Linus Walleij , Dmitry Torokhov , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Maximilian Weigand , Alistair Francis Subject: [PATCH 6/6] Input: cyttsp5: implement proper sleep and wakeup procedures Date: Thu, 23 Mar 2023 14:52:05 +0100 Message-Id: <20230323135205.1160879-7-mweigand@mweigand.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230323135205.1160879-1-mweigand@mweigand.net> References: <20230323135205.1160879-1-mweigand@mweigand.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:zzLyeqflRm7UGravOHiW9xcOiaMBdEHtUyUJZy+G19EFiSvwZEy bB1uFk0Icuov9zFJw5z94J7ZfVW46ZVUEh2+9+1PwidmBZu2lsEzBiXsECNj43pGOJoR/14 l6beIwi8usfnUL0JTV5KAP1rCOoJtFJu7WXVLgZgnlhcYtlRz0SMWIXOUxWBGT387o4bSAb S0CBmfK1ip2o7cuE13Ivg== UI-OutboundReport: notjunk:1;M01:P0:dbSg3Nw2nDA=;psUiAgzFxzslLiHCkMxlFn64goY wlu+imSNWjE1s6slWUg6OJns53Pe8gnVrUdYlaIHM/a6+q1xoSNcb/Zg0MGsvvGjDAN/Ps2Vt XNVmglUZeusYMtIZZyRviCz21ZyfKSQwU4SChKboc0yqTW1SiUkK3a+KXbSheaDn7KUcIsDry NomUVJsDZgWmHu03+IF9HoYKpNnvXeX7e6h7jn04ihq4twrKm075QBwfVeD+Txgo3Sews9YN1 gtvLdwgKImv5AL9xx3PDJZq4zHlZA9cM96aZgWJoM0oqeK1kvieEAgvs6VVFHn4x6hP/mHMhg KUGEMGU/ru4Fj25l5ktJVLqBKOEjhknOSkES7Il46ctAOGfRJBUY1UyL8O9xQzpE43qVMfKc6 j/ynA9I8ulQjbWs8W/AoGVT94WsuMBAzY2YST3XJyU/9hR68UDUkIaMmQaazlO0//fO9a8Slp 8w6n9fwPDvFFGOHF32WJuq6m09sRukTk2EkrFDmny6kVg/FSOH21AjikQRTdzw+5h1ktpALzz Tj7gQqBwOjFL2GkE9q7Yh7M8H6lDKU7MYmstQkNYBVsMeOVe0cY9SrmmbqO690DxyRethv1iY d8ou9y/kcN30787xFt9rBQMtvqe6TYkH0JOvUs9POsLhgHBU+2Ll6rwYrbHWyztna/EqoHdBm hqSXjZy1keh61fCDM4V9+zeDfaAfD/MQsmZuY/CjPQ== 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 | 129 +++++++++++++++++++++++++++- 1 file changed, 128 insertions(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/cyttsp5.c b/drivers/input/touchscreen/cyttsp5.c index 01dd10a596ab..3e8387f6347c 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; @@ -179,6 +195,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]; @@ -191,6 +208,7 @@ struct cyttsp5 { struct regmap *regmap; struct touchscreen_properties prop; struct regulator *vdd; + bool is_wakeup_source; }; /* @@ -556,6 +574,84 @@ 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]; + u16 crc; + + 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]; + u16 crc; + + 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 +766,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 +884,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 +931,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 +988,29 @@ 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); + struct i2c_client *client = to_i2c_client(dev); + int error; + + 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,