Skip to content

Commit 34c51c5

Browse files
bjarki-andreasenkartben
authored andcommitted
pm: device: runtime: add PM_DEVICE_RUNTIME_DEFAULT_ENABLE
Many SoCs which use PM_DEVICE_RUNTIME need every device in the system to have PM_DEVICE_RUNTIME enabled to function. Currently, this is only possible by adding zephyr,pm-device-runtime-auto; to every node in every devicetree which could potentially implement device power management. This is very error prone since its easy to miss a node, especially if users apply overlays, where users need to know and remember to apply or reapply this property. This commit adds a Kconfig, disabled by default, which automatically treats every device as if it had the zephyr,pm-device-runtime-auto property added to every node. Signed-off-by: Bjarki Arge Andreasen <[email protected]>
1 parent ed0fa4a commit 34c51c5

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

subsys/pm/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,15 @@ endif #PM_DEVICE_RUNTIME_USE_DEDICATED_WQ
177177
endchoice
178178

179179
endif # PM_DEVICE_RUNTIME_ASYNC
180+
181+
config PM_DEVICE_RUNTIME_DEFAULT_ENABLE
182+
bool "PM device runtime enable by default"
183+
help
184+
Enable PM device runtime by default for all devices when they are
185+
initialized. This option is identical to adding the devicetree
186+
property zephyr,pm-device-runtime-auto to all nodes in the
187+
devicetree.
188+
180189
endif # PM_DEVICE_RUNTIME
181190

182191
config PM_DEVICE_SHELL

subsys/pm/device.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,8 @@ int pm_device_driver_init(const struct device *dev,
388388

389389
/* If device will have PM device runtime enabled */
390390
if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME) &&
391-
atomic_test_bit(&pm->flags, PM_DEVICE_FLAG_RUNTIME_AUTO)) {
391+
(IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME_DEFAULT_ENABLE) ||
392+
atomic_test_bit(&pm->flags, PM_DEVICE_FLAG_RUNTIME_AUTO))) {
392393
return 0;
393394
}
394395

subsys/pm/device_runtime.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,10 +401,15 @@ int pm_device_runtime_auto_enable(const struct device *dev)
401401
{
402402
struct pm_device_base *pm = dev->pm_base;
403403

404-
/* No action needed if PM_DEVICE_FLAG_RUNTIME_AUTO is not enabled */
405-
if (!pm || !atomic_test_bit(&pm->flags, PM_DEVICE_FLAG_RUNTIME_AUTO)) {
404+
if (!pm) {
406405
return 0;
407406
}
407+
408+
if (!IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME_DEFAULT_ENABLE) &&
409+
!atomic_test_bit(&pm->flags, PM_DEVICE_FLAG_RUNTIME_AUTO)) {
410+
return 0;
411+
}
412+
408413
return pm_device_runtime_enable(dev);
409414
}
410415

0 commit comments

Comments
 (0)