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 <guillaume.gautier-ext@st.com>
This commit is contained in:
parent
58c296b30f
commit
02ef0c5fb9
@ -524,9 +524,11 @@ static int gpio_stm32_config(const struct device *dev,
|
||||
}
|
||||
|
||||
/* Enable device clock before configuration (requires bank writes) */
|
||||
err = pm_device_runtime_get(dev);
|
||||
if (err < 0) {
|
||||
return err;
|
||||
if (((flags & GPIO_OUTPUT) != 0) || ((flags & GPIO_INPUT) != 0)) {
|
||||
err = pm_device_runtime_get(dev);
|
||||
if (err < 0) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
if ((flags & GPIO_OUTPUT) != 0) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user