This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
resources:tools-software:linux-drivers:mux:adgs1408 [15 May 2018 13:48] – [Description] Mircea Caprioru | resources:tools-software:linux-drivers:mux:adgs1408 [18 Jul 2018 13:56] (current) – Use wiki links for links to github Lars-Peter Clausen | ||
---|---|---|---|
Line 16: | Line 16: | ||
====== Source Code ====== | ====== Source Code ====== | ||
+ | |||
+ | ===== Status ===== | ||
+ | |||
+ | ^ Source ^ Mainlined? ^ | ||
+ | | [[linux.github> | ||
+ | |||
+ | ===== Files ===== | ||
+ | |||
+ | ^ Function ^ File ^ | ||
+ | | driver | ||
+ | |||
+ | ===== Devicetree ===== | ||
+ | |||
+ | Required devicetree properties: | ||
+ | * compatible: Needs to be the name of the device. E.g. " | ||
+ | * reg: The chipselect number used for the device | ||
+ | * spi-max-frequency: | ||
+ | * # | ||
+ | |||
+ | < | ||
+ | &spi0 { | ||
+ | pinctrl-names = " | ||
+ | pinctrl-0 = <& | ||
+ | cs-gpios = <& | ||
+ | status = " | ||
+ | |||
+ | mux: mux-controller@2 { | ||
+ | compatible = " | ||
+ | reg = <0>; | ||
+ | spi-max-frequency = < | ||
+ | # | ||
+ | }; | ||
+ | } | ||
+ | |||
+ | / { | ||
+ | adc-mux@3 { | ||
+ | compatible = " | ||
+ | io-channels = <& | ||
+ | io-channel-names = " | ||
+ | mux-controls = <& | ||
+ | |||
+ | channels = " | ||
+ | " | ||
+ | |||
+ | }; | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | 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 = " | ||
+ | # | ||
+ | spi-max-frequency = < | ||
+ | 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 = <& | ||
+ | </ | ||
+ | in this case voltage0 from ad7298 is the channels multiplexed in IIO. | ||
+ | |||
+ | ====== Adding Linux driver support ====== | ||
+ | |||
+ | Configure kernel with "make menuconfig" | ||
+ | "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 | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | Linux Kernel Configuration | ||
+ | Device Drivers | ||
+ | ... | ||
+ | < | ||
+ | ... | ||
+ | Multiplexers ---> | ||
+ | <*> IIO multiplexer driver | ||
+ | ... | ||
+ | --- Industrial I/O support | ||
+ | Multiplexer drivers ---> | ||
+ | ... | ||
+ | <*> Analog Devices ADGS1408/ | ||
+ | ... | ||
+ | ... | ||
+ | </ | ||
+ | |||
+ | ====== Hardware configuration ====== | ||
+ | |||
+ | ====== Driver testing ====== | ||
+ | Since we are using an IIO ADC (AD7298) then our mux will have an IIO device folder in / | ||
+ | |||
+ | {{page> | ||
+ | |||
+ | <WRAP box bggreen>< | ||
+ | < | ||
+ | root@raspberrypi:/ | ||
+ | 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 -> ../ | ||
+ | drwxr-xr-x 2 root root 0 Jul 17 13:21 power | ||
+ | lrwxrwxrwx 1 root root 0 Jul 17 13:21 subsystem -> ../ | ||
+ | -rw-r--r-- 1 root root 4096 Jul 17 13:21 uevent | ||
+ | </ | ||
+ | |||
+ | === Show device name === | ||
+ | |||
+ | <WRAP box bggreen>< | ||
+ | < | ||
+ | root@raspberrypi:/ | ||
+ | adc-mux@3 | ||
+ | </ | ||
+ | |||
+ | === Get Voltage on channel Y === | ||
+ | |||
+ | **Description: | ||
+ | |||
+ | 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>< | ||
+ | < | ||
+ | root@raspberrypi:/ | ||
+ | 4095 | ||
+ | </ | ||
+ | |||
+ | <wrap info>The other attributes correspond to the ADC and can be viewed from here.</ | ||
+ | |||
+ | ====== More Information ====== | ||
+ | |||
+ | {{page> |