xref: /linux/Documentation/devicetree/bindings/gpio/gpio-line-mux.yaml (revision f4b369c6fe0ceaba2da2daff8c9eb415f85926dd)
1# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2%YAML 1.2
3---
4$id: http://devicetree.org/schemas/gpio/gpio-line-mux.yaml#
5$schema: http://devicetree.org/meta-schemas/core.yaml#
6
7title: GPIO line mux
8
9maintainers:
10  - Jonas Jelonek <jelonek.jonas@gmail.com>
11
12description: |
13  A GPIO controller to provide virtual GPIOs for a 1-to-many input-only mapping
14  backed by a single shared GPIO and a multiplexer. A simple illustrated
15  example is:
16
17            +----- A
18    IN     /
19    <-----o------- B
20        / |\
21        | | +----- C
22        | |  \
23        | |   +--- D
24        | |
25       M1 M0
26
27    MUX CONTROL
28
29     M1 M0   IN
30      0  0   A
31      0  1   B
32      1  0   C
33      1  1   D
34
35  This can be used in case a real GPIO is connected to multiple inputs and
36  controlled by a multiplexer, and another subsystem/driver does not work
37  directly with the multiplexer subsystem.
38
39properties:
40  compatible:
41    const: gpio-line-mux
42
43  gpio-controller: true
44
45  "#gpio-cells":
46    const: 2
47
48  gpio-line-mux-states:
49    description: Mux states corresponding to the virtual GPIOs.
50    $ref: /schemas/types.yaml#/definitions/uint32-array
51
52  gpio-line-names: true
53
54  mux-controls:
55    maxItems: 1
56    description:
57      Phandle to the multiplexer to control access to the GPIOs.
58
59  ngpios: false
60
61  muxed-gpios:
62    maxItems: 1
63    description:
64      GPIO which is the '1' in 1-to-many and is shared by the virtual GPIOs
65      and controlled via the mux.
66
67required:
68  - compatible
69  - gpio-controller
70  - gpio-line-mux-states
71  - mux-controls
72  - muxed-gpios
73
74additionalProperties: false
75
76examples:
77  - |
78    #include <dt-bindings/gpio/gpio.h>
79    #include <dt-bindings/mux/mux.h>
80
81    sfp_gpio_mux: mux-controller-1 {
82        compatible = "gpio-mux";
83        mux-gpios = <&gpio0 0 GPIO_ACTIVE_HIGH>,
84                    <&gpio0 1 GPIO_ACTIVE_HIGH>;
85        #mux-control-cells = <0>;
86        idle-state = <MUX_IDLE_AS_IS>;
87    };
88
89    sfp1_gpio: sfp-gpio-1 {
90        compatible = "gpio-line-mux";
91        gpio-controller;
92        #gpio-cells = <2>;
93
94        mux-controls = <&sfp_gpio_mux>;
95        muxed-gpios = <&gpio0 2 GPIO_ACTIVE_HIGH>;
96
97        gpio-line-mux-states = <0>, <1>, <3>;
98    };
99
100    sfp1: sfp-p1 {
101        compatible = "sff,sfp";
102
103        i2c-bus = <&sfp1_i2c>;
104        los-gpios = <&sfp1_gpio 0 GPIO_ACTIVE_HIGH>;
105        mod-def0-gpios = <&sfp1_gpio 1 GPIO_ACTIVE_LOW>;
106        tx-fault-gpios = <&sfp1_gpio 2 GPIO_ACTIVE_HIGH>;
107    };
108