Skip to content

Commit 41fe3b9

Browse files
JordanYateskartben
authored andcommitted
gpio: stm32: initialise according to zephyr,pm-device-runtime-auto
Don't automatically disable all GPIO ports just because `PM_DEVICE_RUNTIME` is enabled. Require the user to explicitly call `pm_device_runtime_enable` on the port, or add `zephyr,pm-device-runtime-auto` to the devicetree node. Signed-off-by: Jordan Yates <[email protected]>
1 parent 3bf1ee7 commit 41fe3b9

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

drivers/gpio/gpio_stm32.c

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,6 @@ static DEVICE_API(gpio, gpio_stm32_driver) = {
679679
.manage_callback = gpio_stm32_manage_callback,
680680
};
681681

682-
#ifdef CONFIG_PM_DEVICE
683682
static int gpio_stm32_pm_action(const struct device *dev,
684683
enum pm_device_action action)
685684
{
@@ -688,13 +687,15 @@ static int gpio_stm32_pm_action(const struct device *dev,
688687
return gpio_stm32_clock_request(dev, true);
689688
case PM_DEVICE_ACTION_SUSPEND:
690689
return gpio_stm32_clock_request(dev, false);
690+
case PM_DEVICE_ACTION_TURN_OFF:
691+
case PM_DEVICE_ACTION_TURN_ON:
692+
break;
691693
default:
692694
return -ENOTSUP;
693695
}
694696

695697
return 0;
696698
}
697-
#endif /* CONFIG_PM_DEVICE */
698699

699700

700701
/**
@@ -710,7 +711,6 @@ static int gpio_stm32_pm_action(const struct device *dev,
710711
static int gpio_stm32_init(const struct device *dev)
711712
{
712713
struct gpio_stm32_data *data = dev->data;
713-
int ret;
714714

715715
data->dev = dev;
716716

@@ -726,18 +726,8 @@ static int gpio_stm32_init(const struct device *dev)
726726
LL_PWR_EnableVddIO2();
727727
z_stm32_hsem_unlock(CFG_HW_RCC_SEMID);
728728
#endif
729-
/* enable port clock (if runtime PM is not enabled) */
730-
ret = gpio_stm32_clock_request(dev, !IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME));
731-
if (ret < 0) {
732-
return ret;
733-
}
734-
735-
if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) {
736-
pm_device_init_suspended(dev);
737-
}
738-
(void)pm_device_runtime_enable(dev);
739729

740-
return 0;
730+
return pm_device_driver_init(dev, gpio_stm32_pm_action);
741731
}
742732

743733
#define GPIO_DEVICE_INIT(__node, __suffix, __base_addr, __port, __cenr, __bus) \

0 commit comments

Comments
 (0)