power: Rework OS <-> Application interface
This commit simplifies OS <-> Application interface controlling power management. In the previous approach application-based PM required overriding sys_suspend() and sys_resume() functions. As these functions actually implemented power state change, in such case application basically had to provide own implementation of all PM-related stuff, which was not portable and hard to maintain. This commit changes this scheme: The sys_suspend() and sys_resume() are now system functions while the application could either use built-in power management policies or provide its own. All details of power mode switching are now handled by the OS. Also, this commit cleans up the Kconfig options related to system-level power management grouping them under common CONFIG_SYS_PM_ prefix. Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
This commit is contained in:
parent
c330f32079
commit
c45961daae
26 changed files with 126 additions and 280 deletions
|
@ -150,7 +150,7 @@ static inline void sys_pm_idle_exit_notification_disable(void)
|
|||
*/
|
||||
extern void sys_pm_force_power_state(enum power_states state);
|
||||
|
||||
#ifdef CONFIG_PM_CONTROL_OS_DEBUG
|
||||
#ifdef CONFIG_SYS_PM_DEBUG
|
||||
/**
|
||||
* @brief Dump Low Power states related debug info
|
||||
*
|
||||
|
@ -158,9 +158,9 @@ extern void sys_pm_force_power_state(enum power_states state);
|
|||
*/
|
||||
extern void sys_pm_dump_debug_info(void);
|
||||
|
||||
#endif /* CONFIG_PM_CONTROL_OS_DEBUG */
|
||||
#endif /* CONFIG_SYS_PM_DEBUG */
|
||||
|
||||
#ifdef CONFIG_PM_CONTROL_STATE_LOCK
|
||||
#ifdef CONFIG_SYS_PM_STATE_LOCK
|
||||
/**
|
||||
* @brief Disable particular power state
|
||||
*
|
||||
|
@ -195,7 +195,7 @@ extern void sys_pm_ctrl_enable_state(enum power_states state);
|
|||
*/
|
||||
extern bool sys_pm_ctrl_is_state_enabled(enum power_states state);
|
||||
|
||||
#endif /* CONFIG_PM_CONTROL_STATE_LOCK */
|
||||
#endif /* CONFIG_SYS_PM_STATE_LOCK */
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
@ -274,6 +274,40 @@ void sys_resume(void);
|
|||
*/
|
||||
extern enum power_states sys_suspend(s32_t ticks);
|
||||
|
||||
/**
|
||||
* @brief Put processor into low 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);
|
||||
|
||||
/**
|
||||
* @brief Do any SoC or architecture specific post ops after low power states.
|
||||
*
|
||||
* This function is a place holder to do any operations that may
|
||||
* be needed to be done after deep sleep exits. Currently it enables
|
||||
* interrupts after resuming from deep sleep. In future, the enabling
|
||||
* of interrupts may be moved into the kernel.
|
||||
*/
|
||||
extern void sys_power_state_post_ops(enum power_states state);
|
||||
|
||||
/**
|
||||
* @brief Application defined function for Lower Power entry
|
||||
*
|
||||
* Application defined function for doing any target specific operations
|
||||
* for low power entry.
|
||||
*/
|
||||
extern void sys_pm_notify_lps_entry(enum power_states state);
|
||||
|
||||
/**
|
||||
* @brief Application defined function for Lower Power exit
|
||||
*
|
||||
* Application defined function for doing any target specific operations
|
||||
* for low power exit.
|
||||
*/
|
||||
extern void sys_pm_notify_lps_exit(enum power_states state);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
@ -15,29 +15,6 @@ menuconfig SYS_POWER_MANAGEMENT
|
|||
timer is due to expire.
|
||||
|
||||
if SYS_POWER_MANAGEMENT
|
||||
choice POWER_MANAGEMENT_CONTROL
|
||||
prompt "Power Management Control"
|
||||
default PM_CONTROL_APP
|
||||
help
|
||||
Select the Application managed or OS managed power saving
|
||||
mechanism.
|
||||
|
||||
config PM_CONTROL_APP
|
||||
bool
|
||||
prompt "Handled at Application level"
|
||||
help
|
||||
This option enables the Application to handle all the Power
|
||||
Management flows for the platform.
|
||||
|
||||
config PM_CONTROL_OS
|
||||
bool
|
||||
prompt "Handle at OS level"
|
||||
help
|
||||
This option allows the OS to handle all the Power
|
||||
Management flows for the platform.
|
||||
|
||||
endchoice # POWER_MANAGEMENT_CONTROL
|
||||
|
||||
config SYS_POWER_LOW_POWER_STATES
|
||||
bool "Low Power states"
|
||||
depends on SYS_POWER_LOW_POWER_STATES_SUPPORTED
|
||||
|
@ -60,6 +37,8 @@ config SYS_POWER_DEEP_SLEEP_STATES
|
|||
from the reset vector same as cold boot. The interface allows
|
||||
restoration of states that were saved at the time of suspend.
|
||||
|
||||
source "subsys/power/Kconfig"
|
||||
|
||||
endif # SYS_POWER_MANAGEMENT
|
||||
|
||||
config DEVICE_POWER_MANAGEMENT
|
||||
|
|
|
@ -4,8 +4,7 @@ CONFIG_SYS_POWER_MANAGEMENT=y
|
|||
CONFIG_SYS_POWER_LOW_POWER_STATES=y
|
||||
CONFIG_SYS_POWER_DEEP_SLEEP_STATES=y
|
||||
CONFIG_DEVICE_POWER_MANAGEMENT=y
|
||||
CONFIG_PM_CONTROL_OS=y
|
||||
CONFIG_PM_CONTROL_STATE_LOCK=y
|
||||
CONFIG_PM_LPS_1_MIN_RES=5
|
||||
CONFIG_PM_LPS_2_MIN_RES=15
|
||||
CONFIG_SYS_PM_STATE_LOCK=y
|
||||
CONFIG_SYS_PM_LPS_1_MIN_RES=5
|
||||
CONFIG_SYS_PM_LPS_2_MIN_RES=15
|
||||
CONFIG_GPIO=y
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <zephyr.h>
|
||||
#include <power.h>
|
||||
#include <string.h>
|
||||
#include <soc.h>
|
||||
#include <device.h>
|
||||
|
|
|
@ -30,53 +30,6 @@ extern "C" {
|
|||
* SYS_POWER_STATE_DEEP_SLEEP_2: SLEEP state with LPMODE enabled
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Put processor into low power state
|
||||
*
|
||||
* This function implements the SoC specific details necessary
|
||||
* to put the processor into available power states.
|
||||
*
|
||||
* Wake up considerations:
|
||||
* -----------------------
|
||||
*
|
||||
* SYS_POWER_STATE_CPU_LPS: Any interrupt works as wake event.
|
||||
*
|
||||
* SYS_POWER_STATE_CPU_LPS_1: Any interrupt works as wake event except
|
||||
* the ARC TIMER which is disabled.
|
||||
*
|
||||
* SYS_POWER_STATE_CPU_LPS_2: SYS_POWER_STATE_DEEP_SLEEP wake events applies.
|
||||
*
|
||||
* SYS_POWER_STATE_DEEP_SLEEP: Only Always-On peripherals can wake up
|
||||
* the SoC. This consists of the Counter, RTC, GPIO 1 and AIO Comparator.
|
||||
*
|
||||
* SYS_POWER_STATE_DEEP_SLEEP_1: Only Always-On peripherals can wake up
|
||||
* the SoC. This consists of the Counter, RTC, GPIO 1 and AIO Comparator.
|
||||
*
|
||||
* SYS_POWER_STATE_DEEP_SLEEP_2: Only Always-On peripherals can wake up
|
||||
* the SoC. This consists of the Counter, RTC, GPIO 1 and AIO Comparator.
|
||||
*
|
||||
* Considerations around SYS_POWER_STATE_CPU_LPS (LPSS state):
|
||||
* -----------------------------------------------------------
|
||||
*
|
||||
* LPSS is a common power state between the x86 and ARC.
|
||||
* When the two applications enter SYS_POWER_STATE_CPU_LPS,
|
||||
* the SoC will enter this lower consumption mode.
|
||||
* After wake up, this state can only be entered again
|
||||
* if the ARC wakes up and transitions again to
|
||||
* SYS_POWER_STATE_CPU_LPS. This is not required on the x86 side.
|
||||
*/
|
||||
void sys_set_power_state(enum power_states state);
|
||||
|
||||
/**
|
||||
* @brief Do any SoC or architecture specific post ops after low power states.
|
||||
*
|
||||
* This function is a place holder to do any operations that may
|
||||
* be needed to be done after deep sleep exits. Currently it enables
|
||||
* interrupts after resuming from deep sleep. In future, the enabling
|
||||
* of interrupts may be moved into the kernel.
|
||||
*/
|
||||
void sys_power_state_post_ops(enum power_states state);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <zephyr.h>
|
||||
#include <soc_power.h>
|
||||
#include <power.h>
|
||||
#include <nrf_power.h>
|
||||
|
||||
#include <logging/log.h>
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
#include <nrf_common.h>
|
||||
#include <nrf.h>
|
||||
|
||||
#include <soc_power.h>
|
||||
|
||||
/* Add include for DTS generated information */
|
||||
#include <generated_dts_board.h>
|
||||
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Intel Corporation.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _SOC_POWER_H_
|
||||
#define _SOC_POWER_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <power.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SYS_POWER_MANAGEMENT
|
||||
|
||||
/*
|
||||
* Power state map:
|
||||
* SYS_POWER_STATE_DEEP_SLEEP: System OFF
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Put processor into low power state
|
||||
*/
|
||||
void sys_set_power_state(enum power_states state);
|
||||
|
||||
/**
|
||||
* @brief Do any SoC or architecture specific post ops after low power states.
|
||||
*/
|
||||
void sys_power_state_post_ops(enum power_states state);
|
||||
|
||||
#endif /* CONFIG_SYS_POWER_MANAGEMENT */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SOC_POWER_H_ */
|
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <zephyr.h>
|
||||
#include <soc_power.h>
|
||||
#include <power.h>
|
||||
#include <nrf_power.h>
|
||||
|
||||
#include <logging/log.h>
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
#include <nrf_common.h>
|
||||
#include <nrf.h>
|
||||
|
||||
#include <soc_power.h>
|
||||
|
||||
/* Add include for DTS generated information */
|
||||
#include <generated_dts_board.h>
|
||||
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Intel Corporation.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _SOC_POWER_H_
|
||||
#define _SOC_POWER_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <power.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SYS_POWER_MANAGEMENT
|
||||
|
||||
/*
|
||||
* Power state map:
|
||||
* SYS_POWER_STATE_DEEP_SLEEP: System OFF
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Put processor into low power state
|
||||
*/
|
||||
void sys_set_power_state(enum power_states state);
|
||||
|
||||
/**
|
||||
* @brief Do any SoC or architecture specific post ops after low power states.
|
||||
*/
|
||||
void sys_power_state_post_ops(enum power_states state);
|
||||
|
||||
#endif /* CONFIG_SYS_POWER_MANAGEMENT */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SOC_POWER_H_ */
|
|
@ -30,41 +30,6 @@ extern "C" {
|
|||
* SYS_POWER_STATE_DEEP_SLEEP_1: SLEEP state with LPMODE enabled
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Put processor into low power state
|
||||
*
|
||||
* This function implements the SoC specific details necessary
|
||||
* to put the processor into available power states.
|
||||
*
|
||||
* Wake up considerations:
|
||||
* SYS_POWER_STATE_CPU_LPS: Any interrupt works as wake event.
|
||||
*
|
||||
* SYS_POWER_STATE_CPU_LPS_1: Any interrupt works as wake event except
|
||||
* if the core enters LPSS where SYS_POWER_STATE_DEEP_SLEEP wake events
|
||||
* applies.
|
||||
*
|
||||
* SYS_POWER_STATE_CPU_LPS_2: Any interrupt works as wake event except the
|
||||
* PIC timer which is gated. If the core enters LPSS only
|
||||
* SYS_POWER_STATE_DEEP_SLEEP wake events applies.
|
||||
*
|
||||
* SYS_POWER_STATE_DEEP_SLEEP: Only Always-On peripherals can wake up
|
||||
* the SoC. This consists of the Counter, RTC, GPIO 1 and AIO Comparator.
|
||||
*
|
||||
* SYS_POWER_STATE_DEEP_SLEEP_1: Only Always-On peripherals can wake up
|
||||
* the SoC. This consists of the Counter, RTC, GPIO 1 and AIO Comparator.
|
||||
*/
|
||||
void sys_set_power_state(enum power_states state);
|
||||
|
||||
/**
|
||||
* @brief Do any SoC or architecture specific post ops after low power states.
|
||||
*
|
||||
* This function is a place holder to do any operations that may
|
||||
* be needed to be done after deep sleep exits. Currently it enables
|
||||
* interrupts after resuming from deep sleep. In future, the enabling
|
||||
* of interrupts may be moved into the kernel.
|
||||
*/
|
||||
void sys_power_state_post_ops(enum power_states state);
|
||||
|
||||
/**
|
||||
* @brief Check if ARC core is ready to enter in DEEP_SLEEP states.
|
||||
*
|
||||
|
|
|
@ -37,8 +37,6 @@ source "subsys/settings/Kconfig"
|
|||
|
||||
source "subsys/app_memory/Kconfig"
|
||||
|
||||
source "subsys/power/Kconfig"
|
||||
|
||||
source "subsys/fb/Kconfig"
|
||||
|
||||
source "subsys/jwt/Kconfig"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
zephyr_sources_ifdef(CONFIG_PM_CONTROL_OS
|
||||
zephyr_sources_ifdef(CONFIG_SYS_POWER_MANAGEMENT
|
||||
power.c
|
||||
device.c
|
||||
)
|
||||
zephyr_sources_ifdef(CONFIG_PM_CONTROL_STATE_LOCK pm_ctrl.c)
|
||||
add_subdirectory_ifdef(CONFIG_PM_CONTROL_OS policy)
|
||||
zephyr_sources_ifdef(CONFIG_SYS_PM_STATE_LOCK pm_ctrl.c)
|
||||
zephyr_sources_if_kconfig(reboot.c)
|
||||
add_subdirectory(policy)
|
||||
|
|
|
@ -1,25 +1,18 @@
|
|||
|
||||
if PM_CONTROL_OS
|
||||
menu "OS Power Management"
|
||||
|
||||
source "subsys/power/policy/Kconfig"
|
||||
|
||||
config PM_CONTROL_STATE_LOCK
|
||||
bool "Enable PM state locking capability"
|
||||
config SYS_PM_STATE_LOCK
|
||||
bool "Enable Power State locking capability"
|
||||
help
|
||||
Enable OS Power Management state locking capability
|
||||
Enable Power Management system state locking capability
|
||||
if any application wants to temporarily disable certain
|
||||
Power States while doing any critical work or needs quick
|
||||
response from hardware resources.
|
||||
|
||||
config PM_CONTROL_OS_DEBUG
|
||||
bool "Enable OS Power Management debug hooks"
|
||||
config SYS_PM_DEBUG
|
||||
bool "Enable System Power Management debug hooks"
|
||||
help
|
||||
Enable OS Power Management debugging hooks.
|
||||
Enable System Power Management debugging hooks.
|
||||
|
||||
module = PM
|
||||
module-str = Power Management
|
||||
source "subsys/power/policy/Kconfig"
|
||||
|
||||
module = SYS_PM
|
||||
module-str = System Power Management
|
||||
source "subsys/logging/Kconfig.template.log_config"
|
||||
|
||||
endmenu
|
||||
endif # PM_CONTROL_OS
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <device.h>
|
||||
#include "policy/pm_policy.h"
|
||||
|
||||
#define LOG_LEVEL CONFIG_PM_LOG_LEVEL /* From power module Kconfig */
|
||||
#define LOG_LEVEL CONFIG_SYS_PM_LOG_LEVEL /* From power module Kconfig */
|
||||
#include <logging/log.h>
|
||||
LOG_MODULE_DECLARE(power);
|
||||
|
||||
|
|
|
@ -6,12 +6,11 @@
|
|||
|
||||
#include <zephyr.h>
|
||||
#include <string.h>
|
||||
#include <soc.h>
|
||||
#include <device.h>
|
||||
#include <atomic.h>
|
||||
#include "policy/pm_policy.h"
|
||||
|
||||
#define LOG_LEVEL CONFIG_PM_LOG_LEVEL /* From power module Kconfig */
|
||||
#define LOG_LEVEL CONFIG_SYS_PM_LOG_LEVEL /* From power module Kconfig */
|
||||
#include <logging/log.h>
|
||||
LOG_MODULE_DECLARE(power);
|
||||
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
zephyr_sources_ifdef(CONFIG_PM_POLICY_DUMMY policy_dummy.c)
|
||||
zephyr_sources_ifdef(CONFIG_PM_POLICY_RESIDENCY policy_residency.c)
|
||||
zephyr_sources_ifdef(CONFIG_SYS_PM_POLICY_DUMMY policy_dummy.c)
|
||||
zephyr_sources_ifdef(CONFIG_SYS_PM_POLICY_RESIDENCY policy_residency.c)
|
||||
|
|
|
@ -1,64 +1,67 @@
|
|||
|
||||
choice
|
||||
prompt "Idle State Power Management Policy"
|
||||
depends on PM_CONTROL_OS
|
||||
help
|
||||
Storage back-end to be used by the settings subsystem.
|
||||
|
||||
config PM_POLICY_RESIDENCY
|
||||
config SYS_PM_POLICY_RESIDENCY
|
||||
bool "PM Policy based on CPU residency"
|
||||
help
|
||||
Select this option for PM policy based on CPU residencies.
|
||||
|
||||
config PM_POLICY_DUMMY
|
||||
config SYS_PM_POLICY_DUMMY
|
||||
bool "Dummy PM Policy"
|
||||
help
|
||||
Dummy PM Policy which simply returns next PM state in a loop.
|
||||
|
||||
config SYS_PM_POLICY_APP
|
||||
bool "Application PM Policy"
|
||||
help
|
||||
When this option is selected, the application must provide PM policy.
|
||||
|
||||
endchoice
|
||||
|
||||
if PM_POLICY_RESIDENCY
|
||||
if SYS_PM_POLICY_RESIDENCY
|
||||
|
||||
config PM_LPS_MIN_RES
|
||||
config SYS_PM_LPS_MIN_RES
|
||||
int "LPS minimum residency"
|
||||
depends on SYS_POWER_STATE_CPU_LPS_SUPPORTED
|
||||
default 5
|
||||
help
|
||||
Minimum residency in ticks to enter LPS state.
|
||||
|
||||
config PM_LPS_1_MIN_RES
|
||||
config SYS_PM_LPS_1_MIN_RES
|
||||
int "LPS_1 minimum residency"
|
||||
depends on SYS_POWER_STATE_CPU_LPS_1_SUPPORTED
|
||||
default 10
|
||||
help
|
||||
Minimum residency in ticks to enter LPS_1 state.
|
||||
|
||||
config PM_LPS_2_MIN_RES
|
||||
config SYS_PM_LPS_2_MIN_RES
|
||||
int "LPS_2 minimum residency"
|
||||
depends on SYS_POWER_STATE_CPU_LPS_2_SUPPORTED
|
||||
default 30
|
||||
help
|
||||
Minimum residency in ticks to enter LPS_2 state.
|
||||
|
||||
config PM_DEEP_SLEEP_MIN_RES
|
||||
config SYS_PM_DEEP_SLEEP_MIN_RES
|
||||
int "DEEP_SLEEP minimum residency"
|
||||
depends on SYS_POWER_STATE_DEEP_SLEEP_SUPPORTED
|
||||
default 60
|
||||
help
|
||||
Minimum residency in ticks to enter DEEP_SLEEP state.
|
||||
|
||||
config PM_DEEP_SLEEP_1_MIN_RES
|
||||
config SYS_PM_DEEP_SLEEP_1_MIN_RES
|
||||
int "DEEP_SLEEP_1 minimum residency"
|
||||
depends on SYS_POWER_STATE_DEEP_SLEEP_1_SUPPORTED
|
||||
default 90
|
||||
help
|
||||
Minimum residency in ticks to enter DEEP_SLEEP_1 state.
|
||||
|
||||
config PM_DEEP_SLEEP_2_MIN_RES
|
||||
config SYS_PM_DEEP_SLEEP_2_MIN_RES
|
||||
int "DEEP_SLEEP_2 minimum residency"
|
||||
depends on SYS_POWER_STATE_DEEP_SLEEP_2_SUPPORTED
|
||||
default 120
|
||||
help
|
||||
Minimum residency in ticks to enter DEEP_SLEEP_2 state.
|
||||
|
||||
endif # PM_POLICY_RESIDENCY
|
||||
endif # SYS_PM_POLICY_RESIDENCY
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#define _PM_POLICY_H_
|
||||
|
||||
#include <power.h>
|
||||
#include <soc_power.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -39,22 +38,6 @@ extern void sys_pm_resume_devices(void);
|
|||
*/
|
||||
extern enum power_states sys_pm_policy_next_state(s32_t ticks);
|
||||
|
||||
/**
|
||||
* @brief Application defined function for Lower Power entry
|
||||
*
|
||||
* Application defined function for doing any target specific operations
|
||||
* for low power entry.
|
||||
*/
|
||||
extern void sys_pm_notify_lps_entry(enum power_states state);
|
||||
|
||||
/**
|
||||
* @brief Application defined function for Lower Power exit
|
||||
*
|
||||
* Application defined function for doing any target specific operations
|
||||
* for low power exit.
|
||||
*/
|
||||
extern void sys_pm_notify_lps_exit(enum power_states state);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -6,11 +6,10 @@
|
|||
|
||||
#include <zephyr.h>
|
||||
#include <kernel.h>
|
||||
#include <soc.h>
|
||||
#include "pm_policy.h"
|
||||
|
||||
#include <logging/log.h>
|
||||
LOG_MODULE_DECLARE(power, CONFIG_PM_LOG_LEVEL);
|
||||
LOG_MODULE_DECLARE(power, CONFIG_SYS_PM_LOG_LEVEL);
|
||||
|
||||
enum power_states sys_pm_policy_next_state(s32_t ticks)
|
||||
{
|
||||
|
@ -25,7 +24,7 @@ enum power_states sys_pm_policy_next_state(s32_t ticks)
|
|||
do {
|
||||
i = (i + 1) % SYS_POWER_STATE_MAX;
|
||||
|
||||
#ifdef CONFIG_PM_CONTROL_STATE_LOCK
|
||||
#ifdef CONFIG_SYS_PM_STATE_LOCK
|
||||
if (!sys_pm_ctrl_is_state_enabled((enum power_states)(i))) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -6,10 +6,9 @@
|
|||
|
||||
#include <zephyr.h>
|
||||
#include <kernel.h>
|
||||
#include <soc.h>
|
||||
#include "pm_policy.h"
|
||||
|
||||
#define LOG_LEVEL CONFIG_PM_LOG_LEVEL /* From power module Kconfig */
|
||||
#define LOG_LEVEL CONFIG_SYS_PM_LOG_LEVEL /* From power module Kconfig */
|
||||
#include <logging/log.h>
|
||||
LOG_MODULE_DECLARE(power);
|
||||
|
||||
|
@ -18,27 +17,27 @@ LOG_MODULE_DECLARE(power);
|
|||
/* PM Policy based on SoC/Platform residency requirements */
|
||||
static const unsigned int pm_min_residency[] = {
|
||||
#ifdef CONFIG_SYS_POWER_STATE_CPU_LPS_SUPPORTED
|
||||
CONFIG_PM_LPS_MIN_RES * SECS_TO_TICKS,
|
||||
CONFIG_SYS_PM_LPS_MIN_RES * SECS_TO_TICKS,
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SYS_POWER_STATE_CPU_LPS_1_SUPPORTED
|
||||
CONFIG_PM_LPS_1_MIN_RES * SECS_TO_TICKS,
|
||||
CONFIG_SYS_PM_LPS_1_MIN_RES * SECS_TO_TICKS,
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SYS_POWER_STATE_CPU_LPS_2_SUPPORTED
|
||||
CONFIG_PM_LPS_2_MIN_RES * SECS_TO_TICKS,
|
||||
CONFIG_SYS_PM_LPS_2_MIN_RES * SECS_TO_TICKS,
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SYS_POWER_STATE_DEEP_SLEEP_SUPPORTED
|
||||
CONFIG_PM_DEEP_SLEEP_MIN_RES * SECS_TO_TICKS,
|
||||
CONFIG_SYS_PM_DEEP_SLEEP_MIN_RES * SECS_TO_TICKS,
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SYS_POWER_STATE_DEEP_SLEEP_1_SUPPORTED
|
||||
CONFIG_PM_DEEP_SLEEP_1_MIN_RES * SECS_TO_TICKS,
|
||||
CONFIG_SYS_PM_DEEP_SLEEP_1_MIN_RES * SECS_TO_TICKS,
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SYS_POWER_STATE_DEEP_SLEEP_2_SUPPORTED
|
||||
CONFIG_PM_DEEP_SLEEP_2_MIN_RES * SECS_TO_TICKS,
|
||||
CONFIG_SYS_PM_DEEP_SLEEP_2_MIN_RES * SECS_TO_TICKS,
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -52,7 +51,7 @@ enum power_states sys_pm_policy_next_state(s32_t ticks)
|
|||
}
|
||||
|
||||
for (i = ARRAY_SIZE(pm_min_residency) - 1; i >= 0; i--) {
|
||||
#ifdef CONFIG_PM_CONTROL_STATE_LOCK
|
||||
#ifdef CONFIG_SYS_PM_STATE_LOCK
|
||||
if (!sys_pm_ctrl_is_state_enabled((enum power_states)(i))) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
#include <kernel.h>
|
||||
#include <init.h>
|
||||
#include <string.h>
|
||||
#include <soc.h>
|
||||
#include <power.h>
|
||||
#include "policy/pm_policy.h"
|
||||
|
||||
#define LOG_LEVEL CONFIG_PM_LOG_LEVEL
|
||||
#define LOG_LEVEL CONFIG_SYS_PM_LOG_LEVEL
|
||||
#include <logging/log.h>
|
||||
LOG_MODULE_REGISTER(power);
|
||||
|
||||
|
@ -19,7 +19,7 @@ static int post_ops_done = 1;
|
|||
static enum power_states forced_pm_state = SYS_POWER_STATE_AUTO;
|
||||
static enum power_states pm_state;
|
||||
|
||||
#ifdef CONFIG_PM_CONTROL_OS_DEBUG
|
||||
#ifdef CONFIG_SYS_PM_DEBUG
|
||||
|
||||
struct pm_debug_info {
|
||||
u32_t count;
|
||||
|
@ -95,9 +95,10 @@ enum power_states sys_suspend(s32_t ticks)
|
|||
return pm_state;
|
||||
}
|
||||
|
||||
deep_sleep = sys_pm_is_deep_sleep_state(pm_state);
|
||||
post_ops_done = 0;
|
||||
deep_sleep = IS_ENABLED(CONFIG_SYS_POWER_DEEP_SLEEP_STATES) ?
|
||||
sys_pm_is_deep_sleep_state(pm_state) : 0;
|
||||
|
||||
post_ops_done = 0;
|
||||
sys_pm_notify_lps_entry(pm_state);
|
||||
|
||||
if (deep_sleep) {
|
||||
|
|
12
tests/kernel/profiling/profiling_api/Kconfig
Normal file
12
tests/kernel/profiling/profiling_api/Kconfig
Normal file
|
@ -0,0 +1,12 @@
|
|||
config KERNEL_PROFILING_API_TEST
|
||||
bool
|
||||
default y
|
||||
select SYS_POWER_LOW_POWER_STATES_SUPPORTED
|
||||
select SYS_POWER_STATE_CPU_LPS_SUPPORTED
|
||||
help
|
||||
Hidden option enabling LPS power state regardless of hardware
|
||||
support. This ensures that power management hooks used in this
|
||||
test to profile idle thread will be executed.
|
||||
|
||||
# Include Zephyr's Kconfig.
|
||||
source "$ZEPHYR_BASE/Kconfig"
|
|
@ -8,8 +8,9 @@ CONFIG_TEST_HW_STACK_PROTECTION=n
|
|||
# to check idle thread
|
||||
CONFIG_SYS_POWER_MANAGEMENT=y
|
||||
CONFIG_SYS_POWER_LOW_POWER_STATES=y
|
||||
CONFIG_IDLE_STACK_SIZE=512
|
||||
CONFIG_SYS_PM_POLICY_APP=y
|
||||
CONFIG_IDLE_STACK_SIZE=768
|
||||
|
||||
# to check isr
|
||||
CONFIG_IRQ_OFFLOAD=y
|
||||
CONFIG_ISR_STACK_SIZE=512
|
||||
CONFIG_ISR_STACK_SIZE=768
|
||||
|
|
|
@ -23,9 +23,24 @@ static void tdata_dump_callback(const struct k_thread *thread, void *user_data)
|
|||
thread->stack_info.size);
|
||||
}
|
||||
|
||||
/*power hook functions*/
|
||||
/*
|
||||
* Weak power hook functions. Used on systems that have not implemented
|
||||
* power management.
|
||||
*/
|
||||
__weak void sys_set_power_state(enum power_states state)
|
||||
{
|
||||
/* Never called. */
|
||||
__ASSERT_NO_MSG(false);
|
||||
}
|
||||
|
||||
enum power_states sys_suspend(s32_t ticks)
|
||||
__weak void sys_power_state_post_ops(enum power_states state)
|
||||
{
|
||||
/* Never called. */
|
||||
__ASSERT_NO_MSG(false);
|
||||
}
|
||||
|
||||
/* Our PM policy handler */
|
||||
enum power_states sys_pm_policy_next_state(s32_t ticks)
|
||||
{
|
||||
static bool test_flag;
|
||||
|
||||
|
@ -40,10 +55,6 @@ enum power_states sys_suspend(s32_t ticks)
|
|||
return SYS_POWER_STATE_ACTIVE;
|
||||
}
|
||||
|
||||
void sys_resume(void)
|
||||
{
|
||||
}
|
||||
|
||||
/*work handler*/
|
||||
static void work_handler(struct k_work *w)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue