Re: [PATCH v5 2/2] dmaengine: fsl-edma: add ColdFire mcf5441x edma support

2018-07-01 Thread Vinod
On 30-06-18, 15:42, Angelo Dureghello wrote:
> Hi Vinod,
> 
> fixed mostly all, but sorry, i have still two questions before
> proceeding,
> 
> > > +// SPDX-License-Identifier: GPL-2.0
> > > +// Copyright (c) 2013-2014 Freescale Semiconductor, Inc
> > > +// Copyright (c) 2017 Sysam, Angelo Dureghello  
> > > +/*
> > > + * drivers/dma/mcf-edma.c
> > > + *
> > > + * Driver for the Freescale ColdFire 64-ch eDMA implementation,
> > > + * derived from drivers/dma/fsl-edma.c.
> > > + *
> > > + * This program is free software; you can redistribute  it and/or modify 
> > > it
> > > + * under  the terms of  the GNU General  Public License as published by 
> > > the
> > > + * Free Software Foundation;  either version 2 of the  License, or (at 
> > > your
> > > + * option) any later version.
> > > + */
> > 
> > again, no need for text
> > 
> 
> It is not clear to me now how the initial header should be (i guess for 
> all the 3 c files at this point).
> 
> Do you want just something as :
> 
> // SPDX-License-Identifier: GPL-2.0
> // Copyright (c) 2013-2014 Freescale Semiconductor, Inc
> // Copyright (c) 2017 Sysam, Angelo Dureghello  

That would be nice. Text is no longer required as SPDX represents that.
Copyright needs to be retained.
> 
> And nothing else ?
> 
> Majority of the files in the dma folder has also generally a line with 
> the file name and path, a brief driver explaination and the reduced GPL
> licence text, and, as imx-sdma.c often copyrights at the end. So what is 
> the current rule ?

Above and if you would like add a line explaining the role of driver.
File name and path are not required and gets stale as people update
stuff in future.

> > > +static int __init mcf_edma_init(void)
> > > +{
> > > + return platform_driver_register(_edma_driver);
> > > +}
> > > +subsys_initcall(mcf_edma_init);
> > 
> > why subsys_initcall?
> > 
> 
> I find subsys_initcall in several dma drivers, my understanding is that
> it initializes the driver before other drivers can use it.
> It also sets the driver as built in only.
> This seems ok for my case.

Yes that is the case, but in your case I would like to know why you
would want this. Others doing is not a good enough justification and you
need to find your reason :)

-- 
~Vinod
--
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 2/2] dmaengine: fsl-edma: add ColdFire mcf5441x edma support

2018-06-30 Thread Geert Uytterhoeven
Hi Angelo,

On Sat, Jun 30, 2018 at 3:42 PM Angelo Dureghello  wrote:
> fixed mostly all, but sorry, i have still two questions before
> proceeding,
>
> On Thu, Jun 28, 2018 at 11:53:41AM +0530, Vinod wrote:
> It is not clear to me now how the initial header should be (i guess for
> all the 3 c files at this point).
>
> Do you want just something as :
>
> // SPDX-License-Identifier: GPL-2.0
> // Copyright (c) 2013-2014 Freescale Semiconductor, Inc
> // Copyright (c) 2017 Sysam, Angelo Dureghello  
>
> And nothing else ?

Looks good to me.

> Majority of the files in the dma folder has also generally a line with
> the file name and path, a brief driver explaination and the reduced GPL

File names and path are superfluous, and annoying, considering move/rename
later.

> licence text, and, as imx-sdma.c often copyrights at the end. So what is

Reduced license text is no longer needed with the right SPDX header.

> the current rule ?

Copyright should be retained.

> > > +static int __init mcf_edma_init(void)
> > > +{
> > > +   return platform_driver_register(_edma_driver);
> > > +}
> > > +subsys_initcall(mcf_edma_init);
> >
> > why subsys_initcall?
> >
>
> I find subsys_initcall in several dma drivers, my understanding is that
> it initializes the driver before other drivers can use it.
> It also sets the driver as built in only.
> This seems ok for my case.

Indeed. If DMAC drivers are initialized before normal device drivers (which
can be DMA slaves), probe deferral can be avoided.

Gr{oetje,eeting}s,

Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 2/2] dmaengine: fsl-edma: add ColdFire mcf5441x edma support

2018-06-30 Thread Angelo Dureghello
Hi Vinod,

fixed mostly all, but sorry, i have still two questions before
proceeding,

On Thu, Jun 28, 2018 at 11:53:41AM +0530, Vinod wrote:
> On 22-06-18, 11:44, Angelo Dureghello wrote:
> >  obj-$(CONFIG_EP93XX_DMA) += ep93xx_dma.o
> >  obj-$(CONFIG_FSL_DMA) += fsldma.o
> >  obj-$(CONFIG_FSL_EDMA) += fsl-edma.o fsl-edma-common.o
> > +obj-$(CONFIG_MCF_EDMA) += mcf-edma.o fsl-edma-common.o
> 
> that makes kernel have two copies of common.o one in thsi driver and one
> in previous one why not do:
> 
> CONFIG_FSL_COMMON += fsl-edma-common.o
> CONFIG_FSL_EDMA += fsl-edma.o
> CONFIG_MCF_EDMA += mcf-edma.o
> 
> and you select CONFIG_FSL_COMMON in both FSL and MCF Kconfig?
> 
> > +// SPDX-License-Identifier: GPL-2.0
> > +// Copyright (c) 2013-2014 Freescale Semiconductor, Inc
> > +// Copyright (c) 2017 Sysam, Angelo Dureghello  
> > +/*
> > + * drivers/dma/mcf-edma.c
> > + *
> > + * Driver for the Freescale ColdFire 64-ch eDMA implementation,
> > + * derived from drivers/dma/fsl-edma.c.
> > + *
> > + * This program is free software; you can redistribute  it and/or modify it
> > + * under  the terms of  the GNU General  Public License as published by the
> > + * Free Software Foundation;  either version 2 of the  License, or (at your
> > + * option) any later version.
> > + */
> 
> again, no need for text
> 

It is not clear to me now how the initial header should be (i guess for 
all the 3 c files at this point).

Do you want just something as :

// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2013-2014 Freescale Semiconductor, Inc
// Copyright (c) 2017 Sysam, Angelo Dureghello  

And nothing else ?

Majority of the files in the dma folder has also generally a line with 
the file name and path, a brief driver explaination and the reduced GPL
licence text, and, as imx-sdma.c often copyrights at the end. So what is 
the current rule ?


