Using NIOS Software programming Interface for Linux applications on ARM HPS

Hi, I’m using Socrates 2 board for the purpose of evaluation: using FPGA as coprocessor doing compuations on data stored in DDRAM attached to HPS.
There are many useful Avalon MM components for Qsys but I’m not sure what is the best way to access them in my linux application. For example Scatter Gather DMA.
Currently I’m controlling this DMA in Linux by setting it’s registers which works so far.
The register and low level programming of this DMA is described in UG-01085 (Embedded Peripherals IP User Guide) and there is also a note about C files and methods (Page 241 ff). But this code was intended for NIOS and thus does not compile “out of the box” for Linux on HPS. So my question is: should we try to use this NIOS code or is something similar implemented some where else? What is the best practice of using Qsys components in Linux?

Try always to search in the altera-opensource(kernel) git for drivers or doc.
for example, try this on the git top level:
grep -inIER “sgdma” . #you will find there a driver (altera_sgdma.c) and a example (altera_tse_main.c)#

grep -inIER “altr,” . #handy for links between devicetree-drivers#

grep -inIER “altera” . #You will get maybe alot of things there, but it OK!!!#

So!! you have your driver there!!

Hi murillo,
thanks for advice, I just had a quick look on git repo and in particular sgdma. This answers my question: Nios code is not reused there. The sgdma layer is re-implemented with different interface as used in altera_avalon_sgdma.h and described in the manual. I think the Nios code is quite mature, stable and is good documented and it would be nice to use this in linux applications. In particular the sgdma implementation in altera-opensource seems to be a part of network driver for Altera TSE Ethernet core which is also re-implemented without obvious relation to well documentad software programming interface described in it’s manual (UG-01008). I will try to use and adopt old nios interface and post my experience here. I think it might be helpful to people who migrate old nios projects to ARM HPS.

As the original question of the topic was answered I renamed the title to more appropriate one.