dma: pl330: Implement device_slave_caps
PATCH 1/1 dma: pl330: Implement device_slave_caps
Implemnt the device_slave_caps() callback for the pl330 driver. This allows dmaengine users like the generic ALSA dmaengine PCM driver to query the capabilities of the driver. The PL330 supports all buswidths and both mem-to-dev as well as dev-to-mem transfers. In theory there is no limit on the number of segments that can be transferred (in practice you'll run out of memory eventually) and the number of bytes per segment is limited by the size of the PL330 program buffer. Due to the nature of the PL330 the maximum number of bytes per segment depends on the burstsize, the driver sets it to the value for a 1-byte burstsize, since it is the smallest.
--- drivers/dma/pl330.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
drivers/dma/pl330.c +27 -0
@@ -2855,6 +2855,32 @@ static irqreturn_t pl330_irq_handler(int irq, void *data)return IRQ_NONE ; } +#define PL330_DMA_BUSWIDTHS \ + BIT(DMA_SLAVE_BUSWIDTH_UNDEFINED) | \ + BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) | \ + BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) | \ + BIT(DMA_SLAVE_BUSWIDTH_4_BYTES) | \ + BIT(DMA_SLAVE_BUSWIDTH_8_BYTES) + +static int pl330_dma_device_slave_caps (struct dma_chan *dchan, +struct dma_slave_caps *caps) +{ + caps->src_addr_widths =PL330_DMA_BUSWIDTHS ; + caps->dstn_addr_widths =PL330_DMA_BUSWIDTHS ; + caps->directions =BIT (DMA_DEV_TO_MEM ) |BIT (DMA_MEM_TO_DEV ); + caps->cmd_pause = false; + caps->cmd_terminate = true; + +/* +* This is the limit for transfers with a buswidth of 1, larger buswidths +* will have larger limits. +*/ + caps->max_sg_len =1900800 ; + caps->max_sg_nr =0 ; + +return 0 ; +} +static int pl330_probe (struct amba_device *adev,const struct amba_id *id) {
@@ -2959,6 +2985,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id) pd->device_prep_slave_sg = pl330_prep_slave_sg; pd->device_control = pl330_control; pd->device_issue_pending = pl330_issue_pending; + pd->device_slave_caps = pl330_dma_device_slave_caps; ret =dma_async_device_register (pd);if (ret) {
Signature · 1 line
1.8.0
Quoted 1 line · Lars-Peter Clausen
Implemnt the
device_slave_caps()callback for the pl330 driver. This allows
typo ^^^^
Quoted 19 lines
dmaengine users like the generic ALSA dmaengine PCM driver to query the capabilities of the driver. The PL330 supports all buswidths and both mem-to-dev as well as dev-to-mem transfers. In theory there is no limit on the number of segments that can be transferred (in practice you'll run out of memory eventually) and the number of bytes per segment is limited by the size of the PL330 program buffer. Due to the nature of the PL330 the maximum number of bytes per segment depends on the burstsize, the driver sets it to the value for a 1-byte burstsize, since it is the smallest.
Signed-off-by Lars-Peter Clausen <[email protected]>--- drivers/dma/pl330.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)drivers/dma/pl330.c +0
-0
drivers/dma/pl330.c static irqreturn_t pl330_irq_handler(int irq, void *data) · line 2863
Quoted 9 lines
drivers/dma/pl330.c +6
-0@@ -2855,6 +2855,32 @@ static irqreturn_t pl330_irq_handler(int irq, void *data)return IRQ_NONE ; } +#define PL330_DMA_BUSWIDTHS \ + BIT(DMA_SLAVE_BUSWIDTH_UNDEFINED) | \ + BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) | \ + BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) | \ + BIT(DMA_SLAVE_BUSWIDTH_4_BYTES) | \ + BIT(DMA_SLAVE_BUSWIDTH_8_BYTES)
checkpatch cribs that this is complex macro and should be enclosed in a parenthesis, I have ignored it as usage doesnt justify it, yet!
drivers/dma/pl330.c static irqreturn_t pl330_irq_handler(int irq, void *data) · line 2874
Quoted 11 lines
drivers/dma/pl330.c +11
-0+ +static int pl330_dma_device_slave_caps (struct dma_chan *dchan, +struct dma_slave_caps *caps) +{ + caps->src_addr_widths =PL330_DMA_BUSWIDTHS ; + caps->dstn_addr_widths =PL330_DMA_BUSWIDTHS ; + caps->directions =BIT (DMA_DEV_TO_MEM ) |BIT (DMA_MEM_TO_DEV ); + caps->cmd_pause = false; + caps->cmd_terminate = true; + +/*
trailing whitepsace here!
drivers/dma/pl330.c static irqreturn_t pl330_irq_handler(int irq, void *data) · line 2875
Quoted 1 line
drivers/dma/pl330.c +1
-0+* This is the limit for transfers with a buswidth of 1, larger buswidths
you could have sticked to 80 char rule here very easily...
drivers/dma/pl330.c static irqreturn_t pl330_irq_handler(int irq, void *data) · line 2877
Quoted 2 lines
drivers/dma/pl330.c +2
-0+* will have larger limits. +*/
Now, i am catching a plane for a work trip tomorrow, so have fixed checkpatch and typo and applied this.
~Vinod