Skip to content

Commit 05f7ea7

Browse files
andreamerellovinodkoul
authored andcommitted
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>
1 parent ae80969 commit 05f7ea7

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

drivers/dma/xilinx/xilinx_dma.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
#define XILINX_DMA_DMASR_DMA_DEC_ERR BIT(6)
8787
#define XILINX_DMA_DMASR_DMA_SLAVE_ERR BIT(5)
8888
#define XILINX_DMA_DMASR_DMA_INT_ERR BIT(4)
89+
#define XILINX_DMA_DMASR_SG_MASK BIT(3)
8990
#define XILINX_DMA_DMASR_IDLE BIT(1)
9091
#define XILINX_DMA_DMASR_HALTED BIT(0)
9192
#define XILINX_DMA_DMASR_DELAY_MASK GENMASK(31, 24)
@@ -414,7 +415,6 @@ struct xilinx_dma_config {
414415
* @dev: Device Structure
415416
* @common: DMA device structure
416417
* @chan: Driver specific DMA channel
417-
* @has_sg: Specifies whether Scatter-Gather is present or not
418418
* @mcdma: Specifies whether Multi-Channel is present or not
419419
* @flush_on_fsync: Flush on frame sync
420420
* @ext_addr: Indicates 64 bit addressing is supported by dma device
@@ -434,7 +434,6 @@ struct xilinx_dma_device {
434434
struct device *dev;
435435
struct dma_device common;
436436
struct xilinx_dma_chan *chan[XILINX_DMA_MAX_CHANS_PER_DEVICE];
437-
bool has_sg;
438437
bool mcdma;
439438
u32 flush_on_fsync;
440439
bool ext_addr;
@@ -2421,7 +2420,6 @@ static int xilinx_dma_chan_probe(struct xilinx_dma_device *xdev,
24212420

24222421
chan->dev = xdev->dev;
24232422
chan->xdev = xdev;
2424-
chan->has_sg = xdev->has_sg;
24252423
chan->desc_pendingcount = 0x0;
24262424
chan->ext_addr = xdev->ext_addr;
24272425
/* This variable ensures that descriptors are not
@@ -2521,6 +2519,15 @@ static int xilinx_dma_chan_probe(struct xilinx_dma_device *xdev,
25212519
chan->stop_transfer = xilinx_dma_stop_transfer;
25222520
}
25232521

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+
25242531
/* Initialize the tasklet */
25252532
tasklet_init(&chan->tasklet, xilinx_dma_do_tasklet,
25262533
(unsigned long)chan);
@@ -2659,7 +2666,6 @@ static int xilinx_dma_probe(struct platform_device *pdev)
26592666
return PTR_ERR(xdev->regs);
26602667

26612668
/* Retrieve the DMA engine properties from the device tree */
2662-
xdev->has_sg = of_property_read_bool(node, "xlnx,include-sg");
26632669
xdev->max_buffer_len = GENMASK(XILINX_DMA_MAX_TRANS_LEN_MAX - 1, 0);
26642670

26652671
if (xdev->dma_config->dmatype == XDMA_TYPE_AXIDMA) {

0 commit comments

Comments
 (0)