2 * linux/arch/h8300/kernel/timer/timer16.c
4 * Yoshinori Sato <ysato@users.sourcefoge.jp>
10 #include <linux/errno.h>
11 #include <linux/sched.h>
12 #include <linux/kernel.h>
13 #include <linux/param.h>
14 #include <linux/string.h>
16 #include <linux/interrupt.h>
17 #include <linux/init.h>
18 #include <linux/timex.h>
20 #include <asm/segment.h>
23 #include <asm/regs306x.h>
26 #if CONFIG_H8300_TIMER16_CH == 0
27 #define _16BASE 0xffff78
29 #elif CONFIG_H8300_TIMER16_CH == 1
30 #define _16BASE 0xffff80
32 #elif CONFIG_H8300_TIMER16_CH == 2
33 #define _16BASE 0xffff88
36 #error Unknown timer channel.
45 #define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*10000 /* Timer input freq. */
47 static irqreturn_t timer_interrupt(int irq, void *dev_id)
50 ctrl_bclr(CONFIG_H8300_TIMER16_CH, TISRA);
54 static struct irqaction timer16_irq = {
56 .handler = timer_interrupt,
57 .flags = IRQF_DISABLED | IRQF_TIMER,
58 .mask = CPU_MASK_NONE,
61 static const int __initdata divide_rate[] = {1, 2, 4, 8};
63 void __init h8300_timer_setup(void)
68 calc_param(cnt, div, divide_rate, 0x10000);
70 setup_irq(_16IRQ, &timer16_irq);
74 ctrl_outb(CCLR0 | div, _16BASE + TCR);
75 ctrl_outw(cnt, _16BASE + GRA);
76 ctrl_bset(4 + CONFIG_H8300_TIMER16_CH, TISRA);
77 ctrl_bset(CONFIG_H8300_TIMER16_CH, TSTR);