From c24188cca9bdfe2713fa67aab6407333cc9ccfa0 Mon Sep 17 00:00:00 2001 From: Aurelien Jarno Date: Fri, 24 Sep 2021 00:02:45 +0200 Subject: [PATCH] soc: arm: stm32wl: wakeup from stop clock selection based on sysclk When exiting Stop mode, if system clock is MSI, MSI oscillator is selected as wakeup from stop clock; otherwise HSI16 oscillator is selected. It is otherwise reconfigured as MSI just after, but it slightly increases the wake-up time and power consumption. Signed-off-by: Aurelien Jarno --- soc/arm/st_stm32/stm32wl/power.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/soc/arm/st_stm32/stm32wl/power.c b/soc/arm/st_stm32/stm32wl/power.c index 38b1175966a3f..3b32b41a6a0d4 100644 --- a/soc/arm/st_stm32/stm32wl/power.c +++ b/soc/arm/st_stm32/stm32wl/power.c @@ -15,16 +15,24 @@ #include #include #include +#include #include LOG_MODULE_DECLARE(soc, CONFIG_SOC_LOG_LEVEL); +/* select MSI as wake-up system clock if configured, HSI otherwise */ +#if STM32_SYSCLK_SRC_MSI +#define RCC_STOP_WAKEUPCLOCK_SELECTED LL_RCC_STOP_WAKEUPCLOCK_MSI +#else +#define RCC_STOP_WAKEUPCLOCK_SELECTED LL_RCC_STOP_WAKEUPCLOCK_HSI +#endif + /* Invoke Low Power/System Off specific Tasks */ __weak void pm_power_state_set(struct pm_state_info info) { switch (info.state) { case PM_STATE_SUSPEND_TO_IDLE: - LL_RCC_SetClkAfterWakeFromStop(LL_RCC_STOP_WAKEUPCLOCK_HSI); + LL_RCC_SetClkAfterWakeFromStop(RCC_STOP_WAKEUPCLOCK_SELECTED); LL_PWR_ClearFlag_WU(); switch (info.substate_id) { case 1: