STM32 GPIO and Pin Mux/Config controller

Schema identifier ($id): "http://devicetree.org/schemas/pinctrl/st,stm32-pinctrl.yaml#"

Schema dialect ($schema): "http://devicetree.org/meta-schemas/core.yaml#"

Maintainers (maintainers): "Alexandre TORGUE <alexandre.torgue@foss.st.com>"

STMicroelectronics's STM32 MCUs integrate a GPIO and Pin mux/config hardware controller. It controls the input/output settings on the available pins and also provides ability to multiplex and configure the output of various on-chip controllers onto these pads.

Properties and child nodes (properties) #

compatible — required here #

Allowed values (enum): "st,stm32f429-pinctrl", "st,stm32f469-pinctrl", "st,stm32f746-pinctrl", "st,stm32f769-pinctrl", "st,stm32h743-pinctrl", "st,stm32mp135-pinctrl", "st,stm32mp157-pinctrl", "st,stm32mp157-z-pinctrl", "st,stm32mp257-pinctrl", "st,stm32mp257-z-pinctrl"

#address-cells — required here #

Exact value (const): 1

#size-cells — required here #

Exact value (const): 1

ranges — required here #

true — No constraints added by this property rule.

pins-are-numbered — not listed as required here #

Shared schema rule ($ref): /schemas/types.yaml#/definitions/flag

Deprecated (deprecated): true

hwlocks — not listed as required here #

true — No constraints added by this property rule.

interrupts — not listed as required here #

Maximum number of items (maxItems): 1

st,syscfg — not listed as required here #

Phandle+args to the syscon node which includes IRQ mux selection.

Shared schema rule ($ref): /schemas/types.yaml#/definitions/phandle-array

Array item rules (items) #

Item 1

Minimum number of items (minItems): 2

Array item rules (items)

Item 1

syscon node which includes IRQ mux selection

Item 2

The offset of the IRQ mux selection register

Item 3

The field mask of IRQ mux, needed if different of 0xf

st,package — not listed as required here #

Indicates the SOC package used. More details in include/dt-bindings/pinctrl/stm32-pinfunc.h

Shared schema rule ($ref): /schemas/types.yaml#/definitions/uint32

Allowed values (enum): 1, 2, 4, 8, 256, 1024, 2048

Properties matching a name pattern (patternProperties) #

^gpio@[0-9a-f]*$ — name matches this regular expression #

Value type (type): "object"

Properties not matched by properties or patternProperties in this schema (additionalProperties) #

false

Not allowed by this rule.

Properties and child nodes (properties) #

gpio-controller — required here

true — No constraints added by this property rule.

#gpio-cells — required here

Exact value (const): 2

interrupt-controller — not listed as required here

true — No constraints added by this property rule.

#interrupt-cells — not listed as required here

Exact value (const): 2

reg — required here

Maximum number of items (maxItems): 1

clocks — required here

Maximum number of items (maxItems): 1

resets — not listed as required here

Maximum number of items (maxItems): 1

gpio-line-names — not listed as required here

true — No constraints added by this property rule.

gpio-ranges — not listed as required here

Minimum number of items (minItems): 1

Maximum number of items (maxItems): 16

ngpios — not listed as required here

Number of available gpios in a bank.

Minimum value (minimum): 1

Maximum value (maximum): 16

st,bank-name — required here

Should be a name string for this bank as specified in the datasheet.

Shared schema rule ($ref): /schemas/types.yaml#/definitions/string

Allowed values (enum): "GPIOA", "GPIOB", "GPIOC", "GPIOD", "GPIOE", "GPIOF", "GPIOG", "GPIOH", "GPIOI", "GPIOJ", "GPIOK", "GPIOZ"

st,bank-ioport — not listed as required here

Should correspond to the EXTI IOport selection (EXTI line used to select GPIOs as interrupts).

Shared schema rule ($ref): /schemas/types.yaml#/definitions/uint32

Minimum value (minimum): 0

Maximum value (maximum): 11

Properties matching a name pattern (patternProperties) #

^(.+-hog(-[0-9]+)?)$ — name matches this regular expression

Value type (type): "object"

Required in this object (required): "gpio-hog"

Required in this object (required): "gpio-controller", "#gpio-cells", "reg", "clocks", "st,bank-name"

-[0-9]*$ — name matches this regular expression #

Value type (type): "object"

