]> git.sur5r.net Git - u-boot/blobdiff - lib_m68k/time.c
Merge branch 'i2c'
[u-boot] / lib_m68k / time.c
index fb997b5b49c06e66c79e1de6befedd87986fce30..d45e470aeb97554bdc48ee9e53c96a58f3695ef1 100644 (file)
 
 #include <asm/mcftimer.h>
 
+#ifdef CONFIG_M5271
+#include <asm/m5271.h>
+#include <asm/immap_5271.h>
+#endif
+
 #ifdef CONFIG_M5272
 #include <asm/m5272.h>
 #include <asm/immap_5272.h>
@@ -43,7 +48,7 @@
 
 
 static ulong timestamp;
-#ifdef CONFIG_M5282
+#if defined(CONFIG_M5282) || defined(CONFIG_M5271)
 static unsigned short lastinc;
 #endif
 
@@ -127,10 +132,32 @@ void set_timer (ulong t)
 }
 #endif
 
-#if defined(CONFIG_M5282)
+#if defined(CONFIG_M5282) || defined(CONFIG_M5271)
 
 void udelay(unsigned long usec)
 {
+       volatile unsigned short *timerp;
+       uint tmp;
+
+       timerp = (volatile unsigned short *) (CFG_MBAR + MCFTIMER_BASE3);
+
+       while (usec > 0) {
+               if (usec > 65000)
+                       tmp = 65000;
+               else
+                       tmp = usec;
+               usec = usec - tmp;
+
+               /* Set up TIMER 3 as timebase clock */
+               timerp[MCFTIMER_PCSR] = MCFTIMER_PCSR_OVW;
+               timerp[MCFTIMER_PMR] = 0;
+               /* set period to 1 us */
+               timerp[MCFTIMER_PCSR] =
+                       (5 << 8) | MCFTIMER_PCSR_EN | MCFTIMER_PCSR_OVW;
+
+               timerp[MCFTIMER_PMR] = tmp;
+               while (timerp[MCFTIMER_PCNTR] > 0);
+       }
 }
 
 void timer_init (void)