Skip to content

Commit dd3ee06

Browse files
FRASTMMaureenHelm
authored andcommitted
drivers: gpio: Add STM32G0X pinmux support
Add gpio support for STM32G0X SoC series. Signed-off-by: Philippe Retornaz <[email protected]> Signed-off-by: Francois Ramu <[email protected]> # Conflicts: # drivers/gpio/gpio_stm32.h
1 parent 9b2025c commit dd3ee06

File tree

5 files changed

+111
-0
lines changed

5 files changed

+111
-0
lines changed

drivers/gpio/gpio_stm32.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@
9696
#define STM32_PERIPH_GPIOI LL_AHB4_GRP1_PERIPH_GPIOI
9797
#define STM32_PERIPH_GPIOJ LL_AHB4_GRP1_PERIPH_GPIOJ
9898
#define STM32_PERIPH_GPIOK LL_AHB4_GRP1_PERIPH_GPIOK
99+
#elif CONFIG_SOC_SERIES_STM32G0X
100+
#define STM32_CLOCK_BUS_GPIO STM32_CLOCK_BUS_IOP
101+
#define STM32_PERIPH_GPIOA LL_IOP_GRP1_PERIPH_GPIOA
102+
#define STM32_PERIPH_GPIOB LL_IOP_GRP1_PERIPH_GPIOB
103+
#define STM32_PERIPH_GPIOC LL_IOP_GRP1_PERIPH_GPIOC
104+
#define STM32_PERIPH_GPIOD LL_IOP_GRP1_PERIPH_GPIOD
105+
#define STM32_PERIPH_GPIOF LL_IOP_GRP1_PERIPH_GPIOF
99106
#elif CONFIG_SOC_SERIES_STM32L0X
100107
#define STM32_CLOCK_BUS_GPIO STM32_CLOCK_BUS_IOP
101108
#define STM32_PERIPH_GPIOA LL_IOP_GRP1_PERIPH_GPIOA

dts/arm/st/g0/stm32g0.dtsi

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,51 @@
5959
#address-cells = <1>;
6060
#size-cells = <1>;
6161
reg = <0x50000000 0x2000>;
62+
63+
gpioa: gpio@50000000 {
64+
compatible = "st,stm32-gpio";
65+
gpio-controller;
66+
#gpio-cells = <2>;
67+
reg = <0x50000000 0x400>;
68+
clocks = <&rcc STM32_CLOCK_BUS_IOP 0x00000001>;
69+
label = "GPIOA";
70+
};
71+
72+
gpiob: gpio@50000400 {
73+
compatible = "st,stm32-gpio";
74+
gpio-controller;
75+
#gpio-cells = <2>;
76+
reg = <0x50000400 0x400>;
77+
clocks = <&rcc STM32_CLOCK_BUS_IOP 0x00000002>;
78+
label = "GPIOB";
79+
};
80+
81+
gpioc: gpio@50000800 {
82+
compatible = "st,stm32-gpio";
83+
gpio-controller;
84+
#gpio-cells = <2>;
85+
reg = <0x50000800 0x400>;
86+
clocks = <&rcc STM32_CLOCK_BUS_IOP 0x00000004>;
87+
label = "GPIOC";
88+
};
89+
90+
gpiod: gpio@50000c00 {
91+
compatible = "st,stm32-gpio";
92+
gpio-controller;
93+
#gpio-cells = <2>;
94+
reg = <0x50000c00 0x400>;
95+
clocks = <&rcc STM32_CLOCK_BUS_IOP 0x00000008>;
96+
label = "GPIOD";
97+
};
98+
99+
gpiof: gpio@50001400 {
100+
compatible = "st,stm32-gpio";
101+
gpio-controller;
102+
#gpio-cells = <2>;
103+
reg = <0x50001400 0x400>;
104+
clocks = <&rcc STM32_CLOCK_BUS_IOP 0x00000020>;
105+
label = "GPIOF";
106+
};
62107
};
63108

