Skip to content

Commit 9136a56

Browse files
committed
soc: nxp: mcx/mcxa: Enable poweroff for mcxa series
This commit introduced the following changes: 1. Selected kconfig option 'HAS_POWEROFF' for NXP MCXA series. 2. Added power.c for NXP MCXA series, in this file, we currently implemented 'z_sys_poweroff()' function. 3. For the MCXA 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 26ada2a commit 9136a56

File tree

4 files changed

+48
-2
lines changed

4 files changed

+48
-2
lines changed

soc/nxp/mcx/mcxa/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright 2024 NXP
2+
# Copyright 2024-2025 NXP
33
#
44
# SPDX-License-Identifier: Apache-2.0
55
#
@@ -8,3 +8,7 @@ zephyr_sources(soc.c)
88
zephyr_include_directories(.)
99

1010
set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm/cortex_m/scripts/linker.ld CACHE INTERNAL "")
11+
12+
if(CONFIG_POWEROFF)
13+
zephyr_sources(power.c)
14+
endif()

soc/nxp/mcx/mcxa/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ config SOC_SERIES_MCXA
99
select CPU_CORTEX_M_HAS_SYSTICK
1010
select CPU_CORTEX_M_HAS_DWT
1111
select SOC_RESET_HOOK
12+
select HAS_POWEROFF
1213

1314
config SOC_MCXA153
1415
select CPU_CORTEX_M33

soc/nxp/mcx/mcxa/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+
#include <stdio.h>
14+
15+
void z_sys_poweroff(void)
16+
{
17+
cmc_power_domain_config_t cmc_config = {
18+
.clock_mode = kCMC_GateAllSystemClocksEnterLowPowerMode,
19+
.main_domain = kCMC_DeepPowerDown,
20+
};
21+
22+
WUU_SetInternalWakeUpModulesConfig(WUU0, 6U, kWUU_InternalModuleInterrupt);
23+
SPC_SetLowPowerWakeUpDelay(SPC0, 0x5B);
24+
25+
CMC_SetPowerModeProtection(CMC, kCMC_AllowDeepPowerDownMode);
26+
CMC_EnterLowPowerMode(CMC, &cmc_config);
27+
28+
CODE_UNREACHABLE;
29+
}

soc/nxp/mcx/mcxa/soc.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 NXP
2+
* Copyright 2024-2025 NXP
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -16,10 +16,22 @@
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
void soc_reset_hook(void)
2226
{
27+
#if defined(CONFIG_PM) || defined(CONFIG_POWEROFF)
28+
/* Release the I/O pads and certain peripherals to normal run mode state,
29+
* for in Power Down mode they will be in a latched state. */
30+
if ((CMC_GetSystemResetStatus(CMC) & kCMC_WakeUpReset) != 0UL) {
31+
SPC_ClearPeriphIOIsolationFlag(SPC0);
32+
}
33+
#endif
34+
2335
SystemInit();
2436
}
2537
#endif

0 commit comments

Comments
 (0)