Skip to content
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

rw6xx: Add Support for Standby Power Mode #84945

Merged
merged 14 commits into from
Mar 21, 2025

Conversation

mmahadevan108
Copy link
Collaborator

This maps to Power Mode 3 in the SoC Power Profile

This PR is dependent on #74371 and #84938

@mmahadevan108
Copy link
Collaborator Author

Push a commit from #74371 to fix CI failures.

usart_intenset = USART_GetEnabledInterrupts(config->base);
return 0;
case PM_DEVICE_ACTION_TURN_ON:
mcux_flexcomm_init(dev);
Copy link
Collaborator

Choose a reason for hiding this comment

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

pm_device_driver_init() must be added to the end of mcux_flexcomm_init(), and will call TURN_ON, potentially followed by resume. Once pm_device_driver_init() is added, calling init here will result in infinite recursion.

the mcux_flexcomm_init() should only be called once, on init, and later reinits are a result of calls to mcux_flexcomm_pm_action()

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@bjarki-andreasen, thank you. I have made the change to call pm_device_driver_init()

Copy link
Collaborator

@bjarki-andreasen bjarki-andreasen left a comment

Choose a reason for hiding this comment

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

pm_device_driver_init() must be added to the gpio_mcux_lpc and uart_mcux_flexcomm init functions to properly initialize the devices. This has further implications which will be clear once pm_device_driver_init() is added.

Add PM action for MCUX LPC driver

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
Add power action callback handlers to the driver.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
This maps to Power Mode 3 in the SoC.
Add RTC node that is used to wakeup from this mode.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
This is required to re-initialize the peripherals on
exit from Power Mode 3.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
This clock is used for certain peripherals such
as RTC.
On certain RW612 boards such as rd_rw612_bga, XTAL32K
and ENET share pins. Add code to check if ENET and
XTAL32 are enabled at the same time.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
Since the clock source when running in PM mode 3 is the
slower 1KHx clock, we adjust the SYS_CLOCK_TICKS_PER_SEC
value to get better accuracy.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
This maps to Zephyr power state Standby. In this power
state the OS Timer cannot be used as a wakeup source as
it will be powered off. Hence the counter is enabled
and RTC is used to keep track of system ticks and wakeup
the system.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
Update the clock init code to gate off unused clocks.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
Power Domains are used to re-enable peripherals
when exit Power Mode 3 (Standby).

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
Provide an API for other drivers to fire GPIO callbacks

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
Call the API provided to fire a GPIO interrupt
if registered on wakeup from PM Mode 3.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
This is used as wakeup source to wakeup from Power Modes
3 and 4.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
Enable PM mode 3 on NXP FRDM_RW612 and RD_RW612 boards.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
Enable testing this sample with PM Mode 3

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
@mmahadevan108
Copy link
Collaborator Author

@bjarki-andreasen , can you please revisit this PR?

Copy link
Collaborator

@bjarki-andreasen bjarki-andreasen left a comment

Choose a reason for hiding this comment

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

Looks fine, added a note regarding some code which could be a bit simpler, but it will not have any impact once compiled :)

Comment on lines +413 to +418
case PM_DEVICE_ACTION_RESUME:
break;
case PM_DEVICE_ACTION_SUSPEND:
break;
case PM_DEVICE_ACTION_TURN_OFF:
break;
Copy link
Collaborator

Choose a reason for hiding this comment

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

None of these are supported, so should also return -ENOTSUP, can be simplified to

if (action == PM_DEVICE_ACTION_TURN_ON) {
        const struct gpio_mcux_lpc_config *config = dev->config;

	GPIO_PortInit(config->gpio_base, config->port_no);
	return 0;
}

return -ENOTSUP;

@@ -1067,6 +1117,42 @@ static int mcux_flexcomm_init(const struct device *dev)
return 0;
}

static uint32_t usart_intenset;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This variable is not used outside the scope of mcux_flexcomm_pm_action, move it inside, also does not need to be static

@kartben kartben merged commit 380494a into zephyrproject-rtos:main Mar 21, 2025
24 checks passed
@mmahadevan108 mmahadevan108 deleted the Add_PM_Mode3 branch March 24, 2025 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants