1*c66ec88fSEmmanuel VadotCommon multiplexer controller bindings 2*c66ec88fSEmmanuel Vadot====================================== 3*c66ec88fSEmmanuel Vadot 4*c66ec88fSEmmanuel VadotA multiplexer (or mux) controller will have one, or several, consumer devices 5*c66ec88fSEmmanuel Vadotthat uses the mux controller. Thus, a mux controller can possibly control 6*c66ec88fSEmmanuel Vadotseveral parallel multiplexers. Presumably there will be at least one 7*c66ec88fSEmmanuel Vadotmultiplexer needed by each consumer, but a single mux controller can of course 8*c66ec88fSEmmanuel Vadotcontrol several multiplexers for a single consumer. 9*c66ec88fSEmmanuel Vadot 10*c66ec88fSEmmanuel VadotA mux controller provides a number of states to its consumers, and the state 11*c66ec88fSEmmanuel Vadotspace is a simple zero-based enumeration. I.e. 0-1 for a 2-way multiplexer, 12*c66ec88fSEmmanuel Vadot0-7 for an 8-way multiplexer, etc. 13*c66ec88fSEmmanuel Vadot 14*c66ec88fSEmmanuel Vadot 15*c66ec88fSEmmanuel VadotConsumers 16*c66ec88fSEmmanuel Vadot--------- 17*c66ec88fSEmmanuel Vadot 18*c66ec88fSEmmanuel VadotMux controller consumers should specify a list of mux controllers that they 19*c66ec88fSEmmanuel Vadotwant to use with a property containing a 'mux-ctrl-list': 20*c66ec88fSEmmanuel Vadot 21*c66ec88fSEmmanuel Vadot mux-ctrl-list ::= <single-mux-ctrl> [mux-ctrl-list] 22*c66ec88fSEmmanuel Vadot single-mux-ctrl ::= <mux-ctrl-phandle> [mux-ctrl-specifier] 23*c66ec88fSEmmanuel Vadot mux-ctrl-phandle : phandle to mux controller node 24*c66ec88fSEmmanuel Vadot mux-ctrl-specifier : array of #mux-control-cells specifying the 25*c66ec88fSEmmanuel Vadot given mux controller (controller specific) 26*c66ec88fSEmmanuel Vadot 27*c66ec88fSEmmanuel VadotMux controller properties should be named "mux-controls". The exact meaning of 28*c66ec88fSEmmanuel Vadoteach mux controller property must be documented in the device tree binding for 29*c66ec88fSEmmanuel Vadoteach consumer. An optional property "mux-control-names" may contain a list of 30*c66ec88fSEmmanuel Vadotstrings to label each of the mux controllers listed in the "mux-controls" 31*c66ec88fSEmmanuel Vadotproperty. 32*c66ec88fSEmmanuel Vadot 33*c66ec88fSEmmanuel VadotDrivers for devices that use more than a single mux controller can use the 34*c66ec88fSEmmanuel Vadot"mux-control-names" property to map the name of the requested mux controller 35*c66ec88fSEmmanuel Vadotto an index into the list given by the "mux-controls" property. 36*c66ec88fSEmmanuel Vadot 37*c66ec88fSEmmanuel Vadotmux-ctrl-specifier typically encodes the chip-relative mux controller number. 38*c66ec88fSEmmanuel VadotIf the mux controller chip only provides a single mux controller, the 39*c66ec88fSEmmanuel Vadotmux-ctrl-specifier can typically be left out. 40*c66ec88fSEmmanuel Vadot 41*c66ec88fSEmmanuel VadotExample: 42*c66ec88fSEmmanuel Vadot 43*c66ec88fSEmmanuel Vadot /* One consumer of a 2-way mux controller (one GPIO-line) */ 44*c66ec88fSEmmanuel Vadot mux: mux-controller { 45*c66ec88fSEmmanuel Vadot compatible = "gpio-mux"; 46*c66ec88fSEmmanuel Vadot #mux-control-cells = <0>; 47*c66ec88fSEmmanuel Vadot 48*c66ec88fSEmmanuel Vadot mux-gpios = <&pioA 0 GPIO_ACTIVE_HIGH>; 49*c66ec88fSEmmanuel Vadot }; 50*c66ec88fSEmmanuel Vadot 51*c66ec88fSEmmanuel Vadot adc-mux { 52*c66ec88fSEmmanuel Vadot compatible = "io-channel-mux"; 53*c66ec88fSEmmanuel Vadot io-channels = <&adc 0>; 54*c66ec88fSEmmanuel Vadot io-channel-names = "parent"; 55*c66ec88fSEmmanuel Vadot 56*c66ec88fSEmmanuel Vadot mux-controls = <&mux>; 57*c66ec88fSEmmanuel Vadot mux-control-names = "adc"; 58*c66ec88fSEmmanuel Vadot 59*c66ec88fSEmmanuel Vadot channels = "sync", "in"; 60*c66ec88fSEmmanuel Vadot }; 61*c66ec88fSEmmanuel Vadot 62*c66ec88fSEmmanuel VadotNote that in the example above, specifying the "mux-control-names" is redundant 63*c66ec88fSEmmanuel Vadotbecause there is only one mux controller in the list. However, if the driver 64*c66ec88fSEmmanuel Vadotfor the consumer node in fact asks for a named mux controller, that name is of 65*c66ec88fSEmmanuel Vadotcourse still required. 66*c66ec88fSEmmanuel Vadot 67*c66ec88fSEmmanuel Vadot /* 68*c66ec88fSEmmanuel Vadot * Two consumers (one for an ADC line and one for an i2c bus) of 69*c66ec88fSEmmanuel Vadot * parallel 4-way multiplexers controlled by the same two GPIO-lines. 70*c66ec88fSEmmanuel Vadot */ 71*c66ec88fSEmmanuel Vadot mux: mux-controller { 72*c66ec88fSEmmanuel Vadot compatible = "gpio-mux"; 73*c66ec88fSEmmanuel Vadot #mux-control-cells = <0>; 74*c66ec88fSEmmanuel Vadot 75*c66ec88fSEmmanuel Vadot mux-gpios = <&pioA 0 GPIO_ACTIVE_HIGH>, 76*c66ec88fSEmmanuel Vadot <&pioA 1 GPIO_ACTIVE_HIGH>; 77*c66ec88fSEmmanuel Vadot }; 78*c66ec88fSEmmanuel Vadot 79*c66ec88fSEmmanuel Vadot adc-mux { 80*c66ec88fSEmmanuel Vadot compatible = "io-channel-mux"; 81*c66ec88fSEmmanuel Vadot io-channels = <&adc 0>; 82*c66ec88fSEmmanuel Vadot io-channel-names = "parent"; 83*c66ec88fSEmmanuel Vadot 84*c66ec88fSEmmanuel Vadot mux-controls = <&mux>; 85*c66ec88fSEmmanuel Vadot 86*c66ec88fSEmmanuel Vadot channels = "sync-1", "in", "out", "sync-2"; 87*c66ec88fSEmmanuel Vadot }; 88*c66ec88fSEmmanuel Vadot 89*c66ec88fSEmmanuel Vadot i2c-mux { 90*c66ec88fSEmmanuel Vadot compatible = "i2c-mux"; 91*c66ec88fSEmmanuel Vadot i2c-parent = <&i2c1>; 92*c66ec88fSEmmanuel Vadot 93*c66ec88fSEmmanuel Vadot mux-controls = <&mux>; 94*c66ec88fSEmmanuel Vadot 95*c66ec88fSEmmanuel Vadot #address-cells = <1>; 96*c66ec88fSEmmanuel Vadot #size-cells = <0>; 97*c66ec88fSEmmanuel Vadot 98*c66ec88fSEmmanuel Vadot i2c@0 { 99*c66ec88fSEmmanuel Vadot reg = <0>; 100*c66ec88fSEmmanuel Vadot #address-cells = <1>; 101*c66ec88fSEmmanuel Vadot #size-cells = <0>; 102*c66ec88fSEmmanuel Vadot 103*c66ec88fSEmmanuel Vadot ssd1307: oled@3c { 104*c66ec88fSEmmanuel Vadot /* ... */ 105*c66ec88fSEmmanuel Vadot }; 106*c66ec88fSEmmanuel Vadot }; 107*c66ec88fSEmmanuel Vadot 108*c66ec88fSEmmanuel Vadot i2c@3 { 109*c66ec88fSEmmanuel Vadot reg = <3>; 110*c66ec88fSEmmanuel Vadot #address-cells = <1>; 111*c66ec88fSEmmanuel Vadot #size-cells = <0>; 112*c66ec88fSEmmanuel Vadot 113*c66ec88fSEmmanuel Vadot pca9555: pca9555@20 { 114*c66ec88fSEmmanuel Vadot /* ... */ 115*c66ec88fSEmmanuel Vadot }; 116*c66ec88fSEmmanuel Vadot }; 117*c66ec88fSEmmanuel Vadot }; 118*c66ec88fSEmmanuel Vadot 119*c66ec88fSEmmanuel Vadot 120*c66ec88fSEmmanuel VadotMux controller nodes 121*c66ec88fSEmmanuel Vadot-------------------- 122*c66ec88fSEmmanuel Vadot 123*c66ec88fSEmmanuel VadotMux controller nodes must specify the number of cells used for the 124*c66ec88fSEmmanuel Vadotspecifier using the '#mux-control-cells' property. 125*c66ec88fSEmmanuel Vadot 126*c66ec88fSEmmanuel VadotOptionally, mux controller nodes can also specify the state the mux should 127*c66ec88fSEmmanuel Vadothave when it is idle. The idle-state property is used for this. If the 128*c66ec88fSEmmanuel Vadotidle-state is not present, the mux controller is typically left as is when 129*c66ec88fSEmmanuel Vadotit is idle. For multiplexer chips that expose several mux controllers, the 130*c66ec88fSEmmanuel Vadotidle-state property is an array with one idle state for each mux controller. 131*c66ec88fSEmmanuel Vadot 132*c66ec88fSEmmanuel VadotThe special value (-1) may be used to indicate that the mux should be left 133*c66ec88fSEmmanuel Vadotas is when it is idle. This is the default, but can still be useful for 134*c66ec88fSEmmanuel Vadotmux controller chips with more than one mux controller, particularly when 135*c66ec88fSEmmanuel Vadotthere is a need to "step past" a mux controller and set some other idle 136*c66ec88fSEmmanuel Vadotstate for a mux controller with a higher index. 137*c66ec88fSEmmanuel Vadot 138*c66ec88fSEmmanuel VadotSome mux controllers have the ability to disconnect the input/output of the 139*c66ec88fSEmmanuel Vadotmultiplexer. Using this disconnected high-impedance state as the idle state 140*c66ec88fSEmmanuel Vadotis indicated with idle state (-2). 141*c66ec88fSEmmanuel Vadot 142*c66ec88fSEmmanuel VadotThese constants are available in 143*c66ec88fSEmmanuel Vadot 144*c66ec88fSEmmanuel Vadot #include <dt-bindings/mux/mux.h> 145*c66ec88fSEmmanuel Vadot 146*c66ec88fSEmmanuel Vadotas MUX_IDLE_AS_IS (-1) and MUX_IDLE_DISCONNECT (-2). 147*c66ec88fSEmmanuel Vadot 148*c66ec88fSEmmanuel VadotAn example mux controller node look like this (the adg972a chip is a triple 149*c66ec88fSEmmanuel Vadot4-way multiplexer): 150*c66ec88fSEmmanuel Vadot 151*c66ec88fSEmmanuel Vadot mux: mux-controller@50 { 152*c66ec88fSEmmanuel Vadot compatible = "adi,adg792a"; 153*c66ec88fSEmmanuel Vadot reg = <0x50>; 154*c66ec88fSEmmanuel Vadot #mux-control-cells = <1>; 155*c66ec88fSEmmanuel Vadot 156*c66ec88fSEmmanuel Vadot idle-state = <MUX_IDLE_DISCONNECT MUX_IDLE_AS_IS 2>; 157*c66ec88fSEmmanuel Vadot }; 158