xref: /linux/Documentation/devicetree/bindings/i2c/i2c-mux-gpio.yaml (revision dc53dbe3e79008ca7c1bc5e5ae2c71b52161f96d)
1f91030edSThierry Reding# SPDX-License-Identifier: GPL-2.0-only
2f91030edSThierry Reding%YAML 1.2
3f91030edSThierry Reding---
4f91030edSThierry Reding$id: http://devicetree.org/schemas/i2c/i2c-mux-gpio.yaml#
5f91030edSThierry Reding$schema: http://devicetree.org/meta-schemas/core.yaml#
6f91030edSThierry Reding
7f91030edSThierry Redingtitle: GPIO-based I2C Bus Mux
8f91030edSThierry Reding
9f91030edSThierry Redingmaintainers:
10f91030edSThierry Reding  - Wolfram Sang <wsa@kernel.org>
11f91030edSThierry Reding
12f91030edSThierry Redingdescription: |
13f91030edSThierry Reding  This binding describes an I2C bus multiplexer that uses GPIOs to route the I2C signals.
14f91030edSThierry Reding
15f91030edSThierry Reding                                  +-----+  +-----+
16f91030edSThierry Reding                                  | dev |  | dev |
17f91030edSThierry Reding    +------------+                +-----+  +-----+
18f91030edSThierry Reding    | SoC        |                   |        |
19f91030edSThierry Reding    |            |          /--------+--------+
20f91030edSThierry Reding    |   +------+ |  +------+    child bus A, on GPIO value set to 0
21f91030edSThierry Reding    |   | I2C  |-|--| Mux  |
22f91030edSThierry Reding    |   +------+ |  +--+---+    child bus B, on GPIO value set to 1
23f91030edSThierry Reding    |            |     |    \----------+--------+--------+
24f91030edSThierry Reding    |   +------+ |     |               |        |        |
25f91030edSThierry Reding    |   | GPIO |-|-----+            +-----+  +-----+  +-----+
26f91030edSThierry Reding    |   +------+ |                  | dev |  | dev |  | dev |
27f91030edSThierry Reding    +------------+                  +-----+  +-----+  +-----+
28f91030edSThierry Reding
29f91030edSThierry Reding  For each I2C child node, an I2C child bus will be created. They will be numbered based on their
30f91030edSThierry Reding  order in the device tree.
31f91030edSThierry Reding
32f91030edSThierry Reding  Whenever an access is made to a device on a child bus, the value set in the relevant node's reg
33f91030edSThierry Reding  property will be output using the list of GPIOs, the first in the list holding the least-
34f91030edSThierry Reding  significant value.
35f91030edSThierry Reding
36f91030edSThierry Reding  If an idle state is defined, using the idle-state (optional) property, whenever an access is not
37f91030edSThierry Reding  being made to a device on a child bus, the GPIOs will be set according to the idle value.
38f91030edSThierry Reding
39f91030edSThierry Reding  If an idle state is not defined, the most recently used value will be left programmed into
40f91030edSThierry Reding  hardware whenever no access is being made to a device on a child bus.
41f91030edSThierry Reding
42f91030edSThierry Redingproperties:
43f91030edSThierry Reding  compatible:
44f91030edSThierry Reding    const: i2c-mux-gpio
45f91030edSThierry Reding
46f91030edSThierry Reding  i2c-parent:
47f91030edSThierry Reding    description: phandle of the I2C bus that this multiplexer's master-side port is connected to
48fc114c75SRob Herring    $ref: /schemas/types.yaml#/definitions/phandle
49f91030edSThierry Reding
50f91030edSThierry Reding  mux-gpios:
51f91030edSThierry Reding    description: list of GPIOs used to control the muxer
52f91030edSThierry Reding    minItems: 1
53f91030edSThierry Reding    maxItems: 4  # Should be enough
54f91030edSThierry Reding
55f91030edSThierry Reding  idle-state:
56f91030edSThierry Reding    description: Value to set the muxer to when idle. When no value is given, it defaults to the
57f91030edSThierry Reding      last value used.
58fc114c75SRob Herring    $ref: /schemas/types.yaml#/definitions/uint32
59f91030edSThierry Reding
60*dc53dbe3SBastien Curutchet  settle-time-us:
61*dc53dbe3SBastien Curutchet    description: Delay to wait before doing any transfer when a new bus gets selected.
62*dc53dbe3SBastien Curutchet
63f91030edSThierry RedingallOf:
64f91030edSThierry Reding  - $ref: i2c-mux.yaml
65f91030edSThierry Reding
66f91030edSThierry RedingunevaluatedProperties: false
67f91030edSThierry Reding
68f91030edSThierry Redingrequired:
69f91030edSThierry Reding  - compatible
70f91030edSThierry Reding  - i2c-parent
71f91030edSThierry Reding  - mux-gpios
72f91030edSThierry Reding
73f91030edSThierry Redingexamples:
74f91030edSThierry Reding  - |
75f91030edSThierry Reding    i2cmux {
76f91030edSThierry Reding      compatible = "i2c-mux-gpio";
77f91030edSThierry Reding      #address-cells = <1>;
78f91030edSThierry Reding      #size-cells = <0>;
79f91030edSThierry Reding      mux-gpios = <&gpio1 22 0>, <&gpio1 23 0>;
80f91030edSThierry Reding      i2c-parent = <&i2c1>;
81f91030edSThierry Reding
82f91030edSThierry Reding      i2c@1 {
83f91030edSThierry Reding        reg = <1>;
84f91030edSThierry Reding        #address-cells = <1>;
85f91030edSThierry Reding        #size-cells = <0>;
86f91030edSThierry Reding
87f91030edSThierry Reding        ssd1307: oled@3c {
88f91030edSThierry Reding          compatible = "solomon,ssd1307fb-i2c";
89f91030edSThierry Reding          reg = <0x3c>;
90f91030edSThierry Reding          pwms = <&pwm 4 3000>;
91f91030edSThierry Reding          reset-gpios = <&gpio2 7 1>;
92f91030edSThierry Reding        };
93f91030edSThierry Reding      };
94f91030edSThierry Reding
95f91030edSThierry Reding      i2c@3 {
96f91030edSThierry Reding        reg = <3>;
97f91030edSThierry Reding        #address-cells = <1>;
98f91030edSThierry Reding        #size-cells = <0>;
99f91030edSThierry Reding
100f91030edSThierry Reding        pca9555: pca9555@20 {
101f91030edSThierry Reding          compatible = "nxp,pca9555";
102f91030edSThierry Reding          gpio-controller;
103f91030edSThierry Reding          #gpio-cells = <2>;
104f91030edSThierry Reding          reg = <0x20>;
105f91030edSThierry Reding        };
106f91030edSThierry Reding      };
107f91030edSThierry Reding    };
108