Skip to content

Commit 0d5c395

Browse files
groeckbroonie
authored andcommitted
spi: mediatek: Fix fifo transfer
Commit 3a70dd2 ("spi: mediatek: fix fifo rx mode") claims that fifo RX mode was never handled, and adds the presumably missing code to the FIFO transfer function. However, the claim that receive data was not handled is incorrect. It was handled as part of interrupt handling after the transfer was complete. The code added with the above mentioned commit reads data from the receive FIFO before the transfer is started, which is wrong. This results in an actual transfer error on a Hayato Chromebook. Remove the code trying to handle receive data before the transfer is started to fix the problem. Fixes: 3a70dd2 ("spi: mediatek: fix fifo rx mode") Cc: Peter Hess <[email protected]> Cc: Frank Wunderlich <[email protected]> Cc: Tzung-Bi Shih <[email protected]> Cc: Hsin-Yi Wang <[email protected]> Signed-off-by: Guenter Roeck <[email protected]> Tested-by: Hsin-Yi Wang <[email protected]> Tested-by: Tzung-Bi Shih <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 36c2530 commit 0d5c395

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

drivers/spi/spi-mt65xx.c

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -426,24 +426,15 @@ static int mtk_spi_fifo_transfer(struct spi_master *master,
426426
mtk_spi_prepare_transfer(master, xfer);
427427
mtk_spi_setup_packet(master);
428428

429-
cnt = xfer->len / 4;
430-
if (xfer->tx_buf)
429+
if (xfer->tx_buf) {
430+
cnt = xfer->len / 4;
431431
iowrite32_rep(mdata->base + SPI_TX_DATA_REG, xfer->tx_buf, cnt);
432-
433-
if (xfer->rx_buf)
434-
ioread32_rep(mdata->base + SPI_RX_DATA_REG, xfer->rx_buf, cnt);
435-
436-
remainder = xfer->len % 4;
437-
if (remainder > 0) {
438-
reg_val = 0;
439-
if (xfer->tx_buf) {
432+
remainder = xfer->len % 4;
433+
if (remainder > 0) {
434+
reg_val = 0;
440435
memcpy(&reg_val, xfer->tx_buf + (cnt * 4), remainder);
441436
writel(reg_val, mdata->base + SPI_TX_DATA_REG);
442437
}
443-
if (xfer->rx_buf) {
444-
reg_val = readl(mdata->base + SPI_RX_DATA_REG);
445-
memcpy(xfer->rx_buf + (cnt * 4), &reg_val, remainder);
446-
}
447438
}
448439

449440
mtk_spi_enable_transfer(master);

0 commit comments

Comments
 (0)