power: remove SYS_ and sys_ prefixes

Remove SYS_ and sys_ from all PM related functions and defines.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
Anas Nashif 2020-09-01 21:46:30 -04:00
parent 142c3060e7
commit e0f3833bf7
45 changed files with 270 additions and 270 deletions

View file

@ -25,7 +25,7 @@ GTEXT(_isr_wrapper)
GTEXT(_isr_demux)
#if defined(CONFIG_PM)
GTEXT(z_sys_power_save_idle_exit)
GTEXT(z_pm_save_idle_exit)
#endif
/*
@ -249,14 +249,14 @@ rirq_path:
clri r0 /* do not interrupt exiting tickless idle operations */
mov_s r1, _kernel
ld_s r3, [r1, _kernel_offset_to_idle] /* requested idle duration */
breq r3, 0, _skip_sys_power_save_idle_exit
breq r3, 0, _skip_pm_save_idle_exit
st 0, [r1, _kernel_offset_to_idle] /* zero idle duration */
push_s blink
jl z_sys_power_save_idle_exit
jl z_pm_save_idle_exit
pop_s blink
_skip_sys_power_save_idle_exit:
_skip_pm_save_idle_exit:
seti r0
#endif
.endm

View file

@ -184,7 +184,7 @@ void _arch_isr_direct_pm(void)
int32_t idle_val = _kernel.idle;
_kernel.idle = 0;
z_sys_power_save_idle_exit(idle_val);
z_pm_save_idle_exit(idle_val);
}
#if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE) \

View file

