From 94a3312920b6f9b5da27309549fb73650718c10a Mon Sep 17 00:00:00 2001 From: Micha Kalfon Date: Wed, 11 Feb 2009 19:50:11 +0200 Subject: pxa: fixing get_timer to return time in miliseconds. Fixing the get_timer function to return time in miliseconds instead of ticks. Also fixed PXA boards to use the conventional value of 1000 for CONFIG_SYS_HZ. Signed-off-by: Micha Kalfon --- cpu/pxa/interrupts.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'cpu') diff --git a/cpu/pxa/interrupts.c b/cpu/pxa/interrupts.c index ec8fb9e3d7..40d8bf251f 100644 --- a/cpu/pxa/interrupts.c +++ b/cpu/pxa/interrupts.c @@ -33,6 +33,14 @@ #error: interrupts not implemented yet #endif +#if defined(CONFIG_PXA27X) || defined(CONFIG_CPU_MONAHANS) +#define TIMER_FREQ_HZ 3250000 +#elif defined(CONFIG_PXA250) +#define TIMER_FREQ_HZ 3686400 +#else +#error "Timer frequency unknown - please config PXA CPU type" +#endif + int interrupt_init (void) { /* nothing happens here - we don't setup any IRQs */ @@ -67,7 +75,10 @@ void reset_timer_masked (void) ulong get_timer_masked (void) { - return OSCR; + unsigned long long ticks = get_ticks(); + + return (((ticks / TIMER_FREQ_HZ) * 1000) + + ((ticks % TIMER_FREQ_HZ) * 1000) / TIMER_FREQ_HZ); } void udelay_masked (unsigned long usec) @@ -78,17 +89,17 @@ void udelay_masked (unsigned long usec) if (usec >= 1000) { tmo = usec / 1000; - tmo *= CONFIG_SYS_HZ; + tmo *= TIMER_FREQ_HZ; tmo /= 1000; } else { - tmo = usec * CONFIG_SYS_HZ; + tmo = usec * TIMER_FREQ_HZ; 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); } @@ -99,7 +110,7 @@ void udelay_masked (unsigned long usec) */ unsigned long long get_ticks(void) { - return get_timer(0); + return OSCR; } /* @@ -109,6 +120,6 @@ unsigned long long get_ticks(void) ulong get_tbclk (void) { ulong tbclk; - tbclk = CONFIG_SYS_HZ; + tbclk = TIMER_FREQ_HZ; return tbclk; } -- cgit v1.2.1