aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/davinci_spi.c
diff options
context:
space:
mode:
authorBrian Niebuhr <bniebuhr@efjohnson.com>2010-09-27 12:53:23 -0400
committerSekhar Nori <nsekhar@ti.com>2010-11-18 08:08:33 -0500
commit96fd881f22b44fc14772316a6b9231012393cda8 (patch)
tree6a722eadf218f8df49bfa84fb734b404de3ff6ce /drivers/spi/davinci_spi.c
parentb23a5d4691043e97bbfde8c2fb5b8fecdc400308 (diff)
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: Brian Niebuhr <bniebuhr@efjohnson.com> Tested-By: Michael Williamson <michael.williamson@criticallink.com> Signed-off-by: Sekhar Nori <nsekhar@ti.com>
Diffstat (limited to 'drivers/spi/davinci_spi.c')
-rw-r--r--drivers/spi/davinci_spi.c47
1 files changed, 18 insertions, 29 deletions
diff --git a/drivers/spi/davinci_spi.c b/drivers/spi/davinci_spi.c
index 77109dc11b09..4aa522134a90 100644
--- a/drivers/spi/davinci_spi.c
+++ b/drivers/spi/davinci_spi.c
@@ -143,7 +143,7 @@ struct davinci_spi {
143 u8 *tmp_buf; 143 u8 *tmp_buf;
144 int rcount; 144 int rcount;
145 int wcount; 145 int wcount;
146 struct davinci_spi_dma *dma_channels; 146 struct davinci_spi_dma dma_channels;
147 struct davinci_spi_platform_data *pdata; 147 struct davinci_spi_platform_data *pdata;
148 148
149 void (*get_rx)(u32 rx_data, struct davinci_spi *); 149 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 struct davinci_spi_dma *davinci_spi_dma; 407 struct davinci_spi_dma *davinci_spi_dma;
408 408
409 davinci_spi = spi_master_get_devdata(spi->master); 409 davinci_spi = spi_master_get_devdata(spi->master);
410 davinci_spi_dma = &(davinci_spi->dma_channels[spi->chip_select]); 410 davinci_spi_dma = &davinci_spi->dma_channels;
411 411
412 if (ch_status == DMA_COMPLETE) 412 if (ch_status == DMA_COMPLETE)
413 edma_stop(davinci_spi_dma->dma_rx_channel); 413 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 struct davinci_spi_dma *davinci_spi_dma; 426 struct davinci_spi_dma *davinci_spi_dma;
427 427
428 davinci_spi = spi_master_get_devdata(spi->master); 428 davinci_spi = spi_master_get_devdata(spi->master);
429 davinci_spi_dma = &(davinci_spi->dma_channels[spi->chip_select]); 429 davinci_spi_dma = &davinci_spi->dma_channels;
430 430
431 if (ch_status == DMA_COMPLETE) 431 if (ch_status == DMA_COMPLETE)
432 edma_stop(davinci_spi_dma->dma_tx_channel); 432 edma_stop(davinci_spi_dma->dma_tx_channel);
@@ -446,7 +446,7 @@ static int davinci_spi_request_dma(struct spi_device *spi)
446 int r; 446 int r;
447 447
448 davinci_spi = spi_master_get_devdata(spi->master); 448 davinci_spi = spi_master_get_devdata(spi->master);
449 davinci_spi_dma = &davinci_spi->dma_channels[spi->chip_select]; 449 davinci_spi_dma = &davinci_spi->dma_channels;
450 sdev = davinci_spi->bitbang.master->dev.parent; 450 sdev = davinci_spi->bitbang.master->dev.parent;
451 451
452 r = edma_alloc_channel(davinci_spi_dma->dma_rx_sync_dev, 452 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 clear_io_bits(davinci_spi->base + SPIGCR1, 509 clear_io_bits(davinci_spi->base + SPIGCR1,
510 SPIGCR1_LOOPBACK_MASK); 510 SPIGCR1_LOOPBACK_MASK);
511 511
512 if (use_dma && davinci_spi->dma_channels) { 512 if (use_dma) {
513 davinci_spi_dma = &davinci_spi->dma_channels[spi->chip_select]; 513 davinci_spi_dma = &davinci_spi->dma_channels;
514 514
515 if ((davinci_spi_dma->dma_rx_channel == -1) || 515 if ((davinci_spi_dma->dma_rx_channel == -1) ||
516 (davinci_spi_dma->dma_tx_channel == -1)) 516 (davinci_spi_dma->dma_tx_channel == -1))
@@ -522,13 +522,11 @@ static int davinci_spi_setup(struct spi_device *spi)
522 522
523static void davinci_spi_cleanup(struct spi_device *spi) 523static void davinci_spi_cleanup(struct spi_device *spi)
524{ 524{
525 struct davinci_spi *davinci_spi = spi_master_get_devdata(spi->master); 525 if (use_dma) {
526 struct davinci_spi_dma *davinci_spi_dma; 526 struct davinci_spi *davinci_spi =
527 527 spi_master_get_devdata(spi->master);
528 davinci_spi_dma = &davinci_spi->dma_channels[spi->chip_select]; 528 struct davinci_spi_dma *davinci_spi_dma =
529 529 &davinci_spi->dma_channels;
530 if (use_dma && davinci_spi->dma_channels) {
531 davinci_spi_dma = &davinci_spi->dma_channels[spi->chip_select];
532 530
533 if ((davinci_spi_dma->dma_rx_channel != -1) 531 if ((davinci_spi_dma->dma_rx_channel != -1)
534 && (davinci_spi_dma->dma_tx_channel != -1)) { 532 && (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 davinci_spi = spi_master_get_devdata(spi->master); 728 davinci_spi = spi_master_get_devdata(spi->master);
731 sdev = davinci_spi->bitbang.master->dev.parent; 729 sdev = davinci_spi->bitbang.master->dev.parent;
732 730
733 davinci_spi_dma = &davinci_spi->dma_channels[spi->chip_select]; 731 davinci_spi_dma = &davinci_spi->dma_channels;
734 732
735 tx_reg = (unsigned long)davinci_spi->pbase + SPIDAT1; 733 tx_reg = (unsigned long)davinci_spi->pbase + SPIDAT1;
736 rx_reg = (unsigned long)davinci_spi->pbase + SPIBUF; 734 rx_reg = (unsigned long)davinci_spi->pbase + SPIBUF;
@@ -967,22 +965,13 @@ static int davinci_spi_probe(struct platform_device *pdev)
967 use_dma = 0; 965 use_dma = 0;
968 } else { 966 } else {
969 davinci_spi->bitbang.txrx_bufs = davinci_spi_bufs_dma; 967 davinci_spi->bitbang.txrx_bufs = davinci_spi_bufs_dma;
970 davinci_spi->dma_channels = kzalloc(master->num_chipselect
971 * sizeof(struct davinci_spi_dma), GFP_KERNEL);
972 if (davinci_spi->dma_channels == NULL) {
973 ret = -ENOMEM;
974 goto free_clk;
975 }
976 968
977 for (i = 0; i < master->num_chipselect; i++) { 969 davinci_spi->dma_channels.dma_rx_channel = -1;
978 davinci_spi->dma_channels[i].dma_rx_channel = -1; 970 davinci_spi->dma_channels.dma_rx_sync_dev = dma_rx_chan;
979 davinci_spi->dma_channels[i].dma_rx_sync_dev = 971 davinci_spi->dma_channels.dma_tx_channel = -1;
980 dma_rx_chan; 972 davinci_spi->dma_channels.dma_tx_sync_dev = dma_tx_chan;
981 davinci_spi->dma_channels[i].dma_tx_channel = -1; 973 davinci_spi->dma_channels.eventq = dma_eventq;
982 davinci_spi->dma_channels[i].dma_tx_sync_dev = 974
983 dma_tx_chan;
984 davinci_spi->dma_channels[i].eventq = dma_eventq;
985 }
986 dev_info(&pdev->dev, "DaVinci SPI driver in EDMA mode\n" 975 dev_info(&pdev->dev, "DaVinci SPI driver in EDMA mode\n"
987 "Using RX channel = %d , TX channel = %d and " 976 "Using RX channel = %d , TX channel = %d and "
988 "event queue = %d", dma_rx_chan, dma_tx_chan, 977 "event queue = %d", dma_rx_chan, dma_tx_chan,