Skip to content

Commit eb51ea0

Browse files
erwangogalak
authored andcommitted
soc/arm/st_stm32: stm32wb: Add gpio support
Add GPIO support to stm32wb series. Only ABCDE and H ports are available for now on this series. Accordingly, update series dtsi file. Signed-off-by: Erwan Gouriou <[email protected]>
1 parent d655073 commit eb51ea0

File tree

5 files changed

+142
-0
lines changed

5 files changed

+142
-0
lines changed

drivers/gpio/gpio_stm32.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@
102102
#define STM32_PERIPH_GPIOG LL_AHB2_GRP1_PERIPH_GPIOG
103103
#define STM32_PERIPH_GPIOH LL_AHB2_GRP1_PERIPH_GPIOH
104104
#define STM32_PERIPH_GPIOI LL_AHB2_GRP1_PERIPH_GPIOI
105+
#elif CONFIG_SOC_SERIES_STM32WBX
106+
#define STM32_CLOCK_BUS_GPIO STM32_CLOCK_BUS_AHB2
107+
#define STM32_PERIPH_GPIOA LL_AHB2_GRP1_PERIPH_GPIOA
108+
#define STM32_PERIPH_GPIOB LL_AHB2_GRP1_PERIPH_GPIOB
109+
#define STM32_PERIPH_GPIOC LL_AHB2_GRP1_PERIPH_GPIOC
110+
#define STM32_PERIPH_GPIOD LL_AHB2_GRP1_PERIPH_GPIOD
111+
#define STM32_PERIPH_GPIOE LL_AHB2_GRP1_PERIPH_GPIOE
112+
#define STM32_PERIPH_GPIOH LL_AHB2_GRP1_PERIPH_GPIOH
105113
#endif /* CONFIG_SOC_SERIES_.. */
106114

107115
#ifdef CONFIG_SOC_SERIES_STM32F1X

dts/arm/st/wb/stm32wb.dtsi

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66

77
#include <arm/armv7-m.dtsi>
8+
#include <dt-bindings/clock/stm32_clock.h>
9+
#include <dt-bindings/gpio/gpio.h>
810

911
/ {
1012
cpus {
@@ -46,6 +48,67 @@
4648
reg = <0x58000000 0x400>;
4749
label = "STM32_CLK_RCC";
4850
};
51+
52+
pinctrl: pin-controller@48000000 {
53+
compatible = "st,stm32-pinmux";
54+
#address-cells = <1>;
55+
#size-cells = <1>;
56+
reg = <0x48000000 0x2000>;
57+
58+
gpioa: gpio@48000000 {
59+
compatible = "st,stm32-gpio";
60+
gpio-controller;
61+
#gpio-cells = <2>;
62+
reg = <0x48000000 0x400>;
63+
clocks = <&rcc STM32_CLOCK_BUS_AHB2 0x00000001>;
64+
label = "GPIOA";
65+
};
66+
67+
gpiob: gpio@48000400 {
68+
compatible = "st,stm32-gpio";
69+
gpio-controller;
70+
#gpio-cells = <2>;
71+
reg = <0x48000400 0x400>;
72+
clocks = <&rcc STM32_CLOCK_BUS_AHB2 0x00000002>;
73+
label = "GPIOB";
74+
};
75+
76+
gpioc: gpio@48000800 {
77+
compatible = "st,stm32-gpio";
78+
gpio-controller;
79+
#gpio-cells = <2>;
80+
reg = <0x48000800 0x400>;
81+
clocks = <&rcc STM32_CLOCK_BUS_AHB2 0x00000004>;
82+
label = "GPIOC";
83+
};
84+
85+
gpiod: gpio@48000c00 {
86+
compatible = "st,stm32-gpio";
87+
gpio-controller;
88+
#gpio-cells = <2>;
89+
reg = <0x48000c00 0x400>;
90+
clocks = <&rcc STM32_CLOCK_BUS_AHB2 0x00000008>;
91+
label = "GPIOD";
92+
};
93+
94+
gpioe: gpio@48001000 {
95+
compatible = "st,stm32-gpio";
96+
gpio-controller;
97+
#gpio-cells = <2>;
98+
reg = <0x48001000 0x400>;
99+
clocks = <&rcc STM32_CLOCK_BUS_AHB2 0x00000010>;
100+
label = "GPIOE";
101+
};
102+
103+
gpioh: gpio@48001c00 {
104+
compatible = "st,stm32-gpio";
105+
gpio-controller;
106+
#gpio-cells = <2>;
107+
reg = <0x48001c00 0x400>;
108+
clocks = <&rcc STM32_CLOCK_BUS_AHB2 0x00000080>;
109+
label = "GPIOH";
110+
};
111+
};
49112
};
50113
};
51114

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,17 @@ source "soc/arm/st_stm32/stm32wb/Kconfig.defconfig.stm32wb*"
1212
config SOC_SERIES
1313
default "stm32wb"
1414

