cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
laursand
Contributor
Contributor
3,282 Views
Registered: ‎08-09-2013

linux xilinx kernel new driver dependencies

hi,

I am new to linux/driver development so this will seem like a very basic question but I hope I can get some pointers...

 

I am trying to interface with a AXI-DMA module inside the Zynq PL. The Kernel linux-xlnx already has a xilinx_axidma.c module (and the resource actually gets mounted fine at boot up).

 

 

I need to do some custom things with the AXI-DMA module (for example, have a custom IRQ handling). I also need to simply use it to transfer data (in my case, a S2MM from device->PS).

 

This might sound super basic, but: how do we write a driver that can depend on another driver? I looked at "linux driver dependency" online - it looks like I should be adding some EXPORT macros to export functions from xilinx_axidma.c. Doesn't seem completely right...

 

Should I duplicate the xilinx_axidma.c altogether to create a new driver with a different resource name from scratch?

Should I add some EXPORT functions in xilinx_axidma.c, recompile the kernel, then call these from my driver?

 

Suggestions welcome,

thank you!

 

 

 

0 Kudos
3 Replies
laursand
Contributor
Contributor
3,257 Views
Registered: ‎08-09-2013

I think this is one approach that kind of answers my question:

https://github.com/bmartini/zynq-xdma

 

The xdma driver creates a dev/xdma node that can be called (from user mode) to configure/start/stop DMA transfers. It accesses (at __init time) the installed dma channels registered in the linux DMA engine framework.

 

The xilinx_axidma driver provides the low-level layer to the AXI DMA engine and doesn't need to be duplicated/rewritten/customized, nor its functions need to be accessed. Things simply communicate through that linux DMA engine.

 

I figured I'd post to help other beginners like me understand a bit how drivers can interact with each other, and for anyone to chime in in case this is a completely wrong approach :-)

thanks

 

 

0 Kudos
pierucci
Visitor
Visitor
2,084 Views
Registered: ‎04-29-2015

Hi laursand,

 

I am currently trying to add a dma interface from the pl to the ps. I found the zynq-xdma driver, but I don't know how to compile the given source code. I allready added the dma ipcore, generated the bitstream and builded the petalinux project with the necessary dma drivers selected. 

 

Can you please describe how you managed to add the module from zynq-xdma to the linux kernel?

 

Thanx in Advance,

Bruno

0 Kudos
laursand
Contributor
Contributor
2,065 Views
Registered: ‎08-09-2013

hi Bruno,

I couldn't figure out how to "inherit" a dma driver.

I ended up duplicating that driver to add my own functions and compiling this as its own driver. Then just entered the resource info in the DTS file.

 

Another way may be to enter a dma resource in the DTS file, and handle interrupts separately in your own driver. There are lots of online resource to write your own drivers - it's not too difficult, start from an existing one.

Thanks and good luck

 

0 Kudos