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

drivers: watchdog: NXP: Fix WDG option handling #72753

Conversation

davidschneider-cpi
Copy link
Contributor

If enableStop is true the watchdog is halted in chip stop mode.
If enableDebug is true the watchdog is halted in chip debug mode.

@@ -42,10 +42,10 @@ static int mcux_wdog_setup(const struct device *dev, uint8_t options)
}

data->wdog_config.workMode.enableStop =
(options & WDT_OPT_PAUSE_IN_SLEEP) == 0U;
(options & WDT_OPT_PAUSE_IN_SLEEP) == WDT_OPT_PAUSE_IN_SLEEP;
Copy link
Collaborator

Choose a reason for hiding this comment

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

The WDT_OPT_PAUSE_IN_SLEEP bit is documented as follows:

Pause watchdog timer when CPU is in sleep state

Therefore, if the bit is cleared, then the watchdog should run in sleep mode, correct?

For the iMX WDOG, Setting enableStop results in the WDZST bit being cleared, so the timer will run in low power modes.

From my understanding of the documentation and the iMX WDOG IP, the current behavior would be correct- is there something I'm missing here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I run into the issue on a IMXRT1064 where the watchdog was running during debug halt although WDT_OPT_PAUSE_HALTED_BY_DBG was set. Inverting the logic fixed the issue.

Digging deeper into the RM I found that the logic is different for WDOG and RTWDOG:
WDOG_WCR_WDBG: 1b - Suspend the watchdog timer.
RTWDOG_CS_DBG: 1b - Watchdog enabled in chip debug mode.
(from IMXRT1064 reference manual)

This is already fixed in the HAL update to SDK 2.15.000
https://github.com/zephyrproject-rtos/hal_nxp/blame/7da0fc961f861b011b7f68a5085d29ee2b401957/mcux/mcux-sdk/drivers/wdog01/fsl_wdog.c#L111-L112

@decsny
Copy link
Member

decsny commented May 14, 2024

please change commit title to begin with drivers: wdt_mcux_imx: , as there are multiple nxp watchdogs in the tree

If `enableStop` is true the watchdog is halted in chip stop mode.
If `enableDebug` is true the watchdog is halted in chip debug mode.

Signed-off-by: David Schneider <[email protected]>
@davidschneider-cpi
Copy link
Contributor Author

davidschneider-cpi commented May 15, 2024

The logic in the Zephyr driver is correct and the the issue I faced get resolved with the latest HAL update.
See also https://github.com/zephyrproject-rtos/hal_nxp/blame/7da0fc961f861b011b7f68a5085d29ee2b401957/mcux/mcux-sdk/drivers/wdog01/fsl_wdog.c#L112

@davidschneider-cpi davidschneider-cpi deleted the mcux-wdog-debug branch May 15, 2024 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Watchdog Watchdog platform: NXP Drivers NXP Semiconductors, drivers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants