0

for my application I would to send some data allocated in RAM to PWM fifo through DMA in Kernel Space. I would to use DMA to generate an Interrupt when the data vector is completed, so to load next one vector and trigger other behavior...

I read "Linux Device Drivers" 3rd edition from O'Reilly but I'm a bit confused about using DMA Engine.

I would ask which step I have to follow to start a DMA transaction Memory-to-Device (PWM) with Interrupt callback?

EDIT 1:

I need to learn how to use Linux DMA API for my case (memory -> pwm fifo), in kernel space.

fdellorso
  • 1
  • 1
  • You need to have DMA engine driver (under *drivers/dma*, and corresponding support in the PWM driver under *drivers/pwm*. – 0andriy Jun 29 '19 at 07:45
  • Possible duplicate of [Linux kernel device driver to DMA from a device into user-space memory](https://stackoverflow.com/questions/5539375/linux-kernel-device-driver-to-dma-from-a-device-into-user-space-memory) – wallyk Jun 29 '19 at 07:55
  • @0andriy DMA & PWM Drivers for BCM2835 are both present in the drivers folder. I need to learn how to use DMA API for my application. Reading the chapter from "LInux Device Drivers" book, I notice that isn't so obvious. My ask is for a simplier guideline to follow... – fdellorso Jun 30 '19 at 13:04
  • I didn’t get, your are not asking about kernel? In user space usually no one cares much how exactly data is transferred, everything depends on the drivers and platform configuration. – 0andriy Jul 01 '19 at 08:22
  • @wallyk, it’s not a duplicate of that anyhow. – 0andriy Jul 01 '19 at 08:24
  • Heyy @fdellorso I am working on a similar project, did you figured out how to push data from memory to pwm fifo? Thank you very much!! :D – dzuda11 Dec 29 '19 at 20:52

1 Answers1

1

I have sumbit a patch to improve ethernet performance by using dma engine. In this patch, driver is able to move packets from rx fifo to RAM (from device to mem. ) So you can get some infomation about using dma engine in linux kernel from this patch. sun4i-emac.c: add dma support

steps:

  1. request an dma channel (api: dma_request_chan)
  2. setup dma channel (api: dmaengine_slave_config)
  3. map data buf to dma region (api: dma_map_single)
  4. prepare for transfer (api: dmaengine_prep_slave_single)
  5. submit dma transfer request (api: dmaengine_submit)
  6. launch! (api: dma_async_issue_pending)
BrooksLee
  • 91
  • 8