lwmon5: enable hardware watchdog
Some boards (e.g. lwmon5) may use rather small watchdog intervals, so
causing it to reboot the board if U-Boot does a long busy-wait with
udelay(). Thus, for these boards we have to restart WD more
frequently.
This patch splits the busy-wait udelay() into smaller, predefined,
intervals, so that the watchdog timer may be resetted with the
configurable (CONFIG_WD_PERIOD) interval.
Signed-off-by: Yuri Tikhonov <yur@emcraft.com>
diff --git a/include/configs/lwmon5.h b/include/configs/lwmon5.h
index d8a2267..97e8bf1 100644
--- a/include/configs/lwmon5.h
+++ b/include/configs/lwmon5.h
@@ -366,12 +366,11 @@
#define CFG_PCI_SUBSYS_VENDORID 0x10e8 /* AMCC */
#define CFG_PCI_SUBSYS_ID 0xcafe /* Whatever */
-#if 0
/*
* ToDo: Watchdog is not test fully, so exclude it for now
*/
#define CONFIG_HW_WATCHDOG 1 /* Use external HW-Watchdog */
-#endif
+#define CONFIG_WD_PERIOD 40000 /* in usec */
/*
* For booting Linux, the board info and command line data
diff --git a/lib_ppc/time.c b/lib_ppc/time.c
index 51e8e840..2649d5f 100644
--- a/lib_ppc/time.c
+++ b/lib_ppc/time.c
@@ -23,6 +23,9 @@
#include <common.h>
+#ifndef CONFIG_WD_PERIOD
+# define CONFIG_WD_PERIOD (10 * 1000 * 1000) /* 10 seconds default*/
+#endif
/* ------------------------------------------------------------------------- */
@@ -53,9 +56,14 @@
*/
void udelay(unsigned long usec)
{
- ulong ticks = usec2ticks (usec);
+ ulong ticks, kv;
- wait_ticks (ticks);
+ do {
+ kv = usec > CONFIG_WD_PERIOD ? CONFIG_WD_PERIOD : usec;
+ ticks = usec2ticks (kv);
+ wait_ticks (ticks);
+ usec -= kv;
+ } while(usec);
}
/* ------------------------------------------------------------------------- */