Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2612077rwb; Fri, 20 Jan 2023 05:20:05 -0800 (PST) X-Google-Smtp-Source: AMrXdXtPe13AwiUE3/cu9pZdN0B6rW8Amh2fjN8iNGPE4j9ThYflAZYU1HeYJiM4Imp/XIsDHHTk X-Received: by 2002:a17:906:edc9:b0:870:2f70:c63e with SMTP id sb9-20020a170906edc900b008702f70c63emr15320321ejb.18.1674220805710; Fri, 20 Jan 2023 05:20:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674220805; cv=none; d=google.com; s=arc-20160816; b=IYxWUEANz7G9pg9rkVvEcGOOiTOLyuWkV/Re5KClMPXnQRjd0yBRmu1KmveK2kSRvi MEHzlFXBVW3sYfrboIFPVE6idAoh3by5Zw/LMxFw77n8zXeMpKK0DWOp9COpAKLrQCtL PxFaPtHWxFTfKZRiom1MNGckoCl3+hac1xmoEBS+ppRJGdCze37kkTZw9tXO5+D9yxdB QqOis9FGTCt3ypitJIVkeMBck0XgfRivrzpPwxPx22E+9/2wa8Ip+Pgbl5sN6VUeztSW 6eE/ccwfbPv0/zrTfywlJrq5qHp+tc+Ucg6JEjS7I7N/yx30vhBCPaT4mCSQpPPltfzD I8ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dAzLVChMU1CmUSM3uqTGOn2u7TwaNsn9tXEaykDjpEU=; b=uMLAmleXP7SsJrJLUgeoHefJhYzrOc3lRxm5oumMuGx39XF/L8J0o6meKXZJoGtZwt AwvntJr5f8BJj8EMkilIYllz2/e0t9m8cKdw09iafffwkd4OoGcrplEQG8fANi54ZNEu 7I1r0xVnoQeZAhBOo4u6O652HmJYLlX4WzFUr9rkNuiOgQwHkOs78eEn0zpcPaooV+jt mD4/RFx537+n+1Zxp7v8ajqf3opFA2yNTBH0XnJyhL1YHErd6MKREu/szOnAZLlBN794 xPqeoWSfdKEbYX50u9fNjolnaFcXhD2pgvvo1og7+4vz/kRS33c6/v1Gn9jgCVKn6cm4 VVSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@aruba.it header.s=a1 header.b=cuNGE9Ij; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=asem.it Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hv10-20020a17090760ca00b00870f9e0ecf2si18213183ejc.356.2023.01.20.05.19.52; Fri, 20 Jan 2023 05:20:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@aruba.it header.s=a1 header.b=cuNGE9Ij; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=asem.it Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229596AbjATNEM (ORCPT + 49 others); Fri, 20 Jan 2023 08:04:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230456AbjATNEI (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 471DBC3803 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 Content-Transfer-Encoding: 8bit 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 X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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; -- 2.25.1