|
@@ -23,7 +23,6 @@
|
|
|
#include <linux/clk.h>
|
|
|
#include <linux/dmaengine.h>
|
|
|
#include <linux/dma-mapping.h>
|
|
|
-#include <linux/edma.h>
|
|
|
#include <linux/of.h>
|
|
|
#include <linux/of_device.h>
|
|
|
#include <linux/of_gpio.h>
|
|
@@ -33,8 +32,6 @@
|
|
|
|
|
|
#include <linux/platform_data/spi-davinci.h>
|
|
|
|
|
|
-#define SPI_NO_RESOURCE ((resource_size_t)-1)
|
|
|
-
|
|
|
#define CS_DEFAULT 0xFF
|
|
|
|
|
|
#define SPIFMT_PHASE_MASK BIT(16)
|
|
@@ -130,8 +127,6 @@ struct davinci_spi {
|
|
|
|
|
|
struct dma_chan *dma_rx;
|
|
|
struct dma_chan *dma_tx;
|
|
|
- int dma_rx_chnum;
|
|
|
- int dma_tx_chnum;
|
|
|
|
|
|
struct davinci_spi_platform_data pdata;
|
|
|
|
|
@@ -797,35 +792,19 @@ static irqreturn_t davinci_spi_irq(s32 irq, void *data)
|
|
|
|
|
|
static int davinci_spi_request_dma(struct davinci_spi *dspi)
|
|
|
{
|
|
|
- dma_cap_mask_t mask;
|
|
|
struct device *sdev = dspi->bitbang.master->dev.parent;
|
|
|
- int r;
|
|
|
-
|
|
|
- dma_cap_zero(mask);
|
|
|
- dma_cap_set(DMA_SLAVE, mask);
|
|
|
|
|
|
- dspi->dma_rx = dma_request_channel(mask, edma_filter_fn,
|
|
|
- &dspi->dma_rx_chnum);
|
|
|
- if (!dspi->dma_rx) {
|
|
|
- dev_err(sdev, "request RX DMA channel failed\n");
|
|
|
- r = -ENODEV;
|
|
|
- goto rx_dma_failed;
|
|
|
- }
|
|
|
+ dspi->dma_rx = dma_request_chan(sdev, "rx");
|
|
|
+ if (IS_ERR(dspi->dma_rx))
|
|
|
+ return PTR_ERR(dspi->dma_rx);
|
|
|
|
|
|
- dspi->dma_tx = dma_request_channel(mask, edma_filter_fn,
|
|
|
- &dspi->dma_tx_chnum);
|
|
|
- if (!dspi->dma_tx) {
|
|
|
- dev_err(sdev, "request TX DMA channel failed\n");
|
|
|
- r = -ENODEV;
|
|
|
- goto tx_dma_failed;
|
|
|
+ dspi->dma_tx = dma_request_chan(sdev, "tx");
|
|
|
+ if (IS_ERR(dspi->dma_tx)) {
|
|
|
+ dma_release_channel(dspi->dma_rx);
|
|
|
+ return PTR_ERR(dspi->dma_tx);
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
|
-
|
|
|
-tx_dma_failed:
|
|
|
- dma_release_channel(dspi->dma_rx);
|
|
|
-rx_dma_failed:
|
|
|
- return r;
|
|
|
}
|
|
|
|
|
|
#if defined(CONFIG_OF)
|
|
@@ -936,8 +915,6 @@ static int davinci_spi_probe(struct platform_device *pdev)
|
|
|
struct davinci_spi *dspi;
|
|
|
struct davinci_spi_platform_data *pdata;
|
|
|
struct resource *r;
|
|
|
- resource_size_t dma_rx_chan = SPI_NO_RESOURCE;
|
|
|
- resource_size_t dma_tx_chan = SPI_NO_RESOURCE;
|
|
|
int ret = 0;
|
|
|
u32 spipc0;
|
|
|
|
|
@@ -1044,27 +1021,15 @@ static int davinci_spi_probe(struct platform_device *pdev)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- r = platform_get_resource(pdev, IORESOURCE_DMA, 0);
|
|
|
- if (r)
|
|
|
- dma_rx_chan = r->start;
|
|
|
- r = platform_get_resource(pdev, IORESOURCE_DMA, 1);
|
|
|
- if (r)
|
|
|
- dma_tx_chan = r->start;
|
|
|
-
|
|
|
dspi->bitbang.txrx_bufs = davinci_spi_bufs;
|
|
|
- if (dma_rx_chan != SPI_NO_RESOURCE &&
|
|
|
- dma_tx_chan != SPI_NO_RESOURCE) {
|
|
|
- dspi->dma_rx_chnum = dma_rx_chan;
|
|
|
- dspi->dma_tx_chnum = dma_tx_chan;
|
|
|
-
|
|
|
- ret = davinci_spi_request_dma(dspi);
|
|
|
- if (ret)
|
|
|
- goto free_clk;
|
|
|
-
|
|
|
- dev_info(&pdev->dev, "DMA: supported\n");
|
|
|
- dev_info(&pdev->dev, "DMA: RX channel: %pa, TX channel: %pa, event queue: %d\n",
|
|
|
- &dma_rx_chan, &dma_tx_chan,
|
|
|
- pdata->dma_event_q);
|
|
|
+
|
|
|
+ ret = davinci_spi_request_dma(dspi);
|
|
|
+ if (ret == -EPROBE_DEFER) {
|
|
|
+ goto free_clk;
|
|
|
+ } else if (ret) {
|
|
|
+ dev_info(&pdev->dev, "DMA is not supported (%d)\n", ret);
|
|
|
+ dspi->dma_rx = NULL;
|
|
|
+ dspi->dma_tx = NULL;
|
|
|
}
|
|
|
|
|
|
dspi->get_rx = davinci_spi_rx_buf_u8;
|
|
@@ -1102,8 +1067,10 @@ static int davinci_spi_probe(struct platform_device *pdev)
|
|
|
return ret;
|
|
|
|
|
|
free_dma:
|
|
|
- dma_release_channel(dspi->dma_rx);
|
|
|
- dma_release_channel(dspi->dma_tx);
|
|
|
+ if (dspi->dma_rx) {
|
|
|
+ dma_release_channel(dspi->dma_rx);
|
|
|
+ dma_release_channel(dspi->dma_tx);
|
|
|
+ }
|
|
|
free_clk:
|
|
|
clk_disable_unprepare(dspi->clk);
|
|
|
free_master:
|
|
@@ -1134,6 +1101,11 @@ static int davinci_spi_remove(struct platform_device *pdev)
|
|
|
clk_disable_unprepare(dspi->clk);
|
|
|
spi_master_put(master);
|
|
|
|
|
|
+ if (dspi->dma_rx) {
|
|
|
+ dma_release_channel(dspi->dma_rx);
|
|
|
+ dma_release_channel(dspi->dma_tx);
|
|
|
+ }
|
|
|
+
|
|
|
return 0;
|
|
|
}
|
|
|
|