Merge tag 'bcm2835-dt-next-2017-03-30' into devicetree/fixes
[sfrench/cifs-2.6.git] / Documentation / devicetree / bindings / pinctrl / st,stm32-pinctrl.txt
1 * STM32 GPIO and Pin Mux/Config controller
2
3 STMicroelectronics's STM32 MCUs intregrate a GPIO and Pin mux/config hardware
4 controller. It controls the input/output settings on the available pins and
5 also provides ability to multiplex and configure the output of various on-chip
6 controllers onto these pads.
7
8 Pin controller node:
9 Required properies:
10  - compatible: value should be one of the following:
11    "st,stm32f429-pinctrl"
12    "st,stm32f469-pinctrl"
13    "st,stm32f746-pinctrl"
14    "st,stm32h743-pinctrl"
15  - #address-cells: The value of this property must be 1
16  - #size-cells  : The value of this property must be 1
17  - ranges       : defines mapping between pin controller node (parent) to
18    gpio-bank node (children).
19  - pins-are-numbered: Specify the subnodes are using numbered pinmux to
20    specify pins.
21
22 GPIO controller/bank node:
23 Required properties:
24  - gpio-controller : Indicates this device is a GPIO controller
25  - #gpio-cells    : Should be two.
26                         The first cell is the pin number
27                         The second one is the polarity:
28                                 - 0 for active high
29                                 - 1 for active low
30  - reg            : The gpio address range, relative to the pinctrl range
31  - clocks         : clock that drives this bank
32  - st,bank-name   : Should be a name string for this bank as specified in
33    the datasheet
34
35 Optional properties:
36  - reset:         : Reference to the reset controller
37  - interrupt-parent: phandle of the interrupt parent to which the external
38    GPIO interrupts are forwarded to.
39  - st,syscfg: Should be phandle/offset pair. The phandle to the syscon node
40    which includes IRQ mux selection register, and the offset of the IRQ mux
41    selection register.
42  - gpio-ranges: Define a dedicated mapping between a pin-controller and
43    a gpio controller. Format is <&phandle a b c> with:
44         -(phandle): phandle of pin-controller.
45         -(a): gpio base offset in range.
46         -(b): pin base offset in range.
47         -(c): gpio count in range
48    This entry has to be used either if there are holes inside a bank:
49         GPIOB0/B1/B2/B14/B15 (see example 2)
50    or if banks are not contiguous:
51         GPIOA/B/C/E...
52    NOTE: If "gpio-ranges" is used for a gpio controller, all gpio-controller
53    have to use a "gpio-ranges" entry.
54    More details in Documentation/devicetree/bindings/gpio/gpio.txt.
55
56 Example 1:
57 #include <dt-bindings/pinctrl/stm32f429-pinfunc.h>
58 ...
59
60         pin-controller {
61                 #address-cells = <1>;
62                 #size-cells = <1>;
63                 compatible = "st,stm32f429-pinctrl";
64                 ranges = <0 0x40020000 0x3000>;
65                 pins-are-numbered;
66
67                 gpioa: gpio@40020000 {
68                         gpio-controller;
69                         #gpio-cells = <2>;
70                         reg = <0x0 0x400>;
71                         resets = <&reset_ahb1 0>;
72                         st,bank-name = "GPIOA";
73                 };
74                 ...
75                 pin-functions nodes follow...
76         };
77
78 Example 2:
79 #include <dt-bindings/pinctrl/stm32f429-pinfunc.h>
80 ...
81
82         pinctrl: pin-controller {
83                 #address-cells = <1>;
84                 #size-cells = <1>;
85                 compatible = "st,stm32f429-pinctrl";
86                 ranges = <0 0x40020000 0x3000>;
87                 pins-are-numbered;
88
89                 gpioa: gpio@40020000 {
90                         gpio-controller;
91                         #gpio-cells = <2>;
92                         reg = <0x0 0x400>;
93                         resets = <&reset_ahb1 0>;
94                         st,bank-name = "GPIOA";
95                         gpio-ranges = <&pinctrl 0 0 16>;
96                 };
97
98                 gpiob: gpio@40020400 {
99                         gpio-controller;
100                         #gpio-cells = <2>;
101                         reg = <0x0 0x400>;
102                         resets = <&reset_ahb1 0>;
103                         st,bank-name = "GPIOB";
104                         ngpios = 4;
105                         gpio-ranges = <&pinctrl 0 16 3>,
106                                       <&pinctrl 14 30 2>;
107                 };
108
109
110                 ...
111                 pin-functions nodes follow...
112         };
113
114
115 Contents of function subnode node:
116 ----------------------------------
117 Subnode format
118 A pinctrl node should contain at least one subnode representing the
119 pinctrl group available on the machine. Each subnode will list the
120 pins it needs, and how they should be configured, with regard to muxer
121 configuration, pullups, drive, output high/low and output speed.
122
123     node {
124         pinmux = <PIN_NUMBER_PINMUX>;
125         GENERIC_PINCONFIG;
126     };
127
128 Required properties:
129 - pinmux: integer array, represents gpio pin number and mux setting.
130   Supported pin number and mux varies for different SoCs, and are defined in
131   dt-bindings/pinctrl/<soc>-pinfunc.h directly.
132   These defines are calculated as:
133     ((port * 16 + line) << 8) | function
134   With:
135     - port: The gpio port index (PA = 0, PB = 1, ..., PK = 11)
136     - line: The line offset within the port (PA0 = 0, PA1 = 1, ..., PA15 = 15)
137     - function: The function number, can be:
138       * 0 : GPIO
139       * 1 : Alternate Function 0
140       * 2 : Alternate Function 1
141       * 3 : Alternate Function 2
142       * ...
143       * 16 : Alternate Function 15
144       * 17 : Analog
145
146 Optional properties:
147 - GENERIC_PINCONFIG: is the generic pinconfig options to use.
148   Available options are:
149    - bias-disable,
150    - bias-pull-down,
151    - bias-pull-up,
152    - drive-push-pull,
153    - drive-open-drain,
154    - output-low
155    - output-high
156    - slew-rate = <x>, with x being:
157        < 0 > : Low speed
158        < 1 > : Medium speed
159        < 2 > : Fast speed
160        < 3 > : High speed
161
162 Example:
163
164 pin-controller {
165 ...
166         usart1_pins_a: usart1@0 {
167                 pins1 {
168                         pinmux = <STM32F429_PA9_FUNC_USART1_TX>;
169                         bias-disable;
170                         drive-push-pull;
171                         slew-rate = <0>;
172                 };
173                 pins2 {
174                         pinmux = <STM32F429_PA10_FUNC_USART1_RX>;
175                         bias-disable;
176                 };
177         };
178 };
179
180 &usart1 {
181         pinctrl-0 = <&usart1_pins_a>;
182         pinctrl-names = "default";
183         status = "okay";
184 };