AD7293

AD7293 12-Bit Power Amplifier Current Controller with ADC, DACs, Temperature and Current Sensors.

Supported Devices

Evaluation Boards

Description

This is a Linux industrial I/O (Linux Industrial I/O Subsystem) subsystem driver, targeting serial interface Microwave converters. 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 Linux Industrial I/O Subsystem for more information.

Source Code

Status

Source

Mainlined?

git

WIP

Files

Unlike PCI or USB devices, SPI devices are not enumerated at the hardware level. Instead, the software must know which devices are connected on each SPI bus segment, and what slave selects these devices are using. For this reason, the kernel code must instantiate SPI devices explicitly. The most common method is to declare the SPI devices by bus number.

This method is appropriate when the SPI bus is a system bus, as in many embedded systems, wherein each SPI bus has a number which is known in advance. It is thus possible to pre-declare the SPI devices that inhabit this bus. This is done with an array of struct spi_board_info, which is registered by calling spi_register_board_info().

For more information see: Overview of Linux kernel SPI support

properties

compatible:

  • enum:

  • adi,ad7293

avdd-supply: true

vdrive-supply: true

reset-gpios:

  • maxItems: 1

reg:

  • maxItems: 1

spi-max-frequency:

  • minimum: 1000000

required:

  • compatible

  • reg

  • avdd-supply

  • vdrive-supply

Example

