diff options
Diffstat (limited to 'Documentation/devicetree/bindings/gpio/gpio.txt')
| -rw-r--r-- | Documentation/devicetree/bindings/gpio/gpio.txt | 93 |
1 files changed, 67 insertions, 26 deletions
diff --git a/Documentation/devicetree/bindings/gpio/gpio.txt b/Documentation/devicetree/bindings/gpio/gpio.txt index d933af370697..0c85bb6e3a80 100644 --- a/Documentation/devicetree/bindings/gpio/gpio.txt +++ b/Documentation/devicetree/bindings/gpio/gpio.txt | |||
| @@ -75,23 +75,51 @@ Example of two SOC GPIO banks defined as gpio-controller nodes: | |||
| 75 | gpio-controller; | 75 | gpio-controller; |
| 76 | }; | 76 | }; |
| 77 | 77 | ||
| 78 | 2.1) gpio-controller and pinctrl subsystem | 78 | 2.1) gpio- and pin-controller interaction |
| 79 | ------------------------------------------ | 79 | ----------------------------------------- |
| 80 | 80 | ||
| 81 | gpio-controller on a SOC might be tightly coupled with the pinctrl | 81 | Some or all of the GPIOs provided by a GPIO controller may be routed to pins |
| 82 | subsystem, in the sense that the pins can be used by other functions | 82 | on the package via a pin controller. This allows muxing those pins between |
| 83 | together with optional gpio feature. | 83 | GPIO and other functions. |
| 84 | 84 | ||
| 85 | While the pin allocation is totally managed by the pin ctrl subsystem, | 85 | It is useful to represent which GPIOs correspond to which pins on which pin |
| 86 | gpio (under gpiolib) is still maintained by gpio drivers. It may happen | 86 | controllers. The gpio-ranges property described below represents this, and |
| 87 | that different pin ranges in a SoC is managed by different gpio drivers. | 87 | contains information structures as follows: |
| 88 | 88 | ||
| 89 | This makes it logical to let gpio drivers announce their pin ranges to | 89 | gpio-range-list ::= <single-gpio-range> [gpio-range-list] |
| 90 | the pin ctrl subsystem and call 'pinctrl_request_gpio' in order to | 90 | single-gpio-range ::= <numeric-gpio-range> | <named-gpio-range> |
| 91 | request the corresponding pin before any gpio usage. | 91 | numeric-gpio-range ::= |
| 92 | 92 | <pinctrl-phandle> <gpio-base> <pinctrl-base> <count> | |
| 93 | For this, the gpio controller can use a pinctrl phandle and pins to | 93 | named-gpio-range ::= <pinctrl-phandle> <gpio-base> '<0 0>' |
| 94 | announce the pinrange to the pin ctrl subsystem. For example, | 94 | gpio-phandle : phandle to pin controller node. |
| 95 | gpio-base : Base GPIO ID in the GPIO controller | ||
| 96 | pinctrl-base : Base pinctrl pin ID in the pin controller | ||
| 97 | count : The number of GPIOs/pins in this range | ||
| 98 | |||
| 99 | The "pin controller node" mentioned above must conform to the bindings | ||
| 100 | described in ../pinctrl/pinctrl-bindings.txt. | ||
| 101 | |||
| 102 | In case named gpio ranges are used (ranges with both <pinctrl-base> and | ||
| 103 | <count> set to 0), the property gpio-ranges-group-names contains one string | ||
| 104 | for every single-gpio-range in gpio-ranges: | ||
| 105 | gpiorange-names-list ::= <gpiorange-name> [gpiorange-names-list] | ||
| 106 | gpiorange-name : Name of the pingroup associated to the GPIO range in | ||
| 107 | the respective pin controller. | ||
| 108 | |||
| 109 | Elements of gpiorange-names-list corresponding to numeric ranges contain | ||
| 110 | the empty string. Elements of gpiorange-names-list corresponding to named | ||
| 111 | ranges contain the name of a pin group defined in the respective pin | ||
| 112 | controller. The number of pins/GPIOs in the range is the number of pins in | ||
| 113 | that pin group. | ||
| 114 | |||
| 115 | Previous versions of this binding required all pin controller nodes that | ||
| 116 | were referenced by any gpio-ranges property to contain a property named | ||
| 117 | #gpio-range-cells with value <3>. This requirement is now deprecated. | ||
| 118 | However, that property may still exist in older device trees for | ||
| 119 | compatibility reasons, and would still be required even in new device | ||
| 120 | trees that need to be compatible with older software. | ||
| 121 | |||
| 122 | Example 1: | ||
| 95 | 123 | ||
| 96 | qe_pio_e: gpio-controller@1460 { | 124 | qe_pio_e: gpio-controller@1460 { |
| 97 | #gpio-cells = <2>; | 125 | #gpio-cells = <2>; |
| @@ -99,16 +127,29 @@ announce the pinrange to the pin ctrl subsystem. For example, | |||
| 99 | reg = <0x1460 0x18>; | 127 | reg = <0x1460 0x18>; |
| 100 | gpio-controller; | 128 | gpio-controller; |
| 101 | gpio-ranges = <&pinctrl1 0 20 10>, <&pinctrl2 10 50 20>; | 129 | gpio-ranges = <&pinctrl1 0 20 10>, <&pinctrl2 10 50 20>; |
| 130 | }; | ||
| 102 | 131 | ||
| 103 | } | 132 | Here, a single GPIO controller has GPIOs 0..9 routed to pin controller |
| 133 | pinctrl1's pins 20..29, and GPIOs 10..19 routed to pin controller pinctrl2's | ||
| 134 | pins 50..59. | ||
| 104 | 135 | ||
| 105 | where, | 136 | Example 2: |
| 106 | &pinctrl1 and &pinctrl2 is the phandle to the pinctrl DT node. | ||
| 107 | 137 | ||
| 108 | Next values specify the base pin and number of pins for the range | 138 | gpio_pio_i: gpio-controller@14B0 { |
| 109 | handled by 'qe_pio_e' gpio. In the given example from base pin 20 to | 139 | #gpio-cells = <2>; |
| 110 | pin 29 under pinctrl1 with gpio offset 0 and pin 50 to pin 69 under | 140 | compatible = "fsl,qe-pario-bank-e", "fsl,qe-pario-bank"; |
| 111 | pinctrl2 with gpio offset 10 is handled by this gpio controller. | 141 | reg = <0x1480 0x18>; |
| 142 | gpio-controller; | ||
| 143 | gpio-ranges = <&pinctrl1 0 20 10>, | ||
| 144 | <&pinctrl2 10 0 0>, | ||
| 145 | <&pinctrl1 15 0 10>, | ||
| 146 | <&pinctrl2 25 0 0>; | ||
| 147 | gpio-ranges-group-names = "", | ||
| 148 | "foo", | ||
| 149 | "", | ||
| 150 | "bar"; | ||
| 151 | }; | ||
| 112 | 152 | ||
| 113 | The pinctrl node must have "#gpio-range-cells" property to show number of | 153 | Here, three GPIO ranges are defined wrt. two pin controllers. pinctrl1 GPIO |
| 114 | arguments to pass with phandle from gpio controllers node. | 154 | ranges are defined using pin numbers whereas the GPIO ranges wrt. pinctrl2 |
| 155 | are named "foo" and "bar". | ||
