linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luca Ellero <l.ellero@asem.it>
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 <l.ellero@asem.it>
Subject: [PATCH 2/3] Input: ads7846 - always set last command to PWRDOWN
Date: Fri, 20 Jan 2023 13:45:43 +0100	[thread overview]
Message-ID: <20230120124544.5993-3-l.ellero@asem.it> (raw)
In-Reply-To: <20230120124544.5993-1-l.ellero@asem.it>

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 <l.ellero@asem.it>
---
 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


  parent reply	other threads:[~2023-01-20 13:04 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-20 12:45 [PATCH v4 0/3] Input: ads7846 - fix support for ADS7845 Luca Ellero
2023-01-20 12:45 ` [PATCH 1/3] Input: ads7846 - don't report pressure for ads7845 Luca Ellero
2023-01-20 15:16   ` Andy Shevchenko
2023-01-23  8:27     ` Luca Ellero
2023-01-23 12:25       ` Andy Shevchenko
2023-01-24  8:40         ` Luca Ellero
2023-01-20 12:45 ` Luca Ellero [this message]
2023-01-20 15:17   ` [PATCH 2/3] Input: ads7846 - always set last command to PWRDOWN Andy Shevchenko
2023-01-20 12:45 ` [PATCH 3/3] Input: ads7846 - don't check penirq immediately for 7845 Luca Ellero
2023-01-20 15:18   ` Andy Shevchenko
2023-01-20 15:18 ` [PATCH v4 0/3] Input: ads7846 - fix support for ADS7845 Andy Shevchenko
2023-01-26 10:52 [PATCH v5 " Luca Ellero
2023-01-26 10:52 ` [PATCH 2/3] Input: ads7846 - always set last command to PWRDOWN Luca Ellero

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230120124544.5993-3-l.ellero@asem.it \
    --to=l.ellero@asem.it \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=daniel@zonque.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=imre.deak@nokia.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luca.ellero@brickedbrain.com \
    --cc=m.felsch@pengutronix.de \
    --cc=miquel.raynal@bootlin.com \
    --cc=mkl@pengutronix.de \
    --cc=u.kleine-koenig@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).