summaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
authorGeert Uytterhoeven <geert+renesas@glider.be>2014-06-02 09:38:11 -0400
committerMark Brown <broonie@linaro.org>2014-06-02 10:49:34 -0400
commit5f338d0ce0b4c9e6c554b92cfb288789a41bfbc1 (patch)
tree3f89d35aa78e6d382f6097c63194bd4d96526881 /drivers/spi
parentfcdc49ae53dc8cfc1a7758607bca68935f568ca2 (diff)
spi: rspi: SPI DMA core needs both RX and TX DMA to function
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@glider.be> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/spi-rspi.c36
1 files 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:
640 640
641static int rspi_is_dma(const struct rspi_data *rspi, struct spi_transfer *t) 641static int rspi_is_dma(const struct rspi_data *rspi, struct spi_transfer *t)
642{ 642{
643 /* If the module receives data by DMAC, it also needs TX DMAC */
644 if (t->rx_buf)
645 return rspi->chan_tx && rspi->chan_rx;
646
647 if (rspi->chan_tx) 643 if (rspi->chan_tx)
648 return 1; 644 return 1;
649 645
@@ -985,29 +981,25 @@ static int rspi_request_dma(struct device *dev, struct rspi_data *rspi,
985{ 981{
986 const struct rspi_plat_data *rspi_pd = dev_get_platdata(dev); 982 const struct rspi_plat_data *rspi_pd = dev_get_platdata(dev);
987 983
988 if (!rspi_pd) 984 if (!rspi_pd || !rspi_pd->dma_rx_id || !rspi_pd->dma_tx_id)
989 return 0; /* The driver assumes no error. */ 985 return 0; /* The driver assumes no error. */
990 986
991 /* If the module receives data by DMAC, it also needs TX DMAC */ 987 rspi->chan_rx = rspi_request_dma_chan(dev, DMA_DEV_TO_MEM,
992 if (rspi_pd->dma_rx_id && rspi_pd->dma_tx_id) { 988 rspi_pd->dma_rx_id,
993 rspi->chan_rx = rspi_request_dma_chan(dev, DMA_DEV_TO_MEM, 989 res->start + RSPI_SPDR);
994 rspi_pd->dma_rx_id, 990 if (!rspi->chan_rx)
995 res->start + RSPI_SPDR); 991 return -ENODEV;
996 if (!rspi->chan_rx)
997 return -ENODEV;
998 992
999 dev_info(dev, "Use DMA when rx.\n"); 993 rspi->chan_tx = rspi_request_dma_chan(dev, DMA_MEM_TO_DEV,
1000 } 994 rspi_pd->dma_tx_id,
1001 if (rspi_pd->dma_tx_id) { 995 res->start + RSPI_SPDR);
1002 rspi->chan_tx = rspi_request_dma_chan(dev, DMA_MEM_TO_DEV, 996 if (!rspi->chan_tx) {
1003 rspi_pd->dma_tx_id, 997 dma_release_channel(rspi->chan_rx);
1004 res->start + RSPI_SPDR); 998 rspi->chan_rx = NULL;
1005 if (!rspi->chan_tx) 999 return -ENODEV;
1006 return -ENODEV;
1007
1008 dev_info(dev, "Use DMA when tx\n");
1009 } 1000 }
1010 1001
1002 dev_info(dev, "DMA available");
1011 return 0; 1003 return 0;
1012} 1004}
1013 1005