]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
arm/s5pxx: Fix get_timer_masked to get the time.
authorZhong Hongbo <bocui107@gmail.com>
Mon, 2 Jul 2012 13:50:49 +0000 (13:50 +0000)
committerAlbert ARIBAUD <albert.u.boot@aribaud.net>
Sat, 1 Sep 2012 12:58:23 +0000 (14:58 +0200)
In general, The get_timer_masked function get the system time,
no the number of ticks. Such as the nand_wait_ready will use
get_timer_masked to delay the operations. And change the system
time to adopt to the CONFIG_SYS_HZ.

Signed-off-by: Hongbo Zhong <bocui107@gmail.com>
Tested-by: Jaehoon Chung<jh80.chung@samsung.com>
Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
arch/arm/cpu/armv7/s5p-common/pwm.c
arch/arm/cpu/armv7/s5p-common/timer.c

index 58d279e003ff0df2ffd34b3373343fd232f95aa2..44d7bc360eda65e84457b7b80efa163dead173e7 100644 (file)
@@ -170,7 +170,7 @@ int pwm_init(int pwm_id, int div, int invert)
        timer_rate_hz = get_pwm_clk() / ((prescaler + 1) *
                        (div + 1));
 
-       timer_rate_hz = timer_rate_hz / 100;
+       timer_rate_hz = timer_rate_hz / CONFIG_SYS_HZ;
 
        /* set count value */
        offset = pwm_id * 3;
index 359c21f5e0c9e2ad02c48b3e61615c2cc3e2dcf9..bb0e795e66823d4963acd309ebbdd3e67bf7d4a4 100644 (file)
@@ -31,6 +31,8 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+unsigned long get_current_tick(void);
+
 /* macro to read the 16 bit timer */
 static inline struct s5p_timer *s5p_get_base_timer(void)
 {
@@ -44,6 +46,8 @@ int timer_init(void)
        pwm_config(4, 0, 0);
        pwm_enable(4);
 
+       reset_timer_masked();
+
        return 0;
 }
 
@@ -72,16 +76,16 @@ void __udelay(unsigned long usec)
                 * 3. finish normalize.
                 */
                tmo = usec / 1000;
-               tmo *= (CONFIG_SYS_HZ * count_value / 10);
+               tmo *= (CONFIG_SYS_HZ * count_value);
                tmo /= 1000;
        } else {
                /* else small number, don't kill it prior to HZ multiply */
-               tmo = usec * CONFIG_SYS_HZ * count_value / 10;
+               tmo = usec * CONFIG_SYS_HZ * count_value;
                tmo /= (1000 * 1000);
        }
 
        /* get current timestamp */
-       tmp = get_timer(0);
+       tmp = get_current_tick();
 
        /* if setting this fordward will roll time stamp */
        /* reset "advancing" timestamp to 0, set lastinc value */
@@ -92,7 +96,7 @@ void __udelay(unsigned long usec)
                tmo += tmp;
 
        /* loop till event */
-       while (get_timer_masked() < tmo)
+       while (get_current_tick() < tmo)
                ;       /* nop */
 }
 
@@ -106,6 +110,14 @@ void reset_timer_masked(void)
 }
 
 unsigned long get_timer_masked(void)
+{
+       struct s5p_timer *const timer = s5p_get_base_timer();
+       unsigned long count_value = readl(&timer->tcntb4);
+
+       return get_current_tick() / count_value;
+}
+
+unsigned long get_current_tick(void)
 {
        struct s5p_timer *const timer = s5p_get_base_timer();
        unsigned long now = readl(&timer->tcnto4);