Skip to content

Enable nxp mcus general power off demo #93248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

ZhaoxiangJin
Copy link
Contributor

  1. Enabled generic poweroff example for NXP MCUs. The example can test pass on frdm_mcxa153, frdm_mcxa156, frdm_mcxa166, frdm_mcxa276, frdm_mcxn236, frdm_mcxn947 and mimxrt595_evk.
  2. Migrate the existing mimxrt595_evk/system_off example to the new poweroff example.

@dleach02
Copy link
Member

@ZhaoxiangJin please address the CI issues

@ZhaoxiangJin ZhaoxiangJin force-pushed the enable-nxp-mcus-general-power-off-demo branch 2 times, most recently from 0ef42bc to 8266f47 Compare July 22, 2025 14:24
Comment on lines 6 to 20
config COUNTER_WAKEUP_ENABLE
bool
select COUNTER
default y if BOARD_FRDM_MCXA153 || BOARD_FRDM_MCXA156 || \
BOARD_FRDM_MCXA166 || BOARD_FRDM_MCXA276 || \
BOARD_FRDM_MCXN947 || BOARD_MIMXRT595_EVK
help
Use counter to wake up device from poweroff.

config GPIO_WAKEUP_ENABLE
bool
select GPIO
default y if BOARD_FRDM_MCXN236
help
Use gpio to wake up device from poweroff.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these kconfigs need to be namedspaced for the sample. also, I recommend using zephyr,user node in DT to drive this instead of kconfig anyways. ie, put a property for counter and a property for gpio and determine from that in the code based on which property exists in zephyr,user node.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the advantage of using DT to drive this? The advantage of using Kconfig is that users can select the wakeup source (wakeup button or counter) as needed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine I guess but you still need to namespace the configs, and I wouldn't call them _ENABLE, and make this a choice config instead (unless you intend both to be possible at once)

Comment on lines 13 to 14
#define WAKEUP_DELAY 0x5B
#define WAKEUP_COUNTER_INDEX 6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at least they have names but they are still kind of magically chosen numbers it looks like

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wakeup delay is the minimum value should be configured when a different VDD_CORE level is configured in low power modes (LP_CFG register) compared to active modes (ACTIVE_CFG register). From RM, it should be 0x5B.

Wakeup counter index is used for wakeup unit (WUU) addressing, wuu manages many wakeup sources, lptmr index is 6.

what about create a Kconfig.poweroff and add Kconfig options for them?

@ZhaoxiangJin ZhaoxiangJin force-pushed the enable-nxp-mcus-general-power-off-demo branch from 8266f47 to 3b7d942 Compare August 6, 2025 03:21
@ZhaoxiangJin ZhaoxiangJin requested a review from decsny August 6, 2025 03:21
@ZhaoxiangJin ZhaoxiangJin force-pushed the enable-nxp-mcus-general-power-off-demo branch 2 times, most recently from d16fd19 to 76fb580 Compare August 6, 2025 09:14
@ZhaoxiangJin
Copy link
Contributor Author

CI blocked by #94169

@ZhaoxiangJin
Copy link
Contributor Author

Ping @decsny for review

Copy link
Member

@decsny decsny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blocked over kconfig namespaces and Kconfig.soc

Comment on lines 93 to 100

config SOC_WAKEUP_DELAY
int "Wakeup delay"
default 91
help
When a different VDD_CORE level is configured in low
power modes compared to active modes, the wakeup delay
must be configured to a minimum value.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this config should not be added in a Kconfig.soc file, Kconfig.soc is only for HWM hierarchy description, put in Kconfig file and namespace for the platform

Comment on lines 69 to 75
config SOC_WAKEUP_DELAY
int "Wakeup delay"
default 780
help
When a different VDD_CORE level is configured in low
power modes compared to active modes, the wakeup delay
must be configured to a minimum value.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the power.c code looks almost the same between mcxa and mcxn, not required but would it be a good idea or not to share code somewhere in a file somewhere like mcx/common ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the code looks very similar, as MCXA and MCXN using the same power architecture. I plan to enable power management for MCXA and MCXN later, and there are still some hardware differences between MCXA and MCXN. So it's probably better to keep them relatively independent for now.

@ZhaoxiangJin ZhaoxiangJin force-pushed the enable-nxp-mcus-general-power-off-demo branch from 76fb580 to 782a375 Compare August 12, 2025 12:17
@ZhaoxiangJin
Copy link
Contributor Author

ZhaoxiangJin commented Aug 12, 2025

Update:

  1. Renamed kconfig option from 'SOC_WAKEUP_DELAY' to 'SOC_MCXN_WAKEUP_DELAY' and moved it from Kconfig.soc to Kconfig
  2. Changed the wakeup source Kconfig option in the poweroff demo Kconfig to choice config, because the poweroff example currently only supports a single wakeup source. In the future, if there is demand, the example can be further expanded to support two wakeup sources at the same time.

