The STMicroelectronics STM32MP25 CPU has 12 GPIO ports:
-
8 GPIO ports (named A, B, D to G, I, J) with 16 I/Os
-
2 GPIO ports (named C, H) with 14 I/Os
-
1 GPIO port (named K) with 8 I/Os
-
1 GPIO port (named Z) with 10 I/Os
GPIO naming
STM32MP25 GPIO signals are named on the schematics and hardware reference manual in the form Pxn where:
-
P stands for "port"
-
x is the GPIO port
-
n is the GPIO number within the port
For instance, PA12 refers to GPIOA 12.
GPIOs on the ConnectCore MP25
-
On the ConnectCore MP25 system-on-module:
-
Many of the STM32MP25 GPIOs are available on the system-on-module, multiplexed with other functions.
-
-
On the ConnectCore MP25 Development Kit:
-
The GPIO connector allows direct access to the following STM32MP25 GPIOs:
-
GPIOA 2
-
GPIOA 3
-
GPIOA 5
-
GPIOA 6
-
GPIOA 7
-
GPIOA 9
-
GPIOA 10
-
GPIOD 8
-
GPIOH 2
-
GPIOH 3
-
GPIOH 6
-
GPIOH 7
-
GPIOH 8
-
-
GPIOF 5 is connected to ULED
-
GPIOF 10 is connected to User button and LED 1
-
GPIOF 12 is connected to User button and LED 2
-
See Hardware reference manuals for information about GPIO pins and their multiplexed functionality.
GPIOs on the SOM and carrier board are used for many purposes, such as:
-
Power enable line for transceivers
-
Reset line for controllers
-
LCD backlight control
-
Interrupt line
-
User LED
-
User button
Kernel configuration
Support for STM32MP25 GPIOs is automatically provided through CONFIG_PINCTRL_STM32MP257}, automatically enabled for this CPU.
Kernel driver
The driver for the STM32MP25 GPIO is located at:
| File | Description |
|---|---|
STM32MP25 Pinctrl driver to control GPIOs |
|
STM32MP157 Pinctrl driver |
Device tree bindings and customization
The STM32MP25 GPIO device tree binding is documented at Documentation/devicetree/bindings/pinctrl/st,stm32-pinctrl.yaml.
One GPIO controller is defined for each STM32MP25 GPIO port in the common STM32MP25 device tree file:
pinctrl: pinctrl@44240000 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "st,stm32mp257-pinctrl";
ranges = <0 0x44240000 0xa0400>;
interrupt-parent = <&exti1>;
pins-are-numbered;
interrupts-extended =
<&exti1 0 0>, <&exti1 1 0>, <&exti1 2 0>, <&exti1 3 0>,
<&exti1 4 0>, <&exti1 5 0>, <&exti1 6 0>, <&exti1 7 0>,
<&exti1 8 0>, <&exti1 9 0>, <&exti1 10 0>, <&exti1 11 0>,
<&exti1 12 0>, <&exti1 13 0>, <&exti1 14 0>, <&exti1 15 0>,
<&exti2 0 0>, <&exti2 1 0>, <&exti2 2 0>, <&exti2 3 0>,
<&exti2 4 0>, <&exti2 5 0>, <&exti2 6 0>, <&exti2 7 0>,
<&exti2 8 0>, <&exti2 9 0>, <&exti2 10 0>, <&exti2 11 0>,
<&exti2 12 0>, <&exti2 13 0>, <&exti2 14 0>, <&exti2 15 0>;
gpioa: gpio@44240000 {
gpio-controller;
#gpio-cells = <2>;
interrupt-controller;
#interrupt-cells = <2>;
reg = <0x0 0x400>;
clocks = <&scmi_clk CK_SCMI_GPIOA>;
st,bank-name = "GPIOA";
status = "disabled";
};
};
The ConnectCore MP25 device tree include file and the carrier board device tree files use the STM32MP25 GPIOs.
For example, on the ConnectCore MP25 Development Kit, Port B GPIO 6 is used to reset the PHY of Ethernet interface:
ð2 {
status = "okay";
pinctrl-0 = <ð2_rgmii_pins_a>;
pinctrl-names = "default";
phy-mode = "rgmii-id";
max-speed = <1000>;
phy-handle = <&phy1_eth2>;
st,eth-ptp-from-rcc;
mdio1 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "snps,dwmac-mdio";
phy1_eth2: ethernet-phy@1 {
compatible = "ethernet-phy-id0141.0dd0";
reset-gpios = <&gpiob 6 GPIO_ACTIVE_LOW>;
reset-assert-us = <1000>;
reset-deassert-us = <2000>;
reg = <1>;
};
};
};
IOMUX configuration
For GPIOs that are managed by other drivers, you must define the port, GPIO number, and polarity.
&spi3 {
pinctrl-names = "default", "sleep";
pinctrl-0 = <&spi3_pins_a>;
pinctrl-1 = <&spi3_sleep_pins_a>;
cs-gpios = <&gpiob 1 0>;
status = "okay";
};
Using the GPIOs
The package libgpiod (added by packagegroup-dey-core) provides a set of tools (such as gpioset, gpioget, etc.) to control the GPIOs from user space.
| You can still control the GPIOs from the sysfs, but this API is not recommended. See https://www.kernel.org/doc/html/latest/userspace-api/gpio/sysfs.html. |
Detect GPIO ports
Use gpiodetect to list the GPIO ports detected by the kernel:
# gpiodetect
gpiochip0 [GPIOA] (16 lines)
gpiochip1 [GPIOB] (16 lines)
gpiochip10 [GPIOK] (8 lines)
gpiochip11 [GPIOZ] (10 lines)
gpiochip2 [GPIOC] (14 lines)
gpiochip3 [GPIOD] (16 lines)
gpiochip4 [GPIOE] (16 lines)
gpiochip5 [GPIOF] (16 lines)
gpiochip6 [GPIOG] (16 lines)
gpiochip7 [GPIOH] (14 lines)
gpiochip8 [GPIOI] (16 lines)
gpiochip9 [GPIOJ] (16 lines)
where:
-
Ports
GPIOAtoGPIOJare the STM32MP25 GPIO ports.
Information about a GPIO port
Use gpioinfo to list the lines of a given port:
# gpioinfo GPIOB
gpiochip1 - 16 lines:
line 0: "PB0" kernel input active-high [used]
line 1: "PB1" "spi0 CS0" output active-low [used]
line 2: "PB2" "regulators:regulator-board@2" output active-high [used]
line 3: "PB3" "PHY reset" output active-low [used]
line 4: "PB4" kernel input active-high [used]
line 5: "PB5" kernel input active-high [used]
line 6: "PB6" "PHY reset" output active-low [used]
line 7: "PB7" kernel input active-high [used]
line 8: "PB8" kernel input active-high [used]
line 9: "PB9" kernel input active-high [used]
line 10: "PB10" kernel input active-high [used]
line 11: "PB11" kernel input active-high [used]
line 12: "PB12" kernel input active-high [used]
line 13: "PB13" kernel input active-high [used]
line 14: "PB14" kernel input active-high [used]
line 15: "PB15" "PHY reset" output active-low [used]
Set an output high/low
Use gpioset to set a STM32MP25 GPIO as output, such as GPIOF 5 (ULED).
Use =1 to set it high, or =0 to set it low:
# gpioset GPIOF 5=1
# gpioset GPIOF 5=0
Read an input
Use gpioget to read the value of a STM32MP25 GPIO input, such as GPIOF 5:
# gpioget GPIOF 5
0
Use a GPIO as interrupt
Use gpiomon to wait for an event on a given GPIO, such as PortA GPIO14 (User 2 button):
# gpiomon --num-events 1 --rising-edge GPIOA 14
See the README of libgpiod for more information on these tools.
Sample application
An example application called apix-gpio-example is included in the dey-examples-digiapix recipe (part of dey-examples package) of the meta-digi layer.
This application shows how to manage GPIO lines using the Digi APIx library on the ConnectCore MP25 platform.
|
By default, the Get Started with ConnectCore Cloud Services demo application seizes the user button.
To use the example, stop the
|
Go to GitHub to see the application instructions and source code.
See GPIO API for more information about the GPIO APIx.