MPC8349E's DMA controller like ISA controller but with more feature?
Hi EveryOne!
This is first time I send a letter to everyone. If I make mistake, please free to correct me. :)
I'm trying to write the first driver which is concerned with DMA. I'm reading dmatest.c and have some confused problem. Oh! No! I have many problem..:D MPC8349's DMA controller like ISA controller but with more features? I want to mean that MPC8349E's DMA controller will send -MEMR, -MEMW, -IOR, -IOW ?. So in DMA APIs such as dma_addr_t dma_map_single(struct device *dev, void *cpu_addr, size_t size, enum dma_data_direction direction)
*dev will pointer to DMA controller or to peripheral device(FPGA, ISA device)? From dmatest.c , *dev seem to pointer to a channel of DMA controller. The channel is connected to a peripheral device. So calling the API, DMA controller will be able to access memory from cpu_addr, and peripheral device does too?
Look struct dma_async_tx_descriptor *(*device_prep_dma_memcpy)(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src, size_t len, unsigned long flags); I want to DMA from device to memory. So how to I can get address of peripheral device ?
Regards!
Quoted 5 lines · lhthanh
<body bgcolor="#ffffff" text="#000000">
<font size="+1">Hi EveryOne!<br>
<br>
This is first time I send a letter to everyone. If I make mistake, please free to correct me. :)<br>
Please post in plaintext, not HTML.
Quoted 1 line
MPC8349's DMA controller like ISA controller but with more features?
No. It is for software-directed memory-to-memory transfers (where "memory" can be main-memory, or the buffer of a device that doesn't do DMA itself).
There is no need for anything like ISA's DMA controller, as devices that want to initiate DMA can master the bus themselves.
Quoted 4 lines
So in DMA APIs such as
dma_addr_tdma_map_single(struct device *dev, void *cpu_addr, size_t size, enum dma_data_direction direction)*dev will pointer to DMA controller or to peripheraldevice(FPGA, ISA device)?
It is whatever device is going to be doing the DMA.
Quoted 2 lines
From
dmatest.c, *dev seem to pointer to a channel of DMA controller.
That's because in that case, the DMA controller is the peripheral device being used.
Quoted 1 line
I want to DMA from device to memory.
What kind of device?
Quoted 1 line
So how to I can get address of peripheral device ?
If you have to ask that, it probably means you don't have a specific device buffer in mind that you want an external entity to stuff data into (or suck data from), but rather are dealing with device-initiated DMA. In that case, ignore the DMA controller.
-Scott
On Mon, Apr 20, 2009 at 10:55 AM, Scott Wood <[email protected]> wrot= e:
Quoted 3 lines
No. =A0It is for software-directed memory-to-memory transfers (where "memory" can be main-memory, or the buffer of a device that doesn't do DMA itself).
It can also be used to transfer data to/from a single I/O register, which is how ISA DMA is frequently used.
--=20
Timur Tabi
Linux kernel developer at Freescale
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Thank Scott and Timur!
Quoted 8 lines
Quoted 5 lines · Scott Wood
Timur Tabi (CCed) has written an audio
driver that does something very similar; he could probably tell you more about how to do that (this is why such discussions should be kept on the mailing list rather than taken to private e-mail).
Quoted 5 lines
The code in
drivers/dmacannot be used to send a buffer of data to a single I/O port. That code is just an elaborate version of memcpy that uses the DMA engine to copy data in the background.
Thanks for your explaination! So if I want to transfer a buffer of data from a single I/O port, will not DMA framework also be able ? Have I to write aother driver?
Quoted 7 lines
If you want to transfer a buffer to a single I/O port, you will need to write your own DMA driver, similar to what I've done in
sound/soc/fsl/fsl_dma.c. This is not trivial. You will need to understand the DMA hardware programming model to determine whether you can use direct mode or if you need to create link descriptors.
Actually, I don't want write all because there are serveral DMA code at hand. I only want to use a framework instead of re-writing. And I afraid that I can not write code which assure sharing DMA channels.
Regards!
Quoted 3 lines · lhthanh
Thanks for your explaination! So if I want to transfer a buffer of data from a single I/O port, will not DMA framework
also be able ?
No.
Quoted 1 line
Have I to write aother driver?
Yes.
Quoted 2 lines
Actually, I don't want write all because there are serveral DMA code at hand. I only want to use a framework instead of re-writing.
There is no framework for what you want to do. There is only one other driver that does what you want (sound/soc/fsl/fsl_dma.c), and that is a complicated driver that does many things besides transferring data to an I/O port.
Quoted 1 line
And I afraid that I can not write code which assure sharing DMA channels.
Look at arch/powerpc/boot/dts/mpc8610_hpcd.dts. The DMA channels that are needed by the 8610 audio driver have a different 'compatible' property. This is how you prevent the generic DMA driver from using a channel that you want.
I'm afraid that you're going to have to study the DMA programming model, and my device driver, and write a brand new driver from scratch.
Signature · 2 lines
Timur Tabi Linux kernel developer at Freescale
Quoted 26 lines · lhthanh
Quoted 4 lines
Thanks for your explaination! So if I want to transfer a buffer of data from a single I/O port, will not DMA framework also be able ?
No.
Quoted 2 lines
Have I to write aother driver?
Yes.
Quoted 2 lines
Actually, I don't want write all because there are serveral DMA code at hand. I only want to use a framework instead of re-writing.
There is no framework for what you want to do. There is only one other driver that does what you want (
sound/soc/fsl/fsl_dma.c), and that is a complicated driver that does many things besides transferring data to an I/O port.Quoted 2 lines
And I afraid that I can not write code which assure sharing DMA channels.
Quoted 9 lines
Look at
arch/powerpc/boot/dts/mpc8610_hpcd.dts. The DMA channels that are needed by the 8610 audio driver have a different 'compatible' property. This is how you prevent the generic DMA driver from using a channel that you want.I'm afraid that you're going to have to study the DMA programming model, and my device driver, and write a brand new driver from scratch.
Thank Scott and Timur very much! I will study more DMA driver and come back later. :)
Regard!