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-ks8695 / fast_timer.h
blob5527205e4d336a26ca8995825ecf8c512aaef134
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>
9 #include <asm/io.h>
11 static irqreturn_t fast_timer_interrupt(int irq, void *dev_id)
13 __raw_writel(KS8695_INTMASK_TIMERINT0, KS8695_REG(KS8695_INT_STATUS));
14 do_fast_timer();
15 return IRQ_HANDLED;
18 static void fast_timer_set(void)
20 unsigned long interval, data, pulse, ctrl;
22 /* Setup TIMER0 as fast clock */
23 interval = (CLOCK_TICK_RATE/1000000) * fast_timer_rate;
24 data = interval >> 1;
25 pulse = interval - data;
26 __raw_writel(data, KS8695_REG(KS8695_TIMER0));
27 __raw_writel(pulse, KS8695_REG(KS8695_TIMER0_PCOUNT));
28 ctrl = __raw_readl(KS8695_REG(KS8695_TIMER_CTRL)) | 0x01;
29 __raw_writel(ctrl, KS8695_REG(KS8695_TIMER_CTRL));
32 static int __init fast_timer_setup(void)
34 /* Connect the interrupt handler and enable the interrupt */
35 if (request_irq(KS8695_INT_TIMERINT0, fast_timer_interrupt,
36 SA_INTERRUPT, "fast timer", NULL))
37 return -EBUSY;
39 fast_timer_rate = 2000;
40 fast_timer_set();
42 printk("fast timer: %d Hz, IRQ %d\n", fast_timer_rate,
43 KS8695_INT_TIMERINT0);
44 return 0;
47 static void __exit fast_timer_cleanup(void)
49 unsigned long ctrl;
51 ctrl = __raw_readl(KS8695_REG(KS8695_TIMER_CTRL)) & 0x02;
52 __raw_writel(ctrl, KS8695_REG(KS8695_TIMER_CTRL));
53 free_irq(KS8695_INT_TIMERINT0, NULL);
56 #endif