Wiki

This version (18 Jul 2018 13:56) was approved by larsc.The Previously approved version (18 Jul 2018 13:13) is available.Diff

ADGS1408/ADGS1409 8:1/Dual 4:1 Muxes Linux Driver

Supported Devices

Evaluation Boards

Description

This is a mux controller subsystem driver, with an interface for accessing mux controllers. This is done in such a way that several consumers can independently access the same mux controller if one controller controls several multiplexers, thus allowing sharing.

Source Code

Status

Source Mainlined?
git [No]

Files

Function File
driver drivers/mux/adgs140x.c

Devicetree

Required devicetree properties:

  • compatible: Needs to be the name of the device. E.g. “adi,adgs1408”
  • reg: 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.

Adding Linux driver support

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

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
            ...
        ...

Hardware configuration

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.

02 Mar 2011 15:16

This specifies any shell prompt running on the target

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

Show device name

This specifies any shell prompt running on the target

root@raspberrypi:/sys/bus/iio/devices/iio:device1# cat name
adc-mux@3

Get Voltage on channel Y

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

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.

This specifies any shell prompt running on the target

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.

More Information

resources/tools-software/linux-drivers/mux/adgs1408.txt · Last modified: 18 Jul 2018 13:56 by larsc