Skip to content

Commit 7cef43c

Browse files
committed
soc: nxp: mcxw2xx: Enable the power management
Enabled modes: idle: SLEEP suspend: DEEP-SLEEP standby: POWER-DOWN with CPU retention OS Time Base: OSTIMER with 32K clock source Signed-off-by: Jason Yu <zejiang.yu@nxp.com>
1 parent f3fa3fd commit 7cef43c

File tree

6 files changed

+344
-6
lines changed

6 files changed

+344
-6
lines changed

boards/nxp/frdm_mcxw23/doc/index.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,21 @@ should see the following message in the terminal:
198198
*** Booting Zephyr OS build v4.2.0-2105-g48f2ffda26de ***
199199
Hello World! frdm_mcxw23/mcxw236
200200
201+
Power Management
202+
================
203+
204+
When Power Management is enabled, OSTIMER is used as OS tick timer.
205+
Add device tree overlay file to the main directory of your application
206+
to enable OSTIMER.
207+
208+
.. code-block:: devicetree
209+
210+
&os_timer {
211+
status = "okay";
212+
};
213+
214+
Limitation: Wakeup pin can't be used as wakeup source in Standby mode.
215+
201216
.. include:: ../../common/board-footer.rst.inc
202217

203218
.. _MCXW23 SoC Website:

boards/nxp/mcxw23_evk/doc/index.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,21 @@ should see the following message in the terminal:
177177
*** Booting Zephyr OS build v4.2.0-2105-g9da1d56da9e7 ***
178178
Hello World! mcxw23_evk/mcxw236
179179
180+
Power Management
181+
================
182+
183+
When Power Management is enabled, OSTIMER is used as OS tick timer.
184+
Add device tree overlay file to the main directory of your application
185+
to enable OSTIMER.
186+
187+
.. code-block:: devicetree
188+
189+
&os_timer {
190+
status = "okay";
191+
};
192+
193+
Limitation: Wakeup pin can't be used as wakeup source in Standby mode.
194+
180195
.. include:: ../../common/board-footer.rst.inc
181196

182197
.. _MCXW23 SoC Website:

dts/arm/nxp/nxp_mcxw23x_common.dtsi

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,47 @@
3232
reg = <0>;
3333
#address-cells = <1>;
3434
#size-cells = <1>;
35+
cpu-power-states = <&idle &suspend &standby>;
3536

3637
mpu: mpu@e000ed90 {
3738
compatible = "arm,armv8m-mpu";
3839
reg = <0xe000ed90 0x40>;
3940
};
4041
};
42+
43+
power-states {
44+
/* Idle mode maps to Sleep mode. */
45+
idle: idle {
46+
compatible = "zephyr,power-state";
47+
power-state-name = "runtime-idle";
48+
min-residency-us = <60>;
49+
exit-latency-us = <16>;
50+
zephyr,pm-device-disabled;
51+
};
52+
53+
/* Suspend mode maps to Deep Sleep mode. */
54+
suspend: suspend {
55+
compatible = "zephyr,power-state";
56+
power-state-name = "suspend-to-idle";
57+
min-residency-us = <1300>;
58+
exit-latency-us = <749>;
59+
};
60+
61+
/* Standby mode maps to Power Down mode with CPU retention . */
62+
standby: standby {
63+
compatible = "zephyr,power-state";
64+
power-state-name = "standby";
65+
min-residency-us = <2000>;
66+
exit-latency-us = <1345>;
67+
};
68+
};
69+
};
70+
71+
/* For the resource which will be off and lose content. */
72+
standby_off_domain: standby-off-domain {
73+
compatible = "power-domain-soc-state-change";
74+
#power-domain-cells = <0>;
75+
onoff-power-states = <&standby>;
4176
};
4277

4378
sysclk: system-clock {
@@ -175,6 +210,7 @@
175210
mode = <0>;
176211
input = <0>;
177212
prescale = <0>;
213+
zephyr,disabling-power-states = <&suspend &standby>;
178214
};
179215

180216
ctimer1: ctimer@9000 {
@@ -187,6 +223,7 @@
187223
mode = <0>;
188224
input = <0>;
189225
prescale = <0>;
226+
zephyr,disabling-power-states = <&suspend &standby>;
190227
};
191228

192229
ctimer2: ctimer@28000 {
@@ -199,6 +236,7 @@
199236
mode = <0>;
200237
input = <0>;
201238
prescale = <0>;
239+
zephyr,disabling-power-states = <&suspend &standby>;
202240
};
203241

204242
ctimer3: ctimer@29000 {
@@ -211,6 +249,7 @@
211249
mode = <0>;
212250
input = <0>;
213251
prescale = <0>;
252+
zephyr,disabling-power-states = <&suspend &standby>;
214253
};
215254

216255
ctimer4: ctimer@2a000 {
@@ -223,6 +262,7 @@
223262
mode = <0>;
224263
input = <0>;
225264
prescale = <0>;
265+
zephyr,disabling-power-states = <&suspend &standby>;
226266
};
227267

