diff --git a/drivers/counter/counter_qmsi_aonpt.c b/drivers/counter/counter_qmsi_aonpt.c index 3afc6ed084c..3a75c9abb28 100644 --- a/drivers/counter/counter_qmsi_aonpt.c +++ b/drivers/counter/counter_qmsi_aonpt.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include diff --git a/drivers/counter/counter_rtc_qmsi.c b/drivers/counter/counter_rtc_qmsi.c index 8553d50fead..55e3b1586dc 100644 --- a/drivers/counter/counter_rtc_qmsi.c +++ b/drivers/counter/counter_rtc_qmsi.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include diff --git a/drivers/gpio/gpio_dw.c b/drivers/gpio/gpio_dw.c index 8d62e1fb52f..679fd53fc10 100644 --- a/drivers/gpio/gpio_dw.c +++ b/drivers/gpio/gpio_dw.c @@ -27,7 +27,7 @@ #endif #ifdef CONFIG_DEVICE_POWER_MANAGEMENT -#include +#include #endif /* diff --git a/drivers/gpio/gpio_qmsi.c b/drivers/gpio/gpio_qmsi.c index 2a1c9941496..4f826a49a63 100644 --- a/drivers/gpio/gpio_qmsi.c +++ b/drivers/gpio/gpio_qmsi.c @@ -18,7 +18,7 @@ #include "qm_isr.h" #include "clk.h" #include "soc.h" -#include +#include struct gpio_qmsi_config { qm_gpio_t gpio; diff --git a/drivers/i2c/i2c_qmsi.c b/drivers/i2c/i2c_qmsi.c index daa18bb4365..740c1495ada 100644 --- a/drivers/i2c/i2c_qmsi.c +++ b/drivers/i2c/i2c_qmsi.c @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include "qm_i2c.h" #include "qm_isr.h" diff --git a/drivers/interrupt_controller/arcv2_irq_unit.c b/drivers/interrupt_controller/arcv2_irq_unit.c index 17665c4dc75..b4160d0afab 100644 --- a/drivers/interrupt_controller/arcv2_irq_unit.c +++ b/drivers/interrupt_controller/arcv2_irq_unit.c @@ -23,7 +23,7 @@ extern void *_VectorTable; #ifdef CONFIG_DEVICE_POWER_MANAGEMENT -#include +#include #include #include diff --git a/drivers/interrupt_controller/ioapic_intr.c b/drivers/interrupt_controller/ioapic_intr.c index c5aa0dc3303..fde81569ced 100644 --- a/drivers/interrupt_controller/ioapic_intr.c +++ b/drivers/interrupt_controller/ioapic_intr.c @@ -70,7 +70,7 @@ #define SUSPEND_BITS_REQD (ROUND_UP((CONFIG_IOAPIC_NUM_RTES * BITS_PER_IRQ), 32)) #ifdef CONFIG_DEVICE_POWER_MANAGEMENT -#include +#include u32_t ioapic_suspend_buf[SUSPEND_BITS_REQD / 32] = {0}; static u32_t ioapic_device_power_state = DEVICE_PM_ACTIVE_STATE; #endif diff --git a/drivers/interrupt_controller/loapic_intr.c b/drivers/interrupt_controller/loapic_intr.c index f56113f0320..d1e00fd6e1b 100644 --- a/drivers/interrupt_controller/loapic_intr.c +++ b/drivers/interrupt_controller/loapic_intr.c @@ -60,7 +60,7 @@ #define LOPIC_SSPND_BITS_PER_IRQ 1 /* Just the one for enable disable*/ #define LOPIC_SUSPEND_BITS_REQD (ROUND_UP((LOAPIC_IRQ_COUNT * LOPIC_SSPND_BITS_PER_IRQ), 32)) #ifdef CONFIG_DEVICE_POWER_MANAGEMENT -#include +#include u32_t loapic_suspend_buf[LOPIC_SUSPEND_BITS_REQD / 32] = {0}; static u32_t loapic_device_power_state = DEVICE_PM_ACTIVE_STATE; #endif diff --git a/drivers/pwm/pwm_qmsi.c b/drivers/pwm/pwm_qmsi.c index 73909d4a3af..8f436713b66 100644 --- a/drivers/pwm/pwm_qmsi.c +++ b/drivers/pwm/pwm_qmsi.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include "qm_pwm.h" diff --git a/drivers/rtc/rtc_mcux.c b/drivers/rtc/rtc_mcux.c index a17b6ff7e35..386ee9f8165 100644 --- a/drivers/rtc/rtc_mcux.c +++ b/drivers/rtc/rtc_mcux.c @@ -13,7 +13,7 @@ LOG_MODULE_REGISTER(rtc_mcux); #include #include #include -#include +#include #include #include #include diff --git a/drivers/serial/uart_qmsi.c b/drivers/serial/uart_qmsi.c index 7539cfb8c36..7dcb8154dfd 100644 --- a/drivers/serial/uart_qmsi.c +++ b/drivers/serial/uart_qmsi.c @@ -10,7 +10,7 @@ #include #endif #include -#include +#include #include "qm_uart.h" #include "qm_isr.h" diff --git a/drivers/spi/spi_intel.c b/drivers/spi/spi_intel.c index 8f236568e33..712e760ceed 100644 --- a/drivers/spi/spi_intel.c +++ b/drivers/spi/spi_intel.c @@ -21,7 +21,7 @@ LOG_MODULE_REGISTER(spi_intel); #include #include -#include +#include #include #include "spi_intel.h" diff --git a/drivers/timer/loapic_timer.c b/drivers/timer/loapic_timer.c index 3824aa86e67..61ed29cf5cb 100644 --- a/drivers/timer/loapic_timer.c +++ b/drivers/timer/loapic_timer.c @@ -62,7 +62,7 @@ #include #include #include -#include +#include #include #include diff --git a/drivers/watchdog/wdt_qmsi.c b/drivers/watchdog/wdt_qmsi.c index 995fb461203..e0b8c239fe4 100644 --- a/drivers/watchdog/wdt_qmsi.c +++ b/drivers/watchdog/wdt_qmsi.c @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include "clk.h" diff --git a/include/power.h b/include/power.h index bf70b000b32..409df0cc89f 100644 --- a/include/power.h +++ b/include/power.h @@ -1,324 +1,15 @@ /* - * Copyright (c) 2012-2014 Wind River Systems, Inc. + * Copyright (c) 2019 Intel Corporation * * SPDX-License-Identifier: Apache-2.0 */ - #ifndef ZEPHYR_INCLUDE_POWER_H_ #define ZEPHYR_INCLUDE_POWER_H_ -#include -#include - -#ifdef __cplusplus -extern "C" { +#ifndef CONFIG_COMPAT_INCLUDES +#warning "This header file has moved, include instead." #endif -/** - * @defgroup power_management_api Power Management - * @{ - * @} - */ - -/** - * @brief System power states. - */ -enum power_states { - SYS_POWER_STATE_AUTO = (-2), - SYS_POWER_STATE_ACTIVE = (-1), -#ifdef CONFIG_SYS_POWER_SLEEP_STATES -# ifdef CONFIG_HAS_SYS_POWER_STATE_SLEEP_1 - SYS_POWER_STATE_SLEEP_1, -# endif -# ifdef CONFIG_HAS_SYS_POWER_STATE_SLEEP_2 - SYS_POWER_STATE_SLEEP_2, -# endif -# ifdef CONFIG_HAS_SYS_POWER_STATE_SLEEP_3 - SYS_POWER_STATE_SLEEP_3, -# endif -#endif /* CONFIG_SYS_POWER_SLEEP_STATES */ - -#ifdef CONFIG_SYS_POWER_DEEP_SLEEP_STATES -# ifdef CONFIG_HAS_SYS_POWER_STATE_DEEP_SLEEP_1 - SYS_POWER_STATE_DEEP_SLEEP_1, -# endif -# ifdef CONFIG_HAS_SYS_POWER_STATE_DEEP_SLEEP_2 - SYS_POWER_STATE_DEEP_SLEEP_2, -# endif -# ifdef CONFIG_HAS_SYS_POWER_STATE_DEEP_SLEEP_3 - SYS_POWER_STATE_DEEP_SLEEP_3, -# endif -#endif /* CONFIG_SYS_POWER_DEEP_SLEEP_STATES */ - SYS_POWER_STATE_MAX -}; - -#ifdef CONFIG_SYS_POWER_MANAGEMENT - -extern unsigned char sys_pm_idle_exit_notify; - -/** - * @brief System Power Management API - * - * @defgroup system_power_management_api System Power Management API - * @ingroup power_management_api - * @{ - */ - -/** - * @brief Check if particular power state is a sleep state. - * - * This function returns true if given power state is a sleep state. - */ -static inline bool sys_pm_is_sleep_state(enum power_states state) -{ - bool ret = true; - - switch (state) { -#ifdef CONFIG_SYS_POWER_SLEEP_STATES -# ifdef CONFIG_HAS_SYS_POWER_STATE_SLEEP_1 - case SYS_POWER_STATE_SLEEP_1: - break; -# endif -# ifdef CONFIG_HAS_SYS_POWER_STATE_SLEEP_2 - case SYS_POWER_STATE_SLEEP_2: - break; -# endif -# ifdef CONFIG_HAS_SYS_POWER_STATE_SLEEP_3 - case SYS_POWER_STATE_SLEEP_3: - break; -# endif -#endif /* CONFIG_SYS_POWER_SLEEP_STATES */ - default: - ret = false; - break; - } - - return ret; -} - -/** - * @brief Check if particular power state is a deep sleep state. - * - * This function returns true if given power state is a deep sleep state. - */ -static inline bool sys_pm_is_deep_sleep_state(enum power_states state) -{ - bool ret = true; - - switch (state) { -#ifdef CONFIG_SYS_POWER_DEEP_SLEEP_STATES -# ifdef CONFIG_HAS_SYS_POWER_STATE_DEEP_SLEEP_1 - case SYS_POWER_STATE_DEEP_SLEEP_1: - break; -# endif -# ifdef CONFIG_HAS_SYS_POWER_STATE_DEEP_SLEEP_2 - case SYS_POWER_STATE_DEEP_SLEEP_2: - break; -# endif -# ifdef CONFIG_HAS_SYS_POWER_STATE_DEEP_SLEEP_3 - case SYS_POWER_STATE_DEEP_SLEEP_3: - break; -# endif -#endif /* CONFIG_SYS_POWER_DEEP_SLEEP_STATES */ - - default: - ret = false; - break; - } - - return ret; -} - -/** - * @brief Function to disable power management idle exit notification - * - * The _sys_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_suspend to disable the corresponding _sys_resume notification. - * - */ -static inline void _sys_pm_idle_exit_notification_disable(void) -{ - sys_pm_idle_exit_notify = 0U; -} - -/** - * @brief Force usage of given power state. - * - * This function overrides decision made by PM policy - * forcing usage of given power state in all subsequent - * suspend operations. Forcing the SYS_POWER_STATE_AUTO - * state restores normal operation. - * - * @param state Power state which should be used in all - * subsequent suspend operations or - * SYS_POWER_STATE_AUTO. - */ -extern void sys_pm_force_power_state(enum power_states state); - -/** - * @brief Put processor into a power state. - * - * This function implements the SoC specific details necessary - * to put the processor into available power states. - */ -extern void sys_set_power_state(enum power_states state); - -#ifdef CONFIG_SYS_PM_DEBUG -/** - * @brief Dump Low Power states related debug info - * - * Dump Low Power states debug info like LPS entry count and residencies. - */ -extern void sys_pm_dump_debug_info(void); - -#endif /* CONFIG_SYS_PM_DEBUG */ - -#ifdef CONFIG_SYS_PM_STATE_LOCK -/** - * @brief Disable particular power state - * - * @details Disabled state cannot be selected by the Zephyr power - * management policies. Application defined policy should - * use the @ref sys_pm_ctrl_is_state_enabled function to - * check if given state could is enabled and could be used. - * - * @param [in] state Power state to be disabled. - */ -extern void sys_pm_ctrl_disable_state(enum power_states state); - -/** - * @brief Enable particular power state - * - * @details Enabled state can be selected by the Zephyr power - * management policies. Application defined policy should - * use the @ref sys_pm_ctrl_is_state_enabled function to - * check if given state could is enabled and could be used. - * By default all power states are enabled. - * - * @param [in] state Power state to be enabled. - */ -extern void sys_pm_ctrl_enable_state(enum power_states state); - -/** - * @brief Check if particular power state is enabled - * - * This function returns true if given power state is enabled. - * - * @param [in] state Power state. - */ -extern bool sys_pm_ctrl_is_state_enabled(enum power_states state); - -#endif /* CONFIG_SYS_PM_STATE_LOCK */ - -/** - * @} - */ - -/** - * @brief Power Management Hooks - * - * @defgroup power_management_hook_interface Power Management Hooks - * @ingroup power_management_api - * @{ - */ - -/** - * @brief Restore context to the point where system entered the deep sleep - * state. - * - * This function is optionally called when exiting from deep sleep if the SOC - * interface does not have bootloader support to handle resume from deep sleep. - * This function should restore context to the point where system entered - * the deep sleep state. - * - * If the function is called at cold boot it should return immediately. - * - * @note This function is not supported on all architectures. - */ -void _sys_resume_from_deep_sleep(void); - -/** - * @brief Notify exit from kernel idling after PM operations - * - * This function would notify exit from kernel idling if a corresponding - * _sys_suspend() notification was handled and did not return - * SYS_POWER_STATE_ACTIVE. - * - * This function would be called from the ISR context of the event - * that caused the exit from kernel idling. This will be called immediately - * 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 - * notification. Alternatively _sys_pm_idle_exit_notification_disable() can - * be called in _sys_suspend to disable this notification. - */ -void _sys_resume(void); - -/** - * @brief Allow entry to power state - * - * When the kernel is about to go idle, it calls this function to notify the - * power management subsystem, that the kernel is ready to enter the idle state. - * - * At this point, the kernel has disabled interrupts and computed the maximum - * time the system can remain idle. The function passes the time that the system - * can remain idle. The SOC interface performs power operations that can be done - * in the available time. The power management operations must halt execution of - * the CPU. - * - * This function assumes that a wake up event has already been set up by the - * application. - * - * This function is entered with interrupts disabled. It should re-enable - * interrupts if it had entered a power state. - * - * @param ticks The upcoming kernel idle time. - * - * @return Power state which was entered or SYS_POWER_STATE_ACTIVE if SoC was - * kept in the active state. - */ -extern enum power_states _sys_suspend(s32_t ticks); - -/** - * @brief Do any SoC or architecture specific post ops after sleep state exits. - * - * This function is a place holder to do any operations that may - * be needed to be done after sleep state exits. Currently it enables - * interrupts after resuming from sleep state. In future, the enabling - * of interrupts may be moved into the kernel. - */ -extern void _sys_pm_power_state_exit_post_ops(enum power_states state); - -/** - * @brief Application defined function for power state entry - * - * Application defined function for doing any target specific operations - * for power state entry. - */ -extern void sys_pm_notify_power_state_entry(enum power_states state); - -/** - * @brief Application defined function for sleep state exit - * - * Application defined function for doing any target specific operations - * for sleep state exit. - */ -extern void sys_pm_notify_power_state_exit(enum power_states state); - -/** - * @} - */ - -#endif /* CONFIG_SYS_POWER_MANAGEMENT */ - -#ifdef __cplusplus -} -#endif +#include #endif /* ZEPHYR_INCLUDE_POWER_H_ */ diff --git a/include/power/power.h b/include/power/power.h new file mode 100644 index 00000000000..c4c549e99ff --- /dev/null +++ b/include/power/power.h @@ -0,0 +1,324 @@ +/* + * Copyright (c) 2012-2014 Wind River Systems, Inc. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_INCLUDE_POWER_POWER_H_ +#define ZEPHYR_INCLUDE_POWER_POWER_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup power_management_api Power Management + * @{ + * @} + */ + +/** + * @brief System power states. + */ +enum power_states { + SYS_POWER_STATE_AUTO = (-2), + SYS_POWER_STATE_ACTIVE = (-1), +#ifdef CONFIG_SYS_POWER_SLEEP_STATES +# ifdef CONFIG_HAS_SYS_POWER_STATE_SLEEP_1 + SYS_POWER_STATE_SLEEP_1, +# endif +# ifdef CONFIG_HAS_SYS_POWER_STATE_SLEEP_2 + SYS_POWER_STATE_SLEEP_2, +# endif +# ifdef CONFIG_HAS_SYS_POWER_STATE_SLEEP_3 + SYS_POWER_STATE_SLEEP_3, +# endif +#endif /* CONFIG_SYS_POWER_SLEEP_STATES */ + +#ifdef CONFIG_SYS_POWER_DEEP_SLEEP_STATES +# ifdef CONFIG_HAS_SYS_POWER_STATE_DEEP_SLEEP_1 + SYS_POWER_STATE_DEEP_SLEEP_1, +# endif +# ifdef CONFIG_HAS_SYS_POWER_STATE_DEEP_SLEEP_2 + SYS_POWER_STATE_DEEP_SLEEP_2, +# endif +# ifdef CONFIG_HAS_SYS_POWER_STATE_DEEP_SLEEP_3 + SYS_POWER_STATE_DEEP_SLEEP_3, +# endif +#endif /* CONFIG_SYS_POWER_DEEP_SLEEP_STATES */ + SYS_POWER_STATE_MAX +}; + +#ifdef CONFIG_SYS_POWER_MANAGEMENT + +extern unsigned char sys_pm_idle_exit_notify; + +/** + * @brief System Power Management API + * + * @defgroup system_power_management_api System Power Management API + * @ingroup power_management_api + * @{ + */ + +/** + * @brief Check if particular power state is a sleep state. + * + * This function returns true if given power state is a sleep state. + */ +static inline bool sys_pm_is_sleep_state(enum power_states state) +{ + bool ret = true; + + switch (state) { +#ifdef CONFIG_SYS_POWER_SLEEP_STATES +# ifdef CONFIG_HAS_SYS_POWER_STATE_SLEEP_1 + case SYS_POWER_STATE_SLEEP_1: + break; +# endif +# ifdef CONFIG_HAS_SYS_POWER_STATE_SLEEP_2 + case SYS_POWER_STATE_SLEEP_2: + break; +# endif +# ifdef CONFIG_HAS_SYS_POWER_STATE_SLEEP_3 + case SYS_POWER_STATE_SLEEP_3: + break; +# endif +#endif /* CONFIG_SYS_POWER_SLEEP_STATES */ + default: + ret = false; + break; + } + + return ret; +} + +/** + * @brief Check if particular power state is a deep sleep state. + * + * This function returns true if given power state is a deep sleep state. + */ +static inline bool sys_pm_is_deep_sleep_state(enum power_states state) +{ + bool ret = true; + + switch (state) { +#ifdef CONFIG_SYS_POWER_DEEP_SLEEP_STATES +# ifdef CONFIG_HAS_SYS_POWER_STATE_DEEP_SLEEP_1 + case SYS_POWER_STATE_DEEP_SLEEP_1: + break; +# endif +# ifdef CONFIG_HAS_SYS_POWER_STATE_DEEP_SLEEP_2 + case SYS_POWER_STATE_DEEP_SLEEP_2: + break; +# endif +# ifdef CONFIG_HAS_SYS_POWER_STATE_DEEP_SLEEP_3 + case SYS_POWER_STATE_DEEP_SLEEP_3: + break; +# endif +#endif /* CONFIG_SYS_POWER_DEEP_SLEEP_STATES */ + + default: + ret = false; + break; + } + + return ret; +} + +/** + * @brief Function to disable power management idle exit notification + * + * The _sys_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_suspend to disable the corresponding _sys_resume notification. + * + */ +static inline void _sys_pm_idle_exit_notification_disable(void) +{ + sys_pm_idle_exit_notify = 0U; +} + +/** + * @brief Force usage of given power state. + * + * This function overrides decision made by PM policy + * forcing usage of given power state in all subsequent + * suspend operations. Forcing the SYS_POWER_STATE_AUTO + * state restores normal operation. + * + * @param state Power state which should be used in all + * subsequent suspend operations or + * SYS_POWER_STATE_AUTO. + */ +extern void sys_pm_force_power_state(enum power_states state); + +/** + * @brief Put processor into a power state. + * + * This function implements the SoC specific details necessary + * to put the processor into available power states. + */ +extern void sys_set_power_state(enum power_states state); + +#ifdef CONFIG_SYS_PM_DEBUG +/** + * @brief Dump Low Power states related debug info + * + * Dump Low Power states debug info like LPS entry count and residencies. + */ +extern void sys_pm_dump_debug_info(void); + +#endif /* CONFIG_SYS_PM_DEBUG */ + +#ifdef CONFIG_SYS_PM_STATE_LOCK +/** + * @brief Disable particular power state + * + * @details Disabled state cannot be selected by the Zephyr power + * management policies. Application defined policy should + * use the @ref sys_pm_ctrl_is_state_enabled function to + * check if given state could is enabled and could be used. + * + * @param [in] state Power state to be disabled. + */ +extern void sys_pm_ctrl_disable_state(enum power_states state); + +/** + * @brief Enable particular power state + * + * @details Enabled state can be selected by the Zephyr power + * management policies. Application defined policy should + * use the @ref sys_pm_ctrl_is_state_enabled function to + * check if given state could is enabled and could be used. + * By default all power states are enabled. + * + * @param [in] state Power state to be enabled. + */ +extern void sys_pm_ctrl_enable_state(enum power_states state); + +/** + * @brief Check if particular power state is enabled + * + * This function returns true if given power state is enabled. + * + * @param [in] state Power state. + */ +extern bool sys_pm_ctrl_is_state_enabled(enum power_states state); + +#endif /* CONFIG_SYS_PM_STATE_LOCK */ + +/** + * @} + */ + +/** + * @brief Power Management Hooks + * + * @defgroup power_management_hook_interface Power Management Hooks + * @ingroup power_management_api + * @{ + */ + +/** + * @brief Restore context to the point where system entered the deep sleep + * state. + * + * This function is optionally called when exiting from deep sleep if the SOC + * interface does not have bootloader support to handle resume from deep sleep. + * This function should restore context to the point where system entered + * the deep sleep state. + * + * If the function is called at cold boot it should return immediately. + * + * @note This function is not supported on all architectures. + */ +void _sys_resume_from_deep_sleep(void); + +/** + * @brief Notify exit from kernel idling after PM operations + * + * This function would notify exit from kernel idling if a corresponding + * _sys_suspend() notification was handled and did not return + * SYS_POWER_STATE_ACTIVE. + * + * This function would be called from the ISR context of the event + * that caused the exit from kernel idling. This will be called immediately + * 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 + * notification. Alternatively _sys_pm_idle_exit_notification_disable() can + * be called in _sys_suspend to disable this notification. + */ +void _sys_resume(void); + +/** + * @brief Allow entry to power state + * + * When the kernel is about to go idle, it calls this function to notify the + * power management subsystem, that the kernel is ready to enter the idle state. + * + * At this point, the kernel has disabled interrupts and computed the maximum + * time the system can remain idle. The function passes the time that the system + * can remain idle. The SOC interface performs power operations that can be done + * in the available time. The power management operations must halt execution of + * the CPU. + * + * This function assumes that a wake up event has already been set up by the + * application. + * + * This function is entered with interrupts disabled. It should re-enable + * interrupts if it had entered a power state. + * + * @param ticks The upcoming kernel idle time. + * + * @return Power state which was entered or SYS_POWER_STATE_ACTIVE if SoC was + * kept in the active state. + */ +extern enum power_states _sys_suspend(s32_t ticks); + +/** + * @brief Do any SoC or architecture specific post ops after sleep state exits. + * + * This function is a place holder to do any operations that may + * be needed to be done after sleep state exits. Currently it enables + * interrupts after resuming from sleep state. In future, the enabling + * of interrupts may be moved into the kernel. + */ +extern void _sys_pm_power_state_exit_post_ops(enum power_states state); + +/** + * @brief Application defined function for power state entry + * + * Application defined function for doing any target specific operations + * for power state entry. + */ +extern void sys_pm_notify_power_state_entry(enum power_states state); + +/** + * @brief Application defined function for sleep state exit + * + * Application defined function for doing any target specific operations + * for sleep state exit. + */ +extern void sys_pm_notify_power_state_exit(enum power_states state); + +/** + * @} + */ + +#endif /* CONFIG_SYS_POWER_MANAGEMENT */ + +#ifdef __cplusplus +} +#endif + +#endif /* ZEPHYR_INCLUDE_POWER_POWER_H_ */ diff --git a/kernel/idle.c b/kernel/idle.c index 0bb25dba7f2..2172c077c28 100644 --- a/kernel/idle.c +++ b/kernel/idle.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #ifdef CONFIG_TICKLESS_IDLE_THRESH diff --git a/samples/boards/nrf52/power_mgr/src/sample.h b/samples/boards/nrf52/power_mgr/src/sample.h index 74a3316a6cf..54dac237b2f 100644 --- a/samples/boards/nrf52/power_mgr/src/sample.h +++ b/samples/boards/nrf52/power_mgr/src/sample.h @@ -5,7 +5,7 @@ */ #include -#include +#include #include #include #include diff --git a/soc/arc/quark_se_c1000_ss/power.c b/soc/arc/quark_se_c1000_ss/power.c index bd314c24cdb..bcc89a2f9a0 100644 --- a/soc/arc/quark_se_c1000_ss/power.c +++ b/soc/arc/quark_se_c1000_ss/power.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/soc/arc/quark_se_c1000_ss/soc_power.h b/soc/arc/quark_se_c1000_ss/soc_power.h index 80fedb4e863..4a77fd599c8 100644 --- a/soc/arc/quark_se_c1000_ss/soc_power.h +++ b/soc/arc/quark_se_c1000_ss/soc_power.h @@ -7,7 +7,7 @@ #ifndef _SOC_POWER_H_ #define _SOC_POWER_H_ -#include +#include #ifdef __cplusplus extern "C" { diff --git a/soc/arm/arm/beetle/power.c b/soc/arm/arm/beetle/power.c index ec667553a33..1d8cfdae377 100644 --- a/soc/arm/arm/beetle/power.c +++ b/soc/arm/arm/beetle/power.c @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include diff --git a/soc/arm/nordic_nrf/nrf51/power.c b/soc/arm/nordic_nrf/nrf51/power.c index 9cb7c5af7c5..91de845073b 100644 --- a/soc/arm/nordic_nrf/nrf51/power.c +++ b/soc/arm/nordic_nrf/nrf51/power.c @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ #include -#include +#include #include #include diff --git a/soc/arm/nordic_nrf/nrf52/power.c b/soc/arm/nordic_nrf/nrf52/power.c index 9cb7c5af7c5..91de845073b 100644 --- a/soc/arm/nordic_nrf/nrf52/power.c +++ b/soc/arm/nordic_nrf/nrf52/power.c @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ #include -#include +#include #include #include diff --git a/soc/arm/silabs_exx32/common/soc_power.c b/soc/arm/silabs_exx32/common/soc_power.c index 87bda44cab4..609e8dbb482 100644 --- a/soc/arm/silabs_exx32/common/soc_power.c +++ b/soc/arm/silabs_exx32/common/soc_power.c @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ #include -#include +#include #include #include diff --git a/soc/x86/intel_quark/quark_se/power.c b/soc/x86/intel_quark/quark_se/power.c index 51adfb58865..b2d7e146362 100644 --- a/soc/x86/intel_quark/quark_se/power.c +++ b/soc/x86/intel_quark/quark_se/power.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include diff --git a/soc/x86/intel_quark/quark_se/soc_power.h b/soc/x86/intel_quark/quark_se/soc_power.h index 741c2d7a396..521236c125e 100644 --- a/soc/x86/intel_quark/quark_se/soc_power.h +++ b/soc/x86/intel_quark/quark_se/soc_power.h @@ -7,7 +7,7 @@ #ifndef _SOC_POWER_H_ #define _SOC_POWER_H_ -#include +#include #ifdef __cplusplus extern "C" { diff --git a/subsys/power/policy/pm_policy.h b/subsys/power/policy/pm_policy.h index f65f42cebfd..71761d3f65f 100644 --- a/subsys/power/policy/pm_policy.h +++ b/subsys/power/policy/pm_policy.h @@ -7,7 +7,7 @@ #ifndef _PM_POLICY_H_ #define _PM_POLICY_H_ -#include +#include #ifdef __cplusplus extern "C" { diff --git a/subsys/power/power.c b/subsys/power/power.c index 8e5c603c19e..d90923c4f46 100644 --- a/subsys/power/power.c +++ b/subsys/power/power.c @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include "policy/pm_policy.h" #define LOG_LEVEL CONFIG_SYS_PM_LOG_LEVEL diff --git a/tests/kernel/profiling/profiling_api/src/main.c b/tests/kernel/profiling/profiling_api/src/main.c index 9dd65a13dc7..3682a766507 100644 --- a/tests/kernel/profiling/profiling_api/src/main.c +++ b/tests/kernel/profiling/profiling_api/src/main.c @@ -5,7 +5,7 @@ */ #include -#include +#include #include #include diff --git a/tests/kernel/tickless/tickless_concept/src/main.c b/tests/kernel/tickless/tickless_concept/src/main.c index 96585f6eb7a..e5aeacca3a7 100644 --- a/tests/kernel/tickless/tickless_concept/src/main.c +++ b/tests/kernel/tickless/tickless_concept/src/main.c @@ -5,7 +5,7 @@ */ #include -#include +#include #define STACK_SIZE (512 + CONFIG_TEST_EXTRA_STACKSIZE) #define NUM_THREAD 4