Patchwork [U-Boot] bug fix for the delay function of ARM s3c44b0

login
register
mail settings
Submitter Chaofu Chen
Date Nov. 13, 2008, 1:11 p.m.
Message ID <88421.34726.qm@web45012.mail.sp1.yahoo.com>
Download mbox | patch
Permalink /patch/71647/
State Not Applicable
Delegated to: Minkyu Kang
Headers show

Comments

Chaofu Chen - Nov. 13, 2008, 1:11 p.m.
The original implementation of delay function of ARM s3c44b0 doesnt' cooperate with U-Boot kernel well, which will cause fake-time-out. What is important is to keep timestamp in unit of millisecond.

Patch

diff -purN old/cpu/s3c44b0/interrupts.c new/cpu/s3c44b0/interrupts.c
--- old/cpu/s3c44b0/interrupts.c	2005-12-17 00:39:27.000000000 +0800
+++ new/cpu/s3c44b0/interrupts.c	2008-11-13 20:36:46.000000000 +0800
@@ -147,7 +147,7 @@  static ulong lastdec;
 int interrupt_init (void)
 {
 	TCFG0 = 0x000000E9;
-	TCFG1 = 0x00000004;
+	TCFG1 = 0x00000040;
 	TCON = 0x00000900;
 	TCNTB1 = TIMER_LOAD_VAL;
 	TCMPB1 = 0;
@@ -185,7 +185,7 @@  void udelay (unsigned long usec)
 
 	tmo = usec / 1000;
 	tmo *= CFG_HZ;
-	tmo /= 8;
+	tmo /= 1000;
 
 	tmo += get_timer (0);
 
@@ -213,7 +213,7 @@  ulong get_timer_masked (void)
 	}
 	lastdec = now;
 
-	return timestamp;
+	return (timestamp >> 3);
 }
 
 void udelay_masked (unsigned long usec)
@@ -225,10 +225,9 @@  void udelay_masked (unsigned long usec)
 	if (usec >= 1000) {
 		tmo = usec / 1000;
 		tmo *= CFG_HZ;
-		tmo /= 8;
+		tmo /= 1000;
 	} else {
-		tmo = usec * CFG_HZ;
-		tmo /= (1000*8);
+		tmo = 1;
 	}
 
 	endtime = get_timer(0) + tmo;