Back to home page

OSCL-LXR

 
 

    


0001 # SPDX-License-Identifier: GPL-2.0-only
0002 %YAML 1.2
0003 ---
0004 $id: http://devicetree.org/schemas/i2c/i2c-mux-gpio.yaml#
0005 $schema: http://devicetree.org/meta-schemas/core.yaml#
0006 
0007 title: GPIO-based I2C Bus Mux
0008 
0009 maintainers:
0010   - Wolfram Sang <wsa@kernel.org>
0011 
0012 description: |
0013   This binding describes an I2C bus multiplexer that uses GPIOs to route the I2C signals.
0014 
0015                                   +-----+  +-----+
0016                                   | dev |  | dev |
0017     +------------+                +-----+  +-----+
0018     | SoC        |                   |        |
0019     |            |          /--------+--------+
0020     |   +------+ |  +------+    child bus A, on GPIO value set to 0
0021     |   | I2C  |-|--| Mux  |
0022     |   +------+ |  +--+---+    child bus B, on GPIO value set to 1
0023     |            |     |    \----------+--------+--------+
0024     |   +------+ |     |               |        |        |
0025     |   | GPIO |-|-----+            +-----+  +-----+  +-----+
0026     |   +------+ |                  | dev |  | dev |  | dev |
0027     +------------+                  +-----+  +-----+  +-----+
0028 
0029   For each I2C child node, an I2C child bus will be created. They will be numbered based on their
0030   order in the device tree.
0031 
0032   Whenever an access is made to a device on a child bus, the value set in the relevant node's reg
0033   property will be output using the list of GPIOs, the first in the list holding the least-
0034   significant value.
0035 
0036   If an idle state is defined, using the idle-state (optional) property, whenever an access is not
0037   being made to a device on a child bus, the GPIOs will be set according to the idle value.
0038 
0039   If an idle state is not defined, the most recently used value will be left programmed into
0040   hardware whenever no access is being made to a device on a child bus.
0041 
0042 properties:
0043   compatible:
0044     const: i2c-mux-gpio
0045 
0046   i2c-parent:
0047     description: phandle of the I2C bus that this multiplexer's master-side port is connected to
0048     $ref: "/schemas/types.yaml#/definitions/phandle"
0049 
0050   mux-gpios:
0051     description: list of GPIOs used to control the muxer
0052     minItems: 1
0053     maxItems: 4  # Should be enough
0054 
0055   idle-state:
0056     description: Value to set the muxer to when idle. When no value is given, it defaults to the
0057       last value used.
0058     $ref: "/schemas/types.yaml#/definitions/uint32"
0059 
0060 allOf:
0061   - $ref: i2c-mux.yaml
0062 
0063 unevaluatedProperties: false
0064 
0065 required:
0066   - compatible
0067   - i2c-parent
0068   - mux-gpios
0069 
0070 examples:
0071   - |
0072     i2cmux {
0073       compatible = "i2c-mux-gpio";
0074       #address-cells = <1>;
0075       #size-cells = <0>;
0076       mux-gpios = <&gpio1 22 0>, <&gpio1 23 0>;
0077       i2c-parent = <&i2c1>;
0078 
0079       i2c@1 {
0080         reg = <1>;
0081         #address-cells = <1>;
0082         #size-cells = <0>;
0083 
0084         ssd1307: oled@3c {
0085           compatible = "solomon,ssd1307fb-i2c";
0086           reg = <0x3c>;
0087           pwms = <&pwm 4 3000>;
0088           reset-gpios = <&gpio2 7 1>;
0089         };
0090       };
0091 
0092       i2c@3 {
0093         reg = <3>;
0094         #address-cells = <1>;
0095         #size-cells = <0>;
0096 
0097         pca9555: pca9555@20 {
0098           compatible = "nxp,pca9555";
0099           gpio-controller;
0100           #gpio-cells = <2>;
0101           reg = <0x20>;
0102         };
0103       };
0104     };