[PATCH 09/18] spi: rspi: SPI DMA core needs both RX and TX DMA to function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The SPI DMA core framework needs both RX and TX DMA to function.  As a
preparation for converting the driver to use this framework, fall back to
PIO if no DMA channel or only one DMA channel is available.

This affects only RSPI, which could do DMA transfers for TX-only before.
RSPI-RZ and QSPI (at least for Single SPI Transfers) will need both RX and
TX DMA anyway.

Signed-off-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>
---
 drivers/spi/spi-rspi.c | 36 ++++++++++++++----------------------
 1 file changed, 14 insertions(+), 22 deletions(-)

diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index 1ec51cb00203..7b993f75a3cf 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -640,10 +640,6 @@ end_tx_mapped:
 
 static int rspi_is_dma(const struct rspi_data *rspi, struct spi_transfer *t)
 {
-	/* If the module receives data by DMAC, it also needs TX DMAC */
-	if (t->rx_buf)
-		return rspi->chan_tx && rspi->chan_rx;
-
 	if (rspi->chan_tx)
 		return 1;
 
@@ -985,29 +981,25 @@ static int rspi_request_dma(struct device *dev, struct rspi_data *rspi,
 {
 	const struct rspi_plat_data *rspi_pd = dev_get_platdata(dev);
 
-	if (!rspi_pd)
+	if (!rspi_pd || !rspi_pd->dma_rx_id || !rspi_pd->dma_tx_id)
 		return 0;	/* The driver assumes no error. */
 
-	/* If the module receives data by DMAC, it also needs TX DMAC */
-	if (rspi_pd->dma_rx_id && rspi_pd->dma_tx_id) {
-		rspi->chan_rx = rspi_request_dma_chan(dev, DMA_DEV_TO_MEM,
-						      rspi_pd->dma_rx_id,
-						      res->start + RSPI_SPDR);
-		if (!rspi->chan_rx)
-			return -ENODEV;
+	rspi->chan_rx = rspi_request_dma_chan(dev, DMA_DEV_TO_MEM,
+					      rspi_pd->dma_rx_id,
+					      res->start + RSPI_SPDR);
+	if (!rspi->chan_rx)
+		return -ENODEV;
 
-		dev_info(dev, "Use DMA when rx.\n");
-	}
-	if (rspi_pd->dma_tx_id) {
-		rspi->chan_tx = rspi_request_dma_chan(dev, DMA_MEM_TO_DEV,
-						      rspi_pd->dma_tx_id,
-						      res->start + RSPI_SPDR);
-		if (!rspi->chan_tx)
-			return -ENODEV;
-
-		dev_info(dev, "Use DMA when tx\n");
+	rspi->chan_tx = rspi_request_dma_chan(dev, DMA_MEM_TO_DEV,
+					      rspi_pd->dma_tx_id,
+					      res->start + RSPI_SPDR);
+	if (!rspi->chan_tx) {
+		dma_release_channel(rspi->chan_rx);
+		rspi->chan_rx = NULL;
+		return -ENODEV;
 	}
 
+	dev_info(dev, "DMA available");
 	return 0;
 }
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux