2016-03-19 07:43:40 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2012-2014 Wind River Systems, Inc.
|
|
|
|
*
|
2017-01-19 09:01:01 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2016-03-19 07:43:40 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __INCpower
|
|
|
|
#define __INCpower
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_SYS_POWER_MANAGEMENT
|
|
|
|
|
2016-09-26 10:17:45 +08:00
|
|
|
/* Constants identifying power state categories */
|
|
|
|
#define SYS_PM_ACTIVE_STATE 0 /* SOC and CPU are in active state */
|
|
|
|
#define SYS_PM_LOW_POWER_STATE 1 /* CPU low power state */
|
|
|
|
#define SYS_PM_DEEP_SLEEP 2 /* SOC low power state */
|
|
|
|
|
|
|
|
#define SYS_PM_NOT_HANDLED SYS_PM_ACTIVE_STATE
|
|
|
|
|
2016-11-11 13:16:12 +08:00
|
|
|
extern unsigned char _sys_pm_idle_exit_notify;
|
2016-03-19 07:43:40 +08:00
|
|
|
|
2016-04-22 03:18:12 +08:00
|
|
|
/**
|
|
|
|
* @brief Power Management Hook Interface
|
|
|
|
*
|
|
|
|
* @defgroup power_management_hook_interface Power Management Hook Interface
|
|
|
|
* @ingroup power_management_api
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2016-03-19 07:43:40 +08:00
|
|
|
/**
|
2016-11-11 13:16:12 +08:00
|
|
|
* @brief Function to disable power management idle exit notification
|
|
|
|
*
|
|
|
|
* _sys_soc_resume() would be called from the ISR of the event that caused
|
|
|
|
* exit from kernel idling after PM operations. For some power operations,
|
|
|
|
* this notification may not be necessary. This function can be called in
|
|
|
|
* _sys_soc_suspend to disable the corresponding _sys_soc_resume notification.
|
2016-09-26 10:17:45 +08:00
|
|
|
*
|
|
|
|
*/
|
2016-11-11 13:16:12 +08:00
|
|
|
static inline void _sys_soc_pm_idle_exit_notification_disable(void)
|
2016-09-26 10:17:45 +08:00
|
|
|
{
|
2016-11-11 13:16:12 +08:00
|
|
|
_sys_pm_idle_exit_notify = 0;
|
2016-09-26 10:17:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-11-10 14:55:14 +08:00
|
|
|
* @brief Hook function to notify exit from deep sleep
|
2016-03-19 07:43:40 +08:00
|
|
|
*
|
|
|
|
* The purpose of this function is to notify exit from
|
2016-11-10 14:55:14 +08:00
|
|
|
* deep sleep. The implementation of this function can vary
|
2016-09-26 10:17:45 +08:00
|
|
|
* depending on the soc specific boot flow.
|
|
|
|
*
|
2016-11-10 14:55:14 +08:00
|
|
|
* This function would switch cpu context to the execution point at the time
|
|
|
|
* system entered deep sleep power state. Some implementations may not require
|
|
|
|
* use of this function e.g. the BSP or boot loader may do the context switch.
|
2016-09-26 10:17:45 +08:00
|
|
|
*
|
|
|
|
* In boot flows where this function gets called even at cold boot, the
|
|
|
|
* function should return immediately.
|
|
|
|
*
|
2016-11-10 14:55:14 +08:00
|
|
|
*/
|
|
|
|
void _sys_soc_resume_from_deep_sleep(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Hook function to notify exit from kernel idling after PM operations
|
|
|
|
*
|
|
|
|
* This function would notify exit from kernel idling if a corresponding
|
|
|
|
* _sys_soc_suspend() notification was handled and did not return
|
|
|
|
* SYS_PM_NOT_HANDLED.
|
|
|
|
*
|
|
|
|
* This function would be called from the ISR context of the event
|
2016-11-11 13:16:12 +08:00
|
|
|
* that caused the exit from kernel idling. This will be called immediately
|
2016-09-26 10:17:45 +08:00
|
|
|
* after interrupts are enabled. This is called to give a chance to do
|
|
|
|
* any operations before the kernel would switch tasks or processes nested
|
|
|
|
* interrupts. This is required for cpu low power states that would require
|
|
|
|
* interrupts to be enabled while entering low power states. e.g. C1 in x86. In
|
|
|
|
* those cases, the ISR would be invoked immediately after the event wakes up
|
|
|
|
* the CPU, before code following the CPU wait, gets a chance to execute. This
|
|
|
|
* can be ignored if no operation needs to be done at the wake event
|
2016-11-11 13:16:12 +08:00
|
|
|
* notification. Alternatively _sys_soc_pm_idle_exit_notification_disable() can
|
2016-09-26 10:17:45 +08:00
|
|
|
* be called in _sys_soc_suspend to disable this notification.
|
|
|
|
*
|
2016-03-19 07:43:40 +08:00
|
|
|
*/
|
2016-10-18 17:35:11 +08:00
|
|
|
void _sys_soc_resume(void);
|
2016-03-19 07:43:40 +08:00
|
|
|
|
|
|
|
/**
|
2016-09-26 10:17:45 +08:00
|
|
|
* @brief Hook function to allow entry to low power state
|
2016-03-19 07:43:40 +08:00
|
|
|
*
|
|
|
|
* This function is called by the kernel when it is about to idle.
|
|
|
|
* It is passed the number of clock ticks that the kernel calculated
|
2016-09-26 10:17:45 +08:00
|
|
|
* as available time to idle.
|
|
|
|
*
|
|
|
|
* The implementation of this function is dependent on the soc specific
|
|
|
|
* components and the various schemes they support. Some implementations
|
|
|
|
* may choose to do device PM operations in this function, while others
|
|
|
|
* would not need to, because they would have done it at other places.
|
|
|
|
*
|
|
|
|
* Typically a wake event is set and the soc or cpu is put to any of the
|
|
|
|
* supported low power states. The wake event should be set to wake up
|
|
|
|
* the soc or cpu before the available idle time expires to avoid disrupting
|
|
|
|
* the kernel's scheduling.
|
|
|
|
*
|
|
|
|
* This function is entered with interrupts disabled. It should
|
|
|
|
* re-enable interrupts if it had entered a low power state.
|
2016-03-19 07:43:40 +08:00
|
|
|
*
|
|
|
|
* @param ticks the upcoming kernel idle time
|
|
|
|
*
|
2016-09-26 10:17:45 +08:00
|
|
|
* @retval SYS_PM_NOT_HANDLED If low power state was not entered.
|
|
|
|
* @retval SYS_PM_LOW_POWER_STATE If CPU low power state was entered.
|
|
|
|
* @retval SYS_PM_DEEP_SLEEP If SOC low power state was entered.
|
2016-03-19 07:43:40 +08:00
|
|
|
*/
|
2017-04-21 23:55:34 +08:00
|
|
|
extern int _sys_soc_suspend(s32_t ticks);
|
2016-03-19 07:43:40 +08:00
|
|
|
|
2016-04-22 03:18:12 +08:00
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
2016-03-19 07:43:40 +08:00
|
|
|
#endif /* CONFIG_SYS_POWER_MANAGEMENT */
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* __INCpower */
|