power_mgmt: Update changes in k_idle.c missing in idle.c
Some changes that went into k_idle.c were missing in idle.c causing errors while building power management code for unified kernel. Added the missing changes. Tested with power_mgr app built for unified kernel. Jira: ZEP-1139 Change-Id: I9fe005544f7ee69d3cb3ff10c649be28037fcf15 Signed-off-by: Ramesh Thomas <ramesh.thomas@intel.com>
This commit is contained in:
parent
6072e455f3
commit
3e0f20a7d5
1 changed files with 32 additions and 35 deletions
|
@ -31,6 +31,12 @@ int32_t _sys_idle_threshold_ticks = CONFIG_TICKLESS_IDLE_THRESH;
|
|||
#endif /* CONFIG_TICKLESS_IDLE */
|
||||
|
||||
#ifdef CONFIG_SYS_POWER_MANAGEMENT
|
||||
/*
|
||||
* Used to allow _sys_soc_suspend() implementation to control notification
|
||||
* of the wake event that caused exit from low power state
|
||||
*/
|
||||
unsigned char _sys_soc_notify_wake_event;
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Indicate that kernel is idling in tickless mode
|
||||
|
@ -65,31 +71,26 @@ static void _sys_power_save_idle(int32_t ticks __unused)
|
|||
|
||||
set_kernel_idle_time_in_ticks(ticks);
|
||||
#if (defined(CONFIG_SYS_POWER_LOW_POWER_STATE) || \
|
||||
defined(CONFIG_SYS_POWER_DEEP_SLEEP) || \
|
||||
defined(CONFIG_DEVICE_POWER_MANAGEMENT))
|
||||
defined(CONFIG_SYS_POWER_DEEP_SLEEP))
|
||||
|
||||
/* This assignment will be controlled by Kconfig flag in future */
|
||||
_sys_soc_notify_wake_event = 1;
|
||||
|
||||
/*
|
||||
* Call the suspend hook function, which checks if the system should
|
||||
* enter deep sleep, low power state or only suspend devices.
|
||||
* If the time available is too short for any PM operation then
|
||||
* the function returns SYS_PM_NOT_HANDLED immediately and kernel
|
||||
* does normal idle processing. Otherwise it will return the code
|
||||
* corresponding to the action taken.
|
||||
* Call the suspend hook function of the soc interface to allow
|
||||
* entry into a low power state. The function returns
|
||||
* SYS_PM_NOT_HANDLED if low power state was not entered, in which
|
||||
* case, kernel does normal idle processing.
|
||||
*
|
||||
* This function can just suspend devices without entering
|
||||
* deep sleep or cpu low power state. In this case it should return
|
||||
* SYS_PM_DEVICE_SUSPEND_ONLY and kernel would do normal idle
|
||||
* processing.
|
||||
*
|
||||
* This function is entered with interrupts disabled. If the function
|
||||
* returns either SYS_PM_LOW_POWER_STATE or SYS_PM_DEEP_SLEEP then
|
||||
* it should ensure interrupts are re-enabled before returning.
|
||||
* This is because the kernel does not do its own idle processing in
|
||||
* these cases i.e. skips nano_cpu_idle(). The kernel's idle
|
||||
* processing re-enables interrupts which is essential for kernel's
|
||||
* scheduling logic.
|
||||
* This function is entered with interrupts disabled. If a low power
|
||||
* state was entered, then the hook function should enable inerrupts
|
||||
* before exiting. This is because the kernel does not do its own idle
|
||||
* processing in those cases i.e. skips nano_cpu_idle(). The kernel's
|
||||
* idle processing re-enables interrupts which is essential for
|
||||
* the kernel's scheduling logic.
|
||||
*/
|
||||
if (!(_sys_soc_suspend(ticks) &
|
||||
(SYS_PM_DEEP_SLEEP | SYS_PM_LOW_POWER_STATE))) {
|
||||
if (_sys_soc_suspend(ticks) == SYS_PM_NOT_HANDLED) {
|
||||
_sys_soc_notify_wake_event = 0;
|
||||
nano_cpu_idle();
|
||||
}
|
||||
#else
|
||||
|
@ -99,20 +100,16 @@ defined(CONFIG_DEVICE_POWER_MANAGEMENT))
|
|||
|
||||
void _sys_power_save_idle_exit(int32_t ticks)
|
||||
{
|
||||
#if (defined(CONFIG_SYS_POWER_LOW_POWER_STATE) || \
|
||||
defined(CONFIG_SYS_POWER_DEEP_SLEEP) || \
|
||||
defined(CONFIG_DEVICE_POWER_MANAGEMENT))
|
||||
/*
|
||||
* Any idle wait based on CPU low power state will be exited by
|
||||
* interrupt. This function is called within that interrupt's
|
||||
* ISR context. _sys_soc_resume() needs to be called here
|
||||
* to handle exit from CPU low power states. This gives an
|
||||
* opportunity for device states altered in _sys_soc_suspend()
|
||||
* to be restored before the kernel schedules another thread.
|
||||
* _sys_soc_resume() is not called from here for deep sleep
|
||||
* exit. Deep sleep recovery happens at cold boot path.
|
||||
#if defined(CONFIG_SYS_POWER_LOW_POWER_STATE)
|
||||
/* Some CPU low power states require notification at the ISR
|
||||
* to allow any operations that needs to be done before kernel
|
||||
* switches task or processes nested interrupts. This can be
|
||||
* disabled by calling _sys_soc_disable_wake_event_notification().
|
||||
* Alternatively it can be simply ignored if not required.
|
||||
*/
|
||||
_sys_soc_resume();
|
||||
if (_sys_soc_notify_wake_event) {
|
||||
_sys_soc_resume();
|
||||
}
|
||||
#endif
|
||||
#ifdef CONFIG_TICKLESS_IDLE
|
||||
if ((ticks == K_FOREVER) || ticks >= _sys_idle_threshold_ticks) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue