blob: c02218b3ae2b23b51056a0d36c3a48258ba87a08 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Local APIC handling, local APIC timers
3 *
4 * (c) 1999, 2000 Ingo Molnar <mingo@redhat.com>
5 *
6 * Fixes
7 * Maciej W. Rozycki : Bits for genuine 82489DX APICs;
8 * thanks to Eric Gilmore
9 * and Rolf G. Tews
10 * for testing these extensively.
11 * Maciej W. Rozycki : Various updates and fixes.
12 * Mikael Pettersson : Power Management for UP-APIC.
13 * Pavel Machek and
14 * Mikael Pettersson : PM converted to driver model.
15 */
16
17#include <linux/config.h>
18#include <linux/init.h>
19
20#include <linux/mm.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <linux/delay.h>
22#include <linux/bootmem.h>
23#include <linux/smp_lock.h>
24#include <linux/interrupt.h>
25#include <linux/mc146818rtc.h>
26#include <linux/kernel_stat.h>
27#include <linux/sysdev.h>
Venkatesh Pallipadid25bf7e2006-01-11 22:44:24 +010028#include <linux/module.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070029
30#include <asm/atomic.h>
31#include <asm/smp.h>
32#include <asm/mtrr.h>
33#include <asm/mpspec.h>
34#include <asm/pgalloc.h>
35#include <asm/mach_apic.h>
Andi Kleen75152112005-05-16 21:53:34 -070036#include <asm/nmi.h>
Andi Kleen95833c82006-01-11 22:44:36 +010037#include <asm/idle.h>
Andi Kleen73dea472006-02-03 21:50:50 +010038#include <asm/proto.h>
39#include <asm/timex.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
41int apic_verbosity;
Andi Kleen73dea472006-02-03 21:50:50 +010042int apic_runs_main_timer;
Andi Kleen0c3749c2006-02-03 21:51:41 +010043int apic_calibrate_pmtmr __initdata;
Linus Torvalds1da177e2005-04-16 15:20:36 -070044
45int disable_apic_timer __initdata;
46
Venkatesh Pallipadid25bf7e2006-01-11 22:44:24 +010047/*
48 * cpu_mask that denotes the CPUs that needs timer interrupt coming in as
49 * IPIs in place of local APIC timers
50 */
51static cpumask_t timer_interrupt_broadcast_ipi_mask;
52
Linus Torvalds1da177e2005-04-16 15:20:36 -070053/* Using APIC to generate smp_local_timer_interrupt? */
54int using_apic_timer = 0;
55
Linus Torvalds1da177e2005-04-16 15:20:36 -070056static void apic_pm_activate(void);
57
58void enable_NMI_through_LVT0 (void * dummy)
59{
Andi Kleen11a8e772006-01-11 22:46:51 +010060 unsigned int v;
Linus Torvalds1da177e2005-04-16 15:20:36 -070061
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 v = APIC_DM_NMI; /* unmask and set to NMI */
Andi Kleen11a8e772006-01-11 22:46:51 +010063 apic_write(APIC_LVT0, v);
Linus Torvalds1da177e2005-04-16 15:20:36 -070064}
65
66int get_maxlvt(void)
67{
Andi Kleen11a8e772006-01-11 22:46:51 +010068 unsigned int v, maxlvt;
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
70 v = apic_read(APIC_LVR);
Linus Torvalds1da177e2005-04-16 15:20:36 -070071 maxlvt = GET_APIC_MAXLVT(v);
72 return maxlvt;
73}
74
75void clear_local_APIC(void)
76{
77 int maxlvt;
78 unsigned int v;
79
80 maxlvt = get_maxlvt();
81
82 /*
83 * Masking an LVT entry on a P6 can trigger a local APIC error
84 * if the vector is zero. Mask LVTERR first to prevent this.
85 */
86 if (maxlvt >= 3) {
87 v = ERROR_APIC_VECTOR; /* any non-zero vector will do */
Andi Kleen11a8e772006-01-11 22:46:51 +010088 apic_write(APIC_LVTERR, v | APIC_LVT_MASKED);
Linus Torvalds1da177e2005-04-16 15:20:36 -070089 }
90 /*
91 * Careful: we have to set masks only first to deassert
92 * any level-triggered sources.
93 */
94 v = apic_read(APIC_LVTT);
Andi Kleen11a8e772006-01-11 22:46:51 +010095 apic_write(APIC_LVTT, v | APIC_LVT_MASKED);
Linus Torvalds1da177e2005-04-16 15:20:36 -070096 v = apic_read(APIC_LVT0);
Andi Kleen11a8e772006-01-11 22:46:51 +010097 apic_write(APIC_LVT0, v | APIC_LVT_MASKED);
Linus Torvalds1da177e2005-04-16 15:20:36 -070098 v = apic_read(APIC_LVT1);
Andi Kleen11a8e772006-01-11 22:46:51 +010099 apic_write(APIC_LVT1, v | APIC_LVT_MASKED);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100 if (maxlvt >= 4) {
101 v = apic_read(APIC_LVTPC);
Andi Kleen11a8e772006-01-11 22:46:51 +0100102 apic_write(APIC_LVTPC, v | APIC_LVT_MASKED);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 }
104
105 /*
106 * Clean APIC state for other OSs:
107 */
Andi Kleen11a8e772006-01-11 22:46:51 +0100108 apic_write(APIC_LVTT, APIC_LVT_MASKED);
109 apic_write(APIC_LVT0, APIC_LVT_MASKED);
110 apic_write(APIC_LVT1, APIC_LVT_MASKED);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111 if (maxlvt >= 3)
Andi Kleen11a8e772006-01-11 22:46:51 +0100112 apic_write(APIC_LVTERR, APIC_LVT_MASKED);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113 if (maxlvt >= 4)
Andi Kleen11a8e772006-01-11 22:46:51 +0100114 apic_write(APIC_LVTPC, APIC_LVT_MASKED);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 v = GET_APIC_VERSION(apic_read(APIC_LVR));
Andi Kleen5a40b7c2005-09-12 18:49:24 +0200116 apic_write(APIC_ESR, 0);
117 apic_read(APIC_ESR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118}
119
120void __init connect_bsp_APIC(void)
121{
122 if (pic_mode) {
123 /*
124 * Do not trust the local APIC being empty at bootup.
125 */
126 clear_local_APIC();
127 /*
128 * PIC mode, enable APIC mode in the IMCR, i.e.
129 * connect BSP's local APIC to INT and NMI lines.
130 */
131 apic_printk(APIC_VERBOSE, "leaving PIC mode, enabling APIC mode.\n");
132 outb(0x70, 0x22);
133 outb(0x01, 0x23);
134 }
135}
136
Eric W. Biederman208fb932005-06-25 14:57:45 -0700137void disconnect_bsp_APIC(int virt_wire_setup)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138{
139 if (pic_mode) {
140 /*
141 * Put the board back into PIC mode (has an effect
142 * only on certain older boards). Note that APIC
143 * interrupts, including IPIs, won't work beyond
144 * this point! The only exception are INIT IPIs.
145 */
146 apic_printk(APIC_QUIET, "disabling APIC mode, entering PIC mode.\n");
147 outb(0x70, 0x22);
148 outb(0x00, 0x23);
149 }
Eric W. Biederman208fb932005-06-25 14:57:45 -0700150 else {
151 /* Go back to Virtual Wire compatibility mode */
152 unsigned long value;
153
154 /* For the spurious interrupt use vector F, and enable it */
155 value = apic_read(APIC_SPIV);
156 value &= ~APIC_VECTOR_MASK;
157 value |= APIC_SPIV_APIC_ENABLED;
158 value |= 0xf;
Andi Kleen11a8e772006-01-11 22:46:51 +0100159 apic_write(APIC_SPIV, value);
Eric W. Biederman208fb932005-06-25 14:57:45 -0700160
161 if (!virt_wire_setup) {
162 /* For LVT0 make it edge triggered, active high, external and enabled */
163 value = apic_read(APIC_LVT0);
164 value &= ~(APIC_MODE_MASK | APIC_SEND_PENDING |
165 APIC_INPUT_POLARITY | APIC_LVT_REMOTE_IRR |
166 APIC_LVT_LEVEL_TRIGGER | APIC_LVT_MASKED );
167 value |= APIC_LVT_REMOTE_IRR | APIC_SEND_PENDING;
168 value = SET_APIC_DELIVERY_MODE(value, APIC_MODE_EXTINT);
Andi Kleen11a8e772006-01-11 22:46:51 +0100169 apic_write(APIC_LVT0, value);
Eric W. Biederman208fb932005-06-25 14:57:45 -0700170 }
171 else {
172 /* Disable LVT0 */
Andi Kleen11a8e772006-01-11 22:46:51 +0100173 apic_write(APIC_LVT0, APIC_LVT_MASKED);
Eric W. Biederman208fb932005-06-25 14:57:45 -0700174 }
175
176 /* For LVT1 make it edge triggered, active high, nmi and enabled */
177 value = apic_read(APIC_LVT1);
178 value &= ~(
179 APIC_MODE_MASK | APIC_SEND_PENDING |
180 APIC_INPUT_POLARITY | APIC_LVT_REMOTE_IRR |
181 APIC_LVT_LEVEL_TRIGGER | APIC_LVT_MASKED);
182 value |= APIC_LVT_REMOTE_IRR | APIC_SEND_PENDING;
183 value = SET_APIC_DELIVERY_MODE(value, APIC_MODE_NMI);
Andi Kleen11a8e772006-01-11 22:46:51 +0100184 apic_write(APIC_LVT1, value);
Eric W. Biederman208fb932005-06-25 14:57:45 -0700185 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186}
187
188void disable_local_APIC(void)
189{
190 unsigned int value;
191
192 clear_local_APIC();
193
194 /*
195 * Disable APIC (implies clearing of registers
196 * for 82489DX!).
197 */
198 value = apic_read(APIC_SPIV);
199 value &= ~APIC_SPIV_APIC_ENABLED;
Andi Kleen11a8e772006-01-11 22:46:51 +0100200 apic_write(APIC_SPIV, value);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201}
202
203/*
204 * This is to verify that we're looking at a real local APIC.
205 * Check these against your board if the CPUs aren't getting
206 * started for no apparent reason.
207 */
208int __init verify_local_APIC(void)
209{
210 unsigned int reg0, reg1;
211
212 /*
213 * The version register is read-only in a real APIC.
214 */
215 reg0 = apic_read(APIC_LVR);
216 apic_printk(APIC_DEBUG, "Getting VERSION: %x\n", reg0);
217 apic_write(APIC_LVR, reg0 ^ APIC_LVR_MASK);
218 reg1 = apic_read(APIC_LVR);
219 apic_printk(APIC_DEBUG, "Getting VERSION: %x\n", reg1);
220
221 /*
222 * The two version reads above should print the same
223 * numbers. If the second one is different, then we
224 * poke at a non-APIC.
225 */
226 if (reg1 != reg0)
227 return 0;
228
229 /*
230 * Check if the version looks reasonably.
231 */
232 reg1 = GET_APIC_VERSION(reg0);
233 if (reg1 == 0x00 || reg1 == 0xff)
234 return 0;
235 reg1 = get_maxlvt();
236 if (reg1 < 0x02 || reg1 == 0xff)
237 return 0;
238
239 /*
240 * The ID register is read/write in a real APIC.
241 */
242 reg0 = apic_read(APIC_ID);
243 apic_printk(APIC_DEBUG, "Getting ID: %x\n", reg0);
244 apic_write(APIC_ID, reg0 ^ APIC_ID_MASK);
245 reg1 = apic_read(APIC_ID);
246 apic_printk(APIC_DEBUG, "Getting ID: %x\n", reg1);
247 apic_write(APIC_ID, reg0);
248 if (reg1 != (reg0 ^ APIC_ID_MASK))
249 return 0;
250
251 /*
252 * The next two are just to see if we have sane values.
253 * They're only really relevant if we're in Virtual Wire
254 * compatibility mode, but most boxes are anymore.
255 */
256 reg0 = apic_read(APIC_LVT0);
257 apic_printk(APIC_DEBUG,"Getting LVT0: %x\n", reg0);
258 reg1 = apic_read(APIC_LVT1);
259 apic_printk(APIC_DEBUG, "Getting LVT1: %x\n", reg1);
260
261 return 1;
262}
263
264void __init sync_Arb_IDs(void)
265{
266 /* Unsupported on P4 - see Intel Dev. Manual Vol. 3, Ch. 8.6.1 */
267 unsigned int ver = GET_APIC_VERSION(apic_read(APIC_LVR));
268 if (ver >= 0x14) /* P4 or higher */
269 return;
270
271 /*
272 * Wait for idle.
273 */
274 apic_wait_icr_idle();
275
276 apic_printk(APIC_DEBUG, "Synchronizing Arb IDs.\n");
Andi Kleen11a8e772006-01-11 22:46:51 +0100277 apic_write(APIC_ICR, APIC_DEST_ALLINC | APIC_INT_LEVELTRIG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278 | APIC_DM_INIT);
279}
280
281extern void __error_in_apic_c (void);
282
283/*
284 * An initial setup of the virtual wire mode.
285 */
286void __init init_bsp_APIC(void)
287{
Andi Kleen11a8e772006-01-11 22:46:51 +0100288 unsigned int value;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289
290 /*
291 * Don't do the setup now if we have a SMP BIOS as the
292 * through-I/O-APIC virtual wire mode might be active.
293 */
294 if (smp_found_config || !cpu_has_apic)
295 return;
296
297 value = apic_read(APIC_LVR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298
299 /*
300 * Do not trust the local APIC being empty at bootup.
301 */
302 clear_local_APIC();
303
304 /*
305 * Enable APIC.
306 */
307 value = apic_read(APIC_SPIV);
308 value &= ~APIC_VECTOR_MASK;
309 value |= APIC_SPIV_APIC_ENABLED;
310 value |= APIC_SPIV_FOCUS_DISABLED;
311 value |= SPURIOUS_APIC_VECTOR;
Andi Kleen11a8e772006-01-11 22:46:51 +0100312 apic_write(APIC_SPIV, value);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313
314 /*
315 * Set up the virtual wire mode.
316 */
Andi Kleen11a8e772006-01-11 22:46:51 +0100317 apic_write(APIC_LVT0, APIC_DM_EXTINT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318 value = APIC_DM_NMI;
Andi Kleen11a8e772006-01-11 22:46:51 +0100319 apic_write(APIC_LVT1, value);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320}
321
Ashok Raje6982c62005-06-25 14:54:58 -0700322void __cpuinit setup_local_APIC (void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323{
Andi Kleen11a8e772006-01-11 22:46:51 +0100324 unsigned int value, maxlvt;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326 value = apic_read(APIC_LVR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327
328 if ((SPURIOUS_APIC_VECTOR & 0x0f) != 0x0f)
329 __error_in_apic_c();
330
331 /*
332 * Double-check whether this APIC is really registered.
333 * This is meaningless in clustered apic mode, so we skip it.
334 */
335 if (!apic_id_registered())
336 BUG();
337
338 /*
339 * Intel recommends to set DFR, LDR and TPR before enabling
340 * an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel
341 * document number 292116). So here it goes...
342 */
343 init_apic_ldr();
344
345 /*
346 * Set Task Priority to 'accept all'. We never change this
347 * later on.
348 */
349 value = apic_read(APIC_TASKPRI);
350 value &= ~APIC_TPRI_MASK;
Andi Kleen11a8e772006-01-11 22:46:51 +0100351 apic_write(APIC_TASKPRI, value);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352
353 /*
354 * Now that we are all set up, enable the APIC
355 */
356 value = apic_read(APIC_SPIV);
357 value &= ~APIC_VECTOR_MASK;
358 /*
359 * Enable APIC
360 */
361 value |= APIC_SPIV_APIC_ENABLED;
362
363 /*
364 * Some unknown Intel IO/APIC (or APIC) errata is biting us with
365 * certain networking cards. If high frequency interrupts are
366 * happening on a particular IOAPIC pin, plus the IOAPIC routing
367 * entry is masked/unmasked at a high rate as well then sooner or
368 * later IOAPIC line gets 'stuck', no more interrupts are received
369 * from the device. If focus CPU is disabled then the hang goes
370 * away, oh well :-(
371 *
372 * [ This bug can be reproduced easily with a level-triggered
373 * PCI Ne2000 networking cards and PII/PIII processors, dual
374 * BX chipset. ]
375 */
376 /*
377 * Actually disabling the focus CPU check just makes the hang less
378 * frequent as it makes the interrupt distributon model be more
379 * like LRU than MRU (the short-term load is more even across CPUs).
380 * See also the comment in end_level_ioapic_irq(). --macro
381 */
382#if 1
383 /* Enable focus processor (bit==0) */
384 value &= ~APIC_SPIV_FOCUS_DISABLED;
385#else
386 /* Disable focus processor (bit==1) */
387 value |= APIC_SPIV_FOCUS_DISABLED;
388#endif
389 /*
390 * Set spurious IRQ vector
391 */
392 value |= SPURIOUS_APIC_VECTOR;
Andi Kleen11a8e772006-01-11 22:46:51 +0100393 apic_write(APIC_SPIV, value);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394
395 /*
396 * Set up LVT0, LVT1:
397 *
398 * set up through-local-APIC on the BP's LINT0. This is not
399 * strictly necessary in pure symmetric-IO mode, but sometimes
400 * we delegate interrupts to the 8259A.
401 */
402 /*
403 * TODO: set up through-local-APIC from through-I/O-APIC? --macro
404 */
405 value = apic_read(APIC_LVT0) & APIC_LVT_MASKED;
406 if (!smp_processor_id() && (pic_mode || !value)) {
407 value = APIC_DM_EXTINT;
408 apic_printk(APIC_VERBOSE, "enabled ExtINT on CPU#%d\n", smp_processor_id());
409 } else {
410 value = APIC_DM_EXTINT | APIC_LVT_MASKED;
411 apic_printk(APIC_VERBOSE, "masked ExtINT on CPU#%d\n", smp_processor_id());
412 }
Andi Kleen11a8e772006-01-11 22:46:51 +0100413 apic_write(APIC_LVT0, value);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414
415 /*
416 * only the BP should see the LINT1 NMI signal, obviously.
417 */
418 if (!smp_processor_id())
419 value = APIC_DM_NMI;
420 else
421 value = APIC_DM_NMI | APIC_LVT_MASKED;
Andi Kleen11a8e772006-01-11 22:46:51 +0100422 apic_write(APIC_LVT1, value);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423
Andi Kleen61c11342005-09-12 18:49:23 +0200424 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425 unsigned oldvalue;
426 maxlvt = get_maxlvt();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427 oldvalue = apic_read(APIC_ESR);
428 value = ERROR_APIC_VECTOR; // enables sending errors
Andi Kleen11a8e772006-01-11 22:46:51 +0100429 apic_write(APIC_LVTERR, value);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430 /*
431 * spec says clear errors after enabling vector.
432 */
433 if (maxlvt > 3)
434 apic_write(APIC_ESR, 0);
435 value = apic_read(APIC_ESR);
436 if (value != oldvalue)
437 apic_printk(APIC_VERBOSE,
438 "ESR value after enabling vector: %08x, after %08x\n",
439 oldvalue, value);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440 }
441
442 nmi_watchdog_default();
443 if (nmi_watchdog == NMI_LOCAL_APIC)
444 setup_apic_nmi_watchdog();
445 apic_pm_activate();
446}
447
448#ifdef CONFIG_PM
449
450static struct {
451 /* 'active' is true if the local APIC was enabled by us and
452 not the BIOS; this signifies that we are also responsible
453 for disabling it before entering apm/acpi suspend */
454 int active;
455 /* r/w apic fields */
456 unsigned int apic_id;
457 unsigned int apic_taskpri;
458 unsigned int apic_ldr;
459 unsigned int apic_dfr;
460 unsigned int apic_spiv;
461 unsigned int apic_lvtt;
462 unsigned int apic_lvtpc;
463 unsigned int apic_lvt0;
464 unsigned int apic_lvt1;
465 unsigned int apic_lvterr;
466 unsigned int apic_tmict;
467 unsigned int apic_tdcr;
468 unsigned int apic_thmr;
469} apic_pm_state;
470
Pavel Machek0b9c33a2005-04-16 15:25:31 -0700471static int lapic_suspend(struct sys_device *dev, pm_message_t state)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472{
473 unsigned long flags;
474
475 if (!apic_pm_state.active)
476 return 0;
477
478 apic_pm_state.apic_id = apic_read(APIC_ID);
479 apic_pm_state.apic_taskpri = apic_read(APIC_TASKPRI);
480 apic_pm_state.apic_ldr = apic_read(APIC_LDR);
481 apic_pm_state.apic_dfr = apic_read(APIC_DFR);
482 apic_pm_state.apic_spiv = apic_read(APIC_SPIV);
483 apic_pm_state.apic_lvtt = apic_read(APIC_LVTT);
484 apic_pm_state.apic_lvtpc = apic_read(APIC_LVTPC);
485 apic_pm_state.apic_lvt0 = apic_read(APIC_LVT0);
486 apic_pm_state.apic_lvt1 = apic_read(APIC_LVT1);
487 apic_pm_state.apic_lvterr = apic_read(APIC_LVTERR);
488 apic_pm_state.apic_tmict = apic_read(APIC_TMICT);
489 apic_pm_state.apic_tdcr = apic_read(APIC_TDCR);
490 apic_pm_state.apic_thmr = apic_read(APIC_LVTTHMR);
491 local_save_flags(flags);
492 local_irq_disable();
493 disable_local_APIC();
494 local_irq_restore(flags);
495 return 0;
496}
497
498static int lapic_resume(struct sys_device *dev)
499{
500 unsigned int l, h;
501 unsigned long flags;
502
503 if (!apic_pm_state.active)
504 return 0;
505
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506 local_irq_save(flags);
507 rdmsr(MSR_IA32_APICBASE, l, h);
508 l &= ~MSR_IA32_APICBASE_BASE;
Shaohua Li5b743572006-01-16 01:56:45 +0100509 l |= MSR_IA32_APICBASE_ENABLE | mp_lapic_addr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510 wrmsr(MSR_IA32_APICBASE, l, h);
511 apic_write(APIC_LVTERR, ERROR_APIC_VECTOR | APIC_LVT_MASKED);
512 apic_write(APIC_ID, apic_pm_state.apic_id);
513 apic_write(APIC_DFR, apic_pm_state.apic_dfr);
514 apic_write(APIC_LDR, apic_pm_state.apic_ldr);
515 apic_write(APIC_TASKPRI, apic_pm_state.apic_taskpri);
516 apic_write(APIC_SPIV, apic_pm_state.apic_spiv);
517 apic_write(APIC_LVT0, apic_pm_state.apic_lvt0);
518 apic_write(APIC_LVT1, apic_pm_state.apic_lvt1);
519 apic_write(APIC_LVTTHMR, apic_pm_state.apic_thmr);
520 apic_write(APIC_LVTPC, apic_pm_state.apic_lvtpc);
521 apic_write(APIC_LVTT, apic_pm_state.apic_lvtt);
522 apic_write(APIC_TDCR, apic_pm_state.apic_tdcr);
523 apic_write(APIC_TMICT, apic_pm_state.apic_tmict);
524 apic_write(APIC_ESR, 0);
525 apic_read(APIC_ESR);
526 apic_write(APIC_LVTERR, apic_pm_state.apic_lvterr);
527 apic_write(APIC_ESR, 0);
528 apic_read(APIC_ESR);
529 local_irq_restore(flags);
530 return 0;
531}
532
533static struct sysdev_class lapic_sysclass = {
534 set_kset_name("lapic"),
535 .resume = lapic_resume,
536 .suspend = lapic_suspend,
537};
538
539static struct sys_device device_lapic = {
540 .id = 0,
541 .cls = &lapic_sysclass,
542};
543
Ashok Raje6982c62005-06-25 14:54:58 -0700544static void __cpuinit apic_pm_activate(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545{
546 apic_pm_state.active = 1;
547}
548
549static int __init init_lapic_sysfs(void)
550{
551 int error;
552 if (!cpu_has_apic)
553 return 0;
554 /* XXX: remove suspend/resume procs if !apic_pm_state.active? */
555 error = sysdev_class_register(&lapic_sysclass);
556 if (!error)
557 error = sysdev_register(&device_lapic);
558 return error;
559}
560device_initcall(init_lapic_sysfs);
561
562#else /* CONFIG_PM */
563
564static void apic_pm_activate(void) { }
565
566#endif /* CONFIG_PM */
567
568static int __init apic_set_verbosity(char *str)
569{
570 if (strcmp("debug", str) == 0)
571 apic_verbosity = APIC_DEBUG;
572 else if (strcmp("verbose", str) == 0)
573 apic_verbosity = APIC_VERBOSE;
574 else
575 printk(KERN_WARNING "APIC Verbosity level %s not recognised"
576 " use apic=verbose or apic=debug", str);
577
578 return 0;
579}
580
581__setup("apic=", apic_set_verbosity);
582
583/*
584 * Detect and enable local APICs on non-SMP boards.
585 * Original code written by Keir Fraser.
586 * On AMD64 we trust the BIOS - if it says no APIC it is likely
587 * not correctly set up (usually the APIC timer won't work etc.)
588 */
589
590static int __init detect_init_APIC (void)
591{
592 if (!cpu_has_apic) {
593 printk(KERN_INFO "No local APIC present\n");
594 return -1;
595 }
596
597 mp_lapic_addr = APIC_DEFAULT_PHYS_BASE;
598 boot_cpu_id = 0;
599 return 0;
600}
601
602void __init init_apic_mappings(void)
603{
604 unsigned long apic_phys;
605
606 /*
607 * If no local APIC can be found then set up a fake all
608 * zeroes page to simulate the local APIC and another
609 * one for the IO-APIC.
610 */
611 if (!smp_found_config && detect_init_APIC()) {
612 apic_phys = (unsigned long) alloc_bootmem_pages(PAGE_SIZE);
613 apic_phys = __pa(apic_phys);
614 } else
615 apic_phys = mp_lapic_addr;
616
617 set_fixmap_nocache(FIX_APIC_BASE, apic_phys);
618 apic_printk(APIC_VERBOSE,"mapped APIC to %16lx (%16lx)\n", APIC_BASE, apic_phys);
619
620 /*
621 * Fetch the APIC ID of the BSP in case we have a
622 * default configuration (or the MP table is broken).
623 */
Andi Kleen1d3fbbf2005-09-12 18:49:24 +0200624 boot_cpu_id = GET_APIC_ID(apic_read(APIC_ID));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625
626#ifdef CONFIG_X86_IO_APIC
627 {
628 unsigned long ioapic_phys, idx = FIX_IO_APIC_BASE_0;
629 int i;
630
631 for (i = 0; i < nr_ioapics; i++) {
632 if (smp_found_config) {
633 ioapic_phys = mp_ioapics[i].mpc_apicaddr;
634 } else {
635 ioapic_phys = (unsigned long) alloc_bootmem_pages(PAGE_SIZE);
636 ioapic_phys = __pa(ioapic_phys);
637 }
638 set_fixmap_nocache(idx, ioapic_phys);
639 apic_printk(APIC_VERBOSE,"mapped IOAPIC to %016lx (%016lx)\n",
640 __fix_to_virt(idx), ioapic_phys);
641 idx++;
642 }
643 }
644#endif
645}
646
647/*
648 * This function sets up the local APIC timer, with a timeout of
649 * 'clocks' APIC bus clock. During calibration we actually call
650 * this function twice on the boot CPU, once with a bogus timeout
651 * value, second time for real. The other (noncalibrating) CPUs
652 * call this function only once, with the real, calibrated value.
653 *
654 * We do reads before writes even if unnecessary, to get around the
655 * P5 APIC double write bug.
656 */
657
658#define APIC_DIVISOR 16
659
660static void __setup_APIC_LVTT(unsigned int clocks)
661{
662 unsigned int lvtt_value, tmp_value, ver;
Venkatesh Pallipadid25bf7e2006-01-11 22:44:24 +0100663 int cpu = smp_processor_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664
665 ver = GET_APIC_VERSION(apic_read(APIC_LVR));
666 lvtt_value = APIC_LVT_TIMER_PERIODIC | LOCAL_TIMER_VECTOR;
Venkatesh Pallipadid25bf7e2006-01-11 22:44:24 +0100667
668 if (cpu_isset(cpu, timer_interrupt_broadcast_ipi_mask))
669 lvtt_value |= APIC_LVT_MASKED;
670
Andi Kleen11a8e772006-01-11 22:46:51 +0100671 apic_write(APIC_LVTT, lvtt_value);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672
673 /*
674 * Divide PICLK by 16
675 */
676 tmp_value = apic_read(APIC_TDCR);
Andi Kleen11a8e772006-01-11 22:46:51 +0100677 apic_write(APIC_TDCR, (tmp_value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678 & ~(APIC_TDR_DIV_1 | APIC_TDR_DIV_TMBASE))
679 | APIC_TDR_DIV_16);
680
Andi Kleen11a8e772006-01-11 22:46:51 +0100681 apic_write(APIC_TMICT, clocks/APIC_DIVISOR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682}
683
684static void setup_APIC_timer(unsigned int clocks)
685{
686 unsigned long flags;
687
688 local_irq_save(flags);
689
Linus Torvalds1da177e2005-04-16 15:20:36 -0700690 /* wait for irq slice */
691 if (vxtime.hpet_address) {
692 int trigger = hpet_readl(HPET_T0_CMP);
693 while (hpet_readl(HPET_COUNTER) >= trigger)
694 /* do nothing */ ;
695 while (hpet_readl(HPET_COUNTER) < trigger)
696 /* do nothing */ ;
697 } else {
698 int c1, c2;
699 outb_p(0x00, 0x43);
700 c2 = inb_p(0x40);
701 c2 |= inb_p(0x40) << 8;
Andi Kleen11a8e772006-01-11 22:46:51 +0100702 do {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700703 c1 = c2;
704 outb_p(0x00, 0x43);
705 c2 = inb_p(0x40);
706 c2 |= inb_p(0x40) << 8;
707 } while (c2 - c1 < 300);
708 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709 __setup_APIC_LVTT(clocks);
Andi Kleen73dea472006-02-03 21:50:50 +0100710 /* Turn off PIT interrupt if we use APIC timer as main timer.
711 Only works with the PM timer right now
712 TBD fix it for HPET too. */
713 if (vxtime.mode == VXTIME_PMTMR &&
714 smp_processor_id() == boot_cpu_id &&
715 apic_runs_main_timer == 1 &&
716 !cpu_isset(boot_cpu_id, timer_interrupt_broadcast_ipi_mask)) {
717 stop_timer_interrupt();
718 apic_runs_main_timer++;
719 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700720 local_irq_restore(flags);
721}
722
723/*
724 * In this function we calibrate APIC bus clocks to the external
725 * timer. Unfortunately we cannot use jiffies and the timer irq
726 * to calibrate, since some later bootup code depends on getting
727 * the first irq? Ugh.
728 *
729 * We want to do the calibration only once since we
730 * want to have local timer irqs syncron. CPUs connected
731 * by the same APIC bus have the very same bus frequency.
732 * And we want to have irqs off anyways, no accidental
733 * APIC irq that way.
734 */
735
736#define TICK_COUNT 100000000
737
738static int __init calibrate_APIC_clock(void)
739{
740 int apic, apic_start, tsc, tsc_start;
741 int result;
742 /*
743 * Put whatever arbitrary (but long enough) timeout
744 * value into the APIC clock, we just want to get the
745 * counter running for calibration.
746 */
747 __setup_APIC_LVTT(1000000000);
748
749 apic_start = apic_read(APIC_TMCCT);
Andi Kleen0c3749c2006-02-03 21:51:41 +0100750#ifdef CONFIG_X86_PM_TIMER
751 if (apic_calibrate_pmtmr && pmtmr_ioport) {
752 pmtimer_wait(5000); /* 5ms wait */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700753 apic = apic_read(APIC_TMCCT);
Andi Kleen0c3749c2006-02-03 21:51:41 +0100754 result = (apic_start - apic) * 1000L / 5;
755 } else
756#endif
757 {
758 rdtscl(tsc_start);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700759
Andi Kleen0c3749c2006-02-03 21:51:41 +0100760 do {
761 apic = apic_read(APIC_TMCCT);
762 rdtscl(tsc);
763 } while ((tsc - tsc_start) < TICK_COUNT &&
764 (apic - apic_start) < TICK_COUNT);
765
766 result = (apic_start - apic) * 1000L * cpu_khz /
767 (tsc - tsc_start);
768 }
769 printk("result %d\n", result);
770
Linus Torvalds1da177e2005-04-16 15:20:36 -0700771
772 printk(KERN_INFO "Detected %d.%03d MHz APIC timer.\n",
773 result / 1000 / 1000, result / 1000 % 1000);
774
775 return result * APIC_DIVISOR / HZ;
776}
777
778static unsigned int calibration_result;
779
780void __init setup_boot_APIC_clock (void)
781{
782 if (disable_apic_timer) {
783 printk(KERN_INFO "Disabling APIC timer\n");
784 return;
785 }
786
787 printk(KERN_INFO "Using local APIC timer interrupts.\n");
788 using_apic_timer = 1;
789
790 local_irq_disable();
791
792 calibration_result = calibrate_APIC_clock();
793 /*
794 * Now set up the timer for real.
795 */
796 setup_APIC_timer(calibration_result);
797
798 local_irq_enable();
799}
800
Ashok Raje6982c62005-06-25 14:54:58 -0700801void __cpuinit setup_secondary_APIC_clock(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700802{
803 local_irq_disable(); /* FIXME: Do we need this? --RR */
804 setup_APIC_timer(calibration_result);
805 local_irq_enable();
806}
807
Venkatesh Pallipadid25bf7e2006-01-11 22:44:24 +0100808void disable_APIC_timer(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700809{
810 if (using_apic_timer) {
811 unsigned long v;
812
813 v = apic_read(APIC_LVTT);
Andi Kleen11a8e772006-01-11 22:46:51 +0100814 apic_write(APIC_LVTT, v | APIC_LVT_MASKED);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700815 }
816}
817
818void enable_APIC_timer(void)
819{
Venkatesh Pallipadid25bf7e2006-01-11 22:44:24 +0100820 int cpu = smp_processor_id();
821
822 if (using_apic_timer &&
823 !cpu_isset(cpu, timer_interrupt_broadcast_ipi_mask)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700824 unsigned long v;
825
826 v = apic_read(APIC_LVTT);
Andi Kleen11a8e772006-01-11 22:46:51 +0100827 apic_write(APIC_LVTT, v & ~APIC_LVT_MASKED);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700828 }
829}
830
Venkatesh Pallipadid25bf7e2006-01-11 22:44:24 +0100831void switch_APIC_timer_to_ipi(void *cpumask)
832{
833 cpumask_t mask = *(cpumask_t *)cpumask;
834 int cpu = smp_processor_id();
835
836 if (cpu_isset(cpu, mask) &&
837 !cpu_isset(cpu, timer_interrupt_broadcast_ipi_mask)) {
838 disable_APIC_timer();
839 cpu_set(cpu, timer_interrupt_broadcast_ipi_mask);
840 }
841}
842EXPORT_SYMBOL(switch_APIC_timer_to_ipi);
843
844void smp_send_timer_broadcast_ipi(void)
845{
846 cpumask_t mask;
847
848 cpus_and(mask, cpu_online_map, timer_interrupt_broadcast_ipi_mask);
849 if (!cpus_empty(mask)) {
850 send_IPI_mask(mask, LOCAL_TIMER_VECTOR);
851 }
852}
853
854void switch_ipi_to_APIC_timer(void *cpumask)
855{
856 cpumask_t mask = *(cpumask_t *)cpumask;
857 int cpu = smp_processor_id();
858
859 if (cpu_isset(cpu, mask) &&
860 cpu_isset(cpu, timer_interrupt_broadcast_ipi_mask)) {
861 cpu_clear(cpu, timer_interrupt_broadcast_ipi_mask);
862 enable_APIC_timer();
863 }
864}
865EXPORT_SYMBOL(switch_ipi_to_APIC_timer);
866
Linus Torvalds1da177e2005-04-16 15:20:36 -0700867int setup_profiling_timer(unsigned int multiplier)
868{
Venkatesh Pallipadi5a07a302006-01-11 22:44:18 +0100869 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700870}
871
Jacob Shin89b831e2005-11-05 17:25:53 +0100872#ifdef CONFIG_X86_MCE_AMD
873void setup_threshold_lvt(unsigned long lvt_off)
874{
875 unsigned int v = 0;
876 unsigned long reg = (lvt_off << 4) + 0x500;
877 v |= THRESHOLD_APIC_VECTOR;
878 apic_write(reg, v);
879}
880#endif /* CONFIG_X86_MCE_AMD */
881
Linus Torvalds1da177e2005-04-16 15:20:36 -0700882#undef APIC_DIVISOR
883
884/*
885 * Local timer interrupt handler. It does both profiling and
886 * process statistics/rescheduling.
887 *
888 * We do profiling in every local tick, statistics/rescheduling
889 * happen only every 'profiling multiplier' ticks. The default
890 * multiplier is 1 and it can be changed by writing the new multiplier
891 * value into /proc/profile.
892 */
893
894void smp_local_timer_interrupt(struct pt_regs *regs)
895{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700896 profile_tick(CPU_PROFILING, regs);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700897#ifdef CONFIG_SMP
Venkatesh Pallipadi5a07a302006-01-11 22:44:18 +0100898 update_process_times(user_mode(regs));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700899#endif
Andi Kleen73dea472006-02-03 21:50:50 +0100900 if (apic_runs_main_timer > 1 && smp_processor_id() == boot_cpu_id)
901 main_timer_handler(regs);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700902 /*
903 * We take the 'long' return path, and there every subsystem
904 * grabs the appropriate locks (kernel lock/ irq lock).
905 *
906 * we might want to decouple profiling from the 'long path',
907 * and do the profiling totally in assembly.
908 *
909 * Currently this isn't too much of an issue (performance wise),
910 * we can take more than 100K local irqs per second on a 100 MHz P5.
911 */
912}
913
914/*
915 * Local APIC timer interrupt. This is the most natural way for doing
916 * local interrupts, but local timer interrupts can be emulated by
917 * broadcast interrupts too. [in case the hw doesn't support APIC timers]
918 *
919 * [ if a single-CPU system runs an SMP kernel then we call the local
920 * interrupt as well. Thus we cannot inline the local irq ... ]
921 */
922void smp_apic_timer_interrupt(struct pt_regs *regs)
923{
924 /*
925 * the NMI deadlock-detector uses this.
926 */
927 add_pda(apic_timer_irqs, 1);
928
929 /*
930 * NOTE! We'd better ACK the irq immediately,
931 * because timer handling can be slow.
932 */
933 ack_APIC_irq();
934 /*
935 * update_process_times() expects us to have done irq_enter().
936 * Besides, if we don't timer interrupts ignore the global
937 * interrupt lock, which is the WrongThing (tm) to do.
938 */
Andi Kleen95833c82006-01-11 22:44:36 +0100939 exit_idle();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700940 irq_enter();
941 smp_local_timer_interrupt(regs);
942 irq_exit();
943}
944
945/*
946 * oem_force_hpet_timer -- force HPET mode for some boxes.
947 *
948 * Thus far, the major user of this is IBM's Summit2 series:
949 *
950 * Clustered boxes may have unsynced TSC problems if they are
951 * multi-chassis. Use available data to take a good guess.
952 * If in doubt, go HPET.
953 */
Shaohua Li396bd502006-02-03 21:51:20 +0100954__cpuinit int oem_force_hpet_timer(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700955{
956 int i, clusters, zeros;
957 unsigned id;
958 DECLARE_BITMAP(clustermap, NUM_APIC_CLUSTERS);
959
Suresh Siddha376ec332005-05-16 21:53:32 -0700960 bitmap_zero(clustermap, NUM_APIC_CLUSTERS);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700961
962 for (i = 0; i < NR_CPUS; i++) {
963 id = bios_cpu_apicid[i];
964 if (id != BAD_APICID)
965 __set_bit(APIC_CLUSTERID(id), clustermap);
966 }
967
968 /* Problem: Partially populated chassis may not have CPUs in some of
969 * the APIC clusters they have been allocated. Only present CPUs have
970 * bios_cpu_apicid entries, thus causing zeroes in the bitmap. Since
971 * clusters are allocated sequentially, count zeros only if they are
972 * bounded by ones.
973 */
974 clusters = 0;
975 zeros = 0;
976 for (i = 0; i < NUM_APIC_CLUSTERS; i++) {
977 if (test_bit(i, clustermap)) {
978 clusters += 1 + zeros;
979 zeros = 0;
980 } else
981 ++zeros;
982 }
983
984 /*
985 * If clusters > 2, then should be multi-chassis. Return 1 for HPET.
986 * Else return 0 to use TSC.
987 * May have to revisit this when multi-core + hyperthreaded CPUs come
988 * out, but AFAIK this will work even for them.
989 */
990 return (clusters > 2);
991}
992
993/*
994 * This interrupt should _never_ happen with our APIC/SMP architecture
995 */
996asmlinkage void smp_spurious_interrupt(void)
997{
998 unsigned int v;
Andi Kleen95833c82006-01-11 22:44:36 +0100999 exit_idle();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001000 irq_enter();
1001 /*
1002 * Check if this really is a spurious interrupt and ACK it
1003 * if it is a vectored one. Just in case...
1004 * Spurious interrupts should not be ACKed.
1005 */
1006 v = apic_read(APIC_ISR + ((SPURIOUS_APIC_VECTOR & ~0x1f) >> 1));
1007 if (v & (1 << (SPURIOUS_APIC_VECTOR & 0x1f)))
1008 ack_APIC_irq();
1009
1010#if 0
1011 static unsigned long last_warning;
1012 static unsigned long skipped;
1013
1014 /* see sw-dev-man vol 3, chapter 7.4.13.5 */
1015 if (time_before(last_warning+30*HZ,jiffies)) {
1016 printk(KERN_INFO "spurious APIC interrupt on CPU#%d, %ld skipped.\n",
1017 smp_processor_id(), skipped);
1018 last_warning = jiffies;
1019 skipped = 0;
1020 } else {
1021 skipped++;
1022 }
1023#endif
1024 irq_exit();
1025}
1026
1027/*
1028 * This interrupt should never happen with our APIC/SMP architecture
1029 */
1030
1031asmlinkage void smp_error_interrupt(void)
1032{
1033 unsigned int v, v1;
1034
Andi Kleen95833c82006-01-11 22:44:36 +01001035 exit_idle();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001036 irq_enter();
1037 /* First tickle the hardware, only then report what went on. -- REW */
1038 v = apic_read(APIC_ESR);
1039 apic_write(APIC_ESR, 0);
1040 v1 = apic_read(APIC_ESR);
1041 ack_APIC_irq();
1042 atomic_inc(&irq_err_count);
1043
1044 /* Here is what the APIC error bits mean:
1045 0: Send CS error
1046 1: Receive CS error
1047 2: Send accept error
1048 3: Receive accept error
1049 4: Reserved
1050 5: Send illegal vector
1051 6: Received illegal vector
1052 7: Illegal register address
1053 */
1054 printk (KERN_DEBUG "APIC error on CPU%d: %02x(%02x)\n",
1055 smp_processor_id(), v , v1);
1056 irq_exit();
1057}
1058
1059int disable_apic;
1060
1061/*
1062 * This initializes the IO-APIC and APIC hardware if this is
1063 * a UP kernel.
1064 */
1065int __init APIC_init_uniprocessor (void)
1066{
1067 if (disable_apic) {
1068 printk(KERN_INFO "Apic disabled\n");
1069 return -1;
1070 }
1071 if (!cpu_has_apic) {
1072 disable_apic = 1;
1073 printk(KERN_INFO "Apic disabled by BIOS\n");
1074 return -1;
1075 }
1076
1077 verify_local_APIC();
1078
1079 connect_bsp_APIC();
1080
Andi Kleen357e11d2005-09-12 18:49:24 +02001081 phys_cpu_present_map = physid_mask_of_physid(boot_cpu_id);
Andi Kleen11a8e772006-01-11 22:46:51 +01001082 apic_write(APIC_ID, SET_APIC_ID(boot_cpu_id));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001083
1084 setup_local_APIC();
1085
1086#ifdef CONFIG_X86_IO_APIC
1087 if (smp_found_config && !skip_ioapic_setup && nr_ioapics)
1088 setup_IO_APIC();
1089 else
1090 nr_ioapics = 0;
1091#endif
1092 setup_boot_APIC_clock();
Andi Kleen75152112005-05-16 21:53:34 -07001093 check_nmi_watchdog();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001094 return 0;
1095}
1096
1097static __init int setup_disableapic(char *str)
1098{
1099 disable_apic = 1;
1100 return 0;
1101}
1102
1103static __init int setup_nolapic(char *str)
1104{
1105 disable_apic = 1;
1106 return 0;
1107}
1108
1109static __init int setup_noapictimer(char *str)
1110{
Andi Kleen73dea472006-02-03 21:50:50 +01001111 if (str[0] != ' ' && str[0] != 0)
1112 return -1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001113 disable_apic_timer = 1;
1114 return 0;
1115}
1116
Andi Kleen73dea472006-02-03 21:50:50 +01001117static __init int setup_apicmaintimer(char *str)
1118{
1119 apic_runs_main_timer = 1;
1120 nohpet = 1;
1121 return 0;
1122}
1123__setup("apicmaintimer", setup_apicmaintimer);
1124
1125static __init int setup_noapicmaintimer(char *str)
1126{
1127 apic_runs_main_timer = -1;
1128 return 0;
1129}
1130__setup("noapicmaintimer", setup_noapicmaintimer);
1131
Andi Kleen0c3749c2006-02-03 21:51:41 +01001132static __init int setup_apicpmtimer(char *s)
1133{
1134 apic_calibrate_pmtmr = 1;
1135 return setup_apicmaintimer(NULL);
1136}
1137__setup("apicpmtimer", setup_apicpmtimer);
1138
Linus Torvalds1da177e2005-04-16 15:20:36 -07001139/* dummy parsing: see setup.c */
1140
1141__setup("disableapic", setup_disableapic);
1142__setup("nolapic", setup_nolapic); /* same as disableapic, for compatibility */
1143
1144__setup("noapictimer", setup_noapictimer);
1145
1146/* no "lapic" flag - we only use the lapic when the BIOS tells us so. */