pm: device_runtime: init into PM_DEVICE_STATE_OFF
Add a function to tell runtime power management that the device is starting in the off state instead of active or suspended. Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
This commit is contained in:
parent
3f7f8d8f75
commit
7101899328
2 changed files with 20 additions and 1 deletions
|
@ -156,6 +156,24 @@ static inline void pm_device_runtime_init_suspended(const struct device *dev)
|
|||
pm->state = PM_DEVICE_STATE_SUSPENDED;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize a device state to #PM_DEVICE_STATE_OFF.
|
||||
*
|
||||
* By default device state is initialized to #PM_DEVICE_STATE_ACTIVE. In
|
||||
* general, this makes sense because the device initialization function will
|
||||
* resume and configure a device, leaving it operational. However, when device
|
||||
* runtime PM is enabled, the device may be connected to a power domain, at
|
||||
* which case it won't be powered at boot.
|
||||
*
|
||||
* @param dev Device instance.
|
||||
*/
|
||||
static inline void pm_device_runtime_init_off(const struct device *dev)
|
||||
{
|
||||
struct pm_device *pm = dev->pm;
|
||||
|
||||
pm->state = PM_DEVICE_STATE_OFF;
|
||||
}
|
||||
|
||||
#else
|
||||
static inline int pm_device_runtime_enable(const struct device *dev) { return -ENOSYS; }
|
||||
static inline int pm_device_runtime_disable(const struct device *dev) { return -ENOSYS; }
|
||||
|
@ -164,6 +182,7 @@ static inline int pm_device_runtime_put(const struct device *dev) { return 0; }
|
|||
static inline int pm_device_runtime_put_async(const struct device *dev) { return 0; }
|
||||
static inline bool pm_device_runtime_is_enabled(const struct device *dev) { return false; }
|
||||
static inline void pm_device_runtime_init_suspended(const struct device *dev) { }
|
||||
static inline void pm_device_runtime_init_off(const struct device *dev) { }
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -230,9 +230,9 @@ int pm_device_runtime_enable(const struct device *dev)
|
|||
if (ret < 0) {
|
||||
goto unlock;
|
||||
}
|
||||
pm->state = PM_DEVICE_STATE_SUSPENDED;
|
||||
}
|
||||
|
||||
pm->state = PM_DEVICE_STATE_SUSPENDED;
|
||||
pm->usage = 0U;
|
||||
|
||||
atomic_set_bit(&pm->flags, PM_DEVICE_FLAG_RUNTIME_ENABLED);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue