Wiki

This version (07 Jan 2021 08:47) was approved by Ioana Chelaru.The Previously approved version (18 Jul 2018 15:25) is available.Diff

AD5770R IIO DAC Linux Driver

Supported Devices

This driver supports the

Evaluation Boards

Description

This is a Linux industrial I/O (IIO) subsystem driver, targeting multi-channel serial interface DACs. 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.

Source Code

Status

Source Mainlined?
git [No]

Devicetree

Required devicetree properties for the AD5770R:

  • compatible: Must be “adi,ad5770r”
  • reg: SPI chip select number for the device
  • spi-max-frequency: Max SPI frequency to use (< 10000000)
  • child nodes: Each child node represents one channel.

Optional properties:

  • vref: Specify the voltage of the external reference used.
  • reset-gpios: GPIO spec for the RESET pin. If specified, it will be asserted during driver probe.
        ad5770r@0 {                                                              
                  compatible = "ad5770r";                                          
                  reg = <0>;                                                       
                  spi-max-frequency = <1000000>;                                   
                  vref-supply = <&vref>;                                           
                                                                                   
                  reset-gpios = <&gpio 22 0>;                                      
                                                                                   
                  channel@0 {                                                      
                          num = <0>;                                               
                          adi,range-microamp = <0 300000>;                         
                  };                                                               
                                                                                   
                  channel@1 {                                                      
                          num = <1>;                                               
                          adi,range-microamp = <0 140000>;                         
                  };                                                               
                                                                                   
                  channel@2 {                                                      
                          num = <2>;                                               
                          adi,range-microamp = <0 55000>;                          
                  };                                                               
                                                                                   
                  channel@3 {                                                      
                          num = <3>;                                               
                          adi,range-microamp = <0 45000>;                          
                  };                                                               
                                                                                   
                  channel@4 {                                                      
                          num = <4>;                                               
                          adi,range-microamp = <0 45000>;                          
                  };                                                               
                                                                                   
                  channel@5 {                                                      
                          num = <5>;                                               
                          adi,range-microamp = <0 45000>;                          
                  };                                                               
         };
         
         vref: fixedregulator@0 {                                                 
                  compatible = "regulator-fixed";                                  
                  regulator-name = "fixed-supply";                                 
                  regulator-min-microvolt = <1250000>;                             
                  regulator-max-microvolt = <1250000>;                             
         };  

Adding Linux driver support

Configure kernel with “make menuconfig” (alternatively use “make xconfig” or “make qconfig”)

Linux Kernel Configuration
    Device Drivers  --->
        ...
        <*>     Industrial I/O support --->
            --- Industrial I/O support
            ...
            Digital to analog converters  ---> 
                ...
                <*> Analog Devices AD5770R IDAC driver
                ...
            ...
        ...

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

This specifies any shell prompt running on the target

