aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-rpc/time.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-rpc/time.c')
-rw-r--r--arch/arm/mach-rpc/time.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/arch/arm/mach-rpc/time.c b/arch/arm/mach-rpc/time.c
index 9a6def14df01..99363ae5cac7 100644
--- a/arch/arm/mach-rpc/time.c
+++ b/arch/arm/mach-rpc/time.c
@@ -24,6 +24,9 @@
24 24
25#include <asm/mach/time.h> 25#include <asm/mach/time.h>
26 26
27#define RPC_CLOCK_FREQ 2000000
28#define RPC_LATCH DIV_ROUND_CLOSEST(RPC_CLOCK_FREQ, HZ)
29
27static u32 ioc_timer_gettimeoffset(void) 30static u32 ioc_timer_gettimeoffset(void)
28{ 31{
29 unsigned int count1, count2, status; 32 unsigned int count1, count2, status;
@@ -46,23 +49,23 @@ static u32 ioc_timer_gettimeoffset(void)
46 * and count2. 49 * and count2.
47 */ 50 */
48 if (status & (1 << 5)) 51 if (status & (1 << 5))
49 offset -= LATCH; 52 offset -= RPC_LATCH;
50 } else if (count2 > count1) { 53 } else if (count2 > count1) {
51 /* 54 /*
52 * We have just had another interrupt between reading 55 * We have just had another interrupt between reading
53 * count1 and count2. 56 * count1 and count2.
54 */ 57 */
55 offset -= LATCH; 58 offset -= RPC_LATCH;
56 } 59 }
57 60
58 offset = (LATCH - offset) * (tick_nsec / 1000); 61 offset = (RPC_LATCH - offset) * (tick_nsec / 1000);
59 return ((offset + LATCH/2) / LATCH) * 1000; 62 return DIV_ROUND_CLOSEST(offset, RPC_LATCH) * 1000;
60} 63}
61 64
62void __init ioctime_init(void) 65void __init ioctime_init(void)
63{ 66{
64 ioc_writeb(LATCH & 255, IOC_T0LTCHL); 67 ioc_writeb(RPC_LATCH & 255, IOC_T0LTCHL);
65 ioc_writeb(LATCH >> 8, IOC_T0LTCHH); 68 ioc_writeb(RPC_LATCH >> 8, IOC_T0LTCHH);
66 ioc_writeb(0, IOC_T0GO); 69 ioc_writeb(0, IOC_T0GO);
67} 70}
68 71