diff options
author | Javier Martin <javier.martin@vista-silicon.com> | 2012-02-28 11:08:17 -0500 |
---|---|---|
committer | Vinod Koul <vinod.koul@linux.intel.com> | 2012-03-06 06:49:21 -0500 |
commit | 6c05f09155f40368c51ce00b8291401858e49bcb (patch) | |
tree | 885eb543385ccf960a44ae5eff02db5eaa9ae9c6 /drivers/dma/imx-dma.c | |
parent | d8b53489d4c80490a70327fce6657816e33fafb3 (diff) |
dmaengine: Add support for MEMCPY for imx-dma.
MEMCPY transfers allow DMA copies from memory to
memory. This patch has been tested with dmatest
device driver.
Signed-off-by: Javier Martin <javier.martin@vista-silicon.com>
Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
Diffstat (limited to 'drivers/dma/imx-dma.c')
-rw-r--r-- | drivers/dma/imx-dma.c | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/drivers/dma/imx-dma.c b/drivers/dma/imx-dma.c index b51391adb289..9a1797873169 100644 --- a/drivers/dma/imx-dma.c +++ b/drivers/dma/imx-dma.c | |||
@@ -195,7 +195,8 @@ static int imxdma_alloc_chan_resources(struct dma_chan *chan) | |||
195 | struct imxdma_channel *imxdmac = to_imxdma_chan(chan); | 195 | struct imxdma_channel *imxdmac = to_imxdma_chan(chan); |
196 | struct imx_dma_data *data = chan->private; | 196 | struct imx_dma_data *data = chan->private; |
197 | 197 | ||
198 | imxdmac->dma_request = data->dma_request; | 198 | if (data != NULL) |
199 | imxdmac->dma_request = data->dma_request; | ||
199 | 200 | ||
200 | dma_async_tx_descriptor_init(&imxdmac->desc, chan); | 201 | dma_async_tx_descriptor_init(&imxdmac->desc, chan); |
201 | imxdmac->desc.tx_submit = imxdma_tx_submit; | 202 | imxdmac->desc.tx_submit = imxdma_tx_submit; |
@@ -327,6 +328,36 @@ static struct dma_async_tx_descriptor *imxdma_prep_dma_cyclic( | |||
327 | return &imxdmac->desc; | 328 | return &imxdmac->desc; |
328 | } | 329 | } |
329 | 330 | ||
331 | static struct dma_async_tx_descriptor *imxdma_prep_dma_memcpy( | ||
332 | struct dma_chan *chan, dma_addr_t dest, | ||
333 | dma_addr_t src, size_t len, unsigned long flags) | ||
334 | { | ||
335 | struct imxdma_channel *imxdmac = to_imxdma_chan(chan); | ||
336 | struct imxdma_engine *imxdma = imxdmac->imxdma; | ||
337 | int ret; | ||
338 | |||
339 | dev_dbg(imxdma->dev, "%s channel: %d src=0x%x dst=0x%x len=%d\n", | ||
340 | __func__, imxdmac->channel, src, dest, len); | ||
341 | |||
342 | if (imxdmac->status == DMA_IN_PROGRESS) | ||
343 | return NULL; | ||
344 | imxdmac->status = DMA_IN_PROGRESS; | ||
345 | |||
346 | ret = imx_dma_config_channel(imxdmac->imxdma_channel, | ||
347 | IMX_DMA_MEMSIZE_32 | IMX_DMA_TYPE_LINEAR, | ||
348 | IMX_DMA_MEMSIZE_32 | IMX_DMA_TYPE_LINEAR, | ||
349 | 0, 0); | ||
350 | if (ret) | ||
351 | return NULL; | ||
352 | |||
353 | ret = imx_dma_setup_single(imxdmac->imxdma_channel, src, len, | ||
354 | dest, DMA_MODE_WRITE); | ||
355 | if (ret) | ||
356 | return NULL; | ||
357 | |||
358 | return &imxdmac->desc; | ||
359 | } | ||
360 | |||
330 | static void imxdma_issue_pending(struct dma_chan *chan) | 361 | static void imxdma_issue_pending(struct dma_chan *chan) |
331 | { | 362 | { |
332 | struct imxdma_channel *imxdmac = to_imxdma_chan(chan); | 363 | struct imxdma_channel *imxdmac = to_imxdma_chan(chan); |
@@ -348,6 +379,7 @@ static int __init imxdma_probe(struct platform_device *pdev) | |||
348 | 379 | ||
349 | dma_cap_set(DMA_SLAVE, imxdma->dma_device.cap_mask); | 380 | dma_cap_set(DMA_SLAVE, imxdma->dma_device.cap_mask); |
350 | dma_cap_set(DMA_CYCLIC, imxdma->dma_device.cap_mask); | 381 | dma_cap_set(DMA_CYCLIC, imxdma->dma_device.cap_mask); |
382 | dma_cap_set(DMA_MEMCPY, imxdma->dma_device.cap_mask); | ||
351 | 383 | ||
352 | /* Initialize channel parameters */ | 384 | /* Initialize channel parameters */ |
353 | for (i = 0; i < MAX_DMA_CHANNELS; i++) { | 385 | for (i = 0; i < MAX_DMA_CHANNELS; i++) { |
@@ -381,11 +413,13 @@ static int __init imxdma_probe(struct platform_device *pdev) | |||
381 | imxdma->dma_device.device_tx_status = imxdma_tx_status; | 413 | imxdma->dma_device.device_tx_status = imxdma_tx_status; |
382 | imxdma->dma_device.device_prep_slave_sg = imxdma_prep_slave_sg; | 414 | imxdma->dma_device.device_prep_slave_sg = imxdma_prep_slave_sg; |
383 | imxdma->dma_device.device_prep_dma_cyclic = imxdma_prep_dma_cyclic; | 415 | imxdma->dma_device.device_prep_dma_cyclic = imxdma_prep_dma_cyclic; |
416 | imxdma->dma_device.device_prep_dma_memcpy = imxdma_prep_dma_memcpy; | ||
384 | imxdma->dma_device.device_control = imxdma_control; | 417 | imxdma->dma_device.device_control = imxdma_control; |
385 | imxdma->dma_device.device_issue_pending = imxdma_issue_pending; | 418 | imxdma->dma_device.device_issue_pending = imxdma_issue_pending; |
386 | 419 | ||
387 | platform_set_drvdata(pdev, imxdma); | 420 | platform_set_drvdata(pdev, imxdma); |
388 | 421 | ||
422 | imxdma->dma_device.copy_align = 2; /* 2^2 = 4 bytes alignment */ | ||
389 | imxdma->dma_device.dev->dma_parms = &imxdma->dma_parms; | 423 | imxdma->dma_device.dev->dma_parms = &imxdma->dma_parms; |
390 | dma_set_max_seg_size(imxdma->dma_device.dev, 0xffffff); | 424 | dma_set_max_seg_size(imxdma->dma_device.dev, 0xffffff); |
391 | 425 | ||