pi@raspberrypi:/sys/bus/iio/devices/iio:device0 $ cd /sys/bus/iio/devices/
pi@raspberrypi:/sys/bus/iio/devices $ ls
iio:device0  iio:device1
pi@raspberrypi:/sys/bus/iio/devices $ cd iio\:device0
pi@raspberrypi:/sys/bus/iio/devices/iio:device0 $ ls -l
total 0
-r--r--r-- 1 root root 4096 Jul 18 12:12 dev
-r--r--r-- 1 root root 4096 Jul 18 12:12 name
lrwxrwxrwx 1 root root    0 Jul 18 12:12 of_node -> ../../../../../../../../firmware/devicetree/base/soc/spi@7e204000/ad5770r@0
-rw-r--r-- 1 root root 4096 Jul 18 12:12 out_current0_filter_low_pass_3db_frequency
-rw-r--r-- 1 root root 4096 Jul 18 12:12 out_current0_powerdown
-rw-r--r-- 1 root root 4096 Jul 18 12:12 out_current0_raw
-rw-r--r-- 1 root root 4096 Jul 18 12:12 out_current0_scale
-rw-r--r-- 1 root root 4096 Jul 18 12:12 out_current1_filter_low_pass_3db_frequency
-rw-r--r-- 1 root root 4096 Jul 18 12:12 out_current1_powerdown
-rw-r--r-- 1 root root 4096 Jul 18 12:12 out_current1_raw
-rw-r--r-- 1 root root 4096 Jul 18 12:12 out_current1_scale
-rw-r--r-- 1 root root 4096 Jul 18 12:12 out_current2_filter_low_pass_3db_frequency
-rw-r--r-- 1 root root 4096 Jul 18 12:12 out_current2_powerdown
-rw-r--r-- 1 root root 4096 Jul 18 12:12 out_current2_raw
-rw-r--r-- 1 root root 4096 Jul 18 12:12 out_current2_scale
-rw-r--r-- 1 root root 4096 Jul 18 12:12 out_current3_filter_low_pass_3db_frequency
-rw-r--r-- 1 root root 4096 Jul 18 12:12 out_current3_powerdown
-rw-r--r-- 1 root root 4096 Jul 18 12:12 out_current3_raw
-rw-r--r-- 1 root root 4096 Jul 18 12:12 out_current3_scale
-rw-r--r-- 1 root root 4096 Jul 18 12:12 out_current4_filter_low_pass_3db_frequency
-rw-r--r-- 1 root root 4096 Jul 18 12:12 out_current4_powerdown
-rw-r--r-- 1 root root 4096 Jul 18 12:12 out_current4_raw
-rw-r--r-- 1 root root 4096 Jul 18 12:12 out_current4_scale
-rw-r--r-- 1 root root 4096 Jul 18 12:12 out_current5_filter_low_pass_3db_frequency
-rw-r--r-- 1 root root 4096 Jul 18 12:12 out_current5_powerdown
-rw-r--r-- 1 root root 4096 Jul 18 12:12 out_current5_raw
-rw-r--r-- 1 root root 4096 Jul 18 12:12 out_current5_scale
-r--r--r-- 1 root root 4096 Jul 18 12:12 out_current_filter_low_pass_3db_frequency_available
drwxr-xr-x 2 root root    0 Jul 18 12:12 power
lrwxrwxrwx 1 root root    0 Jul 18 12:12 subsystem -> ../../../../../../../../bus/iio
-rw-r--r-- 1 root root 4096 Jul 18 12:12 uevent

Show device name

This specifies any shell prompt running on the target

pi@raspberrypi:/sys/bus/iio/devices/iio:device0 $ cat name
ad5770r

Show scale

Description:
/sys/bus/iio/devices/iio:deviceX/out_currentY_scale

scale to be applied to out_currentY_raw in order to obtain the measured current in milliamps.

This specifies any shell prompt running on the target

root@raspberrypi:/sys/bus/iio/devices/iio:device0# cat out_current0_scale 
0.018310546

Set channel Y output current

Description:
/sys/bus/iio/devices/iio:deviceX/out_currentY_raw

Raw (unscaled, no bias etc.) output current for channel Y.

This specifies any shell prompt running on the target

root@raspberrypi:/sys/bus/iio/devices/iio:device0# echo 5000 > out_current0_raw 

I = out_current0_raw * out_current0_scale = 5000 * 0,018310546 = 91,55273 mA

Enable power down mode for the device

/sys/bus/iio/devices/iio:deviceX/out_currentY_powerdown

Description:
Writing 1 causes channel Y to enter power down mode. Clearing returns to normal operation.

This specifies any shell prompt running on the target

root@raspberrypi:/sys/bus/iio/devices/iio:device0# echo 1 > out_current0_powerdown 
root@raspberrypi:/sys/bus/iio/devices/iio:device0# cat out_current0_powerdown
1
root@raspberrypi:/sys/bus/iio/devices/iio:device0# echo 0 > out_current0_powerdown
root@raspberrypi:/sys/bus/iio/devices/iio:device0# cat out_current0_powerdown
0

Show available filter frequencies

/sys/bus/iio/devices/iio:deviceX/out_current_filter_low_pass_3db_frequency_available

Description:
Contains available filter frequencies.

This specifies any shell prompt running on the target

root@raspberrypi:/sys/bus/iio/devices/iio:device0# cat out_current_filter_low_pass_3db_frequency_available 
153 357 715 1400 2800 262000

Set channel Y filter frequency

/sys/bus/iio/devices/iio:deviceX/out_current0_filter_low_pass_3db_frequency

Description:
Write filter value to channel Y.

This specifies any shell prompt running on the target

root@raspberrypi:/sys/bus/iio/devices/iio:device0# cat out_current0_filter_low_pass_3db_frequency 
262000
root@raspberrypi:/sys/bus/iio/devices/iio:device0# echo 1000 > out_current0_filter_low_pass_3db_frequency 
root@raspberrypi:/sys/bus/iio/devices/iio:device0# cat out_current0_filter_low_pass_3db_frequency
1400

More Information

resources/tools-software/linux-drivers/iio-dac/ad5770r.txt · Last modified: 07 Jan 2021 08:47 by Ioana Chelaru