@ZhaoxiangJin ZhaoxiangJin requested a review from decsny August 12, 2025 12:28
@ZhaoxiangJin ZhaoxiangJin force-pushed the enable-nxp-mcus-general-power-off-demo branch from 782a375 to a7b0195 Compare August 15, 2025 01:09
@ZhaoxiangJin
Copy link
Contributor Author

Update:
rebased to fix ci issue

decsny
decsny previously approved these changes Aug 16, 2025
@ZhaoxiangJin
Copy link
Contributor Author

Hello @dleach02, @mmahadevan108, please help to review this PR, thanks.

Pulling MCUX SDK cmc, vbat, wuu driver to Zephyr build tree.

Signed-off-by: Zhaoxiang Jin <[email protected]>
This commit enables MCXN236, MCXN947 LPUART pin internal
pullup resistor. For MCXN947 and MCXN236, during LPUAR
initialization, the RX pin is pulled down internally
and STAT[RAF] is set to one. In this state, attempting
to enter low power mode will trigger LPACK reset and
therefore cannot truly enter low power mode. The correct
setting should be to enable LPUART pin internal pullup
resistor.

Signed-off-by: Zhaoxiang Jin <[email protected]>
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 <[email protected]>
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 <[email protected]>
This commit introduced the following changes:
1. MIMXRT595 poweroff corresponds to its full
deep power down mode not deep power down mode.
2. Enable OSC32K before poweroff, the OSC32K
is the clock source of the wakeup source RTC.
3. Enable RTC wake-up function.

Signed-off-by: Zhaoxiang Jin <[email protected]>
Enabled FRO16k for LPTMR when LPTMR clock source
is set to 0x1.

Signed-off-by: Zhaoxiang Jin <[email protected]>
Enabled FRO16k for LPTMR when LPTMR clock source
is set to 0x1.

Signed-off-by: Zhaoxiang Jin <[email protected]>
Introduce Kconfig.peripherals for NXP devices.
In this file, we defined kconfig options like
MCUX_HW_HAS_xxx, these kconfig option is set to
true or false depending on whether the peripheral
instance node in DT is enabled or not.

why we need MCUX_HW_HAS_xxx?

For example, the konfig option
'COUNTER_MCUX_LPTMR_WAKEUP_SOURCE_INDEX' only sets
its value when LPTMR is used as a wakeup source.
Therefore, we need to use the predefined kconfig
function 'dt_nodelabel_bool_prop' in kconfig to
determine whether LPTMR enabled the wakeup-source property.
To do this, we need to iterate over all LPTMR nodes
in the DT, such as lptmr0, lptmr1, and so on, to
see if they enabled the wakeup-source property.

How can we iterate over all LPTMR nodes?
We need to pass in the currently iterated LPTMR instance.

How do we know which instance we are currently iterating
over?

We need to determine whether MCUX_HW_HAS_LPTMRn
is true and then define the current mcux_hw_lptmr_index
to n. This will determine the instance.

This is why we need MCUX_HW_HAS_xxx and Kconfig.peripherals

Signed-off-by: Zhaoxiang Jin <[email protected]>
1. Enable lptmr wakeup feature
2. Enable lptmr get_freq function

Signed-off-by: Zhaoxiang Jin <[email protected]>
Enable gpio_mcux wakeup feature

Signed-off-by: Zhaoxiang Jin <[email protected]>
This commit introduced the following changes:
1. Enabled generic poweroff example for NXP MCUs. The
example is test on frdm_mcxa153, frdm_mcxa156, frdm_mcxa166,
frdm_mcxa276, frdm_mcxn236, frdm_mcxn947 and mimxrt595_evk.
3. Migrate the existing mimxrt595_evk/system_off example
to the new poweroff example.
4. The Poweroff example now supports counter wake-up and
button/GPIO wake-up, suitable for most NXP devices/boards.
For testing purposes, frdm_mcxn236 is wakeup using the
wake-up button; frdm_mcxa153, frdm_mcxa156, frdm_mcxa166,
frdm_mcxa276, and frdm_mcxn947 are wakeup using lptmr;
mimxrt595_evk is wakeup using high-resolution RTC.

Signed-off-by: Zhaoxiang Jin <[email protected]>
1. Update redirects.py to find the correct mimxrt595_evk
system_off example README.
2. Update release-notes to record the new nxp poweroff
example.

Signed-off-by: Zhaoxiang Jin <[email protected]>
@ZhaoxiangJin ZhaoxiangJin force-pushed the enable-nxp-mcus-general-power-off-demo branch from a7b0195 to 758f0a9 Compare August 19, 2025 14:20
@ZhaoxiangJin ZhaoxiangJin requested a review from decsny August 19, 2025 14:20
@ZhaoxiangJin
Copy link
Contributor Author

Update:
Fixed conflicts

Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants