Skip to content

Commit 98f2f58

Browse files
soc: nxp: Add kw45 SoC support
kw45 SoC is similar to mcxw71 with minor differences in Radio Link Layer Interrupt and link layer configuration and status registers. Signed-off-by: Sumit Batra <sumit.batra@nxp.com>
1 parent 6894fce commit 98f2f58

File tree

7 files changed

+272
-1
lines changed

7 files changed

+272
-1
lines changed

soc/nxp/kinetis/kw45/CMakeLists.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright 2025 NXP
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
zephyr_sources(../../mcx/mcxw/soc.c ../../mcx/mcxw/mcxw71_platform_init.S)
6+
7+
zephyr_include_directories(../../mcx/mcxw/)
8+
9+
zephyr_sources_ifdef(CONFIG_NXP_NBU
10+
../../common/nxp_nbu.c
11+
)
12+
13+
zephyr_include_directories(.)
14+
15+
zephyr_sources_ifdef(
16+
CONFIG_PM
17+
power.c
18+
)
19+
20+
set(SOC_LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/../../mcx/mcxw/linker.ld CACHE INTERNAL "")
21+
22+
zephyr_linker_sources_ifdef(CONFIG_BT RAM_SECTIONS ../../mcx/mcxw/sections.ld)

soc/nxp/kinetis/kw45/Kconfig

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# KW45 Series
2+
3+
# Copyright 2025 NXP
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
config SOC_SERIES_KINETIS_KW45
7+
select ARM
8+
select CPU_CORTEX_M33
9+
select CPU_CORTEX_M_HAS_DWT
10+
select HAS_MCUX
11+
select CLOCK_CONTROL
12+
select SOC_RESET_HOOK
13+
select SOC_EARLY_INIT_HOOK
14+
15+
config SOC_KW45B41Z83
16+
select ARM_TRUSTZONE_M
17+
select CPU_CORTEX_M_HAS_SYSTICK
18+
select CPU_HAS_FPU
19+
select CPU_HAS_ARM_SAU
20+
select CPU_HAS_ARM_MPU
21+
select ARMV8_M_DSP
22+
23+
rsource "../../common/Kconfig.nbu"
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# KW45 series configuration options
2+
3+
# Copyright 2025 NXP
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
if SOC_SERIES_KINETIS_KW45
7+
8+
config SYS_CLOCK_HW_CYCLES_PER_SEC
9+
default 96000000 if CORTEX_M_SYSTICK
10+
11+
config MCUX_FLASH_K4_API
12+
default y
13+
14+
config WDOG_INIT
15+
default n
16+
17+
config SOC_SERIES
18+
default "kw45"
19+
20+
config NUM_IRQS
21+
default 74
22+
23+
if BT
24+
25+
# Include intercore messaging component
26+
config NXP_RF_IMU
27+
default y
28+
29+
# Set the controller's public identity using NXP vendor command
30+
config BT_HCI_SET_PUBLIC_ADDR
31+
default y
32+
33+
# HCI RX buffers are received in ISR context. RX messages
34+
# need to be queued and processed by a dedicated thread
35+
config HCI_NXP_RX_THREAD
36+
default y
37+
38+
endif # BT
39+
40+
config PM
41+
select COUNTER
42+
43+
config FLASH
44+
default y if BT
45+
46+
config BT_BUF_EVT_DISCARDABLE_SIZE
47+
default 84 if BT
48+
49+
choice LIBC_IMPLEMENTATION
50+
default NEWLIB_LIBC if PM
51+
endchoice
52+
53+
endif # SOC_SERIES_KINETIS_KW45

soc/nxp/kinetis/kw45/Kconfig.soc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# KW45 Series
2+
3+
# Copyright 2025 NXP
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
config SOC_SERIES_KINETIS_KW45
7+
bool
8+
select SOC_FAMILY_KINETIS
9+
10+
config SOC_SERIES
11+
default "kw45" if SOC_SERIES_KINETIS_KW45
12+
13+
config SOC_KW45B41Z83
14+
bool
15+
select SOC_SERIES_KINETIS_KW45
16+
17+
config SOC
18+
default "kw45b41z83" if SOC_KW45B41Z83
19+
20+
config SOC_PART_NUMBER_KW45B41Z83AFTA
21+
bool
22+
23+
config SOC_PART_NUMBER
24+
default "KW45B41Z83AFTA" if SOC_PART_NUMBER_KW45B41Z83AFTA

