12c9239c1SAlexandre Torgue# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 22c9239c1SAlexandre Torgue# Copyright (C) STMicroelectronics 2019. 32c9239c1SAlexandre Torgue%YAML 1.2 42c9239c1SAlexandre Torgue--- 52c9239c1SAlexandre Torgue$id: http://devicetree.org/schemas/pinctrl/st,stm32-pinctrl.yaml# 62c9239c1SAlexandre Torgue$schema: http://devicetree.org/meta-schemas/core.yaml# 72c9239c1SAlexandre Torgue 82c9239c1SAlexandre Torguetitle: STM32 GPIO and Pin Mux/Config controller 92c9239c1SAlexandre Torgue 102c9239c1SAlexandre Torguemaintainers: 11f4eedebdSPatrice Chotard - Alexandre TORGUE <alexandre.torgue@foss.st.com> 122c9239c1SAlexandre Torgue 132c9239c1SAlexandre Torguedescription: | 142c9239c1SAlexandre Torgue STMicroelectronics's STM32 MCUs intregrate a GPIO and Pin mux/config hardware 152c9239c1SAlexandre Torgue controller. It controls the input/output settings on the available pins and 162c9239c1SAlexandre Torgue also provides ability to multiplex and configure the output of various 172c9239c1SAlexandre Torgue on-chip controllers onto these pads. 182c9239c1SAlexandre Torgue 192c9239c1SAlexandre Torgueproperties: 202c9239c1SAlexandre Torgue compatible: 212c9239c1SAlexandre Torgue enum: 222c9239c1SAlexandre Torgue - st,stm32f429-pinctrl 232c9239c1SAlexandre Torgue - st,stm32f469-pinctrl 242c9239c1SAlexandre Torgue - st,stm32f746-pinctrl 252c9239c1SAlexandre Torgue - st,stm32f769-pinctrl 262c9239c1SAlexandre Torgue - st,stm32h743-pinctrl 27510fc348SAlexandre Torgue - st,stm32mp135-pinctrl 282c9239c1SAlexandre Torgue - st,stm32mp157-pinctrl 292c9239c1SAlexandre Torgue - st,stm32mp157-z-pinctrl 302c9239c1SAlexandre Torgue - st,stm32mp257-pinctrl 312c9239c1SAlexandre Torgue - st,stm32mp257-z-pinctrl 322c9239c1SAlexandre Torgue 332c9239c1SAlexandre Torgue '#address-cells': 342c9239c1SAlexandre Torgue const: 1 352c9239c1SAlexandre Torgue '#size-cells': 362c9239c1SAlexandre Torgue const: 1 3780b99ed7SBernhard Rosenkränzer 3880b99ed7SBernhard Rosenkränzer ranges: true 3980b99ed7SBernhard Rosenkränzer pins-are-numbered: 402c9239c1SAlexandre Torgue $ref: /schemas/types.yaml#/definitions/flag 412c9239c1SAlexandre Torgue deprecated: true 42a45c0ec2SBenjamin Gaignard hwlocks: true 43a45c0ec2SBenjamin Gaignard 44a45c0ec2SBenjamin Gaignard interrupts: 452c9239c1SAlexandre Torgue maxItems: 1 4639bd2b6aSRob Herring 47*49cd1dd1SRob Herring st,syscfg: 4839bd2b6aSRob Herring description: Phandle+args to the syscon node which includes IRQ mux selection. 4939bd2b6aSRob Herring $ref: /schemas/types.yaml#/definitions/phandle-array 5039bd2b6aSRob Herring items: 5139bd2b6aSRob Herring - items: 5239bd2b6aSRob Herring - description: syscon node which includes IRQ mux selection 532c9239c1SAlexandre Torgue - description: The offset of the IRQ mux selection register 542c9239c1SAlexandre Torgue - description: The field mask of IRQ mux, needed if different of 0xf 552c9239c1SAlexandre Torgue 562c9239c1SAlexandre Torgue st,package: 572c9239c1SAlexandre Torgue description: 583d21a460SRob Herring Indicates the SOC package used. 593d21a460SRob Herring More details in include/dt-bindings/pinctrl/stm32-pinfunc.h 602c9239c1SAlexandre Torgue $ref: /schemas/types.yaml#/definitions/uint32 612c9239c1SAlexandre Torgue enum: [0x1, 0x2, 0x4, 0x8, 0x100, 0x400, 0x800] 622c9239c1SAlexandre Torgue 6315ffef1aSRob HerringpatternProperties: 64e79368b1SRob Herring '^gpio@[0-9a-f]*$': 652c9239c1SAlexandre Torgue type: object 662c9239c1SAlexandre Torgue additionalProperties: false 672c9239c1SAlexandre Torgue properties: 682c9239c1SAlexandre Torgue gpio-controller: true 695197b707SMarek Vasut '#gpio-cells': 705197b707SMarek Vasut const: 2 715197b707SMarek Vasut interrupt-controller: true 722c9239c1SAlexandre Torgue '#interrupt-cells': 732c9239c1SAlexandre Torgue const: 2 742c9239c1SAlexandre Torgue 752c9239c1SAlexandre Torgue reg: 762c9239c1SAlexandre Torgue maxItems: 1 77e79368b1SRob Herring clocks: 782c9239c1SAlexandre Torgue maxItems: 1 7944892170SMarek Vasut resets: 802c9239c1SAlexandre Torgue maxItems: 1 812c9239c1SAlexandre Torgue gpio-line-names: true 822c9239c1SAlexandre Torgue gpio-ranges: 832c9239c1SAlexandre Torgue minItems: 1 842c9239c1SAlexandre Torgue maxItems: 16 852c9239c1SAlexandre Torgue ngpios: 862c9239c1SAlexandre Torgue description: 872c9239c1SAlexandre Torgue Number of available gpios in a bank. 882c9239c1SAlexandre Torgue minimum: 1 892c9239c1SAlexandre Torgue maximum: 16 903d21a460SRob Herring 913d21a460SRob Herring st,bank-name: 92*49cd1dd1SRob Herring description: 933d21a460SRob Herring Should be a name string for this bank as specified in the datasheet. 942c9239c1SAlexandre Torgue $ref: /schemas/types.yaml#/definitions/string 952c9239c1SAlexandre Torgue enum: 962c9239c1SAlexandre Torgue - GPIOA 972c9239c1SAlexandre Torgue - GPIOB 982c9239c1SAlexandre Torgue - GPIOC 992c9239c1SAlexandre Torgue - GPIOD 1002c9239c1SAlexandre Torgue - GPIOE 1012c9239c1SAlexandre Torgue - GPIOF 1022c9239c1SAlexandre Torgue - GPIOG 1032c9239c1SAlexandre Torgue - GPIOH 1042c9239c1SAlexandre Torgue - GPIOI 1052c9239c1SAlexandre Torgue - GPIOJ 1062c9239c1SAlexandre Torgue - GPIOK 1072c9239c1SAlexandre Torgue - GPIOZ 1082c9239c1SAlexandre Torgue 1092c9239c1SAlexandre Torgue st,bank-ioport: 1102c9239c1SAlexandre Torgue description: 111*49cd1dd1SRob Herring Should correspond to the EXTI IOport selection (EXTI line used 1123d21a460SRob Herring to select GPIOs as interrupts). 1133d21a460SRob Herring $ref: /schemas/types.yaml#/definitions/uint32 1142c9239c1SAlexandre Torgue minimum: 0 115140bb023SMarek Vasut maximum: 11 116140bb023SMarek Vasut 117140bb023SMarek Vasut patternProperties: 118140bb023SMarek Vasut "^(.+-hog(-[0-9]+)?)$": 119140bb023SMarek Vasut type: object 120140bb023SMarek Vasut required: 1212c9239c1SAlexandre Torgue - gpio-hog 1222c9239c1SAlexandre Torgue 1232c9239c1SAlexandre Torgue required: 1242c9239c1SAlexandre Torgue - gpio-controller 1252c9239c1SAlexandre Torgue - '#gpio-cells' 1262c9239c1SAlexandre Torgue - reg 1272c9239c1SAlexandre Torgue - clocks 1282c9239c1SAlexandre Torgue - st,bank-name 12915ffef1aSRob Herring 1309194e0f8SRob Herring '-[0-9]*$': 1319194e0f8SRob Herring type: object 1322c9239c1SAlexandre Torgue additionalProperties: false 1332c9239c1SAlexandre Torgue 13415ffef1aSRob Herring patternProperties: 1359194e0f8SRob Herring '^pins': 1362c9239c1SAlexandre Torgue type: object 1372c9239c1SAlexandre Torgue additionalProperties: false 1382c9239c1SAlexandre Torgue description: | 1392c9239c1SAlexandre Torgue A pinctrl node should contain at least one subnode representing the 1402c9239c1SAlexandre Torgue pinctrl group available on the machine. Each subnode will list the 1412c9239c1SAlexandre Torgue pins it needs, and how they should be configured, with regard to muxer 1422c9239c1SAlexandre Torgue configuration, pullups, drive, output high/low and output speed. 143*49cd1dd1SRob Herring properties: 1442c9239c1SAlexandre Torgue pinmux: 1452c9239c1SAlexandre Torgue $ref: /schemas/types.yaml#/definitions/uint32-array 1462c9239c1SAlexandre Torgue description: | 1472c9239c1SAlexandre Torgue Integer array, represents gpio pin number and mux setting. 1482c9239c1SAlexandre Torgue Supported pin number and mux varies for different SoCs, and are 1492c9239c1SAlexandre Torgue defined in dt-bindings/pinctrl/<soc>-pinfunc.h directly. 1502c9239c1SAlexandre Torgue These defines are calculated as: ((port * 16 + line) << 8) | function 1512c9239c1SAlexandre Torgue With: 1522c9239c1SAlexandre Torgue - port: The gpio port index (PA = 0, PB = 1, ..., PK = 11) 1532c9239c1SAlexandre Torgue - line: The line offset within the port (PA0 = 0, PA1 = 1, ..., PA15 = 15) 1542c9239c1SAlexandre Torgue - function: The function number, can be: 1552c9239c1SAlexandre Torgue * 0 : GPIO 1562c9239c1SAlexandre Torgue * 1 : Alternate Function 0 1572c9239c1SAlexandre Torgue * 2 : Alternate Function 1 1582c9239c1SAlexandre Torgue * 3 : Alternate Function 2 1592c9239c1SAlexandre Torgue * ... 1602c9239c1SAlexandre Torgue * 16 : Alternate Function 15 1612c9239c1SAlexandre Torgue * 17 : Analog 1622c9239c1SAlexandre Torgue To simplify the usage, macro is available to generate "pinmux" field. 1632c9239c1SAlexandre Torgue This macro is available here: 1642c9239c1SAlexandre Torgue - include/dt-bindings/pinctrl/stm32-pinfunc.h 1652c9239c1SAlexandre Torgue Some examples of using macro: 1662c9239c1SAlexandre Torgue /* GPIO A9 set as alernate function 2 */ 1672c9239c1SAlexandre Torgue ... { 1682c9239c1SAlexandre Torgue pinmux = <STM32_PINMUX('A', 9, AF2)>; 1692c9239c1SAlexandre Torgue }; 1702c9239c1SAlexandre Torgue /* GPIO A9 set as GPIO */ 1712c9239c1SAlexandre Torgue ... { 1722c9239c1SAlexandre Torgue pinmux = <STM32_PINMUX('A', 9, GPIO)>; 1732c9239c1SAlexandre Torgue }; 1742c9239c1SAlexandre Torgue /* GPIO A9 set as analog */ 1752c9239c1SAlexandre Torgue ... { 1762c9239c1SAlexandre Torgue pinmux = <STM32_PINMUX('A', 9, ANALOG)>; 1772c9239c1SAlexandre Torgue }; 1782c9239c1SAlexandre Torgue 1792c9239c1SAlexandre Torgue bias-disable: 1802c9239c1SAlexandre Torgue type: boolean 1812c9239c1SAlexandre Torgue bias-pull-down: 1822c9239c1SAlexandre Torgue type: boolean 1832c9239c1SAlexandre Torgue bias-pull-up: 1842c9239c1SAlexandre Torgue type: boolean 1852c9239c1SAlexandre Torgue drive-push-pull: 1862c9239c1SAlexandre Torgue type: boolean 1872c9239c1SAlexandre Torgue drive-open-drain: 1882c9239c1SAlexandre Torgue type: boolean 1892c9239c1SAlexandre Torgue output-low: 1902c9239c1SAlexandre Torgue type: boolean 1912c9239c1SAlexandre Torgue output-high: 1922c9239c1SAlexandre Torgue type: boolean 1932c9239c1SAlexandre Torgue slew-rate: 1942c9239c1SAlexandre Torgue description: | 1952c9239c1SAlexandre Torgue 0: Low speed 1962c9239c1SAlexandre Torgue 1: Medium speed 1973d21a460SRob Herring 2: Fast speed 1983d21a460SRob Herring 3: High speed 1992c9239c1SAlexandre Torgue $ref: /schemas/types.yaml#/definitions/uint32 2002c9239c1SAlexandre Torgue enum: [0, 1, 2, 3] 2012c9239c1SAlexandre Torgue 2022c9239c1SAlexandre Torgue required: 203c09acbc4SRafał Miłecki - pinmux 204*49cd1dd1SRob Herring 205c09acbc4SRafał MiłeckiallOf: 2062c9239c1SAlexandre Torgue - $ref: pinctrl.yaml# 2072c9239c1SAlexandre Torgue 2082c9239c1SAlexandre Torguerequired: 2092c9239c1SAlexandre Torgue - compatible 2102c9239c1SAlexandre Torgue - '#address-cells' 2112c9239c1SAlexandre Torgue - '#size-cells' 2127f464532SRob Herring - ranges 2137f464532SRob Herring 2142c9239c1SAlexandre TorgueadditionalProperties: false 2152c9239c1SAlexandre Torgue 2162c9239c1SAlexandre Torgueexamples: 217e2297f7cSRob Herring - | 2182c9239c1SAlexandre Torgue #include <dt-bindings/pinctrl/stm32-pinfunc.h> 2192c9239c1SAlexandre Torgue #include <dt-bindings/mfd/stm32f4-rcc.h> 2202c9239c1SAlexandre Torgue //Example 1 2212c9239c1SAlexandre Torgue pinctrl@40020000 { 2222c9239c1SAlexandre Torgue #address-cells = <1>; 2232c9239c1SAlexandre Torgue #size-cells = <1>; 2242c9239c1SAlexandre Torgue compatible = "st,stm32f429-pinctrl"; 2252c9239c1SAlexandre Torgue ranges = <0 0x40020000 0x3000>; 2262c9239c1SAlexandre Torgue 2272c9239c1SAlexandre Torgue gpioa: gpio@0 { 2282c9239c1SAlexandre Torgue gpio-controller; 2292c9239c1SAlexandre Torgue #gpio-cells = <2>; 230e2297f7cSRob Herring reg = <0x0 0x400>; 2312c9239c1SAlexandre Torgue resets = <&reset_ahb1 0>; 2322c9239c1SAlexandre Torgue clocks = <&rcc 0 STM32F4_AHB1_CLOCK(GPIOA)>; 2332c9239c1SAlexandre Torgue st,bank-name = "GPIOA"; 2342c9239c1SAlexandre Torgue }; 2352c9239c1SAlexandre Torgue }; 2362c9239c1SAlexandre Torgue 2372c9239c1SAlexandre Torgue //Example 2 (using gpio-ranges) 2382c9239c1SAlexandre Torgue pinctrl@50020000 { 2392c9239c1SAlexandre Torgue #address-cells = <1>; 2402c9239c1SAlexandre Torgue #size-cells = <1>; 2412c9239c1SAlexandre Torgue compatible = "st,stm32f429-pinctrl"; 2422c9239c1SAlexandre Torgue ranges = <0 0x50020000 0x3000>; 2432c9239c1SAlexandre Torgue 2442c9239c1SAlexandre Torgue gpiob: gpio@1000 { 2452c9239c1SAlexandre Torgue gpio-controller; 2462c9239c1SAlexandre Torgue #gpio-cells = <2>; 247e2297f7cSRob Herring reg = <0x1000 0x400>; 2482c9239c1SAlexandre Torgue resets = <&reset_ahb1 0>; 2492c9239c1SAlexandre Torgue clocks = <&rcc 0 STM32F4_AHB1_CLOCK(GPIOB)>; 2502c9239c1SAlexandre Torgue st,bank-name = "GPIOB"; 2512c9239c1SAlexandre Torgue gpio-ranges = <&pinctrl 0 0 16>; 2522c9239c1SAlexandre Torgue }; 2532c9239c1SAlexandre Torgue 2542c9239c1SAlexandre Torgue gpioc: gpio@2000 { 2552c9239c1SAlexandre Torgue gpio-controller; 2562c9239c1SAlexandre Torgue #gpio-cells = <2>; 257e2297f7cSRob Herring reg = <0x2000 0x400>; 2582c9239c1SAlexandre Torgue resets = <&reset_ahb1 0>; 2592c9239c1SAlexandre Torgue clocks = <&rcc 0 STM32F4_AHB1_CLOCK(GPIOC)>; 2602c9239c1SAlexandre Torgue st,bank-name = "GPIOC"; 2612c9239c1SAlexandre Torgue ngpios = <5>; 2622c9239c1SAlexandre Torgue gpio-ranges = <&pinctrl 0 16 3>, 2632c9239c1SAlexandre Torgue <&pinctrl 14 30 2>; 2642c9239c1SAlexandre Torgue }; 2652c9239c1SAlexandre Torgue }; 26651a21e0eSRob Herring 2672c9239c1SAlexandre Torgue //Example 3 pin groups 2682c9239c1SAlexandre Torgue pinctrl { 2692c9239c1SAlexandre Torgue usart1_pins_a: usart1-0 { 2702c9239c1SAlexandre Torgue pins1 { 2712c9239c1SAlexandre Torgue pinmux = <STM32_PINMUX('A', 9, AF7)>; 2722c9239c1SAlexandre Torgue bias-disable; 2732c9239c1SAlexandre Torgue drive-push-pull; 2742c9239c1SAlexandre Torgue slew-rate = <0>; 2752c9239c1SAlexandre Torgue }; 2762c9239c1SAlexandre Torgue pins2 { 2772c9239c1SAlexandre Torgue pinmux = <STM32_PINMUX('A', 10, AF7)>; 2782c9239c1SAlexandre Torgue bias-disable; 2792c9239c1SAlexandre Torgue }; 2802c9239c1SAlexandre Torgue }; 2812c9239c1SAlexandre Torgue }; 2822c9239c1SAlexandre Torgue 2832c9239c1SAlexandre Torgue usart1 { 2842c9239c1SAlexandre Torgue pinctrl-0 = <&usart1_pins_a>; 2852c9239c1SAlexandre Torgue pinctrl-names = "default"; 2862c9239c1SAlexandre Torgue }; 287 288... 289