#define WATCHDOG_TIMEOUT_SECS (CONFIG_WATCHDOG_TIMEOUT_MSECS / 1000)
+/*
+ * Reset every 1000ms, or however often is required as indicated by a
+ * hw_margin_ms property.
+ */
+static ulong reset_period = 1000;
+
int initr_watchdog(void)
{
u32 timeout = WATCHDOG_TIMEOUT_SECS;
if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) {
timeout = dev_read_u32_default(gd->watchdog_dev, "timeout-sec",
WATCHDOG_TIMEOUT_SECS);
+ reset_period = dev_read_u32_default(gd->watchdog_dev,
+ "hw_margin_ms",
+ 4 * reset_period) / 4;
}
wdt_start(gd->watchdog_dev, timeout * 1000, 0);
/* Do not reset the watchdog too often */
now = get_timer(0);
if (time_after(now, next_reset)) {
- next_reset = now + 1000; /* reset every 1000ms */
+ next_reset = now + reset_period;
wdt_reset(gd->watchdog_dev);
}
}