Wiki

This version (15 Nov 2018 13:26) was approved by mirceac.

AD4003/AD4007/AD4011/AD4020/ADAQ40XX Linux Driver

Supported Devices

Evaluation Boards

Description

This is a Linux industrial I/O (IIO) subsystem driver, targeting single channel serial interface ADCs. The industrial I/O subsystem provides a unified framework for drivers for many different types of converters and sensors using a number of different physical interfaces (i2c, spi, etc). See IIO for more information.

Status

Source Mainlined?
git [No]

Files

Driver setup

Since AD4003/4007/4011/4020 are high speed analog-to-digital converters with speeds up to 2 Msps additional components are required in order to achieve high performance. In this scenario the following hdl components are required:

The device will interface with these components and follow the device tree bindings.

This specifies any shell prompt running on the target

&fpga_axi {                                                                      
         rx_dma: rx-dmac@44a30000 {                                               
                 compatible = "adi,axi-dmac-1.00.a";                              
                 reg = <0x44a30000 0x1000>;                                       
                 #dma-cells = <1>;                                                
                 interrupts = <0 57 0>;                                           
                 clocks = <&clkc 16>;                                             
                                                                                  
                 adi,channels {                                                   
                         #size-cells = <0>;                                       
                         #address-cells = <1>;                                    
                                                                                  
                         dma-channel@0 {                                          
                                 reg = <0>;                                       
                                 adi,source-bus-width = <32>;                     
                                 adi,source-bus-type = <1>;                       
                                 adi,destination-bus-width = <64>;                
                                 adi,destination-bus-type = <0>;                  
                         };                                                       
                 };                                                               
         };                                                                       
                                                                                  
         axi_spi_engine_0: axi-spi-engine@44a00000 {                              
                 compatible = "adi,axi-spi-engine-1.00.a";                        
                 reg = <0x44a00000 0x1000>;                                       
                 interrupt-parent = <&intc>;                                      
                 interrupts = <0 56 4>;                                           
                 clocks = <&clkc 15 &clkc 15>;                                    
                 clock-names = "s_axi_aclk", "spi_clk";                           
                 num-cs = <1>;                                                    
                                                                                 
                 #address-cells = <0x1>;                                          
                 #size-cells = <0x0>;                                             
                                                                                  
                 ad4020: adc@0 {                                                  
                         compatible = "ad4020";                                   
                         reg = <0>;                                               
                         spi-max-frequency = <71000000>;                          
                                                                                  
                         dmas = <&rx_dma 0>;                                      
                         dma-names = "rx";                                        
                                                                                  
                         vref-supply = <&vref>;                                   
                         #io-channel-cells = <1>;                                 
                 };                                                               
         };                                                                       
 };    

Driver testing

Each and every IIO device, typically a hardware chip, has a device folder under /sys/bus/iio/devices/iio:deviceX. Where X is the IIO index of the device. Under every of these directory folders reside a set of files, depending on the characteristics and features of the hardware device in question. These files are consistently generalized and documented in the IIO ABI documentation. In order to determine which IIO deviceX corresponds to which hardware device, the user can read the name file /sys/bus/iio/devices/iio:deviceX/name. In case the sequence in which the iio device drivers are loaded/registered is constant, the numbering is constant and may be known in advance.

02 Mar 2011 15:16

TIP: An example program which uses the interface can be found here:


This specifies any shell prompt running on the target

root@analog:/sys/bus/iio/devices# ls -l
total 0
lrwxrwxrwx 1 root root 0 Jan  1  1970 iio:device0 -> ../../../devices/soc0/fpga-axi@0/44a00000.axi-spi-engine/spi_master/spi0/spi0.0/iio:device0
lrwxrwxrwx 1 root root 0 Jan  1  1970 iio:device1 -> ../../../devices/soc0/amba/f8007100.adc/iio:device1
lrwxrwxrwx 1 root root 0 Jan  1  1970 iio_sysfs_trigger -> ../../../devices/iio_sysfs_trigger

root@analog:/sys/bus/iio/devices# 
root@analog:/sys/bus/iio/devices# cd iio\:device0
root@analog:/sys/bus/iio/devices/iio:device0# ls -l
total 0
drwxrwxrwx 2 root root    0 Jan  1  1970 buffer
-rw-rw-rw- 1 root root 4096 Jan  1  1970 dev
-rw-rw-rw- 1 root root 4096 Jan  1  1970 in_voltage0_raw
-rw-rw-rw- 1 root root 4096 Jan  1  1970 in_voltage0_scale
-rw-rw-rw- 1 root root 4096 Jan  1  1970 name
lrwxrwxrwx 1 root root    0 Nov  2 08:43 of_node -> ../../../../../../../../firmware/devicetree/base/fpga-axi@0/axi-spi-engine@44a00000/adc@0
drwxrwxrwx 2 root root    0 Jan  1  1970 power
-rw-rw-rw- 1 root root 4096 Jan  1  1970 sampling_frequency
drwxrwxrwx 2 root root    0 Jan  1  1970 scan_elements
lrwxrwxrwx 1 root root    0 Nov  2 08:43 subsystem -> ../../../../../../../../bus/iio
-rw-rw-rw- 1 root root 4096 Jan  1  1970 uevent

Show device name

This specifies any shell prompt running on the target

root@analog:/sys/bus/iio/devices/iio:device0# cat name
ad4020

Show channel scale

Description:
Scale to be applied to in_voltagex_raw in order to obdatin the measured voltage in millivolts

This specifies any shell prompt running on the target

root@analog:/sys/bus/iio/devices/iio:device0# cat in_voltage0_scale 
0.002384185

More Information

resources/tools-software/linux-drivers/iio-adc/ad400x.txt · Last modified: 14 Nov 2018 11:26 by mirceac