64109
timers3: timers@40000400 {

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ config SOC_SERIES
1515

1616
if GPIO_STM32
1717

18+
# GPIO ports A, B and C are set in ../common/Kconfig.defconfig.series
19+
20+
config GPIO_STM32_PORTD
21+
default y
22+
23+
config GPIO_STM32_PORTF
24+
default y
25+
1826
endif # GPIO_STM32
1927

2028
endif # SOC_SERIES_STM32G0X

soc/arm/st_stm32/stm32g0/dts_fixup.h

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,51 @@
1414
#define DT_PWM_STM32_3_DEV_NAME DT_ST_STM32_PWM_40000400_PWM_LABEL
1515
#define DT_PWM_STM32_3_PRESCALER DT_ST_STM32_PWM_40000400_PWM_ST_PRESCALER
1616

17+
/* there is no reference to GPIOE, GPIOG and GPIOH in the dts files */
18+
19+
#define DT_GPIO_STM32_GPIOA_BASE_ADDRESS DT_ST_STM32_GPIO_50000000_BASE_ADDRESS
20+
#define DT_GPIO_STM32_GPIOA_CLOCK_BITS_0 DT_ST_STM32_GPIO_50000000_CLOCK_BITS_0
21+
#define DT_GPIO_STM32_GPIOA_CLOCK_BUS_0 DT_ST_STM32_GPIO_50000000_CLOCK_BUS_0
22+
#define DT_GPIO_STM32_GPIOA_CLOCK_CONTROLLER DT_ST_STM32_GPIO_50000000_CLOCK_CONTROLLER
23+
#define DT_GPIO_STM32_GPIOA_LABEL DT_ST_STM32_GPIO_50000000_LABEL
24+
#define DT_GPIO_STM32_GPIOA_SIZE DT_ST_STM32_GPIO_50000000_SIZE
25+
#define DT_GPIO_STM32_GPIOA_CLOCK_BITS DT_ST_STM32_GPIO_50000000_CLOCK_BITS
26+
#define DT_GPIO_STM32_GPIOA_CLOCK_BUS DT_ST_STM32_GPIO_50000000_CLOCK_BUS
27+
28+
#define DT_GPIO_STM32_GPIOB_BASE_ADDRESS DT_ST_STM32_GPIO_50000400_BASE_ADDRESS
29+
#define DT_GPIO_STM32_GPIOB_CLOCK_BITS_0 DT_ST_STM32_GPIO_50000400_CLOCK_BITS_0
30+
#define DT_GPIO_STM32_GPIOB_CLOCK_BUS_0 DT_ST_STM32_GPIO_50000400_CLOCK_BUS_0
31+
#define DT_GPIO_STM32_GPIOB_CLOCK_CONTROLLER DT_ST_STM32_GPIO_50000400_CLOCK_CONTROLLER
32+
#define DT_GPIO_STM32_GPIOB_LABEL DT_ST_STM32_GPIO_50000400_LABEL
33+
#define DT_GPIO_STM32_GPIOB_SIZE DT_ST_STM32_GPIO_50000400_SIZE
34+
#define DT_GPIO_STM32_GPIOB_CLOCK_BITS DT_ST_STM32_GPIO_50000400_CLOCK_BITS
35+
#define DT_GPIO_STM32_GPIOB_CLOCK_BUS DT_ST_STM32_GPIO_50000400_CLOCK_BUS
36+
37+
#define DT_GPIO_STM32_GPIOC_BASE_ADDRESS DT_ST_STM32_GPIO_50000800_BASE_ADDRESS
38+
#define DT_GPIO_STM32_GPIOC_CLOCK_BITS_0 DT_ST_STM32_GPIO_50000800_CLOCK_BITS_0
39+
#define DT_GPIO_STM32_GPIOC_CLOCK_BUS_0 DT_ST_STM32_GPIO_50000800_CLOCK_BUS_0
40+
#define DT_GPIO_STM32_GPIOC_CLOCK_CONTROLLER DT_ST_STM32_GPIO_50000800_CLOCK_CONTROLLER
41+
#define DT_GPIO_STM32_GPIOC_LABEL DT_ST_STM32_GPIO_50000800_LABEL
42+
#define DT_GPIO_STM32_GPIOC_SIZE DT_ST_STM32_GPIO_50000800_SIZE
43+
#define DT_GPIO_STM32_GPIOC_CLOCK_BITS DT_ST_STM32_GPIO_50000800_CLOCK_BITS
44+
#define DT_GPIO_STM32_GPIOC_CLOCK_BUS DT_ST_STM32_GPIO_50000800_CLOCK_BUS
45+
46+
#define DT_GPIO_STM32_GPIOD_BASE_ADDRESS DT_ST_STM32_GPIO_50000C00_BASE_ADDRESS
47+
#define DT_GPIO_STM32_GPIOD_CLOCK_BITS_0 DT_ST_STM32_GPIO_50000C00_CLOCK_BITS_0
48+
#define DT_GPIO_STM32_GPIOD_CLOCK_BUS_0 DT_ST_STM32_GPIO_50000C00_CLOCK_BUS_0
49+
#define DT_GPIO_STM32_GPIOD_CLOCK_CONTROLLER DT_ST_STM32_GPIO_50000C00_CLOCK_CONTROLLER
50+
#define DT_GPIO_STM32_GPIOD_LABEL DT_ST_STM32_GPIO_50000C00_LABEL
51+
#define DT_GPIO_STM32_GPIOD_SIZE DT_ST_STM32_GPIO_50000C00_SIZE
52+
#define DT_GPIO_STM32_GPIOD_CLOCK_BITS DT_ST_STM32_GPIO_50000C00_CLOCK_BITS
53+
#define DT_GPIO_STM32_GPIOD_CLOCK_BUS DT_ST_STM32_GPIO_50000C00_CLOCK_BUS
54+
55+
#define DT_GPIO_STM32_GPIOF_BASE_ADDRESS DT_ST_STM32_GPIO_50001400_BASE_ADDRESS
56+
#define DT_GPIO_STM32_GPIOF_CLOCK_BITS_0 DT_ST_STM32_GPIO_50001400_CLOCK_BITS_0
57+
#define DT_GPIO_STM32_GPIOF_CLOCK_BUS_0 DT_ST_STM32_GPIO_50001400_CLOCK_BUS_0
58+
#define DT_GPIO_STM32_GPIOF_CLOCK_CONTROLLER DT_ST_STM32_GPIO_50001400_CLOCK_CONTROLLER
59+
#define DT_GPIO_STM32_GPIOF_LABEL DT_ST_STM32_GPIO_50001400_LABEL
60+
#define DT_GPIO_STM32_GPIOF_SIZE DT_ST_STM32_GPIO_50001400_SIZE
61+
#define DT_GPIO_STM32_GPIOF_CLOCK_BITS DT_ST_STM32_GPIO_50001400_CLOCK_BITS
62+
#define DT_GPIO_STM32_GPIOF_CLOCK_BUS DT_ST_STM32_GPIO_50001400_CLOCK_BUS
63+
1764
/* End of SoC Level DTS fixup file */

soc/arm/st_stm32/stm32g0/soc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
#include <stm32g0xx_ll_rcc.h>
3737
#endif /* CONFIG_CLOCK_CONTROL_STM32_CUBE */
3838

39+
#ifdef CONFIG_GPIO_STM32
40+
#include <stm32g0xx_ll_gpio.h>
41+
#endif
42+
3943
#endif /* !_ASMLANGUAGE */
4044

4145
#endif /* _STM32G0_SOC_H_ */

0 commit comments

Comments
 (0)