Skip to content

Commit 13f82ca

Browse files
Luca Ellerodtor
authored andcommitted
Input: ads7846 - always set last command to PWRDOWN
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. Fixes: ffa458c ("spi: ads7846 driver") Signed-off-by: Luca Ellero <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent d50584d commit 13f82ca

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

drivers/input/touchscreen/ads7846.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1066,6 +1066,9 @@ static int ads7846_setup_spi_msg(struct ads7846 *ts,
10661066
struct ads7846_buf_layout *l = &packet->l[cmd_idx];
10671067
unsigned int max_count;
10681068

1069+
if (cmd_idx == packet->cmds - 1)
1070+
cmd_idx = ADS7846_PWDOWN;
1071+
10691072
if (ads7846_cmd_need_settle(cmd_idx))
10701073
max_count = packet->count + packet->count_skip;
10711074
else
@@ -1102,7 +1105,12 @@ static int ads7846_setup_spi_msg(struct ads7846 *ts,
11021105

11031106
for (cmd_idx = 0; cmd_idx < packet->cmds; cmd_idx++) {
11041107
struct ads7846_buf_layout *l = &packet->l[cmd_idx];
1105-
u8 cmd = ads7846_get_cmd(cmd_idx, vref);
1108+
u8 cmd;
1109+
1110+
if (cmd_idx == packet->cmds - 1)
1111+
cmd_idx = ADS7846_PWDOWN;
1112+
1113+
cmd = ads7846_get_cmd(cmd_idx, vref);
11061114

11071115
for (b = 0; b < l->count; b++)
11081116
packet->tx[l->offset + b].cmd = cmd;

0 commit comments

Comments
 (0)