aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-clps711x/time.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/arm/mach-clps711x/time.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/arm/mach-clps711x/time.c')
-rw-r--r--arch/arm/mach-clps711x/time.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/arch/arm/mach-clps711x/time.c b/arch/arm/mach-clps711x/time.c
new file mode 100644
index 000000000000..383d4e0c6e35
--- /dev/null
+++ b/arch/arm/mach-clps711x/time.c
@@ -0,0 +1,85 @@
1/*
2 * linux/arch/arm/mach-clps711x/time.c
3 *
4 * Copyright (C) 2001 Deep Blue Solutions Ltd.
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 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#include <linux/timex.h>
20#include <linux/init.h>
21#include <linux/interrupt.h>
22#include <linux/sched.h>
23
24#include <asm/hardware.h>
25#include <asm/irq.h>
26#include <asm/leds.h>
27#include <asm/io.h>
28#include <asm/hardware/clps7111.h>
29
30#include <asm/mach/time.h>
31
32
33/*
34 * gettimeoffset() returns time since last timer tick, in usecs.
35 *
36 * 'LATCH' is hwclock ticks (see CLOCK_TICK_RATE in timex.h) per jiffy.
37 * 'tick' is usecs per jiffy.
38 */
39static unsigned long clps711x_gettimeoffset(void)
40{
41 unsigned long hwticks;
42 hwticks = LATCH - (clps_readl(TC2D) & 0xffff); /* since last underflow */
43 return (hwticks * (tick_nsec / 1000)) / LATCH;
44}
45
46/*
47 * IRQ handler for the timer
48 */
49static irqreturn_t
50p720t_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
51{
52 write_seqlock(&xtime_lock);
53 timer_tick(regs);
54 write_sequnlock(&xtime_lock);
55 return IRQ_HANDLED;
56}
57
58static struct irqaction clps711x_timer_irq = {
59 .name = "CLPS711x Timer Tick",
60 .flags = SA_INTERRUPT,
61 .handler = p720t_timer_interrupt
62};
63
64static void __init clps711x_timer_init(void)
65{
66 struct timespec tv;
67 unsigned int syscon;
68
69 syscon = clps_readl(SYSCON1);
70 syscon |= SYSCON1_TC2S | SYSCON1_TC2M;
71 clps_writel(syscon, SYSCON1);
72
73 clps_writel(LATCH-1, TC2D); /* 512kHz / 100Hz - 1 */
74
75 setup_irq(IRQ_TC2OI, &clps711x_timer_irq);
76
77 tv.tv_nsec = 0;
78 tv.tv_sec = clps_readl(RTCDR);
79 do_settimeofday(&tv);
80}
81
82struct sys_timer clps711x_timer = {
83 .init = clps711x_timer_init,
84 .offset = clps711x_gettimeoffset,
85};