soc: stm32g0x: add poweroff implementation

Same implementation as stm32c0x and stm32l4x. This is required
for wake-up from sleep.

Signed-off-by: Martin Jäger <martin@libre.solar>
This commit is contained in:
Martin Jäger 2025-04-29 22:39:12 +02:00 committed by Benjamin Cabé
commit bb0e580be4
3 changed files with 36 additions and 3 deletions

View file

@ -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(.)

View file

@ -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

View file

@ -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 <zephyr/kernel.h>
#include <zephyr/sys/poweroff.h>
#include <zephyr/toolchain.h>
#include <zephyr/drivers/misc/stm32_wkup_pins/stm32_wkup_pins.h>
#include <stm32_ll_cortex.h>
#include <stm32_ll_pwr.h>
#include <stm32_ll_system.h>
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;
}