Still don’t have a Meld Account?
Join now to be a part of the worlds largest embedded linux community!
Join Now!
Got a question or issue? The meld community is here to help!
Start a discussion
Start a discussion
DMA in powerpc 405EP
ashok.athukuri - August 27, 2010
Hello All,
I'm looking forward to implement DMA for a memory device (mapped to the powerpc 405EP EBC bus), but I dont know where to start !?. Is it u-boot first or the kernel?
Please suggest me some tutorial links to implement this.
Regards,
Ashok

Hello All, To understand
Hello All,
To understand DMA, I tried to implement sample dma module in x86 machine on (SUSE ). here is the code
<code>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/dma-mapping.h>
#include <linux/dmapool.h>
#include <linux/device.h>
static char *buffer= NULL;
static struct device *dev= NULL;
dma_addr_t mapping;
static int __init dma_init(void)
{
buffer = kmalloc(10, GFP_KERNEL);
if(buffer == NULL)
{
printk("kernel unbale to allocate memory for buffer\n");
return -1;
}
int ret = -1;
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if(dev == NULL)
{
kfree(buffer);
return -1;
}
dev_set_name(dev, "asht_dma");
ret = device_register(dev);
printk("device reg ret =%d\n", ret);
if(ret != 0)
{
kfree(buffer);
kfree(dev);
return -1;
}
if(dma_set_mask(dev, 0xffffffff))
{
printk("DMA supports\n");
}
else
{
printk("DMA Not Supported\n");
kfree(buffer);
kfree(dev);
return -1;
}
mapping = dma_map_single(dev, buffer, 10, DMA_TO_DEVICE);
if(mapping == NULL)
{
printk("dma_map_single is failed !!!!!!!!!");
kfree(buffer);
kfree(dev);
return 0;
}
dma_unmap_single(dev, mapping, 10, DMA_TO_DEVICE);
printk("dma modlule inserted\n");
return 0;
}
static void __exit dma_exit(void)
{
kfree(buffer);
//device_unregister(dev);
dma_unmap_single(dev, mapping, 10, DMA_TO_DEVICE);
kfree(dev);
printk("dma modlule removed\n");
}
module_init(dma_init);
module_exit(dma_exit);
MODULE_AUTHOR("ASHT");
MODULE_LICENSE("GPL");
I'm not familiar with
I'm not familiar with PowerPC, so I can only speak in general terms. Typically, there is no need to write a driver from scratch because someone probably already written it. In terms using DMA in powerPC, there seems to be some code for the DMA controller in arch/powerpc/kernel/dma*. May want to take a look. Personally, I usually find it helpful to look at the code for a similar device that is already in the kernel tree.
Also, the code you have above. device name is the only thing that was initialized in dev. I would expect dma_map_single needs a lot more parameters initialized.
Good luck,
Steve