0652e801be71cdc0a9066ff94940ad35c457272d
[linux-flexiantxendom0-3.2.10.git] / arch / h8300 / platform / h8300h / generic / timer.c
1 /*
2  *  linux/arch/h8300/platform/h8300h/generic/timer.c
3  *
4  *  Yoshinori Sato <qzb04471@nifty.ne.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 #if defined(CONFIG_H83007) || defined(CONFIG_H83068)
26 #define TMR8CMA2 0x00ffff94
27 #define TMR8TCSR2 0x00ffff92
28 #define TMR8TCNT2 0x00ffff90
29
30 int platform_timer_setup(void (*timer_int)(int, void *, struct pt_regs *))
31 {
32         outb(H8300_TIMER_COUNT_DATA,TMR8CMA2);
33         outb(0x00,TMR8TCSR2);
34         request_irq(40,timer_int,0,"timer",0);
35         outb(0x40|0x08|0x03,TMR8TCNT2);
36         return 0;
37 }
38
39 void platform_timer_eoi(void)
40 {
41         __asm__("bclr #6,@0xffff92:8");
42 }
43 #endif
44
45 #if defined(H8_3002) || defined(CONFIG_H83048)
46 #define TSTR 0x00ffff60
47 #define TSNC 0x00ffff61
48 #define TMDR 0x00ffff62
49 #define TFCR 0x00ffff63
50 #define TOER 0x00ffff90
51 #define TOCR 0x00ffff91
52 #define TCR  0x00ffff64
53 #define TIOR 0x00ffff65
54 #define TIER 0x00ffff66
55 #define TSR  0x00ffff67
56 #define TCNT 0x00ffff68
57 #define GRA  0x00ffff6a
58 #define GRB  0x00ffff6c
59
60 int platform_timer_setup(void (*timer_int)(int, void *, struct pt_regs *))
61 {
62         *(unsigned short *)GRA= H8300_TIMER_COUNT_DATA;
63         *(unsigned short *)TCNT=0;
64         outb(0x23,TCR);
65         outb(0x00,TIOR);
66         request_irq(26,timer_int,0,"timer",0);
67         outb(inb(TIER) | 0x01,TIER);
68         outb(inb(TSNC) & ~0x01,TSNC);
69         outb(inb(TMDR) & ~0x01,TMDR);
70         outb(inb(TSTR) | 0x01,TSTR);
71         return 0;
72 }
73
74 void platform_timer_eoi(void)
75 {
76         outb(inb(TSR) & ~0x01,TSR);
77 }
78 #endif
79
80 void platform_gettod(int *year, int *mon, int *day, int *hour,
81                  int *min, int *sec)
82 {
83         *year = *mon = *day = *hour = *min = *sec = 0;
84 }