-
Notifications
You must be signed in to change notification settings - Fork 7.3k
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
Added EWM Driver #88389
Conversation
caaa6da
to
ec8cb41
Compare
There was a problem hiding this 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
#define WDT_MAX_WINDOW 0xFE | ||
#define WDT_TIMEOUT K_TICKS(0x100) | ||
#define SLEEP_TIME K_TICKS(0x45) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
bd996d5
to
a09c68a
Compare
drivers/watchdog/wdt_nxp_ewm.c
Outdated
#define LOG_LEVEL CONFIG_WDT_LOG_LEVEL | ||
#include <zephyr/logging/log.h> | ||
LOG_MODULE_REGISTER(wdt_nxp_ewm); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
drivers/watchdog/wdt_nxp_ewm.c
Outdated
base->CTRL &= (~EWM_CTRL_INTEN_MASK); | ||
if (data->timeout_cfg.callback) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
a09c68a
to
eaa9ebe
Compare
drivers/watchdog/wdt_nxp_ewm.c
Outdated
struct nxp_ewm_data *data = dev->data; | ||
|
||
if (!data->is_watchdog_setup) { | ||
-ENOMEM; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
drivers/watchdog/wdt_nxp_ewm.c
Outdated
|
||
if (cfg && cfg->window.max <= NXP_EWM_MAX_TIMEOUT_WINDOW && | ||
cfg->window.min <= cfg->window.max && | ||
cfg->window.max > 0 && |
There was a problem hiding this comment.
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 '&&'
There was a problem hiding this comment.
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.
drivers/watchdog/wdt_nxp_ewm.c
Outdated
} | ||
#else | ||
|
||
if (cfg->flags) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
drivers/watchdog/wdt_nxp_ewm.c
Outdated
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)); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
05d8f98
to
2d11a04
Compare
drivers/watchdog/wdt_nxp_ewm.c
Outdated
EWM_Type *base = config->base; | ||
base->CTRL &= (~EWM_CTRL_INTEN_MASK); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
drivers/watchdog/wdt_nxp_ewm.c
Outdated
return -ENOTSUP; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extra newline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
6926b10
to
7b064a2
Compare
@DerekSnell do you still have a pending change request? |
There was a problem hiding this 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
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]>
7b064a2
to
1a10121
Compare
Adding the EWM Driver, tested with wdt_basic_none_reset test using the included overlay.