blob: 1919835d9610a6a07195e5c6299569f2d573921a [file] [log] [blame]
Marc Singer638b2662006-05-16 11:41:28 +01001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * arch/arm/mach-lh7a40x/time.c
3 *
4 * Copyright (C) 2004 Logic Product Development
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * version 2 as published by the Free Software Foundation.
9 *
10 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#include <linux/module.h>
12#include <linux/kernel.h>
13#include <linux/interrupt.h>
14#include <linux/time.h>
15
16#include <asm/hardware.h>
17#include <asm/io.h>
18#include <asm/irq.h>
19#include <asm/leds.h>
20
21#include <asm/mach/time.h>
22#include "common.h"
23
24#if HZ < 100
25# define TIMER_CONTROL TIMER_CONTROL2
26# define TIMER_LOAD TIMER_LOAD2
27# define TIMER_CONSTANT (508469/HZ)
28# define TIMER_MODE (TIMER_C_ENABLE | TIMER_C_PERIODIC | TIMER_C_508KHZ)
29# define TIMER_EOI TIMER_EOI2
30# define TIMER_IRQ IRQ_T2UI
31#else
32# define TIMER_CONTROL TIMER_CONTROL3
33# define TIMER_LOAD TIMER_LOAD3
34# define TIMER_CONSTANT (3686400/HZ)
35# define TIMER_MODE (TIMER_C_ENABLE | TIMER_C_PERIODIC)
36# define TIMER_EOI TIMER_EOI3
37# define TIMER_IRQ IRQ_T3UI
38#endif
39
40static irqreturn_t
41lh7a40x_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
42{
43 write_seqlock(&xtime_lock);
44
45 TIMER_EOI = 0;
46 timer_tick(regs);
47
48 write_sequnlock(&xtime_lock);
49
50 return IRQ_HANDLED;
51}
52
53static struct irqaction lh7a40x_timer_irq = {
54 .name = "LHA740x Timer Tick",
Russell King09b8b5f2005-06-26 17:06:36 +010055 .flags = SA_INTERRUPT | SA_TIMER,
56 .handler = lh7a40x_timer_interrupt,
Linus Torvalds1da177e2005-04-16 15:20:36 -070057};
58
Marc Singer638b2662006-05-16 11:41:28 +010059static void __init lh7a40x_timer_init (void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070060{
61 /* Stop/disable all timers */
62 TIMER_CONTROL1 = 0;
63 TIMER_CONTROL2 = 0;
64 TIMER_CONTROL3 = 0;
65
66 setup_irq (TIMER_IRQ, &lh7a40x_timer_irq);
67
68 TIMER_LOAD = TIMER_CONSTANT;
69 TIMER_CONTROL = TIMER_MODE;
70}
71
72struct sys_timer lh7a40x_timer = {
73 .init = &lh7a40x_timer_init,
74};