AnsweredAssumed Answered

Is it possible to use iio_device_reg_read()/write() to set and get values from AXI registers?

Question asked by VANSMILE on Jul 18, 2017
Latest reply on Jul 27, 2017 by mhennerich


My DUT is PicoZed SDR development kit board. I am trying to read "axi_ad9361 block" 32-bit register inside ad9361-iiosream.c example with a help of iio_device_reg_read() API provided by Libiio framework, but still no succeed with error code -13. I do it like this:

assert(get_ad9361_stream_dev(ctx,RX,&rx) && "No rx dev found"); // from ad9361-iiostream.c example

ret = iio_device_reg_read(rx,0x800000BC,&value); 

Trying to find solution I found the followind post why iio_device_reg_read() doesn't work?  and as I understood I have two options using these API:

1) if I use physical addresses starting from 0x0 for specific device I get access to its SPI registers

2) if I use virtual addresses starting from 0x80000000 I get access to the AXI registers, because they are mmaped by Libiio drivers to this virtual address in OS.

In my case I would like to use the 2-nd option. Here are my AXI blocks:

In order to check my understanding I used iio-oscilloscope software provided by AD (debug tab) in order to write 32-bit value inside register 0x790200BC of "axi_ad9361" block. This register I choosed from hld reg map. I found that "cf-ad9361-lpc" is the exact device which is MMAPED to axi block and used 0x800000BC virtual address in order to write values there. And I can succesfully read these values with AXI-JTAG debugger from Vivado using address 0x790200BC. I would like to do the same but inside ad9361-iiostream.c. So my questions are:

1) Is my understaning of the whole workflow correct ?

2) How to read and write AXI registers with a help of iio_device_reg_read()/write() if it is possible? 

3) Are all these axi blocks already mmaped in ad9361-iiostream.c to some specific devices. For example axi_ad9361 to cf-ad9361-lpc device? 

4) What do I need to do in order to mmap custom AXI block if I would like to do it somewhen ? 

I will be very grateful to receive any advice and help. Thank you!