• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-WNDR4500-V1.0.1.40_1.0.68/src/linux/linux-2.6/arch/h8300/platform/h8300h/generic/
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/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>
17
18#include <asm/segment.h>
19#include <asm/io.h>
20#include <asm/irq.h>
21
22#include <linux/timex.h>
23
24#if defined(CONFIG_H83007) || defined(CONFIG_H83068)
25#include <asm/regs306x.h>
26#define CMFA 6
27
28#define CMIEA 0x40
29#define CCLR_CMA 0x08
30#define CLK_DIV8192 0x03
31
32#define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*1000/8192 /* Timer input freq. */
33
34void __init platform_timer_setup(irqreturn_t (*timer_int)(int, void *, struct pt_regs *))
35{
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 */
41}
42
43void platform_timer_eoi(void)
44{
45	*(volatile unsigned char *)_8TCSR2 &= ~(1 << CMFA);
46}
47#endif
48
49#if defined(CONFIG_H83002) || defined(CONFIG_H83048)
50#define TSTR 0x00ffff60
51#define TSNC 0x00ffff61
52#define TMDR 0x00ffff62
53#define TFCR 0x00ffff63
54#define TOER 0x00ffff90
55#define TOCR 0x00ffff91
56/* ITU0 */
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#define CCLR_CMGRA 0x20
66#define CLK_DIV8 0x03
67
68#define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*1000/8 /* Timer input freq. */
69
70void __init platform_timer_setup(irqreturn_t (*timer_int)(int, void *, struct pt_regs *))
71{
72	*(unsigned short *)GRA= H8300_TIMER_FREQ / HZ;  /* set interval */
73	*(unsigned short *)TCNT=0;                      /* clear counter */
74	ctrl_outb(0x80|CCLR_CMGRA|CLK_DIV8, TCR);       /* set ITU0 clock */
75	ctrl_outb(0x88, TIOR);                          /* no output */
76	request_irq(26, timer_int, 0, "timer", 0);
77	ctrl_outb(0xf9, TIER);                          /* compare match GRA interrupt */
78	ctrl_outb(ctrl_inb(TSNC) & ~0x01, TSNC);        /* ITU0 async */
79	ctrl_outb(ctrl_inb(TMDR) & ~0x01, TMDR);        /* ITU0 normal mode */
80	ctrl_outb(ctrl_inb(TSTR) | 0x01, TSTR);         /* ITU0 Start */
81	return 0;
82}
83
84void platform_timer_eoi(void)
85{
86	ctrl_outb(ctrl_inb(TSR) & ~0x01,TSR);
87}
88#endif
89
90void platform_gettod(int *year, int *mon, int *day, int *hour,
91		 int *min, int *sec)
92{
93	*year = *mon = *day = *hour = *min = *sec = 0;
94}
95