]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
CONFIG_SYS_HZ fix for ARM902T S3C24X0 Boards
authorkevin.morfitt@fearnside-systems.co.uk <kevin.morfitt@fearnside-systems.co.uk>
Sat, 5 Sep 2009 15:33:13 +0000 (00:33 +0900)
committerMinkyu Kang <mk7.kang@samsung.com>
Fri, 9 Oct 2009 05:33:50 +0000 (14:33 +0900)
This sets CONFIG_SYS_HZ to 1000 for all boards that use the s3c2400 and
s3c2410 cpu's which fixes various problems such as the timeouts in tftp being
too short.

Tested on an Embest SBC2440-II Board with local u-boot patches as I don't
have any s3c2400 or s3c2410 boards but need this patch applying before I can
submit patches for the SBC2440-II Board. Also, ran MAKEALL for all ARM9 targets
and no new warnings or errors were found.

It was originally submitted on 21/06/2009 but didn't get into the 2009.08
release, and Jean-Pierre made one comment on the original patch (see
http://lists.denx.de/pipermail/u-boot/2009-July/055470.html). I've made two
changes to the original patch:
- it's been re-based to the current release
- I've re-named get_timer_raw() to get_ticks() in response to Jean-Pierre's comment

This affects the sbc2410, smdk2400, smdk2410 and trab boards. I've copied it
directly to the maintainers of all except the sbc2410 which doesn't have an
entry in MAINTAINERS.

Signed-off-by: Kevin Morfitt <kmorfitt@aselaptop-1.localdomain>
Tested-by: Wolfgang Denk <wd@denx.de>
Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
cpu/arm920t/s3c24x0/timer.c
include/configs/sbc2410x.h
include/configs/smdk2400.h
include/configs/smdk2410.h
include/configs/trab.h

index c8c7cdb5202b6378cee90591d29b6008a6d83819..db472bf54feb4517e5907c19b8e0198927e96bea 100644 (file)
@@ -39,6 +39,7 @@
 #endif
 
 int timer_load_val = 0;
+static ulong timer_clk;
 
 /* macro to read the 16 bit timer */
 static inline ulong READ_TIMER(void)
@@ -66,6 +67,7 @@ int timer_init (void)
                 * @33.25MHz and 15625 @ 50 MHz
                 */
                timer_load_val = get_PCLK()/(2 * 16 * 100);
+               timer_clk = get_PCLK() / (2 * 16);
        }
        /* load value for 10 ms timeout */
        lastdec = timers->TCNTB4 = timer_load_val;
@@ -100,13 +102,13 @@ void set_timer (ulong t)
 void udelay (unsigned long usec)
 {
        ulong tmo;
-       ulong start = get_timer(0);
+       ulong start = get_ticks();
 
        tmo = usec / 1000;
        tmo *= (timer_load_val * 100);
        tmo /= 1000;
 
-       while ((ulong)(get_timer_masked () - start) < tmo)
+       while ((ulong) (get_ticks() - start) < tmo)
                /*NOP*/;
 }
 
@@ -119,18 +121,9 @@ void reset_timer_masked (void)
 
 ulong get_timer_masked (void)
 {
-       ulong now = READ_TIMER();
-
-       if (lastdec >= now) {
-               /* normal mode */
-               timestamp += lastdec - now;
-       } else {
-               /* we have an overflow ... */
-               timestamp += lastdec + timer_load_val - now;
-       }
-       lastdec = now;
+       ulong tmr = get_ticks();
 
-       return timestamp;
+       return tmr / (timer_clk / CONFIG_SYS_HZ);
 }
 
 void udelay_masked (unsigned long usec)
@@ -148,10 +141,10 @@ void udelay_masked (unsigned long usec)
                tmo /= (1000*1000);
        }
 
-       endtime = get_timer_masked () + tmo;
+       endtime = get_ticks() + tmo;
 
        do {
-               ulong now = get_timer_masked ();
+               ulong now = get_ticks();
                diff = endtime - now;
        } while (diff >= 0);
 }
@@ -162,7 +155,18 @@ void udelay_masked (unsigned long usec)
  */
 unsigned long long get_ticks(void)
 {
-       return get_timer(0);
+       ulong now = READ_TIMER();
+
+       if (lastdec >= now) {
+               /* normal mode */
+               timestamp += lastdec - now;
+       } else {
+               /* we have an overflow ... */
+               timestamp += lastdec + timer_load_val - now;
+       }
+       lastdec = now;
+
+       return timestamp;
 }
 
 /*
index f2ea926f92465872a29953a00839035a992180de..e6886cf7f6f86c8ec88d2e408b9e3d394683ce5f 100644 (file)
 
 #define        CONFIG_SYS_LOAD_ADDR            0x33000000      /* default load address */
 
-/* the PWM TImer 4 uses a counter of 15625 for 10 ms, so we need */
-/* it to wrap 100 times (total 1562500) to get 1 sec. */
-#define        CONFIG_SYS_HZ                   1562500
+#define        CONFIG_SYS_HZ                   1000
 
 /* valid baudrates */
 #define CONFIG_SYS_BAUDRATE_TABLE      { 9600, 19200, 38400, 57600, 115200 }
index c23417776738ad9270f03c3c4d88dd5bd5a55a8d..a1beb65d0ead377c76d7b86cde730c699dcd83ac 100644 (file)
 
 #define        CONFIG_SYS_LOAD_ADDR            0x0cf00000      /* default load address */
 
-/* the PWM TImer 4 uses a counter of 15625 for 10 ms, so we need */
-/* it to wrap 100 times (total 1562500) to get 1 sec. */
-#define        CONFIG_SYS_HZ                   1562500
+#define        CONFIG_SYS_HZ                   1000
 
 /* valid baudrates */
 #define CONFIG_SYS_BAUDRATE_TABLE      { 9600, 19200, 38400, 57600, 115200 }
index d340098d0bcd4a02215a6043f8850a7534dc536f..c57751bf90b085f4532c788880b9bdd455d3b59b 100644 (file)
 
 #define        CONFIG_SYS_LOAD_ADDR            0x33000000      /* default load address */
 
-/* the PWM TImer 4 uses a counter of 15625 for 10 ms, so we need */
-/* it to wrap 100 times (total 1562500) to get 1 sec. */
-#define        CONFIG_SYS_HZ                   1562500
+#define        CONFIG_SYS_HZ                   1000
 
 /* valid baudrates */
 #define CONFIG_SYS_BAUDRATE_TABLE      { 9600, 19200, 38400, 57600, 115200 }
index 43c191b4356c1e87f30ff7aaa7f5fde2c0320ba8..97f30cea750cf75f7827b2587320a40ded66be0b 100644 (file)
 
 #define        CONFIG_SYS_LOAD_ADDR            0x0CF00000      /* default load address */
 
-#ifdef CONFIG_TRAB_50MHZ
-/* the PWM TImer 4 uses a counter of 15625 for 10 ms, so we need */
-/* it to wrap 100 times (total 1562500) to get 1 sec. */
-/* this should _really_ be calculated !! */
-#define        CONFIG_SYS_HZ                   1562500
-#else
-/* the PWM TImer 4 uses a counter of 10390 for 10 ms, so we need */
-/* it to wrap 100 times (total 1039000) to get 1 sec. */
-/* this should _really_ be calculated !! */
-#define        CONFIG_SYS_HZ                   1039000
-#endif
+#define        CONFIG_SYS_HZ                   1000
 
 /* valid baudrates */
 #define CONFIG_SYS_BAUDRATE_TABLE      { 9600, 19200, 38400, 57600, 115200 }