mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Luca Ellero <luca.ellero@brickedbrain.com>
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
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	Luca Ellero <l.ellero@asem.it>
Subject: [PATCH v2 2/3] ads7846: always set last command to PWRDOWN
Date: Thu, 21 Jul 2022 10:34:57 +0200	[thread overview]
Message-ID: <20220721083458.6412-3-luca.ellero@brickedbrain.com> (raw)
In-Reply-To: <20220721083458.6412-1-luca.ellero@brickedbrain.com>

From: Luca Ellero <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.

This patch fixes it.

Signed-off-by: Luca Ellero <l.ellero@asem.it>
---
Changes for v2:
 - elaborate commit message

 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


  parent reply	other threads:[~2022-07-21  8:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-21  8:34 [PATCH v2 0/3] ads7846: fix support for ADS7845 Luca Ellero
2022-07-21  8:34 ` [PATCH v2 1/3] ads7846: don't report pressure for ads7845 Luca Ellero
2022-07-21 20:48   ` Uwe Kleine-König
2022-07-22  9:33     ` Luca Ellero
2022-07-29 13:50     ` Andy Shevchenko
2022-08-01  7:02       ` Luca Ellero
2022-07-21  8:34 ` Luca Ellero [this message]
2022-07-21  8:34 ` [PATCH v2 3/3] ads7846: don't check penirq immediately for 7845 Luca Ellero
2022-07-29 13:52 ` [PATCH v2 0/3] ads7846: fix support for ADS7845 Andy Shevchenko

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=20220721083458.6412-3-luca.ellero@brickedbrain.com \
    --to=luca.ellero@brickedbrain.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=daniel@zonque.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=imre.deak@nokia.com \
    --cc=l.ellero@asem.it \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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

all inboxes | Powered by JetHome®