allow coexistance of N build and AC build.
[tomato.git] / release / src-rt-6.x / linux / linux-2.6 / arch / h8300 / platform / h8300h / generic / timer.c
blob6f5cefe0cceb2a36643a6fe35a82bb35235c7edd
1 /*
2 * linux/arch/h8300/platform/h8300h/generic/timer.c
4 * Yoshinori Sato <ysato@users.sourceforge.jp>
6 * Platform depend Timer Handler
8 */
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>
15 #include <linux/mm.h>
16 #include <linux/interrupt.h>
18 #include <asm/segment.h>
19 #include <asm/io.h>
20 #include <asm/irq.h>
22 #include <linux/timex.h>
24 #if defined(CONFIG_H83007) || defined(CONFIG_H83068)
25 #include <asm/regs306x.h>
26 #define CMFA 6
28 #define CMIEA 0x40
29 #define CCLR_CMA 0x08
30 #define CLK_DIV8192 0x03
32 #define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*1000/8192 /* Timer input freq. */
34 void __init platform_timer_setup(irqreturn_t (*timer_int)(int, void *, struct pt_regs *))
36 /* setup 8bit timer ch2 */
37 ctrl_outb(H8300_TIMER_FREQ / HZ, TCORA2); /* set interval */
38 ctrl_outb(0x00, _8TCSR2); /* no output */
39 request_irq(40, timer_int, 0, "timer", 0);
40 ctrl_outb(CMIEA|CCLR_CMA|CLK_DIV8192, _8TCR2); /* start count */
43 void platform_timer_eoi(void)
45 *(volatile unsigned char *)_8TCSR2 &= ~(1 << CMFA);
47 #endif
49 #if defined(CONFIG_H83002) || defined(CONFIG_H83048)
50 /* FIXME! */
51 #define TSTR 0x00ffff60
52 #define TSNC 0x00ffff61
53 #define TMDR 0x00ffff62
54 #define TFCR 0x00ffff63
55 #define TOER 0x00ffff90
56 #define TOCR 0x00ffff91
57 /* ITU0 */
58 #define TCR 0x00ffff64
59 #define TIOR 0x00ffff65
60 #define TIER 0x00ffff66
61 #define TSR 0x00ffff67
62 #define TCNT 0x00ffff68
63 #define GRA 0x00ffff6a
64 #define GRB 0x00ffff6c
66 #define CCLR_CMGRA 0x20
67 #define CLK_DIV8 0x03
69 #define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*1000/8 /* Timer input freq. */
71 void __init platform_timer_setup(irqreturn_t (*timer_int)(int, void *, struct pt_regs *))
73 *(unsigned short *)GRA= H8300_TIMER_FREQ / HZ; /* set interval */
74 *(unsigned short *)TCNT=0; /* clear counter */
75 ctrl_outb(0x80|CCLR_CMGRA|CLK_DIV8, TCR); /* set ITU0 clock */
76 ctrl_outb(0x88, TIOR); /* no output */
77 request_irq(26, timer_int, 0, "timer", 0);
78 ctrl_outb(0xf9, TIER); /* compare match GRA interrupt */
79 ctrl_outb(ctrl_inb(TSNC) & ~0x01, TSNC); /* ITU0 async */
80 ctrl_outb(ctrl_inb(TMDR) & ~0x01, TMDR); /* ITU0 normal mode */
81 ctrl_outb(ctrl_inb(TSTR) | 0x01, TSTR); /* ITU0 Start */
82 return 0;
85 void platform_timer_eoi(void)
87 ctrl_outb(ctrl_inb(TSR) & ~0x01,TSR);
89 #endif
91 void platform_gettod(int *year, int *mon, int *day, int *hour,
92 int *min, int *sec)
94 *year = *mon = *day = *hour = *min = *sec = 0;