228268
sc_timer: pwm@85000 {
@@ -232,13 +272,15 @@
232272
status = "disabled";
233273
clocks = <&syscon MCUX_SCTIMER_CLK>;
234274
prescaler = <2>;
275+
zephyr,disabling-power-states = <&suspend &standby>;
235276
#pwm-cells = <3>;
236277
};
237278

238279
os_timer: timers@2d000 {
239280
compatible = "nxp,os-timer";
240281
reg = <0x2d000 0x1000>;
241282
interrupts = <38 1>;
283+
resets = <&reset NXP_SYSCON_RESET(1, 1)>;
242284
status = "disabled";
243285
};
244286

@@ -250,6 +292,7 @@
250292
resets = <&reset NXP_SYSCON_RESET(1, 11)>;
251293
dmas = <&dma0 4 &dma0 5>;
252294
dma-names = "rx", "tx";
295+
zephyr,disabling-power-states = <&suspend &standby>;
253296
status = "disabled";
254297
};
255298

@@ -261,6 +304,8 @@
261304
resets = <&reset NXP_SYSCON_RESET(1, 12)>;
262305
dmas = <&dma0 6 &dma0 7>;
263306
dma-names = "rx", "tx";
307+
zephyr,disabling-power-states = <&suspend &standby>;
308+
power-domains = <&standby_off_domain>;
264309
status = "disabled";
265310
};
266311

@@ -272,6 +317,8 @@
272317
resets = <&reset NXP_SYSCON_RESET(1, 13)>;
273318
dmas = <&dma0 8 &dma0 9>;
274319
dma-names = "rx", "tx";
320+
zephyr,disabling-power-states = <&suspend &standby>;
321+
power-domains = <&standby_off_domain>;
275322
status = "disabled";
276323
};
277324

@@ -287,6 +334,8 @@
287334
reg = <0x82000 0x1000>;
288335
interrupts = <1 1>;
289336
dma-channels = <23>;
337+
zephyr,disabling-power-states = <&suspend &standby>;
338+
power-domains = <&standby_off_domain>;
290339
status = "disabled";
291340
#dma-cells = <1>;
292341
};
@@ -296,6 +345,8 @@
296345
reg = <0xa7000 0x1000>;
297346
interrupts = <58 1>;
298347
dma-channels = <10>;
348+
zephyr,disabling-power-states = <&suspend &standby>;
349+
power-domains = <&standby_off_domain>;
299350
status = "disabled";
300351
#dma-cells = <1>;
301352
};
@@ -328,6 +379,7 @@
328379
resets = <&reset NXP_SYSCON_RESET(1, 0)>;
329380
#address-cells = <1>;
330381
#size-cells = <0>;
382+
zephyr,disabling-power-states = <&suspend &standby>;
331383

332384
mrt0_channel0: mrt0_channel@0 {
333385
compatible = "nxp,mrt-channel";

soc/nxp/mcx/mcxw/mcxw2xx/Kconfig.defconfig

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
if SOC_SERIES_MCXW2XX
66

7+
config MCUX_OS_TIMER
8+
default y if PM
9+
710
config CORTEX_M_SYSTICK
811
default n if MCUX_OS_TIMER
912

@@ -13,9 +16,14 @@ config NUM_IRQS
1316
DT_SYSCLK_PATH := $(dt_nodelabel_path,sysclk)
1417

1518
config SYS_CLOCK_HW_CYCLES_PER_SEC
16-
default 1000000 if MCUX_OS_TIMER
19+
default 32768 if MCUX_OS_TIMER && PM
20+
default 1000000 if MCUX_OS_TIMER && !PM
1721
default $(dt_node_int_prop_int,$(DT_SYSCLK_PATH),clock-frequency) if CORTEX_M_SYSTICK
1822

23+
config SYS_CLOCK_TICKS_PER_SEC
24+
default 512 if MCUX_OS_TIMER && PM
25+
default 1000 if MCUX_OS_TIMER && !PM
26+
1927
# Set to the minimal size of data which can be written.
2028
config FLASH_FILL_BUFFER_SIZE
2129
default 512
@@ -36,4 +44,35 @@ config MAIN_STACK_SIZE
3644

3745
endif # BT
3846

47+
if PM
48+
49+
# Enable PM_DEVICE for Suspend mode and Standby mode,
50+
# because some devices can't work in these modes.
51+
config PM_DEVICE
52+
default y if "$(dt_nodelabel_enabled,standby)" || "$(dt_nodelabel_enabled,suspend)"
53+
54+
config PM_POLICY_DEVICE_CONSTRAINTS
55+
default y if PM_DEVICE
56+
57+
config IDLE_STACK_SIZE
58+
default 640
59+
60+
config TICKLESS_KERNEL
61+
default y if PM
62+
63+
if BT
64+
choice PM_POLICY
65+
default PM_POLICY_CUSTOM
66+
endchoice
67+
endif # BT
68+
69+
endif # PM
70+
71+
if PM_DEVICE
72+
73+
config POWER_DOMAIN
74+
default y
75+
76+
endif # PM_DEVICE
77+
3978
endif # SOC_SERIES_MCXW2XX

0 commit comments

Comments
 (0)