> > +static irqreturn_t mcf_edma_tx_handler(int irq, void *dev_id)
> > +{
> > +   struct fsl_edma_engine *mcf_edma = dev_id;
> > +   struct edma_regs *regs = _edma->regs;
> > +   unsigned int ch;
> > +   struct fsl_edma_chan *mcf_chan;
> > +   u64 intmap;
> > +
> > +   intmap = ioread32(regs->inth);
> > +   intmap <<= 32;
> > +   intmap |= ioread32(regs->intl);
> > +   if (!intmap)
> > +   return IRQ_NONE;
> > +
> > +   for (ch = 0; ch < mcf_edma->n_chans; ch++) {
> > +   if (intmap & (0x1 << ch)) {
> 
> intmap & BIT(ch)
> 
> > +static irqreturn_t mcf_edma_err_handler(int irq, void *dev_id)
> > +{
> > +   struct fsl_edma_engine *mcf_edma = dev_id;
> > +   struct edma_regs *regs = _edma->regs;
> > +   unsigned int err, ch;
> > +
> > +   err = ioread32(regs->errl);
> > +   if (!err)
> > +   return IRQ_NONE;
> > +
> > +   for (ch = 0; ch < (EDMA_CHANNELS / 2); ch++) {
> > +   if (err & (0x1 << ch)) {
> 
> here as well
> 
> > +static int mcf_edma_remove(struct platform_device *pdev)
> > +{
> > +   struct fsl_edma_engine *mcf_edma = platform_get_drvdata(pdev);
> > +
> > +   fsl_edma_cleanup_vchan(_edma->dma_dev);
> > +   dma_async_device_unregister(_edma->dma_dev);
> 
> at this point your irqs are still registered and running. You vchan
> tasklet maybe still pending to be eecuted and can be scheduled again
> 
> > +static int __init mcf_edma_init(void)
> > +{
> > +   return platform_driver_register(_edma_driver);
> > +}
> > +subsys_initcall(mcf_edma_init);
> 
> why subsys_initcall?
> 

I find subsys_initcall in several dma drivers, my understanding is that
it initializes the driver before other drivers can use it.
It also sets the driver as built in only.
This seems ok for my case.

Regards,
Angelo

> -- 
> ~Vinod
--
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 2/2] dmaengine: fsl-edma: add ColdFire mcf5441x edma support

2018-06-28 Thread Vinod
On 28-06-18, 18:56, Angelo Dureghello wrote:

> Vinod,
> what do you think, am i near to a possible "accept" in a v6 or v7 ? 
> Or do you see any additional great job to do or other important 
> blocking points ?

I review to merge :) If I dont find any issues I will merge straight
away, there is nothing like v6/v7

HTH
-- 
~Vinod
--
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 2/2] dmaengine: fsl-edma: add ColdFire mcf5441x edma support

2018-06-28 Thread Angelo Dureghello
Hi Vinod and Geert,

On Thu, Jun 28, 2018 at 04:39:13PM +0530, Vinod wrote:
> On 28-06-18, 09:43, Geert Uytterhoeven wrote:
> > Hi Vinod,
> > 
> > On Thu, Jun 28, 2018 at 9:29 AM Vinod  wrote:
> > > On 28-06-18, 08:50, Geert Uytterhoeven wrote:
> > > > On Thu, Jun 28, 2018 at 8:29 AM Vinod  wrote:
> > > > > On 22-06-18, 11:44, Angelo Dureghello wrote:
> > > > > >  obj-$(CONFIG_EP93XX_DMA) += ep93xx_dma.o
> > > > > >  obj-$(CONFIG_FSL_DMA) += fsldma.o
> > > > > >  obj-$(CONFIG_FSL_EDMA) += fsl-edma.o fsl-edma-common.o
> > > > > > +obj-$(CONFIG_MCF_EDMA) += mcf-edma.o fsl-edma-common.o
> > > > >
> > > > > that makes kernel have two copies of common.o one in thsi driver and 
> > > > > one
> > > >
> > > > Does it? It's a common pattern in several Makefiles (e.g.
> > > > drivers/net/ethernet/8390/Makefile and drivers/scsi/Makefile)
> > >
> > > won't each static symbol be part each one?
> > 
> > Remember, obj-y is a list, and IIRC it's filtered for duplicates.
> > 
> > > What about when they are modules?
> > 
> > Same thing, you'll have fsl-edma-common.ko, and fsl-edma.ko and/or 
> > mcf-edma.ko.
> 
> Yeah that is right, I missed the list part
>

Ok, so if i understand, i'll fix all the Vinod points except the
Kconfig/makefile part that seems ok as is.

Vinod,
what do you think, am i near to a possible "accept" in a v6 or v7 ? 
Or do you see any additional great job to do or other important 
blocking points ?

Thanks,
regards,
Angelo Dureghello

 
> -- 
> ~Vinod
> --
> To unsubscribe from this list: send the line "unsubscribe dmaengine" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 2/2] dmaengine: fsl-edma: add ColdFire mcf5441x edma support

2018-06-28 Thread Vinod
On 28-06-18, 09:43, Geert Uytterhoeven wrote:
> Hi Vinod,
> 
> On Thu, Jun 28, 2018 at 9:29 AM Vinod  wrote:
> > On 28-06-18, 08:50, Geert Uytterhoeven wrote:
> > > On Thu, Jun 28, 2018 at 8:29 AM Vinod  wrote:
> > > > On 22-06-18, 11:44, Angelo Dureghello wrote:
> > > > >  obj-$(CONFIG_EP93XX_DMA) += ep93xx_dma.o
> > > > >  obj-$(CONFIG_FSL_DMA) += fsldma.o
> > > > >  obj-$(CONFIG_FSL_EDMA) += fsl-edma.o fsl-edma-common.o
> > > > > +obj-$(CONFIG_MCF_EDMA) += mcf-edma.o fsl-edma-common.o
> > > >
> > > > that makes kernel have two copies of common.o one in thsi driver and one
> > >
> > > Does it? It's a common pattern in several Makefiles (e.g.
> > > drivers/net/ethernet/8390/Makefile and drivers/scsi/Makefile)
> >
> > won't each static symbol be part each one?
> 
> Remember, obj-y is a list, and IIRC it's filtered for duplicates.
> 
> > What about when they are modules?
> 
> Same thing, you'll have fsl-edma-common.ko, and fsl-edma.ko and/or 
> mcf-edma.ko.

Yeah that is right, I missed the list part

-- 
~Vinod
--
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 2/2] dmaengine: fsl-edma: add ColdFire mcf5441x edma support

2018-06-28 Thread Geert Uytterhoeven
Hi Vinod,