Properties not matched by properties or patternProperties in this schema (additionalProperties) #

false

Not allowed by this rule.

Properties matching a name pattern (patternProperties) #

^pins — name matches this regular expression

Value type (type): "object"

Properties not matched by properties or patternProperties in this schema (additionalProperties)

false

Not allowed by this rule.

A pinctrl node should contain at least one subnode representing the pinctrl group available on the machine. Each subnode will list the pins it needs, and how they should be configured, with regard to muxer configuration, pullups, drive, output high/low and output speed.

Shared schema rule ($ref): /schemas/pinctrl/pincfg-node.yaml

Properties and child nodes (properties)

pinmux — required here

Shared schema rule ($ref): /schemas/types.yaml#/definitions/uint32-array

Integer array, represents gpio pin number and mux setting.
Supported pin number and mux varies for different SoCs, and are
defined in dt-bindings/pinctrl/<soc>-pinfunc.h directly.
These defines are calculated as: ((port * 16 + line) << 8) | function
With:
- port: The gpio port index (PA = 0, PB = 1, ..., PK = 11)
- line: The line offset within the port (PA0 = 0, PA1 = 1, ..., PA15 = 15)
- function: The function number, can be:
* 0 : GPIO
* 1 : Alternate Function 0
* 2 : Alternate Function 1
* 3 : Alternate Function 2
* ...
* 16 : Alternate Function 15
* 17 : Analog
* 18 : Reserved
To simplify the usage, macro is available to generate "pinmux" field.
This macro is available here:
  - include/dt-bindings/pinctrl/stm32-pinfunc.h
Setting the pinmux's function to the Reserved (RSVD) value is used to inform
the driver that it shall not apply the mux setting. This can be used to
reserve some pins, for example to a co-processor not running Linux.
Some examples of using macro:
 /* GPIO A9 set as alternate function 2 */
 ... {
            pinmux = <STM32_PINMUX('A', 9, AF2)>;
 };
 /* GPIO A9 set as GPIO  */
 ... {
            pinmux = <STM32_PINMUX('A', 9, GPIO)>;
 };
 /* GPIO A9 set as analog */
 ... {
            pinmux = <STM32_PINMUX('A', 9, ANALOG)>;
 };
 /* GPIO A9 reserved for co-processor */
 ... {
            pinmux = <STM32_PINMUX('A', 9, RSVD)>;
 };

bias-disable — not listed as required here

true — No constraints added by this property rule.

bias-pull-down — not listed as required here

true — No constraints added by this property rule.

bias-pull-up — not listed as required here

true — No constraints added by this property rule.

drive-push-pull — not listed as required here

true — No constraints added by this property rule.

drive-open-drain — not listed as required here

true — No constraints added by this property rule.

output-low — not listed as required here

true — No constraints added by this property rule.

output-high — not listed as required here

true — No constraints added by this property rule.

slew-rate — not listed as required here

0: Low speed 1: Medium speed 2: Fast speed 3: High speed

Minimum value (minimum): 0

Maximum value (maximum): 3

skew-delay-input-ps — not listed as required here

IO synchronization skew rate applied to the input path

Allowed values (enum): 0, 300, 500, 750, 1000, 1250, 1500, 1750, 2000, 2250, 2500, 2750, 3000, 3250

skew-delay-output-ps — not listed as required here

IO synchronization latch delay applied to the output path

Allowed values (enum): 0, 300, 500, 750, 1000, 1250, 1500, 1750, 2000, 2250, 2500, 2750, 3000, 3250

st,io-sync — not listed as required here

Shared schema rule ($ref): /schemas/types.yaml#/definitions/string

Allowed values (enum): "pass-through", "clock inverted", "data on rising edge", "data on falling edge", "data on both edges"

IO synchronization through re-sampling or inversion "pass-through" - data or clock GPIO pass-through "clock inverted" - clock GPIO inverted "data on rising edge" - data GPIO re-sampled on clock rising edge "data on falling edge" - data GPIO re-sampled on clock falling edge "data on both edges" - data GPIO re-sampled on both clock edges

Default value (default): "pass-through"

Required in this object (required): "pinmux"

Condition (if)

Required in this object (required): "skew-delay-input-ps"

When the condition matches (then)

Properties and child nodes (properties)

skew-delay-output-ps — not listed as required here

false — Not permitted by this property rule.

All of these rules must match (allOf) #

