Skip to content

Commit 7d3a3aa

Browse files
bijudasvinodkoul
authored andcommitted
dmaengine: sh: rz-dmac: Add device_synchronize callback
Some on-chip peripheral modules(for eg:- rspi) on RZ/G2L SoC use the same signal for both interrupt and DMA transfer requests. The signal works as a DMA transfer request signal by setting DMARS, and subsequent interrupt requests to the interrupt controller are masked. We can re-enable the interrupt by clearing the DMARS. This patch adds device_synchronize callback for clearing DMARS and thereby allowing DMA consumers to switch to interrupt mode. Signed-off-by: Biju Das <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 1e42f82 commit 7d3a3aa

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

drivers/dma/sh/rz-dmac.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/dma-mapping.h>
1313
#include <linux/dmaengine.h>
1414
#include <linux/interrupt.h>
15+
#include <linux/iopoll.h>
1516
#include <linux/list.h>
1617
#include <linux/module.h>
1718
#include <linux/of.h>
@@ -630,6 +631,21 @@ static void rz_dmac_virt_desc_free(struct virt_dma_desc *vd)
630631
*/
631632
}
632633

634+
static void rz_dmac_device_synchronize(struct dma_chan *chan)
635+
{
636+
struct rz_dmac_chan *channel = to_rz_dmac_chan(chan);
637+
struct rz_dmac *dmac = to_rz_dmac(chan->device);
638+
u32 chstat;
639+
int ret;
640+
641+
ret = read_poll_timeout(rz_dmac_ch_readl, chstat, !(chstat & CHSTAT_EN),
642+
100, 100000, false, channel, CHSTAT, 1);
643+
if (ret < 0)
644+
dev_warn(dmac->dev, "DMA Timeout");
645+
646+
rz_dmac_set_dmars_register(dmac, channel->index, 0);
647+
}
648+
633649
/*
634650
* -----------------------------------------------------------------------------
635651
* IRQ handling
@@ -909,6 +925,7 @@ static int rz_dmac_probe(struct platform_device *pdev)
909925
engine->device_config = rz_dmac_config;
910926
engine->device_terminate_all = rz_dmac_terminate_all;
911927
engine->device_issue_pending = rz_dmac_issue_pending;
928+
engine->device_synchronize = rz_dmac_device_synchronize;
912929

913930
engine->copy_align = DMAENGINE_ALIGN_1_BYTE;
914931
dma_set_max_seg_size(engine->dev, U32_MAX);

0 commit comments

Comments
 (0)