ADGS1408
ADGS1408/ADGS1409 8:1/Dual 4:1 Muxes Linux Driver.
Supported Devices
Evaluation Boards
Description
The driver registers one mux controller. ADGS1408 provides eight states and ADGS1409 provides four states; the two ADGS1409 paths share the same selection. Consumers coordinate access through the mux framework. Optional idle-state selects the idle state; by default the mux retains its last selection, after being disabled at probe.
Source Code
Status
Source |
Mainlined? |
|
|---|---|---|
Yes |
Files
Function |
File |
|
|---|---|---|
driver |
Adding Linux driver support
Kernel configuration
Configure kernel with make menuconfig (alternatively use make xconfig or
make qconfig)
Note
If the multiplexer is used to select a signal that is fed to an IIO device, then you must enable IIO multiplexer driver
Linux Kernel Configuration
Device Drivers --->
...
<*> Industrial I/O support --->
...
Multiplexers --->
<*> IIO multiplexer driver
...
--- Industrial I/O support
Multiplexer drivers --->
...
<*> Analog Devices ADGS1408/ADGS1409 Multiplexers
...
...
Devicetree configuration
Required devicetree properties:
compatible: Needs to be the name of the device. E.g.
adi,adgs1408reg: The chipselect number used for the device
spi-max-frequency: Maximum SPI clock frequency.
#mux-control-cells:is required to be <0>
&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins &spi0_cs_pins>;
cs-gpios = <&gpio 8 1>, <&gpio 7 1>;
status = "okay";
mux: mux-controller@2 {
compatible = "adi,adgs1408";
reg = <0>;
spi-max-frequency = <1000000>;
#mux-control-cells = <0>;
};
}
/ {
adc-mux@3 {
compatible = "io-channel-mux";
io-channels = <&adc 1>;
io-channel-names = "parent";
mux-controls = <&mux>;
channels = "out_a0", "out_a1", "test0", "test1",
"out_b0", "out_b1", "testb0", "testb1";
};
}
A consumer must also be provided to be able to control the mux. In this example we used a regular IIO ADC driver. Which is interfaced with the IIO mux controller consumer.
adc: ad7298@3 {
compatible = "ad7298";
#io-channel-cells = <1>;
spi-max-frequency = <1000000>;
reg = <1>;
};
The mux controller extends the ADC’s IO channel that is selected. In this case the selected channels is represented by :
io-channels = <&adc 1>;
in this case voltage0 from ad7298 is the channels multiplexed in IIO.
Driver testing
Since we are using an IIO ADC (AD7298) then our mux will have an IIO device folder in /sys/bus/iio/devices/iio:deviceX with the name adc-mux@3.
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@raspberrypi:/sys/bus/iio/devices/iio:device1# ls -l
total 0
-r--r--r-- 1 root root 4096 Jul 17 13:21 dev
-rw-r--r-- 1 root root 4096 Jul 17 13:21 in_voltage0_raw
-rw-r--r-- 1 root root 4096 Jul 17 13:21 in_voltage0_scale
-rw-r--r-- 1 root root 4096 Jul 17 13:21 in_voltage1_raw
-rw-r--r-- 1 root root 4096 Jul 17 13:21 in_voltage1_scale
-rw-r--r-- 1 root root 4096 Jul 17 13:21 in_voltage2_raw
-rw-r--r-- 1 root root 4096 Jul 17 13:21 in_voltage2_scale
-rw-r--r-- 1 root root 4096 Jul 17 13:21 in_voltage3_raw
-rw-r--r-- 1 root root 4096 Jul 17 13:21 in_voltage3_scale
-rw-r--r-- 1 root root 4096 Jul 17 13:21 in_voltage4_raw
-rw-r--r-- 1 root root 4096 Jul 17 13:21 in_voltage4_scale
-rw-r--r-- 1 root root 4096 Jul 17 13:21 in_voltage5_raw
-rw-r--r-- 1 root root 4096 Jul 17 13:21 in_voltage5_scale
-rw-r--r-- 1 root root 4096 Jul 17 13:21 in_voltage6_raw
-rw-r--r-- 1 root root 4096 Jul 17 13:21 in_voltage6_scale
-rw-r--r-- 1 root root 4096 Jul 17 13:21 in_voltage7_raw
-rw-r--r-- 1 root root 4096 Jul 17 13:21 in_voltage7_scale
-r--r--r-- 1 root root 4096 Jul 17 13:21 name
lrwxrwxrwx 1 root root 0 Jul 17 13:21 of_node -> ../../../../firmware/devicetree/base/adc-mux@3
drwxr-xr-x 2 root root 0 Jul 17 13:21 power
lrwxrwxrwx 1 root root 0 Jul 17 13:21 subsystem -> ../../../../bus/iio
-rw-r--r-- 1 root root 4096 Jul 17 13:21 uevent
Identify the device
root@raspberrypi:/sys/bus/iio/devices/iio:device1# cat name
adc-mux@3
Basic operation
Get Voltage on channel Y
This will select channel Y of the multiplexer and feed it to the input channel of the ADC that is physically connected to the mux.
root@raspberrypi:/sys/bus/iio/devices/iio:device1# cat in_voltage0_raw
4095
The other attributes correspond to the ADC and can be viewed from here.