2 * linux/arch/arm/kernel/time-acorn.c
4 * Copyright (c) 1996-2000 Russell King.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
11 * 24-Sep-1996 RMK Created
12 * 10-Oct-1996 RMK Brought up to date with arch-sa110eval
13 * 04-Dec-1997 RMK Updated for new arch/arm/time.c
15 #include <linux/sched.h>
16 #include <linux/interrupt.h>
17 #include <linux/init.h>
19 #include <asm/hardware.h>
22 #include <asm/hardware/ioc.h>
24 extern unsigned long (*gettimeoffset)(void);
26 static unsigned long ioctime_gettimeoffset(void)
28 unsigned int count1, count2, status1, status2;
29 unsigned long offset = 0;
31 status1 = ioc_readb(IOC_IRQREQA);
33 ioc_writeb (0, IOC_T0LATCH);
35 count1 = ioc_readb(IOC_T0CNTL) | (ioc_readb(IOC_T0CNTH) << 8);
37 status2 = ioc_readb(IOC_IRQREQA);
39 ioc_writeb (0, IOC_T0LATCH);
41 count2 = ioc_readb(IOC_T0CNTL) | (ioc_readb(IOC_T0CNTH) << 8);
43 if (count2 < count1) {
45 * This means that we haven't just had an interrupt
46 * while reading into status2.
48 if (status2 & (1 << 5))
51 } else if (count2 > count1) {
53 * We have just had another interrupt while reading
60 count1 = LATCH - count1;
62 * count1 = number of clock ticks since last interrupt
64 offset += count1 * tick / LATCH;
68 void __init ioctime_init(void)
70 ioc_writeb(LATCH & 255, IOC_T0LTCHL);
71 ioc_writeb(LATCH >> 8, IOC_T0LTCHH);
72 ioc_writeb(0, IOC_T0GO);
74 gettimeoffset = ioctime_gettimeoffset;