How to do a driver for HPS PL330 DMA Controller?


#1

Hi!

I am using Angstrom running on DE1-SoC with kernel 3.10. I am trying to do a kernel module to perform data transfers from application on user space to a FPGA memory. I understand that:

  • I can use character device driver API and copy_from_user() to copy the buffer from the app to the module.

  • I can use platform device API to find address and properties of PL330 in device tree.

  • I can use DMA-engine API or PL330.c to communicate with the PL330 DMAC and perform the transfers.

Up to now the device driver API is working nicely. There are plenty examples on that. Regarding the platform device I cannot do the binding with PL330. I can see the device entry for the DMAC. Doing cat /prc/device-tree/sopc@/dma@ffe01000/compatible it gives “arm,pl330-14.1arm,pl330arm,primecell” as answer. Its like if the 3 strings in dts are compressed to only one. Regarding the control of the DMAC I can only find Altera examples on DMA-engine for DMACs in the FPGA. I have found for Zynq examples using DMA-engine and directly pl330.h. None of the 4 or 5 I tried compile because some file is always different missing macros or functions.

I would appreciate any help on these questions:

  • Is there any Altera example on binding PL330 or using DMA-engine???

  • Which are the restrictions regarding the OS? Should I switch on DMA options when compiling OS? How can I find wich files to use (DMA-engine or pl330.h).

Thanks!


#2

Hi Roberbot

I would like to know if you successfully able use the PL330 driver?.

Regards,

John


#3

Yes, I didnt find any inbuilt code for controlling the DMA from a driver so I had to do it myself. I ported the code of a baremetal example and created my own driver that can be easily used to transfer data from the
applications to the FPGA as easy as opening a file. What i did was basically to transform the code to use virtual addresses of the OS instead of directly the physical ones.
The driver is here:

And an example on how to use it is available here:

Take a look to the whole repo, you may find some other code interesting. I was building this repo of easy examples that I think is useful since the examples you find in rocketboards and other websites are quite complex.

Regards!


#4

Are these still latest findings on the PL330 on a Cyclone V from Linux? Anything from Intel as of 18.0?

Thanks Robert for the awesome project!