Skip to content

Commit b4b7020

Browse files
yboutreuxgalak
authored andcommitted
gpio: Add stm32mp157c_dk2 board support
Add support for stm32mp1x GPIO with Zephyr GPIO driver Signed-off-by: Yaël Boutreux <[email protected]> Signed-off-by: Arnaud Pouliquen <[email protected]> Signed-off-by: Alexandre Torgue <[email protected]>
1 parent 524c625 commit b4b7020

File tree

9 files changed

+349
-1
lines changed

9 files changed

+349
-1
lines changed

boards/arm/stm32mp157c_dk2/doc/stm32mp157_dk2.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ features:
168168
+===========+============+=====================================+
169169
| NVIC | on-chip | nested vector interrupt controller |
170170
+-----------+------------+-------------------------------------+
171+
| GPIO | on-chip | gpio |
172+
+-----------+------------+-------------------------------------+
171173

172174
The default configuration can be found in the defconfig file:
173175
``boards/arm/stm32mp157c_dk2/stm32mp157c_dk2_defconfig``

boards/arm/stm32mp157c_dk2/stm32mp157c_dk2.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ toolchain:
66
- zephyr
77
- gccarmemb
88
- xtools
9+
supported:
10+
- gpio
911
testing:
1012
ignore_tags:
1113
- cmsis_rtos_v2
@@ -17,7 +19,6 @@ testing:
1719
- cmm
1820
- shell
1921
- LED
20-
- gpio
2122
- nfc
2223
ram: 256
2324
flash: 64

boards/arm/stm32mp157c_dk2/stm32mp157c_dk2_defconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ CONFIG_CORTEX_M_SYSTICK=y
66
# 209 MHz system clock
77
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=209000000
88

9+
# enable GPIO
10+
CONFIG_GPIO=y
11+
912
# clock configuration
1013
CONFIG_CLOCK_CONTROL=y
1114

drivers/gpio/gpio_stm32.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ const int gpio_stm32_enable_int(int port, int pin)
214214
#if defined(CONFIG_SOC_SERIES_STM32L0X) || \
215215
defined(CONFIG_SOC_SERIES_STM32F0X)
216216
line = ((pin % 4 * 4) << 16) | (pin / 4);
217+
#elif defined(CONFIG_SOC_SERIES_STM32MP1X)
218+
line = (((pin * 8) % 32) << 16) | (pin / 4);
217219
#else
218220
line = (0xF << ((pin % 4 * 4) + 16)) | (pin / 4);
219221
#endif
@@ -231,6 +233,8 @@ const int gpio_stm32_enable_int(int port, int pin)
231233

232234
#ifdef CONFIG_SOC_SERIES_STM32F1X
233235
LL_GPIO_AF_SetEXTISource(port, line);
236+
#elif CONFIG_SOC_SERIES_STM32MP1X
237+
LL_EXTI_SetEXTISource(port, line);
234238
#else
235239
LL_SYSCFG_SetEXTISource(port, line);
236240
#endif

drivers/gpio/gpio_stm32.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,19 @@
112112
#define STM32_PERIPH_GPIOG LL_AHB2_GRP1_PERIPH_GPIOG
113113
#define STM32_PERIPH_GPIOH LL_AHB2_GRP1_PERIPH_GPIOH
114114
#define STM32_PERIPH_GPIOI LL_AHB2_GRP1_PERIPH_GPIOI
115+
#elif CONFIG_SOC_SERIES_STM32MP1X
116+
#define STM32_CLOCK_BUS_GPIO STM32_CLOCK_BUS_AHB4
117+
#define STM32_PERIPH_GPIOA LL_AHB4_GRP1_PERIPH_GPIOA
118+
#define STM32_PERIPH_GPIOB LL_AHB4_GRP1_PERIPH_GPIOB
119+
#define STM32_PERIPH_GPIOC LL_AHB4_GRP1_PERIPH_GPIOC
120+
#define STM32_PERIPH_GPIOD LL_AHB4_GRP1_PERIPH_GPIOD
121+
#define STM32_PERIPH_GPIOE LL_AHB4_GRP1_PERIPH_GPIOE
122+
#define STM32_PERIPH_GPIOF LL_AHB4_GRP1_PERIPH_GPIOF
123+
#define STM32_PERIPH_GPIOG LL_AHB4_GRP1_PERIPH_GPIOG
124+
#define STM32_PERIPH_GPIOH LL_AHB4_GRP1_PERIPH_GPIOH
125+
#define STM32_PERIPH_GPIOI LL_AHB4_GRP1_PERIPH_GPIOI
126+
#define STM32_PERIPH_GPIOJ LL_AHB4_GRP1_PERIPH_GPIOJ
127+
#define STM32_PERIPH_GPIOK LL_AHB4_GRP1_PERIPH_GPIOK
115128
#elif CONFIG_SOC_SERIES_STM32WBX
116129
#define STM32_CLOCK_BUS_GPIO STM32_CLOCK_BUS_AHB2
117130
#define STM32_PERIPH_GPIOA LL_AHB2_GRP1_PERIPH_GPIOA

dts/arm/st/mp1/stm32mp157.dtsi

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
#include <mem.h>
88
#include <arm/armv7-m.dtsi>
9+
#include <dt-bindings/gpio/gpio.h>
10+
#include <dt-bindings/clock/stm32_clock.h>
911

