xref: /linux/Documentation/devicetree/bindings/pinctrl/st,stm32-pinctrl.yaml (revision 39bd2b6a3783b8990d97494ec4c8698ba5bb6740)
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
312c9239c1SAlexandre Torgue  '#address-cells':
322c9239c1SAlexandre Torgue    const: 1
332c9239c1SAlexandre Torgue  '#size-cells':
342c9239c1SAlexandre Torgue    const: 1
352c9239c1SAlexandre Torgue
362c9239c1SAlexandre Torgue  ranges: true
372c9239c1SAlexandre Torgue  pins-are-numbered: true
382c9239c1SAlexandre Torgue  hwlocks: true
392c9239c1SAlexandre Torgue
40a45c0ec2SBenjamin Gaignard  interrupts:
41a45c0ec2SBenjamin Gaignard    maxItems: 1
42a45c0ec2SBenjamin Gaignard
432c9239c1SAlexandre Torgue  st,syscfg:
44*39bd2b6aSRob Herring    description: Phandle+args to the syscon node which includes IRQ mux selection.
453d21a460SRob Herring    $ref: "/schemas/types.yaml#/definitions/phandle-array"
46*39bd2b6aSRob Herring    items:
47*39bd2b6aSRob Herring      - items:
48*39bd2b6aSRob Herring          - description: syscon node which includes IRQ mux selection
49*39bd2b6aSRob Herring          - description: The offset of the IRQ mux selection register
50*39bd2b6aSRob Herring          - description: The field mask of IRQ mux, needed if different of 0xf
512c9239c1SAlexandre Torgue
522c9239c1SAlexandre Torgue  st,package:
532c9239c1SAlexandre Torgue    description:
542c9239c1SAlexandre Torgue      Indicates the SOC package used.
552c9239c1SAlexandre Torgue      More details in include/dt-bindings/pinctrl/stm32-pinfunc.h
563d21a460SRob Herring    $ref: /schemas/types.yaml#/definitions/uint32
573d21a460SRob Herring    enum: [1, 2, 4, 8]
582c9239c1SAlexandre Torgue
592c9239c1SAlexandre TorguepatternProperties:
602c9239c1SAlexandre Torgue  '^gpio@[0-9a-f]*$':
6115ffef1aSRob Herring    type: object
622c9239c1SAlexandre Torgue    properties:
632c9239c1SAlexandre Torgue      gpio-controller: true
642c9239c1SAlexandre Torgue      '#gpio-cells':
652c9239c1SAlexandre Torgue        const: 2
662c9239c1SAlexandre Torgue
672c9239c1SAlexandre Torgue      reg:
682c9239c1SAlexandre Torgue        maxItems: 1
692c9239c1SAlexandre Torgue      clocks:
702c9239c1SAlexandre Torgue        maxItems: 1
712c9239c1SAlexandre Torgue      reset:
722c9239c1SAlexandre Torgue        minItems: 1
732c9239c1SAlexandre Torgue        maxItems: 1
742c9239c1SAlexandre Torgue      gpio-ranges:
752c9239c1SAlexandre Torgue        minItems: 1
762c9239c1SAlexandre Torgue        maxItems: 16
772c9239c1SAlexandre Torgue      ngpios:
782c9239c1SAlexandre Torgue        description:
792c9239c1SAlexandre Torgue          Number of available gpios in a bank.
802c9239c1SAlexandre Torgue        minimum: 1
812c9239c1SAlexandre Torgue        maximum: 16
822c9239c1SAlexandre Torgue
832c9239c1SAlexandre Torgue      st,bank-name:
843d21a460SRob Herring        description:
853d21a460SRob Herring          Should be a name string for this bank as specified in the datasheet.
863d21a460SRob Herring        $ref: "/schemas/types.yaml#/definitions/string"
873d21a460SRob Herring        enum:
882c9239c1SAlexandre Torgue          - GPIOA
892c9239c1SAlexandre Torgue          - GPIOB
902c9239c1SAlexandre Torgue          - GPIOC
912c9239c1SAlexandre Torgue          - GPIOD
922c9239c1SAlexandre Torgue          - GPIOE
932c9239c1SAlexandre Torgue          - GPIOF
942c9239c1SAlexandre Torgue          - GPIOG
952c9239c1SAlexandre Torgue          - GPIOH
962c9239c1SAlexandre Torgue          - GPIOI
972c9239c1SAlexandre Torgue          - GPIOJ
982c9239c1SAlexandre Torgue          - GPIOK
992c9239c1SAlexandre Torgue          - GPIOZ
1002c9239c1SAlexandre Torgue
1012c9239c1SAlexandre Torgue      st,bank-ioport:
1022c9239c1SAlexandre Torgue        description:
1032c9239c1SAlexandre Torgue          Should correspond to the EXTI IOport selection (EXTI line used
1042c9239c1SAlexandre Torgue          to select GPIOs as interrupts).
1053d21a460SRob Herring        $ref: "/schemas/types.yaml#/definitions/uint32"
1063d21a460SRob Herring        minimum: 0
1073d21a460SRob Herring        maximum: 11
1082c9239c1SAlexandre Torgue
1092c9239c1SAlexandre Torgue    required:
1102c9239c1SAlexandre Torgue      - gpio-controller
1112c9239c1SAlexandre Torgue      - '#gpio-cells'
1122c9239c1SAlexandre Torgue      - reg
1132c9239c1SAlexandre Torgue      - clocks
1142c9239c1SAlexandre Torgue      - st,bank-name
1152c9239c1SAlexandre Torgue
1162c9239c1SAlexandre Torgue  '-[0-9]*$':
11715ffef1aSRob Herring    type: object
1182c9239c1SAlexandre Torgue    patternProperties:
1192c9239c1SAlexandre Torgue      '^pins':
12015ffef1aSRob Herring        type: object
1212c9239c1SAlexandre Torgue        description: |
1222c9239c1SAlexandre Torgue          A pinctrl node should contain at least one subnode representing the
1232c9239c1SAlexandre Torgue          pinctrl group available on the machine. Each subnode will list the
1242c9239c1SAlexandre Torgue          pins it needs, and how they should be configured, with regard to muxer
1252c9239c1SAlexandre Torgue          configuration, pullups, drive, output high/low and output speed.
1262c9239c1SAlexandre Torgue        properties:
1272c9239c1SAlexandre Torgue          pinmux:
1283d21a460SRob Herring            $ref: "/schemas/types.yaml#/definitions/uint32-array"
1292c9239c1SAlexandre Torgue            description: |
1302c9239c1SAlexandre Torgue              Integer array, represents gpio pin number and mux setting.
1312c9239c1SAlexandre Torgue              Supported pin number and mux varies for different SoCs, and are
1322c9239c1SAlexandre Torgue              defined in dt-bindings/pinctrl/<soc>-pinfunc.h directly.
1332c9239c1SAlexandre Torgue              These defines are calculated as: ((port * 16 + line) << 8) | function
1342c9239c1SAlexandre Torgue              With:
1352c9239c1SAlexandre Torgue              - port: The gpio port index (PA = 0, PB = 1, ..., PK = 11)
1362c9239c1SAlexandre Torgue              - line: The line offset within the port (PA0 = 0, PA1 = 1, ..., PA15 = 15)
1372c9239c1SAlexandre Torgue              - function: The function number, can be:
1382c9239c1SAlexandre Torgue              * 0 : GPIO
1392c9239c1SAlexandre Torgue              * 1 : Alternate Function 0
1402c9239c1SAlexandre Torgue              * 2 : Alternate Function 1
1412c9239c1SAlexandre Torgue              * 3 : Alternate Function 2
1422c9239c1SAlexandre Torgue              * ...
1432c9239c1SAlexandre Torgue              * 16 : Alternate Function 15
1442c9239c1SAlexandre Torgue              * 17 : Analog
1452c9239c1SAlexandre Torgue              To simplify the usage, macro is available to generate "pinmux" field.
1462c9239c1SAlexandre Torgue              This macro is available here:
1472c9239c1SAlexandre Torgue                - include/dt-bindings/pinctrl/stm32-pinfunc.h
1482c9239c1SAlexandre Torgue              Some examples of using macro:
1492c9239c1SAlexandre Torgue               /* GPIO A9 set as alernate function 2 */
1502c9239c1SAlexandre Torgue               ... {
1512c9239c1SAlexandre Torgue                          pinmux = <STM32_PINMUX('A', 9, AF2)>;
1522c9239c1SAlexandre Torgue               };
1532c9239c1SAlexandre Torgue               /* GPIO A9 set as GPIO  */
1542c9239c1SAlexandre Torgue               ... {
1552c9239c1SAlexandre Torgue                          pinmux = <STM32_PINMUX('A', 9, GPIO)>;
1562c9239c1SAlexandre Torgue               };
1572c9239c1SAlexandre Torgue               /* GPIO A9 set as analog */
1582c9239c1SAlexandre Torgue               ... {
1592c9239c1SAlexandre Torgue                          pinmux = <STM32_PINMUX('A', 9, ANALOG)>;
1602c9239c1SAlexandre Torgue               };
1612c9239c1SAlexandre Torgue
1622c9239c1SAlexandre Torgue          bias-disable:
1632c9239c1SAlexandre Torgue            type: boolean
1642c9239c1SAlexandre Torgue          bias-pull-down:
1652c9239c1SAlexandre Torgue            type: boolean
1662c9239c1SAlexandre Torgue          bias-pull-up:
1672c9239c1SAlexandre Torgue            type: boolean
1682c9239c1SAlexandre Torgue          drive-push-pull:
1692c9239c1SAlexandre Torgue            type: boolean
1702c9239c1SAlexandre Torgue          drive-open-drain:
1712c9239c1SAlexandre Torgue            type: boolean
1722c9239c1SAlexandre Torgue          output-low:
1732c9239c1SAlexandre Torgue            type: boolean
1742c9239c1SAlexandre Torgue          output-high:
1752c9239c1SAlexandre Torgue            type: boolean
1762c9239c1SAlexandre Torgue          slew-rate:
1772c9239c1SAlexandre Torgue            description: |
1782c9239c1SAlexandre Torgue              0: Low speed
1792c9239c1SAlexandre Torgue              1: Medium speed
1802c9239c1SAlexandre Torgue              2: Fast speed
1812c9239c1SAlexandre Torgue              3: High speed
1823d21a460SRob Herring            $ref: /schemas/types.yaml#/definitions/uint32
1833d21a460SRob Herring            enum: [0, 1, 2, 3]
1842c9239c1SAlexandre Torgue
1852c9239c1SAlexandre Torgue        required:
1862c9239c1SAlexandre Torgue          - pinmux
1872c9239c1SAlexandre Torgue
188c09acbc4SRafał MiłeckiallOf:
189c09acbc4SRafał Miłecki  - $ref: "pinctrl.yaml#"
190c09acbc4SRafał Miłecki
1912c9239c1SAlexandre Torguerequired:
1922c9239c1SAlexandre Torgue  - compatible
1932c9239c1SAlexandre Torgue  - '#address-cells'
1942c9239c1SAlexandre Torgue  - '#size-cells'
1952c9239c1SAlexandre Torgue  - ranges
1962c9239c1SAlexandre Torgue  - pins-are-numbered
1972c9239c1SAlexandre Torgue
1987f464532SRob HerringadditionalProperties: false
1997f464532SRob Herring
2002c9239c1SAlexandre Torgueexamples:
2012c9239c1SAlexandre Torgue  - |
2022c9239c1SAlexandre Torgue    #include <dt-bindings/pinctrl/stm32-pinfunc.h>
203e2297f7cSRob Herring    #include <dt-bindings/mfd/stm32f4-rcc.h>
2042c9239c1SAlexandre Torgue    //Example 1
2052c9239c1SAlexandre Torgue      pinctrl@40020000 {
2062c9239c1SAlexandre Torgue              #address-cells = <1>;
2072c9239c1SAlexandre Torgue              #size-cells = <1>;
2082c9239c1SAlexandre Torgue              compatible = "st,stm32f429-pinctrl";
2092c9239c1SAlexandre Torgue              ranges = <0 0x40020000 0x3000>;
2102c9239c1SAlexandre Torgue              pins-are-numbered;
2112c9239c1SAlexandre Torgue
2122c9239c1SAlexandre Torgue              gpioa: gpio@0 {
2132c9239c1SAlexandre Torgue                      gpio-controller;
2142c9239c1SAlexandre Torgue                      #gpio-cells = <2>;
2152c9239c1SAlexandre Torgue                      reg = <0x0 0x400>;
2162c9239c1SAlexandre Torgue                      resets = <&reset_ahb1 0>;
217e2297f7cSRob Herring                      clocks = <&rcc 0 STM32F4_AHB1_CLOCK(GPIOA)>;
2182c9239c1SAlexandre Torgue                      st,bank-name = "GPIOA";
2192c9239c1SAlexandre Torgue              };
2202c9239c1SAlexandre Torgue       };
2212c9239c1SAlexandre Torgue
2222c9239c1SAlexandre Torgue    //Example 2 (using gpio-ranges)
2232c9239c1SAlexandre Torgue      pinctrl@50020000 {
2242c9239c1SAlexandre Torgue              #address-cells = <1>;
2252c9239c1SAlexandre Torgue              #size-cells = <1>;
2262c9239c1SAlexandre Torgue              compatible = "st,stm32f429-pinctrl";
2272c9239c1SAlexandre Torgue              ranges = <0 0x50020000 0x3000>;
2282c9239c1SAlexandre Torgue              pins-are-numbered;
2292c9239c1SAlexandre Torgue
2302c9239c1SAlexandre Torgue              gpiob: gpio@1000 {
2312c9239c1SAlexandre Torgue                      gpio-controller;
2322c9239c1SAlexandre Torgue                      #gpio-cells = <2>;
2332c9239c1SAlexandre Torgue                      reg = <0x1000 0x400>;
2342c9239c1SAlexandre Torgue                      resets = <&reset_ahb1 0>;
235e2297f7cSRob Herring                      clocks = <&rcc 0 STM32F4_AHB1_CLOCK(GPIOB)>;
2362c9239c1SAlexandre Torgue                      st,bank-name = "GPIOB";
2372c9239c1SAlexandre Torgue                      gpio-ranges = <&pinctrl 0 0 16>;
2382c9239c1SAlexandre Torgue              };
2392c9239c1SAlexandre Torgue
2402c9239c1SAlexandre Torgue              gpioc: gpio@2000 {
2412c9239c1SAlexandre Torgue                      gpio-controller;
2422c9239c1SAlexandre Torgue                      #gpio-cells = <2>;
2432c9239c1SAlexandre Torgue                      reg = <0x2000 0x400>;
2442c9239c1SAlexandre Torgue                      resets = <&reset_ahb1 0>;
245e2297f7cSRob Herring                      clocks = <&rcc 0 STM32F4_AHB1_CLOCK(GPIOC)>;
2462c9239c1SAlexandre Torgue                      st,bank-name = "GPIOC";
2472c9239c1SAlexandre Torgue                      ngpios = <5>;
2482c9239c1SAlexandre Torgue                      gpio-ranges = <&pinctrl 0 16 3>,
2492c9239c1SAlexandre Torgue                                    <&pinctrl 14 30 2>;
2502c9239c1SAlexandre Torgue              };
2512c9239c1SAlexandre Torgue      };
2522c9239c1SAlexandre Torgue
2532c9239c1SAlexandre Torgue    //Example 3 pin groups
25451a21e0eSRob Herring      pinctrl {
2552c9239c1SAlexandre Torgue        usart1_pins_a: usart1-0 {
2562c9239c1SAlexandre Torgue                pins1 {
2572c9239c1SAlexandre Torgue                        pinmux = <STM32_PINMUX('A', 9, AF7)>;
2582c9239c1SAlexandre Torgue                        bias-disable;
2592c9239c1SAlexandre Torgue                        drive-push-pull;
2602c9239c1SAlexandre Torgue                        slew-rate = <0>;
2612c9239c1SAlexandre Torgue                };
2622c9239c1SAlexandre Torgue                pins2 {
2632c9239c1SAlexandre Torgue                        pinmux = <STM32_PINMUX('A', 10, AF7)>;
2642c9239c1SAlexandre Torgue                        bias-disable;
2652c9239c1SAlexandre Torgue                };
2662c9239c1SAlexandre Torgue        };
2672c9239c1SAlexandre Torgue    };
2682c9239c1SAlexandre Torgue
2692c9239c1SAlexandre Torgue    usart1 {
2702c9239c1SAlexandre Torgue                pinctrl-0 = <&usart1_pins_a>;
2712c9239c1SAlexandre Torgue                pinctrl-names = "default";
2722c9239c1SAlexandre Torgue    };
2732c9239c1SAlexandre Torgue
2742c9239c1SAlexandre Torgue...
275