soc: arm: st_stm32: u5: add support for sys_poweroff
Add support for the sys_poweroff hook, re-using code from the SOFT_OFF state. Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
This commit is contained in:
parent
825b0fb5d3
commit
d7a0b4fa93
4 changed files with 24 additions and 13 deletions
|
@ -8,3 +8,5 @@ zephyr_sources(
|
||||||
zephyr_sources_ifdef(CONFIG_PM
|
zephyr_sources_ifdef(CONFIG_PM
|
||||||
power.c
|
power.c
|
||||||
)
|
)
|
||||||
|
|
||||||
|
zephyr_sources_ifdef(CONFIG_POWEROFF poweroff.c)
|
||||||
|
|
|
@ -16,5 +16,6 @@ config SOC_SERIES_STM32U5X
|
||||||
select CPU_CORTEX_M_HAS_DWT
|
select CPU_CORTEX_M_HAS_DWT
|
||||||
select HAS_STM32CUBE
|
select HAS_STM32CUBE
|
||||||
select HAS_PM
|
select HAS_PM
|
||||||
|
select HAS_POWEROFF
|
||||||
help
|
help
|
||||||
Enable support for STM32U5 MCU series
|
Enable support for STM32U5 MCU series
|
||||||
|
|
|
@ -54,13 +54,6 @@ void set_mode_standby(uint8_t substate_id)
|
||||||
LL_PWR_SetPowerMode(LL_PWR_STANDBY_MODE);
|
LL_PWR_SetPowerMode(LL_PWR_STANDBY_MODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_mode_shutdown(uint8_t substate_id)
|
|
||||||
{
|
|
||||||
ARG_UNUSED(substate_id);
|
|
||||||
/* Select shutdown mode */
|
|
||||||
LL_PWR_SetPowerMode(LL_PWR_SHUTDOWN_MODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Invoke Low Power/System Off specific Tasks */
|
/* Invoke Low Power/System Off specific Tasks */
|
||||||
void pm_state_set(enum pm_state state, uint8_t substate_id)
|
void pm_state_set(enum pm_state state, uint8_t substate_id)
|
||||||
{
|
{
|
||||||
|
@ -72,9 +65,6 @@ void pm_state_set(enum pm_state state, uint8_t substate_id)
|
||||||
/* To be tested */
|
/* To be tested */
|
||||||
set_mode_standby(substate_id);
|
set_mode_standby(substate_id);
|
||||||
break;
|
break;
|
||||||
case PM_STATE_SOFT_OFF:
|
|
||||||
set_mode_shutdown(substate_id);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
LOG_DBG("Unsupported power state %u", state);
|
LOG_DBG("Unsupported power state %u", state);
|
||||||
return;
|
return;
|
||||||
|
@ -102,9 +92,6 @@ void pm_state_exit_post_ops(enum pm_state state, uint8_t substate_id)
|
||||||
case PM_STATE_STANDBY:
|
case PM_STATE_STANDBY:
|
||||||
/* To be tested */
|
/* To be tested */
|
||||||
LL_LPM_EnableSleep();
|
LL_LPM_EnableSleep();
|
||||||
case PM_STATE_SOFT_OFF:
|
|
||||||
/* We should not get there */
|
|
||||||
__fallthrough;
|
|
||||||
case PM_STATE_SUSPEND_TO_RAM:
|
case PM_STATE_SUSPEND_TO_RAM:
|
||||||
__fallthrough;
|
__fallthrough;
|
||||||
case PM_STATE_SUSPEND_TO_DISK:
|
case PM_STATE_SUSPEND_TO_DISK:
|
||||||
|
|
21
soc/arm/st_stm32/stm32u5/poweroff.c
Normal file
21
soc/arm/st_stm32/stm32u5/poweroff.c
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023 Nordic Semiconductor ASA
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <zephyr/kernel.h>
|
||||||
|
#include <zephyr/sys/poweroff.h>
|
||||||
|
#include <zephyr/toolchain.h>
|
||||||
|
|
||||||
|
#include <stm32_ll_cortex.h>
|
||||||
|
#include <stm32_ll_pwr.h>
|
||||||
|
|
||||||
|
void z_sys_poweroff(void)
|
||||||
|
{
|
||||||
|
LL_PWR_SetPowerMode(LL_PWR_SHUTDOWN_MODE);
|
||||||
|
LL_LPM_EnableDeepSleep();
|
||||||
|
|
||||||
|
k_cpu_idle();
|
||||||
|
|
||||||
|
CODE_UNREACHABLE;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue