diff mbox series

[v4,01/13] spi: dw: Fix driving MOSI low while recieving

Message ID 20201016225755.302659-2-seanga2@gmail.com
State Accepted
Commit caf110798ccca5d1fe7e75ae73397212262b9ee9
Delegated to: Jagannadha Sutradharudu Teki
Headers show
Series riscv: Add SPI support for Kendryte K210 | expand

Commit Message

Sean Anderson Oct. 16, 2020, 10:57 p.m. UTC
The resting state of MOSI is high when nothing is driving it. If we drive
it low while recieving, it looks like we are transmitting 0x00 instead of
transmitting nothing. This can confuse slaves (like SD cards) which allow
new commands to be sent over MOSI while they are returning data over MISO.
The return of MOSI from 0 to 1 at the end of recieving a byte can look like
a start bit and a transmission bit to an SD card. This will cause the card
to become out-of-sync with the SPI device, as it thinks the device has
already started transmitting two bytes of a new command. The mmc-spi driver
will not detect the R1 response from the SD card, since it is sent too
early, and offset by two bits. This patch fixes transfer errors when using
SD cards with dw spi.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
---

Changes in v4:
- New

 drivers/spi/designware_spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/spi/designware_spi.c b/drivers/spi/designware_spi.c
index 2559aac2e9..74372171aa 100644
--- a/drivers/spi/designware_spi.c
+++ b/drivers/spi/designware_spi.c
@@ -322,7 +322,7 @@  static inline u32 rx_max(struct dw_spi_priv *priv)
 static void dw_writer(struct dw_spi_priv *priv)
 {
 	u32 max = tx_max(priv);
-	u16 txw = 0;
+	u16 txw = 0xFFFF;
 
 	while (max--) {
 		/* Set the tx word if the transfer's original "tx" is not null */