# BRCM_VERSION=3
[bcm963xx.git] / kernel / linux / arch / arm / mach-lh7a40x / time.c
1 /* 
2  *  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  */
11 #include <linux/config.h>
12 #include <linux/module.h>
13 #include <linux/kernel.h>
14 #include <linux/interrupt.h>
15 #include <linux/time.h>
16
17 #include <asm/hardware.h>
18 #include <asm/io.h>
19 #include <asm/irq.h>
20 #include <asm/leds.h>
21
22 #include <asm/mach/time.h>
23
24 #if HZ < 100
25 # define TIMER_CONTROL  TIMER_CONTROL1
26 # define TIMER_LOAD     TIMER_LOAD1
27 # define TIMER_CONSTANT (508469/HZ)
28 # define TIMER_MODE     (TIMER_C_ENABLE | TIMER_C_PERIODIC | TIMER_C_508KHZ)
29 # define TIMER_EOI      TIMER_EOI1
30 # define TIMER_IRQ      IRQ_T1UI
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
40 static irqreturn_t
41 lh7a40x_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
42 {
43         TIMER_EOI = 0;
44         timer_tick(regs);
45
46         return IRQ_HANDLED;
47 }
48
49 static struct irqaction lh7a40x_timer_irq = {
50         .name           = "LHA740x Timer Tick",
51         .flags          = SA_INTERRUPT,
52         .handler        = lh7a40x_timer_interrupt
53 };
54
55 void __init lh7a40x_init_time(void)
56 {
57                                 /* Stop/disable all timers */
58         TIMER_CONTROL1 = 0;
59         TIMER_CONTROL2 = 0;
60         TIMER_CONTROL3 = 0;
61
62         setup_irq (TIMER_IRQ, &lh7a40x_timer_irq);
63
64         TIMER_LOAD = TIMER_CONSTANT;
65         TIMER_CONTROL = TIMER_MODE;
66 }
67