]> git.sur5r.net Git - u-boot/blobdiff - lib_m68k/time.c
TWL4030 Add usb PHY support
[u-boot] / lib_m68k / time.c
index 697d67edc6966bbb86bf15f94b59c9fbb1306f9e..7eaea5e7f77deddffede0a00cd5cdc03c4c45e5b 100644 (file)
 
 #include <asm/timer.h>
 #include <asm/immap.h>
+#include <watchdog.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static ulong timestamp;
+static volatile ulong timestamp = 0;
+
+#ifndef CONFIG_SYS_WATCHDOG_FREQ
+#define CONFIG_SYS_WATCHDOG_FREQ (CONFIG_SYS_HZ / 2)
+#endif
 
 #if defined(CONFIG_MCFTMR)
 #ifndef CONFIG_SYS_UDELAY_BASE
@@ -42,7 +47,7 @@ static ulong timestamp;
 #endif
 extern void dtimer_intr_setup(void);
 
-void udelay(unsigned long usec)
+void __udelay(unsigned long usec)
 {
        volatile dtmr_t *timerp = (dtmr_t *) (CONFIG_SYS_UDELAY_BASE);
        uint start, now, tmp;
@@ -76,6 +81,12 @@ void dtimer_interrupt(void *not_used)
        if ((CONFIG_SYS_TMRPND_REG & CONFIG_SYS_TMRINTR_MASK) == CONFIG_SYS_TMRINTR_PEND) {
                timerp->ter = (DTIM_DTER_CAP | DTIM_DTER_REF);
                timestamp++;
+
+               #if defined(CONFIG_WATCHDOG) || defined (CONFIG_HW_WATCHDOG)
+               if ((timestamp % (CONFIG_SYS_WATCHDOG_FREQ)) == 0) {
+                       WATCHDOG_RESET ();
+               }
+               #endif    /* CONFIG_WATCHDOG || CONFIG_HW_WATCHDOG */
                return;
        }
 }
@@ -128,7 +139,7 @@ void set_timer(ulong t)
 
 static unsigned short lastinc;
 
-void udelay(unsigned long usec)
+void __udelay(unsigned long usec)
 {
        volatile pit_t *timerp = (pit_t *) (CONFIG_SYS_UDELAY_BASE);
        uint tmp;