ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / include / asm-arm / arch-lh7a40x / time.h
1 /* include/asm-arm/arch-lh7a40x/time.h
2  *
3  *  Copyright (C) 2004 Logic Product Development
4  *
5  *  This program is free software; you can redistribute it and/or
6  *  modify it under the terms of the GNU General Public License
7  *  version 2 as published by the Free Software Foundation.
8  *
9  */
10
11 #if HZ < 100
12 # define TIMER_CONTROL  TIMER_CONTROL1
13 # define TIMER_LOAD     TIMER_LOAD1
14 # define TIMER_CONSTANT (508469/HZ)
15 # define TIMER_MODE     (TIMER_C_ENABLE | TIMER_C_PERIODIC | TIMER_C_508KHZ)
16 # define TIMER_EOI      TIMER_EOI1
17 # define TIMER_IRQ      IRQ_T1UI
18 #else
19 # define TIMER_CONTROL  TIMER_CONTROL3
20 # define TIMER_LOAD     TIMER_LOAD3
21 # define TIMER_CONSTANT (3686400/HZ)
22 # define TIMER_MODE     (TIMER_C_ENABLE | TIMER_C_PERIODIC)
23 # define TIMER_EOI      TIMER_EOI3
24 # define TIMER_IRQ      IRQ_T3UI
25 #endif
26
27 static irqreturn_t
28 lh7a40x_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
29 {
30         TIMER_EOI = 0;
31         do_profile (regs);
32         do_leds();
33         do_set_rtc();
34         do_timer (regs);
35
36         return IRQ_HANDLED;
37 }
38
39 void __init time_init(void)
40 {
41                                 /* Stop/disable all timers */
42         TIMER_CONTROL1 = 0;
43         TIMER_CONTROL2 = 0;
44         TIMER_CONTROL3 = 0;
45
46         timer_irq.handler = lh7a40x_timer_interrupt;
47         timer_irq.flags |= SA_INTERRUPT;
48         setup_irq (TIMER_IRQ, &timer_irq);
49
50         TIMER_LOAD = TIMER_CONSTANT;
51         TIMER_CONTROL = TIMER_MODE;
52 }
53