From patchwork Fri Jan 20 12:45:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ellero X-Patchwork-Id: 13109780 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 E2DCBC25B4E for ; Fri, 20 Jan 2023 13:04:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230424AbjATNEG (ORCPT ); Fri, 20 Jan 2023 08:04:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229596AbjATNEF (ORCPT ); Fri, 20 Jan 2023 08:04:05 -0500 Received: from smtpcmd13147.aruba.it (smtpcmd13147.aruba.it [62.149.156.147]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 454C2C3817 for ; Fri, 20 Jan 2023 05:04:04 -0800 (PST) Received: from asem-TANK-H61.asem.intra ([151.1.184.193]) by Aruba Outgoing Smtp with ESMTPSA id IqmFpgGfF6DTZIqmNpKxBE; Fri, 20 Jan 2023 13:46:00 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=aruba.it; s=a1; t=1674218760; bh=aKZV7YqgUVh4R9awPP7VR+8sbXhX+ysYAcgvRZTvUls=; h=From:To:Subject:Date:MIME-Version; b=JWvMxhup1Fy6IyuRYpgDsQm/NbZdmAl/Cti3f0wKMJze3lgVapg8YGHt4eZDv5OxG 25NM4bmVQP/dM/g5MzOz924p9DOtLKr9oA8dna58B9zmnRtFBUXTghDBJj5VJvqc+3 Lb5LQcvm8lHEbHybdkTL7WAhM1QY97YOvdp5mc01/qUpemq3EskGfP9v0rZlJF6FsQ cprGQvs9Dis8hw/h50yx0Dk9lc7VD7nT5TkD7rF3xaXl8vnIlUih3irQ8e+dpDH/bb KNyp2I9Sz2XajGux1q1mhUnwOjXhgoQl9fF91vmjMZcOa0vKaWPOjbCSYzpLdVHN5a BRdwJyBUmXXsQ== From: Luca Ellero To: dmitry.torokhov@gmail.com, daniel@zonque.org, m.felsch@pengutronix.de, andriy.shevchenko@linux.intel.com, u.kleine-koenig@pengutronix.de, mkl@pengutronix.de, miquel.raynal@bootlin.com, imre.deak@nokia.com, luca.ellero@brickedbrain.com Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Luca Ellero Subject: [PATCH 1/3] Input: ads7846 - don't report pressure for ads7845 Date: Fri, 20 Jan 2023 13:45:42 +0100 Message-Id: <20230120124544.5993-2-l.ellero@asem.it> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230120124544.5993-1-l.ellero@asem.it> References: <20230120124544.5993-1-l.ellero@asem.it> MIME-Version: 1.0 X-CMAE-Envelope: MS4xfMHgp32vFwmxKkThC/2xZoh1U2HE14/ocdRhWnkWzpyt2YOvvxb5NLG47OKRwoSygfHLcrk3qhKsA5W8vehGLKc9bYNxUVVEifm97ttxwGnl+vrK/WW4 E+XCZnSpVR/3uXSilSGaHiSW7M32IwSZFcwD1Yb+sdRwPy1hLy8JseDoYSVb+3BdHDt5Tc4iZ7Wn9YMGSzvQnboqfoWWIXaOVgkU7Jz8awhjL9MmMk+4cBix YlIhRKkrCpB8ua/NKiojr0g1TWbW58v09XxRbTBTW3CB8oXp8aAz5lqRBoA/9LLtN0SQho9pTnSvoxSidbu8vwS99Hm43D+UIxnVsrkXVXYb2bu1PViIdDPA HbH0yS6CAlM+546K9sbKhI3bK365nMPq0v9mue3ANCBQ+YjHbQUntfdoARLZ0BNnjFj8oLmgSnriSkYCMeQvFLKLB0soANbSW82kn3eUqtlVxxbCrILwY5bs U+Ez/Krl4jJjqtK2RjyjOggUwyGT/qyjk/dpON71dfzixSULTeCLj7RDmGdf/6XP0Vs/EuoF48qD1sTDwP8tzP3wsy9I9SCfCqj0D6vKsK4ByG2V8lbzqNla wQ+ASeCHWVmPpMVKDHJhV/re Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org ADS7845 doesn't support pressure. This patch avoids the following error reported by libinput-list-devices: "ADS7845 Touchscreen: kernel bug: device has min == max on ABS_PRESSURE". Signed-off-by: Luca Ellero --- drivers/input/touchscreen/ads7846.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index 4c3dd01902d0..f11b444f2138 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c @@ -1316,8 +1316,9 @@ static int ads7846_probe(struct spi_device *spi) pdata->y_min ? : 0, pdata->y_max ? : MAX_12BIT, 0, 0); - input_set_abs_params(input_dev, ABS_PRESSURE, - pdata->pressure_min, pdata->pressure_max, 0, 0); + if (ts->model != 7845) + input_set_abs_params(input_dev, ABS_PRESSURE, + pdata->pressure_min, pdata->pressure_max, 0, 0); /* * Parse common framework properties. Must be done here to ensure the From patchwork Fri Jan 20 12:45:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ellero X-Patchwork-Id: 13109781 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 8496DC27C76 for ; Fri, 20 Jan 2023 13:04:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230374AbjATNEJ (ORCPT ); Fri, 20 Jan 2023 08:04:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230453AbjATNEI (ORCPT ); Fri, 20 Jan 2023 08:04:08 -0500 Received: from smtpcmd13147.aruba.it (smtpcmd13147.aruba.it [62.149.156.147]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3F4DCBD156 for ; Fri, 20 Jan 2023 05:04:07 -0800 (PST) Received: from asem-TANK-H61.asem.intra ([151.1.184.193]) by Aruba Outgoing Smtp with ESMTPSA id IqmFpgGfF6DTZIqmQpKxDO; Fri, 20 Jan 2023 13:46:03 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=aruba.it; s=a1; t=1674218763; bh=DFxo0lMWx1LamJoO8gw7DU+04h/F4i+eiapIx8PP5jQ=; h=From:To:Subject:Date:MIME-Version; b=cuNGE9Ijj4X1QMZV1GMEqCwDZpf5uR0kueMLuyN/hdxEYhzqliHQ4Op8PsbyTvx3r IFPA4dK7hHBJGQmyyAT8W847rmK/1dKsPBvN56YSD8efUKEiKq0AZWv+CXDDDY/8Ui X2RS3p51xEtPoEgaWtQVIXTiuyjRBHTZFuzeXSMjenb320Vt9Ssq94FQQQnzmfu7Tn +0mEfM5mILmahesZ0iU3d8MJ9HUTwZBgbAtbNXU+fbmRFKDXwGYK8h2m55gAFeb3X+ FMKfF35pbqZDuGrWoeBcKCiHtZZmnDqftpBYBLVxpdj0VCw92b/EQMosDiJppkDXXB m0bwPItMgzJBA== From: Luca Ellero To: dmitry.torokhov@gmail.com, daniel@zonque.org, m.felsch@pengutronix.de, andriy.shevchenko@linux.intel.com, u.kleine-koenig@pengutronix.de, mkl@pengutronix.de, miquel.raynal@bootlin.com, imre.deak@nokia.com, luca.ellero@brickedbrain.com Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Luca Ellero Subject: [PATCH 2/3] Input: ads7846 - always set last command to PWRDOWN Date: Fri, 20 Jan 2023 13:45:43 +0100 Message-Id: <20230120124544.5993-3-l.ellero@asem.it> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230120124544.5993-1-l.ellero@asem.it> References: <20230120124544.5993-1-l.ellero@asem.it> MIME-Version: 1.0 X-CMAE-Envelope: MS4xfL0QDsHFOS64LRHL6Al7UbqGJaiezOl1+OOvf8A67u1hfdUyoKem/h3PepIkXrctWfEhnNHmhDiEs1n6+mT8MqhCYkYGllEJjaUHDXnqOhpwQ36VNez2 P7ghc6w47ez1XPKv7AuB4kVgGuc9jKxijDNqiAyyqqJKM7R4Ks5XDMhWgMQUsS0shTtZfXtEBDAZcj//azuy3f0sK6TW/0IFk6FPFpXORjGME7bEMGSwtVY2 0K9GFEh9/WPR31UN5lbRdtk00da6J/nFX8i1Pwf8c30w2zha5kLQ3yjPnW7EG+MsuBjagelBuiS1JPqKgTKd0Q50H/uC4Mp0vgfkzVedX4KXsgN/q4y1gfci +rOzNEEHbNgv2KPRarQWVkrUrPAwjp55VV5kCfit4Egs0FGxHZa2GyhBK0lrq0JWOzGXjeHGs+oWwX8T6Dv99DcGl7NqCBPuHUC2thKpWXSXhfPiFjYprRfE 5Co6umRFAmGCl24KJ/dfENdF36hlb4SA0WHek6xlv4Rh1BhT3kdgyszoQ+liBoX7zFrKIHzjIY5jVeURSN5FKB+Ds7lcdUiY6W8RmNa+nXvNk8vZ6fIxKrDL 8SP6+kKI6HsPVV/Qa7QakBYL Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Controllers that report pressure (e.g. ADS7846) use 5 commands and the correct sequence is READ_X, READ_Y, READ_Z1, READ_Z2, PWRDOWN. Controllers that don't report pressure (e.g. ADS7845/ADS7843) use only 3 commands and the correct sequence should be READ_X, READ_Y, PWRDOWN. But the sequence sent was incorrect: READ_X, READ_Y, READ_Z1. Fix this by setting the third (and last) command to PWRDOWN. Signed-off-by: Luca Ellero --- drivers/input/touchscreen/ads7846.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index f11b444f2138..15da1047a577 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c @@ -1066,6 +1066,9 @@ static int ads7846_setup_spi_msg(struct ads7846 *ts, struct ads7846_buf_layout *l = &packet->l[cmd_idx]; unsigned int max_count; + if (cmd_idx == packet->cmds - 1) + cmd_idx = ADS7846_PWDOWN; + if (ads7846_cmd_need_settle(cmd_idx)) max_count = packet->count + packet->count_skip; else @@ -1102,7 +1105,12 @@ static int ads7846_setup_spi_msg(struct ads7846 *ts, for (cmd_idx = 0; cmd_idx < packet->cmds; cmd_idx++) { struct ads7846_buf_layout *l = &packet->l[cmd_idx]; - u8 cmd = ads7846_get_cmd(cmd_idx, vref); + u8 cmd; + + if (cmd_idx == packet->cmds - 1) + cmd_idx = ADS7846_PWDOWN; + + cmd = ads7846_get_cmd(cmd_idx, vref); for (b = 0; b < l->count; b++) packet->tx[l->offset + b].cmd = cmd; From patchwork Fri Jan 20 12:45:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ellero X-Patchwork-Id: 13109766 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 89A15C25B4E for ; Fri, 20 Jan 2023 12:56:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230044AbjATM4O (ORCPT ); Fri, 20 Jan 2023 07:56:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229841AbjATM4O (ORCPT ); Fri, 20 Jan 2023 07:56:14 -0500 X-Greylist: delayed 614 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 20 Jan 2023 04:56:09 PST Received: from smtpcmd13147.aruba.it (smtpcmd13147.aruba.it [62.149.156.147]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 388805FFF for ; Fri, 20 Jan 2023 04:56:08 -0800 (PST) Received: from asem-TANK-H61.asem.intra ([151.1.184.193]) by Aruba Outgoing Smtp with ESMTPSA id IqmFpgGfF6DTZIqmTpKxFZ; Fri, 20 Jan 2023 13:46:05 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=aruba.it; s=a1; t=1674218765; bh=clriM8z2Ncxi4fAOWxWB+jvP5/EzqBX4gQWuMCxv8Rc=; h=From:To:Subject:Date:MIME-Version; b=lapgEq5sABIekSkKB7RRhsJtMtwhjbDABv5/vkkYXQiX8pNUKyz688adxNjhZ2zzJ aBS4Ulqu+3DE6/nbW90rOT/SeyxCCmfDnHD57Fz1ft0NLYNPIo6/wK74/FpmK6j6Ez I1H3UMADDinPvpzsDIA5TBF46lJW8FnQbYr84rawt+tD+U5rbSAjmEWNMpiOnYb8Bz a/67B8Ppmt9tSQnZGBhArZ13tsWmgYtJ07g7G3mwner/ATveXd+Nltr95+S9pWfBxQ nKEvvdR7B3U2+9Ri4EWpiqCt8mBkReScTn15GJ6iZ6xBjGlBRpaqLQTN9wpR+Evb84 8S8mbSSQvGUbw== From: Luca Ellero To: dmitry.torokhov@gmail.com, daniel@zonque.org, m.felsch@pengutronix.de, andriy.shevchenko@linux.intel.com, u.kleine-koenig@pengutronix.de, mkl@pengutronix.de, miquel.raynal@bootlin.com, imre.deak@nokia.com, luca.ellero@brickedbrain.com Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Luca Ellero Subject: [PATCH 3/3] Input: ads7846 - don't check penirq immediately for 7845 Date: Fri, 20 Jan 2023 13:45:44 +0100 Message-Id: <20230120124544.5993-4-l.ellero@asem.it> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230120124544.5993-1-l.ellero@asem.it> References: <20230120124544.5993-1-l.ellero@asem.it> MIME-Version: 1.0 X-CMAE-Envelope: MS4xfOvKTel4AMy9mgv2aDCh+FC7Vu9mcAlOTWAUNZhZU3ZJd12ZBlI7VzbaTcXCOZ0luEXUJl0JhyM9KQ/248BtB5tDHZOdHYGEgfz3HnguekQ22mR8Tt6a U1MwQVQYjkiSBPu8dWNrN1A2ctYlGtJLNfvZ7yLoCDZ1tUIscrw5ky5NfNtAc53lhgMPfvpq26SsA5VISmW43Yj3LV7y8NEL73caQY0TEqgUr6kMPqT/8oPK nwS+lkVWYQe1qC5JJG6j9K2qXTjdM8lRAgvyneJ8joTW/WUm0midKwpucCxUJrMO/9y6SkFmW+SoQSl3EHO/HhBZY01/DBxuSdHJO6SpTaaV42ZvMlI1kn5H AwEbFl/Bf9nIpaJ7mzERFwg+dTIqy3ZTKSghLT1lClMrnsUM+ktd/YvvP+M+cF5NhdDW4ox97kko00FFiMVIi9c/8HYRROlqkUwOXdRddg5QYVqv7cOhELwA eVJSpM6/z9zW52gHDqQrfxs4H96S0/FJmPXcB9gx8dnNC3RsxciOi1sU2Qi6m7GeuQfwomipWai94uzfBUiKmkT5Qvwk/2L1oJG9aQY+dECVsi5laKRji+yp Q8LMq6Nx90Vfo4bHCPL/ATaX Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org To discard false readings, one should use "ti,penirq-recheck-delay-usecs". Checking get_pendown_state() at the beginning, most of the time fails causing malfunctioning. Signed-off-by: Luca Ellero --- drivers/input/touchscreen/ads7846.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index 15da1047a577..17f11bce8113 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c @@ -843,14 +843,8 @@ static void ads7846_report_state(struct ads7846 *ts) if (x == MAX_12BIT) x = 0; - if (ts->model == 7843) { + if (ts->model == 7843 || ts->model == 7845) { Rt = ts->pressure_max / 2; - } else if (ts->model == 7845) { - if (get_pendown_state(ts)) - Rt = ts->pressure_max / 2; - else - Rt = 0; - dev_vdbg(&ts->spi->dev, "x/y: %d/%d, PD %d\n", x, y, Rt); } else if (likely(x && z1)) { /* compute touch pressure resistance using equation #2 */ Rt = z2;