Skip to content

Commit 02ef0c5

Browse files
gautierg-stcarlescufi
authored andcommitted
drivers: gpio: stm32: do not resume device when flag is DISCONNECTED
Fix a bug where after a standby, it was impossible to reenable a GPIO clock. A counter is incremented each time pm_device_runtime_get is called, and decremented each time pm_device_runtime_put is called. The clock is only enabled if this counter equals 1. When configuring a GPIO (as input or output), the timer is incremented, and when disconnecting it, it is both incremented and decremented. Thus the next time we try to configuring it, the clock is not enabled (since the counter will now be equal to 2). This causes a problem when using low power standby mode: after wakeup all clocks are disabled and the GPIO clock can not be reenabled. This commit fixes this bug by not incrementing the counter when disconnect is asked (or in other words incrementing it only when configuring either an input or an output). Signed-off-by: Guillaume Gautier <[email protected]>
1 parent 58c296b commit 02ef0c5

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/gpio/gpio_stm32.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -524,9 +524,11 @@ static int gpio_stm32_config(const struct device *dev,
524524
}
525525

526526
/* Enable device clock before configuration (requires bank writes) */
527-
err = pm_device_runtime_get(dev);
528-
if (err < 0) {
529-
return err;
527+
if (((flags & GPIO_OUTPUT) != 0) || ((flags & GPIO_INPUT) != 0)) {
528+
err = pm_device_runtime_get(dev);
529+
if (err < 0) {
530+
return err;
531+
}
530532
}
531533

532534
if ((flags & GPIO_OUTPUT) != 0) {

0 commit comments

Comments
 (0)