Skip to content

Commit 781a07d

Browse files
Marek Vasutdtor
authored andcommitted
Input: ads7846 - add dummy command register clearing cycle
On STM32MP135F with XPT2046 touch controller attached to SPI bus, it has been observed that the touch controller locks up after Linux kernel has finished booting. Adding a dummy cycle on the SPI bus seems to mitigate the lock up. The XPTEK XPT2046 controller seems to be an identical clone of TI TSC2046, the datasheet seems to be a clone of the TI part as well, text seem to be word to word identical, except all the pictures have been drawn again. This touch controller is present e.g. on WaveShare 3.2inch RPi LCD (B) panel, the DTO provided by WaveShare uses 50 kHz SPI clock for this touch controller, which is unusually low and possibly might have been used as some sort of workaround for an issue. The SPI LCD on the same bus uses 16 MHz clock. SPI bus DT properties spi-cs-setup-delay-ns, spi-cs-hold-delay-ns, spi-cs-inactive-delay-ns, spi-rx-delay-us, spi-tx-delay-us set to range of 500ns..5us seem to have no impact on the behavior of the touch controller, the lock up always occurs. The STM32MP13xx SPI controller users GPIO control for the nCS pins. Since the dummy cycle happens after the controller has been put into power down mode and both ADC and REF regulators have been disabled, the cycle should have no impact on the configuration of the controller, i.e. it should be a NOP. It is unclear whether this problem is specific to this cloned XPT2046 controller, or whether this is also present on TSC2046. A test on either TSC2046 or ADS7846 would be very welcome. Signed-off-by: Marek Vasut <marex@denx.de> Link: https://lore.kernel.org/r/20240320072533.170029-1-marex@denx.de Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent 57a0636 commit 781a07d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

drivers/input/touchscreen/ads7846.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,9 +405,19 @@ static int ads7846_read12_ser(struct device *dev, unsigned command)
405405

406406
req->xfer[5].rx_buf = &req->scratch;
407407
req->xfer[5].len = 2;
408-
CS_CHANGE(req->xfer[5]);
409408
spi_message_add_tail(&req->xfer[5], &req->msg);
410409

410+
/* clear the command register */
411+
req->scratch = 0;
412+
req->xfer[6].tx_buf = &req->scratch;
413+
req->xfer[6].len = 1;
414+
spi_message_add_tail(&req->xfer[6], &req->msg);
415+
416+
req->xfer[7].rx_buf = &req->scratch;
417+
req->xfer[7].len = 2;
418+
CS_CHANGE(req->xfer[7]);
419+
spi_message_add_tail(&req->xfer[7], &req->msg);
420+
411421
mutex_lock(&ts->lock);
412422
ads7846_stop(ts);
413423
status = spi_sync(spi, &req->msg);

0 commit comments

Comments
 (0)