LTC2672
LTC2672 IIO DAC Linux Driver.
The LTC2672 is a family of five-channel, 12-/16-bit current source, digital-to-analog converters (DACs) that provide five high compliance, current source outputs with guaranteed 0.6 V dropout at 200 mA. There are eight current ranges that are programmable per channel with full-scale outputs of up to 300 mA. The channels can be paralleled to allow either ultrafine adjustments of large currents or combined outputs of up to 1.5 A. A dedicated supply pin is provided for each output channel. Each channel can be operated from 2.1 V to VCC, and internal switches allow any output to be pulled to the optional negative supply. The LTC2672 includes a precision integrated 1.25 V reference (10 ppm/°C maximum (LFCSP) or 2.4 ppm/°C nominal (WLCSP)), with the option to use an external reference. The serial peripheral interface (SPI)-compatible, 3‑wire serial interface operates on logic levels as low as 1.71 V and at clock rates as high as 50 MHz.
Supported Devices
Evaluation Boards
Description
This is a Linux industrial I/O (Linux Industrial I/O Subsystem) subsystem driver, targeting single-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 Linux Industrial I/O Subsystem for more information.
Source Code
Status
Files
Function |
File |
|---|---|
driver |
|
dt-bindings |
main?Documentation/devicetree/bindings/iio/dac/adi,ltc2672.yaml |
Example platform device initialization
Devicetree
Required devicetree properties:
compatible: Needs to beadi,followed by the name of the device. E.g.adi,ltc2672reg: The chipselect number used for the devicespi-max-frequency: Maximum SPI clock frequencyvcc-supply: Analog Supply Voltage Input.iovcc-supply: Digital Input/Output Supply Voltage.v-neg-supply: Negative Supply Voltage Input.Channel nodes with
reg,output-range-microamp, and optionallyadi,toggle-modeproperties.
Optional devicetree properties:
ref-supply: external reference voltage supply regulator. This should only be set if there is an external reference voltage connected to the REF pin.
adi,toggle-mode:
description:
Set the channel as a toggle enabled channel. Toggle operation enables
fast switching of a DAC output between two different DAC codes without
any SPI transaction.
type: boolean
adi,rfsadj-ohms:
description:
If FSADJ is tied to VCC, an internal RFSADJ (20 kΩ) is selected, which
results in nominal output ranges. When an external resistor of 19 kΩ to
41 kΩ can be used instead by connecting the resistor between FSADJ and
GND
it controls the scaling of the ranges, and the internal resistor is
automatically disconnected.
minimum: 19000
maximum: 41000
default: 20000
Example Overlay |
File |
|---|---|
Overlay |
rpi-6.1.y?arch/arm/boot/dts/overlays/rpi-ltc2672-overlay.dts |
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.
root@analog:/> cd /sys/bus/iio/devices/
root@analog:/sys/bus/iio/devices> ls
iio:device0
root@analog:/sys/bus/iio/devices> cd iio\:device0
root@analog:/sys/bus/iio/devices/iio:device0> ls -l
total 0
-r--r--r-- 1 root root 4096 Jul 2 07:20 name
lrwxrwxrwx 1 root root 0 Jul 2 07:20 of_node -> ../../../../../../../../firmware/devicetree/base/soc/spi@7e204000/ltc2672@0
-rw-r--r-- 1 root root 4096 Jul 2 07:20 out_current0_offset
-rw-r--r-- 1 root root 4096 Jul 2 07:20 out_current0_powerdown
-r--r--r-- 1 root root 4096 Jul 2 07:20 out_current0_powerdown_mode
-rw-r--r-- 1 root root 4096 Jul 2 07:20 out_current0_raw
-r--r--r-- 1 root root 4096 Jul 2 07:20 out_current0_raw_available
-rw-r--r-- 1 root root 4096 Jul 2 07:20 out_current0_scale
-rw-r--r-- 1 root root 4096 Jul 2 07:20 out_current1_offset
-rw-r--r-- 1 root root 4096 Jul 2 07:20 out_current1_powerdown
-r--r--r-- 1 root root 4096 Jul 2 07:20 out_current1_powerdown_mode
-rw-r--r-- 1 root root 4096 Jul 2 07:20 out_current1_raw0
-rw-r--r-- 1 root root 4096 Jul 2 07:20 out_current1_raw1
-r--r--r-- 1 root root 4096 Jul 2 07:20 out_current1_raw_available
-rw-r--r-- 1 root root 4096 Jul 2 07:20 out_current1_scale
-rw-r--r-- 1 root root 4096 Jul 2 07:20 out_current1_symbol
-rw-r--r-- 1 root root 4096 Jul 2 07:20 out_current1_toggle_en
-rw-r--r-- 1 root root 4096 Jul 2 07:20 out_current2_offset
-rw-r--r-- 1 root root 4096 Jul 2 07:20 out_current2_powerdown
-r--r--r-- 1 root root 4096 Jul 2 07:20 out_current2_powerdown_mode
-rw-r--r-- 1 root root 4096 Jul 2 07:20 out_current2_raw
-r--r--r-- 1 root root 4096 Jul 2 07:20 out_current2_raw_available
-rw-r--r-- 1 root root 4096 Jul 2 07:20 out_current2_scale
-rw-r--r-- 1 root root 4096 Jul 2 07:20 out_current3_offset
-rw-r--r-- 1 root root 4096 Jul 2 07:20 out_current3_powerdown
-r--r--r-- 1 root root 4096 Jul 2 07:20 out_current3_powerdown_mode
-rw-r--r-- 1 root root 4096 Jul 2 07:20 out_current3_raw
-r--r--r-- 1 root root 4096 Jul 2 07:20 out_current3_raw_available
-rw-r--r-- 1 root root 4096 Jul 2 07:20 out_current3_scale
-rw-r--r-- 1 root root 4096 Jul 2 07:20 out_current4_offset
-rw-r--r-- 1 root root 4096 Jul 2 07:20 out_current4_powerdown
-r--r--r-- 1 root root 4096 Jul 2 07:20 out_current4_powerdown_mode
-rw-r--r-- 1 root root 4096 Jul 2 07:20 out_current4_raw
-r--r--r-- 1 root root 4096 Jul 2 07:20 out_current4_raw_available
-rw-r--r-- 1 root root 4096 Jul 2 07:20 out_current4_scale
drwxr-xr-x 2 root root 0 Jul 2 07:20 power
lrwxrwxrwx 1 root root 0 Jul 2 07:20 subsystem -> ../../../../../../../../bus/iio
-rw-r--r-- 1 root root 4096 Jul 2 07:20 uevent
-r--r--r-- 1 root root 4096 Jul 2 07:20 waiting_for_supplier
root@analog:/sys/bus/iio/devices/iio:device0#
root@analog:~# iio_info
iio_info version: 0.25 (git tag:b6028fde)
Libiio version: 0.25 (git tag: b6028fd) backends: local xml ip usb
IIO context created with local backend.
Backend version: 0.25 (git tag: b6028fd)
Backend description string: Linux analog 6.10.0-rc5-v7l-embedded+ #1 SMP Sun
Jun 30 21:12:36 BST 2024 armv7l
IIO context has 2 attributes:
local,kernel: 6.10.0-rc5-v7l-embedded+
uri: local:
IIO context has 3 devices:
hwmon0: cpu_thermal
1 channels found:
temp1: (input)
1 channel-specific attributes found:
attr 0: input value: 49660
No trigger on this device
hwmon1: rpi_volt
1 channels found:
in0: (input)
1 channel-specific attributes found:
attr 0: lcrit_alarm value: 0
No trigger on this device
iio:device0: ltc2672
5 channels found:
current2: (output)
6 channel-specific attributes found:
attr 0: offset value: 0
attr 1: powerdown value: 0
attr 2: powerdown_mode value: 42kohm_to_gnd
attr 3: raw value: 0
attr 4: raw_available value: [0 1 65535]
attr 5: scale value: 4.577636718
current1: (output)
9 channel-specific attributes found:
attr 0: offset value: 0
attr 1: powerdown value: 0
attr 2: powerdown_mode value: 42kohm_to_gnd
attr 3: raw0 value: 0
attr 4: raw1 value: 0
attr 5: raw_available value: [0 1 65535]
attr 6: scale value: 3.051757812
attr 7: symbol value: 0
attr 8: toggle_en value: 0
current4: (output)
6 channel-specific attributes found:
attr 0: offset value: 0
attr 1: powerdown value: 0
attr 2: powerdown_mode value: 42kohm_to_gnd
attr 3: raw value: 0
attr 4: raw_available value: [0 1 65535]
attr 5: scale value: 4.577636718
current3: (output)
6 channel-specific attributes found:
attr 0: offset value: 0
attr 1: powerdown value: 0
attr 2: powerdown_mode value: 42kohm_to_gnd
attr 3: raw value: 0
attr 4: raw_available value: [0 1 65535]
attr 5: scale value: 4.577636718
current0: (output)
6 channel-specific attributes found:
attr 0: offset value: 0
attr 1: powerdown value: 0
attr 2: powerdown_mode value: 42kohm_to_gnd
attr 3: raw value: 0
attr 4: raw_available value: [0 1 65535]
attr 5: scale value: 4.577636718
1 device-specific attributes found:
attr 0: waiting_for_supplier value: 0
1 debug attributes found:
debug attr 0: direct_reg_access ERROR:
Operation not supported (95)
No trigger on this device
root@analog:~#
Show device name
root@analog:/sys/bus/iio/devices/iio:device0> cat name
ltc2672
Show scale
Description: Scale to be applied to out_currentY_raw in order to obtain the measured current in microamps.
root@analog:/sys/bus/iio/devices/iio:device0> cat out_current0_scale
4.577636718
Show offset
Raw offset to be applied to out_currentY_raw in order to obtain the measured current in microamps. The offset is applied before scale is applied.
root@analog:/sys/bus/iio/devices/iio:device0> cat out_current0_offset
0
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.
root@analog:/sys/bus/iio/devices/iio:device0> echo 10000 > out_current0_raw
I = (out_current0_raw + out_current0_offset) * out_current0_scale = (10000 - 0) * 4.577636718μA = 45,776.367 μA
Enable power down mode on output Y
/sys/bus/iio/devices/iio:deviceX/out_currentY_powerdown
Description: Writing 1 causes output Y to enter the power down mode. Clearing returns to normal operation.
root@analog:/sys/bus/iio/devices/iio:device0> echo 1 > out_current0_powerdown
root@analog:/sys/bus/iio/devices/iio:device0> cat out_current0_powerdown
1
root@analog:/sys/bus/iio/devices/iio:device0> echo 0 > out_current0_powerdown
root@analog:/sys/bus/iio/devices/iio:device0> cat out_current0_powerdown
0
Hardware Interface
Using:
DC2903A LTC2672-16 Demo Board
Raspberry Pi 4
Wiring/Connection
Demo Board |
RPI4 |
|---|---|
SCK |
SCLK SPI0 |
SDO |
MISO SPI0 |
SDI |
MOSI SPIO |
CS |
CE SPIO |
VCC |
5V |
GND |
GND |
LDAC |
5V |
TGP |
5V |