#include <asm/arch/immap_lsch2.h>
#endif
#include <fsl_wdog.h>
+#include <div64.h>
+
+#define TIMEOUT_MAX 128000
+#define TIMEOUT_MIN 500
static void imx_watchdog_expire_now(struct watchdog_regs *wdog, bool ext_reset)
{
#endif /* CONFIG_WATCHDOG_RESET_DISABLE*/
}
-static void imx_watchdog_init(struct watchdog_regs *wdog, bool ext_reset)
+static void imx_watchdog_init(struct watchdog_regs *wdog, bool ext_reset,
+ u64 timeout)
{
- u16 timeout;
u16 wcr;
/*
#ifndef CONFIG_WATCHDOG_TIMEOUT_MSECS
#define CONFIG_WATCHDOG_TIMEOUT_MSECS 128000
#endif
- timeout = (CONFIG_WATCHDOG_TIMEOUT_MSECS / 500) - 1;
+
+ timeout = max_t(u64, timeout, TIMEOUT_MIN);
+ timeout = min_t(u64, timeout, TIMEOUT_MAX);
+ timeout = lldiv(timeout, 500) - 1;
+
#ifdef CONFIG_FSL_LSCH2
wcr = (WCR_WDA | WCR_SRS | WCR_WDE) << 8 | timeout;
#else
{
struct watchdog_regs *wdog = (struct watchdog_regs *)WDOG1_BASE_ADDR;
- imx_watchdog_init(wdog, true);
+ imx_watchdog_init(wdog, true, CONFIG_WATCHDOG_TIMEOUT_MSECS);
}
#else
struct imx_wdt_priv {
{
struct imx_wdt_priv *priv = dev_get_priv(dev);
- imx_watchdog_init(priv->base, priv->ext_reset);
+ imx_watchdog_init(priv->base, priv->ext_reset, timeout);
return 0;
}