Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pm: device: Add power domain get function #81793

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions include/zephyr/pm/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,16 @@ bool pm_device_wakeup_is_capable(const struct device *dev);
*/
bool pm_device_on_power_domain(const struct device *dev);

/**
* @brief Get the device's power domain.
*
* @param dev Device instance.
*
* @retval pd The device's power domain if on a power domain
* @retval NULL if not on a power domain
*/
const struct device *pm_device_get_power_domain(const struct device *dev);

/**
* @brief Add a device to a power domain.
*
Expand Down
13 changes: 13 additions & 0 deletions subsys/pm/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,19 @@ bool pm_device_on_power_domain(const struct device *dev)
#endif
}

const struct device *pm_device_get_power_domain(const struct device *dev)
{
#ifdef CONFIG_PM_DEVICE_POWER_DOMAIN
if (pm_device_on_power_domain(dev) == false) {
return NULL;
}
return dev->pm_base->domain;
#else
ARG_UNUSED(dev);
return NULL;
#endif
}

bool pm_device_is_powered(const struct device *dev)
{
#ifdef CONFIG_PM_DEVICE_POWER_DOMAIN
Expand Down
Loading