|
161 | 161 | #define XILINX_DMA_REG_BTT 0x28
|
162 | 162 |
|
163 | 163 | /* AXI DMA Specific Masks/Bit fields */
|
164 |
| -#define XILINX_DMA_MAX_TRANS_LEN GENMASK(22, 0) |
| 164 | +#define XILINX_DMA_MAX_TRANS_LEN_MIN 8 |
| 165 | +#define XILINX_DMA_MAX_TRANS_LEN_MAX 23 |
| 166 | +#define XILINX_DMA_V2_MAX_TRANS_LEN_MAX 26 |
165 | 167 | #define XILINX_DMA_CR_COALESCE_MAX GENMASK(23, 16)
|
166 | 168 | #define XILINX_DMA_CR_CYCLIC_BD_EN_MASK BIT(4)
|
167 | 169 | #define XILINX_DMA_CR_COALESCE_SHIFT 16
|
@@ -2626,7 +2628,7 @@ static int xilinx_dma_probe(struct platform_device *pdev)
|
2626 | 2628 | struct xilinx_dma_device *xdev;
|
2627 | 2629 | struct device_node *child, *np = pdev->dev.of_node;
|
2628 | 2630 | struct resource *io;
|
2629 |
| - u32 num_frames, addr_width; |
| 2631 | + u32 num_frames, addr_width, len_width; |
2630 | 2632 | int i, err;
|
2631 | 2633 |
|
2632 | 2634 | /* Allocate and initialize the DMA engine structure */
|
@@ -2658,10 +2660,24 @@ static int xilinx_dma_probe(struct platform_device *pdev)
|
2658 | 2660 |
|
2659 | 2661 | /* Retrieve the DMA engine properties from the device tree */
|
2660 | 2662 | xdev->has_sg = of_property_read_bool(node, "xlnx,include-sg");
|
2661 |
| - xdev->max_buffer_len = XILINX_DMA_MAX_TRANS_LEN; |
| 2663 | + xdev->max_buffer_len = GENMASK(XILINX_DMA_MAX_TRANS_LEN_MAX - 1, 0); |
2662 | 2664 |
|
2663 |
| - if (xdev->dma_config->dmatype == XDMA_TYPE_AXIDMA) |
| 2665 | + if (xdev->dma_config->dmatype == XDMA_TYPE_AXIDMA) { |
2664 | 2666 | xdev->mcdma = of_property_read_bool(node, "xlnx,mcdma");
|
| 2667 | + if (!of_property_read_u32(node, "xlnx,sg-length-width", |
| 2668 | + &len_width)) { |
| 2669 | + if (len_width < XILINX_DMA_MAX_TRANS_LEN_MIN || |
| 2670 | + len_width > XILINX_DMA_V2_MAX_TRANS_LEN_MAX) { |
| 2671 | + dev_warn(xdev->dev, |
| 2672 | + "invalid xlnx,sg-length-width property value. Using default width\n"); |
| 2673 | + } else { |
| 2674 | + if (len_width > XILINX_DMA_MAX_TRANS_LEN_MAX) |
| 2675 | + dev_warn(xdev->dev, "Please ensure that IP supports buffer length > 23 bits\n"); |
| 2676 | + xdev->max_buffer_len = |
| 2677 | + GENMASK(len_width - 1, 0); |
| 2678 | + } |
| 2679 | + } |
| 2680 | + } |
2665 | 2681 |
|
2666 | 2682 | if (xdev->dma_config->dmatype == XDMA_TYPE_VDMA) {
|
2667 | 2683 | err = of_property_read_u32(node, "xlnx,num-fstores",
|
|
0 commit comments