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
|
@ -54,6 +54,7 @@
|
||||||
clk-pclkdiv = <(NUMAKER_CLK_PCLKDIV_APB0DIV_DIV2 |
|
clk-pclkdiv = <(NUMAKER_CLK_PCLKDIV_APB0DIV_DIV2 |
|
||||||
NUMAKER_CLK_PCLKDIV_APB1DIV_DIV2)>;
|
NUMAKER_CLK_PCLKDIV_APB1DIV_DIV2)>;
|
||||||
core-clock = <200000000>;
|
core-clock = <200000000>;
|
||||||
|
powerdown-mode = <NUMAKER_CLK_PMUCTL_PDMSEL_DPD>;
|
||||||
|
|
||||||
pcc: peripheral-clock-controller {
|
pcc: peripheral-clock-controller {
|
||||||
compatible = "nuvoton,numaker-pcc";
|
compatible = "nuvoton,numaker-pcc";
|
||||||
|
|
|
@ -47,3 +47,9 @@ properties:
|
||||||
type: int
|
type: int
|
||||||
description: |
|
description: |
|
||||||
Configure core clock (HCLK)
|
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
|
||||||
|
|
|
@ -1300,4 +1300,10 @@
|
||||||
|
|
||||||
/* End of M460 BSP clk.h copy */
|
/* 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
|
#endif
|
||||||
|
|
|
@ -6,4 +6,6 @@ zephyr_sources(soc.c)
|
||||||
|
|
||||||
zephyr_include_directories(.)
|
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 "")
|
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_FPU
|
||||||
select CPU_HAS_ARM_MPU
|
select CPU_HAS_ARM_MPU
|
||||||
select CORTEX_M_SYSTICK if SYS_CLOCK_EXISTS
|
select CORTEX_M_SYSTICK if SYS_CLOCK_EXISTS
|
||||||
|
select HAS_POWEROFF
|
||||||
|
|
||||||
config SOC_M467
|
config SOC_M467
|
||||||
select HAS_NUMAKER_HAL
|
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 */
|
/* Unlock protected registers */
|
||||||
SYS_UnlockReg();
|
SYS_UnlockReg();
|
||||||
|
|
||||||
|
/* Release I/O hold status */
|
||||||
|
CLK->IOPDCTL = 1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* -------------------
|
* -------------------
|
||||||
* Init System Clock
|
* Init System Clock
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue