soc: nuvoton: numaker: add poweroff for m46x
Add support of sys_poweroff API on m46x series. It could support SPD standby or DPD deep power down mode. Signed-off-by: cyliang tw <cyliang@nuvoton.com>
This commit is contained in:
parent
371206d254
commit
5b921c53b0
7 changed files with 50 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 "")
|
||||
|
|
|
@ -9,6 +9,7 @@ config SOC_SERIES_M46X
|
|||
select CPU_HAS_FPU
|
||||
select CPU_HAS_ARM_MPU
|
||||
select CORTEX_M_SYSTICK if SYS_CLOCK_EXISTS
|
||||
select HAS_POWEROFF
|
||||
|
||||
config SOC_M467
|
||||
select HAS_NUMAKER_HAL
|
||||
|
|
31
soc/nuvoton/numaker/m46x/poweroff.c
Normal file
31
soc/nuvoton/numaker/m46x/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_SPD));
|
||||
|
||||
/* 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