Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1049711rwb; Tue, 29 Nov 2022 08:22:02 -0800 (PST) X-Google-Smtp-Source: AA0mqf7LFGTEgjcq53OHwJ//t3jBu6qp9PYW9zriWy7mCctxWI0wDdbefT0mzgAnw9ICsFZxkhnD X-Received: by 2002:a63:6e46:0:b0:477:f5ae:55a3 with SMTP id j67-20020a636e46000000b00477f5ae55a3mr16419038pgc.277.1669738921848; Tue, 29 Nov 2022 08:22:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669738921; cv=none; d=google.com; s=arc-20160816; b=1Fq3gRg/iLfYLpXlAO64sh4UDMVsLha8vVOCvGTv+4N43cTv54HQ9F97Nzcw9ZAhqB zMyU2lENHKsvalIxnbUt/BGpdDkssNHWxDizJ5QqG7O2BPxImclCfjwXySdC40t97QFK RC4Ebw+J/xU6lHejWy0M3L9/2NEsE9R4t8ZXjR8O0E+ZvJdySO/s1xfbiC8K8ziWLE6E +22nA8mG+BUuS2LEUTFYqm3FUAccW1SK3mMcXP6Vd6n/JXHIlywAxD7eVkoRGJxC6/fF M/0GxOasLVVYK8eklX3WgDrh8YOHQgMgwcq8MRw2HWMTvEx85IyU6vlw2yyg/xaQ4IXf n02A== 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=OxFMcooBP0tM+MEDVFkVKBhSQ3L4Oev80tyJR0L6eaA=; b=ZIh4R/yopoVMHXeZx7PPKowj5kIV00vwm/bOSffpcTECa8whtGhRbMVv10iMXJPONI 9bIMh7/AcwppCqCHEX+MreAz4kVN6z4/ypjpzqOkq5ScrMBT2jvycVbVwPMEtPFaVoJo nrcbVnHatrFBvwM2RMoVEeqofPJTjlEFMjeZOJa3/jxfE8+7KTVYoe/lU/3SHTt4JFm2 Q6a9ujU+HCj2fcEBM6EmkF6uBCh4Hsy0MextSOOMfuOkVyGsmRJGt06CLVqjV9MVgCgP UzOCVQXUR/FvkWs6gJ0zW3q5uBGCdLgYzqKi7ebmicUy7w0UcjAPdr015da2ZMZeWiQO S0PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@aruba.it header.s=a1 header.b=EvoQWEPn; 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 m15-20020a65564f000000b00476c6e96225si14334954pgs.539.2022.11.29.08.21.46; Tue, 29 Nov 2022 08:22:01 -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=EvoQWEPn; 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 S235557AbiK2Pia (ORCPT + 84 others); Tue, 29 Nov 2022 10:38:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234741AbiK2PiX (ORCPT ); Tue, 29 Nov 2022 10:38:23 -0500 Received: from smtpcmd04131.aruba.it (smtpcmd04131.aruba.it [62.149.158.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5D2A91C8 for ; Tue, 29 Nov 2022 07:38:22 -0800 (PST) Received: from asem-TANK-H61.asem.intra ([151.1.184.193]) by Aruba Outgoing Smtp with ESMTPSA id 02Ozp6txJm9gv02PApWxO5; Tue, 29 Nov 2022 16:20:18 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=aruba.it; s=a1; t=1669735218; bh=zTsu9YvjjwpwF7zSkRalIemgq9HBKFWhACD/LncT3zM=; h=From:To:Subject:Date:MIME-Version; b=EvoQWEPn6+aJ7OysISOue95GBqEH3etE/fPxXolkiY7Kmhwk++Wb9DGdIh+5Y4Wgn n4iEN4TXMtpeeFnvNL0nG3N0y5XlPpqinowcRLrbFwdCfqy5ctEGh5vBrVeFzdiuww u981UjGzk9dv5FbIz7OtNxKsnuWN/Rmth41Dz4k2/0LzNq8TvDddhbldxsrcNmaes0 TA145W2IKxaPzYBxkLvrsv3N+u1Ny4kuOT/e/Bcggx5ktbw/poTudnjdAfvGbxmHqM PSEFZvhFZZ1L0YjHBeD9XstF/Cg0bL3ir3tJcKbR+0juZ8x2oAcMYxo0dodDbJmK9c 8cDWRrTxrawqA== 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] ads7846: always set last command to PWRDOWN Date: Tue, 29 Nov 2022 16:19:58 +0100 Message-Id: <20221129151959.26052-3-l.ellero@asem.it> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221129151959.26052-1-l.ellero@asem.it> References: <20221129151959.26052-1-l.ellero@asem.it> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CMAE-Envelope: MS4xfAmA3u28NvvV4JGz2hpRmeIayrM1Psfe+/ROG4Pc5pcbewBBCWDiNDpCFeyPYwVYM80csFMbbKUZ3XJG/cmlxqQkfGE1tCpBO72NEMQqgs409Sl0IJe8 WdKCYuFi7Cimg+x3BdKcXcV57LD0oMM5q4CQouGNwIvsBVD8U7pY6kzndCdQuTEHsGXt4byoe/LB41mNrwUGz35RgPTMb4H3WVlrJSetuS8u+E2jo0sZarZi c4KXesBtVAZWTH8TnHo1O+1ehgUpsXrNfrY0NKAWM1P6A1CCvDPKopS44bm3YdR8+GRCZqm6ASQ0KYaBfA6+2YJuQvmdwmtYN3VeRtOXI5IgOs1ibDFLwqnV +UuVkpmAAcIPV2TuP9yrRMo0BDQHhzMkS+79M14fUTWyA4GLqghnwdPmwf34RPItmIpdRozEyOe3U/1ZJAPGS0Xn+li5vLQLvOtUqpygp+as2j6fT3S4yETr T88OxdfG2xFhM8bvtwGJaJw/EBYltnV4Pwv3yTPdA9NvJz2J8SfCpaLO5F81NbXM9EV73+QLxzuv0Nv74bWfyh0a6Yeq8oX24ZlYMQ4mqUf693lvS5TyYFc0 GIHuMUBsrUj+csjCHeqNyeur X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, 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. This patch fixes it. 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 24605c40d039..9e15cdf6faa0 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