1012
/ {
1113
cpus {
@@ -39,6 +41,111 @@
3941
label = "STM32_CLK_RCC";
4042
};
4143

44+
pinctrl: pin-controller@50002000 {
45+
compatible = "st,stm32-pinmux";
46+
reg = <0x50002000 0x9000>;
47+
#address-cells = <1>;
48+
#size-cells = <1>;
49+
50+
gpioa: gpio@50002000 {
51+
compatible = "st,stm32-gpio";
52+
reg = <0x50002000 0x400>;
53+
gpio-controller;
54+
#gpio-cells = <2>;
55+
clocks = <&rcc STM32_CLOCK_BUS_AHB4 0x00000001>;
56+
label = "GPIOA";
57+
};
58+
59+
gpiob: gpio@50003000 {
60+
compatible = "st,stm32-gpio";
61+
reg = <0x50003000 0x400>;
62+
gpio-controller;
63+
#gpio-cells = <2>;
64+
clocks = <&rcc STM32_CLOCK_BUS_AHB4 0x00000002>;
65+
label = "GPIOB";
66+
};
67+
68+
gpioc: gpio@50004000 {
69+
compatible = "st,stm32-gpio";
70+
reg = <0x50004000 0x400>;
71+
gpio-controller;
72+
#gpio-cells = <2>;
73+
clocks = <&rcc STM32_CLOCK_BUS_AHB4 0x00000004>;
74+
label = "GPIOC";
75+
};
76+
77+
gpiod: gpio@50005000 {
78+
compatible = "st,stm32-gpio";
79+
reg = <0x50005000 0x400>;
80+
gpio-controller;
81+
#gpio-cells = <2>;
82+
clocks = <&rcc STM32_CLOCK_BUS_AHB4 0x00000008>;
83+
label = "GPIOD";
84+
};
85+
86+
gpioe: gpio@50006000 {
87+
compatible = "st,stm32-gpio";
88+
reg = <0x50006000 0x400>;
89+
gpio-controller;
90+
#gpio-cells = <2>;
91+
clocks = <&rcc STM32_CLOCK_BUS_AHB4 0x00000010>;
92+
label = "GPIOE";
93+
};
94+
95+
gpiof: gpio@50007000 {
96+
compatible = "st,stm32-gpio";
97+
reg = <0x50007000 0x400>;
98+
gpio-controller;
99+
#gpio-cells = <2>;
100+
clocks = <&rcc STM32_CLOCK_BUS_AHB4 0x00000020>;
101+
label = "GPIOF";
102+
};
103+
104+
gpiog: gpio@50008000 {
105+
compatible = "st,stm32-gpio";
106+
reg = <0x50008000 0x400>;
107+
gpio-controller;
108+
#gpio-cells = <2>;
109+
clocks = <&rcc STM32_CLOCK_BUS_AHB4 0x00000040>;
110+
label = "GPIOG";
111+
};
112+
113+
gpioh: gpio@50009000 {
114+
compatible = "st,stm32-gpio";
115+
reg = <0x50009000 0x400>;
116+
gpio-controller;
117+
#gpio-cells = <2>;
118+
clocks = <&rcc STM32_CLOCK_BUS_AHB4 0x00000080>;
119+
label = "GPIOH";
120+
};
121+
122+
gpioi: gpio@5000a000 {
123+
compatible = "st,stm32-gpio";
124+
reg = <0x5000a000 0x400>;
125+
gpio-controller;
126+
#gpio-cells = <2>;
127+
clocks = <&rcc STM32_CLOCK_BUS_AHB4 0x00000100>;
128+
label = "GPIOI";
129+
};
130+
131+
gpioj: gpio@5000b000 {
132+
compatible = "st,stm32-gpio";
133+
reg = <0x5000b000 0x400>;
134+
gpio-controller;
135+
#gpio-cells = <2>;
136+
clocks = <&rcc STM32_CLOCK_BUS_AHB4 0x00000200>;
137+
label = "GPIOJ";
138+
};
139+
140+
gpiok: gpio@5000c000 {
141+
compatible = "st,stm32-gpio";
142+
reg = <0x5000c000 0x400>;
143+
gpio-controller;
144+
#gpio-cells = <2>;
145+
clocks = <&rcc STM32_CLOCK_BUS_AHB4 0x00000400>;
146+
label = "GPIOK";
147+
};
148+
};
42149
};
43150
};
44151

soc/arm/st_stm32/stm32mp1/Kconfig.defconfig.series

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,32 @@ config STM32_CORE_CM4
1616
bool "define stm32 core"
1717
default y
1818

19+
if GPIO_STM32
20+
21+
config GPIO_STM32_PORTD
22+
default y
23+
24+
config GPIO_STM32_PORTE
25+
default y
26+
27+
config GPIO_STM32_PORTF
28+
default y
29+
30+
config GPIO_STM32_PORTG
31+
default y
32+
33+
config GPIO_STM32_PORTH
34+
default y
35+
36+
config GPIO_STM32_PORTI
37+
default y
38+
39+
config GPIO_STM32_PORTJ
40+
default y
41+
42+
config GPIO_STM32_PORTK
43+
default y
44+
45+
endif # GPIO_STM32
46+
1947
endif # SOC_SERIES_STM32MP1X

0 commit comments

Comments
 (0)