2 * linux/arch/arm/common/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
14 * 13=Jun-2004 DS Moved to arch/arm/common b/c shared w/CLPS7500
16 #include <linux/timex.h>
17 #include <linux/init.h>
19 #include <asm/hardware.h>
21 #include <asm/hardware/ioc.h>
23 #include <asm/mach/time.h>
25 static unsigned long ioctime_gettimeoffset(void)
27 unsigned int count1
, count2
, status
;
30 ioc_writeb (0, IOC_T0LATCH
);
32 count1
= ioc_readb(IOC_T0CNTL
) | (ioc_readb(IOC_T0CNTH
) << 8);
34 status
= ioc_readb(IOC_IRQREQA
);
36 ioc_writeb (0, IOC_T0LATCH
);
38 count2
= ioc_readb(IOC_T0CNTL
) | (ioc_readb(IOC_T0CNTH
) << 8);
41 if (count2
< count1
) {
43 * We have not had an interrupt between reading count1
46 if (status
& (1 << 5))
48 } else if (count2
> count1
) {
50 * We have just had another interrupt between reading
56 offset
= (LATCH
- offset
) * (tick_nsec
/ 1000);
57 return (offset
+ LATCH
/2) / LATCH
;
60 void __init
ioctime_init(void)
62 ioc_writeb(LATCH
& 255, IOC_T0LTCHL
);
63 ioc_writeb(LATCH
>> 8, IOC_T0LTCHH
);
64 ioc_writeb(0, IOC_T0GO
);
66 gettimeoffset
= ioctime_gettimeoffset
;