Skip to content

Commit 507a257

Browse files
committed
soc: nxp: mcx/mcxn: Enable poweroff for mcxn series
This commit introduced the following changes: 1. Selected kconfig option 'HAS_POWEROFF' for NXP MCXN series. 2. Added power.c for NXP MCXN series, in this file, we currently implemented 'z_sys_poweroff()' function. 3. For the MCXN series, after waking up from the deep power down mode, the reset handler will be executed, and we need to release the I/O pads and certain peripheral devices to normal operating mode in 'soc_reset_hook'. Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
1 parent 6418646 commit 507a257

File tree

4 files changed

+46
-0
lines changed

4 files changed

+46
-0
lines changed

soc/nxp/mcx/mcxn/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,7 @@ endif()
3434
zephyr_include_directories(.)
3535

3636
set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm/cortex_m/scripts/linker.ld CACHE INTERNAL "")
37+
38+
if(CONFIG_POWEROFF)
39+
zephyr_sources(power.c)
40+
endif()

soc/nxp/mcx/mcxn/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ config SOC_SERIES_MCXN
1010
select CPU_CORTEX_M_HAS_SYSTICK
1111
select CPU_CORTEX_M_HAS_DWT
1212
select HAS_MCUX_MCX_CMC
13+
select HAS_POWEROFF
1314

1415
config SOC_MCXN947_CPU0
1516
select CPU_CORTEX_M33

soc/nxp/mcx/mcxn/power.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2025 NXP
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/sys/poweroff.h>
8+
#include <zephyr/toolchain.h>
9+
#include "fsl_cmc.h"
10+
#include "fsl_spc.h"
11+
#include "fsl_vbat.h"
12+
#include "fsl_wuu.h"
13+
14+
void z_sys_poweroff(void)
15+
{
16+
cmc_power_domain_config_t cmc_config = {
17+
.clock_mode = kCMC_GateAllSystemClocksEnterLowPowerMode,
18+
.main_domain = kCMC_DeepPowerDown,
19+
.wake_domain = kCMC_DeepPowerDown,
20+
};
21+
22+
WUU_SetInternalWakeUpModulesConfig(WUU0, 6U, kWUU_InternalModuleInterrupt);
23+
SPC_SetLowPowerWakeUpDelay(SPC0, 0x637);
24+
25+
CMC_SetPowerModeProtection(CMC0, kCMC_AllowDeepPowerDownMode);
26+
CMC_EnterLowPowerMode(CMC0, &cmc_config);
27+
28+
CODE_UNREACHABLE;
29+
}

soc/nxp/mcx/mcxn/soc.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,23 @@
1616
#include <zephyr/device.h>
1717
#include <zephyr/init.h>
1818
#include <soc.h>
19+
#if defined(CONFIG_PM) || defined(CONFIG_POWEROFF)
20+
#include <fsl_spc.h>
21+
#include <fsl_cmc.h>
22+
#endif
1923

2024
#ifdef CONFIG_SOC_RESET_HOOK
2125

2226
void soc_reset_hook(void)
2327
{
28+
#if defined(CONFIG_PM) || defined(CONFIG_POWEROFF)
29+
/* Release the I/O pads and certain peripherals to normal run mode state,
30+
* for in Power Down mode they will be in a latched state.
31+
*/
32+
if ((CMC_GetSystemResetStatus(CMC0) & kCMC_WakeUpReset) != 0UL) {
33+
SPC_ClearPeriphIOIsolationFlag(SPC0);
34+
}
35+
#endif
2436
SystemInit();
2537
}
2638

0 commit comments

Comments
 (0)