blob: 83a18d0331b1844645e5730f911f4b44b83b7199 [file] [log] [blame]
Alexandre Torgue2c9239c2019-05-10 17:45:26 +02001# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
2# Copyright (C) STMicroelectronics 2019.
3%YAML 1.2
4---
5$id: http://devicetree.org/schemas/pinctrl/st,stm32-pinctrl.yaml#
6$schema: http://devicetree.org/meta-schemas/core.yaml#
7
8title: STM32 GPIO and Pin Mux/Config controller
9
10maintainers:
Patrice Chotardf4eedeb2021-11-10 16:01:44 +010011 - Alexandre TORGUE <alexandre.torgue@foss.st.com>
Alexandre Torgue2c9239c2019-05-10 17:45:26 +020012
13description: |
14 STMicroelectronics's STM32 MCUs intregrate a GPIO and Pin mux/config hardware
15 controller. It controls the input/output settings on the available pins and
16 also provides ability to multiplex and configure the output of various
17 on-chip controllers onto these pads.
18
19properties:
20 compatible:
21 enum:
22 - st,stm32f429-pinctrl
23 - st,stm32f469-pinctrl
24 - st,stm32f746-pinctrl
25 - st,stm32f769-pinctrl
26 - st,stm32h743-pinctrl
Alexandre Torgue510fc342021-07-23 15:28:04 +020027 - st,stm32mp135-pinctrl
Alexandre Torgue2c9239c2019-05-10 17:45:26 +020028 - st,stm32mp157-pinctrl
29 - st,stm32mp157-z-pinctrl
30
31 '#address-cells':
32 const: 1
33 '#size-cells':
34 const: 1
35
36 ranges: true
37 pins-are-numbered: true
38 hwlocks: true
39
Benjamin Gaignarda45c0ec22020-05-13 16:59:34 +020040 interrupts:
41 maxItems: 1
42
Alexandre Torgue2c9239c2019-05-10 17:45:26 +020043 st,syscfg:
Alexandre Torgue2c9239c2019-05-10 17:45:26 +020044 description: Should be phandle/offset/mask
Alexandre Torgue4b6fffe2019-10-07 15:44:09 +020045 - Phandle to the syscon node which includes IRQ mux selection.
46 - The offset of the IRQ mux selection register.
47 - The field mask of IRQ mux, needed if different of 0xf.
Rob Herring3d21a462020-04-15 19:55:49 -050048 $ref: "/schemas/types.yaml#/definitions/phandle-array"
Alexandre Torgue2c9239c2019-05-10 17:45:26 +020049
50 st,package:
Alexandre Torgue2c9239c2019-05-10 17:45:26 +020051 description:
Rob Herringf516fb72020-04-20 21:24:47 -050052 Indicates the SOC package used.
53 More details in include/dt-bindings/pinctrl/stm32-pinfunc.h
Rob Herring3d21a462020-04-15 19:55:49 -050054 $ref: /schemas/types.yaml#/definitions/uint32
55 enum: [1, 2, 4, 8]
Alexandre Torgue2c9239c2019-05-10 17:45:26 +020056
57patternProperties:
58 '^gpio@[0-9a-f]*$':
Rob Herring15ffef12019-07-03 14:17:06 -060059 type: object
Alexandre Torgue2c9239c2019-05-10 17:45:26 +020060 properties:
61 gpio-controller: true
62 '#gpio-cells':
63 const: 2
64
65 reg:
66 maxItems: 1
67 clocks:
68 maxItems: 1
69 reset:
70 minItems: 1
71 maxItems: 1
72 gpio-ranges:
73 minItems: 1
74 maxItems: 16
75 ngpios:
76 description:
77 Number of available gpios in a bank.
78 minimum: 1
79 maximum: 16
80
81 st,bank-name:
Alexandre Torgue2c9239c2019-05-10 17:45:26 +020082 description:
83 Should be a name string for this bank as specified in the datasheet.
Rob Herring3d21a462020-04-15 19:55:49 -050084 $ref: "/schemas/types.yaml#/definitions/string"
85 enum:
86 - GPIOA
87 - GPIOB
88 - GPIOC
89 - GPIOD
90 - GPIOE
91 - GPIOF
92 - GPIOG
93 - GPIOH
94 - GPIOI
95 - GPIOJ
96 - GPIOK
97 - GPIOZ
Alexandre Torgue2c9239c2019-05-10 17:45:26 +020098
99 st,bank-ioport:
Alexandre Torgue2c9239c2019-05-10 17:45:26 +0200100 description:
101 Should correspond to the EXTI IOport selection (EXTI line used
102 to select GPIOs as interrupts).
Rob Herring3d21a462020-04-15 19:55:49 -0500103 $ref: "/schemas/types.yaml#/definitions/uint32"
104 minimum: 0
105 maximum: 11
Alexandre Torgue2c9239c2019-05-10 17:45:26 +0200106
107 required:
108 - gpio-controller
109 - '#gpio-cells'
110 - reg
111 - clocks
112 - st,bank-name
113
114 '-[0-9]*$':
Rob Herring15ffef12019-07-03 14:17:06 -0600115 type: object
Alexandre Torgue2c9239c2019-05-10 17:45:26 +0200116 patternProperties:
117 '^pins':
Rob Herring15ffef12019-07-03 14:17:06 -0600118 type: object
Alexandre Torgue2c9239c2019-05-10 17:45:26 +0200119 description: |
120 A pinctrl node should contain at least one subnode representing the
121 pinctrl group available on the machine. Each subnode will list the
122 pins it needs, and how they should be configured, with regard to muxer
123 configuration, pullups, drive, output high/low and output speed.
124 properties:
125 pinmux:
Rob Herring3d21a462020-04-15 19:55:49 -0500126 $ref: "/schemas/types.yaml#/definitions/uint32-array"
Alexandre Torgue2c9239c2019-05-10 17:45:26 +0200127 description: |
128 Integer array, represents gpio pin number and mux setting.
129 Supported pin number and mux varies for different SoCs, and are
130 defined in dt-bindings/pinctrl/<soc>-pinfunc.h directly.
131 These defines are calculated as: ((port * 16 + line) << 8) | function
132 With:
133 - port: The gpio port index (PA = 0, PB = 1, ..., PK = 11)
134 - line: The line offset within the port (PA0 = 0, PA1 = 1, ..., PA15 = 15)
135 - function: The function number, can be:
136 * 0 : GPIO
137 * 1 : Alternate Function 0
138 * 2 : Alternate Function 1
139 * 3 : Alternate Function 2
140 * ...
141 * 16 : Alternate Function 15
142 * 17 : Analog
143 To simplify the usage, macro is available to generate "pinmux" field.
144 This macro is available here:
145 - include/dt-bindings/pinctrl/stm32-pinfunc.h
146 Some examples of using macro:
147 /* GPIO A9 set as alernate function 2 */
148 ... {
149 pinmux = <STM32_PINMUX('A', 9, AF2)>;
150 };
151 /* GPIO A9 set as GPIO */
152 ... {
153 pinmux = <STM32_PINMUX('A', 9, GPIO)>;
154 };
155 /* GPIO A9 set as analog */
156 ... {
157 pinmux = <STM32_PINMUX('A', 9, ANALOG)>;
158 };
159
160 bias-disable:
161 type: boolean
162 bias-pull-down:
163 type: boolean
164 bias-pull-up:
165 type: boolean
166 drive-push-pull:
167 type: boolean
168 drive-open-drain:
169 type: boolean
170 output-low:
171 type: boolean
172 output-high:
173 type: boolean
174 slew-rate:
175 description: |
176 0: Low speed
177 1: Medium speed
178 2: Fast speed
179 3: High speed
Rob Herring3d21a462020-04-15 19:55:49 -0500180 $ref: /schemas/types.yaml#/definitions/uint32
181 enum: [0, 1, 2, 3]
Alexandre Torgue2c9239c2019-05-10 17:45:26 +0200182
183 required:
184 - pinmux
185
Rafał Miłeckic09acbc2021-12-02 07:32:16 +0100186allOf:
187 - $ref: "pinctrl.yaml#"
188
Alexandre Torgue2c9239c2019-05-10 17:45:26 +0200189required:
190 - compatible
191 - '#address-cells'
192 - '#size-cells'
193 - ranges
194 - pins-are-numbered
195
Rob Herring7f464532020-03-25 16:05:41 -0600196additionalProperties: false
197
Alexandre Torgue2c9239c2019-05-10 17:45:26 +0200198examples:
199 - |
200 #include <dt-bindings/pinctrl/stm32-pinfunc.h>
Rob Herringe2297f72019-07-16 15:34:40 -0600201 #include <dt-bindings/mfd/stm32f4-rcc.h>
Alexandre Torgue2c9239c2019-05-10 17:45:26 +0200202 //Example 1
203 pinctrl@40020000 {
204 #address-cells = <1>;
205 #size-cells = <1>;
206 compatible = "st,stm32f429-pinctrl";
207 ranges = <0 0x40020000 0x3000>;
208 pins-are-numbered;
209
210 gpioa: gpio@0 {
211 gpio-controller;
212 #gpio-cells = <2>;
213 reg = <0x0 0x400>;
214 resets = <&reset_ahb1 0>;
Rob Herringe2297f72019-07-16 15:34:40 -0600215 clocks = <&rcc 0 STM32F4_AHB1_CLOCK(GPIOA)>;
Alexandre Torgue2c9239c2019-05-10 17:45:26 +0200216 st,bank-name = "GPIOA";
217 };
218 };
219
220 //Example 2 (using gpio-ranges)
221 pinctrl@50020000 {
222 #address-cells = <1>;
223 #size-cells = <1>;
224 compatible = "st,stm32f429-pinctrl";
225 ranges = <0 0x50020000 0x3000>;
226 pins-are-numbered;
227
228 gpiob: gpio@1000 {
229 gpio-controller;
230 #gpio-cells = <2>;
231 reg = <0x1000 0x400>;
232 resets = <&reset_ahb1 0>;
Rob Herringe2297f72019-07-16 15:34:40 -0600233 clocks = <&rcc 0 STM32F4_AHB1_CLOCK(GPIOB)>;
Alexandre Torgue2c9239c2019-05-10 17:45:26 +0200234 st,bank-name = "GPIOB";
235 gpio-ranges = <&pinctrl 0 0 16>;
236 };
237
238 gpioc: gpio@2000 {
239 gpio-controller;
240 #gpio-cells = <2>;
241 reg = <0x2000 0x400>;
242 resets = <&reset_ahb1 0>;
Rob Herringe2297f72019-07-16 15:34:40 -0600243 clocks = <&rcc 0 STM32F4_AHB1_CLOCK(GPIOC)>;
Alexandre Torgue2c9239c2019-05-10 17:45:26 +0200244 st,bank-name = "GPIOC";
245 ngpios = <5>;
246 gpio-ranges = <&pinctrl 0 16 3>,
247 <&pinctrl 14 30 2>;
248 };
249 };
250
251 //Example 3 pin groups
Rob Herring51a21e02020-02-21 16:27:10 -0600252 pinctrl {
Alexandre Torgue2c9239c2019-05-10 17:45:26 +0200253 usart1_pins_a: usart1-0 {
254 pins1 {
255 pinmux = <STM32_PINMUX('A', 9, AF7)>;
256 bias-disable;
257 drive-push-pull;
258 slew-rate = <0>;
259 };
260 pins2 {
261 pinmux = <STM32_PINMUX('A', 10, AF7)>;
262 bias-disable;
263 };
264 };
265 };
266
267 usart1 {
268 pinctrl-0 = <&usart1_pins_a>;
269 pinctrl-names = "default";
270 };
271
272...