aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-rpc
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2012-03-01 10:35:50 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2012-03-24 05:37:30 -0400
commita1be5d649699e0eecfe5fc65130954435543cda4 (patch)
tree6a31c20d91e1b20958ba6b3951a9d8862c8827ac /arch/arm/mach-rpc
parentd65b4e98d7ea3038b767b70fe8be959b2913f16d (diff)
ARM: riscpc: move time-acorn.c to mach-rpc
Nothing but RiscPC makes use of the Acorn timekeeping code, so move it into mach-rpc. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-rpc')
-rw-r--r--arch/arm/mach-rpc/Makefile2
-rw-r--r--arch/arm/mach-rpc/time.c95
2 files changed, 96 insertions, 1 deletions
diff --git a/arch/arm/mach-rpc/Makefile b/arch/arm/mach-rpc/Makefile
index aa77bc9efbbb..69f2c0656966 100644
--- a/arch/arm/mach-rpc/Makefile
+++ b/arch/arm/mach-rpc/Makefile
@@ -4,7 +4,7 @@
4 4
5# Object file lists. 5# Object file lists.
6 6
7obj-y := dma.o irq.o riscpc.o 7obj-y := dma.o irq.o riscpc.o time.o
8obj-m := 8obj-m :=
9obj-n := 9obj-n :=
10obj- := 10obj- :=
diff --git a/arch/arm/mach-rpc/time.c b/arch/arm/mach-rpc/time.c
new file mode 100644
index 000000000000..deeed561b168
--- /dev/null
+++ b/arch/arm/mach-rpc/time.c
@@ -0,0 +1,95 @@
1/*
2 * linux/arch/arm/common/time-acorn.c
3 *
4 * Copyright (c) 1996-2000 Russell King.
5 *
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.
9 *
10 * Changelog:
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
15 */
16#include <linux/timex.h>
17#include <linux/init.h>
18#include <linux/interrupt.h>
19#include <linux/irq.h>
20#include <linux/io.h>
21
22#include <mach/hardware.h>
23#include <asm/hardware/ioc.h>
24
25#include <asm/mach/time.h>
26
27unsigned long ioc_timer_gettimeoffset(void)
28{
29 unsigned int count1, count2, status;
30 long offset;
31
32 ioc_writeb (0, IOC_T0LATCH);
33 barrier ();
34 count1 = ioc_readb(IOC_T0CNTL) | (ioc_readb(IOC_T0CNTH) << 8);
35 barrier ();
36 status = ioc_readb(IOC_IRQREQA);
37 barrier ();
38 ioc_writeb (0, IOC_T0LATCH);
39 barrier ();
40 count2 = ioc_readb(IOC_T0CNTL) | (ioc_readb(IOC_T0CNTH) << 8);
41
42 offset = count2;
43 if (count2 < count1) {
44 /*
45 * We have not had an interrupt between reading count1
46 * and count2.
47 */
48 if (status & (1 << 5))
49 offset -= LATCH;
50 } else if (count2 > count1) {
51 /*
52 * We have just had another interrupt between reading
53 * count1 and count2.
54 */
55 offset -= LATCH;
56 }
57
58 offset = (LATCH - offset) * (tick_nsec / 1000);
59 return (offset + LATCH/2) / LATCH;
60}
61
62void __init ioctime_init(void)
63{
64 ioc_writeb(LATCH & 255, IOC_T0LTCHL);
65 ioc_writeb(LATCH >> 8, IOC_T0LTCHH);
66 ioc_writeb(0, IOC_T0GO);
67}
68
69static irqreturn_t
70ioc_timer_interrupt(int irq, void *dev_id)
71{
72 timer_tick();
73 return IRQ_HANDLED;
74}
75
76static struct irqaction ioc_timer_irq = {
77 .name = "timer",
78 .flags = IRQF_DISABLED,
79 .handler = ioc_timer_interrupt
80};
81
82/*
83 * Set up timer interrupt.
84 */
85static void __init ioc_timer_init(void)
86{
87 ioctime_init();
88 setup_irq(IRQ_TIMER, &ioc_timer_irq);
89}
90
91struct sys_timer ioc_timer = {
92 .init = ioc_timer_init,
93 .offset = ioc_timer_gettimeoffset,
94};
95