15+
if GPIO_STM32
16+
17+
config GPIO_STM32_PORTD
18+
default y
19+
20+
config GPIO_STM32_PORTE
21+
default y
22+
23+
config GPIO_STM32_PORTH
24+
default y
25+
26+
endif # GPIO_STM32
27+
1528
endif # SOC_SERIES_STM32WBX

soc/arm/st_stm32/stm32wb/dts_fixup.h

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,58 @@
88

99
#define DT_NUM_IRQ_PRIO_BITS DT_ARM_V7M_NVIC_E000E100_ARM_NUM_IRQ_PRIORITY_BITS
1010

11+
#define DT_GPIO_STM32_GPIOA_BASE_ADDRESS DT_ST_STM32_GPIO_48000000_BASE_ADDRESS
12+
#define DT_GPIO_STM32_GPIOA_CLOCK_BITS_0 DT_ST_STM32_GPIO_48000000_CLOCK_BITS_0
13+
#define DT_GPIO_STM32_GPIOA_CLOCK_BUS_0 DT_ST_STM32_GPIO_48000000_CLOCK_BUS_0
14+
#define DT_GPIO_STM32_GPIOA_CLOCK_CONTROLLER DT_ST_STM32_GPIO_48000000_CLOCK_CONTROLLER
15+
#define DT_GPIO_STM32_GPIOA_LABEL DT_ST_STM32_GPIO_48000000_LABEL
16+
#define DT_GPIO_STM32_GPIOA_SIZE DT_ST_STM32_GPIO_48000000_SIZE
17+
#define DT_GPIO_STM32_GPIOA_CLOCK_BITS DT_ST_STM32_GPIO_48000000_CLOCK_BITS
18+
#define DT_GPIO_STM32_GPIOA_CLOCK_BUS DT_ST_STM32_GPIO_48000000_CLOCK_BUS
19+
20+
#define DT_GPIO_STM32_GPIOB_BASE_ADDRESS DT_ST_STM32_GPIO_48000400_BASE_ADDRESS
21+
#define DT_GPIO_STM32_GPIOB_CLOCK_BITS_0 DT_ST_STM32_GPIO_48000400_CLOCK_BITS_0
22+
#define DT_GPIO_STM32_GPIOB_CLOCK_BUS_0 DT_ST_STM32_GPIO_48000400_CLOCK_BUS_0
23+
#define DT_GPIO_STM32_GPIOB_CLOCK_CONTROLLER DT_ST_STM32_GPIO_48000400_CLOCK_CONTROLLER
24+
#define DT_GPIO_STM32_GPIOB_LABEL DT_ST_STM32_GPIO_48000400_LABEL
25+
#define DT_GPIO_STM32_GPIOB_SIZE DT_ST_STM32_GPIO_48000400_SIZE
26+
#define DT_GPIO_STM32_GPIOB_CLOCK_BITS DT_ST_STM32_GPIO_48000400_CLOCK_BITS
27+
#define DT_GPIO_STM32_GPIOB_CLOCK_BUS DT_ST_STM32_GPIO_48000400_CLOCK_BUS
28+
29+
#define DT_GPIO_STM32_GPIOC_BASE_ADDRESS DT_ST_STM32_GPIO_48000800_BASE_ADDRESS
30+
#define DT_GPIO_STM32_GPIOC_CLOCK_BITS_0 DT_ST_STM32_GPIO_48000800_CLOCK_BITS_0
31+
#define DT_GPIO_STM32_GPIOC_CLOCK_BUS_0 DT_ST_STM32_GPIO_48000800_CLOCK_BUS_0
32+
#define DT_GPIO_STM32_GPIOC_CLOCK_CONTROLLER DT_ST_STM32_GPIO_48000800_CLOCK_CONTROLLER
33+
#define DT_GPIO_STM32_GPIOC_LABEL DT_ST_STM32_GPIO_48000800_LABEL
34+
#define DT_GPIO_STM32_GPIOC_SIZE DT_ST_STM32_GPIO_48000800_SIZE
35+
#define DT_GPIO_STM32_GPIOC_CLOCK_BITS DT_ST_STM32_GPIO_48000800_CLOCK_BITS
36+
#define DT_GPIO_STM32_GPIOC_CLOCK_BUS DT_ST_STM32_GPIO_48000800_CLOCK_BUS
37+
38+
#define DT_GPIO_STM32_GPIOD_BASE_ADDRESS DT_ST_STM32_GPIO_48000C00_BASE_ADDRESS
39+
#define DT_GPIO_STM32_GPIOD_CLOCK_BITS_0 DT_ST_STM32_GPIO_48000C00_CLOCK_BITS_0
40+
#define DT_GPIO_STM32_GPIOD_CLOCK_BUS_0 DT_ST_STM32_GPIO_48000C00_CLOCK_BUS_0
41+
#define DT_GPIO_STM32_GPIOD_CLOCK_CONTROLLER DT_ST_STM32_GPIO_48000C00_CLOCK_CONTROLLER
42+
#define DT_GPIO_STM32_GPIOD_LABEL DT_ST_STM32_GPIO_48000C00_LABEL
43+
#define DT_GPIO_STM32_GPIOD_SIZE DT_ST_STM32_GPIO_48000C00_SIZE
44+
#define DT_GPIO_STM32_GPIOD_CLOCK_BITS DT_ST_STM32_GPIO_48000C00_CLOCK_BITS
45+
#define DT_GPIO_STM32_GPIOD_CLOCK_BUS DT_ST_STM32_GPIO_48000C00_CLOCK_BUS
46+
47+
#define DT_GPIO_STM32_GPIOE_BASE_ADDRESS DT_ST_STM32_GPIO_48001000_BASE_ADDRESS
48+
#define DT_GPIO_STM32_GPIOE_CLOCK_BITS_0 DT_ST_STM32_GPIO_48001000_CLOCK_BITS_0
49+
#define DT_GPIO_STM32_GPIOE_CLOCK_BUS_0 DT_ST_STM32_GPIO_48001000_CLOCK_BUS_0
50+
#define DT_GPIO_STM32_GPIOE_CLOCK_CONTROLLER DT_ST_STM32_GPIO_48001000_CLOCK_CONTROLLER
51+
#define DT_GPIO_STM32_GPIOE_LABEL DT_ST_STM32_GPIO_48001000_LABEL
52+
#define DT_GPIO_STM32_GPIOE_SIZE DT_ST_STM32_GPIO_48001000_SIZE
53+
#define DT_GPIO_STM32_GPIOE_CLOCK_BITS DT_ST_STM32_GPIO_48001000_CLOCK_BITS
54+
#define DT_GPIO_STM32_GPIOE_CLOCK_BUS DT_ST_STM32_GPIO_48001000_CLOCK_BUS
55+
56+
#define DT_GPIO_STM32_GPIOH_BASE_ADDRESS DT_ST_STM32_GPIO_48001C00_BASE_ADDRESS
57+
#define DT_GPIO_STM32_GPIOH_CLOCK_BITS_0 DT_ST_STM32_GPIO_48001C00_CLOCK_BITS_0
58+
#define DT_GPIO_STM32_GPIOH_CLOCK_BUS_0 DT_ST_STM32_GPIO_48001C00_CLOCK_BUS_0
59+
#define DT_GPIO_STM32_GPIOH_CLOCK_CONTROLLER DT_ST_STM32_GPIO_48001C00_CLOCK_CONTROLLER
60+
#define DT_GPIO_STM32_GPIOH_LABEL DT_ST_STM32_GPIO_48001C00_LABEL
61+
#define DT_GPIO_STM32_GPIOH_SIZE DT_ST_STM32_GPIO_48001C00_SIZE
62+
#define DT_GPIO_STM32_GPIOH_CLOCK_BITS DT_ST_STM32_GPIO_48001C00_CLOCK_BITS
63+
#define DT_GPIO_STM32_GPIOH_CLOCK_BUS DT_ST_STM32_GPIO_48001C00_CLOCK_BUS
64+
1165
/* End of SoC Level DTS fixup file */

soc/arm/st_stm32/stm32wb/soc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
*/
2828
#include <kernel_includes.h>
2929

30+
#ifdef CONFIG_GPIO_STM32
31+
#include <stm32wbxx_ll_gpio.h>
32+
#endif
33+
3034
#ifdef CONFIG_CLOCK_CONTROL_STM32_CUBE
3135
#include <stm32wbxx_ll_utils.h>
3236
#include <stm32wbxx_ll_bus.h>

0 commit comments

Comments
 (0)