Power: change sys_pm_force_power_state only works for one shot

Change sys_pm_force_power_state only works for the current ongoing
suspend operation, before the end of syspend state forced_pm_state
will be cleared.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
This commit is contained in:
Wentong Wu 2020-01-22 03:29:50 -05:00 committed by Anas Nashif
commit a9bd208b5b
2 changed files with 8 additions and 7 deletions

View file

@ -146,14 +146,13 @@ static inline void _sys_pm_idle_exit_notification_disable(void)
/** /**
* @brief Force usage of given power state. * @brief Force usage of given power state.
* *
* This function overrides decision made by PM policy * This function overrides decision made by PM policy forcing
* forcing usage of given power state in all subsequent * usage of given power state in the ongoing suspend operation.
* suspend operations. Forcing the SYS_POWER_STATE_AUTO * And before the end of suspend, the state of forced_pm_state
* state restores normal operation. * is cleared with interrupt disabled.
* *
* @param state Power state which should be used in all * @param state Power state which should be used in the ongoing
* subsequent suspend operations or * suspend operation or SYS_POWER_STATE_AUTO.
* SYS_POWER_STATE_AUTO.
*/ */
void sys_pm_force_power_state(enum power_states state); void sys_pm_force_power_state(enum power_states state);

View file

@ -152,6 +152,8 @@ enum power_states _sys_suspend(s32_t ticks)
if (!post_ops_done) { if (!post_ops_done) {
post_ops_done = 1; post_ops_done = 1;
/* clear forced_pm_state */
forced_pm_state = SYS_POWER_STATE_AUTO;
sys_pm_notify_power_state_exit(pm_state); sys_pm_notify_power_state_exit(pm_state);
_sys_pm_power_state_exit_post_ops(pm_state); _sys_pm_power_state_exit_post_ops(pm_state);
} }