Skip to content

Added EWM Driver #88389

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

Merged

Conversation

EmilioCBen
Copy link
Collaborator

Adding the EWM Driver, tested with wdt_basic_none_reset test using the included overlay.

@github-actions github-actions bot added the platform: NXP Drivers NXP Semiconductors, drivers label Apr 9, 2025
@EmilioCBen EmilioCBen force-pushed the feature/mcxw7x_ewm_support branch 2 times, most recently from caaa6da to ec8cb41 Compare April 10, 2025 14:29
Copy link
Collaborator

@DerekSnell DerekSnell left a comment

Choose a reason for hiding this comment

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

Thanks @EmilioCBen ,

Overall, this LGTM. But I am blocking for the hard-coded clock name in driver

Comment on lines 27 to 29
#define WDT_MAX_WINDOW 0xFE
#define WDT_TIMEOUT K_TICKS(0x100)
#define SLEEP_TIME K_TICKS(0x45)
Copy link
Collaborator

Choose a reason for hiding this comment

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

should these be a Kconfig for this test app so other platforms can change these?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

At first I had these as Kconfigs but I went back on it after realizing the big difference is the function being used e.g. K_TICKS vs K_MSEC, but I went ahead and changed the values passed in to Kconfigs as requested, let me know if this is what was expected or if you had another change in mind here.

@EmilioCBen EmilioCBen force-pushed the feature/mcxw7x_ewm_support branch 2 times, most recently from bd996d5 to a09c68a Compare April 14, 2025 14:53
Comment on lines 14 to 13
#define LOG_LEVEL CONFIG_WDT_LOG_LEVEL
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(wdt_nxp_ewm);
Copy link
Member

Choose a reason for hiding this comment

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

log level can be an argument to the register macro, no need for LOG_LEVEL macro

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated

Copy link
Member

Choose a reason for hiding this comment

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

@EmilioCBen you removed the LOG_MODULE_REGISTER instead of the LOG_LEVEL, now there will be no logging

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks, I have adjusted the change

Comment on lines 136 to 134
base->CTRL &= (~EWM_CTRL_INTEN_MASK);
if (data->timeout_cfg.callback) {
Copy link
Member

Choose a reason for hiding this comment

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

nit please separate with newline

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated

Copy link
Member

Choose a reason for hiding this comment

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

well now you just put it without a newline next to the above code, which should be triggering check compliance, I feel like check compliance has been really lenient lately, I wonder if someone changed it

EWM_Type *base = config->base;
unsigned int key = irq_lock();

base->SERV = EWM_SERV_SERVICE(NXP_EWM_FEED_MAGIC_NUMBER);
Copy link
Member

Choose a reason for hiding this comment

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

is this macro going to convert the 16 bit integer literal to 8 bit ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It should but extra precaution I added a cast to 8 bit


#if defined(CONFIG_WDT_NXP_EWM)
#define WDT_SETUP_FLAGS 0
#define WDT_TIMEOUT K_TICKS(WDT_TIMEOUT_VALUE)
Copy link
Collaborator

@mmahadevan108 mmahadevan108 Apr 14, 2025

Choose a reason for hiding this comment

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

Why does the NXP_EWM get the value in ticks?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The watchdog window to feed the watchdog is in the Microsecond range. The Tick value is the most accurate speed to test this EWM without having to worry about the test unintentionally missing a watchdog feed.

@EmilioCBen EmilioCBen force-pushed the feature/mcxw7x_ewm_support branch from a09c68a to eaa9ebe Compare April 20, 2025 15:41
struct nxp_ewm_data *data = dev->data;

if (!data->is_watchdog_setup) {
-ENOMEM;
Copy link
Member

Choose a reason for hiding this comment

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

I'll note that this is just a free standing ENOMEM?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch, I added the return


if (cfg && cfg->window.max <= NXP_EWM_MAX_TIMEOUT_WINDOW &&
cfg->window.min <= cfg->window.max &&
cfg->window.max > 0 &&
Copy link
Member

Choose a reason for hiding this comment

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

nit, but I don't think you should use tabs to align the '&&'

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have removed the tabs.

}
#else

if (cfg->flags) {
Copy link
Member

Choose a reason for hiding this comment

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

Should this test be at the beginning of this routine? Seems odd to do configuration of the timeoue_cfg.window above but then here decide to return an error.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure since it is a passed in argument I will give this check the priority and put it on the top of the routine.

unsigned int key = irq_lock();

base->SERV = EWM_SERV_SERVICE(NXP_EWM_FEED_MAGIC_NUMBER);
base->SERV = EWM_SERV_SERVICE((int8_t)(NXP_EWM_FEED_MAGIC_NUMBER >> 8));
Copy link
Member

Choose a reason for hiding this comment

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

If you are going to cast then you should cast in the target value. SERV is a uint8_t.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated.

@EmilioCBen EmilioCBen force-pushed the feature/mcxw7x_ewm_support branch 2 times, most recently from 05d8f98 to 2d11a04 Compare April 21, 2025 19:26
EWM_Type *base = config->base;
base->CTRL &= (~EWM_CTRL_INTEN_MASK);
Copy link
Member

Choose a reason for hiding this comment

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

im surprised if the check compliance doesnt complain, declarations should be separated from following code by newline

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated

return -ENOTSUP;
}


Copy link
Member

Choose a reason for hiding this comment

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

nit: extra newline

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated

@EmilioCBen EmilioCBen force-pushed the feature/mcxw7x_ewm_support branch 5 times, most recently from 6926b10 to 7b064a2 Compare April 29, 2025 22:55
@dleach02
Copy link
Member

dleach02 commented May 1, 2025

@DerekSnell do you still have a pending change request?

DerekSnell
DerekSnell previously approved these changes May 2, 2025
Copy link
Collaborator

@DerekSnell DerekSnell left a comment

Choose a reason for hiding this comment

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

Thanks for updating @EmilioCBen

dleach02
dleach02 previously approved these changes May 5, 2025
EmilioCBen added 3 commits May 5, 2025 09:15
Added a driver for the External Watchdog Driver

Signed-off-by: Emilio Benavente <[email protected]>
Added EWM Support for MCXW71 and MCXW72

Signed-off-by: Emilio Benavente <[email protected]>
Enabled the wdt_basic_reset_none to test boards using the EWM.

Signed-off-by: Emilio Benavente <[email protected]>
@EmilioCBen EmilioCBen dismissed stale reviews from dleach02 and DerekSnell via 1a10121 May 5, 2025 14:16
@EmilioCBen EmilioCBen force-pushed the feature/mcxw7x_ewm_support branch from 7b064a2 to 1a10121 Compare May 5, 2025 14:16
@kartben kartben merged commit 417b902 into zephyrproject-rtos:main May 8, 2025
24 checks passed
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 platform: NXP NXP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants