Wiki

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
resources:tools-software:linux-drivers:mux:adgs1408 [15 May 2018 13:49] – [Source Code] Mircea Caprioruresources:tools-software:linux-drivers:mux:adgs1408 [18 Jul 2018 13:56] (current) – Use wiki links for links to github Lars-Peter Clausen
Line 20: Line 20:
  
 ^ Source ^ Mainlined? ^ ^ Source ^ Mainlined? ^
-| [[https://github.com/analogdevicesinc/linux/blob/rpi-4.9.y/drivers/iio/accel/adxl372.c|git]] | [No] |+| [[linux.github>rpi-4.14.y?drivers/mux/adgs140x.c|git]] | [No] |
  
 +===== Files =====
 +
 +^ Function ^ File ^
 +| driver  | [[linux.github>rpi-4.14.y?drivers/mux/adgs140x.c|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> 
 +
 +<code>
 +&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";
 +
 + };
 +}
 +</code>
 +
 +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.
 +<code>
 + adc: ad7298@3 {
 + compatible = "ad7298";
 + #io-channel-cells = <1>;
 + spi-max-frequency = <1000000>;
 + reg = <1>;
 + };
 +</code>
 +
 +The mux controller extends the ADC's IO channel that is selected. In this case the selected channels is represented by :
 +<code>
 +io-channels = <&adc 1>;
 +</code>
 +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")
 +
 +<WRAP round help>
 +If the multiplexer is used to select a signal that is fed to an IIO device, then you must enable IIO multiplexer driver 
 +</WRAP>
 +
 +<code>
 +Linux Kernel Configuration
 +    Device Drivers  --->
 +        ...
 +        <*>     Industrial I/O support --->
 +            ...
 +            Multiplexers --->
 +                <*> IIO multiplexer driver
 +            ...
 +        --- Industrial I/O support
 +        Multiplexer drivers --->
 +            ...
 +            <*> Analog Devices ADGS1408/ADGS1409 Multiplexers
 +            ...
 +        ...
 +</code>
 +
 +====== 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.
 +
 +{{page>software:linux:docs:iio:iio_snippets#iio device files&noheader&firstseconly&noeditbtn}}
 +
 +<WRAP box bggreen><wrap info>This specifies any shell prompt running on the target</wrap>
 +<xterm>
 +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
 +</xterm>
 +
 +=== Show device name ===
 +
 +<WRAP box bggreen><wrap info>This specifies any shell prompt running on the target</wrap>
 +<xterm>
 +root@raspberrypi:/sys/bus/iio/devices/iio:device1# cat name
 +adc-mux@3
 +</xterm></WRAP>
 +
 +=== 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.
 +
 +<WRAP box bggreen><wrap info>This specifies any shell prompt running on the target</wrap>
 +<xterm>
 +root@raspberrypi:/sys/bus/iio/devices/iio:device1# cat in_voltage0_raw 
 +4095
 +</xterm></WRAP>
 +
 +<wrap info>The other attributes correspond to the ADC and can be viewed from here.</wrap>  
 +
 +====== More Information ======
 +
 +{{page>software:linux:docs:iio:iio_snippets#iio pointers&noheader&firstseconly&noeditbtn}}
resources/tools-software/linux-drivers/mux/adgs1408.1526384955.txt.gz · Last modified: 15 May 2018 13:49 by Mircea Caprioru