spi {
      spi {
      #address-cells = <1>;
      #size-cells = <0>;
      ad7293@0 {
        compatible = "adi,ad7293";
        reg = <0>;
        spi-max-frequency = <1000000>;
        avdd-supply = <&avdd>;
        vdrive-supply = <&vdrive>;
        reset-gpios = <&gpio 10 0>;
      };
    };

Adding Linux driver support

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

Note

The AD7293 Driver depends on CONFIG_SPI

Linux Kernel Configuration
    Device Drivers  --->
        <*>     Industrial I/O support --->
            --- Industrial I/O support
                Digital to analog converters --->
                    <*> Analog Devices AD7293 Power Amplifier Current Controller

Hardware configuration

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.

root:/> cd /sys/bus/iio/devices/
root:/sys/bus/iio/devices> ls
iio:device0
root:/sys/bus/iio/devices> iio:device0

root:/> ls -l
-r--r--r-- 1 root root 4096 Dec 14 11:48 dev
-rw-r--r-- 1 root root 4096 Dec 14 11:48 in_current0_offset
-rw-r--r-- 1 root root 4096 Dec 14 11:48 in_current0_raw
-rw-r--r-- 1 root root 4096 Dec 14 11:48 in_current0_scale
-rw-r--r-- 1 root root 4096 Dec 14 11:48 in_current1_offset
-rw-r--r-- 1 root root 4096 Dec 14 11:48 in_current1_raw
-rw-r--r-- 1 root root 4096 Dec 14 11:48 in_current1_scale
-rw-r--r-- 1 root root 4096 Dec 14 11:48 in_current2_offset
-rw-r--r-- 1 root root 4096 Dec 14 11:48 in_current2_raw
-rw-r--r-- 1 root root 4096 Dec 14 11:48 in_current2_scale
-rw-r--r-- 1 root root 4096 Dec 14 11:48 in_current3_offset
-rw-r--r-- 1 root root 4096 Dec 14 11:48 in_current3_raw
-rw-r--r-- 1 root root 4096 Dec 14 11:48 in_current3_scale
-r--r--r-- 1 root root 4096 Dec 14 11:48 in_current_scale_available
-rw-r--r-- 1 root root 4096 Dec 14 11:48 in_temp0_offset
-rw-r--r-- 1 root root 4096 Dec 14 11:48 in_temp0_raw
-rw-r--r-- 1 root root 4096 Dec 14 11:48 in_temp1_offset
-rw-r--r-- 1 root root 4096 Dec 14 11:48 in_temp1_raw
-rw-r--r-- 1 root root 4096 Dec 14 11:48 in_temp2_offset
-rw-r--r-- 1 root root 4096 Dec 14 11:48 in_temp2_raw
-rw-r--r-- 1 root root 4096 Dec 14 11:48 in_temp_scale
-rw-r--r-- 1 root root 4096 Dec 14 11:48 in_voltage0_offset
-rw-r--r-- 1 root root 4096 Dec 14 11:48 in_voltage0_raw
-rw-r--r-- 1 root root 4096 Dec 14 11:48 in_voltage0_scale
-rw-r--r-- 1 root root 4096 Dec 14 11:48 in_voltage1_offset
-rw-r--r-- 1 root root 4096 Dec 14 11:48 in_voltage1_raw
-rw-r--r-- 1 root root 4096 Dec 14 11:48 in_voltage1_scale
-rw-r--r-- 1 root root 4096 Dec 14 11:48 in_voltage2_offset
-rw-r--r-- 1 root root 4096 Dec 14 11:48 in_voltage2_raw
-rw-r--r-- 1 root root 4096 Dec 14 11:48 in_voltage2_scale
-rw-r--r-- 1 root root 4096 Dec 14 11:48 in_voltage3_offset
-rw-r--r-- 1 root root 4096 Dec 14 11:48 in_voltage3_raw
-rw-r--r-- 1 root root 4096 Dec 14 11:48 in_voltage3_scale
-r--r--r-- 1 root root 4096 Dec 14 11:48 in_voltage_scale_available
-r--r--r-- 1 root root 4096 Dec 14 11:48 name
lrwxrwxrwx 1 root root    0 Dec 14 11:48 of_node -> ../../../../../../../../firmware/devicetree/base/soc/spi@7e204000/ad7293@0
-rw-r--r-- 1 root root 4096 Dec 14 11:48 out_voltage0_offset
-rw-r--r-- 1 root root 4096 Dec 14 11:48 out_voltage0_raw
-rw-r--r-- 1 root root 4096 Dec 14 11:48 out_voltage1_offset
-rw-r--r-- 1 root root 4096 Dec 14 11:48 out_voltage1_raw
-rw-r--r-- 1 root root 4096 Dec 14 11:48 out_voltage2_offset
-rw-r--r-- 1 root root 4096 Dec 14 11:48 out_voltage2_raw
-rw-r--r-- 1 root root 4096 Dec 14 11:48 out_voltage3_offset
-rw-r--r-- 1 root root 4096 Dec 14 11:48 out_voltage3_raw
-rw-r--r-- 1 root root 4096 Dec 14 11:48 out_voltage4_offset
-rw-r--r-- 1 root root 4096 Dec 14 11:48 out_voltage4_raw
-rw-r--r-- 1 root root 4096 Dec 14 11:48 out_voltage5_offset
-rw-r--r-- 1 root root 4096 Dec 14 11:48 out_voltage5_raw
-rw-r--r-- 1 root root 4096 Dec 14 11:48 out_voltage6_offset
-rw-r--r-- 1 root root 4096 Dec 14 11:48 out_voltage6_raw
-rw-r--r-- 1 root root 4096 Dec 14 11:48 out_voltage7_offset
-rw-r--r-- 1 root root 4096 Dec 14 11:48 out_voltage7_raw
-r--r--r-- 1 root root 4096 Dec 14 11:48 out_voltage_offset_available
drwxr-xr-x 2 root root    0 Dec 14 11:48 power
lrwxrwxrwx 1 root root    0 Dec 14 11:48 subsystem -> ../../../../../../../../bus/iio
-rw-r--r-- 1 root root 4096 Dec 14 11:48 uevent

Show device name

root:/> cd /sys/bus/iio/devices/iio\:device0/
root:/> cat name
ad7293

Set ChannelY Current offset value

/sys/bus/iio/devices/iio:deviceX/in_currentY_offset

Set offset value for the corresponding current sensor channel.

root:/> cat in_current0_offset
0

root:/> echo 20 > in_current0_offset
root:/> cat in_current0_offset
20

Set ChannelY Current gain value

/sys/bus/iio/devices/iio:deviceX/in_currentY_scale

Set gain value for the corresponding current sensor channel.

root:/> cat in_current0_scale
0

root:/> echo 2 > in_current0_scale
root:/> cat in_current0_scale
2

Get Current gain available values

/sys/bus/iio/devices/iio:deviceX/in_current_scale_available

Read available values for the current sensor channel gain.

root:/> cat in_current_scale_available
0 1 2 3 4 5 6 7 8 9 10

Get ChannelY Current raw value

/sys/bus/iio/devices/iio:deviceX/in_currentY_raw

Read raw value for the current sensor channel.

root:/> cat in_current0_raw
2177

Set ChannelY Temperature offset value

/sys/bus/iio/devices/iio:deviceX/in_tempY_offset

Set offset value for the corresponding temperature sensor channel.

root:/> cat in_temp0_offset
0

root:/> echo 20 > in_temp0_offset
root:/> cat in_temp0_offset
20

Get ChannelY Temperature raw value

/sys/bus/iio/devices/iio:deviceX/in_tempY_raw

Read raw value for the temperature sensor channel.

root:/> cat in_temp0_raw
3977

Set ChannelY ADC offset value

/sys/bus/iio/devices/iio:deviceX/in_voltageY_offset

Set offset value for the corresponding ADC channel.

root:/> cat in_voltage0_offset
0

root:/> echo 20 > in_voltage0_offset
root:/> cat in_voltage0_offset
20

Set ChannelY ADC range value

/sys/bus/iio/devices/iio:deviceX/in_voltageY_scale

Set VIN range value for the corresponding ADC channel.

root:/> cat in_voltage0_scale
0

root:/> echo 2 > in_voltage0_scale
root:/> cat in_voltage0_scale
2

Get ADC range available values

/sys/bus/iio/devices/iio:deviceX/in_voltage_scale_available

Read available values for the ADC VIN range.

root:/> cat in_voltage_scale_available
0 1 2 3

Get ChannelY ADC raw value

/sys/bus/iio/devices/iio:deviceX/in_voltageY_raw

Read raw value for the ADC channel.

root:/> cat in_voltage0_raw
4095

Set ChannelY DAC offset value

/sys/bus/iio/devices/iio:deviceX/out_voltageY_offset

Set offset value for the corresponding ADC channel.

root:/> cat out_voltage0_offset
0

root:/> echo 2 > out_voltage0_offset
root:/> cat out_voltage0_offset
2

Get DAC offset available values

/sys/bus/iio/devices/iio:deviceX/out_voltage_offset_available

Read available values for the DAC offset.

root:/> cat out_voltage_offset_available
0 1 2

Get ChannelY DAC raw value

/sys/bus/iio/devices/iio:deviceX/out_voltageY_raw

Read raw value for the DAC channel.

root:/> cat out_voltage0_raw
0

root:/> echo 2000 > out_voltage0_raw
root:/> cat out_voltage0_raw
2000

Low level register access via debugfs (direct_reg_access)

Some IIO drivers feature an optional debug facility, allowing users to read or write registers directly. Special care needs to be taken when using this feature, since you can modify registers on the back of the driver. Accessing debugfs requires root privileges.

root:/> /sys/kernel/debug/iio/iio:device0/
root:/sys/kernel/debug/iio/iio:device0> ls direct_reg_access
direct_reg_access

Reading

root:/sys/kernel/debug/iio/iio:device0> echo 0x2000C > direct_reg_access
root:/sys/kernel/debug/iio/iio:device0> cat direct_reg_access
0x18

Writing

Write ADDRESS VALUE

root@analog:/sys/kernel/debug/iio/iio:device0> echo 0x20214 0x80 > direct_reg_access
root@analog:/sys/kernel/debug/iio/iio:device0> cat direct_reg_access
0x80

More Information