ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / h8300 / platform / h8300h / generic / timer.c
1 /*
2  *  linux/arch/h8300/platform/h8300h/generic/timer.c
3  *
4  *  Yoshinori Sato <ysato@users.sourceforge.jp>
5  *
6  *  Platform depend Timer Handler
7  *
8  */
9
10 #include <linux/config.h>
11 #include <linux/errno.h>
12 #include <linux/sched.h>
13 #include <linux/kernel.h>
14 #include <linux/param.h>
15 #include <linux/string.h>
16 #include <linux/mm.h>
17 #include <linux/interrupt.h>
18
19 #include <asm/segment.h>
20 #include <asm/io.h>
21 #include <asm/irq.h>
22
23 #include <linux/timex.h>
24
25 extern int request_irq_boot(unsigned int,
26                              irqreturn_t (*handler)(int, void *, struct pt_regs *),
27                              unsigned long, const char *, void *);
28
29
30 #if defined(CONFIG_H83007) || defined(CONFIG_H83068)
31 #include <asm/regs306x.h>
32 #define CMFA 6
33
34 int platform_timer_setup(irqreturn_t (*timer_int)(int, void *, struct pt_regs *))
35 {
36         ctrl_outb(H8300_TIMER_COUNT_DATA,TCORA2);
37         ctrl_outb(0x00,_8TCSR2);
38         request_irq(40,timer_int,0,"timer",0);
39         ctrl_outb(0x40|0x08|0x03,_8TCR2);
40         return 0;
41 }
42
43 void platform_timer_eoi(void)
44 {
45         *(volatile unsigned char *)_8TCSR2 &= ~(1 << CMFA);
46 }
47 #endif
48
49 #if defined(H8_3002) || 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 #define TCR  0x00ffff64
58 #define TIOR 0x00ffff65
59 #define TIER 0x00ffff66
60 #define TSR  0x00ffff67
61 #define TCNT 0x00ffff68
62 #define GRA  0x00ffff6a
63 #define GRB  0x00ffff6c
64
65 int platform_timer_setup(irqreturn_t (*timer_int)(int, void *, struct pt_regs *))
66 {
67         *(unsigned short *)GRA= H8300_TIMER_COUNT_DATA;
68         *(unsigned short *)TCNT=0;
69         ctrl_outb(0x23,TCR);
70         ctrl_outb(0x00,TIOR);
71         request_timer_irq(26,timer_int,0,"timer",0);
72         ctrl_outb(inb(TIER) | 0x01,TIER);
73         ctrl_outb(inb(TSNC) & ~0x01,TSNC);
74         ctrl_outb(inb(TMDR) & ~0x01,TMDR);
75         ctrl_outb(inb(TSTR) | 0x01,TSTR);
76         return 0;
77 }
78
79 void platform_timer_eoi(void)
80 {
81         ctrl_outb(inb(TSR) & ~0x01,TSR);
82 }
83 #endif
84
85 void platform_gettod(int *year, int *mon, int *day, int *hour,
86                  int *min, int *sec)
87 {
88         *year = *mon = *day = *hour = *min = *sec = 0;
89 }