Wiki

This version (14 Dec 2021 14:13) was approved by Antoniu Miclaus.

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 (IIO) 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 IIO for more information.

Source Code

Status

Source Mainlined?
git WIP

Files

Declaring SPI slave devices

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: Documentation/spi/spi-summary.rst

21 Oct 2010 16:10

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”)

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.

02 Mar 2011 15:16

This specifies any shell prompt running on the target

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

This specifies any shell prompt running on the target

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.

This specifies any shell prompt running on the target

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.

This specifies any shell prompt running on the target

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.

This specifies any shell prompt running on the target

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.

This specifies any shell prompt running on the target

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.

This specifies any shell prompt running on the target

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.

This specifies any shell prompt running on the target

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.

This specifies any shell prompt running on the target

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.

This specifies any shell prompt running on the target

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.

This specifies any shell prompt running on the target

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.

This specifies any shell prompt running on the target

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.

This specifies any shell prompt running on the target

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.

This specifies any shell prompt running on the target

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.

This specifies any shell prompt running on the target

root:/> cat out_voltage0_raw
0

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

More Information

resources/tools-software/linux-drivers/iio-dac/ad7293.txt · Last modified: 14 Dec 2021 14:13 by Antoniu Miclaus