diff --git a/include/power/power.h b/include/power/power.h index fb73ca2fd59..d0c5f9fb98e 100644 --- a/include/power/power.h +++ b/include/power/power.h @@ -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. */ diff --git a/subsys/power/Kconfig b/subsys/power/Kconfig index 52bfc951fd8..c5df0744941 100644 --- a/subsys/power/Kconfig +++ b/subsys/power/Kconfig @@ -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 diff --git a/subsys/power/power.c b/subsys/power/power.c index 9a10e9ea9f7..b29139d1237 100644 --- a/subsys/power/power.c +++ b/subsys/power/power.c @@ -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)