Merge tag 'asoc-fix-v5.0-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/brooni...
[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,stm32f769-pinctrl"
15    "st,stm32h743-pinctrl"
16    "st,stm32mp157-pinctrl"
17    "st,stm32mp157-z-pinctrl"
18  - #address-cells: The value of this property must be 1
19  - #size-cells  : The value of this property must be 1
20  - ranges       : defines mapping between pin controller node (parent) to
21    gpio-bank node (children).
22  - pins-are-numbered: Specify the subnodes are using numbered pinmux to
23    specify pins.
24
25 GPIO controller/bank node:
26 Required properties:
27  - gpio-controller : Indicates this device is a GPIO controller
28  - #gpio-cells    : Should be two.
29                         The first cell is the pin number
30                         The second one is the polarity:
31                                 - 0 for active high
32                                 - 1 for active low
33  - reg            : The gpio address range, relative to the pinctrl range
34  - clocks         : clock that drives this bank
35  - st,bank-name   : Should be a name string for this bank as specified in
36    the datasheet
37
38 Optional properties:
39  - reset:         : Reference to the reset controller
40  - st,syscfg: Should be phandle/offset/mask.
41         -The phandle to the syscon node which includes IRQ mux selection register.
42         -The offset of the IRQ mux selection register
43         -The field mask of IRQ mux, needed if different of 0xf.
44  - gpio-ranges: Define a dedicated mapping between a pin-controller and
45    a gpio controller. Format is <&phandle a b c> with:
46         -(phandle): phandle of pin-controller.
47         -(a): gpio base offset in range.
48         -(b): pin base offset in range.
49         -(c): gpio count in range
50    This entry has to be used either if there are holes inside a bank:
51         GPIOB0/B1/B2/B14/B15 (see example 2)
52    or if banks are not contiguous:
53         GPIOA/B/C/E...
54    NOTE: If "gpio-ranges" is used for a gpio controller, all gpio-controller
55    have to use a "gpio-ranges" entry.
56    More details in Documentation/devicetree/bindings/gpio/gpio.txt.
57  - st,bank-ioport: should correspond to the EXTI IOport selection (EXTI line
58    used to select GPIOs as interrupts).
59  - hwlocks: reference to a phandle of a hardware spinlock provider node.
60
61 Example 1:
62 #include <dt-bindings/pinctrl/stm32f429-pinfunc.h>
63 ...
64
65         pin-controller {
66                 #address-cells = <1>;
67                 #size-cells = <1>;
68                 compatible = "st,stm32f429-pinctrl";
69                 ranges = <0 0x40020000 0x3000>;
70                 pins-are-numbered;
71
72                 gpioa: gpio@40020000 {
73                         gpio-controller;
74                         #gpio-cells = <2>;
75                         reg = <0x0 0x400>;
76                         resets = <&reset_ahb1 0>;
77                         st,bank-name = "GPIOA";
78                 };
79                 ...
80                 pin-functions nodes follow...
81         };
82
83 Example 2:
84 #include <dt-bindings/pinctrl/stm32f429-pinfunc.h>
85 ...
86
87         pinctrl: pin-controller {
88                 #address-cells = <1>;
89                 #size-cells = <1>;
90                 compatible = "st,stm32f429-pinctrl";
91                 ranges = <0 0x40020000 0x3000>;
92                 pins-are-numbered;
93
94                 gpioa: gpio@40020000 {
95                         gpio-controller;
96                         #gpio-cells = <2>;
97                         reg = <0x0 0x400>;
98                         resets = <&reset_ahb1 0>;
99                         st,bank-name = "GPIOA";
100                         gpio-ranges = <&pinctrl 0 0 16>;
101                 };
102
103                 gpiob: gpio@40020400 {
104                         gpio-controller;
105                         #gpio-cells = <2>;
106                         reg = <0x0 0x400>;
107                         resets = <&reset_ahb1 0>;
108                         st,bank-name = "GPIOB";
109                         ngpios = 4;
110                         gpio-ranges = <&pinctrl 0 16 3>,
111                                       <&pinctrl 14 30 2>;
112                 };
113
114
115                 ...
116                 pin-functions nodes follow...
117         };
118
119
120 Contents of function subnode node:
121 ----------------------------------
122 Subnode format
123 A pinctrl node should contain at least one subnode representing the
124 pinctrl group available on the machine. Each subnode will list the
125 pins it needs, and how they should be configured, with regard to muxer
126 configuration, pullups, drive, output high/low and output speed.
127
128     node {
129         pinmux = <PIN_NUMBER_PINMUX>;
130         GENERIC_PINCONFIG;
131     };
132
133 Required properties:
134 - pinmux: integer array, represents gpio pin number and mux setting.
135   Supported pin number and mux varies for different SoCs, and are defined in
136   dt-bindings/pinctrl/<soc>-pinfunc.h directly.
137   These defines are calculated as:
138     ((port * 16 + line) << 8) | function
139   With:
140     - port: The gpio port index (PA = 0, PB = 1, ..., PK = 11)
141     - line: The line offset within the port (PA0 = 0, PA1 = 1, ..., PA15 = 15)
142     - function: The function number, can be:
143       * 0 : GPIO
144       * 1 : Alternate Function 0
145       * 2 : Alternate Function 1
146       * 3 : Alternate Function 2
147       * ...
148       * 16 : Alternate Function 15
149       * 17 : Analog
150
151   To simplify the usage, macro is available to generate "pinmux" field.
152   This macro is available here:
153     - include/dt-bindings/pinctrl/stm32-pinfunc.h
154
155   Some examples of using macro:
156     /* GPIO A9 set as alernate function 2 */
157     ... {
158                 pinmux = <STM32_PINMUX('A', 9, AF2)>;
159     };
160     /* GPIO A9 set as GPIO  */
161     ... {
162                 pinmux = <STM32_PINMUX('A', 9, GPIO)>;
163     };
164     /* GPIO A9 set as analog */
165     ... {
166                 pinmux = <STM32_PINMUX('A', 9, ANALOG)>;
167     };
168
169 Optional properties:
170 - GENERIC_PINCONFIG: is the generic pinconfig options to use.
171   Available options are:
172    - bias-disable,
173    - bias-pull-down,
174    - bias-pull-up,
175    - drive-push-pull,
176    - drive-open-drain,
177    - output-low
178    - output-high
179    - slew-rate = <x>, with x being:
180        < 0 > : Low speed
181        < 1 > : Medium speed
182        < 2 > : Fast speed
183        < 3 > : High speed
184
185 Example:
186
187 pin-controller {
188 ...
189         usart1_pins_a: usart1@0 {
190                 pins1 {
191                         pinmux = <STM32_PINMUX('A', 9, AF7)>;
192                         bias-disable;
193                         drive-push-pull;
194                         slew-rate = <0>;
195                 };
196                 pins2 {
197                         pinmux = <STM32_PINMUX('A', 10, AF7)>;
198                         bias-disable;
199                 };
200         };
201 };
202
203 &usart1 {
204         pinctrl-0 = <&usart1_pins_a>;
205         pinctrl-names = "default";
206 };