Skip to content

Commit 0bd9b0f

Browse files
committed
soc: nxp: mcxw2xx: Add poweroff support
Add poweroff MCXW2xx SoCs, support btn_wk pin wakeup. Signed-off-by: Jason Yu <zejiang.yu@nxp.com>
1 parent 362560a commit 0bd9b0f

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

soc/nxp/mcx/mcxw/mcxw2xx/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ zephyr_sources(soc.c)
66

77
zephyr_sources_ifdef(CONFIG_PM power.c)
88

9+
zephyr_sources_ifdef(CONFIG_POWEROFF poweroff.c)
10+
911
zephyr_include_directories(./)
1012

1113
set(SOC_LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/linker.ld CACHE INTERNAL "")

soc/nxp/mcx/mcxw/mcxw2xx/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
# Copyright 2025 NXP
22
#
33
# SPDX-License-Identifier: Apache-2.0
4+
5+
config SOC_SERIES_MCXW2XX
6+
select HAS_POWEROFF
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright 2025 NXP
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/devicetree.h>
8+
#include <zephyr/sys/poweroff.h>
9+
#include <zephyr/toolchain.h>
10+
#include <zephyr/drivers/gpio.h>
11+
#include <fsl_power.h>
12+
13+
#if CONFIG_GPIO && DT_NODE_EXISTS(DT_NODELABEL(btn_wk))
14+
15+
#if (DT_GPIO_FLAGS(DT_NODELABEL(btn_wk), gpios)) & GPIO_ACTIVE_LOW
16+
#define POWEROFF_WAKEUP (kWAKEUP_PIN_ENABLE | \
17+
kWAKEUP_PIN_PUP_EN | \
18+
kWAKEUP_PIN_WAKEUP_LOW_LVL)
19+
#else /* !GPIO_ACTIVE_LOW */
20+
#define POWEROFF_WAKEUP (kWAKEUP_PIN_ENABLE | \
21+
kWAKEUP_PIN_PDN_EN | \
22+
kWAKEUP_PIN_WAKEUP_HIGH_LVL)
23+
#endif /* GPIO_ACTIVE_LOW */
24+
25+
#else
26+
#define POWEROFF_WAKEUP kWAKEUP_PIN_DISABLE
27+
#endif /* CONFIG_GPIO && DT_NODE_EXISTS(DT_NODELABEL(btn_wk)) */
28+
29+
void z_sys_poweroff(void)
30+
{
31+
POWER_EnterPowerOff(0, POWEROFF_WAKEUP);
32+
33+
CODE_UNREACHABLE;
34+
}

0 commit comments

Comments
 (0)