Rule 1 #

Shared schema rule ($ref): pinctrl.yaml#

Rule 2 #

Condition (if) #

This rule must not match (not)

Properties and child nodes (properties)

compatible — not listed as required here

Rule for matching array elements (contains)

Allowed values (enum): "st,stm32mp257-pinctrl", "st,stm32mp257-z-pinctrl"

When the condition matches (then) #

Properties matching a name pattern (patternProperties)

-[0-9]*$ — name matches this regular expression

Properties matching a name pattern (patternProperties)

^pins — name matches this regular expression

Properties and child nodes (properties)

skew-delay-input-ps — not listed as required here

false — Not permitted by this property rule.

skew-delay-output-ps — not listed as required here

false — Not permitted by this property rule.

st,io-sync — not listed as required here

false — Not permitted by this property rule.

Required in this object (required): "compatible", "#address-cells", "#size-cells", "ranges"

Properties not matched by properties or patternProperties in this schema (additionalProperties) #

false

Not allowed by this rule.

Examples (examples) #

#include <dt-bindings/pinctrl/stm32-pinfunc.h>
#include <dt-bindings/mfd/stm32f4-rcc.h>
//Example 1
  pinctrl@40020000 {
          #address-cells = <1>;
          #size-cells = <1>;
          compatible = "st,stm32f429-pinctrl";
          ranges = <0 0x40020000 0x3000>;

          gpioa: gpio@0 {
                  gpio-controller;
                  #gpio-cells = <2>;
                  reg = <0x0 0x400>;
                  resets = <&reset_ahb1 0>;
                  clocks = <&rcc 0 STM32F4_AHB1_CLOCK(GPIOA)>;
                  st,bank-name = "GPIOA";
          };
   };

//Example 2 (using gpio-ranges)
  pinctrl@50020000 {
          #address-cells = <1>;
          #size-cells = <1>;
          compatible = "st,stm32f429-pinctrl";
          ranges = <0 0x50020000 0x3000>;

          gpiob: gpio@1000 {
                  gpio-controller;
                  #gpio-cells = <2>;
                  reg = <0x1000 0x400>;
                  resets = <&reset_ahb1 0>;
                  clocks = <&rcc 0 STM32F4_AHB1_CLOCK(GPIOB)>;
                  st,bank-name = "GPIOB";
                  gpio-ranges = <&pinctrl 0 0 16>;
          };

          gpioc: gpio@2000 {
                  gpio-controller;
                  #gpio-cells = <2>;
                  reg = <0x2000 0x400>;
                  resets = <&reset_ahb1 0>;
                  clocks = <&rcc 0 STM32F4_AHB1_CLOCK(GPIOC)>;
                  st,bank-name = "GPIOC";
                  ngpios = <5>;
                  gpio-ranges = <&pinctrl 0 16 3>,
                                <&pinctrl 14 30 2>;
          };
  };

//Example 3 pin groups
  pinctrl {
    usart1_pins_a: usart1-0 {
            pins1 {
                    pinmux = <STM32_PINMUX('A', 9, AF7)>;
                    bias-disable;
                    drive-push-pull;
                    slew-rate = <0>;
            };
            pins2 {
                    pinmux = <STM32_PINMUX('A', 10, AF7)>;
                    bias-disable;
            };
    };
};

usart1 {
            pinctrl-0 = <&usart1_pins_a>;
            pinctrl-names = "default";
};
#include <dt-bindings/pinctrl/stm32-pinfunc.h>
//Example 4 skew-delay and st,io-sync
  pinctrl: pinctrl@44240000 {
          compatible = "st,stm32mp257-pinctrl";
          #address-cells = <1>;
          #size-cells = <1>;
          ranges = <0 0x44240000 0xa0400>;

          eth3_rgmii_pins_a: eth3-rgmii-0 {
                  pins1 {
                          pinmux = <STM32_PINMUX('A', 6, AF14)>;
                          st,io-sync = "data on both edges";
                  };
                  pins2 {
                          pinmux = <STM32_PINMUX('H', 2, AF14)>;
                          skew-delay-output-ps = <500>;
                  };
          };
  };

Source notes #

Annotations retained from the schema source

Line 1: SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)

Line 2: Copyright (C) STMicroelectronics 2019.

Line 253: Not allowed both skew-delay-input-ps and skew-delay-output-ps

Edit this page