Re: [PATCH v3 7/8] dmaengine: fsl-edma: add i.mx7ulp edma2 version support

From: Robin Gong
Date: Tue Jun 04 2019 - 22:33:53 EST


On 2019-06-04 at 12:37 +0000, Vinod Koul wrote:
> On 29-05-19, 17:08, yibin.gong@xxxxxxx wrote:
> >
> > From: Robin Gong <yibin.gong@xxxxxxx>
> >
> > Â Add edma2 for i.mx7ulp by version v3, since v2 has already
> Why leading spaces at start of line?
Sorry for the typo, will fix in next version
>
> >
> > been used by mcf-edma.
> > The big changes based on v1 are belows:
> > 1. only one dmamux.
> > 2. another clock dma_clk except dmamux clk.
> > 3. 16 independent interrupts instead of only one interrupt for
> > all channels.
> >
> > Signed-off-by: Robin Gong <yibin.gong@xxxxxxx>
> > ---
> > Âdrivers/dma/fsl-edma-common.c | 18 +++++++++++-
> > Âdrivers/dma/fsl-edma-common.h |ÂÂ3 ++
> > Âdrivers/dma/fsl-edma.cÂÂÂÂÂÂÂÂ| 67
> > +++++++++++++++++++++++++++++++++++++++++++
> > Â3 files changed, 87 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/dma/fsl-edma-common.c b/drivers/dma/fsl-edma-
> > common.c
> > index 45d70d3..0d9915c 100644
> > --- a/drivers/dma/fsl-edma-common.c
> > +++ b/drivers/dma/fsl-edma-common.c
> > @@ -90,6 +90,19 @@ static void mux_configure8(struct fsl_edma_chan
> > *fsl_chan, void __iomem *addr,
> > Â iowrite8(val8, addr + off);
> > Â}
> > Â
> > +void mux_configure32(struct fsl_edma_chan *fsl_chan, void __iomem
> > *addr,
> > + ÂÂÂÂÂu32 off, u32 slot, bool enable)
> > +{
> > + u32 val;
> > +
> > + if (enable)
> > + val = EDMAMUX_CHCFG_ENBL << 24 | slot;
> > + else
> > + val = EDMAMUX_CHCFG_DIS;
> > +
> > + iowrite32(val, addr + off * 4);
> > +}
> > +
> > Âvoid fsl_edma_chan_mux(struct fsl_edma_chan *fsl_chan,
> > Â unsigned int slot, bool enable)
> > Â{
> > @@ -102,7 +115,10 @@ void fsl_edma_chan_mux(struct fsl_edma_chan
> > *fsl_chan,
> > Â muxaddr = fsl_chan->edma->muxbase[ch / chans_per_mux];
> > Â slot = EDMAMUX_CHCFG_SOURCE(slot);
> > Â
> > - mux_configure8(fsl_chan, muxaddr, ch_off, slot, enable);
> > + if (fsl_chan->edma->version == v3)
> > + mux_configure32(fsl_chan, muxaddr, ch_off, slot,
> > enable);
> > + else
> > + mux_configure8(fsl_chan, muxaddr, ch_off, slot,
> > enable);
> > Â}
> > ÂEXPORT_SYMBOL_GPL(fsl_edma_chan_mux);
> > Â
> > diff --git a/drivers/dma/fsl-edma-common.h b/drivers/dma/fsl-edma-
> > common.h
> > index 014ab74..07482d2 100644
> > --- a/drivers/dma/fsl-edma-common.h
> > +++ b/drivers/dma/fsl-edma-common.h
> > @@ -125,6 +125,7 @@ struct fsl_edma_chan {
> > Â dma_addr_t dma_dev_addr;
> > Â u32 dma_dev_size;
> > Â enum dma_data_direction dma_dir;
> > + char chan_name[16];
> > Â};
> > Â
> > Âstruct fsl_edma_desc {
> > @@ -139,6 +140,7 @@ struct fsl_edma_desc {
> > Âenum edma_version {
> > Â v1, /* 32ch, Vybrid, mpc57x, etc */
> > Â v2, /* 64ch Coldfire */
> > + v3, /* 32ch, i.mx7ulp */
> > Â};
> > Â
> > Âstruct fsl_edma_drvdata {
> > @@ -154,6 +156,7 @@ struct fsl_edma_engine {
> > Â void __iomem *membase;
> > Â void __iomem *muxbase[DMAMUX_NR];
> > Â struct clk *muxclk[DMAMUX_NR];
> > + struct clk *dmaclk;
> > Â u32 dmamux_nr;
> > Â struct mutex fsl_edma_mutex;
> > Â const struct fsl_edma_drvdata *drvdata;
> > diff --git a/drivers/dma/fsl-edma.c b/drivers/dma/fsl-edma.c
> > index cf18301..45b26d6 100644
> > --- a/drivers/dma/fsl-edma.c
> > +++ b/drivers/dma/fsl-edma.c
> > @@ -165,6 +165,51 @@ fsl_edma_irq_init(struct platform_device
> > *pdev, struct fsl_edma_engine *fsl_edma
> > Â return 0;
> > Â}
> > Â
> > +static int
> > +fsl_edma2_irq_init(struct platform_device *pdev,
> > + ÂÂÂstruct fsl_edma_engine *fsl_edma)
> > +{
> > + struct device_node *np = pdev->dev.of_node;
> > + int i, ret, irq;
> > + int count = 0;
> Superflous initialization of count!
Would fix it in v4.
>
> >
> > +
> > + count = of_irq_count(np);
> > + dev_info(&pdev->dev, "%s Found %d interrupts\r\n",
> > __func__, count);
> Consider using debug level..
Would downgrade print level in v4.
>
> >
> > + if (count <= 2) {
> > + dev_err(&pdev->dev, "Interrupts in DTS not
> > correct.\n");
> > + return -EINVAL;
> > + }
> > + /*
> > + Â* 16 channel independent interrupts + 1 error interrupt
> > on i.mx7ulp.
> > + Â* 2 channel share one interrupt, for example, ch0/ch16,
> > ch1/ch17...
> > + Â* For now, just simply request irq without IRQF_SHARED
> > flag, since 16
> > + Â* channels are enough on i.mx7ulp whose M4 domain own
> > some peripherals.
> > + Â*/
> > + for (i = 0; i < count; i++) {
> > + irq = platform_get_irq(pdev, i);
> > + if (irq < 0)
> > + return -ENXIO;
> > +
> > + sprintf(fsl_edma->chans[i].chan_name, "eDMA2-
> > CH%02d", i);
> > +
> > + /* The last IRQ is for eDMA err */
> > + if (i == count - 1)
> > + ret = devm_request_irq(&pdev->dev, irq,
> > + fsl_edma_err_handl
> > er,
> > + 0, "eDMA2-ERR",
> > fsl_edma);
> > + else
> > +
> empty line is waste here
>
> >
> > + ret = devm_request_irq(&pdev->dev, irq,
> > + fsl_edma_tx_handle
> > r, 0,
> > + fsl_edma-
> > >chans[i].chan_name,
> > + fsl_edma);
> > + if (ret)
> > + return ret;
> > + }
> > +
> > + return 0;
> > +}
> > +
> > Âstatic void fsl_edma_irq_exit(
> > Â struct platform_device *pdev, struct
> > fsl_edma_engine *fsl_edma)
> > Â{
> > @@ -191,8 +236,16 @@ static struct fsl_edma_drvdata vf610_data = {
> > Â .setup_irq = fsl_edma_irq_init,
> > Â};
> > Â
> > +static struct fsl_edma_drvdata imx7ulp_data = {
> > + .version = v3,
> > + .dmamuxs = 1,
> > + .has_dmaclk = true,
> > + .setup_irq = fsl_edma2_irq_init,
> > +};
> > +
> > Âstatic const struct of_device_id fsl_edma_dt_ids[] = {
> > Â { .compatible = "fsl,vf610-edma", .data = &vf610_data},
> > + { .compatible = "fsl,imx7ulp-edma", .data =
> > &imx7ulp_data},
> > Â { /* sentinel */ }
> > Â};
> > ÂMODULE_DEVICE_TABLE(of, fsl_edma_dt_ids);
> > @@ -242,6 +295,20 @@ static int fsl_edma_probe(struct
> > platform_device *pdev)
> > Â fsl_edma_setup_regs(fsl_edma);
> > Â regs = &fsl_edma->regs;
> > Â
> > + if (drvdata->has_dmaclk) {
> > + fsl_edma->dmaclk = devm_clk_get(&pdev->dev,
> > "dma");
> > + if (IS_ERR(fsl_edma->dmaclk)) {
> > + dev_err(&pdev->dev, "Missing DMA block
> > clock.\n");
> > + return PTR_ERR(fsl_edma->dmaclk);
> > + }
> > +
> > + ret = clk_prepare_enable(fsl_edma->dmaclk);
> > + if (ret) {
> > + dev_err(&pdev->dev, "DMA clk block
> > failed.\n");
> > + return ret;
> > + }
> > + }
> > +
> > Â for (i = 0; i < fsl_edma->dmamux_nr; i++) {
> > Â char clkname[32];
> > Â
> > --Â
> > 2.7.4