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