Skip to content

Commit 8d8bef5

Browse files
l1kbroonie
authored andcommitted
spi: bcm2835: Fix 3-wire mode if DMA is enabled
Commit 6935224 ("spi: bcm2835: enable support of 3-wire mode") added 3-wire support to the BCM2835 SPI driver by setting the REN bit (Read Enable) in the CS register when receiving data. The REN bit puts the transmitter in high-impedance state. The driver recognizes that data is to be received by checking whether the rx_buf of a transfer is non-NULL. Commit 3ecd37e ("spi: bcm2835: enable dma modes for transfers meeting certain conditions") subsequently broke 3-wire support because it set the SPI_MASTER_MUST_RX flag which causes spi_map_msg() to replace rx_buf with a dummy buffer if it is NULL. As a result, rx_buf is *always* non-NULL if DMA is enabled. Reinstate 3-wire support by not only checking whether rx_buf is non-NULL, but also checking that it is not the dummy buffer. Fixes: 3ecd37e ("spi: bcm2835: enable dma modes for transfers meeting certain conditions") Reported-by: Nuno Sá <[email protected]> Signed-off-by: Lukas Wunner <[email protected]> Cc: [email protected] # v4.2+ Cc: Martin Sperl <[email protected]> Acked-by: Stefan Wahren <[email protected]> Link: https://lore.kernel.org/r/328318841455e505370ef8ecad97b646c033dc8a.1562148527.git.lukas@wunner.de Signed-off-by: Mark Brown <[email protected]>
1 parent 1274204 commit 8d8bef5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/spi/spi-bcm2835.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,8 @@ static int bcm2835_spi_transfer_one(struct spi_controller *ctlr,
834834
bcm2835_wr(bs, BCM2835_SPI_CLK, cdiv);
835835

836836
/* handle all the 3-wire mode */
837-
if ((spi->mode & SPI_3WIRE) && (tfr->rx_buf))
837+
if (spi->mode & SPI_3WIRE && tfr->rx_buf &&
838+
tfr->rx_buf != ctlr->dummy_rx)
838839
cs |= BCM2835_SPI_CS_REN;
839840
else
840841
cs &= ~BCM2835_SPI_CS_REN;

0 commit comments

Comments
 (0)