19b358af7SRob Herring# SPDX-License-Identifier: GPL-2.0
29b358af7SRob Herring%YAML 1.2
39b358af7SRob Herring---
49b358af7SRob Herring$id: http://devicetree.org/schemas/mux/mux-controller.yaml#
59b358af7SRob Herring$schema: http://devicetree.org/meta-schemas/core.yaml#
69b358af7SRob Herring
7*84e85359SKrzysztof Kozlowskititle: Common multiplexer controller provider
89b358af7SRob Herring
99b358af7SRob Herringmaintainers:
109b358af7SRob Herring  - Peter Rosin <peda@axentia.se>
119b358af7SRob Herring
129b358af7SRob Herringdescription: |
139b358af7SRob Herring  A multiplexer (or mux) controller will have one, or several, consumer devices
149b358af7SRob Herring  that uses the mux controller. Thus, a mux controller can possibly control
159b358af7SRob Herring  several parallel multiplexers. Presumably there will be at least one
169b358af7SRob Herring  multiplexer needed by each consumer, but a single mux controller can of course
179b358af7SRob Herring  control several multiplexers for a single consumer.
189b358af7SRob Herring
199b358af7SRob Herring  A mux controller provides a number of states to its consumers, and the state
209b358af7SRob Herring  space is a simple zero-based enumeration. I.e. 0-1 for a 2-way multiplexer,
219b358af7SRob Herring  0-7 for an 8-way multiplexer, etc.
229b358af7SRob Herring
239b358af7SRob Herring
249b358af7SRob Herring  Mux controller nodes
259b358af7SRob Herring  --------------------
269b358af7SRob Herring
279b358af7SRob Herring  Mux controller nodes must specify the number of cells used for the
288f2cade5SAswath Govindraju  specifier using the '#mux-control-cells' or '#mux-state-cells' property.
298f2cade5SAswath Govindraju  The value of '#mux-state-cells' will always be one greater than the value
308f2cade5SAswath Govindraju  of '#mux-control-cells'.
319b358af7SRob Herring
329b358af7SRob Herring  Optionally, mux controller nodes can also specify the state the mux should
339b358af7SRob Herring  have when it is idle. The idle-state property is used for this. If the
349b358af7SRob Herring  idle-state is not present, the mux controller is typically left as is when
359b358af7SRob Herring  it is idle. For multiplexer chips that expose several mux controllers, the
369b358af7SRob Herring  idle-state property is an array with one idle state for each mux controller.
379b358af7SRob Herring
389b358af7SRob Herring  The special value (-1) may be used to indicate that the mux should be left
399b358af7SRob Herring  as is when it is idle. This is the default, but can still be useful for
409b358af7SRob Herring  mux controller chips with more than one mux controller, particularly when
419b358af7SRob Herring  there is a need to "step past" a mux controller and set some other idle
429b358af7SRob Herring  state for a mux controller with a higher index.
439b358af7SRob Herring
449b358af7SRob Herring  Some mux controllers have the ability to disconnect the input/output of the
459b358af7SRob Herring  multiplexer. Using this disconnected high-impedance state as the idle state
469b358af7SRob Herring  is indicated with idle state (-2).
479b358af7SRob Herring
489b358af7SRob Herring  These constants are available in
499b358af7SRob Herring
509b358af7SRob Herring        #include <dt-bindings/mux/mux.h>
519b358af7SRob Herring
529b358af7SRob Herring  as MUX_IDLE_AS_IS (-1) and MUX_IDLE_DISCONNECT (-2).
539b358af7SRob Herring
549b358af7SRob Herring  An example mux controller node look like this (the adg972a chip is a triple
559b358af7SRob Herring  4-way multiplexer):
569b358af7SRob Herring
579b358af7SRob Herring    mux: mux-controller@50 {
589b358af7SRob Herring      compatible = "adi,adg792a";
599b358af7SRob Herring      reg = <0x50>;
609b358af7SRob Herring      #mux-control-cells = <1>;
619b358af7SRob Herring
629b358af7SRob Herring      idle-state = <MUX_IDLE_DISCONNECT MUX_IDLE_AS_IS 2>;
639b358af7SRob Herring    };
649b358af7SRob Herring
659b358af7SRob Herringselect:
669b358af7SRob Herring  anyOf:
679b358af7SRob Herring    - properties:
689b358af7SRob Herring        $nodename:
699b358af7SRob Herring          pattern: '^mux-controller'
709b358af7SRob Herring    - required:
719b358af7SRob Herring        - '#mux-control-cells'
728f2cade5SAswath Govindraju    - required:
738f2cade5SAswath Govindraju        - '#mux-state-cells'
749b358af7SRob Herring
759b358af7SRob Herringproperties:
769b358af7SRob Herring  $nodename:
779b358af7SRob Herring    pattern: '^mux-controller(@.*|-[0-9a-f]+)?$'
789b358af7SRob Herring
799b358af7SRob Herring  '#mux-control-cells':
809b358af7SRob Herring    enum: [ 0, 1 ]
819b358af7SRob Herring
828f2cade5SAswath Govindraju  '#mux-state-cells':
838f2cade5SAswath Govindraju    enum: [ 1, 2 ]
848f2cade5SAswath Govindraju
859b358af7SRob Herring  idle-state:
869b358af7SRob Herring    $ref: /schemas/types.yaml#/definitions/int32
879b358af7SRob Herring    minimum: -2
889b358af7SRob Herring
899b358af7SRob Herring  idle-states:
909b358af7SRob Herring    description: |
919b358af7SRob Herring      Mux controller nodes can specify the state the mux should have when it is
929b358af7SRob Herring      idle. If the idle-state is not present, the mux controller is typically
939b358af7SRob Herring      left as is when it is idle. For multiplexer chips that expose several mux
949b358af7SRob Herring      controllers, the idle-state property is an array with one idle state for
959b358af7SRob Herring      each mux controller.
969b358af7SRob Herring
979b358af7SRob Herring      The special value (-1) may be used to indicate that the mux should be left
989b358af7SRob Herring      as is when it is idle. This is the default, but can still be useful for
999b358af7SRob Herring      mux controller chips with more than one mux controller, particularly when
1009b358af7SRob Herring      there is a need to "step past" a mux controller and set some other idle
1019b358af7SRob Herring      state for a mux controller with a higher index.
1029b358af7SRob Herring
1039b358af7SRob Herring      Some mux controllers have the ability to disconnect the input/output of the
1049b358af7SRob Herring      multiplexer. Using this disconnected high-impedance state as the idle state
1059b358af7SRob Herring      is indicated with idle state (-2).
1069b358af7SRob Herring    $ref: /schemas/types.yaml#/definitions/int32-array
1079b358af7SRob Herring    items:
1089b358af7SRob Herring      minimum: -2
1099b358af7SRob Herring
1109b358af7SRob HerringadditionalProperties: true
1119b358af7SRob Herring
1129b358af7SRob Herringexamples:
1139b358af7SRob Herring  - |
1149b358af7SRob Herring    #include <dt-bindings/gpio/gpio.h>
1159b358af7SRob Herring
1169b358af7SRob Herring    /* One consumer of a 2-way mux controller (one GPIO-line) */
1179b358af7SRob Herring    mux: mux-controller {
1189b358af7SRob Herring        compatible = "gpio-mux";
1199b358af7SRob Herring        #mux-control-cells = <0>;
1209b358af7SRob Herring
1219b358af7SRob Herring        mux-gpios = <&pioA 0 GPIO_ACTIVE_HIGH>;
1229b358af7SRob Herring    };
1239b358af7SRob Herring
1249b358af7SRob Herring    adc-mux {
1259b358af7SRob Herring        compatible = "io-channel-mux";
1269b358af7SRob Herring        io-channels = <&adc 0>;
1279b358af7SRob Herring        io-channel-names = "parent";
1289b358af7SRob Herring
1299b358af7SRob Herring        mux-controls = <&mux>;
1309b358af7SRob Herring        mux-control-names = "adc";
1319b358af7SRob Herring
1329b358af7SRob Herring        channels = "sync", "in";
1339b358af7SRob Herring    };
1349b358af7SRob Herring
1359b358af7SRob Herring  - |
1369b358af7SRob Herring    #include <dt-bindings/gpio/gpio.h>
1379b358af7SRob Herring
1389b358af7SRob Herring    /*
1399b358af7SRob Herring     * Two consumers (one for an ADC line and one for an i2c bus) of
1409b358af7SRob Herring     * parallel 4-way multiplexers controlled by the same two GPIO-lines.
1419b358af7SRob Herring     */
1429b358af7SRob Herring    mux2: mux-controller {
1439b358af7SRob Herring        compatible = "gpio-mux";
1449b358af7SRob Herring        #mux-control-cells = <0>;
1459b358af7SRob Herring
1469b358af7SRob Herring        mux-gpios = <&pioA 0 GPIO_ACTIVE_HIGH>,
1479b358af7SRob Herring              <&pioA 1 GPIO_ACTIVE_HIGH>;
1489b358af7SRob Herring    };
1499b358af7SRob Herring
1509b358af7SRob Herring    adc-mux {
1519b358af7SRob Herring        compatible = "io-channel-mux";
1529b358af7SRob Herring        io-channels = <&adc 0>;
1539b358af7SRob Herring        io-channel-names = "parent";
1549b358af7SRob Herring
1559b358af7SRob Herring        mux-controls = <&mux2>;
1569b358af7SRob Herring
1579b358af7SRob Herring        channels = "sync-1", "in", "out", "sync-2";
1589b358af7SRob Herring    };
1599b358af7SRob Herring
1609b358af7SRob Herring    i2c-mux {
1619b358af7SRob Herring        compatible = "i2c-mux";
1629b358af7SRob Herring        i2c-parent = <&i2c1>;
1639b358af7SRob Herring
1649b358af7SRob Herring        mux-controls = <&mux2>;
1659b358af7SRob Herring
1669b358af7SRob Herring        #address-cells = <1>;
1679b358af7SRob Herring        #size-cells = <0>;
1689b358af7SRob Herring
1699b358af7SRob Herring        i2c@0 {
1709b358af7SRob Herring            reg = <0>;
1719b358af7SRob Herring            #address-cells = <1>;
1729b358af7SRob Herring            #size-cells = <0>;
1739b358af7SRob Herring
1749b358af7SRob Herring            ssd1307: oled@3c {
1759b358af7SRob Herring                reg = <0x3c>;
1769b358af7SRob Herring            };
1779b358af7SRob Herring        };
1789b358af7SRob Herring
1799b358af7SRob Herring        i2c@3 {
1809b358af7SRob Herring            reg = <3>;
1819b358af7SRob Herring            #address-cells = <1>;
1829b358af7SRob Herring            #size-cells = <0>;
1839b358af7SRob Herring
1849b358af7SRob Herring            pca9555: pca9555@20 {
1859b358af7SRob Herring                reg = <0x20>;
1869b358af7SRob Herring            };
1879b358af7SRob Herring        };
1889b358af7SRob Herring    };
1898f2cade5SAswath Govindraju
1908f2cade5SAswath Govindraju  - |
1918f2cade5SAswath Govindraju    #include <dt-bindings/gpio/gpio.h>
1928f2cade5SAswath Govindraju
1938f2cade5SAswath Govindraju    mux1: mux-controller {
1948f2cade5SAswath Govindraju        compatible = "gpio-mux";
1958f2cade5SAswath Govindraju        #mux-state-cells = <1>;
1968f2cade5SAswath Govindraju        mux-gpios = <&exp_som 2 GPIO_ACTIVE_HIGH>;
1978f2cade5SAswath Govindraju    };
1988f2cade5SAswath Govindraju
1998f2cade5SAswath Govindraju    transceiver4: can-phy4 {
2008f2cade5SAswath Govindraju        compatible = "ti,tcan1042";
2018f2cade5SAswath Govindraju        #phy-cells = <0>;
2028f2cade5SAswath Govindraju        max-bitrate = <5000000>;
2038f2cade5SAswath Govindraju        standby-gpios = <&exp_som 7 GPIO_ACTIVE_HIGH>;
2048f2cade5SAswath Govindraju        mux-states = <&mux1 1>;
2058f2cade5SAswath Govindraju    };
2069b358af7SRob Herring...
207