Re: [PATCH] fsl-dma: allow Freescale Elo DMA driver to be compiled as a module

2008-09-24 Thread Kumar Gala


On Sep 19, 2008, at 10:11 AM, Timur Tabi wrote:

Modify the Freescale Elo / Elo Plus DMA driver so that it can be  
compiled as

a module.

The primary change is to stop treating the DMA controller as a bus,  
and the
DMA channels as devices on the bus.  This is because the Open  
Firmware (OF)
kernel code does not allow busses to be removed, so although we can  
call

of_platform_bus_probe() to probe the DMA channels, there is no
of_platform_bus_remove().  Therefore, the DMA channels must be  
manually probed.


Signed-off-by: Timur Tabi [EMAIL PROTECTED]
---

(Reposting because I forgot to CC: the maintainers)

This patch is for the 2.6.28 kernel.  This patch exposes a bug in  
the dmatest
module, so my other patch dmatest: properly handle duplicate DMA  
channels

should be applied if this patch is applied.

drivers/dma/Kconfig  |   10 ++--
drivers/dma/fsldma.c |  165 + 
+

drivers/dma/fsldma.h |2 +
3 files changed, 119 insertions(+), 58 deletions(-)


Dan, any update on this patch?

- k
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH] fsl-dma: allow Freescale Elo DMA driver to be compiled as a module

2008-09-24 Thread Timur Tabi
Kumar Gala wrote:

 Dan, any update on this patch?

I'm going to post a new version.  This whole thing is more complicated than I
thought.

-- 
Timur Tabi
Linux kernel developer at Freescale
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH] fsl-dma: allow Freescale Elo DMA driver to be compiled as a module

2008-09-19 Thread Timur Tabi
Modify the Freescale Elo / Elo Plus DMA driver so that it can be compiled as
a module.

The primary change is to stop treating the DMA controller as a bus, and the
DMA channels as devices on the bus.  This is because the Open Firmware (OF)
kernel code does not allow busses to be removed, so although we can call
of_platform_bus_probe() to probe the DMA channels, there is no
of_platform_bus_remove().  Therefore, the DMA channels must be manually probed.

Signed-off-by: Timur Tabi [EMAIL PROTECTED]
---

(Reposting because I forgot to CC: the maintainers) 

This patch is for the 2.6.28 kernel.  This patch exposes a bug in the dmatest
module, so my other patch dmatest: properly handle duplicate DMA channels
should be applied if this patch is applied.

 drivers/dma/Kconfig  |   10 ++--
 drivers/dma/fsldma.c |  165 ++
 drivers/dma/fsldma.h |2 +
 3 files changed, 119 insertions(+), 58 deletions(-)

diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index cd30390..9dfd502 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -48,13 +48,13 @@ config DW_DMAC
  can be integrated in chips such as the Atmel AT32ap7000.
 
 config FSL_DMA
-   bool Freescale MPC85xx/MPC83xx DMA support
-   depends on PPC
+   tristate Freescale Elo and Elo Plus DMA support
+   depends on PPC_83xx || PPC_85xx || PPC_86xx
select DMA_ENGINE
---help---
- Enable support for the Freescale DMA engine. Now, it support
- MPC8560/40, MPC8555, MPC8548 and MPC8641 processors.
- The MPC8349, MPC8360 is also supported.
+ Enable support for the Freescale Elo and Elo Plus DMA controllers.
+ The Elo is the DMA controller on 83xx parts, and the Elo Plus is
+ the DMA controller on 85xx and 86xx parts.
 
 config MV_XOR
bool Marvell XOR engine support
diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c
index c0059ca..327c485 100644
--- a/drivers/dma/fsldma.c
+++ b/drivers/dma/fsldma.c
@@ -372,6 +372,10 @@ static int fsl_dma_alloc_chan_resources(struct dma_chan 
*chan,
struct fsl_dma_chan *fsl_chan = to_fsl_chan(chan);
LIST_HEAD(tmp_list);
 
+   /* Has this channel already been allocated? */
+   if (fsl_chan-desc_pool)
+   return 1;
+
/* We need the descriptor to be aligned to 32bytes
 * for meeting FSL DMA specification requirement.
 */
@@ -381,7 +385,7 @@ static int fsl_dma_alloc_chan_resources(struct dma_chan 
*chan,
if (!fsl_chan-desc_pool) {
dev_err(fsl_chan-dev, No memory for channel %d 
descriptor dma pool.\n, fsl_chan-id);
-   return 0;
+   return -ENOMEM;
}
 
return 1;
@@ -410,6 +414,8 @@ static void fsl_dma_free_chan_resources(struct dma_chan 
*chan)
}
spin_unlock_irqrestore(fsl_chan-desc_lock, flags);
dma_pool_destroy(fsl_chan-desc_pool);
+
+   fsl_chan-desc_pool = NULL;
 }
 
 static struct dma_async_tx_descriptor *
@@ -912,33 +918,37 @@ out:
return err;
 }
 
-static int __devinit of_fsl_dma_chan_probe(struct of_device *dev,
-   const struct of_device_id *match)
+static int __devinit fsl_dma_chan_probe(struct fsl_dma_device *fdev,
+   struct device_node *node, u32 feature, const char *compatible)
 {
-   struct fsl_dma_device *fdev;
struct fsl_dma_chan *new_fsl_chan;
+   const u32 *iprop;
int err;
 
-   fdev = dev_get_drvdata(dev-dev.parent);
-   BUG_ON(!fdev);
-
/* alloc channel */
new_fsl_chan = kzalloc(sizeof(struct fsl_dma_chan), GFP_KERNEL);
if (!new_fsl_chan) {
-   dev_err(dev-dev, No free memory for allocating 
+   dev_err(fdev-dev, No free memory for allocating 
dma channels!\n);
return -ENOMEM;
}
 
+   new_fsl_chan-of_dev = of_platform_device_create(node, NULL, fdev-dev);
+   if (!new_fsl_chan-of_dev) {
+   dev_err(fdev-dev, cannot create platform device\n);
+   err = -EINVAL;
+   goto err_no_dev;
+   }
+
/* get dma channel register base */
-   err = of_address_to_resource(dev-node, 0, new_fsl_chan-reg);
+   err = of_address_to_resource(node, 0, new_fsl_chan-reg);
if (err) {
-   dev_err(dev-dev, Can't get %s property 'reg'\n,
-   dev-node-full_name);
+   dev_err(fdev-dev, Can't get %s property 'reg'\n,
+   node-full_name);
goto err_no_reg;
}
 
-   new_fsl_chan-feature = *(u32 *)match-data;
+   new_fsl_chan-feature = feature;
 
if (!fdev-feature)
fdev-feature = new_fsl_chan-feature;
@@ -948,17 +958,22 @@ static int __devinit of_fsl_dma_chan_probe(struct 
of_device *dev,
 */
WARN_ON(fdev-feature != new_fsl_chan-feature);
 
-