diff options
author | Joy Zou <joy.zou@nxp.com> | 2021-10-26 11:00:25 +0200 |
---|---|---|
committer | Vinod Koul <vkoul@kernel.org> | 2021-10-28 19:26:24 +0200 |
commit | e0674853943287669a82d1ffe09a700944615978 (patch) | |
tree | 030225807cafa7f415ecb6c777678f00962d0218 /drivers/dma/fsl-edma-common.c | |
parent | dmaengine: idxd: fix resource leak on dmaengine driver disable (diff) | |
download | linux-e0674853943287669a82d1ffe09a700944615978.tar.xz linux-e0674853943287669a82d1ffe09a700944615978.zip |
dmaengine: fsl-edma: support edma memcpy
Add memcpy in edma. The edma has the capability to transfer data by
software trigger so that it could be used for memory copy. Enable
MEMCPY for edma driver and it could be test directly by dmatest.
Signed-off-by: Joy Zou <joy.zou@nxp.com>
Link: https://lore.kernel.org/r/20211026090025.2777292-1-joy.zou@nxp.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Diffstat (limited to 'drivers/dma/fsl-edma-common.c')
-rw-r--r-- | drivers/dma/fsl-edma-common.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/dma/fsl-edma-common.c b/drivers/dma/fsl-edma-common.c index 009c75ff1320..3ae05d1446a5 100644 --- a/drivers/dma/fsl-edma-common.c +++ b/drivers/dma/fsl-edma-common.c @@ -348,6 +348,7 @@ static void fsl_edma_set_tcd_regs(struct fsl_edma_chan *fsl_chan, struct fsl_edma_engine *edma = fsl_chan->edma; struct edma_regs *regs = &fsl_chan->edma->regs; u32 ch = fsl_chan->vchan.chan.chan_id; + u16 csr = 0; /* * TCD parameters are stored in struct fsl_edma_hw_tcd in little @@ -373,6 +374,12 @@ static void fsl_edma_set_tcd_regs(struct fsl_edma_chan *fsl_chan, edma_writel(edma, (s32)tcd->dlast_sga, ®s->tcd[ch].dlast_sga); + if (fsl_chan->is_sw) { + csr = le16_to_cpu(tcd->csr); + csr |= EDMA_TCD_CSR_START; + tcd->csr = cpu_to_le16(csr); + } + edma_writew(edma, (s16)tcd->csr, ®s->tcd[ch].csr); } @@ -587,6 +594,29 @@ struct dma_async_tx_descriptor *fsl_edma_prep_slave_sg( } EXPORT_SYMBOL_GPL(fsl_edma_prep_slave_sg); +struct dma_async_tx_descriptor *fsl_edma_prep_memcpy(struct dma_chan *chan, + dma_addr_t dma_dst, dma_addr_t dma_src, + size_t len, unsigned long flags) +{ + struct fsl_edma_chan *fsl_chan = to_fsl_edma_chan(chan); + struct fsl_edma_desc *fsl_desc; + + fsl_desc = fsl_edma_alloc_desc(fsl_chan, 1); + if (!fsl_desc) + return NULL; + fsl_desc->iscyclic = false; + + fsl_chan->is_sw = true; + + /* To match with copy_align and max_seg_size so 1 tcd is enough */ + fsl_edma_fill_tcd(fsl_desc->tcd[0].vtcd, dma_src, dma_dst, + EDMA_TCD_ATTR_SSIZE_32BYTE | EDMA_TCD_ATTR_DSIZE_32BYTE, + 32, len, 0, 1, 1, 32, 0, true, true, false); + + return vchan_tx_prep(&fsl_chan->vchan, &fsl_desc->vdesc, flags); +} +EXPORT_SYMBOL_GPL(fsl_edma_prep_memcpy); + void fsl_edma_xfer_desc(struct fsl_edma_chan *fsl_chan) { struct virt_dma_desc *vdesc; @@ -654,6 +684,7 @@ void fsl_edma_free_chan_resources(struct dma_chan *chan) vchan_dma_desc_free_list(&fsl_chan->vchan, &head); dma_pool_destroy(fsl_chan->tcd_pool); fsl_chan->tcd_pool = NULL; + fsl_chan->is_sw = false; } EXPORT_SYMBOL_GPL(fsl_edma_free_chan_resources); |