On Thu, Jun 28, 2018 at 9:29 AM Vinod  wrote:
> On 28-06-18, 08:50, Geert Uytterhoeven wrote:
> > On Thu, Jun 28, 2018 at 8:29 AM Vinod  wrote:
> > > On 22-06-18, 11:44, Angelo Dureghello wrote:
> > > >  obj-$(CONFIG_EP93XX_DMA) += ep93xx_dma.o
> > > >  obj-$(CONFIG_FSL_DMA) += fsldma.o
> > > >  obj-$(CONFIG_FSL_EDMA) += fsl-edma.o fsl-edma-common.o
> > > > +obj-$(CONFIG_MCF_EDMA) += mcf-edma.o fsl-edma-common.o
> > >
> > > that makes kernel have two copies of common.o one in thsi driver and one
> >
> > Does it? It's a common pattern in several Makefiles (e.g.
> > drivers/net/ethernet/8390/Makefile and drivers/scsi/Makefile)
>
> won't each static symbol be part each one?

Remember, obj-y is a list, and IIRC it's filtered for duplicates.

> What about when they are modules?

Same thing, you'll have fsl-edma-common.ko, and fsl-edma.ko and/or mcf-edma.ko.

> > > in previous one why not do:
> > >
> > > CONFIG_FSL_COMMON += fsl-edma-common.o
> > > CONFIG_FSL_EDMA += fsl-edma.o
> > > CONFIG_MCF_EDMA += mcf-edma.o
> > >
> > > and you select CONFIG_FSL_COMMON in both FSL and MCF Kconfig?
> >
> > That's what he had originally, until I suggested to do the above, as
> > nothing else
> > needed the CONFIG_FSL_COMMON symbol.
>
> Hmmm, okay what are we gaining from this approach?

Less Kconfig symbols, less lines of Kconfig and Makefile?

Gr{oetje,eeting}s,

Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 2/2] dmaengine: fsl-edma: add ColdFire mcf5441x edma support

2018-06-28 Thread Vinod
On 28-06-18, 08:50, Geert Uytterhoeven wrote:
> Hi Vinod,
> 
> On Thu, Jun 28, 2018 at 8:29 AM Vinod  wrote:
> > On 22-06-18, 11:44, Angelo Dureghello wrote:
> > >  obj-$(CONFIG_EP93XX_DMA) += ep93xx_dma.o
> > >  obj-$(CONFIG_FSL_DMA) += fsldma.o
> > >  obj-$(CONFIG_FSL_EDMA) += fsl-edma.o fsl-edma-common.o
> > > +obj-$(CONFIG_MCF_EDMA) += mcf-edma.o fsl-edma-common.o
> >
> > that makes kernel have two copies of common.o one in thsi driver and one
> 
> Does it? It's a common pattern in several Makefiles (e.g.
> drivers/net/ethernet/8390/Makefile and drivers/scsi/Makefile)

won't each static symbol be part each one? What about when they are
modules?

> > in previous one why not do:
> >
> > CONFIG_FSL_COMMON += fsl-edma-common.o
> > CONFIG_FSL_EDMA += fsl-edma.o
> > CONFIG_MCF_EDMA += mcf-edma.o
> >
> > and you select CONFIG_FSL_COMMON in both FSL and MCF Kconfig?
> 
> That's what he had originally, until I suggested to do the above, as
> nothing else
> needed the CONFIG_FSL_COMMON symbol.

Hmmm, okay what are we gaining from this approach?

-- 
~Vinod
--
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 2/2] dmaengine: fsl-edma: add ColdFire mcf5441x edma support

2018-06-28 Thread Geert Uytterhoeven
Hi Vinod,

On Thu, Jun 28, 2018 at 8:29 AM Vinod  wrote:
> On 22-06-18, 11:44, Angelo Dureghello wrote:
> >  obj-$(CONFIG_EP93XX_DMA) += ep93xx_dma.o
> >  obj-$(CONFIG_FSL_DMA) += fsldma.o
> >  obj-$(CONFIG_FSL_EDMA) += fsl-edma.o fsl-edma-common.o
> > +obj-$(CONFIG_MCF_EDMA) += mcf-edma.o fsl-edma-common.o
>
> that makes kernel have two copies of common.o one in thsi driver and one

Does it? It's a common pattern in several Makefiles (e.g.
drivers/net/ethernet/8390/Makefile and drivers/scsi/Makefile)

> in previous one why not do:
>
> CONFIG_FSL_COMMON += fsl-edma-common.o
> CONFIG_FSL_EDMA += fsl-edma.o
> CONFIG_MCF_EDMA += mcf-edma.o
>
> and you select CONFIG_FSL_COMMON in both FSL and MCF Kconfig?

