Zephyr API Documentation
3.0.0
A Scalable Open Source RTOS
|
|
3.0.0 |
Device Power Management API. More...
Macros | |
#define | PM_DEVICE_DEFINE(dev_name, pm_action_cb) Z_PM_DEVICE_DEFINE(DT_INVALID_NODE, dev_name, pm_action_cb) |
#define | PM_DEVICE_DT_DEFINE(node_id, pm_action_cb) |
#define | PM_DEVICE_DT_INST_DEFINE(idx, pm_action_cb) |
#define | PM_DEVICE_GET(dev_name) Z_PM_DEVICE_GET(dev_name) |
Obtain a reference to the device PM resources for the given device. More... | |
#define | PM_DEVICE_DT_GET(node_id) PM_DEVICE_GET(Z_DEVICE_DT_DEV_NAME(node_id)) |
Obtain a reference to the device PM resources for the given node. More... | |
#define | PM_DEVICE_DT_INST_GET(idx) PM_DEVICE_DT_GET(DT_DRV_INST(idx)) |
Obtain a reference to the device PM resources for the given instance. More... | |
Enumerations | |
enum | pm_device_state { PM_DEVICE_STATE_ACTIVE , PM_DEVICE_STATE_SUSPENDED , PM_DEVICE_STATE_SUSPENDING , PM_DEVICE_STATE_OFF } |
Device power states. More... | |
enum | pm_device_action { PM_DEVICE_ACTION_SUSPEND , PM_DEVICE_ACTION_RESUME , PM_DEVICE_ACTION_TURN_OFF , PM_DEVICE_ACTION_TURN_ON , PM_DEVICE_ACTION_FORCE_SUSPEND } |
Device PM actions. More... | |
Functions | |
const char * | pm_device_state_str (enum pm_device_state state) |
Get name of device PM state. More... | |
int | pm_device_state_set (const struct device *dev, enum pm_device_state state) |
Set the power state of a device. More... | |
int | pm_device_state_get (const struct device *dev, enum pm_device_state *state) |
Obtain the power state of a device. More... | |
int | pm_device_action_run (const struct device *dev, enum pm_device_action action) |
Run a pm action on a device. More... | |
void | pm_device_children_action_run (const struct device *dev, enum pm_device_action action, pm_device_action_failed_cb_t failure_cb) |
Run a pm action on all children of a device. More... | |
void | pm_device_busy_set (const struct device *dev) |
Mark a device as busy. More... | |
void | pm_device_busy_clear (const struct device *dev) |
Clear a device busy status. More... | |
bool | pm_device_is_any_busy (void) |
Check if any device is busy. More... | |
bool | pm_device_is_busy (const struct device *dev) |
Check if a device is busy. More... | |
bool | pm_device_wakeup_enable (struct device *dev, bool enable) |
Enable or disable a device as a wake up source. More... | |
bool | pm_device_wakeup_is_enabled (const struct device *dev) |
Check if a device is enabled as a wake up source. More... | |
bool | pm_device_wakeup_is_capable (const struct device *dev) |
Check if a device is wake up capable. More... | |
void | pm_device_state_lock (const struct device *dev) |
Lock current device state. More... | |
void | pm_device_state_unlock (const struct device *dev) |
Unlock the current device state. More... | |
bool | pm_device_state_is_locked (const struct device *dev) |
Check if the device pm is locked. More... | |
bool | pm_device_on_power_domain (const struct device *dev) |
Check if the device is on a switchable power domain. More... | |
static void | device_busy_set (const struct device *dev) |
static void | device_busy_clear (const struct device *dev) |
Clear busy status of a device. More... | |
static int | device_any_busy_check (void) |
Check if any device is busy. More... | |
static int | device_busy_check (const struct device *dev) |
Check if a device is busy. More... | |
Device Power Management API.
#define PM_DEVICE_DEFINE | ( | dev_name, | |
pm_action_cb | |||
) | Z_PM_DEVICE_DEFINE(DT_INVALID_NODE, dev_name, pm_action_cb) |
#include <include/pm/device.h>
Define device PM resources for the given device name.
embed:rst:inline :kconfig:`CONFIG_PM_DEVICE`is not enabled.
dev_name | Device name. |
pm_action_cb | PM control callback. |
#define PM_DEVICE_DT_DEFINE | ( | node_id, | |
pm_action_cb | |||
) |
#include <include/pm/device.h>
Define device PM resources for the given node identifier.
embed:rst:inline :kconfig:`CONFIG_PM_DEVICE`is not enabled.
node_id | Node identifier. |
pm_action_cb | PM control callback. |
#define PM_DEVICE_DT_GET | ( | node_id | ) | PM_DEVICE_GET(Z_DEVICE_DT_DEV_NAME(node_id)) |
#include <include/pm/device.h>
Obtain a reference to the device PM resources for the given node.
node_id | Node identifier. |
embed:rst:inline :kconfig:`CONFIG_PM_DEVICE`is disabled).
#define PM_DEVICE_DT_INST_DEFINE | ( | idx, | |
pm_action_cb | |||
) |
#include <include/pm/device.h>
Define device PM resources for the given instance.
embed:rst:inline :kconfig:`CONFIG_PM_DEVICE`is not enabled.
idx | Instance index. |
pm_action_cb | PM control callback. |
#define PM_DEVICE_DT_INST_GET | ( | idx | ) | PM_DEVICE_DT_GET(DT_DRV_INST(idx)) |
#include <include/pm/device.h>
Obtain a reference to the device PM resources for the given instance.
idx | Instance index. |
embed:rst:inline :kconfig:`CONFIG_PM_DEVICE`is disabled).
#define PM_DEVICE_GET | ( | dev_name | ) | Z_PM_DEVICE_GET(dev_name) |
#include <include/pm/device.h>
Obtain a reference to the device PM resources for the given device.
dev_name | Device name. |
embed:rst:inline :kconfig:`CONFIG_PM_DEVICE`is disabled).
enum pm_device_action |
#include <include/pm/device.h>
Device PM actions.
enum pm_device_state |
#include <include/pm/device.h>
Device power states.
|
inlinestatic |
#include <include/pm/device.h>
Check if any device is busy.
0 | No devices are busy. |
-EBUSY | One or more devices are busy. |
|
inlinestatic |
#include <include/pm/device.h>
Check if a device is busy.
dev | Device instance. |
0 | Device is not busy. |
-EBUSY | Device is busy. |
|
inlinestatic |
#include <include/pm/device.h>
Clear busy status of a device.
dev | Device instance. |
|
inlinestatic |
#include <include/pm/device.h>
Mark a device as busy.
dev | Device instance. |
int pm_device_action_run | ( | const struct device * | dev, |
enum pm_device_action | action | ||
) |
#include <include/pm/device.h>
Run a pm action on a device.
This function calls the device PM control callback so that the device does the necessary operations to execute the given action.
dev | Device instance. |
action | Device pm action. |
0 | If successful. |
-ENOTSUP | If requested state is not supported. |
-EALREADY | If device is already at the requested state. |
-EBUSY | If device is changing its state. |
-ENOSYS | If device does not support PM. |
-EPERM | If device has power state locked. |
Errno | Other negative errno on failure. |
void pm_device_busy_clear | ( | const struct device * | dev | ) |
#include <include/pm/device.h>
Clear a device busy status.
dev | Device instance. |
void pm_device_busy_set | ( | const struct device * | dev | ) |
#include <include/pm/device.h>
Mark a device as busy.
Devices marked as busy will not be suspended when the system goes into low-power states. This can be useful if, for example, the device is in the middle of a transaction.
dev | Device instance. |
void pm_device_children_action_run | ( | const struct device * | dev, |
enum pm_device_action | action, | ||
pm_device_action_failed_cb_t | failure_cb | ||
) |
#include <include/pm/device.h>
Run a pm action on all children of a device.
This function calls all child devices PM control callback so that the device does the necessary operations to execute the given action.
dev | Device instance. |
action | Device pm action. |
failure_cb | Function to call if a child fails the action, can be NULL. |
bool pm_device_is_any_busy | ( | void | ) |
#include <include/pm/device.h>
Check if any device is busy.
false | If no device is busy |
true | If one or more devices are busy |
#include <include/pm/device.h>
Check if a device is busy.
dev | Device instance. |
false | If the device is not busy |
true | If the device is busy |
#include <include/pm/device.h>
Check if the device is on a switchable power domain.
dev | Device instance. |
true | If device is on a switchable power domain. |
false | If device is not on a switchable power domain. |
int pm_device_state_get | ( | const struct device * | dev, |
enum pm_device_state * | state | ||
) |
#include <include/pm/device.h>
Obtain the power state of a device.
dev | Device instance. |
state | Pointer where device power state will be stored. |
0 | If successful. |
-ENOSYS | If device does not implement power management. |
#include <include/pm/device.h>
Check if the device pm is locked.
dev | Device instance. |
true | If device is locked. |
false | If device is not locked. |
void pm_device_state_lock | ( | const struct device * | dev | ) |
#include <include/pm/device.h>
Lock current device state.
This function locks the current device power state. Once locked the device power state will not be changed by system power management or device runtime power management until unlocked.
dev | Device instance. |
int pm_device_state_set | ( | const struct device * | dev, |
enum pm_device_state | state | ||
) |
#include <include/pm/device.h>
Set the power state of a device.
This function calls the device PM control callback so that the device does the necessary operations to put the device into the given state.
dev | Device instance. |
state | Device power state to be set. |
0 | If successful. |
-ENOTSUP | If requested state is not supported. |
-EALREADY | If device is already at the requested state. |
-EBUSY | If device is changing its state. |
-ENOSYS | If device does not support PM. |
-EPERM | If device has power state locked. |
Errno | Other negative errno on failure. |
const char * pm_device_state_str | ( | enum pm_device_state | state | ) |
#include <include/pm/device.h>
Get name of device PM state.
state | State id which name should be returned |
void pm_device_state_unlock | ( | const struct device * | dev | ) |
#include <include/pm/device.h>
Unlock the current device state.
Unlocks a previously locked device pm.
dev | Device instance. |
#include <include/pm/device.h>
Enable or disable a device as a wake up source.
A device marked as a wake up source will not be suspended when the system goes into low-power modes, thus allowing to use it as a wake up source for the system.
dev | Device instance. |
enable | true to enable or false to disable |
true | If the wakeup source was successfully enabled. |
false | If the wakeup source was not successfully enabled. |
#include <include/pm/device.h>
Check if a device is wake up capable.
dev | Device instance. |
true | If the device is wake up capable. |
false | If the device is not wake up capable. |
#include <include/pm/device.h>
Check if a device is enabled as a wake up source.
dev | Device instance. |
true | if the wakeup source is enabled. |
false | if the wakeup source is not enabled. |