Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dt-bindings: document devicetree bindings for mux-controllers and gpio-mux

Allow specifying that a single multiplexer controller can be used to
control several parallel multiplexers, thus enabling sharing of the
multiplexer controller by different consumers.

Add a binding for a first mux controller in the form of a GPIO based mux
controller.

Acked-by: Jonathan Cameron <jic23@kernel.org>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Peter Rosin and committed by
Greg Kroah-Hartman
256ac037 b594b101

+248
+69
Documentation/devicetree/bindings/mux/gpio-mux.txt
··· 1 + GPIO-based multiplexer controller bindings 2 + 3 + Define what GPIO pins are used to control a multiplexer. Or several 4 + multiplexers, if the same pins control more than one multiplexer. 5 + 6 + Required properties: 7 + - compatible : "gpio-mux" 8 + - mux-gpios : list of gpios used to control the multiplexer, least 9 + significant bit first. 10 + - #mux-control-cells : <0> 11 + * Standard mux-controller bindings as decribed in mux-controller.txt 12 + 13 + Optional properties: 14 + - idle-state : if present, the state the mux will have when idle. The 15 + special state MUX_IDLE_AS_IS is the default. 16 + 17 + The multiplexer state is defined as the number represented by the 18 + multiplexer GPIO pins, where the first pin is the least significant 19 + bit. An active pin is a binary 1, an inactive pin is a binary 0. 20 + 21 + Example: 22 + 23 + mux: mux-controller { 24 + compatible = "gpio-mux"; 25 + #mux-control-cells = <0>; 26 + 27 + mux-gpios = <&pioA 0 GPIO_ACTIVE_HIGH>, 28 + <&pioA 1 GPIO_ACTIVE_HIGH>; 29 + }; 30 + 31 + adc-mux { 32 + compatible = "io-channel-mux"; 33 + io-channels = <&adc 0>; 34 + io-channel-names = "parent"; 35 + 36 + mux-controls = <&mux>; 37 + 38 + channels = "sync-1", "in", "out", "sync-2"; 39 + }; 40 + 41 + i2c-mux { 42 + compatible = "i2c-mux"; 43 + i2c-parent = <&i2c1>; 44 + 45 + mux-controls = <&mux>; 46 + 47 + #address-cells = <1>; 48 + #size-cells = <0>; 49 + 50 + i2c@0 { 51 + reg = <0>; 52 + #address-cells = <1>; 53 + #size-cells = <0>; 54 + 55 + ssd1307: oled@3c { 56 + /* ... */ 57 + }; 58 + }; 59 + 60 + i2c@3 { 61 + reg = <3>; 62 + #address-cells = <1>; 63 + #size-cells = <0>; 64 + 65 + pca9555: pca9555@20 { 66 + /* ... */ 67 + }; 68 + }; 69 + };
+157
Documentation/devicetree/bindings/mux/mux-controller.txt
··· 1 + Common multiplexer controller bindings 2 + ====================================== 3 + 4 + A multiplexer (or mux) controller will have one, or several, consumer devices 5 + that uses the mux controller. Thus, a mux controller can possibly control 6 + several parallel multiplexers. Presumably there will be at least one 7 + multiplexer needed by each consumer, but a single mux controller can of course 8 + control several multiplexers for a single consumer. 9 + 10 + A mux controller provides a number of states to its consumers, and the state 11 + space is a simple zero-based enumeration. I.e. 0-1 for a 2-way multiplexer, 12 + 0-7 for an 8-way multiplexer, etc. 13 + 14 + 15 + Consumers 16 + --------- 17 + 18 + Mux controller consumers should specify a list of mux controllers that they 19 + want to use with a property containing a 'mux-ctrl-list': 20 + 21 + mux-ctrl-list ::= <single-mux-ctrl> [mux-ctrl-list] 22 + single-mux-ctrl ::= <mux-ctrl-phandle> [mux-ctrl-specifier] 23 + mux-ctrl-phandle : phandle to mux controller node 24 + mux-ctrl-specifier : array of #mux-control-cells specifying the 25 + given mux controller (controller specific) 26 + 27 + Mux controller properties should be named "mux-controls". The exact meaning of 28 + each mux controller property must be documented in the device tree binding for 29 + each consumer. An optional property "mux-control-names" may contain a list of 30 + strings to label each of the mux controllers listed in the "mux-controls" 31 + property. 32 + 33 + Drivers for devices that use more than a single mux controller can use the 34 + "mux-control-names" property to map the name of the requested mux controller 35 + to an index into the list given by the "mux-controls" property. 36 + 37 + mux-ctrl-specifier typically encodes the chip-relative mux controller number. 38 + If the mux controller chip only provides a single mux controller, the 39 + mux-ctrl-specifier can typically be left out. 40 + 41 + Example: 42 + 43 + /* One consumer of a 2-way mux controller (one GPIO-line) */ 44 + mux: mux-controller { 45 + compatible = "gpio-mux"; 46 + #mux-control-cells = <0>; 47 + 48 + mux-gpios = <&pioA 0 GPIO_ACTIVE_HIGH>; 49 + }; 50 + 51 + adc-mux { 52 + compatible = "io-channel-mux"; 53 + io-channels = <&adc 0>; 54 + io-channel-names = "parent"; 55 + 56 + mux-controls = <&mux>; 57 + mux-control-names = "adc"; 58 + 59 + channels = "sync", "in"; 60 + }; 61 + 62 + Note that in the example above, specifying the "mux-control-names" is redundant 63 + because there is only one mux controller in the list. However, if the driver 64 + for the consumer node in fact asks for a named mux controller, that name is of 65 + course still required. 66 + 67 + /* 68 + * Two consumers (one for an ADC line and one for an i2c bus) of 69 + * parallel 4-way multiplexers controlled by the same two GPIO-lines. 70 + */ 71 + mux: mux-controller { 72 + compatible = "gpio-mux"; 73 + #mux-control-cells = <0>; 74 + 75 + mux-gpios = <&pioA 0 GPIO_ACTIVE_HIGH>, 76 + <&pioA 1 GPIO_ACTIVE_HIGH>; 77 + }; 78 + 79 + adc-mux { 80 + compatible = "io-channel-mux"; 81 + io-channels = <&adc 0>; 82 + io-channel-names = "parent"; 83 + 84 + mux-controls = <&mux>; 85 + 86 + channels = "sync-1", "in", "out", "sync-2"; 87 + }; 88 + 89 + i2c-mux { 90 + compatible = "i2c-mux"; 91 + i2c-parent = <&i2c1>; 92 + 93 + mux-controls = <&mux>; 94 + 95 + #address-cells = <1>; 96 + #size-cells = <0>; 97 + 98 + i2c@0 { 99 + reg = <0>; 100 + #address-cells = <1>; 101 + #size-cells = <0>; 102 + 103 + ssd1307: oled@3c { 104 + /* ... */ 105 + }; 106 + }; 107 + 108 + i2c@3 { 109 + reg = <3>; 110 + #address-cells = <1>; 111 + #size-cells = <0>; 112 + 113 + pca9555: pca9555@20 { 114 + /* ... */ 115 + }; 116 + }; 117 + }; 118 + 119 + 120 + Mux controller nodes 121 + -------------------- 122 + 123 + Mux controller nodes must specify the number of cells used for the 124 + specifier using the '#mux-control-cells' property. 125 + 126 + Optionally, mux controller nodes can also specify the state the mux should 127 + have when it is idle. The idle-state property is used for this. If the 128 + idle-state is not present, the mux controller is typically left as is when 129 + it is idle. For multiplexer chips that expose several mux controllers, the 130 + idle-state property is an array with one idle state for each mux controller. 131 + 132 + The special value (-1) may be used to indicate that the mux should be left 133 + as is when it is idle. This is the default, but can still be useful for 134 + mux controller chips with more than one mux controller, particularly when 135 + there is a need to "step past" a mux controller and set some other idle 136 + state for a mux controller with a higher index. 137 + 138 + Some mux controllers have the ability to disconnect the input/output of the 139 + multiplexer. Using this disconnected high-impedance state as the idle state 140 + is indicated with idle state (-2). 141 + 142 + These constants are available in 143 + 144 + #include <dt-bindings/mux/mux.h> 145 + 146 + as MUX_IDLE_AS_IS (-1) and MUX_IDLE_DISCONNECT (-2). 147 + 148 + An example mux controller node look like this (the adg972a chip is a triple 149 + 4-way multiplexer): 150 + 151 + mux: mux-controller@50 { 152 + compatible = "adi,adg792a"; 153 + reg = <0x50>; 154 + #mux-control-cells = <1>; 155 + 156 + idle-state = <MUX_IDLE_DISCONNECT MUX_IDLE_AS_IS 2>; 157 + };
+6
MAINTAINERS
··· 8716 8716 F: drivers/mmc/host/mmc_spi.c 8717 8717 F: include/linux/spi/mmc_spi.h 8718 8718 8719 + MULTIPLEXER SUBSYSTEM 8720 + M: Peter Rosin <peda@axentia.se> 8721 + S: Maintained 8722 + F: Documentation/devicetree/bindings/mux/ 8723 + F: include/linux/dt-bindings/mux/ 8724 + 8719 8725 MULTISOUND SOUND DRIVER 8720 8726 M: Andrew Veliath <andrewtv@usa.net> 8721 8727 S: Maintained
+16
include/dt-bindings/mux/mux.h
··· 1 + /* 2 + * This header provides constants for most Multiplexer bindings. 3 + * 4 + * Most Multiplexer bindings specify an idle state. In most cases, the 5 + * the multiplexer can be left as is when idle, and in some cases it can 6 + * disconnect the input/output and leave the multiplexer in a high 7 + * impedance state. 8 + */ 9 + 10 + #ifndef _DT_BINDINGS_MUX_MUX_H 11 + #define _DT_BINDINGS_MUX_MUX_H 12 + 13 + #define MUX_IDLE_AS_IS (-1) 14 + #define MUX_IDLE_DISCONNECT (-2) 15 + 16 + #endif