Alexandre Torgue | 2c9239c | 2019-05-10 17:45:26 +0200 | [diff] [blame] | 1 | # 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 | |
| 8 | title: STM32 GPIO and Pin Mux/Config controller |
| 9 | |
| 10 | maintainers: |
Patrice Chotard | f4eedeb | 2021-11-10 16:01:44 +0100 | [diff] [blame] | 11 | - Alexandre TORGUE <alexandre.torgue@foss.st.com> |
Alexandre Torgue | 2c9239c | 2019-05-10 17:45:26 +0200 | [diff] [blame] | 12 | |
| 13 | description: | |
| 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 | |
| 19 | properties: |
| 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 Torgue | 510fc34 | 2021-07-23 15:28:04 +0200 | [diff] [blame] | 27 | - st,stm32mp135-pinctrl |
Alexandre Torgue | 2c9239c | 2019-05-10 17:45:26 +0200 | [diff] [blame] | 28 | - 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 Gaignard | a45c0ec2 | 2020-05-13 16:59:34 +0200 | [diff] [blame] | 40 | interrupts: |
| 41 | maxItems: 1 |
| 42 | |
Alexandre Torgue | 2c9239c | 2019-05-10 17:45:26 +0200 | [diff] [blame] | 43 | st,syscfg: |
Alexandre Torgue | 2c9239c | 2019-05-10 17:45:26 +0200 | [diff] [blame] | 44 | description: Should be phandle/offset/mask |
Alexandre Torgue | 4b6fffe | 2019-10-07 15:44:09 +0200 | [diff] [blame] | 45 | - 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 Herring | 3d21a46 | 2020-04-15 19:55:49 -0500 | [diff] [blame] | 48 | $ref: "/schemas/types.yaml#/definitions/phandle-array" |
Alexandre Torgue | 2c9239c | 2019-05-10 17:45:26 +0200 | [diff] [blame] | 49 | |
| 50 | st,package: |
Alexandre Torgue | 2c9239c | 2019-05-10 17:45:26 +0200 | [diff] [blame] | 51 | description: |
Rob Herring | f516fb7 | 2020-04-20 21:24:47 -0500 | [diff] [blame] | 52 | Indicates the SOC package used. |
| 53 | More details in include/dt-bindings/pinctrl/stm32-pinfunc.h |
Rob Herring | 3d21a46 | 2020-04-15 19:55:49 -0500 | [diff] [blame] | 54 | $ref: /schemas/types.yaml#/definitions/uint32 |
| 55 | enum: [1, 2, 4, 8] |
Alexandre Torgue | 2c9239c | 2019-05-10 17:45:26 +0200 | [diff] [blame] | 56 | |
| 57 | patternProperties: |
| 58 | '^gpio@[0-9a-f]*$': |
Rob Herring | 15ffef1 | 2019-07-03 14:17:06 -0600 | [diff] [blame] | 59 | type: object |
Alexandre Torgue | 2c9239c | 2019-05-10 17:45:26 +0200 | [diff] [blame] | 60 | 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 Torgue | 2c9239c | 2019-05-10 17:45:26 +0200 | [diff] [blame] | 82 | description: |
| 83 | Should be a name string for this bank as specified in the datasheet. |
Rob Herring | 3d21a46 | 2020-04-15 19:55:49 -0500 | [diff] [blame] | 84 | $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 Torgue | 2c9239c | 2019-05-10 17:45:26 +0200 | [diff] [blame] | 98 | |
| 99 | st,bank-ioport: |
Alexandre Torgue | 2c9239c | 2019-05-10 17:45:26 +0200 | [diff] [blame] | 100 | description: |
| 101 | Should correspond to the EXTI IOport selection (EXTI line used |
| 102 | to select GPIOs as interrupts). |
Rob Herring | 3d21a46 | 2020-04-15 19:55:49 -0500 | [diff] [blame] | 103 | $ref: "/schemas/types.yaml#/definitions/uint32" |
| 104 | minimum: 0 |
| 105 | maximum: 11 |
Alexandre Torgue | 2c9239c | 2019-05-10 17:45:26 +0200 | [diff] [blame] | 106 | |
| 107 | required: |
| 108 | - gpio-controller |
| 109 | - '#gpio-cells' |
| 110 | - reg |
| 111 | - clocks |
| 112 | - st,bank-name |
| 113 | |
| 114 | '-[0-9]*$': |
Rob Herring | 15ffef1 | 2019-07-03 14:17:06 -0600 | [diff] [blame] | 115 | type: object |
Alexandre Torgue | 2c9239c | 2019-05-10 17:45:26 +0200 | [diff] [blame] | 116 | patternProperties: |
| 117 | '^pins': |
Rob Herring | 15ffef1 | 2019-07-03 14:17:06 -0600 | [diff] [blame] | 118 | type: object |
Alexandre Torgue | 2c9239c | 2019-05-10 17:45:26 +0200 | [diff] [blame] | 119 | 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 Herring | 3d21a46 | 2020-04-15 19:55:49 -0500 | [diff] [blame] | 126 | $ref: "/schemas/types.yaml#/definitions/uint32-array" |
Alexandre Torgue | 2c9239c | 2019-05-10 17:45:26 +0200 | [diff] [blame] | 127 | 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 Herring | 3d21a46 | 2020-04-15 19:55:49 -0500 | [diff] [blame] | 180 | $ref: /schemas/types.yaml#/definitions/uint32 |
| 181 | enum: [0, 1, 2, 3] |
Alexandre Torgue | 2c9239c | 2019-05-10 17:45:26 +0200 | [diff] [blame] | 182 | |
| 183 | required: |
| 184 | - pinmux |
| 185 | |
Rafał Miłecki | c09acbc | 2021-12-02 07:32:16 +0100 | [diff] [blame] | 186 | allOf: |
| 187 | - $ref: "pinctrl.yaml#" |
| 188 | |
Alexandre Torgue | 2c9239c | 2019-05-10 17:45:26 +0200 | [diff] [blame] | 189 | required: |
| 190 | - compatible |
| 191 | - '#address-cells' |
| 192 | - '#size-cells' |
| 193 | - ranges |
| 194 | - pins-are-numbered |
| 195 | |
Rob Herring | 7f46453 | 2020-03-25 16:05:41 -0600 | [diff] [blame] | 196 | additionalProperties: false |
| 197 | |
Alexandre Torgue | 2c9239c | 2019-05-10 17:45:26 +0200 | [diff] [blame] | 198 | examples: |
| 199 | - | |
| 200 | #include <dt-bindings/pinctrl/stm32-pinfunc.h> |
Rob Herring | e2297f7 | 2019-07-16 15:34:40 -0600 | [diff] [blame] | 201 | #include <dt-bindings/mfd/stm32f4-rcc.h> |
Alexandre Torgue | 2c9239c | 2019-05-10 17:45:26 +0200 | [diff] [blame] | 202 | //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 Herring | e2297f7 | 2019-07-16 15:34:40 -0600 | [diff] [blame] | 215 | clocks = <&rcc 0 STM32F4_AHB1_CLOCK(GPIOA)>; |
Alexandre Torgue | 2c9239c | 2019-05-10 17:45:26 +0200 | [diff] [blame] | 216 | 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 Herring | e2297f7 | 2019-07-16 15:34:40 -0600 | [diff] [blame] | 233 | clocks = <&rcc 0 STM32F4_AHB1_CLOCK(GPIOB)>; |
Alexandre Torgue | 2c9239c | 2019-05-10 17:45:26 +0200 | [diff] [blame] | 234 | 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 Herring | e2297f7 | 2019-07-16 15:34:40 -0600 | [diff] [blame] | 243 | clocks = <&rcc 0 STM32F4_AHB1_CLOCK(GPIOC)>; |
Alexandre Torgue | 2c9239c | 2019-05-10 17:45:26 +0200 | [diff] [blame] | 244 | 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 Herring | 51a21e0 | 2020-02-21 16:27:10 -0600 | [diff] [blame] | 252 | pinctrl { |
Alexandre Torgue | 2c9239c | 2019-05-10 17:45:26 +0200 | [diff] [blame] | 253 | 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 | ... |