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:
cyliang tw 2024-07-12 11:53:32 +08:00 committed by Carles Cufí
commit 5b921c53b0
7 changed files with 50 additions and 0 deletions

View file

@ -54,6 +54,7 @@
clk-pclkdiv = <(NUMAKER_CLK_PCLKDIV_APB0DIV_DIV2 |
NUMAKER_CLK_PCLKDIV_APB1DIV_DIV2)>;
core-clock = <200000000>;
powerdown-mode = <NUMAKER_CLK_PMUCTL_PDMSEL_DPD>;
pcc: peripheral-clock-controller {
compatible = "nuvoton,numaker-pcc";

View file

@ -47,3 +47,9 @@ properties:
type: int
description: |
Configure core clock (HCLK)
powerdown-mode:
type: int
description: |
Configure power down mode, please choose one of NUMAKER_CLK_PMUCTL_PDMSEL_XXX
from numaker_xxx_clock.h

View file

@ -1300,4 +1300,10 @@
/* End of M460 BSP clk.h copy */
#define NUMAKER_CLK_PMUCTL_PDMSEL_PD 0x00000000
#define NUMAKER_CLK_PMUCTL_PDMSEL_LLPD 0x00000001
#define NUMAKER_CLK_PMUCTL_PDMSEL_FWPD 0x00000002
#define NUMAKER_CLK_PMUCTL_PDMSEL_SPD 0x00000004
#define NUMAKER_CLK_PMUCTL_PDMSEL_DPD 0x00000006
#endif

View file

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

View file

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

View 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;
}

View file

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