summaryrefslogtreecommitdiffstats
path: root/drivers/dma
diff options
context:
space:
mode:
authorAndrea Merello <andrea.merello@gmail.com>2018-11-20 10:31:49 -0500
committerVinod Koul <vkoul@kernel.org>2019-01-06 23:23:12 -0500
commit05f7ea7f6ef611a077fcbb983fb8d6a99e91e1f6 (patch)
treed2e03103101f54b9161f01d839953dfcad229048 /drivers/dma
parentae809690b46a71dc56cda5b3b8884c8c41a0df15 (diff)
dmaengine: xilinx_dma: autodetect whether the HW supports scatter-gather
The AXIDMA and CDMA HW can be either direct-access or scatter-gather version. These are SW incompatible. The driver can handle both versions: a DT property was used to tell the driver whether to assume the HW is in scatter-gather mode. This patch makes the driver to autodetect this information. The DT property is not required anymore. No changes for VDMA. Cc: Rob Herring <robh+dt@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: devicetree@vger.kernel.org Cc: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com> Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Reviewed-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com> Signed-off-by: Vinod Koul <vkoul@kernel.org>
Diffstat (limited to 'drivers/dma')
-rw-r--r--drivers/dma/xilinx/xilinx_dma.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dma.c
index d59af2b33a99..b559efe06adb 100644
--- a/drivers/dma/xilinx/xilinx_dma.c
+++ b/drivers/dma/xilinx/xilinx_dma.c
@@ -86,6 +86,7 @@
86#define XILINX_DMA_DMASR_DMA_DEC_ERR BIT(6) 86#define XILINX_DMA_DMASR_DMA_DEC_ERR BIT(6)
87#define XILINX_DMA_DMASR_DMA_SLAVE_ERR BIT(5) 87#define XILINX_DMA_DMASR_DMA_SLAVE_ERR BIT(5)
88#define XILINX_DMA_DMASR_DMA_INT_ERR BIT(4) 88#define XILINX_DMA_DMASR_DMA_INT_ERR BIT(4)
89#define XILINX_DMA_DMASR_SG_MASK BIT(3)
89#define XILINX_DMA_DMASR_IDLE BIT(1) 90#define XILINX_DMA_DMASR_IDLE BIT(1)
90#define XILINX_DMA_DMASR_HALTED BIT(0) 91#define XILINX_DMA_DMASR_HALTED BIT(0)
91#define XILINX_DMA_DMASR_DELAY_MASK GENMASK(31, 24) 92#define XILINX_DMA_DMASR_DELAY_MASK GENMASK(31, 24)
@@ -414,7 +415,6 @@ struct xilinx_dma_config {
414 * @dev: Device Structure 415 * @dev: Device Structure
415 * @common: DMA device structure 416 * @common: DMA device structure
416 * @chan: Driver specific DMA channel 417 * @chan: Driver specific DMA channel
417 * @has_sg: Specifies whether Scatter-Gather is present or not
418 * @mcdma: Specifies whether Multi-Channel is present or not 418 * @mcdma: Specifies whether Multi-Channel is present or not
419 * @flush_on_fsync: Flush on frame sync 419 * @flush_on_fsync: Flush on frame sync
420 * @ext_addr: Indicates 64 bit addressing is supported by dma device 420 * @ext_addr: Indicates 64 bit addressing is supported by dma device
@@ -434,7 +434,6 @@ struct xilinx_dma_device {
434 struct device *dev; 434 struct device *dev;
435 struct dma_device common; 435 struct dma_device common;
436 struct xilinx_dma_chan *chan[XILINX_DMA_MAX_CHANS_PER_DEVICE]; 436 struct xilinx_dma_chan *chan[XILINX_DMA_MAX_CHANS_PER_DEVICE];
437 bool has_sg;
438 bool mcdma; 437 bool mcdma;
439 u32 flush_on_fsync; 438 u32 flush_on_fsync;
440 bool ext_addr; 439 bool ext_addr;
@@ -2421,7 +2420,6 @@ static int xilinx_dma_chan_probe(struct xilinx_dma_device *xdev,
2421 2420
2422 chan->dev = xdev->dev; 2421 chan->dev = xdev->dev;
2423 chan->xdev = xdev; 2422 chan->xdev = xdev;
2424 chan->has_sg = xdev->has_sg;
2425 chan->desc_pendingcount = 0x0; 2423 chan->desc_pendingcount = 0x0;
2426 chan->ext_addr = xdev->ext_addr; 2424 chan->ext_addr = xdev->ext_addr;
2427 /* This variable ensures that descriptors are not 2425 /* This variable ensures that descriptors are not
@@ -2521,6 +2519,15 @@ static int xilinx_dma_chan_probe(struct xilinx_dma_device *xdev,
2521 chan->stop_transfer = xilinx_dma_stop_transfer; 2519 chan->stop_transfer = xilinx_dma_stop_transfer;
2522 } 2520 }
2523 2521
2522 /* check if SG is enabled (only for AXIDMA and CDMA) */
2523 if (xdev->dma_config->dmatype != XDMA_TYPE_VDMA) {
2524 if (dma_ctrl_read(chan, XILINX_DMA_REG_DMASR) &
2525 XILINX_DMA_DMASR_SG_MASK)
2526 chan->has_sg = true;
2527 dev_dbg(chan->dev, "ch %d: SG %s\n", chan->id,
2528 chan->has_sg ? "enabled" : "disabled");
2529 }
2530
2524 /* Initialize the tasklet */ 2531 /* Initialize the tasklet */
2525 tasklet_init(&chan->tasklet, xilinx_dma_do_tasklet, 2532 tasklet_init(&chan->tasklet, xilinx_dma_do_tasklet,
2526 (unsigned long)chan); 2533 (unsigned long)chan);
@@ -2659,7 +2666,6 @@ static int xilinx_dma_probe(struct platform_device *pdev)
2659 return PTR_ERR(xdev->regs); 2666 return PTR_ERR(xdev->regs);
2660 2667
2661 /* Retrieve the DMA engine properties from the device tree */ 2668 /* Retrieve the DMA engine properties from the device tree */
2662 xdev->has_sg = of_property_read_bool(node, "xlnx,include-sg");
2663 xdev->max_buffer_len = GENMASK(XILINX_DMA_MAX_TRANS_LEN_MAX - 1, 0); 2669 xdev->max_buffer_len = GENMASK(XILINX_DMA_MAX_TRANS_LEN_MAX - 1, 0);
2664 2670
2665 if (xdev->dma_config->dmatype == XDMA_TYPE_AXIDMA) { 2671 if (xdev->dma_config->dmatype == XDMA_TYPE_AXIDMA) {