@ -90,7 +90,7 @@ SECTION_FUNC(TEXT, _isr_wrapper)
* idle, this ensures that the calculation and programming of the
* device for the next timer deadline is not interrupted. For
* non-tickless idle, this ensures that the clearing of the kernel idle
* state is not interrupted. In each case, z_sys_power_save_idle_exit
* state is not interrupted. In each case, z_pm_save_idle_exit
* is called with interrupts disabled.
*/
@ -115,7 +115,7 @@ SECTION_FUNC(TEXT, _isr_wrapper)
movs.n r1, #0
/* clear kernel idle state */
str r1, [r2, #_kernel_offset_to_idle]
bl z_sys_power_save_idle_exit
bl z_pm_save_idle_exit
_idle_state_cleared:
#elif defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE)
@ -123,13 +123,13 @@ _idle_state_cleared:
movne r1, #0
/* clear kernel idle state */
strne r1, [r2, #_kernel_offset_to_idle]
blne z_sys_power_save_idle_exit
blne z_pm_save_idle_exit
#elif defined(CONFIG_ARMV7_R)
beq _idle_state_cleared
movs r1, #0
/* clear kernel idle state */
str r1, [r2, #_kernel_offset_to_idle]
bl z_sys_power_save_idle_exit
bl z_pm_save_idle_exit
_idle_state_cleared:
#else
#error Unknown ARM architecture

View file

@ -11,7 +11,7 @@
*
* An implementation of the architecture-specific
* arch_cpu_idle() primitive required by the kernel idle loop component.
* It can be called within an implementation of _sys_power_save_idle(),
* It can be called within an implementation of _pm_save_idle(),
* which is provided for the kernel by the platform.
*
* An implementation of arch_cpu_atomic_idle(), which

View file

@ -113,7 +113,7 @@ void posix_irq_check_idle_exit(void)
int32_t idle_val = _kernel.idle;
_kernel.idle = 0;
z_sys_power_save_idle_exit(idle_val);
z_pm_save_idle_exit(idle_val);
}
}
#endif

View file

@ -32,7 +32,7 @@
GTEXT(arch_swap)
#ifdef CONFIG_PM
GTEXT(z_sys_power_save_idle_exit)
GTEXT(z_pm_save_idle_exit)
#endif
/**
@ -301,19 +301,19 @@ nestedInterrupt:
handle_idle:
pushl %eax
pushl %edx
/* Populate 'ticks' argument to z_sys_power_save_idle_exit */
/* Populate 'ticks' argument to z_pm_save_idle_exit */
push _kernel_offset_to_idle(%ecx)
/* Zero out _kernel.idle */
movl $0, _kernel_offset_to_idle(%ecx)
/*
* Beware that a timer driver's z_sys_power_save_idle_exit() implementation might
* Beware that a timer driver's z_pm_save_idle_exit() implementation might
* expect that interrupts are disabled when invoked. This ensures that
* the calculation and programming of the device for the next timer
* deadline is not interrupted.
*/
call z_sys_power_save_idle_exit
call z_pm_save_idle_exit
/* discard 'ticks' argument passed on the stack */
add $0x4, %esp
popl %edx

View file

@ -218,9 +218,9 @@ disable sleep state 2 while polling:
.. code-block:: c
sys_pm_ctrl_disable_state(SYS_POWER_STATE_SLEEP_2);
pm_ctrl_disable_state(POWER_STATE_SLEEP_2);
<code that calls uart_poll_in() and expects input at any point in time>
sys_pm_ctrl_enable_state(SYS_POWER_STATE_SLEEP_2);
pm_ctrl_enable_state(POWER_STATE_SLEEP_2);
References

View file

@ -244,9 +244,9 @@ disable sleep state 2 while polling:
.. code-block:: c
sys_pm_ctrl_disable_state(SYS_POWER_STATE_SLEEP_2);
pm_ctrl_disable_state(SYS_POWER_STATE_SLEEP_2);
<code that calls uart_poll_in() and expects input at any point in time>
sys_pm_ctrl_enable_state(SYS_POWER_STATE_SLEEP_2);
pm_ctrl_enable_state(SYS_POWER_STATE_SLEEP_2);
References

View file

@ -224,9 +224,9 @@ disable sleep state 2 while polling:
.. code-block:: c
sys_pm_ctrl_disable_state(SYS_POWER_STATE_SLEEP_2);
pm_ctrl_disable_state(POWER_STATE_SLEEP_2);
<code that calls uart_poll_in() and expects input at any point in time>
sys_pm_ctrl_enable_state(SYS_POWER_STATE_SLEEP_2);
pm_ctrl_enable_state(POWER_STATE_SLEEP_2);
References

View file

@ -158,7 +158,7 @@ the following function.
.. code-block:: c
enum power_states sys_pm_policy_next_state(int32_t ticks);
enum power_states pm_policy_next_state(int32_t ticks);
Dummy
-----

View file

@ -112,7 +112,7 @@ static int entropy_cc13xx_cc26xx_get_entropy(const struct device *dev,
unsigned int key = irq_lock();
if (!data->constrained) {
sys_pm_ctrl_disable_state(SYS_POWER_STATE_SLEEP_2);
pm_ctrl_disable_state(POWER_STATE_SLEEP_2);
data->constrained = true;
}
irq_unlock(key);
@ -158,8 +158,8 @@ static void entropy_cc13xx_cc26xx_isr(const void *arg)
#if defined(CONFIG_PM) && \
defined(CONFIG_PM_SLEEP_STATES)
if (data->constrained) {
sys_pm_ctrl_enable_state(
SYS_POWER_STATE_SLEEP_2);
pm_ctrl_enable_state(
POWER_STATE_SLEEP_2);
data->constrained = false;
}
#endif
@ -338,7 +338,7 @@ static int entropy_cc13xx_cc26xx_init(const struct device *dev)
Power_setDependency(PowerCC26XX_PERIPH_TRNG);
#if defined(CONFIG_PM_SLEEP_STATES)
/* Stay out of standby until buffer is filled with entropy */
sys_pm_ctrl_disable_state(SYS_POWER_STATE_SLEEP_2);
pm_ctrl_disable_state(POWER_STATE_SLEEP_2);
data->constrained = true;
#endif
/* Register notification function */

View file

@ -211,7 +211,7 @@ static int i2c_cc13xx_cc26xx_transfer(const struct device *dev,
#if defined(CONFIG_PM) && \
defined(CONFIG_PM_SLEEP_STATES)
sys_pm_ctrl_disable_state(SYS_POWER_STATE_SLEEP_2);
pm_ctrl_disable_state(POWER_STATE_SLEEP_2);
#endif
for (int i = 0; i < num_msgs; i++) {
@ -236,7 +236,7 @@ static int i2c_cc13xx_cc26xx_transfer(const struct device *dev,
#if defined(CONFIG_PM) && \
defined(CONFIG_PM_SLEEP_STATES)
sys_pm_ctrl_enable_state(SYS_POWER_STATE_SLEEP_2);
pm_ctrl_enable_state(POWER_STATE_SLEEP_2);
#endif
k_sem_give(&get_dev_data(dev)->lock);

View file

@ -244,7 +244,7 @@ static void uart_cc13xx_cc26xx_irq_tx_enable(const struct device *dev)
* standby mode instead, since it is the power state that
* would interfere with a transfer.
*/
sys_pm_ctrl_disable_state(SYS_POWER_STATE_SLEEP_2);
pm_ctrl_disable_state(POWER_STATE_SLEEP_2);
get_dev_data(dev)->tx_constrained = true;
}
#endif
@ -259,7 +259,7 @@ static void uart_cc13xx_cc26xx_irq_tx_disable(const struct device *dev)
#if defined(CONFIG_PM) && \
defined(CONFIG_PM_SLEEP_STATES)
if (get_dev_data(dev)->tx_constrained) {
sys_pm_ctrl_enable_state(SYS_POWER_STATE_SLEEP_2);
pm_ctrl_enable_state(POWER_STATE_SLEEP_2);
get_dev_data(dev)->tx_constrained = false;
}
#endif
@ -280,7 +280,7 @@ static void uart_cc13xx_cc26xx_irq_rx_enable(const struct device *dev)
* standby.
*/
if (!get_dev_data(dev)->rx_constrained) {
sys_pm_ctrl_disable_state(SYS_POWER_STATE_SLEEP_2);
pm_ctrl_disable_state(POWER_STATE_SLEEP_2);
get_dev_data(dev)->rx_constrained = true;
}
#endif
@ -293,7 +293,7 @@ static void uart_cc13xx_cc26xx_irq_rx_disable(const struct device *dev)
#if defined(CONFIG_PM) && \
defined(CONFIG_PM_SLEEP_STATES)
if (get_dev_data(dev)->rx_constrained) {
sys_pm_ctrl_enable_state(SYS_POWER_STATE_SLEEP_2);
pm_ctrl_enable_state(POWER_STATE_SLEEP_2);
get_dev_data(dev)->rx_constrained = false;
}
#endif

View file

@ -150,7 +150,7 @@ static int spi_cc13xx_cc26xx_transceive(const struct device *dev,
#if defined(CONFIG_PM) && \
defined(CONFIG_PM_SLEEP_STATES)
sys_pm_ctrl_disable_state(SYS_POWER_STATE_SLEEP_2);
pm_ctrl_disable_state(POWER_STATE_SLEEP_2);
#endif
err = spi_cc13xx_cc26xx_configure(dev, config);
@ -187,7 +187,7 @@ static int spi_cc13xx_cc26xx_transceive(const struct device *dev,
done:
#if defined(CONFIG_PM) && \
defined(CONFIG_PM_SLEEP_STATES)
sys_pm_ctrl_enable_state(SYS_POWER_STATE_SLEEP_2);
pm_ctrl_enable_state(POWER_STATE_SLEEP_2);
#endif
spi_context_release(ctx, err);
return err;

View file

@ -235,10 +235,10 @@ typedef struct s_isrList {
#ifdef CONFIG_PM
/*
* FIXME: z_sys_power_save_idle_exit is defined in kernel.h, which cannot be
* FIXME: z_pm_save_idle_exit is defined in kernel.h, which cannot be
* included here due to circular dependency
*/
extern void z_sys_power_save_idle_exit(int32_t ticks);
extern void z_pm_save_idle_exit(int32_t ticks);
static inline void arch_irq_direct_pm(void)
{
@ -246,7 +246,7 @@ static inline void arch_irq_direct_pm(void)
int32_t idle_val = _kernel.idle;
_kernel.idle = 0;
z_sys_power_save_idle_exit(idle_val);
z_pm_save_idle_exit(idle_val);
}
}

View file

@ -4939,7 +4939,7 @@ static inline void k_cpu_atomic_idle(unsigned int key)
/**
* @internal
*/
extern void z_sys_power_save_idle_exit(int32_t ticks);
extern void z_pm_save_idle_exit(int32_t ticks);
#ifdef ARCH_EXCEPT
/* This architecture has direct support for triggering a CPU exception */

View file

@ -25,37 +25,37 @@ extern "C" {
* @brief System power states.
*/
enum power_states {
SYS_POWER_STATE_AUTO = (-2),
SYS_POWER_STATE_ACTIVE = (-1),
POWER_STATE_AUTO = (-2),
POWER_STATE_ACTIVE = (-1),
#ifdef CONFIG_PM_SLEEP_STATES
# ifdef CONFIG_HAS_POWER_STATE_SLEEP_1
SYS_POWER_STATE_SLEEP_1,
POWER_STATE_SLEEP_1,
# endif
# ifdef CONFIG_HAS_POWER_STATE_SLEEP_2
SYS_POWER_STATE_SLEEP_2,
POWER_STATE_SLEEP_2,
# endif
# ifdef CONFIG_HAS_POWER_STATE_SLEEP_3
SYS_POWER_STATE_SLEEP_3,
POWER_STATE_SLEEP_3,
# endif
#endif /* CONFIG_PM_SLEEP_STATES */
#ifdef CONFIG_PM_DEEP_SLEEP_STATES
# ifdef CONFIG_HAS_POWER_STATE_DEEP_SLEEP_1
SYS_POWER_STATE_DEEP_SLEEP_1,
POWER_STATE_DEEP_SLEEP_1,
# endif
# ifdef CONFIG_HAS_POWER_STATE_DEEP_SLEEP_2
SYS_POWER_STATE_DEEP_SLEEP_2,
POWER_STATE_DEEP_SLEEP_2,
# endif
# ifdef CONFIG_HAS_POWER_STATE_DEEP_SLEEP_3
SYS_POWER_STATE_DEEP_SLEEP_3,
POWER_STATE_DEEP_SLEEP_3,
# endif
#endif /* CONFIG_PM_DEEP_SLEEP_STATES */
SYS_POWER_STATE_MAX
POWER_STATE_MAX
};
#ifdef CONFIG_PM
extern unsigned char sys_pm_idle_exit_notify;
extern unsigned char pm_idle_exit_notify;
/**
* @brief System Power Management API
@ -70,22 +70,22 @@ extern unsigned char sys_pm_idle_exit_notify;
*
* This function returns true if given power state is a sleep state.
*/
static inline bool sys_pm_is_sleep_state(enum power_states state)
static inline bool pm_is_sleep_state(enum power_states state)
{
bool ret = true;
switch (state) {
#ifdef CONFIG_PM_SLEEP_STATES
# ifdef CONFIG_HAS_POWER_STATE_SLEEP_1
case SYS_POWER_STATE_SLEEP_1:
case POWER_STATE_SLEEP_1:
break;
# endif
# ifdef CONFIG_HAS_POWER_STATE_SLEEP_2
case SYS_POWER_STATE_SLEEP_2:
case POWER_STATE_SLEEP_2:
break;
# endif
# ifdef CONFIG_HAS_POWER_STATE_SLEEP_3
case SYS_POWER_STATE_SLEEP_3:
case POWER_STATE_SLEEP_3:
break;
# endif
#endif /* CONFIG_PM_SLEEP_STATES */
@ -102,22 +102,22 @@ static inline bool sys_pm_is_sleep_state(enum power_states 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)
static inline bool pm_is_deep_sleep_state(enum power_states state)
{
bool ret = true;
switch (state) {
#ifdef CONFIG_PM_DEEP_SLEEP_STATES
# ifdef CONFIG_HAS_POWER_STATE_DEEP_SLEEP_1
case SYS_POWER_STATE_DEEP_SLEEP_1:
case POWER_STATE_DEEP_SLEEP_1:
break;
# endif
# ifdef CONFIG_HAS_POWER_STATE_DEEP_SLEEP_2
case SYS_POWER_STATE_DEEP_SLEEP_2:
case POWER_STATE_DEEP_SLEEP_2:
break;
# endif
# ifdef CONFIG_HAS_POWER_STATE_DEEP_SLEEP_3
case SYS_POWER_STATE_DEEP_SLEEP_3:
case POWER_STATE_DEEP_SLEEP_3:
break;
# endif
#endif /* CONFIG_PM_DEEP_SLEEP_STATES */
@ -139,9 +139,9 @@ static inline bool sys_pm_is_deep_sleep_state(enum power_states state)
* _sys_suspend to disable the corresponding _sys_resume notification.
*
*/
static inline void _sys_pm_idle_exit_notification_disable(void)
static inline void _pm_idle_exit_notification_disable(void)
{
sys_pm_idle_exit_notify = 0U;
pm_idle_exit_notify = 0U;
}
/**
@ -156,9 +156,9 @@ static inline void _sys_pm_idle_exit_notification_disable(void)
* run in thread context.
*
* @param state Power state which should be used in the ongoing
* suspend operation or SYS_POWER_STATE_AUTO.
* suspend operation or POWER_STATE_AUTO.
*/
void sys_pm_force_power_state(enum power_states state);
void pm_force_power_state(enum power_states state);
/**
* @brief Put processor into a power state.
@ -174,7 +174,7 @@ void sys_set_power_state(enum power_states state);
*
* Dump Low Power states debug info like LPS entry count and residencies.
*/
void sys_pm_dump_debug_info(void);
void pm_dump_debug_info(void);
#endif /* CONFIG_PM_DEBUG */
@ -184,25 +184,25 @@ void sys_pm_dump_debug_info(void);
*
* @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
* use the @ref 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.
*/
void sys_pm_ctrl_disable_state(enum power_states state);
void 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
* use the @ref 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.
*/
void sys_pm_ctrl_enable_state(enum power_states state);
void pm_ctrl_enable_state(enum power_states state);
/**
* @brief Check if particular power state is enabled
@ -211,7 +211,7 @@ void sys_pm_ctrl_enable_state(enum power_states state);
*
* @param [in] state Power state.
*/
bool sys_pm_ctrl_is_state_enabled(enum power_states state);
bool pm_ctrl_is_state_enabled(enum power_states state);
#endif /* CONFIG_PM_STATE_LOCK */
@ -247,7 +247,7 @@ void _sys_resume_from_deep_sleep(void);
*
* This function would notify exit from kernel idling if a corresponding
* _sys_suspend() notification was handled and did not return
* SYS_POWER_STATE_ACTIVE.
* 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
@ -258,7 +258,7 @@ void _sys_resume_from_deep_sleep(void);
* 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
* notification. Alternatively _pm_idle_exit_notification_disable() can
* be called in _sys_suspend to disable this notification.
*/
void _sys_resume(void);
@ -283,7 +283,7 @@ void _sys_resume(void);
*
* @param ticks The upcoming kernel idle time.
*
* @return Power state which was entered or SYS_POWER_STATE_ACTIVE if SoC was
* @return Power state which was entered or POWER_STATE_ACTIVE if SoC was
* kept in the active state.
*/
enum power_states _sys_suspend(int32_t ticks);
@ -296,7 +296,7 @@ enum power_states _sys_suspend(int32_t ticks);
* interrupts after resuming from sleep state. In future, the enabling
* of interrupts may be moved into the kernel.
*/
void _sys_pm_power_state_exit_post_ops(enum power_states state);
void _pm_power_state_exit_post_ops(enum power_states state);
/**
* @brief Application defined function for power state entry
@ -304,7 +304,7 @@ void _sys_pm_power_state_exit_post_ops(enum power_states state);
* Application defined function for doing any target specific operations
* for power state entry.
*/
void sys_pm_notify_power_state_entry(enum power_states state);
void pm_notify_power_state_entry(enum power_states state);
/**
* @brief Application defined function for sleep state exit
@ -312,7 +312,7 @@ void sys_pm_notify_power_state_entry(enum power_states state);
* Application defined function for doing any target specific operations
* for sleep state exit.
*/
void sys_pm_notify_power_state_exit(enum power_states state);
void pm_notify_power_state_exit(enum power_states state);
/**
* @}

View file

@ -144,8 +144,8 @@ static inline uint32_t arch_k_cycle_get_32(void);
* @brief Power save idle routine
*
* This function will be called by the kernel idle loop or possibly within
* an implementation of z_sys_power_save_idle in the kernel when the
* '_sys_power_save_flag' variable is non-zero.
* an implementation of z_pm_save_idle in the kernel when the
* '_pm_save_flag' variable is non-zero.
*
* Architectures that do not implement power management instructions may
* immediately return, otherwise a power-saving instruction should be

View file

@ -34,7 +34,7 @@ LOG_MODULE_DECLARE(os, CONFIG_KERNEL_LOG_LEVEL);
* Used to allow _sys_suspend() implementation to control notification
* of the event that caused exit from kernel idling after pm operations.
*/
unsigned char sys_pm_idle_exit_notify;
unsigned char pm_idle_exit_notify;
/* LCOV_EXCL_START
@ -74,7 +74,7 @@ static void set_kernel_idle_time_in_ticks(int32_t ticks)
#endif
}
static void sys_power_save_idle(void)
static void pm_save_idle(void)
{
int32_t ticks = z_get_next_timeout_expiry();
@ -92,12 +92,12 @@ static void sys_power_save_idle(void)
#if (defined(CONFIG_PM_SLEEP_STATES) || \
defined(CONFIG_PM_DEEP_SLEEP_STATES))
sys_pm_idle_exit_notify = 1U;
pm_idle_exit_notify = 1U;
/*
* Call the suspend hook function of the soc interface to allow
* entry into a low power state. The function returns
* SYS_POWER_STATE_ACTIVE if low power state was not entered, in which
* POWER_STATE_ACTIVE if low power state was not entered, in which
* case, kernel does normal idle processing.
*
* This function is entered with interrupts disabled. If a low power
@ -107,8 +107,8 @@ static void sys_power_save_idle(void)
* idle processing re-enables interrupts which is essential for
* the kernel's scheduling logic.
*/
if (_sys_suspend(ticks) == SYS_POWER_STATE_ACTIVE) {
sys_pm_idle_exit_notify = 0U;
if (_sys_suspend(ticks) == POWER_STATE_ACTIVE) {
pm_idle_exit_notify = 0U;
k_cpu_idle();
}
#else
@ -117,16 +117,16 @@ static void sys_power_save_idle(void)
}
#endif
void z_sys_power_save_idle_exit(int32_t ticks)
void z_pm_save_idle_exit(int32_t ticks)
{
#if defined(CONFIG_PM_SLEEP_STATES)
/* 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_pm_idle_exit_notification_disable().
* disabled by calling _pm_idle_exit_notification_disable().
* Alternatively it can be simply ignored if not required.
*/
if (sys_pm_idle_exit_notify) {
if (pm_idle_exit_notify) {
_sys_resume();
}
#endif
@ -194,7 +194,7 @@ void idle(void *p1, void *unused2, void *unused3)
k_yield();
#else
(void)arch_irq_lock();
sys_power_save_idle();
pm_save_idle();
IDLE_YIELD_IF_COOP();
#endif
}

View file

@ -85,18 +85,18 @@ static void pm_latency_check(void)
}
/* Hooks to count entry/exit */
void sys_pm_notify_power_state_entry(enum power_states state)
void pm_notify_power_state_entry(enum power_states state)
{
if (!checks_enabled) {
return;
}
switch (state) {
case SYS_POWER_STATE_SLEEP_1:
case POWER_STATE_SLEEP_1:
GPIO_CTRL_REGS->CTRL_0012 = 0x240ul;
pm_counters[0].entry_cnt++;
break;
case SYS_POWER_STATE_DEEP_SLEEP_1:
case POWER_STATE_DEEP_SLEEP_1:
GPIO_CTRL_REGS->CTRL_0013 = 0x240ul;
pm_counters[1].entry_cnt++;
pm_latency_check();
@ -106,18 +106,18 @@ void sys_pm_notify_power_state_entry(enum power_states state)
}
}
void sys_pm_notify_power_state_exit(enum power_states state)
void pm_notify_power_state_exit(enum power_states state)
{
if (!checks_enabled) {
return;
}
switch (state) {
case SYS_POWER_STATE_SLEEP_1:
case POWER_STATE_SLEEP_1:
GPIO_CTRL_REGS->CTRL_0012 = 0x10240ul;
pm_counters[0].exit_cnt++;
break;
case SYS_POWER_STATE_DEEP_SLEEP_1:
case POWER_STATE_DEEP_SLEEP_1:
GPIO_CTRL_REGS->CTRL_0013 = 0x10240ul;
pm_counters[1].exit_cnt++;
break;

View file

@ -27,7 +27,7 @@ static int disable_ds_1(const struct device *dev)
{
ARG_UNUSED(dev);
sys_pm_ctrl_disable_state(SYS_POWER_STATE_DEEP_SLEEP_1);
pm_ctrl_disable_state(POWER_STATE_DEEP_SLEEP_1);
return 0;
}
@ -68,7 +68,7 @@ void main(void)
* controlled delay. Here we need to override that, then
* force entry to deep sleep on any delay.
*/
sys_pm_force_power_state(SYS_POWER_STATE_DEEP_SLEEP_1);
pm_force_power_state(POWER_STATE_DEEP_SLEEP_1);
k_sleep(K_MSEC(1));
printk("ERROR: System off failed\n");

View file

@ -68,7 +68,7 @@ void main(void)
* controlled delay. Here we need to override that, then
* force a sleep so that the deep sleep takes effect.
*/
sys_pm_force_power_state(SYS_POWER_STATE_DEEP_SLEEP_1);
pm_force_power_state(POWER_STATE_DEEP_SLEEP_1);
k_sleep(K_MSEC(1));
printk("ERROR: System off failed\n");

View file

@ -71,7 +71,7 @@ static void z_power_soc_deep_sleep(void)
soc_deep_sleep_periph_restore();
/*
* _sys_pm_power_state_exit_post_ops() is not being called
* _pm_power_state_exit_post_ops() is not being called
* after exiting deep sleep, so need to unmask exceptions
* and interrupts here.
*/
@ -111,12 +111,12 @@ void sys_set_power_state(enum power_states state)
{
switch (state) {
#if (defined(CONFIG_PM_SLEEP_STATES))
case SYS_POWER_STATE_SLEEP_1:
case POWER_STATE_SLEEP_1:
z_power_soc_sleep();
break;
#endif
#if (defined(CONFIG_PM_DEEP_SLEEP_STATES))
case SYS_POWER_STATE_DEEP_SLEEP_1:
case POWER_STATE_DEEP_SLEEP_1:
z_power_soc_deep_sleep();
break;
#endif
@ -125,16 +125,16 @@ void sys_set_power_state(enum power_states state)
}
}
void _sys_pm_power_state_exit_post_ops(enum power_states state)
void _pm_power_state_exit_post_ops(enum power_states state)
{
switch (state) {
#if (defined(CONFIG_PM_SLEEP_STATES))
case SYS_POWER_STATE_SLEEP_1:
case POWER_STATE_SLEEP_1:
__enable_irq();
break;
#endif
#if (defined(CONFIG_PM_DEEP_SLEEP_STATES))
case SYS_POWER_STATE_DEEP_SLEEP_1:
case POWER_STATE_DEEP_SLEEP_1:
__enable_irq();
break;
#endif

View file

@ -16,7 +16,7 @@ void sys_set_power_state(enum power_states state)
switch (state) {
#ifdef CONFIG_PM_DEEP_SLEEP_STATES
#ifdef CONFIG_HAS_POWER_STATE_DEEP_SLEEP_1
case SYS_POWER_STATE_DEEP_SLEEP_1:
case POWER_STATE_DEEP_SLEEP_1:
nrf_power_system_off(NRF_POWER);
break;
#endif
@ -28,12 +28,12 @@ void sys_set_power_state(enum power_states state)
}
/* Handle SOC specific activity after Low Power Mode Exit */
void _sys_pm_power_state_exit_post_ops(enum power_states state)
void _pm_power_state_exit_post_ops(enum power_states state)
{
switch (state) {
#ifdef CONFIG_PM_DEEP_SLEEP_STATES
#ifdef CONFIG_HAS_POWER_STATE_DEEP_SLEEP_1
case SYS_POWER_STATE_DEEP_SLEEP_1:
case POWER_STATE_DEEP_SLEEP_1:
/* Nothing to do. */
break;
#endif

View file

@ -16,7 +16,7 @@ void sys_set_power_state(enum power_states state)
switch (state) {
#ifdef CONFIG_PM_DEEP_SLEEP_STATES
#ifdef CONFIG_HAS_POWER_STATE_DEEP_SLEEP_1
case SYS_POWER_STATE_DEEP_SLEEP_1:
case POWER_STATE_DEEP_SLEEP_1:
nrf_power_system_off(NRF_POWER);
break;
#endif
@ -28,12 +28,12 @@ void sys_set_power_state(enum power_states state)
}
/* Handle SOC specific activity after Low Power Mode Exit */
void _sys_pm_power_state_exit_post_ops(enum power_states state)
void _pm_power_state_exit_post_ops(enum power_states state)
{
switch (state) {
#ifdef CONFIG_PM_DEEP_SLEEP_STATES
#ifdef CONFIG_HAS_POWER_STATE_DEEP_SLEEP_1
case SYS_POWER_STATE_DEEP_SLEEP_1:
case POWER_STATE_DEEP_SLEEP_1:
/* Nothing to do. */
break;
#endif

View file

@ -20,7 +20,7 @@ void sys_set_power_state(enum power_states state)
switch (state) {
#ifdef CONFIG_PM_DEEP_SLEEP_STATES
#ifdef CONFIG_HAS_POWER_STATE_DEEP_SLEEP_1
case SYS_POWER_STATE_DEEP_SLEEP_1:
case POWER_STATE_DEEP_SLEEP_1:
nrf_regulators_system_off(NRF_REGULATORS);
break;
#endif
@ -32,12 +32,12 @@ void sys_set_power_state(enum power_states state)
}
/* Handle SOC specific activity after Low Power Mode Exit */
void _sys_pm_power_state_exit_post_ops(enum power_states state)
void _pm_power_state_exit_post_ops(enum power_states state)
{
switch (state) {
#ifdef CONFIG_PM_DEEP_SLEEP_STATES
#ifdef CONFIG_HAS_POWER_STATE_DEEP_SLEEP_1
case SYS_POWER_STATE_DEEP_SLEEP_1:
case POWER_STATE_DEEP_SLEEP_1:
/* Nothing to do. */
break;
#endif

View file

@ -17,7 +17,7 @@ void sys_set_power_state(enum power_states state)
switch (state) {
#ifdef CONFIG_PM_DEEP_SLEEP_STATES
#ifdef CONFIG_HAS_POWER_STATE_DEEP_SLEEP_1
case SYS_POWER_STATE_DEEP_SLEEP_1:
case POWER_STATE_DEEP_SLEEP_1:
nrf_regulators_system_off(NRF_REGULATORS);
break;
#endif
@ -29,12 +29,12 @@ void sys_set_power_state(enum power_states state)
}
/* Handle SOC specific activity after Low Power Mode Exit */
void _sys_pm_power_state_exit_post_ops(enum power_states state)
void _pm_power_state_exit_post_ops(enum power_states state)
{
switch (state) {
#ifdef CONFIG_PM_DEEP_SLEEP_STATES
#ifdef CONFIG_HAS_POWER_STATE_DEEP_SLEEP_1
case SYS_POWER_STATE_DEEP_SLEEP_1:
case POWER_STATE_DEEP_SLEEP_1:
/* Nothing to do. */
break;
#endif

View file

@ -12,9 +12,9 @@ LOG_MODULE_DECLARE(soc, CONFIG_SOC_LOG_LEVEL);
/*
* Power state map:
* SYS_POWER_STATE_SLEEP_1: EM1 Sleep
* SYS_POWER_STATE_SLEEP_2: EM2 Deep Sleep
* SYS_POWER_STATE_SLEEP_3: EM3 Stop
* POWER_STATE_SLEEP_1: EM1 Sleep
* POWER_STATE_SLEEP_2: EM2 Deep Sleep
* POWER_STATE_SLEEP_3: EM3 Stop
*/
/* Invoke Low Power/System Off specific Tasks */
@ -37,17 +37,17 @@ void sys_set_power_state(enum power_states state)
switch (state) {
#ifdef CONFIG_PM_SLEEP_STATES
#ifdef CONFIG_HAS_POWER_STATE_SLEEP_1
case SYS_POWER_STATE_SLEEP_1:
case POWER_STATE_SLEEP_1:
EMU_EnterEM1();
break;
#endif /* CONFIG_HAS_POWER_STATE_SLEEP_1 */
#ifdef CONFIG_HAS_POWER_STATE_SLEEP_2
case SYS_POWER_STATE_SLEEP_2:
case POWER_STATE_SLEEP_2:
EMU_EnterEM2(true);
break;
#endif /* CONFIG_HAS_POWER_STATE_SLEEP_2 */
#ifdef CONFIG_HAS_POWER_STATE_SLEEP_3
case SYS_POWER_STATE_SLEEP_3:
case POWER_STATE_SLEEP_3:
EMU_EnterEM3(true);
break;
#endif /* CONFIG_HAS_POWER_STATE_SLEEP_3 */
@ -64,7 +64,7 @@ void sys_set_power_state(enum power_states state)
}
/* Handle SOC specific activity after Low Power Mode Exit */
void _sys_pm_power_state_exit_post_ops(enum power_states state)
void _pm_power_state_exit_post_ops(enum power_states state)
{
ARG_UNUSED(state);
}

View file

@ -22,7 +22,7 @@ void sys_set_power_state(enum power_states state)
switch (state) {
#ifdef CONFIG_PM_SLEEP_STATES
#ifdef CONFIG_HAS_POWER_STATE_SLEEP_1
case SYS_POWER_STATE_SLEEP_1:
case POWER_STATE_SLEEP_1:
/* this corresponds to the STOP0 mode: */
#ifdef CONFIG_DEBUG
@ -39,7 +39,7 @@ void sys_set_power_state(enum power_states state)
break;
#endif /* CONFIG_HAS_POWER_STATE_SLEEP_1 */
#ifdef CONFIG_HAS_POWER_STATE_SLEEP_2
case SYS_POWER_STATE_SLEEP_2:
case POWER_STATE_SLEEP_2:
/* this corresponds to the STOP1 mode: */
#ifdef CONFIG_DEBUG
/* Enable the Debug Module during STOP mode */
@ -54,7 +54,7 @@ void sys_set_power_state(enum power_states state)
break;
#endif /* CONFIG_HAS_POWER_STATE_SLEEP_2 */
#ifdef CONFIG_HAS_POWER_STATE_SLEEP_3
case SYS_POWER_STATE_SLEEP_3:
case POWER_STATE_SLEEP_3:
/* this corresponds to the STOP2 mode: */
#ifdef CONFIG_DEBUG
/* Enable the Debug Module during STOP mode */
@ -79,18 +79,18 @@ void sys_set_power_state(enum power_states state)
}
/* Handle SOC specific activity after Low Power Mode Exit */
void _sys_pm_power_state_exit_post_ops(enum power_states state)
void _pm_power_state_exit_post_ops(enum power_states state)
{
switch (state) {
#ifdef CONFIG_PM_SLEEP_STATES
#ifdef CONFIG_HAS_POWER_STATE_SLEEP_1
case SYS_POWER_STATE_SLEEP_1:
case POWER_STATE_SLEEP_1:
#endif /* CONFIG_HAS_POWER_STATE_SLEEP_1 */
#ifdef CONFIG_HAS_POWER_STATE_SLEEP_2
case SYS_POWER_STATE_SLEEP_2:
case POWER_STATE_SLEEP_2:
#endif /* CONFIG_HAS_POWER_STATE_SLEEP_2 */
#ifdef CONFIG_HAS_POWER_STATE_SLEEP_3
case SYS_POWER_STATE_SLEEP_3:
case POWER_STATE_SLEEP_3:
#endif /* CONFIG_HAS_POWER_STATE_SLEEP_3 */
LL_LPM_DisableSleepOnExit();
LL_LPM_EnableSleep();

View file

@ -22,7 +22,7 @@ void sys_set_power_state(enum power_states state)
switch (state) {
#ifdef CONFIG_PM_SLEEP_STATES
#ifdef CONFIG_HAS_POWER_STATE_SLEEP_1
case SYS_POWER_STATE_SLEEP_1:
case POWER_STATE_SLEEP_1:
/* this corresponds to the STOP0 mode: */
#ifdef CONFIG_DEBUG
@ -39,7 +39,7 @@ void sys_set_power_state(enum power_states state)
break;
#endif /* CONFIG_HAS_POWER_STATE_SLEEP_1 */
#ifdef CONFIG_HAS_POWER_STATE_SLEEP_2
case SYS_POWER_STATE_SLEEP_2:
case POWER_STATE_SLEEP_2:
/* this corresponds to the STOP1 mode: */
#ifdef CONFIG_DEBUG
/* Enable the Debug Module during STOP mode */
@ -54,7 +54,7 @@ void sys_set_power_state(enum power_states state)
break;
#endif /* CONFIG_HAS_POWER_STATE_SLEEP_2 */
#ifdef CONFIG_HAS_POWER_STATE_SLEEP_3
case SYS_POWER_STATE_SLEEP_3:
case POWER_STATE_SLEEP_3:
/* this corresponds to the STOP2 mode: */
#ifdef CONFIG_DEBUG
/* Enable the Debug Module during STOP mode */
@ -79,18 +79,18 @@ void sys_set_power_state(enum power_states state)
}
/* Handle SOC specific activity after Low Power Mode Exit */
void _sys_pm_power_state_exit_post_ops(enum power_states state)
void _pm_power_state_exit_post_ops(enum power_states state)
{
switch (state) {
#ifdef CONFIG_PM_SLEEP_STATES
#ifdef CONFIG_HAS_POWER_STATE_SLEEP_1
case SYS_POWER_STATE_SLEEP_1:
case POWER_STATE_SLEEP_1:
#endif /* CONFIG_HAS_POWER_STATE_SLEEP_1 */
#ifdef CONFIG_HAS_POWER_STATE_SLEEP_2
case SYS_POWER_STATE_SLEEP_2:
case POWER_STATE_SLEEP_2:
#endif /* CONFIG_HAS_POWER_STATE_SLEEP_2 */
#ifdef CONFIG_HAS_POWER_STATE_SLEEP_3
case SYS_POWER_STATE_SLEEP_3:
case POWER_STATE_SLEEP_3:
#endif /* CONFIG_HAS_POWER_STATE_SLEEP_3 */
LL_LPM_DisableSleepOnExit();
LL_LPM_EnableSleep();

View file

@ -50,9 +50,9 @@ extern PowerCC26X2_ModuleState PowerCC26X2_module;
/*
* Power state mapping:
* SYS_POWER_STATE_SLEEP_1: Idle
* SYS_POWER_STATE_SLEEP_2: Standby
* SYS_POWER_STATE_DEEP_SLEEP_1: Shutdown
* POWER_STATE_SLEEP_1: Idle
* POWER_STATE_SLEEP_2: Standby
* POWER_STATE_DEEP_SLEEP_1: Shutdown
*/
/* Invoke Low Power/System Off specific Tasks */
@ -75,7 +75,7 @@ void sys_set_power_state(enum power_states state)
switch (state) {
#ifdef CONFIG_PM_SLEEP_STATES
case SYS_POWER_STATE_SLEEP_1:
case POWER_STATE_SLEEP_1:
/* query the declared constraints */
constraints = Power_getConstraintMask();
/* 1. Get the current VIMS mode */
@ -101,7 +101,7 @@ void sys_set_power_state(enum power_states state)
SysCtrlAonUpdate();
break;
case SYS_POWER_STATE_SLEEP_2:
case POWER_STATE_SLEEP_2:
/* schedule the wakeup event */
ClockP_start(ClockP_handle((ClockP_Struct *)
&PowerCC26X2_module.clockObj));
@ -114,7 +114,7 @@ void sys_set_power_state(enum power_states state)
#endif
#ifdef CONFIG_PM_DEEP_SLEEP_STATES
case SYS_POWER_STATE_DEEP_SLEEP_1:
case POWER_STATE_DEEP_SLEEP_1:
Power_shutdown(0, 0);
break;
#endif
@ -127,7 +127,7 @@ void sys_set_power_state(enum power_states state)
}
/* Handle SOC specific activity after Low Power Mode Exit */
void _sys_pm_power_state_exit_post_ops(enum power_states state)
void _pm_power_state_exit_post_ops(enum power_states state)
{
/*
* System is now in active mode. Reenable interrupts which were disabled

View file

@ -26,8 +26,8 @@ static ALWAYS_INLINE void riscv_idle(unsigned int key)
* @brief Power save idle routine
*
* This function will be called by the kernel idle loop or possibly within
* an implementation of _sys_power_save_idle in the kernel when the
* '_sys_power_save_flag' variable is non-zero.
* an implementation of _pm_save_idle in the kernel when the
* '_pm_save_flag' variable is non-zero.
*
* @return N/A
*/

View file

@ -138,17 +138,17 @@ config HAS_POWER_STATE_SLEEP_3
config HAS_POWER_STATE_DEEP_SLEEP_1
bool
help
This option signifies that the target supports the SYS_POWER_STATE_DEEP_SLEEP_1
This option signifies that the target supports the POWER_STATE_DEEP_SLEEP_1
configuration option.
config HAS_POWER_STATE_DEEP_SLEEP_2
bool
help
This option signifies that the target supports the SYS_POWER_STATE_DEEP_SLEEP_2
This option signifies that the target supports the POWER_STATE_DEEP_SLEEP_2
configuration option.
config HAS_POWER_STATE_DEEP_SLEEP_3
bool
help
This option signifies that the target supports the SYS_POWER_STATE_DEEP_SLEEP_3
This option signifies that the target supports the POWER_STATE_DEEP_SLEEP_3
configuration option.

View file

@ -78,7 +78,7 @@ const char *device_pm_state_str(uint32_t state)
}
}
static int _sys_pm_devices(uint32_t state)
static int _pm_devices(uint32_t state)
{
num_susp = 0;
@ -103,22 +103,22 @@ static int _sys_pm_devices(uint32_t state)
return 0;
}
int sys_pm_suspend_devices(void)
int pm_suspend_devices(void)
{
return _sys_pm_devices(DEVICE_PM_SUSPEND_STATE);
return _pm_devices(DEVICE_PM_SUSPEND_STATE);
}
int sys_pm_low_power_devices(void)
int pm_low_power_devices(void)
{
return _sys_pm_devices(DEVICE_PM_LOW_POWER_STATE);
return _pm_devices(DEVICE_PM_LOW_POWER_STATE);
}
int sys_pm_force_suspend_devices(void)
int pm_force_suspend_devices(void)
{
return _sys_pm_devices(DEVICE_PM_FORCE_SUSPEND_STATE);
return _pm_devices(DEVICE_PM_FORCE_SUSPEND_STATE);
}
void sys_pm_resume_devices(void)
void pm_resume_devices(void)
{
device_idx_t pmi = num_pm - num_susp;
@ -133,7 +133,7 @@ void sys_pm_resume_devices(void)
}
}
void sys_pm_create_device_list(void)
void pm_create_device_list(void)
{
size_t count = z_device_get_all_static(&all_devices);
device_idx_t pmi, core_dev;

View file

@ -14,13 +14,13 @@
#include <logging/log.h>
LOG_MODULE_DECLARE(power);
static atomic_t power_state_disable_count[SYS_POWER_STATE_MAX];
static atomic_t power_state_disable_count[POWER_STATE_MAX];
void sys_pm_ctrl_disable_state(enum power_states state)
void pm_ctrl_disable_state(enum power_states state)
{
atomic_val_t v;
__ASSERT(state < SYS_POWER_STATE_MAX, "Invalid power state!");
__ASSERT(state < POWER_STATE_MAX, "Invalid power state!");
v = atomic_inc(&power_state_disable_count[state]);
__ASSERT(v < UINT_MAX, "Power state disable count overflowed!");
@ -28,11 +28,11 @@ void sys_pm_ctrl_disable_state(enum power_states state)
(void)(v);
}
void sys_pm_ctrl_enable_state(enum power_states state)
void pm_ctrl_enable_state(enum power_states state)
{
atomic_val_t v;
__ASSERT(state < SYS_POWER_STATE_MAX, "Invalid power state!");
__ASSERT(state < POWER_STATE_MAX, "Invalid power state!");
v = atomic_dec(&power_state_disable_count[state]);
__ASSERT(v > 0, "Power state disable count underflowed!");
@ -40,9 +40,9 @@ void sys_pm_ctrl_enable_state(enum power_states state)
(void)(v);
}
bool sys_pm_ctrl_is_state_enabled(enum power_states state)
bool pm_ctrl_is_state_enabled(enum power_states state)
{
__ASSERT(state < SYS_POWER_STATE_MAX, "Invalid power state!");
__ASSERT(state < POWER_STATE_MAX, "Invalid power state!");
return (atomic_get(&power_state_disable_count[state]) == 0);
}

View file

@ -41,7 +41,7 @@ config PM_MIN_RESIDENCY_SLEEP_1
depends on HAS_POWER_STATE_SLEEP_1
default 5000
help
Minimum residency in milliseconds to enter SYS_POWER_STATE_SLEEP_1
Minimum residency in milliseconds to enter POWER_STATE_SLEEP_1
state.
config PM_MIN_RESIDENCY_SLEEP_2
@ -49,7 +49,7 @@ config PM_MIN_RESIDENCY_SLEEP_2
depends on HAS_POWER_STATE_SLEEP_2
default 10000
help
Minimum residency in milliseconds to enter SYS_POWER_STATE_SLEEP_2
Minimum residency in milliseconds to enter POWER_STATE_SLEEP_2
state.
config PM_MIN_RESIDENCY_SLEEP_3
@ -57,7 +57,7 @@ config PM_MIN_RESIDENCY_SLEEP_3
depends on HAS_POWER_STATE_SLEEP_3
default 30000
help
Minimum residency in milliseconds to enter SYS_POWER_STATE_SLEEP_3
Minimum residency in milliseconds to enter POWER_STATE_SLEEP_3
state.
config PM_MIN_RESIDENCY_DEEP_SLEEP_1
@ -65,7 +65,7 @@ config PM_MIN_RESIDENCY_DEEP_SLEEP_1
depends on HAS_POWER_STATE_DEEP_SLEEP_1
default 60000
help
Minimum residency in milliseconds to enter SYS_POWER_STATE_DEEP_SLEEP_1
Minimum residency in milliseconds to enter POWER_STATE_DEEP_SLEEP_1
state.
config PM_MIN_RESIDENCY_DEEP_SLEEP_2
@ -73,7 +73,7 @@ config PM_MIN_RESIDENCY_DEEP_SLEEP_2
depends on HAS_POWER_STATE_DEEP_SLEEP_2
default 90000
help
Minimum residency in milliseconds to enter SYS_POWER_STATE_DEEP_SLEEP_2
Minimum residency in milliseconds to enter POWER_STATE_DEEP_SLEEP_2
state.
config PM_MIN_RESIDENCY_DEEP_SLEEP_3
@ -81,7 +81,7 @@ config PM_MIN_RESIDENCY_DEEP_SLEEP_3
depends on HAS_POWER_STATE_DEEP_SLEEP_3
default 120000
help
Minimum residency in milliseconds to enter SYS_POWER_STATE_DEEP_SLEEP_3
Minimum residency in milliseconds to enter POWER_STATE_DEEP_SLEEP_3
state.
endif # PM_POLICY_RESIDENCY

View file

@ -16,38 +16,38 @@ extern "C" {
/**
* @brief Function to create device PM list
*/
void sys_pm_create_device_list(void);
void pm_create_device_list(void);
/**
* @brief Function to suspend the devices in PM device list
*/
int sys_pm_suspend_devices(void);
int pm_suspend_devices(void);
/**
* @brief Function to put the devices in PM device list in low power state
*/
int sys_pm_low_power_devices(void);
int pm_low_power_devices(void);
/**
* @brief Function to force suspend the devices in PM device list
*/
int sys_pm_force_suspend_devices(void);
int pm_force_suspend_devices(void);
/**
* @brief Function to resume the devices in PM device list
*/
void sys_pm_resume_devices(void);
void pm_resume_devices(void);
/**
* @brief Function to get the next PM state based on the ticks
*/
enum power_states sys_pm_policy_next_state(int32_t ticks);
enum power_states pm_policy_next_state(int32_t ticks);
/**
* @brief Function to determine whether to put devices in low
* power state, given the system PM state.
*/
bool sys_pm_policy_low_power_devices(enum power_states pm_state);
bool pm_policy_low_power_devices(enum power_states pm_state);
#ifdef __cplusplus
}

View file

@ -11,21 +11,21 @@
#include <logging/log.h>
LOG_MODULE_DECLARE(power, CONFIG_PM_LOG_LEVEL);
enum power_states sys_pm_policy_next_state(int32_t ticks)
enum power_states pm_policy_next_state(int32_t ticks)
{
static uint8_t cur_power_state;
int i = cur_power_state;
if (SYS_POWER_STATE_MAX == 0) {
if (POWER_STATE_MAX == 0) {
/* No power states to go through. */
return SYS_POWER_STATE_ACTIVE;
return POWER_STATE_ACTIVE;
}
do {
i = (i + 1) % SYS_POWER_STATE_MAX;
i = (i + 1) % POWER_STATE_MAX;
#ifdef CONFIG_PM_STATE_LOCK
if (!sys_pm_ctrl_is_state_enabled((enum power_states)(i))) {
if (!pm_ctrl_is_state_enabled((enum power_states)(i))) {
continue;
}
#endif
@ -36,10 +36,10 @@ enum power_states sys_pm_policy_next_state(int32_t ticks)
} while (i != cur_power_state);
LOG_DBG("No suitable power state found!");
return SYS_POWER_STATE_ACTIVE;
return POWER_STATE_ACTIVE;
}
__weak bool sys_pm_policy_low_power_devices(enum power_states pm_state)
__weak bool pm_policy_low_power_devices(enum power_states pm_state)
{
return sys_pm_is_sleep_state(pm_state);
return pm_is_sleep_state(pm_state);
}

View file

@ -45,18 +45,18 @@ static const unsigned int pm_min_residency[] = {
#endif /* CONFIG_PM_DEEP_SLEEP_STATES */
};
enum power_states sys_pm_policy_next_state(int32_t ticks)
enum power_states pm_policy_next_state(int32_t ticks)
{
int i;
if ((ticks != K_TICKS_FOREVER) && (ticks < pm_min_residency[0])) {
LOG_DBG("Not enough time for PM operations: %d", ticks);
return SYS_POWER_STATE_ACTIVE;
return POWER_STATE_ACTIVE;
}
for (i = ARRAY_SIZE(pm_min_residency) - 1; i >= 0; i--) {
#ifdef CONFIG_PM_STATE_LOCK
if (!sys_pm_ctrl_is_state_enabled((enum power_states)(i))) {
if (!pm_ctrl_is_state_enabled((enum power_states)(i))) {
continue;
}
#endif
@ -70,10 +70,10 @@ enum power_states sys_pm_policy_next_state(int32_t ticks)
}
LOG_DBG("No suitable power state found!");
return SYS_POWER_STATE_ACTIVE;
return POWER_STATE_ACTIVE;
}
__weak bool sys_pm_policy_low_power_devices(enum power_states pm_state)
__weak bool pm_policy_low_power_devices(enum power_states pm_state)
{
return sys_pm_is_sleep_state(pm_state);
return pm_is_sleep_state(pm_state);
}

View file

@ -37,7 +37,7 @@ static const unsigned int pm_min_residency[] = {
#endif /* CONFIG_PM_SLEEP_STATES */
};
enum power_states sys_pm_policy_next_state(int32_t ticks)
enum power_states pm_policy_next_state(int32_t ticks)
{
uint32_t constraints;
bool disallowed = false;
@ -51,12 +51,12 @@ enum power_states sys_pm_policy_next_state(int32_t ticks)
if ((ticks != K_TICKS_FOREVER) && (ticks < pm_min_residency[0])) {
LOG_DBG("Not enough time for PM operations: %d", ticks);
return SYS_POWER_STATE_ACTIVE;
return POWER_STATE_ACTIVE;
}
for (i = ARRAY_SIZE(pm_min_residency) - 1; i >= 0; i--) {
#ifdef CONFIG_PM_STATE_LOCK
if (!sys_pm_ctrl_is_state_enabled((enum power_states)(i))) {
if (!pm_ctrl_is_state_enabled((enum power_states)(i))) {
continue;
}
#endif
@ -132,13 +132,13 @@ enum power_states sys_pm_policy_next_state(int32_t ticks)
}
LOG_DBG("No suitable power state found!");
return SYS_POWER_STATE_ACTIVE;
return POWER_STATE_ACTIVE;
}
__weak bool sys_pm_policy_low_power_devices(enum power_states pm_state)
__weak bool pm_policy_low_power_devices(enum power_states pm_state)
{
#ifdef CONFIG_PM_SLEEP_STATES
return (pm_state == SYS_POWER_STATE_SLEEP_2);
return (pm_state == POWER_STATE_SLEEP_2);
#else
return false;
#endif

View file

@ -16,7 +16,7 @@
LOG_MODULE_REGISTER(power);
static int post_ops_done = 1;
static enum power_states forced_pm_state = SYS_POWER_STATE_AUTO;
static enum power_states forced_pm_state = POWER_STATE_AUTO;
static enum power_states pm_state;
#ifdef CONFIG_PM_DEBUG
@ -27,20 +27,20 @@ struct pm_debug_info {
uint32_t total_res;
};
static struct pm_debug_info pm_dbg_info[SYS_POWER_STATE_MAX];
static struct pm_debug_info pm_dbg_info[POWER_STATE_MAX];
static uint32_t timer_start, timer_end;
static inline void sys_pm_debug_start_timer(void)
static inline void pm_debug_start_timer(void)
{
timer_start = k_cycle_get_32();
}
static inline void sys_pm_debug_stop_timer(void)
static inline void pm_debug_stop_timer(void)
{
timer_end = k_cycle_get_32();
}
static void sys_pm_log_debug_info(enum power_states state)
static void pm_log_debug_info(enum power_states state)
{
uint32_t res = timer_end - timer_start;
@ -49,35 +49,35 @@ static void sys_pm_log_debug_info(enum power_states state)
pm_dbg_info[state].total_res += res;
}
void sys_pm_dump_debug_info(void)
void pm_dump_debug_info(void)
{
for (int i = 0; i < SYS_POWER_STATE_MAX; i++) {
for (int i = 0; i < POWER_STATE_MAX; i++) {
LOG_DBG("PM:state = %d, count = %d last_res = %d, "
"total_res = %d\n", i, pm_dbg_info[i].count,
pm_dbg_info[i].last_res, pm_dbg_info[i].total_res);
}
}
#else
static inline void sys_pm_debug_start_timer(void) { }
static inline void sys_pm_debug_stop_timer(void) { }
static void sys_pm_log_debug_info(enum power_states state) { }
void sys_pm_dump_debug_info(void) { }
static inline void pm_debug_start_timer(void) { }
static inline void pm_debug_stop_timer(void) { }
static void pm_log_debug_info(enum power_states state) { }
void pm_dump_debug_info(void) { }
#endif
__weak void sys_pm_notify_power_state_entry(enum power_states state)
__weak void pm_notify_power_state_entry(enum power_states state)
{
/* This function can be overridden by the application. */
}
__weak void sys_pm_notify_power_state_exit(enum power_states state)
__weak void pm_notify_power_state_exit(enum power_states state)
{
/* This function can be overridden by the application. */
}
void sys_pm_force_power_state(enum power_states state)
void pm_force_power_state(enum power_states state)
{
__ASSERT(state >= SYS_POWER_STATE_AUTO &&
state < SYS_POWER_STATE_MAX,
__ASSERT(state >= POWER_STATE_AUTO &&
state < POWER_STATE_MAX,
"Invalid power state %d!", state);
#ifdef CONFIG_PM_DIRECT_FORCE_MODE
@ -96,28 +96,28 @@ enum power_states _sys_suspend(int32_t ticks)
bool low_power = false;
#endif
pm_state = (forced_pm_state == SYS_POWER_STATE_AUTO) ?
sys_pm_policy_next_state(ticks) : forced_pm_state;
pm_state = (forced_pm_state == POWER_STATE_AUTO) ?
pm_policy_next_state(ticks) : forced_pm_state;
if (pm_state == SYS_POWER_STATE_ACTIVE) {
if (pm_state == POWER_STATE_ACTIVE) {
LOG_DBG("No PM operations done.");
return pm_state;
}
deep_sleep = IS_ENABLED(CONFIG_PM_DEEP_SLEEP_STATES) ?
sys_pm_is_deep_sleep_state(pm_state) : 0;
pm_is_deep_sleep_state(pm_state) : 0;
post_ops_done = 0;
sys_pm_notify_power_state_entry(pm_state);
pm_notify_power_state_entry(pm_state);
if (deep_sleep) {
#if CONFIG_PM_DEVICE
/* Suspend peripherals. */
if (sys_pm_suspend_devices()) {
if (pm_suspend_devices()) {
LOG_DBG("Some devices didn't enter suspend state!");
sys_pm_resume_devices();
sys_pm_notify_power_state_exit(pm_state);
pm_state = SYS_POWER_STATE_ACTIVE;
pm_resume_devices();
pm_notify_power_state_exit(pm_state);
pm_state = POWER_STATE_ACTIVE;
return pm_state;
}
#endif
@ -125,16 +125,16 @@ enum power_states _sys_suspend(int32_t ticks)
* Disable idle exit notification as it is not needed
* in deep sleep mode.
*/
_sys_pm_idle_exit_notification_disable();
_pm_idle_exit_notification_disable();
#if CONFIG_PM_DEVICE
} else {
if (sys_pm_policy_low_power_devices(pm_state)) {
if (pm_policy_low_power_devices(pm_state)) {
/* low power peripherals. */
if (sys_pm_low_power_devices()) {
if (pm_low_power_devices()) {
LOG_DBG("Someone didn't enter low power state");
sys_pm_resume_devices();
sys_pm_notify_power_state_exit(pm_state);
pm_state = SYS_POWER_STATE_ACTIVE;
pm_resume_devices();
pm_notify_power_state_exit(pm_state);
pm_state = POWER_STATE_ACTIVE;
return pm_state;
}
@ -144,24 +144,24 @@ enum power_states _sys_suspend(int32_t ticks)
}
/* Enter power state */
sys_pm_debug_start_timer();
pm_debug_start_timer();
sys_set_power_state(pm_state);
sys_pm_debug_stop_timer();
pm_debug_stop_timer();
#if CONFIG_PM_DEVICE
if (deep_sleep || low_power) {
/* Turn on peripherals and restore device states as necessary */
sys_pm_resume_devices();
pm_resume_devices();
}
#endif
sys_pm_log_debug_info(pm_state);
pm_log_debug_info(pm_state);
if (!post_ops_done) {
post_ops_done = 1;
/* clear forced_pm_state */
forced_pm_state = SYS_POWER_STATE_AUTO;
sys_pm_notify_power_state_exit(pm_state);
_sys_pm_power_state_exit_post_ops(pm_state);
forced_pm_state = POWER_STATE_AUTO;
pm_notify_power_state_exit(pm_state);
_pm_power_state_exit_post_ops(pm_state);
}
return pm_state;
@ -181,24 +181,24 @@ void _sys_resume(void)
* The kernel scheduler will get control after the ISR finishes
* and it may schedule another thread.
*
* Call _sys_pm_idle_exit_notification_disable() if this
* Call _pm_idle_exit_notification_disable() if this
* notification is not required.
*/
if (!post_ops_done) {
post_ops_done = 1;
sys_pm_notify_power_state_exit(pm_state);
_sys_pm_power_state_exit_post_ops(pm_state);
pm_notify_power_state_exit(pm_state);
_pm_power_state_exit_post_ops(pm_state);
}
}
#if CONFIG_PM_DEVICE
static int sys_pm_init(const struct device *dev)
static int pm_init(const struct device *dev)
{
ARG_UNUSED(dev);
sys_pm_create_device_list();
pm_create_device_list();
return 0;
}
SYS_INIT(sys_pm_init, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
SYS_INIT(pm_init, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
#endif /* CONFIG_PM_DEVICE */

View file

@ -32,14 +32,14 @@ __weak void sys_set_power_state(enum power_states state)
__ASSERT_NO_MSG(false);
}
__weak void _sys_pm_power_state_exit_post_ops(enum power_states state)
__weak void _pm_power_state_exit_post_ops(enum power_states state)
{
/* Never called. */
__ASSERT_NO_MSG(false);
}
/* Our PM policy handler */
enum power_states sys_pm_policy_next_state(int32_t ticks)
enum power_states pm_policy_next_state(int32_t ticks)
{
static bool test_flag;
@ -51,7 +51,7 @@ enum power_states sys_pm_policy_next_state(int32_t ticks)
test_flag = true;
}
return SYS_POWER_STATE_ACTIVE;
return POWER_STATE_ACTIVE;
}
/*work handler*/

View file

@ -1,7 +1,7 @@
# Copyright (c) 2020 Intel Corporation.
# SPDX-License-Identifier: Apache-2.0
config SUBSYS_POWER_TEST
config SUBPOWER_TEST
bool
default y
select HAS_POWER_STATE_SLEEP_1

View file

@ -20,7 +20,7 @@
static bool enter_low_power;
static bool notify_app_entry;
static bool notify_app_exit;
static bool set_sys_power;
static bool set_pm;
static bool leave_idle;
static bool idle_entered;
@ -32,10 +32,10 @@ static struct dummy_driver_api *api;
*/
__weak void sys_set_power_state(enum power_states state)
{
/* at this point, sys_pm_notify_power_state_entry() implemented in
* this file has been called and set_sys_power should have been set
/* at this point, pm_notify_power_state_entry() implemented in
* this file has been called and set_pm should have been set
*/
zassert_true(set_sys_power == true,
zassert_true(set_pm == true,
"Notification to enter suspend was not sent to the App");
/* this function is called after devices enter low power state */
@ -45,13 +45,13 @@ __weak void sys_set_power_state(enum power_states state)
zassert_false(device_power_state == DEVICE_PM_ACTIVE_STATE, NULL);
/* this function is called when system entering low power state, so
* parameter state should not be SYS_POWER_STATE_ACTIVE
* parameter state should not be POWER_STATE_ACTIVE
*/
zassert_false(state == SYS_POWER_STATE_ACTIVE,
zassert_false(state == POWER_STATE_ACTIVE,
"Entering low power state with a wrong parameter");
}
__weak void _sys_pm_power_state_exit_post_ops(enum power_states state)
__weak void _pm_power_state_exit_post_ops(enum power_states state)
{
/* _sys_suspend is entered with irq locked
* unlock irq before leave _sys_suspend
@ -59,13 +59,13 @@ __weak void _sys_pm_power_state_exit_post_ops(enum power_states state)
irq_unlock(0);
}
__weak bool sys_pm_policy_low_power_devices(enum power_states pm_state)
__weak bool pm_policy_low_power_devices(enum power_states pm_state)
{
return sys_pm_is_sleep_state(pm_state);
return pm_is_sleep_state(pm_state);
}
/* Our PM policy handler */
enum power_states sys_pm_policy_next_state(int ticks)
enum power_states pm_policy_next_state(int ticks)
{
enum power_states state;
@ -77,18 +77,18 @@ enum power_states sys_pm_policy_next_state(int ticks)
if (enter_low_power) {
enter_low_power = false;
notify_app_entry = true;
state = SYS_POWER_STATE_SLEEP_1;
state = POWER_STATE_SLEEP_1;
} else {
/* only test sys_pm_policy_next_state()
/* only test pm_policy_next_state()
* no PM operation done
*/
state = SYS_POWER_STATE_ACTIVE;
state = POWER_STATE_ACTIVE;
}
return state;
}
/* implement in application, called by idle thread */
void sys_pm_notify_power_state_entry(enum power_states state)
void pm_notify_power_state_entry(enum power_states state)
{
uint32_t device_power_state;
@ -96,17 +96,17 @@ void sys_pm_notify_power_state_entry(enum power_states state)
zassert_true(notify_app_entry == true,
"Notification to enter suspend was not sent to the App");
zassert_true(z_is_idle_thread_object(_current), NULL);
zassert_equal(state, SYS_POWER_STATE_SLEEP_1, NULL);
zassert_equal(state, POWER_STATE_SLEEP_1, NULL);
/* at this point, devices are active */
device_get_power_state(dev, &device_power_state);
zassert_equal(device_power_state, DEVICE_PM_ACTIVE_STATE, NULL);
set_sys_power = true;
set_pm = true;
notify_app_exit = true;
}
/* implement in application, called by idle thread */
void sys_pm_notify_power_state_exit(enum power_states state)
void pm_notify_power_state_exit(enum power_states state)
{
uint32_t device_power_state;
@ -114,7 +114,7 @@ void sys_pm_notify_power_state_exit(enum power_states state)
zassert_true(notify_app_exit == true,
"Notification to leave suspend was not sent to the App");
zassert_true(z_is_idle_thread_object(_current), NULL);
zassert_equal(state, SYS_POWER_STATE_SLEEP_1, NULL);
zassert_equal(state, POWER_STATE_SLEEP_1, NULL);
/* at this point, devices are active again*/
device_get_power_state(dev, &device_power_state);
@ -130,11 +130,11 @@ void sys_pm_notify_power_state_exit(enum power_states state)
* - The global idle routine executes when no other work is available
* - The idle routine provide a timeout parameter to the suspend routine
* indicating the amount of time guaranteed to expire before the next
* timeout, sys_pm_policy_next_state() handle this parameter.
* - In this case, sys_pm_policy_next_sate() return SYS_POWER_STATE_ACTIVE,
* timeout, pm_policy_next_state() handle this parameter.
* - In this case, pm_policy_next_sate() return POWER_STATE_ACTIVE,
* so there is no low power operation happen.
*
* @see sys_pm_policy_next_state()
* @see pm_policy_next_state()
*
* @ingroup power_tests
*/
@ -152,9 +152,9 @@ void test_power_idle(void)
* - The system support control of power state ordering between
* subsystems and devices
* - The application can control system power state transitions in idle thread
* through sys_pm_notify_power_state_entry and sys_pm_notify_power_state_exit
* through pm_notify_power_state_entry and pm_notify_power_state_exit
*
* @see sys_pm_notify_power_state_entry(), sys_pm_notify_power_state_exit()
* @see pm_notify_power_state_entry(), pm_notify_power_state_exit()
*
* @ingroup power_tests
*/

View file

@ -69,30 +69,30 @@ static void pm_latency_check(void)
}
/* Hooks to count entry/exit */
void sys_pm_notify_power_state_entry(enum power_states state)
void pm_notify_power_state_entry(enum power_states state)
{
if (!checks_enabled) {
return;
}
if (sys_pm_is_sleep_state(state)) {
if (pm_is_sleep_state(state)) {
pm_counters[0].entry_cnt++;
pm_latency_check();
} else if (sys_pm_is_deep_sleep_state(state)) {
} else if (pm_is_deep_sleep_state(state)) {
pm_counters[1].entry_cnt++;
pm_latency_check();
}
}
void sys_pm_notify_power_state_exit(enum power_states state)
void pm_notify_power_state_exit(enum power_states state)
{
if (!checks_enabled) {
return;
}
if (sys_pm_is_sleep_state(state)) {
if (pm_is_sleep_state(state)) {
pm_counters[0].exit_cnt++;
} else if (sys_pm_is_deep_sleep_state(state)) {
} else if (pm_is_deep_sleep_state(state)) {
pm_counters[1].exit_cnt++;
}
}