soc: nuvoton: numaker: add poweroff for m2l31x
Add support of sys_poweroff API on m2l31x series. It could support SPD0~2 standby or DPD0~1 deep power down mode. Signed-off-by: cyliang tw <cyliang@nuvoton.com>
This commit is contained in:
parent
f3dcaaee35
commit
5025487dd0
6 changed files with 51 additions and 0 deletions
|
@ -6,4 +6,6 @@ zephyr_sources(soc.c)
|
|||
|
||||
zephyr_include_directories(.)
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_POWEROFF poweroff.c)
|
||||
|
||||
set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm/cortex_m/scripts/linker.ld CACHE INTERNAL "")
|
||||
|
|
|
@ -8,6 +8,7 @@ config SOC_SERIES_M2L31X
|
|||
select CPU_CORTEX_M_HAS_SYSTICK
|
||||
select CPU_CORTEX_M_HAS_VTOR
|
||||
select CPU_HAS_ARM_MPU
|
||||
select HAS_POWEROFF
|
||||
|
||||
config SOC_M2L31XXX
|
||||
select HAS_NUMAKER_HAL
|
||||
|
|
31
soc/nuvoton/numaker/m2l31x/poweroff.c
Normal file
31
soc/nuvoton/numaker/m2l31x/poweroff.c
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (c) 2024 Nuvoton Technology Corporation.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/devicetree.h>
|
||||
#include <zephyr/sys/poweroff.h>
|
||||
#include <NuMicro.h>
|
||||
|
||||
void z_sys_poweroff(void)
|
||||
{
|
||||
SYS_UnlockReg();
|
||||
|
||||
/* Clear all wake-up flag */
|
||||
CLK->PMUSTS |= CLK_PMUSTS_CLRWK_Msk;
|
||||
|
||||
/* Select Power-down mode */
|
||||
CLK_SetPowerDownMode(DT_PROP_OR(DT_NODELABEL(scc), powerdown_mode, CLK_PMUCTL_PDMSEL_SPD0));
|
||||
|
||||
/* Enable RTC wake-up */
|
||||
CLK_ENABLE_RTCWK();
|
||||
|
||||
/* Enter to Power-down mode */
|
||||
CLK_PowerDown();
|
||||
|
||||
k_cpu_idle();
|
||||
|
||||
CODE_UNREACHABLE;
|
||||
}
|
|
@ -16,6 +16,9 @@ void z_arm_platform_init(void)
|
|||
/* Unlock protected registers */
|
||||
SYS_UnlockReg();
|
||||
|
||||
/* Release I/O hold status */
|
||||
CLK->IOPDCTL = 1;
|
||||
|
||||
/*
|
||||
* -------------------
|
||||
* Init System Clock
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue