pm: device: Add wakeup source API

Introduce a new API to allow devices capable of wake up the system
register themselves was wake up sources. This permits applications to
select the most appropriate way to wake up the system when it is
suspended.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
Flavio Ceolin 2021-06-30 14:32:56 -07:00 committed by Christopher Friedt
commit 8eceeee798
7 changed files with 115 additions and 3 deletions

View file

@ -66,6 +66,13 @@ enum pm_device_state {
enum pm_device_flag {
/** Indicate if the device is busy or not. */
PM_DEVICE_FLAG_BUSY,
/**
* Indicates whether or not the device is capable of waking the system
* up.
*/
PM_DEVICE_FLAGS_WS_CAPABLE,
/** Indicates if the device is being used as wakeup source. */
PM_DEVICE_FLAGS_WS_ENABLED,
/** Number of flags (internal use only). */
PM_DEVICE_FLAG_COUNT
};
@ -231,6 +238,42 @@ __deprecated static inline int device_busy_check(const struct device *dev)
/** Alias for legacy use of device_pm_control_nop */
#define device_pm_control_nop __DEPRECATED_MACRO NULL
/**
* @brief Enable a power management wakeup source
*
* Enable a wakeup source. This will keep the current device active when the
* system is suspended, allowing it to be used to wake up the system.
*
* @param dev device object to enable.
* @param enable @c true to enable or @c false to disable
*
* @retval true if the wakeup source was successfully enabled.
* @retval false if the wakeup source was not successfully enabled.
*/
bool pm_device_wakeup_enable(struct device *dev, bool enable);
/**
* @brief Check if a power management wakeup source is enabled
*
* Checks if a wake up source is enabled.
*
* @param dev device object to check.
*
* @retval true if the wakeup source is enabled.
* @retval false if the wakeup source is not enabled.
*/
bool pm_device_wakeup_is_enabled(const struct device *dev);
/**
* @brief Check if a device is wake up capable
*
* @param dev device object to check.
*
* @retval true if the device is wake up capable.
* @retval false if the device is not wake up capable.
*/
bool pm_device_wakeup_is_capable(const struct device *dev);
/** @} */
#ifdef __cplusplus