spi: rspi: Fix loopback mode for Dual/Quad SPI Transfers
authorGeert Uytterhoeven <geert+renesas@linux-m68k.org>
Fri, 21 Feb 2014 16:29:18 +0000 (17:29 +0100)
committerMark Brown <broonie@linaro.org>
Sun, 23 Feb 2014 03:27:03 +0000 (12:27 +0900)
While normal Dual and Quad SPI Transfers are unidirectional, we must do
a bidirectional transfer if loopback mode is enabled, else rx_buf is not
filled.

With spidev it seemed to work, as spidev uses the same buffer for
tranmission and reception.

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
drivers/spi/spi-rspi.c

index 4a1f978c3381c9aaca15a4522e41a6767fa2393b..92bec7e91046fd67ba657d3e79dd0691708738a3 100644 (file)
@@ -859,7 +859,9 @@ static int qspi_transfer_one(struct spi_master *master, struct spi_device *spi,
 {
        struct rspi_data *rspi = spi_master_get_devdata(master);
 
-       if (xfer->tx_buf && xfer->tx_nbits > SPI_NBITS_SINGLE) {
+       if (spi->mode & SPI_LOOP) {
+               return qspi_transfer_out_in(rspi, xfer);
+       } else if (xfer->tx_buf && xfer->tx_nbits > SPI_NBITS_SINGLE) {
                /* Quad or Dual SPI Write */
                return qspi_transfer_out(rspi, xfer);
        } else if (xfer->rx_buf && xfer->rx_nbits > SPI_NBITS_SINGLE) {