power: add system power management direct force mode.

Add system power management direct force trigger mode. In this
mode application thread can directly put system in sleep or deep
sleep mode instead of waiting for idle thread to do it, so that
it can reduce latency to enter low power mode.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
This commit is contained in:
Wentong Wu 2020-01-22 03:36:21 -05:00 committed by Anas Nashif
parent a9bd208b5b
commit 7cb74655da
3 changed files with 17 additions and 0 deletions

View file

@ -151,6 +151,9 @@ static inline void _sys_pm_idle_exit_notification_disable(void)
* And before the end of suspend, the state of forced_pm_state
* is cleared with interrupt disabled.
*
* If enabled SYS_PM_DIRECT_FORCE_MODE, this function can only
* run in thread context.
*
* @param state Power state which should be used in the ongoing
* suspend operation or SYS_POWER_STATE_AUTO.
*/

View file

@ -8,6 +8,14 @@ config SYS_PM_STATE_LOCK
Power States while doing any critical work or needs quick
response from hardware resources.
config SYS_PM_DIRECT_FORCE_MODE
bool "Enable system power management direct force trigger mode"
help
Enable system power management direct force trigger mode. In
this mode application thread can directly put system in sleep
or deep sleep mode instead of waiting for idle thread to do
it, so that it can reduce latency to enter low power mode.
config SYS_PM_DEBUG
bool "Enable System Power Management debug hooks"
help

View file

@ -80,7 +80,13 @@ void sys_pm_force_power_state(enum power_states state)
state < SYS_POWER_STATE_MAX,
"Invalid power state %d!", state);
#ifdef CONFIG_SYS_PM_DIRECT_FORCE_MODE
(void)arch_irq_lock();
forced_pm_state = state;
_sys_suspend(K_FOREVER);
#else
forced_pm_state = state;
#endif
}
enum power_states _sys_suspend(s32_t ticks)