summaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-atmel.c
diff options
context:
space:
mode:
authorRichard Genoud <richard.genoud@gmail.com>2013-05-31 11:01:59 -0400
committerMark Brown <broonie@linaro.org>2013-06-03 11:22:50 -0400
commit2f767a9f6b9d06a7e6a7b9b2ce0b6f0888ea15fa (patch)
tree8b8da774a1555ecf78f7696931569a1ba23ac981 /drivers/spi/spi-atmel.c
parentd683b96b072dc4680fc74964eca77e6a23d1fa6e (diff)
spi: atmel: convert to dma_request_slave_channel_compat()
Use generic DMA DT helper. Platforms booting with or without DT populated are both supported. Based on Ludovic Desroches <ludovic.desroches@atmel.com> patchset "ARM: at91: move to generic DMA device tree binding" Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Acked-by: Ludovic Desroches <ludovic.desroches@gmail.com> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/spi/spi-atmel.c')
-rw-r--r--drivers/spi/spi-atmel.c42
1 files changed, 27 insertions, 15 deletions
diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
index 380387a47b1d..ceda43c91142 100644
--- a/drivers/spi/spi-atmel.c
+++ b/drivers/spi/spi-atmel.c
@@ -424,10 +424,15 @@ static int atmel_spi_dma_slave_config(struct atmel_spi *as,
424 return err; 424 return err;
425} 425}
426 426
427static bool filter(struct dma_chan *chan, void *slave) 427static bool filter(struct dma_chan *chan, void *pdata)
428{ 428{
429 struct at_dma_slave *sl = slave; 429 struct atmel_spi_dma *sl_pdata = pdata;
430 struct at_dma_slave *sl;
430 431
432 if (!sl_pdata)
433 return false;
434
435 sl = &sl_pdata->dma_slave;
431 if (sl->dma_dev == chan->device->dev) { 436 if (sl->dma_dev == chan->device->dev) {
432 chan->private = sl; 437 chan->private = sl;
433 return true; 438 return true;
@@ -438,24 +443,31 @@ static bool filter(struct dma_chan *chan, void *slave)
438 443
439static int atmel_spi_configure_dma(struct atmel_spi *as) 444static int atmel_spi_configure_dma(struct atmel_spi *as)
440{ 445{
441 struct at_dma_slave *sdata = &as->dma.dma_slave;
442 struct dma_slave_config slave_config; 446 struct dma_slave_config slave_config;
447 struct device *dev = &as->pdev->dev;
443 int err; 448 int err;
444 449
445 if (sdata && sdata->dma_dev) { 450 dma_cap_mask_t mask;
446 dma_cap_mask_t mask; 451 dma_cap_zero(mask);
452 dma_cap_set(DMA_SLAVE, mask);
447 453
448 /* Try to grab two DMA channels */ 454 as->dma.chan_tx = dma_request_slave_channel_compat(mask, filter,
449 dma_cap_zero(mask); 455 &as->dma,
450 dma_cap_set(DMA_SLAVE, mask); 456 dev, "tx");
451 as->dma.chan_tx = dma_request_channel(mask, filter, sdata); 457 if (!as->dma.chan_tx) {
452 if (as->dma.chan_tx) 458 dev_err(dev,
453 as->dma.chan_rx = 459 "DMA TX channel not available, SPI unable to use DMA\n");
454 dma_request_channel(mask, filter, sdata); 460 err = -EBUSY;
461 goto error;
455 } 462 }
456 if (!as->dma.chan_rx || !as->dma.chan_tx) { 463
457 dev_err(&as->pdev->dev, 464 as->dma.chan_rx = dma_request_slave_channel_compat(mask, filter,
458 "DMA channel not available, SPI unable to use DMA\n"); 465 &as->dma,
466 dev, "rx");
467
468 if (!as->dma.chan_rx) {
469 dev_err(dev,
470 "DMA RX channel not available, SPI unable to use DMA\n");
459 err = -EBUSY; 471 err = -EBUSY;
460 goto error; 472 goto error;
461 } 473 }