That's what he had originally, until I suggested to do the above, as
nothing else
needed the CONFIG_FSL_COMMON symbol.

Gr{oetje,eeting}s,

Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 2/2] dmaengine: fsl-edma: add ColdFire mcf5441x edma support

2018-06-28 Thread Vinod
On 22-06-18, 11:44, Angelo Dureghello wrote:
>  obj-$(CONFIG_EP93XX_DMA) += ep93xx_dma.o
>  obj-$(CONFIG_FSL_DMA) += fsldma.o
>  obj-$(CONFIG_FSL_EDMA) += fsl-edma.o fsl-edma-common.o
> +obj-$(CONFIG_MCF_EDMA) += mcf-edma.o fsl-edma-common.o

that makes kernel have two copies of common.o one in thsi driver and one
in previous one why not do:

CONFIG_FSL_COMMON += fsl-edma-common.o
CONFIG_FSL_EDMA += fsl-edma.o
CONFIG_MCF_EDMA += mcf-edma.o

and you select CONFIG_FSL_COMMON in both FSL and MCF Kconfig?

> +// SPDX-License-Identifier: GPL-2.0
> +// Copyright (c) 2013-2014 Freescale Semiconductor, Inc
> +// Copyright (c) 2017 Sysam, Angelo Dureghello  
> +/*
> + * drivers/dma/mcf-edma.c
> + *
> + * Driver for the Freescale ColdFire 64-ch eDMA implementation,
> + * derived from drivers/dma/fsl-edma.c.
> + *
> + * This program is free software; you can redistribute  it and/or modify it
> + * under  the terms of  the GNU General  Public License as published by the
> + * Free Software Foundation;  either version 2 of the  License, or (at your
> + * option) any later version.
> + */

again, no need for text

