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