1*9b358af7SRob Herring# SPDX-License-Identifier: GPL-2.0
2*9b358af7SRob Herring%YAML 1.2
3*9b358af7SRob Herring---
4*9b358af7SRob Herring$id: http://devicetree.org/schemas/mux/mux-controller.yaml#
5*9b358af7SRob Herring$schema: http://devicetree.org/meta-schemas/core.yaml#
6*9b358af7SRob Herring
7*9b358af7SRob Herringtitle: Common multiplexer controller provider bindings
8*9b358af7SRob Herring
9*9b358af7SRob Herringmaintainers:
10*9b358af7SRob Herring  - Peter Rosin <peda@axentia.se>
11*9b358af7SRob Herring
12*9b358af7SRob Herringdescription: |
13*9b358af7SRob Herring  A multiplexer (or mux) controller will have one, or several, consumer devices
14*9b358af7SRob Herring  that uses the mux controller. Thus, a mux controller can possibly control
15*9b358af7SRob Herring  several parallel multiplexers. Presumably there will be at least one
16*9b358af7SRob Herring  multiplexer needed by each consumer, but a single mux controller can of course
17*9b358af7SRob Herring  control several multiplexers for a single consumer.
18*9b358af7SRob Herring
19*9b358af7SRob Herring  A mux controller provides a number of states to its consumers, and the state
20*9b358af7SRob Herring  space is a simple zero-based enumeration. I.e. 0-1 for a 2-way multiplexer,
21*9b358af7SRob Herring  0-7 for an 8-way multiplexer, etc.
22*9b358af7SRob Herring
23*9b358af7SRob Herring
24*9b358af7SRob Herring  Mux controller nodes
25*9b358af7SRob Herring  --------------------
26*9b358af7SRob Herring
27*9b358af7SRob Herring  Mux controller nodes must specify the number of cells used for the
28*9b358af7SRob Herring  specifier using the '#mux-control-cells' property.
29*9b358af7SRob Herring
30*9b358af7SRob Herring  Optionally, mux controller nodes can also specify the state the mux should
31*9b358af7SRob Herring  have when it is idle. The idle-state property is used for this. If the
32*9b358af7SRob Herring  idle-state is not present, the mux controller is typically left as is when
33*9b358af7SRob Herring  it is idle. For multiplexer chips that expose several mux controllers, the
34*9b358af7SRob Herring  idle-state property is an array with one idle state for each mux controller.
35*9b358af7SRob Herring
36*9b358af7SRob Herring  The special value (-1) may be used to indicate that the mux should be left
37*9b358af7SRob Herring  as is when it is idle. This is the default, but can still be useful for
38*9b358af7SRob Herring  mux controller chips with more than one mux controller, particularly when
39*9b358af7SRob Herring  there is a need to "step past" a mux controller and set some other idle
40*9b358af7SRob Herring  state for a mux controller with a higher index.
41*9b358af7SRob Herring
42*9b358af7SRob Herring  Some mux controllers have the ability to disconnect the input/output of the
43*9b358af7SRob Herring  multiplexer. Using this disconnected high-impedance state as the idle state
44*9b358af7SRob Herring  is indicated with idle state (-2).
45*9b358af7SRob Herring
46*9b358af7SRob Herring  These constants are available in
47*9b358af7SRob Herring
48*9b358af7SRob Herring        #include <dt-bindings/mux/mux.h>
49*9b358af7SRob Herring
50*9b358af7SRob Herring  as MUX_IDLE_AS_IS (-1) and MUX_IDLE_DISCONNECT (-2).
51*9b358af7SRob Herring
52*9b358af7SRob Herring  An example mux controller node look like this (the adg972a chip is a triple
53*9b358af7SRob Herring  4-way multiplexer):
54*9b358af7SRob Herring
55*9b358af7SRob Herring    mux: mux-controller@50 {
56*9b358af7SRob Herring      compatible = "adi,adg792a";
57*9b358af7SRob Herring      reg = <0x50>;
58*9b358af7SRob Herring      #mux-control-cells = <1>;
59*9b358af7SRob Herring
60*9b358af7SRob Herring      idle-state = <MUX_IDLE_DISCONNECT MUX_IDLE_AS_IS 2>;
61*9b358af7SRob Herring    };
62*9b358af7SRob Herring
63*9b358af7SRob Herringselect:
64*9b358af7SRob Herring  anyOf:
65*9b358af7SRob Herring    - properties:
66*9b358af7SRob Herring        $nodename:
67*9b358af7SRob Herring          pattern: '^mux-controller'
68*9b358af7SRob Herring    - required:
69*9b358af7SRob Herring        - '#mux-control-cells'
70*9b358af7SRob Herring
71*9b358af7SRob Herringproperties:
72*9b358af7SRob Herring  $nodename:
73*9b358af7SRob Herring    pattern: '^mux-controller(@.*|-[0-9a-f]+)?$'
74*9b358af7SRob Herring
75*9b358af7SRob Herring  '#mux-control-cells':
76*9b358af7SRob Herring    enum: [ 0, 1 ]
77*9b358af7SRob Herring
78*9b358af7SRob Herring  idle-state:
79*9b358af7SRob Herring    $ref: /schemas/types.yaml#/definitions/int32
80*9b358af7SRob Herring    minimum: -2
81*9b358af7SRob Herring
82*9b358af7SRob Herring  idle-states:
83*9b358af7SRob Herring    description: |
84*9b358af7SRob Herring      Mux controller nodes can specify the state the mux should have when it is
85*9b358af7SRob Herring      idle. If the idle-state is not present, the mux controller is typically
86*9b358af7SRob Herring      left as is when it is idle. For multiplexer chips that expose several mux
87*9b358af7SRob Herring      controllers, the idle-state property is an array with one idle state for
88*9b358af7SRob Herring      each mux controller.
89*9b358af7SRob Herring
90*9b358af7SRob Herring      The special value (-1) may be used to indicate that the mux should be left
91*9b358af7SRob Herring      as is when it is idle. This is the default, but can still be useful for
92*9b358af7SRob Herring      mux controller chips with more than one mux controller, particularly when
93*9b358af7SRob Herring      there is a need to "step past" a mux controller and set some other idle
94*9b358af7SRob Herring      state for a mux controller with a higher index.
95*9b358af7SRob Herring
96*9b358af7SRob Herring      Some mux controllers have the ability to disconnect the input/output of the
97*9b358af7SRob Herring      multiplexer. Using this disconnected high-impedance state as the idle state
98*9b358af7SRob Herring      is indicated with idle state (-2).
99*9b358af7SRob Herring    $ref: /schemas/types.yaml#/definitions/int32-array
100*9b358af7SRob Herring    items:
101*9b358af7SRob Herring      minimum: -2
102*9b358af7SRob Herring
103*9b358af7SRob HerringadditionalProperties: true
104*9b358af7SRob Herring
105*9b358af7SRob Herringexamples:
106*9b358af7SRob Herring  - |
107*9b358af7SRob Herring    #include <dt-bindings/gpio/gpio.h>
108*9b358af7SRob Herring
109*9b358af7SRob Herring    /* One consumer of a 2-way mux controller (one GPIO-line) */
110*9b358af7SRob Herring    mux: mux-controller {
111*9b358af7SRob Herring        compatible = "gpio-mux";
112*9b358af7SRob Herring        #mux-control-cells = <0>;
113*9b358af7SRob Herring
114*9b358af7SRob Herring        mux-gpios = <&pioA 0 GPIO_ACTIVE_HIGH>;
115*9b358af7SRob Herring    };
116*9b358af7SRob Herring
117*9b358af7SRob Herring    adc-mux {
118*9b358af7SRob Herring        compatible = "io-channel-mux";
119*9b358af7SRob Herring        io-channels = <&adc 0>;
120*9b358af7SRob Herring        io-channel-names = "parent";
121*9b358af7SRob Herring
122*9b358af7SRob Herring        mux-controls = <&mux>;
123*9b358af7SRob Herring        mux-control-names = "adc";
124*9b358af7SRob Herring
125*9b358af7SRob Herring        channels = "sync", "in";
126*9b358af7SRob Herring    };
127*9b358af7SRob Herring
128*9b358af7SRob Herring  - |
129*9b358af7SRob Herring    #include <dt-bindings/gpio/gpio.h>
130*9b358af7SRob Herring
131*9b358af7SRob Herring    /*
132*9b358af7SRob Herring     * Two consumers (one for an ADC line and one for an i2c bus) of
133*9b358af7SRob Herring     * parallel 4-way multiplexers controlled by the same two GPIO-lines.
134*9b358af7SRob Herring     */
135*9b358af7SRob Herring    mux2: mux-controller {
136*9b358af7SRob Herring        compatible = "gpio-mux";
137*9b358af7SRob Herring        #mux-control-cells = <0>;
138*9b358af7SRob Herring
139*9b358af7SRob Herring        mux-gpios = <&pioA 0 GPIO_ACTIVE_HIGH>,
140*9b358af7SRob Herring              <&pioA 1 GPIO_ACTIVE_HIGH>;
141*9b358af7SRob Herring    };
142*9b358af7SRob Herring
143*9b358af7SRob Herring    adc-mux {
144*9b358af7SRob Herring        compatible = "io-channel-mux";
145*9b358af7SRob Herring        io-channels = <&adc 0>;
146*9b358af7SRob Herring        io-channel-names = "parent";
147*9b358af7SRob Herring
148*9b358af7SRob Herring        mux-controls = <&mux2>;
149*9b358af7SRob Herring
150*9b358af7SRob Herring        channels = "sync-1", "in", "out", "sync-2";
151*9b358af7SRob Herring    };
152*9b358af7SRob Herring
153*9b358af7SRob Herring    i2c-mux {
154*9b358af7SRob Herring        compatible = "i2c-mux";
155*9b358af7SRob Herring        i2c-parent = <&i2c1>;
156*9b358af7SRob Herring
157*9b358af7SRob Herring        mux-controls = <&mux2>;
158*9b358af7SRob Herring
159*9b358af7SRob Herring        #address-cells = <1>;
160*9b358af7SRob Herring        #size-cells = <0>;
161*9b358af7SRob Herring
162*9b358af7SRob Herring        i2c@0 {
163*9b358af7SRob Herring            reg = <0>;
164*9b358af7SRob Herring            #address-cells = <1>;
165*9b358af7SRob Herring            #size-cells = <0>;
166*9b358af7SRob Herring
167*9b358af7SRob Herring            ssd1307: oled@3c {
168*9b358af7SRob Herring                reg = <0x3c>;
169*9b358af7SRob Herring            };
170*9b358af7SRob Herring        };
171*9b358af7SRob Herring
172*9b358af7SRob Herring        i2c@3 {
173*9b358af7SRob Herring            reg = <3>;
174*9b358af7SRob Herring            #address-cells = <1>;
175*9b358af7SRob Herring            #size-cells = <0>;
176*9b358af7SRob Herring
177*9b358af7SRob Herring            pca9555: pca9555@20 {
178*9b358af7SRob Herring                reg = <0x20>;
179*9b358af7SRob Herring            };
180*9b358af7SRob Herring        };
181*9b358af7SRob Herring    };
182*9b358af7SRob Herring...
183