MOXA linux-2.6.x / linux-2.6.19-uc1 from UC-7110-LX-BOOTLOADER-1.9_VERSION-4.2.tgz
[linux-2.6.19-moxart.git] / include / asm-arm / arch-ixp4xx / fast_timer.h
blobd3262f63758ce429f3daf0972dc1d74cce26b39e
1 #ifndef __ASM_ARM_MACH_FAST_TIMER_H
2 #define __ASM_ARM_MACH_FAST_TIMER_H
4 #include <linux/sched.h>
5 #include <linux/timex.h>
6 #include <linux/interrupt.h>
7 #include <asm/hardware.h>
8 #include <asm/irq.h>
10 static irqreturn_t
11 fast_timer_interrupt(int irq, void *dev_id)
13 /* Clear Pending Interrupt by writing '1' to it */
14 *IXP4XX_OSST = IXP4XX_OSST_TIMER_2_PEND;
16 do_fast_timer();
17 return IRQ_HANDLED;
20 static void fast_timer_set(void)
22 unsigned long interval;
24 /* Setup the Timer counter value */
25 interval = (CLOCK_TICK_RATE + fast_timer_rate/2) / fast_timer_rate;
26 *IXP4XX_OSRT2 = (interval & ~IXP4XX_OST_RELOAD_MASK) | IXP4XX_OST_ENABLE;
29 static int __init fast_timer_setup(void)
31 /* Clear Pending Interrupt by writing '1' to it */
32 *IXP4XX_OSST = IXP4XX_OSST_TIMER_2_PEND;
34 /* Connect the interrupt handler and enable the interrupt */
35 if (request_irq(IRQ_IXP4XX_TIMER2, fast_timer_interrupt, SA_INTERRUPT,
36 "fast timer", NULL))
37 return -EBUSY;
39 fast_timer_rate = 5000;
40 fast_timer_set();
42 printk("fast timer: %d Hz, IRQ %d\n", fast_timer_rate,
43 IRQ_IXP4XX_TIMER2);
44 return 0;
47 static void __exit fast_timer_cleanup(void)
49 *IXP4XX_OSRT2 = IXP4XX_OST_DISABLED;
50 free_irq(IRQ_IXP4XX_TIMER2, NULL);
53 #endif