[PATCH 2/3] dmaengine: dw-axi-dmac: Add support for CV1800B DMA
Inochi Amaoto
inochiama at gmail.com
Sat Dec 13 02:26:35 PST 2025
On Sat, Dec 13, 2025 at 04:55:06PM +0900, Samuel Holland wrote:
> Hi Inochi,
>
> On 2025-12-12 11:05 AM, Inochi Amaoto wrote:
> > As the DMA controller on Sophgo CV1800 series SoC only has 8 channels,
> > the SoC provides a dma multiplexer to reuse the DMA channel. However,
> > the dma multiplexer also controlls the DMA interrupt multiplexer, which
>
> typo: controls
>
Thanks.
> > means that the dma multiplexer needs to know the channel number.
> >
> > Allow the driver to use DMA phandle args as the channel number, so the
> > DMA multiplexer can route the DMA interrupt correctly.
> >
> > Signed-off-by: Inochi Amaoto <inochiama at gmail.com>
> > ---
> > .../dma/dw-axi-dmac/dw-axi-dmac-platform.c | 23 ++++++++++++++++---
> > drivers/dma/dw-axi-dmac/dw-axi-dmac.h | 1 +
> > 2 files changed, 21 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
> > index b23536645ff7..62bf0d0dc354 100644
> > --- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
> > +++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
> > @@ -50,6 +50,7 @@
> > #define AXI_DMA_FLAG_HAS_APB_REGS BIT(0)
> > #define AXI_DMA_FLAG_HAS_RESETS BIT(1)
> > #define AXI_DMA_FLAG_USE_CFG2 BIT(2)
> > +#define AXI_DMA_FLAG_HANDSHAKE_AS_CHAN BIT(3)
> >
> > static inline void
> > axi_dma_iowrite32(struct axi_dma_chip *chip, u32 reg, u32 val)
> > @@ -1361,15 +1362,26 @@ static struct dma_chan *dw_axi_dma_of_xlate(struct of_phandle_args *dma_spec,
> > struct of_dma *ofdma)
> > {
> > struct dw_axi_dma *dw = ofdma->of_dma_data;
> > + unsigned int handshake = dma_spec->args[0];
> > struct axi_dma_chan *chan;
> > struct dma_chan *dchan;
> >
> > - dchan = dma_get_any_slave_channel(&dw->dma);
> > + if (dw->hdata->use_handshake_as_channel_number) {
> > + if (handshake >= dw->hdata->nr_channels)
> > + return NULL;
> > +
> > + chan = &dw->chan[handshake];
> > + dchan = dma_get_slave_channel(&chan->vc.chan);
> > + } else {
> > + dchan = dma_get_any_slave_channel(&dw->dma);
> > + }
> > +
> > if (!dchan)
> > return NULL;
> >
> > - chan = dchan_to_axi_dma_chan(dchan);
> > - chan->hw_handshake_num = dma_spec->args[0];
> > + if (!chan)
>
> When use_handshake_as_channel_number is false, chan is uninitialized here.
>
> Regards,
> Samuel
>
Thanks, I also noticed this, will fixed in the V2.
Regards,
Inochi
> > + chan = dchan_to_axi_dma_chan(dchan);
> > + chan->hw_handshake_num = handshake;
> > return dchan;
> > }
> >
> > @@ -1508,6 +1520,8 @@ static int dw_probe(struct platform_device *pdev)
> > return ret;
> > }
> >
> > + chip->dw->hdata->use_handshake_as_channel_number = !!(flags & AXI_DMA_FLAG_HANDSHAKE_AS_CHAN);
> > +
> > chip->dw->hdata->use_cfg2 = !!(flags & AXI_DMA_FLAG_USE_CFG2);
> >
> > chip->core_clk = devm_clk_get(chip->dev, "core-clk");
> > @@ -1663,6 +1677,9 @@ static const struct of_device_id dw_dma_of_id_table[] = {
> > }, {
> > .compatible = "intel,kmb-axi-dma",
> > .data = (void *)AXI_DMA_FLAG_HAS_APB_REGS,
> > + }, {
> > + .compatible = "sophgo,cv1800b-axi-dma",
> > + .data = (void *)AXI_DMA_FLAG_HANDSHAKE_AS_CHAN,
> > }, {
> > .compatible = "starfive,jh7110-axi-dma",
> > .data = (void *)(AXI_DMA_FLAG_HAS_RESETS | AXI_DMA_FLAG_USE_CFG2),
> > diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac.h b/drivers/dma/dw-axi-dmac/dw-axi-dmac.h
> > index b842e6a8d90d..67cc199e24d1 100644
> > --- a/drivers/dma/dw-axi-dmac/dw-axi-dmac.h
> > +++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac.h
> > @@ -34,6 +34,7 @@ struct dw_axi_dma_hcfg {
> > bool reg_map_8_channels;
> > bool restrict_axi_burst_len;
> > bool use_cfg2;
> > + bool use_handshake_as_channel_number;
> > };
> >
> > struct axi_dma_chan {
> > --
> > 2.52.0
> >
> >
> > _______________________________________________
> > linux-riscv mailing list
> > linux-riscv at lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-riscv
>
More information about the linux-riscv
mailing list