diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2007-10-18 12:48:11 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2007-10-18 13:11:47 -0400 |
commit | 42f77542f4a1c104bb6fbba2e18e04e84415a96b (patch) | |
tree | 79b58e2d3e93abacbdd535684e2627231d2e0ffc /arch/mips/kernel | |
parent | 2cfa7660dbf94a61b9d43edaa84be454f9dc25fc (diff) |
[MIPS] time: Move R4000 clockevent device code to separate configurable file
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/kernel')
-rw-r--r-- | arch/mips/kernel/Makefile | 2 | ||||
-rw-r--r-- | arch/mips/kernel/cevt-r4k.c | 272 | ||||
-rw-r--r-- | arch/mips/kernel/time.c | 241 | ||||
-rw-r--r-- | arch/mips/kernel/traps.c | 11 |
4 files changed, 285 insertions, 241 deletions
diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile index 95a356ef3910..a3afa39faae5 100644 --- a/arch/mips/kernel/Makefile +++ b/arch/mips/kernel/Makefile | |||
@@ -8,6 +8,8 @@ obj-y += cpu-probe.o branch.o entry.o genex.o irq.o process.o \ | |||
8 | ptrace.o reset.o semaphore.o setup.o signal.o syscall.o \ | 8 | ptrace.o reset.o semaphore.o setup.o signal.o syscall.o \ |
9 | time.o topology.o traps.o unaligned.o | 9 | time.o topology.o traps.o unaligned.o |
10 | 10 | ||
11 | obj-$(CONFIG_CEVT_R4K) += cevt-r4k.o | ||
12 | |||
11 | binfmt_irix-objs := irixelf.o irixinv.o irixioctl.o irixsig.o \ | 13 | binfmt_irix-objs := irixelf.o irixinv.o irixioctl.o irixsig.o \ |
12 | irix5sys.o sysirix.o | 14 | irix5sys.o sysirix.o |
13 | 15 | ||
diff --git a/arch/mips/kernel/cevt-r4k.c b/arch/mips/kernel/cevt-r4k.c new file mode 100644 index 000000000000..08b84d476c87 --- /dev/null +++ b/arch/mips/kernel/cevt-r4k.c | |||
@@ -0,0 +1,272 @@ | |||
1 | /* | ||
2 | * This file is subject to the terms and conditions of the GNU General Public | ||
3 | * License. See the file "COPYING" in the main directory of this archive | ||
4 | * for more details. | ||
5 | * | ||
6 | * Copyright (C) 2007 MIPS Technologies, Inc. | ||
7 | * Copyright (C) 2007 Ralf Baechle <ralf@linux-mips.org> | ||
8 | */ | ||
9 | #include <linux/clockchips.h> | ||
10 | #include <linux/interrupt.h> | ||
11 | #include <linux/percpu.h> | ||
12 | |||
13 | #include <asm/time.h> | ||
14 | |||
15 | static int mips_next_event(unsigned long delta, | ||
16 | struct clock_event_device *evt) | ||
17 | { | ||
18 | unsigned int cnt; | ||
19 | int res; | ||
20 | |||
21 | #ifdef CONFIG_MIPS_MT_SMTC | ||
22 | { | ||
23 | unsigned long flags, vpflags; | ||
24 | local_irq_save(flags); | ||
25 | vpflags = dvpe(); | ||
26 | #endif | ||
27 | cnt = read_c0_count(); | ||
28 | cnt += delta; | ||
29 | write_c0_compare(cnt); | ||
30 | res = ((long)(read_c0_count() - cnt ) > 0) ? -ETIME : 0; | ||
31 | #ifdef CONFIG_MIPS_MT_SMTC | ||
32 | evpe(vpflags); | ||
33 | local_irq_restore(flags); | ||
34 | } | ||
35 | #endif | ||
36 | return res; | ||
37 | } | ||
38 | |||
39 | static void mips_set_mode(enum clock_event_mode mode, | ||
40 | struct clock_event_device *evt) | ||
41 | { | ||
42 | /* Nothing to do ... */ | ||
43 | } | ||
44 | |||
45 | static DEFINE_PER_CPU(struct clock_event_device, mips_clockevent_device); | ||
46 | static int cp0_timer_irq_installed; | ||
47 | |||
48 | /* | ||
49 | * Timer ack for an R4k-compatible timer of a known frequency. | ||
50 | */ | ||
51 | static void c0_timer_ack(void) | ||
52 | { | ||
53 | write_c0_compare(read_c0_compare()); | ||
54 | } | ||
55 | |||
56 | /* | ||
57 | * Possibly handle a performance counter interrupt. | ||
58 | * Return true if the timer interrupt should not be checked | ||
59 | */ | ||
60 | static inline int handle_perf_irq(int r2) | ||
61 | { | ||
62 | /* | ||
63 | * The performance counter overflow interrupt may be shared with the | ||
64 | * timer interrupt (cp0_perfcount_irq < 0). If it is and a | ||
65 | * performance counter has overflowed (perf_irq() == IRQ_HANDLED) | ||
66 | * and we can't reliably determine if a counter interrupt has also | ||
67 | * happened (!r2) then don't check for a timer interrupt. | ||
68 | */ | ||
69 | return (cp0_perfcount_irq < 0) && | ||
70 | perf_irq() == IRQ_HANDLED && | ||
71 | !r2; | ||
72 | } | ||
73 | |||
74 | static irqreturn_t c0_compare_interrupt(int irq, void *dev_id) | ||
75 | { | ||
76 | const int r2 = cpu_has_mips_r2; | ||
77 | struct clock_event_device *cd; | ||
78 | int cpu = smp_processor_id(); | ||
79 | |||
80 | /* | ||
81 | * Suckage alert: | ||
82 | * Before R2 of the architecture there was no way to see if a | ||
83 | * performance counter interrupt was pending, so we have to run | ||
84 | * the performance counter interrupt handler anyway. | ||
85 | */ | ||
86 | if (handle_perf_irq(r2)) | ||
87 | goto out; | ||
88 | |||
89 | /* | ||
90 | * The same applies to performance counter interrupts. But with the | ||
91 | * above we now know that the reason we got here must be a timer | ||
92 | * interrupt. Being the paranoiacs we are we check anyway. | ||
93 | */ | ||
94 | if (!r2 || (read_c0_cause() & (1 << 30))) { | ||
95 | c0_timer_ack(); | ||
96 | #ifdef CONFIG_MIPS_MT_SMTC | ||
97 | if (cpu_data[cpu].vpe_id) | ||
98 | goto out; | ||
99 | cpu = 0; | ||
100 | #endif | ||
101 | cd = &per_cpu(mips_clockevent_device, cpu); | ||
102 | cd->event_handler(cd); | ||
103 | } | ||
104 | |||
105 | out: | ||
106 | return IRQ_HANDLED; | ||
107 | } | ||
108 | |||
109 | static struct irqaction c0_compare_irqaction = { | ||
110 | .handler = c0_compare_interrupt, | ||
111 | #ifdef CONFIG_MIPS_MT_SMTC | ||
112 | .flags = IRQF_DISABLED, | ||
113 | #else | ||
114 | .flags = IRQF_DISABLED | IRQF_PERCPU, | ||
115 | #endif | ||
116 | .name = "timer", | ||
117 | }; | ||
118 | |||
119 | #ifdef CONFIG_MIPS_MT_SMTC | ||
120 | DEFINE_PER_CPU(struct clock_event_device, smtc_dummy_clockevent_device); | ||
121 | |||
122 | static void smtc_set_mode(enum clock_event_mode mode, | ||
123 | struct clock_event_device *evt) | ||
124 | { | ||
125 | } | ||
126 | |||
127 | static void mips_broadcast(cpumask_t mask) | ||
128 | { | ||
129 | unsigned int cpu; | ||
130 | |||
131 | for_each_cpu_mask(cpu, mask) | ||
132 | smtc_send_ipi(cpu, SMTC_CLOCK_TICK, 0); | ||
133 | } | ||
134 | |||
135 | static void setup_smtc_dummy_clockevent_device(void) | ||
136 | { | ||
137 | //uint64_t mips_freq = mips_hpt_^frequency; | ||
138 | unsigned int cpu = smp_processor_id(); | ||
139 | struct clock_event_device *cd; | ||
140 | |||
141 | cd = &per_cpu(smtc_dummy_clockevent_device, cpu); | ||
142 | |||
143 | cd->name = "SMTC"; | ||
144 | cd->features = CLOCK_EVT_FEAT_DUMMY; | ||
145 | |||
146 | /* Calculate the min / max delta */ | ||
147 | cd->mult = 0; //div_sc((unsigned long) mips_freq, NSEC_PER_SEC, 32); | ||
148 | cd->shift = 0; //32; | ||
149 | cd->max_delta_ns = 0; //clockevent_delta2ns(0x7fffffff, cd); | ||
150 | cd->min_delta_ns = 0; //clockevent_delta2ns(0x30, cd); | ||
151 | |||
152 | cd->rating = 200; | ||
153 | cd->irq = 17; //-1; | ||
154 | // if (cpu) | ||
155 | // cd->cpumask = CPU_MASK_ALL; // cpumask_of_cpu(cpu); | ||
156 | // else | ||
157 | cd->cpumask = cpumask_of_cpu(cpu); | ||
158 | |||
159 | cd->set_mode = smtc_set_mode; | ||
160 | |||
161 | cd->broadcast = mips_broadcast; | ||
162 | |||
163 | clockevents_register_device(cd); | ||
164 | } | ||
165 | #endif | ||
166 | |||
167 | static void mips_event_handler(struct clock_event_device *dev) | ||
168 | { | ||
169 | } | ||
170 | |||
171 | /* | ||
172 | * FIXME: This doesn't hold for the relocated E9000 compare interrupt. | ||
173 | */ | ||
174 | static int c0_compare_int_pending(void) | ||
175 | { | ||
176 | return (read_c0_cause() >> cp0_compare_irq) & 0x100; | ||
177 | } | ||
178 | |||
179 | static int c0_compare_int_usable(void) | ||
180 | { | ||
181 | const unsigned int delta = 0x300000; | ||
182 | unsigned int cnt; | ||
183 | |||
184 | /* | ||
185 | * IP7 already pending? Try to clear it by acking the timer. | ||
186 | */ | ||
187 | if (c0_compare_int_pending()) { | ||
188 | write_c0_compare(read_c0_compare()); | ||
189 | irq_disable_hazard(); | ||
190 | if (c0_compare_int_pending()) | ||
191 | return 0; | ||
192 | } | ||
193 | |||
194 | cnt = read_c0_count(); | ||
195 | cnt += delta; | ||
196 | write_c0_compare(cnt); | ||
197 | |||
198 | while ((long)(read_c0_count() - cnt) <= 0) | ||
199 | ; /* Wait for expiry */ | ||
200 | |||
201 | if (!c0_compare_int_pending()) | ||
202 | return 0; | ||
203 | |||
204 | write_c0_compare(read_c0_compare()); | ||
205 | irq_disable_hazard(); | ||
206 | if (c0_compare_int_pending()) | ||
207 | return 0; | ||
208 | |||
209 | /* | ||
210 | * Feels like a real count / compare timer. | ||
211 | */ | ||
212 | return 1; | ||
213 | } | ||
214 | |||
215 | void __cpuinit mips_clockevent_init(void) | ||
216 | { | ||
217 | uint64_t mips_freq = mips_hpt_frequency; | ||
218 | unsigned int cpu = smp_processor_id(); | ||
219 | struct clock_event_device *cd; | ||
220 | unsigned int irq = MIPS_CPU_IRQ_BASE + 7; | ||
221 | |||
222 | if (!cpu_has_counter) | ||
223 | return; | ||
224 | |||
225 | #ifdef CONFIG_MIPS_MT_SMTC | ||
226 | setup_smtc_dummy_clockevent_device(); | ||
227 | |||
228 | /* | ||
229 | * On SMTC we only register VPE0's compare interrupt as clockevent | ||
230 | * device. | ||
231 | */ | ||
232 | if (cpu) | ||
233 | return; | ||
234 | #endif | ||
235 | |||
236 | if (!c0_compare_int_usable()) | ||
237 | return; | ||
238 | |||
239 | cd = &per_cpu(mips_clockevent_device, cpu); | ||
240 | |||
241 | cd->name = "MIPS"; | ||
242 | cd->features = CLOCK_EVT_FEAT_ONESHOT; | ||
243 | |||
244 | /* Calculate the min / max delta */ | ||
245 | cd->mult = div_sc((unsigned long) mips_freq, NSEC_PER_SEC, 32); | ||
246 | cd->shift = 32; | ||
247 | cd->max_delta_ns = clockevent_delta2ns(0x7fffffff, cd); | ||
248 | cd->min_delta_ns = clockevent_delta2ns(0x300, cd); | ||
249 | |||
250 | cd->rating = 300; | ||
251 | cd->irq = irq; | ||
252 | #ifdef CONFIG_MIPS_MT_SMTC | ||
253 | cd->cpumask = CPU_MASK_ALL; | ||
254 | #else | ||
255 | cd->cpumask = cpumask_of_cpu(cpu); | ||
256 | #endif | ||
257 | cd->set_next_event = mips_next_event; | ||
258 | cd->set_mode = mips_set_mode; | ||
259 | cd->event_handler = mips_event_handler; | ||
260 | |||
261 | clockevents_register_device(cd); | ||
262 | |||
263 | if (!cp0_timer_irq_installed) { | ||
264 | #ifdef CONFIG_MIPS_MT_SMTC | ||
265 | #define CPUCTR_IMASKBIT (0x100 << cp0_compare_irq) | ||
266 | setup_irq_smtc(irq, &c0_compare_irqaction, CPUCTR_IMASKBIT); | ||
267 | #else | ||
268 | setup_irq(irq, &c0_compare_irqaction); | ||
269 | #endif /* CONFIG_MIPS_MT_SMTC */ | ||
270 | cp0_timer_irq_installed = 1; | ||
271 | } | ||
272 | } | ||
diff --git a/arch/mips/kernel/time.c b/arch/mips/kernel/time.c index abadb8cb77c0..ea7cfe766a8e 100644 --- a/arch/mips/kernel/time.c +++ b/arch/mips/kernel/time.c | |||
@@ -81,14 +81,6 @@ static cycle_t null_hpt_read(void) | |||
81 | } | 81 | } |
82 | 82 | ||
83 | /* | 83 | /* |
84 | * Timer ack for an R4k-compatible timer of a known frequency. | ||
85 | */ | ||
86 | static void c0_timer_ack(void) | ||
87 | { | ||
88 | write_c0_compare(read_c0_compare()); | ||
89 | } | ||
90 | |||
91 | /* | ||
92 | * High precision timer functions for a R4k-compatible timer. | 84 | * High precision timer functions for a R4k-compatible timer. |
93 | */ | 85 | */ |
94 | static cycle_t c0_hpt_read(void) | 86 | static cycle_t c0_hpt_read(void) |
@@ -126,35 +118,6 @@ int (*perf_irq)(void) = null_perf_irq; | |||
126 | EXPORT_SYMBOL(perf_irq); | 118 | EXPORT_SYMBOL(perf_irq); |
127 | 119 | ||
128 | /* | 120 | /* |
129 | * Timer interrupt | ||
130 | */ | ||
131 | int cp0_compare_irq; | ||
132 | |||
133 | /* | ||
134 | * Performance counter IRQ or -1 if shared with timer | ||
135 | */ | ||
136 | int cp0_perfcount_irq; | ||
137 | EXPORT_SYMBOL_GPL(cp0_perfcount_irq); | ||
138 | |||
139 | /* | ||
140 | * Possibly handle a performance counter interrupt. | ||
141 | * Return true if the timer interrupt should not be checked | ||
142 | */ | ||
143 | static inline int handle_perf_irq(int r2) | ||
144 | { | ||
145 | /* | ||
146 | * The performance counter overflow interrupt may be shared with the | ||
147 | * timer interrupt (cp0_perfcount_irq < 0). If it is and a | ||
148 | * performance counter has overflowed (perf_irq() == IRQ_HANDLED) | ||
149 | * and we can't reliably determine if a counter interrupt has also | ||
150 | * happened (!r2) then don't check for a timer interrupt. | ||
151 | */ | ||
152 | return (cp0_perfcount_irq < 0) && | ||
153 | perf_irq() == IRQ_HANDLED && | ||
154 | !r2; | ||
155 | } | ||
156 | |||
157 | /* | ||
158 | * time_init() - it does the following things. | 121 | * time_init() - it does the following things. |
159 | * | 122 | * |
160 | * 1) plat_time_init() - | 123 | * 1) plat_time_init() - |
@@ -219,84 +182,6 @@ struct clocksource clocksource_mips = { | |||
219 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, | 182 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, |
220 | }; | 183 | }; |
221 | 184 | ||
222 | static int mips_next_event(unsigned long delta, | ||
223 | struct clock_event_device *evt) | ||
224 | { | ||
225 | unsigned int cnt; | ||
226 | int res; | ||
227 | |||
228 | #ifdef CONFIG_MIPS_MT_SMTC | ||
229 | { | ||
230 | unsigned long flags, vpflags; | ||
231 | local_irq_save(flags); | ||
232 | vpflags = dvpe(); | ||
233 | #endif | ||
234 | cnt = read_c0_count(); | ||
235 | cnt += delta; | ||
236 | write_c0_compare(cnt); | ||
237 | res = ((long)(read_c0_count() - cnt ) > 0) ? -ETIME : 0; | ||
238 | #ifdef CONFIG_MIPS_MT_SMTC | ||
239 | evpe(vpflags); | ||
240 | local_irq_restore(flags); | ||
241 | } | ||
242 | #endif | ||
243 | return res; | ||
244 | } | ||
245 | |||
246 | static void mips_set_mode(enum clock_event_mode mode, | ||
247 | struct clock_event_device *evt) | ||
248 | { | ||
249 | /* Nothing to do ... */ | ||
250 | } | ||
251 | |||
252 | static DEFINE_PER_CPU(struct clock_event_device, mips_clockevent_device); | ||
253 | static int cp0_timer_irq_installed; | ||
254 | |||
255 | static irqreturn_t timer_interrupt(int irq, void *dev_id) | ||
256 | { | ||
257 | const int r2 = cpu_has_mips_r2; | ||
258 | struct clock_event_device *cd; | ||
259 | int cpu = smp_processor_id(); | ||
260 | |||
261 | /* | ||
262 | * Suckage alert: | ||
263 | * Before R2 of the architecture there was no way to see if a | ||
264 | * performance counter interrupt was pending, so we have to run | ||
265 | * the performance counter interrupt handler anyway. | ||
266 | */ | ||
267 | if (handle_perf_irq(r2)) | ||
268 | goto out; | ||
269 | |||
270 | /* | ||
271 | * The same applies to performance counter interrupts. But with the | ||
272 | * above we now know that the reason we got here must be a timer | ||
273 | * interrupt. Being the paranoiacs we are we check anyway. | ||
274 | */ | ||
275 | if (!r2 || (read_c0_cause() & (1 << 30))) { | ||
276 | c0_timer_ack(); | ||
277 | #ifdef CONFIG_MIPS_MT_SMTC | ||
278 | if (cpu_data[cpu].vpe_id) | ||
279 | goto out; | ||
280 | cpu = 0; | ||
281 | #endif | ||
282 | cd = &per_cpu(mips_clockevent_device, cpu); | ||
283 | cd->event_handler(cd); | ||
284 | } | ||
285 | |||
286 | out: | ||
287 | return IRQ_HANDLED; | ||
288 | } | ||
289 | |||
290 | static struct irqaction timer_irqaction = { | ||
291 | .handler = timer_interrupt, | ||
292 | #ifdef CONFIG_MIPS_MT_SMTC | ||
293 | .flags = IRQF_DISABLED, | ||
294 | #else | ||
295 | .flags = IRQF_DISABLED | IRQF_PERCPU, | ||
296 | #endif | ||
297 | .name = "timer", | ||
298 | }; | ||
299 | |||
300 | static void __init init_mips_clocksource(void) | 185 | static void __init init_mips_clocksource(void) |
301 | { | 186 | { |
302 | u64 temp; | 187 | u64 temp; |
@@ -336,8 +221,6 @@ static void smtc_set_mode(enum clock_event_mode mode, | |||
336 | { | 221 | { |
337 | } | 222 | } |
338 | 223 | ||
339 | int dummycnt[NR_CPUS]; | ||
340 | |||
341 | static void mips_broadcast(cpumask_t mask) | 224 | static void mips_broadcast(cpumask_t mask) |
342 | { | 225 | { |
343 | unsigned int cpu; | 226 | unsigned int cpu; |
@@ -378,113 +261,6 @@ static void setup_smtc_dummy_clockevent_device(void) | |||
378 | } | 261 | } |
379 | #endif | 262 | #endif |
380 | 263 | ||
381 | static void mips_event_handler(struct clock_event_device *dev) | ||
382 | { | ||
383 | } | ||
384 | |||
385 | /* | ||
386 | * FIXME: This doesn't hold for the relocated E9000 compare interrupt. | ||
387 | */ | ||
388 | static int c0_compare_int_pending(void) | ||
389 | { | ||
390 | return (read_c0_cause() >> cp0_compare_irq) & 0x100; | ||
391 | } | ||
392 | |||
393 | static int c0_compare_int_usable(void) | ||
394 | { | ||
395 | const unsigned int delta = 0x300000; | ||
396 | unsigned int cnt; | ||
397 | |||
398 | /* | ||
399 | * IP7 already pending? Try to clear it by acking the timer. | ||
400 | */ | ||
401 | if (c0_compare_int_pending()) { | ||
402 | write_c0_compare(read_c0_compare()); | ||
403 | irq_disable_hazard(); | ||
404 | if (c0_compare_int_pending()) | ||
405 | return 0; | ||
406 | } | ||
407 | |||
408 | cnt = read_c0_count(); | ||
409 | cnt += delta; | ||
410 | write_c0_compare(cnt); | ||
411 | |||
412 | while ((long)(read_c0_count() - cnt) <= 0) | ||
413 | ; /* Wait for expiry */ | ||
414 | |||
415 | if (!c0_compare_int_pending()) | ||
416 | return 0; | ||
417 | |||
418 | write_c0_compare(read_c0_compare()); | ||
419 | irq_disable_hazard(); | ||
420 | if (c0_compare_int_pending()) | ||
421 | return 0; | ||
422 | |||
423 | /* | ||
424 | * Feels like a real count / compare timer. | ||
425 | */ | ||
426 | return 1; | ||
427 | } | ||
428 | |||
429 | void __cpuinit mips_clockevent_init(void) | ||
430 | { | ||
431 | uint64_t mips_freq = mips_hpt_frequency; | ||
432 | unsigned int cpu = smp_processor_id(); | ||
433 | struct clock_event_device *cd; | ||
434 | unsigned int irq = MIPS_CPU_IRQ_BASE + 7; | ||
435 | |||
436 | if (!cpu_has_counter) | ||
437 | return; | ||
438 | |||
439 | #ifdef CONFIG_MIPS_MT_SMTC | ||
440 | setup_smtc_dummy_clockevent_device(); | ||
441 | |||
442 | /* | ||
443 | * On SMTC we only register VPE0's compare interrupt as clockevent | ||
444 | * device. | ||
445 | */ | ||
446 | if (cpu) | ||
447 | return; | ||
448 | #endif | ||
449 | |||
450 | if (!c0_compare_int_usable()) | ||
451 | return; | ||
452 | |||
453 | cd = &per_cpu(mips_clockevent_device, cpu); | ||
454 | |||
455 | cd->name = "MIPS"; | ||
456 | cd->features = CLOCK_EVT_FEAT_ONESHOT; | ||
457 | |||
458 | /* Calculate the min / max delta */ | ||
459 | cd->mult = div_sc((unsigned long) mips_freq, NSEC_PER_SEC, 32); | ||
460 | cd->shift = 32; | ||
461 | cd->max_delta_ns = clockevent_delta2ns(0x7fffffff, cd); | ||
462 | cd->min_delta_ns = clockevent_delta2ns(0x300, cd); | ||
463 | |||
464 | cd->rating = 300; | ||
465 | cd->irq = irq; | ||
466 | #ifdef CONFIG_MIPS_MT_SMTC | ||
467 | cd->cpumask = CPU_MASK_ALL; | ||
468 | #else | ||
469 | cd->cpumask = cpumask_of_cpu(cpu); | ||
470 | #endif | ||
471 | cd->set_next_event = mips_next_event; | ||
472 | cd->set_mode = mips_set_mode; | ||
473 | cd->event_handler = mips_event_handler; | ||
474 | |||
475 | clockevents_register_device(cd); | ||
476 | |||
477 | if (!cp0_timer_irq_installed) { | ||
478 | #ifdef CONFIG_MIPS_MT_SMTC | ||
479 | #define CPUCTR_IMASKBIT (0x100 << cp0_compare_irq) | ||
480 | setup_irq_smtc(irq, &timer_irqaction, CPUCTR_IMASKBIT); | ||
481 | #else | ||
482 | setup_irq(irq, &timer_irqaction); | ||
483 | #endif /* CONFIG_MIPS_MT_SMTC */ | ||
484 | cp0_timer_irq_installed = 1; | ||
485 | } | ||
486 | } | ||
487 | |||
488 | void __init time_init(void) | 264 | void __init time_init(void) |
489 | { | 265 | { |
490 | plat_time_init(); | 266 | plat_time_init(); |
@@ -511,25 +287,8 @@ void __init time_init(void) | |||
511 | printk("Using %u.%03u MHz high precision timer.\n", | 287 | printk("Using %u.%03u MHz high precision timer.\n", |
512 | ((mips_hpt_frequency + 500) / 1000) / 1000, | 288 | ((mips_hpt_frequency + 500) / 1000) / 1000, |
513 | ((mips_hpt_frequency + 500) / 1000) % 1000); | 289 | ((mips_hpt_frequency + 500) / 1000) % 1000); |
514 | |||
515 | #ifdef CONFIG_IRQ_CPU | ||
516 | setup_irq(MIPS_CPU_IRQ_BASE + 7, &timer_irqaction); | ||
517 | #endif | ||
518 | } | 290 | } |
519 | 291 | ||
520 | /* | ||
521 | * Call board specific timer interrupt setup. | ||
522 | * | ||
523 | * this pointer must be setup in machine setup routine. | ||
524 | * | ||
525 | * Even if a machine chooses to use a low-level timer interrupt, | ||
526 | * it still needs to setup the timer_irqaction. | ||
527 | * In that case, it might be better to set timer_irqaction.handler | ||
528 | * to be NULL function so that we are sure the high-level code | ||
529 | * is not invoked accidentally. | ||
530 | */ | ||
531 | plat_timer_setup(&timer_irqaction); | ||
532 | |||
533 | init_mips_clocksource(); | 292 | init_mips_clocksource(); |
534 | mips_clockevent_init(); | 293 | mips_clockevent_init(); |
535 | } | 294 | } |
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c index bbf01b81a4ff..7b78d137259f 100644 --- a/arch/mips/kernel/traps.c +++ b/arch/mips/kernel/traps.c | |||
@@ -1336,6 +1336,17 @@ extern void cpu_cache_init(void); | |||
1336 | extern void tlb_init(void); | 1336 | extern void tlb_init(void); |
1337 | extern void flush_tlb_handlers(void); | 1337 | extern void flush_tlb_handlers(void); |
1338 | 1338 | ||
1339 | /* | ||
1340 | * Timer interrupt | ||
1341 | */ | ||
1342 | int cp0_compare_irq; | ||
1343 | |||
1344 | /* | ||
1345 | * Performance counter IRQ or -1 if shared with timer | ||
1346 | */ | ||
1347 | int cp0_perfcount_irq; | ||
1348 | EXPORT_SYMBOL_GPL(cp0_perfcount_irq); | ||
1349 | |||
1339 | void __init per_cpu_trap_init(void) | 1350 | void __init per_cpu_trap_init(void) |
1340 | { | 1351 | { |
1341 | unsigned int cpu = smp_processor_id(); | 1352 | unsigned int cpu = smp_processor_id(); |