soc/nxp/kinetis/kw45/power.c

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
/*
2+
* Copyright 2025 NXP
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/kernel.h>
8+
#include <zephyr/device.h>
9+
#include <zephyr/pm/pm.h>
10+
#include <zephyr/timeout_q.h>
11+
#include <zephyr/drivers/counter.h>
12+
#include <zephyr/drivers/timer/system_timer.h>
13+
14+
#include "fsl_pm_core.h"
15+
#include "fsl_pm_board.h"
16+
17+
#include "fwk_platform_lowpower.h"
18+
19+
#include <zephyr/logging/log.h>
20+
LOG_MODULE_DECLARE(soc, CONFIG_SOC_LOG_LEVEL);
21+
22+
#define LPTMR0_DEV DT_NODELABEL(lptmr0)
23+
const struct device *const counter_dev = DEVICE_DT_GET(LPTMR0_DEV);
24+
25+
/* TODO: change this line when PowerDown is enabled
26+
* This definition is needed for compilation, but only used on PowerDown
27+
*/
28+
uint32_t m_warmboot_stack_end __section("RetainedMem");
29+
30+
/* -------------------------------------------------------------------------- */
31+
/* Private variables */
32+
/* -------------------------------------------------------------------------- */
33+
34+
static pm_handle_t pm_hdl;
35+
static bool unsupported_state;
36+
static uint8_t lowest_state;
37+
38+
/* -------------------------------------------------------------------------- */
39+
/* Public functions */
40+
/* -------------------------------------------------------------------------- */
41+
42+
__weak void pm_state_set(enum pm_state state, uint8_t substate_id)
43+
{
44+
int32_t timeout_expiry;
45+
struct counter_top_cfg counter_info;
46+
47+
ARG_UNUSED(substate_id);
48+
49+
__ASSERT(device_is_ready(counter_dev), "ERROR: Counter is not ready to be used");
50+
51+
__disable_irq();
52+
irq_unlock(0);
53+
54+
unsupported_state = false;
55+
56+
switch (state) {
57+
case PM_STATE_SUSPEND_TO_IDLE:
58+
lowest_state = PM_LP_STATE_DEEP_SLEEP;
59+
break;
60+
61+
default:
62+
LOG_DBG("Unsupported power state %u", state);
63+
unsupported_state = true;
64+
break;
65+
}
66+
67+
if (!unsupported_state) {
68+
69+
if (PM_SetConstraints(lowest_state, 0) != 0) {
70+
__ASSERT(0, "ERROR: to set constraint");
71+
}
72+
73+
timeout_expiry = z_get_next_timeout_expiry();
74+
75+
counter_info.ticks =
76+
counter_us_to_ticks(counter_dev, k_ticks_to_us_floor32(timeout_expiry));
77+
counter_info.callback = NULL;
78+
counter_info.user_data = NULL;
79+
80+
counter_set_top_value(counter_dev, &counter_info);
81+
/* Disable systick before going to low power */
82+
SysTick->CTRL &= ~(SysTick_CTRL_TICKINT_Msk | SysTick_CTRL_ENABLE_Msk);
83+
/* LPTMR (counter) is set to wakeup the system after the requested time */
84+
if (counter_start(counter_dev) != 0) {
85+
__ASSERT(0, "ERROR: can't start timer to wakeup");
86+
}
87+
88+
PM_EnterLowPower(k_ticks_to_us_floor64(timeout_expiry));
89+
}
90+
}
91+
92+
/* Handle SOC specific activity after Low Power Mode Exit */
93+
__weak void pm_state_exit_post_ops(enum pm_state state, uint8_t substate_id)
94+
{
95+
uint32_t slept_time_ticks;
96+
uint32_t slept_time_us;
97+
98+
ARG_UNUSED(state);
99+
ARG_UNUSED(substate_id);
100+
101+
if (!unsupported_state) {
102+
counter_get_value(counter_dev, &slept_time_ticks);
103+
/* Reactivate systick */
104+
SysTick->CTRL |= (SysTick_CTRL_TICKINT_Msk | SysTick_CTRL_ENABLE_Msk);
105+
106+
counter_stop(counter_dev);
107+
slept_time_us = counter_ticks_to_us(counter_dev, slept_time_ticks);
108+
/* Announce the time slept to the kernel*/
109+
sys_clock_announce(k_us_to_ticks_near32(slept_time_us));
110+
111+
if (PM_ReleaseConstraints(lowest_state, 0) != 0) {
112+
__ASSERT(0, "ERROR: to release constraint");
113+
}
114+
}
115+
/* Clear PRIMASK */
116+
__enable_irq();
117+
}
118+
119+
static int kw45_power_init(void)
120+
{
121+
int ret = 0;
122+
123+
PM_CreateHandle(&pm_hdl);
124+
PM_EnablePowerManager(true);
125+
126+
PLATFORM_LowPowerInit();
127+
#if !defined(CONFIG_BT)
128+
RFMC->CTRL |= RFMC_CTRL_RFMC_RST(0x1U);
129+
RFMC->CTRL &= ~RFMC_CTRL_RFMC_RST_MASK;
130+
131+
/* NBU was probably in low power before the RFMC reset, so we need to wait for
132+
* the FRO clock to be valid before accessing RF_CMC
133+
*/
134+
while ((RFMC->RF2P4GHZ_STAT & RFMC_RF2P4GHZ_STAT_FRO_CLK_VLD_STAT_MASK) == 0U) {
135+
;
136+
}
137+
138+
RF_CMC1->RADIO_LP |= RF_CMC1_RADIO_LP_CK(0x2);
139+
140+
/* Force low power entry request to the radio domain */
141+
RFMC->RF2P4GHZ_CTRL |= RFMC_RF2P4GHZ_CTRL_LP_ENTER(0x1U);
142+
#endif
143+
return ret;
144+
}
145+
146+
SYS_INIT(kw45_power_init, PRE_KERNEL_2, 0);

soc/nxp/kinetis/soc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ family:
3434
- name: mke15z7
3535
- name: mke17z7
3636
- name: mke17z9
37+
- name: kw45
38+
socs:
39+
- name: kw45b41z83
3740
runners:
3841
run_once:
3942
'--erase':

west.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ manifest:
203203
groups:
204204
- hal
205205
- name: hal_nxp
206-
revision: be4d59d9c84e9519f3c05645f410b6dd63aeac4f
206+
revision: pull/502/head
207207
path: modules/hal/nxp
208208
groups:
209209
- hal

0 commit comments

Comments
 (0)