Merge tag 'for-linus-4.15-rc7-tag' of git://git.kernel.org/pub/scm/linux/kernel/git...
[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   To simplify the usage, macro is available to generate "pinmux" field.
147   This macro is available here:
148     - include/dt-bindings/pinctrl/stm32-pinfunc.h
149
150   Some examples of using macro:
151     /* GPIO A9 set as alernate function 2 */
152     ... {
153                 pinmux = <STM32_PINMUX('A', 9, AF2)>;
154     };
155     /* GPIO A9 set as GPIO  */
156     ... {
157                 pinmux = <STM32_PINMUX('A', 9, GPIO)>;
158     };
159     /* GPIO A9 set as analog */
160     ... {
161                 pinmux = <STM32_PINMUX('A', 9, ANALOG)>;
162     };
163
164 Optional properties:
165 - GENERIC_PINCONFIG: is the generic pinconfig options to use.
166   Available options are:
167    - bias-disable,
168    - bias-pull-down,
169    - bias-pull-up,
170    - drive-push-pull,
171    - drive-open-drain,
172    - output-low
173    - output-high
174    - slew-rate = <x>, with x being:
175        < 0 > : Low speed
176        < 1 > : Medium speed
177        < 2 > : Fast speed
178        < 3 > : High speed
179
180 Example:
181
182 pin-controller {
183 ...
184         usart1_pins_a: usart1@0 {
185                 pins1 {
186                         pinmux = <STM32_PINMUX('A', 9, AF7)>;
187                         bias-disable;
188                         drive-push-pull;
189                         slew-rate = <0>;
190                 };
191                 pins2 {
192                         pinmux = <STM32_PINMUX('A', 10, AF7)>;
193                         bias-disable;
194                 };
195         };
196 };
197
198 &usart1 {
199         pinctrl-0 = <&usart1_pins_a>;
200         pinctrl-names = "default";
201 };