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: | 14*a7fcc232SYu-Chun Lin STMicroelectronics's STM32 MCUs integrate 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 30a4564547SAlexandre Torgue - st,stm32mp257-pinctrl 31a4564547SAlexandre Torgue - st,stm32mp257-z-pinctrl 322c9239c1SAlexandre Torgue 332c9239c1SAlexandre Torgue '#address-cells': 342c9239c1SAlexandre Torgue const: 1 352c9239c1SAlexandre Torgue '#size-cells': 362c9239c1SAlexandre Torgue const: 1 372c9239c1SAlexandre Torgue 382c9239c1SAlexandre Torgue ranges: true 3980b99ed7SBernhard Rosenkränzer pins-are-numbered: 4080b99ed7SBernhard Rosenkränzer $ref: /schemas/types.yaml#/definitions/flag 4180b99ed7SBernhard Rosenkränzer deprecated: true 422c9239c1SAlexandre Torgue hwlocks: true 432c9239c1SAlexandre Torgue 44a45c0ec2SBenjamin Gaignard interrupts: 45a45c0ec2SBenjamin Gaignard maxItems: 1 46a45c0ec2SBenjamin Gaignard 472c9239c1SAlexandre Torgue st,syscfg: 4839bd2b6aSRob Herring description: Phandle+args to the syscon node which includes IRQ mux selection. 4949cd1dd1SRob Herring $ref: /schemas/types.yaml#/definitions/phandle-array 5039bd2b6aSRob Herring items: 51b1191940SMartin Kaiser - minItems: 2 52b1191940SMartin Kaiser items: 5339bd2b6aSRob Herring - description: syscon node which includes IRQ mux selection 5439bd2b6aSRob Herring - description: The offset of the IRQ mux selection register 5539bd2b6aSRob Herring - description: The field mask of IRQ mux, needed if different of 0xf 562c9239c1SAlexandre Torgue 572c9239c1SAlexandre Torgue st,package: 582c9239c1SAlexandre Torgue description: 592c9239c1SAlexandre Torgue Indicates the SOC package used. 602c9239c1SAlexandre Torgue More details in include/dt-bindings/pinctrl/stm32-pinfunc.h 613d21a460SRob Herring $ref: /schemas/types.yaml#/definitions/uint32 62a4564547SAlexandre Torgue enum: [0x1, 0x2, 0x4, 0x8, 0x100, 0x400, 0x800] 632c9239c1SAlexandre Torgue 642c9239c1SAlexandre TorguepatternProperties: 652c9239c1SAlexandre Torgue '^gpio@[0-9a-f]*$': 6615ffef1aSRob Herring type: object 67e79368b1SRob Herring additionalProperties: false 682c9239c1SAlexandre Torgue properties: 692c9239c1SAlexandre Torgue gpio-controller: true 702c9239c1SAlexandre Torgue '#gpio-cells': 712c9239c1SAlexandre Torgue const: 2 725197b707SMarek Vasut interrupt-controller: true 735197b707SMarek Vasut '#interrupt-cells': 745197b707SMarek Vasut const: 2 752c9239c1SAlexandre Torgue 762c9239c1SAlexandre Torgue reg: 772c9239c1SAlexandre Torgue maxItems: 1 782c9239c1SAlexandre Torgue clocks: 792c9239c1SAlexandre Torgue maxItems: 1 80e79368b1SRob Herring resets: 812c9239c1SAlexandre Torgue maxItems: 1 8244892170SMarek Vasut gpio-line-names: true 832c9239c1SAlexandre Torgue gpio-ranges: 842c9239c1SAlexandre Torgue minItems: 1 852c9239c1SAlexandre Torgue maxItems: 16 862c9239c1SAlexandre Torgue ngpios: 872c9239c1SAlexandre Torgue description: 882c9239c1SAlexandre Torgue Number of available gpios in a bank. 892c9239c1SAlexandre Torgue minimum: 1 902c9239c1SAlexandre Torgue maximum: 16 912c9239c1SAlexandre Torgue 922c9239c1SAlexandre Torgue st,bank-name: 933d21a460SRob Herring description: 943d21a460SRob Herring Should be a name string for this bank as specified in the datasheet. 9549cd1dd1SRob Herring $ref: /schemas/types.yaml#/definitions/string 963d21a460SRob Herring enum: 972c9239c1SAlexandre Torgue - GPIOA 982c9239c1SAlexandre Torgue - GPIOB 992c9239c1SAlexandre Torgue - GPIOC 1002c9239c1SAlexandre Torgue - GPIOD 1012c9239c1SAlexandre Torgue - GPIOE 1022c9239c1SAlexandre Torgue - GPIOF 1032c9239c1SAlexandre Torgue - GPIOG 1042c9239c1SAlexandre Torgue - GPIOH 1052c9239c1SAlexandre Torgue - GPIOI 1062c9239c1SAlexandre Torgue - GPIOJ 1072c9239c1SAlexandre Torgue - GPIOK 1082c9239c1SAlexandre Torgue - GPIOZ 1092c9239c1SAlexandre Torgue 1102c9239c1SAlexandre Torgue st,bank-ioport: 1112c9239c1SAlexandre Torgue description: 1122c9239c1SAlexandre Torgue Should correspond to the EXTI IOport selection (EXTI line used 1132c9239c1SAlexandre Torgue to select GPIOs as interrupts). 11449cd1dd1SRob Herring $ref: /schemas/types.yaml#/definitions/uint32 1153d21a460SRob Herring minimum: 0 1163d21a460SRob Herring maximum: 11 1172c9239c1SAlexandre Torgue 118140bb023SMarek Vasut patternProperties: 119140bb023SMarek Vasut "^(.+-hog(-[0-9]+)?)$": 120140bb023SMarek Vasut type: object 121140bb023SMarek Vasut required: 122140bb023SMarek Vasut - gpio-hog 123140bb023SMarek Vasut 1242c9239c1SAlexandre Torgue required: 1252c9239c1SAlexandre Torgue - gpio-controller 1262c9239c1SAlexandre Torgue - '#gpio-cells' 1272c9239c1SAlexandre Torgue - reg 1282c9239c1SAlexandre Torgue - clocks 1292c9239c1SAlexandre Torgue - st,bank-name 1302c9239c1SAlexandre Torgue 1312c9239c1SAlexandre Torgue '-[0-9]*$': 13215ffef1aSRob Herring type: object 1339194e0f8SRob Herring additionalProperties: false 1349194e0f8SRob Herring 1352c9239c1SAlexandre Torgue patternProperties: 1362c9239c1SAlexandre Torgue '^pins': 13715ffef1aSRob Herring type: object 1389194e0f8SRob Herring additionalProperties: false 1392c9239c1SAlexandre Torgue description: | 1402c9239c1SAlexandre Torgue A pinctrl node should contain at least one subnode representing the 1412c9239c1SAlexandre Torgue pinctrl group available on the machine. Each subnode will list the 1422c9239c1SAlexandre Torgue pins it needs, and how they should be configured, with regard to muxer 1432c9239c1SAlexandre Torgue configuration, pullups, drive, output high/low and output speed. 1442c9239c1SAlexandre Torgue properties: 1452c9239c1SAlexandre Torgue pinmux: 14649cd1dd1SRob Herring $ref: /schemas/types.yaml#/definitions/uint32-array 1472c9239c1SAlexandre Torgue description: | 1482c9239c1SAlexandre Torgue Integer array, represents gpio pin number and mux setting. 1492c9239c1SAlexandre Torgue Supported pin number and mux varies for different SoCs, and are 1502c9239c1SAlexandre Torgue defined in dt-bindings/pinctrl/<soc>-pinfunc.h directly. 1512c9239c1SAlexandre Torgue These defines are calculated as: ((port * 16 + line) << 8) | function 1522c9239c1SAlexandre Torgue With: 1532c9239c1SAlexandre Torgue - port: The gpio port index (PA = 0, PB = 1, ..., PK = 11) 1542c9239c1SAlexandre Torgue - line: The line offset within the port (PA0 = 0, PA1 = 1, ..., PA15 = 15) 1552c9239c1SAlexandre Torgue - function: The function number, can be: 1562c9239c1SAlexandre Torgue * 0 : GPIO 1572c9239c1SAlexandre Torgue * 1 : Alternate Function 0 1582c9239c1SAlexandre Torgue * 2 : Alternate Function 1 1592c9239c1SAlexandre Torgue * 3 : Alternate Function 2 1602c9239c1SAlexandre Torgue * ... 1612c9239c1SAlexandre Torgue * 16 : Alternate Function 15 1622c9239c1SAlexandre Torgue * 17 : Analog 1632c9239c1SAlexandre Torgue To simplify the usage, macro is available to generate "pinmux" field. 1642c9239c1SAlexandre Torgue This macro is available here: 1652c9239c1SAlexandre Torgue - include/dt-bindings/pinctrl/stm32-pinfunc.h 1662c9239c1SAlexandre Torgue Some examples of using macro: 167*a7fcc232SYu-Chun Lin /* GPIO A9 set as alternate function 2 */ 1682c9239c1SAlexandre Torgue ... { 1692c9239c1SAlexandre Torgue pinmux = <STM32_PINMUX('A', 9, AF2)>; 1702c9239c1SAlexandre Torgue }; 1712c9239c1SAlexandre Torgue /* GPIO A9 set as GPIO */ 1722c9239c1SAlexandre Torgue ... { 1732c9239c1SAlexandre Torgue pinmux = <STM32_PINMUX('A', 9, GPIO)>; 1742c9239c1SAlexandre Torgue }; 1752c9239c1SAlexandre Torgue /* GPIO A9 set as analog */ 1762c9239c1SAlexandre Torgue ... { 1772c9239c1SAlexandre Torgue pinmux = <STM32_PINMUX('A', 9, ANALOG)>; 1782c9239c1SAlexandre Torgue }; 1792c9239c1SAlexandre Torgue 1802c9239c1SAlexandre Torgue bias-disable: 1812c9239c1SAlexandre Torgue type: boolean 1822c9239c1SAlexandre Torgue bias-pull-down: 1832c9239c1SAlexandre Torgue type: boolean 1842c9239c1SAlexandre Torgue bias-pull-up: 1852c9239c1SAlexandre Torgue type: boolean 1862c9239c1SAlexandre Torgue drive-push-pull: 1872c9239c1SAlexandre Torgue type: boolean 1882c9239c1SAlexandre Torgue drive-open-drain: 1892c9239c1SAlexandre Torgue type: boolean 1902c9239c1SAlexandre Torgue output-low: 1912c9239c1SAlexandre Torgue type: boolean 1922c9239c1SAlexandre Torgue output-high: 1932c9239c1SAlexandre Torgue type: boolean 1942c9239c1SAlexandre Torgue slew-rate: 1952c9239c1SAlexandre Torgue description: | 1962c9239c1SAlexandre Torgue 0: Low speed 1972c9239c1SAlexandre Torgue 1: Medium speed 1982c9239c1SAlexandre Torgue 2: Fast speed 1992c9239c1SAlexandre Torgue 3: High speed 2003d21a460SRob Herring $ref: /schemas/types.yaml#/definitions/uint32 2013d21a460SRob Herring enum: [0, 1, 2, 3] 2022c9239c1SAlexandre Torgue 2032c9239c1SAlexandre Torgue required: 2042c9239c1SAlexandre Torgue - pinmux 2052c9239c1SAlexandre Torgue 206c09acbc4SRafał MiłeckiallOf: 20749cd1dd1SRob Herring - $ref: pinctrl.yaml# 208c09acbc4SRafał Miłecki 2092c9239c1SAlexandre Torguerequired: 2102c9239c1SAlexandre Torgue - compatible 2112c9239c1SAlexandre Torgue - '#address-cells' 2122c9239c1SAlexandre Torgue - '#size-cells' 2132c9239c1SAlexandre Torgue - ranges 2142c9239c1SAlexandre Torgue 2157f464532SRob HerringadditionalProperties: false 2167f464532SRob Herring 2172c9239c1SAlexandre Torgueexamples: 2182c9239c1SAlexandre Torgue - | 2192c9239c1SAlexandre Torgue #include <dt-bindings/pinctrl/stm32-pinfunc.h> 220e2297f7cSRob Herring #include <dt-bindings/mfd/stm32f4-rcc.h> 2212c9239c1SAlexandre Torgue //Example 1 2222c9239c1SAlexandre Torgue pinctrl@40020000 { 2232c9239c1SAlexandre Torgue #address-cells = <1>; 2242c9239c1SAlexandre Torgue #size-cells = <1>; 2252c9239c1SAlexandre Torgue compatible = "st,stm32f429-pinctrl"; 2262c9239c1SAlexandre Torgue ranges = <0 0x40020000 0x3000>; 2272c9239c1SAlexandre Torgue 2282c9239c1SAlexandre Torgue gpioa: gpio@0 { 2292c9239c1SAlexandre Torgue gpio-controller; 2302c9239c1SAlexandre Torgue #gpio-cells = <2>; 2312c9239c1SAlexandre Torgue reg = <0x0 0x400>; 2322c9239c1SAlexandre Torgue resets = <&reset_ahb1 0>; 233e2297f7cSRob Herring clocks = <&rcc 0 STM32F4_AHB1_CLOCK(GPIOA)>; 2342c9239c1SAlexandre Torgue st,bank-name = "GPIOA"; 2352c9239c1SAlexandre Torgue }; 2362c9239c1SAlexandre Torgue }; 2372c9239c1SAlexandre Torgue 2382c9239c1SAlexandre Torgue //Example 2 (using gpio-ranges) 2392c9239c1SAlexandre Torgue pinctrl@50020000 { 2402c9239c1SAlexandre Torgue #address-cells = <1>; 2412c9239c1SAlexandre Torgue #size-cells = <1>; 2422c9239c1SAlexandre Torgue compatible = "st,stm32f429-pinctrl"; 2432c9239c1SAlexandre Torgue ranges = <0 0x50020000 0x3000>; 2442c9239c1SAlexandre Torgue 2452c9239c1SAlexandre Torgue gpiob: gpio@1000 { 2462c9239c1SAlexandre Torgue gpio-controller; 2472c9239c1SAlexandre Torgue #gpio-cells = <2>; 2482c9239c1SAlexandre Torgue reg = <0x1000 0x400>; 2492c9239c1SAlexandre Torgue resets = <&reset_ahb1 0>; 250e2297f7cSRob Herring clocks = <&rcc 0 STM32F4_AHB1_CLOCK(GPIOB)>; 2512c9239c1SAlexandre Torgue st,bank-name = "GPIOB"; 2522c9239c1SAlexandre Torgue gpio-ranges = <&pinctrl 0 0 16>; 2532c9239c1SAlexandre Torgue }; 2542c9239c1SAlexandre Torgue 2552c9239c1SAlexandre Torgue gpioc: gpio@2000 { 2562c9239c1SAlexandre Torgue gpio-controller; 2572c9239c1SAlexandre Torgue #gpio-cells = <2>; 2582c9239c1SAlexandre Torgue reg = <0x2000 0x400>; 2592c9239c1SAlexandre Torgue resets = <&reset_ahb1 0>; 260e2297f7cSRob Herring clocks = <&rcc 0 STM32F4_AHB1_CLOCK(GPIOC)>; 2612c9239c1SAlexandre Torgue st,bank-name = "GPIOC"; 2622c9239c1SAlexandre Torgue ngpios = <5>; 2632c9239c1SAlexandre Torgue gpio-ranges = <&pinctrl 0 16 3>, 2642c9239c1SAlexandre Torgue <&pinctrl 14 30 2>; 2652c9239c1SAlexandre Torgue }; 2662c9239c1SAlexandre Torgue }; 2672c9239c1SAlexandre Torgue 2682c9239c1SAlexandre Torgue //Example 3 pin groups 26951a21e0eSRob Herring pinctrl { 2702c9239c1SAlexandre Torgue usart1_pins_a: usart1-0 { 2712c9239c1SAlexandre Torgue pins1 { 2722c9239c1SAlexandre Torgue pinmux = <STM32_PINMUX('A', 9, AF7)>; 2732c9239c1SAlexandre Torgue bias-disable; 2742c9239c1SAlexandre Torgue drive-push-pull; 2752c9239c1SAlexandre Torgue slew-rate = <0>; 2762c9239c1SAlexandre Torgue }; 2772c9239c1SAlexandre Torgue pins2 { 2782c9239c1SAlexandre Torgue pinmux = <STM32_PINMUX('A', 10, AF7)>; 2792c9239c1SAlexandre Torgue bias-disable; 2802c9239c1SAlexandre Torgue }; 2812c9239c1SAlexandre Torgue }; 2822c9239c1SAlexandre Torgue }; 2832c9239c1SAlexandre Torgue 2842c9239c1SAlexandre Torgue usart1 { 2852c9239c1SAlexandre Torgue pinctrl-0 = <&usart1_pins_a>; 2862c9239c1SAlexandre Torgue pinctrl-names = "default"; 2872c9239c1SAlexandre Torgue }; 2882c9239c1SAlexandre Torgue 2892c9239c1SAlexandre Torgue... 290