drivers: wdt_mcux_wwdt: Fix warning callback
Warning callback by default is configured to happen at the same time as reset, which results in unexpected behavior from the point of view of Zephyr API. Return -ENOTSUP from install_timeout if trying to set up callback with 0 warning time, and add kconfig to configure the warning time. Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
This commit is contained in:
parent
f8398fda02
commit
dbbdd3c6cf
2 changed files with 21 additions and 2 deletions
|
@ -25,3 +25,15 @@ config WDT_MCUX_WWDT
|
|||
depends on DT_HAS_NXP_LPC_WWDT_ENABLED
|
||||
help
|
||||
Enable the mcux wwdt driver.
|
||||
|
||||
if WDT_MCUX_WWDT
|
||||
|
||||
config WDT_MCUX_WWDT_WARNING_INTERRUPT_CFG
|
||||
int "WWDT timeout warning interrupt configuration"
|
||||
range 0 1023
|
||||
default 0
|
||||
help
|
||||
WWDT timeout warning interrupt time. The units are
|
||||
the number of watchdog counter ticks before timeout.
|
||||
|
||||
endif # WDT_MCUX_WWDT
|
||||
|
|
|
@ -69,7 +69,7 @@ static int mcux_wwdt_disable(const struct device *dev)
|
|||
* This prescaler is different from the clock divider specified in Device Tree.
|
||||
*/
|
||||
#define MSEC_TO_WWDT_TICKS(clock_freq, msec) \
|
||||
((uint32_t)(clock_freq * msec / MSEC_PER_SEC / 4))
|
||||
((uint32_t)((clock_freq / MSEC_PER_SEC) * msec) / 4)
|
||||
|
||||
static int mcux_wwdt_install_timeout(const struct device *dev,
|
||||
const struct wdt_timeout_cfg *cfg)
|
||||
|
@ -115,7 +115,14 @@ static int mcux_wwdt_install_timeout(const struct device *dev,
|
|||
LOG_DBG("Enabling SoC reset");
|
||||
}
|
||||
|
||||
data->callback = cfg->callback;
|
||||
if (cfg->callback && (CONFIG_WDT_MCUX_WWDT_WARNING_INTERRUPT_CFG > 0)) {
|
||||
data->callback = cfg->callback;
|
||||
data->wwdt_config.warningValue = CONFIG_WDT_MCUX_WWDT_WARNING_INTERRUPT_CFG;
|
||||
} else if (cfg->callback) {
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
|
||||
data->timeout_valid = true;
|
||||
LOG_DBG("Installed timeout (timeoutValue = %d)",
|
||||
data->wwdt_config.timeoutValue);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue