2 * linux/arch/h8300/kernel/timer/tpu.c
4 * Yoshinori Sato <ysato@users.sourceforge.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/regs267x.h>
26 #if CONFIG_H8300_TPU_CH == 0
27 #define TPUBASE 0xffffd0
29 #elif CONFIG_H8300_TPU_CH == 1
30 #define TPUBASE 0xffffe0
32 #elif CONFIG_H8300_TPU_CH == 2
33 #define TPUBASE 0xfffff0
35 #elif CONFIG_H8300_TPU_CH == 3
36 #define TPUBASE 0xfffe80
38 #elif CONFIG_H8300_TPU_CH == 4
39 #define TPUBASE 0xfffe90
42 #error Unknown timer channel.
56 static irqreturn_t
timer_interrupt(int irq
, void *dev_id
)
59 ctrl_bclr(0, TPUBASE
+ _TSR
);
63 static struct irqaction tpu_irq
= {
65 .handler
= timer_interrupt
,
66 .flags
= IRQF_DISABLED
| IRQF_TIMER
,
69 static const int __initdata divide_rate
[] = {
70 #if CONFIG_H8300_TPU_CH == 0
72 #elif (CONFIG_H8300_TPU_CH == 1) || (CONFIG_H8300_TPU_CH == 5)
74 #elif (CONFIG_H8300_TPU_CH == 2) || (CONFIG_H8300_TPU_CH == 4)
76 #elif CONFIG_H8300_TPU_CH == 3
77 1,4,16,64,0,1024,256,4096,
81 void __init
h8300_timer_setup(void)
86 calc_param(cnt
, div
, divide_rate
, 0x10000);
88 setup_irq(TPUIRQ
, &tpu_irq
);
90 /* TPU module enabled */
91 ctrl_bclr(3, MSTPCRH
);
94 ctrl_outb(CCLR0
| div
, TPUBASE
+ _TCR
);
95 ctrl_outb(0, TPUBASE
+ _TMDR
);
96 ctrl_outw(0, TPUBASE
+ _TIOR
);
97 ctrl_outb(0x01, TPUBASE
+ _TIER
);
98 ctrl_outw(cnt
, TPUBASE
+ _GRA
);
99 ctrl_bset(CONFIG_H8300_TPU_CH
, TSTR
);