Skip to content

Commit cba339a

Browse files
mrrosencarlescufi
authored andcommitted
dts: arm: st: correct npgios for all stm32 gpio controllers
For almost all STM32 GPIO controllers, the number of supported GPIO pins managed by a single controller is 16 (with some exceptions for fewer). However, the default for ngpios in the device tree bindings for gpio-controllers is 32; leading to inaccuracies in handling GPIO for these controllers, such as presenting too many GPIOs in the GPIO shell. This patch redefines the default for ngpios for "st,stm32-gpio" compatible devices to 16 and adds the correct ngpios for the few exceptions Zephyr current supports. Signed-off-by: Michael R Rosen <[email protected]>
1 parent 0e4e762 commit cba339a

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

dts/arm/st/l4/stm32l496.dtsi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
compatible = "st,stm32-gpio";
4545
gpio-controller;
4646
#gpio-cells = <2>;
47+
ngpios = <12>;
4748
reg = <0x48002000 0x400>;
4849
clocks = <&rcc STM32_CLOCK_BUS_AHB2 0x00000100>;
4950
};

dts/arm/st/wb/stm32wb.dtsi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@
228228
compatible = "st,stm32-gpio";
229229
gpio-controller;
230230
#gpio-cells = <2>;
231+
ngpios = <5>;
231232
reg = <0x48001000 0x400>;
232233
clocks = <&rcc STM32_CLOCK_BUS_AHB2 0x00000010>;
233234
};
@@ -236,6 +237,7 @@
236237
compatible = "st,stm32-gpio";
237238
gpio-controller;
238239
#gpio-cells = <2>;
240+
ngpios = <4>;
239241
reg = <0x48001c00 0x400>;
240242
clocks = <&rcc STM32_CLOCK_BUS_AHB2 0x00000080>;
241243
};

dts/bindings/gpio/st,stm32-gpio.yaml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ description: STM32 GPIO node
55

66
compatible: "st,stm32-gpio"
77

8-
include: [gpio-controller.yaml, base.yaml]
8+
include:
9+
- name: gpio-controller.yaml
10+
property-blocklist:
11+
- ngpios
12+
- name: base.yaml
913

1014
properties:
1115
reg:
@@ -17,6 +21,19 @@ properties:
1721
"#gpio-cells":
1822
const: 2
1923

24+
ngpios:
25+
type: int
26+
default: 16
27+
description: |
28+
This property indicates the number of in-use slots of available slots
29+
for GPIOs. The STM32 GPIO controller typically has all 16 possible port
30+
IO with few exceptions. It should only be necessary to explicitly set
31+
this property if the controller itself does not implement all 16 port
32+
IO register bits; for example PORTE in the STM32WB55xx series which only
33+
implements the first 5. Package restrictions on the number of exposed
34+
GPIO should not influence this property. For cases in which there might
35+
be holes in the slot range, this value should be the max slot number+1.
36+
2037
gpio-cells:
2138
- pin
2239
- flags

0 commit comments

Comments
 (0)