1c66ec88fSEmmanuel Vadot# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2c66ec88fSEmmanuel Vadot# Copyright (C) STMicroelectronics 2019. 3c66ec88fSEmmanuel Vadot%YAML 1.2 4c66ec88fSEmmanuel Vadot--- 5c66ec88fSEmmanuel Vadot$id: http://devicetree.org/schemas/pinctrl/st,stm32-pinctrl.yaml# 6c66ec88fSEmmanuel Vadot$schema: http://devicetree.org/meta-schemas/core.yaml# 7c66ec88fSEmmanuel Vadot 8c66ec88fSEmmanuel Vadottitle: STM32 GPIO and Pin Mux/Config controller 9c66ec88fSEmmanuel Vadot 10c66ec88fSEmmanuel Vadotmaintainers: 118cc087a1SEmmanuel Vadot - Alexandre TORGUE <alexandre.torgue@foss.st.com> 12c66ec88fSEmmanuel Vadot 13c66ec88fSEmmanuel Vadotdescription: | 14c66ec88fSEmmanuel Vadot STMicroelectronics's STM32 MCUs intregrate a GPIO and Pin mux/config hardware 15c66ec88fSEmmanuel Vadot controller. It controls the input/output settings on the available pins and 16c66ec88fSEmmanuel Vadot also provides ability to multiplex and configure the output of various 17c66ec88fSEmmanuel Vadot on-chip controllers onto these pads. 18c66ec88fSEmmanuel Vadot 19c66ec88fSEmmanuel Vadotproperties: 20c66ec88fSEmmanuel Vadot compatible: 21c66ec88fSEmmanuel Vadot enum: 22c66ec88fSEmmanuel Vadot - st,stm32f429-pinctrl 23c66ec88fSEmmanuel Vadot - st,stm32f469-pinctrl 24c66ec88fSEmmanuel Vadot - st,stm32f746-pinctrl 25c66ec88fSEmmanuel Vadot - st,stm32f769-pinctrl 26c66ec88fSEmmanuel Vadot - st,stm32h743-pinctrl 27354d7675SEmmanuel Vadot - st,stm32mp135-pinctrl 28c66ec88fSEmmanuel Vadot - st,stm32mp157-pinctrl 29c66ec88fSEmmanuel Vadot - st,stm32mp157-z-pinctrl 30f126890aSEmmanuel Vadot - st,stm32mp257-pinctrl 31f126890aSEmmanuel Vadot - st,stm32mp257-z-pinctrl 32c66ec88fSEmmanuel Vadot 33c66ec88fSEmmanuel Vadot '#address-cells': 34c66ec88fSEmmanuel Vadot const: 1 35c66ec88fSEmmanuel Vadot '#size-cells': 36c66ec88fSEmmanuel Vadot const: 1 37c66ec88fSEmmanuel Vadot 38c66ec88fSEmmanuel Vadot ranges: true 398bab661aSEmmanuel Vadot pins-are-numbered: 408bab661aSEmmanuel Vadot $ref: /schemas/types.yaml#/definitions/flag 418bab661aSEmmanuel Vadot deprecated: true 42c66ec88fSEmmanuel Vadot hwlocks: true 43c66ec88fSEmmanuel Vadot 44c66ec88fSEmmanuel Vadot interrupts: 45c66ec88fSEmmanuel Vadot maxItems: 1 46c66ec88fSEmmanuel Vadot 47c66ec88fSEmmanuel Vadot st,syscfg: 48c9ccf3a3SEmmanuel Vadot description: Phandle+args to the syscon node which includes IRQ mux selection. 49fac71e4eSEmmanuel Vadot $ref: /schemas/types.yaml#/definitions/phandle-array 50c9ccf3a3SEmmanuel Vadot items: 51*84943d6fSEmmanuel Vadot - minItems: 2 52*84943d6fSEmmanuel Vadot items: 53c9ccf3a3SEmmanuel Vadot - description: syscon node which includes IRQ mux selection 54c9ccf3a3SEmmanuel Vadot - description: The offset of the IRQ mux selection register 55c9ccf3a3SEmmanuel Vadot - description: The field mask of IRQ mux, needed if different of 0xf 56c66ec88fSEmmanuel Vadot 57c66ec88fSEmmanuel Vadot st,package: 58c66ec88fSEmmanuel Vadot description: 59c66ec88fSEmmanuel Vadot Indicates the SOC package used. 60c66ec88fSEmmanuel Vadot More details in include/dt-bindings/pinctrl/stm32-pinfunc.h 61c66ec88fSEmmanuel Vadot $ref: /schemas/types.yaml#/definitions/uint32 62f126890aSEmmanuel Vadot enum: [0x1, 0x2, 0x4, 0x8, 0x100, 0x400, 0x800] 63c66ec88fSEmmanuel Vadot 64c66ec88fSEmmanuel VadotpatternProperties: 65c66ec88fSEmmanuel Vadot '^gpio@[0-9a-f]*$': 66c66ec88fSEmmanuel Vadot type: object 67b97ee269SEmmanuel Vadot additionalProperties: false 68c66ec88fSEmmanuel Vadot properties: 69c66ec88fSEmmanuel Vadot gpio-controller: true 70c66ec88fSEmmanuel Vadot '#gpio-cells': 71c66ec88fSEmmanuel Vadot const: 2 727ef62cebSEmmanuel Vadot interrupt-controller: true 737ef62cebSEmmanuel Vadot '#interrupt-cells': 747ef62cebSEmmanuel Vadot const: 2 75c66ec88fSEmmanuel Vadot 76c66ec88fSEmmanuel Vadot reg: 77c66ec88fSEmmanuel Vadot maxItems: 1 78c66ec88fSEmmanuel Vadot clocks: 79c66ec88fSEmmanuel Vadot maxItems: 1 80b97ee269SEmmanuel Vadot resets: 81c66ec88fSEmmanuel Vadot maxItems: 1 827ef62cebSEmmanuel Vadot gpio-line-names: true 83c66ec88fSEmmanuel Vadot gpio-ranges: 84c66ec88fSEmmanuel Vadot minItems: 1 85c66ec88fSEmmanuel Vadot maxItems: 16 86c66ec88fSEmmanuel Vadot ngpios: 87c66ec88fSEmmanuel Vadot description: 88c66ec88fSEmmanuel Vadot Number of available gpios in a bank. 89c66ec88fSEmmanuel Vadot minimum: 1 90c66ec88fSEmmanuel Vadot maximum: 16 91c66ec88fSEmmanuel Vadot 92c66ec88fSEmmanuel Vadot st,bank-name: 93c66ec88fSEmmanuel Vadot description: 94c66ec88fSEmmanuel Vadot Should be a name string for this bank as specified in the datasheet. 95fac71e4eSEmmanuel Vadot $ref: /schemas/types.yaml#/definitions/string 96c66ec88fSEmmanuel Vadot enum: 97c66ec88fSEmmanuel Vadot - GPIOA 98c66ec88fSEmmanuel Vadot - GPIOB 99c66ec88fSEmmanuel Vadot - GPIOC 100c66ec88fSEmmanuel Vadot - GPIOD 101c66ec88fSEmmanuel Vadot - GPIOE 102c66ec88fSEmmanuel Vadot - GPIOF 103c66ec88fSEmmanuel Vadot - GPIOG 104c66ec88fSEmmanuel Vadot - GPIOH 105c66ec88fSEmmanuel Vadot - GPIOI 106c66ec88fSEmmanuel Vadot - GPIOJ 107c66ec88fSEmmanuel Vadot - GPIOK 108c66ec88fSEmmanuel Vadot - GPIOZ 109c66ec88fSEmmanuel Vadot 110c66ec88fSEmmanuel Vadot st,bank-ioport: 111c66ec88fSEmmanuel Vadot description: 112c66ec88fSEmmanuel Vadot Should correspond to the EXTI IOport selection (EXTI line used 113c66ec88fSEmmanuel Vadot to select GPIOs as interrupts). 114fac71e4eSEmmanuel Vadot $ref: /schemas/types.yaml#/definitions/uint32 115c66ec88fSEmmanuel Vadot minimum: 0 116c66ec88fSEmmanuel Vadot maximum: 11 117c66ec88fSEmmanuel Vadot 1187ef62cebSEmmanuel Vadot patternProperties: 1197ef62cebSEmmanuel Vadot "^(.+-hog(-[0-9]+)?)$": 1207ef62cebSEmmanuel Vadot type: object 1217ef62cebSEmmanuel Vadot required: 1227ef62cebSEmmanuel Vadot - gpio-hog 1237ef62cebSEmmanuel Vadot 124c66ec88fSEmmanuel Vadot required: 125c66ec88fSEmmanuel Vadot - gpio-controller 126c66ec88fSEmmanuel Vadot - '#gpio-cells' 127c66ec88fSEmmanuel Vadot - reg 128c66ec88fSEmmanuel Vadot - clocks 129c66ec88fSEmmanuel Vadot - st,bank-name 130c66ec88fSEmmanuel Vadot 131c66ec88fSEmmanuel Vadot '-[0-9]*$': 132c66ec88fSEmmanuel Vadot type: object 1337ef62cebSEmmanuel Vadot additionalProperties: false 1347ef62cebSEmmanuel Vadot 135c66ec88fSEmmanuel Vadot patternProperties: 136c66ec88fSEmmanuel Vadot '^pins': 137c66ec88fSEmmanuel Vadot type: object 1387ef62cebSEmmanuel Vadot additionalProperties: false 139c66ec88fSEmmanuel Vadot description: | 140c66ec88fSEmmanuel Vadot A pinctrl node should contain at least one subnode representing the 141c66ec88fSEmmanuel Vadot pinctrl group available on the machine. Each subnode will list the 142c66ec88fSEmmanuel Vadot pins it needs, and how they should be configured, with regard to muxer 143c66ec88fSEmmanuel Vadot configuration, pullups, drive, output high/low and output speed. 144c66ec88fSEmmanuel Vadot properties: 145c66ec88fSEmmanuel Vadot pinmux: 146fac71e4eSEmmanuel Vadot $ref: /schemas/types.yaml#/definitions/uint32-array 147c66ec88fSEmmanuel Vadot description: | 148c66ec88fSEmmanuel Vadot Integer array, represents gpio pin number and mux setting. 149c66ec88fSEmmanuel Vadot Supported pin number and mux varies for different SoCs, and are 150c66ec88fSEmmanuel Vadot defined in dt-bindings/pinctrl/<soc>-pinfunc.h directly. 151c66ec88fSEmmanuel Vadot These defines are calculated as: ((port * 16 + line) << 8) | function 152c66ec88fSEmmanuel Vadot With: 153c66ec88fSEmmanuel Vadot - port: The gpio port index (PA = 0, PB = 1, ..., PK = 11) 154c66ec88fSEmmanuel Vadot - line: The line offset within the port (PA0 = 0, PA1 = 1, ..., PA15 = 15) 155c66ec88fSEmmanuel Vadot - function: The function number, can be: 156c66ec88fSEmmanuel Vadot * 0 : GPIO 157c66ec88fSEmmanuel Vadot * 1 : Alternate Function 0 158c66ec88fSEmmanuel Vadot * 2 : Alternate Function 1 159c66ec88fSEmmanuel Vadot * 3 : Alternate Function 2 160c66ec88fSEmmanuel Vadot * ... 161c66ec88fSEmmanuel Vadot * 16 : Alternate Function 15 162c66ec88fSEmmanuel Vadot * 17 : Analog 163c66ec88fSEmmanuel Vadot To simplify the usage, macro is available to generate "pinmux" field. 164c66ec88fSEmmanuel Vadot This macro is available here: 165c66ec88fSEmmanuel Vadot - include/dt-bindings/pinctrl/stm32-pinfunc.h 166c66ec88fSEmmanuel Vadot Some examples of using macro: 167c66ec88fSEmmanuel Vadot /* GPIO A9 set as alernate function 2 */ 168c66ec88fSEmmanuel Vadot ... { 169c66ec88fSEmmanuel Vadot pinmux = <STM32_PINMUX('A', 9, AF2)>; 170c66ec88fSEmmanuel Vadot }; 171c66ec88fSEmmanuel Vadot /* GPIO A9 set as GPIO */ 172c66ec88fSEmmanuel Vadot ... { 173c66ec88fSEmmanuel Vadot pinmux = <STM32_PINMUX('A', 9, GPIO)>; 174c66ec88fSEmmanuel Vadot }; 175c66ec88fSEmmanuel Vadot /* GPIO A9 set as analog */ 176c66ec88fSEmmanuel Vadot ... { 177c66ec88fSEmmanuel Vadot pinmux = <STM32_PINMUX('A', 9, ANALOG)>; 178c66ec88fSEmmanuel Vadot }; 179c66ec88fSEmmanuel Vadot 180c66ec88fSEmmanuel Vadot bias-disable: 181c66ec88fSEmmanuel Vadot type: boolean 182c66ec88fSEmmanuel Vadot bias-pull-down: 183c66ec88fSEmmanuel Vadot type: boolean 184c66ec88fSEmmanuel Vadot bias-pull-up: 185c66ec88fSEmmanuel Vadot type: boolean 186c66ec88fSEmmanuel Vadot drive-push-pull: 187c66ec88fSEmmanuel Vadot type: boolean 188c66ec88fSEmmanuel Vadot drive-open-drain: 189c66ec88fSEmmanuel Vadot type: boolean 190c66ec88fSEmmanuel Vadot output-low: 191c66ec88fSEmmanuel Vadot type: boolean 192c66ec88fSEmmanuel Vadot output-high: 193c66ec88fSEmmanuel Vadot type: boolean 194c66ec88fSEmmanuel Vadot slew-rate: 195c66ec88fSEmmanuel Vadot description: | 196c66ec88fSEmmanuel Vadot 0: Low speed 197c66ec88fSEmmanuel Vadot 1: Medium speed 198c66ec88fSEmmanuel Vadot 2: Fast speed 199c66ec88fSEmmanuel Vadot 3: High speed 200c66ec88fSEmmanuel Vadot $ref: /schemas/types.yaml#/definitions/uint32 201c66ec88fSEmmanuel Vadot enum: [0, 1, 2, 3] 202c66ec88fSEmmanuel Vadot 203c66ec88fSEmmanuel Vadot required: 204c66ec88fSEmmanuel Vadot - pinmux 205c66ec88fSEmmanuel Vadot 206e67e8565SEmmanuel VadotallOf: 207fac71e4eSEmmanuel Vadot - $ref: pinctrl.yaml# 208e67e8565SEmmanuel Vadot 209c66ec88fSEmmanuel Vadotrequired: 210c66ec88fSEmmanuel Vadot - compatible 211c66ec88fSEmmanuel Vadot - '#address-cells' 212c66ec88fSEmmanuel Vadot - '#size-cells' 213c66ec88fSEmmanuel Vadot - ranges 214c66ec88fSEmmanuel Vadot 215c66ec88fSEmmanuel VadotadditionalProperties: false 216c66ec88fSEmmanuel Vadot 217c66ec88fSEmmanuel Vadotexamples: 218c66ec88fSEmmanuel Vadot - | 219c66ec88fSEmmanuel Vadot #include <dt-bindings/pinctrl/stm32-pinfunc.h> 220c66ec88fSEmmanuel Vadot #include <dt-bindings/mfd/stm32f4-rcc.h> 221c66ec88fSEmmanuel Vadot //Example 1 222c66ec88fSEmmanuel Vadot pinctrl@40020000 { 223c66ec88fSEmmanuel Vadot #address-cells = <1>; 224c66ec88fSEmmanuel Vadot #size-cells = <1>; 225c66ec88fSEmmanuel Vadot compatible = "st,stm32f429-pinctrl"; 226c66ec88fSEmmanuel Vadot ranges = <0 0x40020000 0x3000>; 227c66ec88fSEmmanuel Vadot 228c66ec88fSEmmanuel Vadot gpioa: gpio@0 { 229c66ec88fSEmmanuel Vadot gpio-controller; 230c66ec88fSEmmanuel Vadot #gpio-cells = <2>; 231c66ec88fSEmmanuel Vadot reg = <0x0 0x400>; 232c66ec88fSEmmanuel Vadot resets = <&reset_ahb1 0>; 233c66ec88fSEmmanuel Vadot clocks = <&rcc 0 STM32F4_AHB1_CLOCK(GPIOA)>; 234c66ec88fSEmmanuel Vadot st,bank-name = "GPIOA"; 235c66ec88fSEmmanuel Vadot }; 236c66ec88fSEmmanuel Vadot }; 237c66ec88fSEmmanuel Vadot 238c66ec88fSEmmanuel Vadot //Example 2 (using gpio-ranges) 239c66ec88fSEmmanuel Vadot pinctrl@50020000 { 240c66ec88fSEmmanuel Vadot #address-cells = <1>; 241c66ec88fSEmmanuel Vadot #size-cells = <1>; 242c66ec88fSEmmanuel Vadot compatible = "st,stm32f429-pinctrl"; 243c66ec88fSEmmanuel Vadot ranges = <0 0x50020000 0x3000>; 244c66ec88fSEmmanuel Vadot 245c66ec88fSEmmanuel Vadot gpiob: gpio@1000 { 246c66ec88fSEmmanuel Vadot gpio-controller; 247c66ec88fSEmmanuel Vadot #gpio-cells = <2>; 248c66ec88fSEmmanuel Vadot reg = <0x1000 0x400>; 249c66ec88fSEmmanuel Vadot resets = <&reset_ahb1 0>; 250c66ec88fSEmmanuel Vadot clocks = <&rcc 0 STM32F4_AHB1_CLOCK(GPIOB)>; 251c66ec88fSEmmanuel Vadot st,bank-name = "GPIOB"; 252c66ec88fSEmmanuel Vadot gpio-ranges = <&pinctrl 0 0 16>; 253c66ec88fSEmmanuel Vadot }; 254c66ec88fSEmmanuel Vadot 255c66ec88fSEmmanuel Vadot gpioc: gpio@2000 { 256c66ec88fSEmmanuel Vadot gpio-controller; 257c66ec88fSEmmanuel Vadot #gpio-cells = <2>; 258c66ec88fSEmmanuel Vadot reg = <0x2000 0x400>; 259c66ec88fSEmmanuel Vadot resets = <&reset_ahb1 0>; 260c66ec88fSEmmanuel Vadot clocks = <&rcc 0 STM32F4_AHB1_CLOCK(GPIOC)>; 261c66ec88fSEmmanuel Vadot st,bank-name = "GPIOC"; 262c66ec88fSEmmanuel Vadot ngpios = <5>; 263c66ec88fSEmmanuel Vadot gpio-ranges = <&pinctrl 0 16 3>, 264c66ec88fSEmmanuel Vadot <&pinctrl 14 30 2>; 265c66ec88fSEmmanuel Vadot }; 266c66ec88fSEmmanuel Vadot }; 267c66ec88fSEmmanuel Vadot 268c66ec88fSEmmanuel Vadot //Example 3 pin groups 269c66ec88fSEmmanuel Vadot pinctrl { 270c66ec88fSEmmanuel Vadot usart1_pins_a: usart1-0 { 271c66ec88fSEmmanuel Vadot pins1 { 272c66ec88fSEmmanuel Vadot pinmux = <STM32_PINMUX('A', 9, AF7)>; 273c66ec88fSEmmanuel Vadot bias-disable; 274c66ec88fSEmmanuel Vadot drive-push-pull; 275c66ec88fSEmmanuel Vadot slew-rate = <0>; 276c66ec88fSEmmanuel Vadot }; 277c66ec88fSEmmanuel Vadot pins2 { 278c66ec88fSEmmanuel Vadot pinmux = <STM32_PINMUX('A', 10, AF7)>; 279c66ec88fSEmmanuel Vadot bias-disable; 280c66ec88fSEmmanuel Vadot }; 281c66ec88fSEmmanuel Vadot }; 282c66ec88fSEmmanuel Vadot }; 283c66ec88fSEmmanuel Vadot 284c66ec88fSEmmanuel Vadot usart1 { 285c66ec88fSEmmanuel Vadot pinctrl-0 = <&usart1_pins_a>; 286c66ec88fSEmmanuel Vadot pinctrl-names = "default"; 287c66ec88fSEmmanuel Vadot }; 288c66ec88fSEmmanuel Vadot 289c66ec88fSEmmanuel Vadot... 290