summaryrefslogtreecommitdiffstats
path: root/Documentation/devicetree/bindings/gpio/gpio-line-mux.yaml
blob: f49c05249ca78f989f64d06e0d7a3b1157552eb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/gpio/gpio-line-mux.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: GPIO line mux

maintainers:
  - Jonas Jelonek <jelonek.jonas@gmail.com>

description: |
  A GPIO controller to provide virtual GPIOs for a 1-to-many input-only mapping
  backed by a single shared GPIO and a multiplexer. A simple illustrated
  example is:

            +----- A
    IN     /
    <-----o------- B
        / |\
        | | +----- C
        | |  \
        | |   +--- D
        | |
       M1 M0

    MUX CONTROL

     M1 M0   IN
      0  0   A
      0  1   B
      1  0   C
      1  1   D

  This can be used in case a real GPIO is connected to multiple inputs and
  controlled by a multiplexer, and another subsystem/driver does not work
  directly with the multiplexer subsystem.

properties:
  compatible:
    const: gpio-line-mux

  gpio-controller: true

  "#gpio-cells":
    const: 2

  gpio-line-mux-states:
    description: Mux states corresponding to the virtual GPIOs.
    $ref: /schemas/types.yaml#/definitions/uint32-array

  gpio-line-names: true

  mux-controls:
    maxItems: 1
    description:
      Phandle to the multiplexer to control access to the GPIOs.

  ngpios: false

  muxed-gpios:
    maxItems: 1
    description:
      GPIO which is the '1' in 1-to-many and is shared by the virtual GPIOs
      and controlled via the mux.

required:
  - compatible
  - gpio-controller
  - gpio-line-mux-states
  - mux-controls
  - muxed-gpios

additionalProperties: false

examples:
  - |
    #include <dt-bindings/gpio/gpio.h>
    #include <dt-bindings/mux/mux.h>

    sfp_gpio_mux: mux-controller-1 {
        compatible = "gpio-mux";
        mux-gpios = <&gpio0 0 GPIO_ACTIVE_HIGH>,
                    <&gpio0 1 GPIO_ACTIVE_HIGH>;
        #mux-control-cells = <0>;
        idle-state = <MUX_IDLE_AS_IS>;
    };

    sfp1_gpio: sfp-gpio-1 {
        compatible = "gpio-line-mux";
        gpio-controller;
        #gpio-cells = <2>;

        mux-controls = <&sfp_gpio_mux>;
        muxed-gpios = <&gpio0 2 GPIO_ACTIVE_HIGH>;

        gpio-line-mux-states = <0>, <1>, <3>;
    };

    sfp1: sfp-p1 {
        compatible = "sff,sfp";

        i2c-bus = <&sfp1_i2c>;
        los-gpios = <&sfp1_gpio 0 GPIO_ACTIVE_HIGH>;
        mod-def0-gpios = <&sfp1_gpio 1 GPIO_ACTIVE_LOW>;
        tx-fault-gpios = <&sfp1_gpio 2 GPIO_ACTIVE_HIGH>;
    };