pm: device: Make power domain optional
Add a Kconfig symbol to enable/disable power domain on Zephyr. Disabling power domain save some memory / space. Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
parent
ddfa048058
commit
2e732dff6d
3 changed files with 35 additions and 9 deletions
|
@ -110,14 +110,16 @@ struct pm_device {
|
||||||
/** Event conditional var to listen to the sync request events */
|
/** Event conditional var to listen to the sync request events */
|
||||||
struct k_condvar condvar;
|
struct k_condvar condvar;
|
||||||
#endif /* CONFIG_PM_DEVICE_RUNTIME */
|
#endif /* CONFIG_PM_DEVICE_RUNTIME */
|
||||||
|
#ifdef CONFIG_PM_DEVICE_POWER_DOMAIN
|
||||||
|
/** Power Domain it belongs */
|
||||||
|
const struct device *domain;
|
||||||
|
#endif /* CONFIG_PM_DEVICE_POWER_DOMAIN */
|
||||||
/* Device PM status flags. */
|
/* Device PM status flags. */
|
||||||
atomic_t flags;
|
atomic_t flags;
|
||||||
/** Device power state */
|
/** Device power state */
|
||||||
enum pm_device_state state;
|
enum pm_device_state state;
|
||||||
/** Device PM action callback */
|
/** Device PM action callback */
|
||||||
pm_device_action_cb_t action_cb;
|
pm_device_action_cb_t action_cb;
|
||||||
/** Power Domain it belongs */
|
|
||||||
const struct device *domain;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_PM_DEVICE_RUNTIME
|
#ifdef CONFIG_PM_DEVICE_RUNTIME
|
||||||
|
@ -128,6 +130,14 @@ struct pm_device {
|
||||||
#define Z_PM_DEVICE_RUNTIME_INIT(obj)
|
#define Z_PM_DEVICE_RUNTIME_INIT(obj)
|
||||||
#endif /* CONFIG_PM_DEVICE_RUNTIME */
|
#endif /* CONFIG_PM_DEVICE_RUNTIME */
|
||||||
|
|
||||||
|
#ifdef CONFIG_PM_DEVICE_POWER_DOMAIN
|
||||||
|
#define Z_PM_DEVICE_POWER_DOMAIN_INIT(_node_id) \
|
||||||
|
.domain = DEVICE_DT_GET_OR_NULL(DT_PHANDLE(_node_id, \
|
||||||
|
power_domain)),
|
||||||
|
#else
|
||||||
|
#define Z_PM_DEVICE_POWER_DOMAIN_INIT(obj)
|
||||||
|
#endif /* CONFIG_PM_DEVICE_POWER_DOMAIN */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Utility macro to initialize #pm_device.
|
* @brief Utility macro to initialize #pm_device.
|
||||||
*
|
*
|
||||||
|
@ -147,7 +157,7 @@ struct pm_device {
|
||||||
DT_NODE_EXISTS(node_id), \
|
DT_NODE_EXISTS(node_id), \
|
||||||
(DT_PROP_OR(node_id, wakeup_source, 0)),\
|
(DT_PROP_OR(node_id, wakeup_source, 0)),\
|
||||||
(0)) << PM_DEVICE_FLAG_WS_CAPABLE), \
|
(0)) << PM_DEVICE_FLAG_WS_CAPABLE), \
|
||||||
.domain = DEVICE_DT_GET_OR_NULL(DT_PHANDLE(node_id, power_domain))\
|
Z_PM_DEVICE_POWER_DOMAIN_INIT(node_id) \
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -54,6 +54,15 @@ module = PM_DEVICE
|
||||||
module-str = Device Power Management
|
module-str = Device Power Management
|
||||||
source "subsys/logging/Kconfig.template.log_config"
|
source "subsys/logging/Kconfig.template.log_config"
|
||||||
|
|
||||||
|
config PM_DEVICE_POWER_DOMAIN
|
||||||
|
bool "Enable power domain"
|
||||||
|
depends on PM_DEVICE
|
||||||
|
default y
|
||||||
|
help
|
||||||
|
Enable support for Power Domain. With power domain enabled,
|
||||||
|
devices that depend on a domain will be notified when this
|
||||||
|
domain is suspended or resumed.
|
||||||
|
|
||||||
config PM_DEVICE_RUNTIME
|
config PM_DEVICE_RUNTIME
|
||||||
bool "Runtime Device Power Management"
|
bool "Runtime Device Power Management"
|
||||||
help
|
help
|
||||||
|
|
|
@ -12,6 +12,13 @@
|
||||||
#include <logging/log.h>
|
#include <logging/log.h>
|
||||||
LOG_MODULE_DECLARE(pm_device, CONFIG_PM_DEVICE_LOG_LEVEL);
|
LOG_MODULE_DECLARE(pm_device, CONFIG_PM_DEVICE_LOG_LEVEL);
|
||||||
|
|
||||||
|
#ifdef CONFIG_PM_DEVICE_POWER_DOMAIN
|
||||||
|
#define PM_DOMAIN(_pm) \
|
||||||
|
(_pm)->domain
|
||||||
|
#else
|
||||||
|
#define PM_DOMAIN(_pm) NULL
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Suspend a device
|
* @brief Suspend a device
|
||||||
*
|
*
|
||||||
|
@ -99,8 +106,8 @@ static void runtime_suspend_work(struct k_work *work)
|
||||||
* On async put, we have to suspend the domain when the device
|
* On async put, we have to suspend the domain when the device
|
||||||
* finishes its operation
|
* finishes its operation
|
||||||
*/
|
*/
|
||||||
if (pm->domain != NULL) {
|
if (PM_DOMAIN(pm) != NULL) {
|
||||||
(void)pm_device_runtime_put(pm->domain);
|
(void)pm_device_runtime_put(PM_DOMAIN(pm));
|
||||||
}
|
}
|
||||||
|
|
||||||
__ASSERT(ret == 0, "Could not suspend device (%d)", ret);
|
__ASSERT(ret == 0, "Could not suspend device (%d)", ret);
|
||||||
|
@ -125,8 +132,8 @@ int pm_device_runtime_get(const struct device *dev)
|
||||||
* If the device is under a power domain, the domain has to be get
|
* If the device is under a power domain, the domain has to be get
|
||||||
* first.
|
* first.
|
||||||
*/
|
*/
|
||||||
if (pm->domain != NULL) {
|
if (PM_DOMAIN(pm) != NULL) {
|
||||||
ret = pm_device_runtime_get(pm->domain);
|
ret = pm_device_runtime_get(PM_DOMAIN(pm));
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
goto unlock;
|
goto unlock;
|
||||||
}
|
}
|
||||||
|
@ -173,8 +180,8 @@ int pm_device_runtime_put(const struct device *dev)
|
||||||
/*
|
/*
|
||||||
* Now put the domain
|
* Now put the domain
|
||||||
*/
|
*/
|
||||||
if ((ret == 0) && dev->pm->domain != NULL) {
|
if ((ret == 0) && PM_DOMAIN(dev->pm) != NULL) {
|
||||||
ret = pm_device_runtime_put(dev->pm->domain);
|
ret = pm_device_runtime_put(PM_DOMAIN(dev->pm));
|
||||||
}
|
}
|
||||||
SYS_PORT_TRACING_FUNC_EXIT(pm, device_runtime_put, dev, ret);
|
SYS_PORT_TRACING_FUNC_EXIT(pm, device_runtime_put, dev, ret);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue