Commit 96fd881f authored by Brian Niebuhr's avatar Brian Niebuhr Committed by Sekhar Nori

spi: davinci: do not store DMA channel information per chip select

Do not store DMA channel related information per chip-select since
that information does not depend on the chip select.

The same DMA channels can be used for transfers on all chip-selects
since the transfer happens one-at-a-time.
Signed-off-by: default avatarBrian Niebuhr <bniebuhr@efjohnson.com>
Tested-By: default avatarMichael Williamson <michael.williamson@criticallink.com>
Signed-off-by: default avatarSekhar Nori <nsekhar@ti.com>
parent b23a5d46
...@@ -143,7 +143,7 @@ struct davinci_spi { ...@@ -143,7 +143,7 @@ struct davinci_spi {
u8 *tmp_buf; u8 *tmp_buf;
int rcount; int rcount;
int wcount; int wcount;
struct davinci_spi_dma *dma_channels; struct davinci_spi_dma dma_channels;
struct davinci_spi_platform_data *pdata; struct davinci_spi_platform_data *pdata;
void (*get_rx)(u32 rx_data, struct davinci_spi *); void (*get_rx)(u32 rx_data, struct davinci_spi *);
...@@ -407,7 +407,7 @@ static void davinci_spi_dma_rx_callback(unsigned lch, u16 ch_status, void *data) ...@@ -407,7 +407,7 @@ static void davinci_spi_dma_rx_callback(unsigned lch, u16 ch_status, void *data)
struct davinci_spi_dma *davinci_spi_dma; struct davinci_spi_dma *davinci_spi_dma;
davinci_spi = spi_master_get_devdata(spi->master); davinci_spi = spi_master_get_devdata(spi->master);
davinci_spi_dma = &(davinci_spi->dma_channels[spi->chip_select]); davinci_spi_dma = &davinci_spi->dma_channels;
if (ch_status == DMA_COMPLETE) if (ch_status == DMA_COMPLETE)
edma_stop(davinci_spi_dma->dma_rx_channel); edma_stop(davinci_spi_dma->dma_rx_channel);
...@@ -426,7 +426,7 @@ static void davinci_spi_dma_tx_callback(unsigned lch, u16 ch_status, void *data) ...@@ -426,7 +426,7 @@ static void davinci_spi_dma_tx_callback(unsigned lch, u16 ch_status, void *data)
struct davinci_spi_dma *davinci_spi_dma; struct davinci_spi_dma *davinci_spi_dma;
davinci_spi = spi_master_get_devdata(spi->master); davinci_spi = spi_master_get_devdata(spi->master);
davinci_spi_dma = &(davinci_spi->dma_channels[spi->chip_select]); davinci_spi_dma = &davinci_spi->dma_channels;
if (ch_status == DMA_COMPLETE) if (ch_status == DMA_COMPLETE)
edma_stop(davinci_spi_dma->dma_tx_channel); edma_stop(davinci_spi_dma->dma_tx_channel);
...@@ -446,7 +446,7 @@ static int davinci_spi_request_dma(struct spi_device *spi) ...@@ -446,7 +446,7 @@ static int davinci_spi_request_dma(struct spi_device *spi)
int r; int r;
davinci_spi = spi_master_get_devdata(spi->master); davinci_spi = spi_master_get_devdata(spi->master);
davinci_spi_dma = &davinci_spi->dma_channels[spi->chip_select]; davinci_spi_dma = &davinci_spi->dma_channels;
sdev = davinci_spi->bitbang.master->dev.parent; sdev = davinci_spi->bitbang.master->dev.parent;
r = edma_alloc_channel(davinci_spi_dma->dma_rx_sync_dev, r = edma_alloc_channel(davinci_spi_dma->dma_rx_sync_dev,
...@@ -509,8 +509,8 @@ static int davinci_spi_setup(struct spi_device *spi) ...@@ -509,8 +509,8 @@ static int davinci_spi_setup(struct spi_device *spi)
clear_io_bits(davinci_spi->base + SPIGCR1, clear_io_bits(davinci_spi->base + SPIGCR1,
SPIGCR1_LOOPBACK_MASK); SPIGCR1_LOOPBACK_MASK);
if (use_dma && davinci_spi->dma_channels) { if (use_dma) {
davinci_spi_dma = &davinci_spi->dma_channels[spi->chip_select]; davinci_spi_dma = &davinci_spi->dma_channels;
if ((davinci_spi_dma->dma_rx_channel == -1) || if ((davinci_spi_dma->dma_rx_channel == -1) ||
(davinci_spi_dma->dma_tx_channel == -1)) (davinci_spi_dma->dma_tx_channel == -1))
...@@ -522,13 +522,11 @@ static int davinci_spi_setup(struct spi_device *spi) ...@@ -522,13 +522,11 @@ static int davinci_spi_setup(struct spi_device *spi)
static void davinci_spi_cleanup(struct spi_device *spi) static void davinci_spi_cleanup(struct spi_device *spi)
{ {
struct davinci_spi *davinci_spi = spi_master_get_devdata(spi->master); if (use_dma) {
struct davinci_spi_dma *davinci_spi_dma; struct davinci_spi *davinci_spi =
spi_master_get_devdata(spi->master);
davinci_spi_dma = &davinci_spi->dma_channels[spi->chip_select]; struct davinci_spi_dma *davinci_spi_dma =
&davinci_spi->dma_channels;
if (use_dma && davinci_spi->dma_channels) {
davinci_spi_dma = &davinci_spi->dma_channels[spi->chip_select];
if ((davinci_spi_dma->dma_rx_channel != -1) if ((davinci_spi_dma->dma_rx_channel != -1)
&& (davinci_spi_dma->dma_tx_channel != -1)) { && (davinci_spi_dma->dma_tx_channel != -1)) {
...@@ -730,7 +728,7 @@ static int davinci_spi_bufs_dma(struct spi_device *spi, struct spi_transfer *t) ...@@ -730,7 +728,7 @@ static int davinci_spi_bufs_dma(struct spi_device *spi, struct spi_transfer *t)
davinci_spi = spi_master_get_devdata(spi->master); davinci_spi = spi_master_get_devdata(spi->master);
sdev = davinci_spi->bitbang.master->dev.parent; sdev = davinci_spi->bitbang.master->dev.parent;
davinci_spi_dma = &davinci_spi->dma_channels[spi->chip_select]; davinci_spi_dma = &davinci_spi->dma_channels;
tx_reg = (unsigned long)davinci_spi->pbase + SPIDAT1; tx_reg = (unsigned long)davinci_spi->pbase + SPIDAT1;
rx_reg = (unsigned long)davinci_spi->pbase + SPIBUF; rx_reg = (unsigned long)davinci_spi->pbase + SPIBUF;
...@@ -967,22 +965,13 @@ static int davinci_spi_probe(struct platform_device *pdev) ...@@ -967,22 +965,13 @@ static int davinci_spi_probe(struct platform_device *pdev)
use_dma = 0; use_dma = 0;
} else { } else {
davinci_spi->bitbang.txrx_bufs = davinci_spi_bufs_dma; davinci_spi->bitbang.txrx_bufs = davinci_spi_bufs_dma;
davinci_spi->dma_channels = kzalloc(master->num_chipselect
* sizeof(struct davinci_spi_dma), GFP_KERNEL);
if (davinci_spi->dma_channels == NULL) {
ret = -ENOMEM;
goto free_clk;
}
for (i = 0; i < master->num_chipselect; i++) { davinci_spi->dma_channels.dma_rx_channel = -1;
davinci_spi->dma_channels[i].dma_rx_channel = -1; davinci_spi->dma_channels.dma_rx_sync_dev = dma_rx_chan;
davinci_spi->dma_channels[i].dma_rx_sync_dev = davinci_spi->dma_channels.dma_tx_channel = -1;
dma_rx_chan; davinci_spi->dma_channels.dma_tx_sync_dev = dma_tx_chan;
davinci_spi->dma_channels[i].dma_tx_channel = -1; davinci_spi->dma_channels.eventq = dma_eventq;
davinci_spi->dma_channels[i].dma_tx_sync_dev =
dma_tx_chan;
davinci_spi->dma_channels[i].eventq = dma_eventq;
}
dev_info(&pdev->dev, "DaVinci SPI driver in EDMA mode\n" dev_info(&pdev->dev, "DaVinci SPI driver in EDMA mode\n"
"Using RX channel = %d , TX channel = %d and " "Using RX channel = %d , TX channel = %d and "
"event queue = %d", dma_rx_chan, dma_tx_chan, "event queue = %d", dma_rx_chan, dma_tx_chan,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment