From bb0e580be46b8c7ca97b8c34d96fd718119a21b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20J=C3=A4ger?= Date: Tue, 29 Apr 2025 22:39:12 +0200 Subject: [PATCH] soc: stm32g0x: add poweroff implementation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Same implementation as stm32c0x and stm32l4x. This is required for wake-up from sleep. Signed-off-by: Martin Jäger --- soc/st/stm32/stm32g0x/CMakeLists.txt | 5 ++--- soc/st/stm32/stm32g0x/Kconfig | 1 + soc/st/stm32/stm32g0x/poweroff.c | 33 ++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 soc/st/stm32/stm32g0x/poweroff.c diff --git a/soc/st/stm32/stm32g0x/CMakeLists.txt b/soc/st/stm32/stm32g0x/CMakeLists.txt index 65706e73bfa..492cb808f8e 100644 --- a/soc/st/stm32/stm32g0x/CMakeLists.txt +++ b/soc/st/stm32/stm32g0x/CMakeLists.txt @@ -6,9 +6,8 @@ zephyr_sources( soc.c ) -zephyr_sources_ifdef(CONFIG_PM - power.c - ) +zephyr_sources_ifdef(CONFIG_PM power.c) +zephyr_sources_ifdef(CONFIG_POWEROFF poweroff.c) zephyr_include_directories(.) diff --git a/soc/st/stm32/stm32g0x/Kconfig b/soc/st/stm32/stm32g0x/Kconfig index 7361bef642c..0a551904f60 100644 --- a/soc/st/stm32/stm32g0x/Kconfig +++ b/soc/st/stm32/stm32g0x/Kconfig @@ -12,4 +12,5 @@ config SOC_SERIES_STM32G0X select HAS_STM32CUBE select CPU_CORTEX_M_HAS_SYSTICK select HAS_PM + select HAS_POWEROFF select SOC_EARLY_INIT_HOOK diff --git a/soc/st/stm32/stm32g0x/poweroff.c b/soc/st/stm32/stm32g0x/poweroff.c new file mode 100644 index 00000000000..1e6589167ad --- /dev/null +++ b/soc/st/stm32/stm32g0x/poweroff.c @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Nordic Semiconductor ASA + * Copyright (c) 2024 STMicroelectronics + * Copyright (c) 2025 A Labs GmbH + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include + +#include +#include +#include + +void z_sys_poweroff(void) +{ +#ifdef CONFIG_STM32_WKUP_PINS + stm32_pwr_wkup_pin_cfg_pupd(); + + LL_PWR_ClearFlag_WU(); +#endif /* CONFIG_STM32_WKUP_PINS */ + + LL_PWR_SetPowerMode(LL_PWR_MODE_SHUTDOWN); + LL_LPM_EnableDeepSleep(); + LL_DBGMCU_DisableDBGStandbyMode(); + + k_cpu_idle(); + + CODE_UNREACHABLE; +}