This source file includes following definitions.
- dosample
- plat_time_init
- indy_8254timer_irq
1
2
3
4
5
6
7
8
9
10
11
12 #include <linux/bcd.h>
13 #include <linux/i8253.h>
14 #include <linux/init.h>
15 #include <linux/irq.h>
16 #include <linux/kernel.h>
17 #include <linux/interrupt.h>
18 #include <linux/kernel_stat.h>
19 #include <linux/time.h>
20 #include <linux/ftrace.h>
21
22 #include <asm/cpu.h>
23 #include <asm/mipsregs.h>
24 #include <asm/io.h>
25 #include <asm/irq.h>
26 #include <asm/time.h>
27 #include <asm/sgialib.h>
28 #include <asm/sgi/ioc.h>
29 #include <asm/sgi/hpc3.h>
30 #include <asm/sgi/ip22.h>
31
32 static unsigned long dosample(void)
33 {
34 u32 ct0, ct1;
35 u8 msb;
36
37
38 sgint->tcword = (SGINT_TCWORD_CNT2 | SGINT_TCWORD_CALL |
39 SGINT_TCWORD_MRGEN);
40 sgint->tcnt2 = SGINT_TCSAMP_COUNTER & 0xff;
41 sgint->tcnt2 = SGINT_TCSAMP_COUNTER >> 8;
42
43
44 ct0 = read_c0_count();
45
46
47 do {
48 writeb(SGINT_TCWORD_CNT2 | SGINT_TCWORD_CLAT, &sgint->tcword);
49 (void) readb(&sgint->tcnt2);
50 msb = readb(&sgint->tcnt2);
51 ct1 = read_c0_count();
52 } while (msb);
53
54
55 writeb(SGINT_TCWORD_CNT2 | SGINT_TCWORD_CALL | SGINT_TCWORD_MSWST,
56 &sgint->tcword);
57
58
59
60
61
62
63 return (ct1 - ct0) / (500000/HZ) * (500000/HZ);
64 }
65
66
67
68
69 __init void plat_time_init(void)
70 {
71 unsigned long r4k_ticks[3];
72 unsigned long r4k_tick;
73
74
75
76
77
78
79
80
81
82
83 printk(KERN_INFO "Calibrating system timer... ");
84 dosample();
85 dosample();
86
87 do {
88 r4k_ticks[0] = dosample();
89 } while (!r4k_ticks[0]);
90 do {
91 r4k_ticks[1] = dosample();
92 } while (!r4k_ticks[1]);
93
94 if (r4k_ticks[0] != r4k_ticks[1]) {
95 printk("warning: timer counts differ, retrying... ");
96 r4k_ticks[2] = dosample();
97 if (r4k_ticks[2] == r4k_ticks[0]
98 || r4k_ticks[2] == r4k_ticks[1])
99 r4k_tick = r4k_ticks[2];
100 else {
101 printk("disagreement, using average... ");
102 r4k_tick = (r4k_ticks[0] + r4k_ticks[1]
103 + r4k_ticks[2]) / 3;
104 }
105 } else
106 r4k_tick = r4k_ticks[0];
107
108 printk("%d [%d.%04d MHz CPU]\n", (int) r4k_tick,
109 (int) (r4k_tick / (500000 / HZ)),
110 (int) (r4k_tick % (500000 / HZ)));
111
112 mips_hpt_frequency = r4k_tick * HZ;
113
114 if (ip22_is_fullhouse())
115 setup_pit_timer();
116 }
117
118
119 void __irq_entry indy_8254timer_irq(void)
120 {
121 int irq = SGI_8254_0_IRQ;
122 ULONG cnt;
123 char c;
124
125 irq_enter();
126 kstat_incr_irq_this_cpu(irq);
127 printk(KERN_ALERT "Oops, got 8254 interrupt.\n");
128 ArcRead(0, &c, 1, &cnt);
129 ArcEnterInteractiveMode();
130 irq_exit();
131 }