> +static irqreturn_t mcf_edma_tx_handler(int irq, void *dev_id)
> +{
> + struct fsl_edma_engine *mcf_edma = dev_id;
> + struct edma_regs *regs = _edma->regs;
> + unsigned int ch;
> + struct fsl_edma_chan *mcf_chan;
> + u64 intmap;
> +
> + intmap = ioread32(regs->inth);
> + intmap <<= 32;
> + intmap |= ioread32(regs->intl);
> + if (!intmap)
> + return IRQ_NONE;
> +
> + for (ch = 0; ch < mcf_edma->n_chans; ch++) {
> + if (intmap & (0x1 << ch)) {

intmap & BIT(ch)

> +static irqreturn_t mcf_edma_err_handler(int irq, void *dev_id)
> +{
> + struct fsl_edma_engine *mcf_edma = dev_id;
> + struct edma_regs *regs = _edma->regs;
> + unsigned int err, ch;
> +
> + err = ioread32(regs->errl);
> + if (!err)
> + return IRQ_NONE;
> +
> + for (ch = 0; ch < (EDMA_CHANNELS / 2); ch++) {
> + if (err & (0x1 << ch)) {

here as well

> +static int mcf_edma_remove(struct platform_device *pdev)
> +{
> + struct fsl_edma_engine *mcf_edma = platform_get_drvdata(pdev);
> +
> + fsl_edma_cleanup_vchan(_edma->dma_dev);
> + dma_async_device_unregister(_edma->dma_dev);

at this point your irqs are still registered and running. You vchan
tasklet maybe still pending to be eecuted and can be scheduled again

> +static int __init mcf_edma_init(void)
> +{
> + return platform_driver_register(_edma_driver);
> +}
> +subsys_initcall(mcf_edma_init);

why subsys_initcall?

-- 
~Vinod
--
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 2/2] dmaengine: fsl-edma: add ColdFire mcf5441x edma support

2018-06-22 Thread Angelo Dureghello
This patch adds support for ColdFire mcf5441x-family edma
module.

The ColdFire edma module is slightly different from fsl-edma,
so a new driver is added. But most of the code is common
between fsl-edma and mcf-edma so it has been collected into a
separate common module fsl-edma-common (patch 1/2).

Signed-off-by: Angelo Dureghello 
---
Changes for v2:
- patch splitted into 4
- add mcf-edma as minimal different parts from fsl-edma

Changes for v3:
none

Changes for v4:
- patch simplified from 4/4 into 2/2
- collecting all the mcf-edma-related changes

Changes for v5:
none
---
 drivers/dma/Kconfig|  11 +
 drivers/dma/Makefile   |   1 +
 drivers/dma/mcf-edma.c | 299 +
 include/linux/platform_data/dma-mcf-edma.h |  38 +++
 4 files changed, 349 insertions(+)
 create mode 100644 drivers/dma/mcf-edma.c
 create mode 100644 include/linux/platform_data/dma-mcf-edma.h

diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index ca1680afa20a..23f444608514 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -320,6 +320,17 @@ config LPC18XX_DMAMUX
  Enable support for DMA on NXP LPC18xx/43xx platforms
  with PL080 and multiplexed DMA request lines.
 
+config MCF_EDMA
+tristate "Freescale eDMA engine support, ColdFire mcf5441x SoCs"
+depends on M5441x
+select DMA_ENGINE
+select DMA_VIRTUAL_CHANNELS
+help
+  Support the Freescale ColdFire eDMA engine, 64-channel
+  implementation that performs complex data transfers with
+  minimal intervention from a host processor.
+  This module can be found on Freescale ColdFire mcf5441x SoCs.
+
 config MMP_PDMA
bool "MMP PDMA support"
depends on ARCH_MMP || ARCH_PXA || COMPILE_TEST
diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile
index 66022f59fca4..d97f317f4b34 100644
--- a/drivers/dma/Makefile
+++ b/drivers/dma/Makefile
@@ -32,6 +32,7 @@ obj-$(CONFIG_DW_DMAC_CORE) += dw/
 obj-$(CONFIG_EP93XX_DMA) += ep93xx_dma.o
 obj-$(CONFIG_FSL_DMA) += fsldma.o
 obj-$(CONFIG_FSL_EDMA) += fsl-edma.o fsl-edma-common.o
+obj-$(CONFIG_MCF_EDMA) += mcf-edma.o fsl-edma-common.o
 obj-$(CONFIG_FSL_RAID) += fsl_raid.o
 obj-$(CONFIG_HSU_DMA) += hsu/
 obj-$(CONFIG_IMG_MDC_DMA) += img-mdc-dma.o
diff --git a/drivers/dma/mcf-edma.c b/drivers/dma/mcf-edma.c
new file mode 100644
index ..9e1d55a5cc90
--- /dev/null
+++ b/drivers/dma/mcf-edma.c
@@ -0,0 +1,299 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2013-2014 Freescale Semiconductor, Inc
+// Copyright (c) 2017 Sysam, Angelo Dureghello  
+/*
+ * drivers/dma/mcf-edma.c
+ *
+ * Driver for the Freescale ColdFire 64-ch eDMA implementation,
+ * derived from drivers/dma/fsl-edma.c.
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "fsl-edma-common.h"
+
+#define EDMA_CHANNELS  64
+#define EDMA_MASK_CH(x)((x) & GENMASK(5, 0))
+
+static irqreturn_t mcf_edma_tx_handler(int irq, void *dev_id)
+{
+   struct fsl_edma_engine *mcf_edma = dev_id;
+   struct edma_regs *regs = _edma->regs;
+   unsigned int ch;
+   struct fsl_edma_chan *mcf_chan;
+   u64 intmap;
+
+   intmap = ioread32(regs->inth);
+   intmap <<= 32;
+   intmap |= ioread32(regs->intl);
+   if (!intmap)
+   return IRQ_NONE;
+
+   for (ch = 0; ch < mcf_edma->n_chans; ch++) {
+   if (intmap & (0x1 << ch)) {
+   iowrite8(EDMA_MASK_CH(ch), regs->cint);
+
+   mcf_chan = _edma->chans[ch];
+
+   spin_lock(_chan->vchan.lock);
+   if (!mcf_chan->edesc->iscyclic) {
+   list_del(_chan->edesc->vdesc.node);
+   vchan_cookie_complete(_chan->edesc->vdesc);
+   mcf_chan->edesc = NULL;
+   mcf_chan->status = DMA_COMPLETE;
+   mcf_chan->idle = true;
+   } else {
+   vchan_cyclic_callback(_chan->edesc->vdesc);
+   }
+
+   if (!mcf_chan->edesc)
+   fsl_edma_xfer_desc(mcf_chan);
+
+   spin_unlock(_chan->vchan.lock);
+   }
+   }
+
+   return IRQ_HANDLED;
+}
+
+static irqreturn_t mcf_edma_err_handler(int irq, void *dev_id)
+{
+   struct fsl_edma_engine *mcf_edma = dev_id;
+   struct edma_regs *regs = _edma->regs;
+   unsigned int err, ch;
+
+   err = ioread32(regs->errl);
+   if (!err)
+   return IRQ_NONE;
+
+   for (ch = 0; ch <