Merge remote branch 'origin/x86/apic' into x86/mrst
[linux-2.6/x86.git] / arch / x86 / kernel / acpi / boot.c
blobdb2773c6defd7dc03ba36e729a3095121abb373e
1 /*
2 * boot.c - Architecture-Specific Low-Level ACPI Boot Support
4 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
5 * Copyright (C) 2001 Jun Nakajima <jun.nakajima@intel.com>
7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26 #include <linux/init.h>
27 #include <linux/acpi.h>
28 #include <linux/acpi_pmtmr.h>
29 #include <linux/efi.h>
30 #include <linux/cpumask.h>
31 #include <linux/module.h>
32 #include <linux/dmi.h>
33 #include <linux/irq.h>
34 #include <linux/bootmem.h>
35 #include <linux/ioport.h>
36 #include <linux/pci.h>
38 #include <asm/pci_x86.h>
39 #include <asm/pgtable.h>
40 #include <asm/io_apic.h>
41 #include <asm/apic.h>
42 #include <asm/io.h>
43 #include <asm/mpspec.h>
44 #include <asm/smp.h>
46 static int __initdata acpi_force = 0;
47 u32 acpi_rsdt_forced;
48 int acpi_disabled;
49 EXPORT_SYMBOL(acpi_disabled);
51 #ifdef CONFIG_X86_64
52 # include <asm/proto.h>
53 #endif /* X86 */
55 #define BAD_MADT_ENTRY(entry, end) ( \
56 (!entry) || (unsigned long)entry + sizeof(*entry) > end || \
57 ((struct acpi_subtable_header *)entry)->length < sizeof(*entry))
59 #define PREFIX "ACPI: "
61 int acpi_noirq; /* skip ACPI IRQ initialization */
62 int acpi_pci_disabled; /* skip ACPI PCI scan and IRQ initialization */
63 EXPORT_SYMBOL(acpi_pci_disabled);
64 int acpi_ht __initdata = 1; /* enable HT */
66 int acpi_lapic;
67 int acpi_ioapic;
68 int acpi_strict;
70 u8 acpi_sci_flags __initdata;
71 int acpi_sci_override_gsi __initdata;
72 int acpi_skip_timer_override __initdata;
73 int acpi_use_timer_override __initdata;
75 #ifdef CONFIG_X86_LOCAL_APIC
76 static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
77 #endif
79 #ifndef __HAVE_ARCH_CMPXCHG
80 #warning ACPI uses CMPXCHG, i486 and later hardware
81 #endif
83 /* --------------------------------------------------------------------------
84 Boot-time Configuration
85 -------------------------------------------------------------------------- */
88 * The default interrupt routing model is PIC (8259). This gets
89 * overridden if IOAPICs are enumerated (below).
91 enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC;
95 * Temporarily use the virtual area starting from FIX_IO_APIC_BASE_END,
96 * to map the target physical address. The problem is that set_fixmap()
97 * provides a single page, and it is possible that the page is not
98 * sufficient.
99 * By using this area, we can map up to MAX_IO_APICS pages temporarily,
100 * i.e. until the next __va_range() call.
102 * Important Safety Note: The fixed I/O APIC page numbers are *subtracted*
103 * from the fixed base. That's why we start at FIX_IO_APIC_BASE_END and
104 * count idx down while incrementing the phys address.
106 char *__init __acpi_map_table(unsigned long phys, unsigned long size)
109 if (!phys || !size)
110 return NULL;
112 return early_ioremap(phys, size);
114 void __init __acpi_unmap_table(char *map, unsigned long size)
116 if (!map || !size)
117 return;
119 early_iounmap(map, size);
122 #ifdef CONFIG_X86_LOCAL_APIC
123 static int __init acpi_parse_madt(struct acpi_table_header *table)
125 struct acpi_table_madt *madt = NULL;
127 if (!cpu_has_apic)
128 return -EINVAL;
130 madt = (struct acpi_table_madt *)table;
131 if (!madt) {
132 printk(KERN_WARNING PREFIX "Unable to map MADT\n");
133 return -ENODEV;
136 if (madt->address) {
137 acpi_lapic_addr = (u64) madt->address;
139 printk(KERN_DEBUG PREFIX "Local APIC address 0x%08x\n",
140 madt->address);
143 default_acpi_madt_oem_check(madt->header.oem_id,
144 madt->header.oem_table_id);
146 return 0;
149 static void __cpuinit acpi_register_lapic(int id, u8 enabled)
151 unsigned int ver = 0;
153 if (!enabled) {
154 ++disabled_cpus;
155 return;
158 if (boot_cpu_physical_apicid != -1U)
159 ver = apic_version[boot_cpu_physical_apicid];
161 generic_processor_info(id, ver);
164 static int __init
165 acpi_parse_x2apic(struct acpi_subtable_header *header, const unsigned long end)
167 struct acpi_madt_local_x2apic *processor = NULL;
169 processor = (struct acpi_madt_local_x2apic *)header;
171 if (BAD_MADT_ENTRY(processor, end))
172 return -EINVAL;
174 acpi_table_print_madt_entry(header);
176 #ifdef CONFIG_X86_X2APIC
178 * We need to register disabled CPU as well to permit
179 * counting disabled CPUs. This allows us to size
180 * cpus_possible_map more accurately, to permit
181 * to not preallocating memory for all NR_CPUS
182 * when we use CPU hotplug.
184 acpi_register_lapic(processor->local_apic_id, /* APIC ID */
185 processor->lapic_flags & ACPI_MADT_ENABLED);
186 #else
187 printk(KERN_WARNING PREFIX "x2apic entry ignored\n");
188 #endif
190 return 0;
193 static int __init
194 acpi_parse_lapic(struct acpi_subtable_header * header, const unsigned long end)
196 struct acpi_madt_local_apic *processor = NULL;
198 processor = (struct acpi_madt_local_apic *)header;
200 if (BAD_MADT_ENTRY(processor, end))
201 return -EINVAL;
203 acpi_table_print_madt_entry(header);
206 * We need to register disabled CPU as well to permit
207 * counting disabled CPUs. This allows us to size
208 * cpus_possible_map more accurately, to permit
209 * to not preallocating memory for all NR_CPUS
210 * when we use CPU hotplug.
212 acpi_register_lapic(processor->id, /* APIC ID */
213 processor->lapic_flags & ACPI_MADT_ENABLED);
215 return 0;
218 static int __init
219 acpi_parse_sapic(struct acpi_subtable_header *header, const unsigned long end)
221 struct acpi_madt_local_sapic *processor = NULL;
223 processor = (struct acpi_madt_local_sapic *)header;
225 if (BAD_MADT_ENTRY(processor, end))
226 return -EINVAL;
228 acpi_table_print_madt_entry(header);
230 acpi_register_lapic((processor->id << 8) | processor->eid,/* APIC ID */
231 processor->lapic_flags & ACPI_MADT_ENABLED);
233 return 0;
236 static int __init
237 acpi_parse_lapic_addr_ovr(struct acpi_subtable_header * header,
238 const unsigned long end)
240 struct acpi_madt_local_apic_override *lapic_addr_ovr = NULL;
242 lapic_addr_ovr = (struct acpi_madt_local_apic_override *)header;
244 if (BAD_MADT_ENTRY(lapic_addr_ovr, end))
245 return -EINVAL;
247 acpi_lapic_addr = lapic_addr_ovr->address;
249 return 0;
252 static int __init
253 acpi_parse_x2apic_nmi(struct acpi_subtable_header *header,
254 const unsigned long end)
256 struct acpi_madt_local_x2apic_nmi *x2apic_nmi = NULL;
258 x2apic_nmi = (struct acpi_madt_local_x2apic_nmi *)header;
260 if (BAD_MADT_ENTRY(x2apic_nmi, end))
261 return -EINVAL;
263 acpi_table_print_madt_entry(header);
265 if (x2apic_nmi->lint != 1)
266 printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n");
268 return 0;
271 static int __init
272 acpi_parse_lapic_nmi(struct acpi_subtable_header * header, const unsigned long end)
274 struct acpi_madt_local_apic_nmi *lapic_nmi = NULL;
276 lapic_nmi = (struct acpi_madt_local_apic_nmi *)header;
278 if (BAD_MADT_ENTRY(lapic_nmi, end))
279 return -EINVAL;
281 acpi_table_print_madt_entry(header);
283 if (lapic_nmi->lint != 1)
284 printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n");
286 return 0;
289 #endif /*CONFIG_X86_LOCAL_APIC */
291 #ifdef CONFIG_X86_IO_APIC
293 static int __init
294 acpi_parse_ioapic(struct acpi_subtable_header * header, const unsigned long end)
296 struct acpi_madt_io_apic *ioapic = NULL;
298 ioapic = (struct acpi_madt_io_apic *)header;
300 if (BAD_MADT_ENTRY(ioapic, end))
301 return -EINVAL;
303 acpi_table_print_madt_entry(header);
305 mp_register_ioapic(ioapic->id,
306 ioapic->address, ioapic->global_irq_base);
308 return 0;
312 * Parse Interrupt Source Override for the ACPI SCI
314 static void __init acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger)
316 if (trigger == 0) /* compatible SCI trigger is level */
317 trigger = 3;
319 if (polarity == 0) /* compatible SCI polarity is low */
320 polarity = 3;
322 /* Command-line over-ride via acpi_sci= */
323 if (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK)
324 trigger = (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK) >> 2;
326 if (acpi_sci_flags & ACPI_MADT_POLARITY_MASK)
327 polarity = acpi_sci_flags & ACPI_MADT_POLARITY_MASK;
330 * mp_config_acpi_legacy_irqs() already setup IRQs < 16
331 * If GSI is < 16, this will update its flags,
332 * else it will create a new mp_irqs[] entry.
334 mp_override_legacy_irq(gsi, polarity, trigger, gsi);
337 * stash over-ride to indicate we've been here
338 * and for later update of acpi_gbl_FADT
340 acpi_sci_override_gsi = gsi;
341 return;
344 static int __init
345 acpi_parse_int_src_ovr(struct acpi_subtable_header * header,
346 const unsigned long end)
348 struct acpi_madt_interrupt_override *intsrc = NULL;
350 intsrc = (struct acpi_madt_interrupt_override *)header;
352 if (BAD_MADT_ENTRY(intsrc, end))
353 return -EINVAL;
355 acpi_table_print_madt_entry(header);
357 if (intsrc->source_irq == acpi_gbl_FADT.sci_interrupt) {
358 acpi_sci_ioapic_setup(intsrc->global_irq,
359 intsrc->inti_flags & ACPI_MADT_POLARITY_MASK,
360 (intsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2);
361 return 0;
364 if (acpi_skip_timer_override &&
365 intsrc->source_irq == 0 && intsrc->global_irq == 2) {
366 printk(PREFIX "BIOS IRQ0 pin2 override ignored.\n");
367 return 0;
370 mp_override_legacy_irq(intsrc->source_irq,
371 intsrc->inti_flags & ACPI_MADT_POLARITY_MASK,
372 (intsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2,
373 intsrc->global_irq);
375 return 0;
378 static int __init
379 acpi_parse_nmi_src(struct acpi_subtable_header * header, const unsigned long end)
381 struct acpi_madt_nmi_source *nmi_src = NULL;
383 nmi_src = (struct acpi_madt_nmi_source *)header;
385 if (BAD_MADT_ENTRY(nmi_src, end))
386 return -EINVAL;
388 acpi_table_print_madt_entry(header);
390 /* TBD: Support nimsrc entries? */
392 return 0;
395 #endif /* CONFIG_X86_IO_APIC */
398 * acpi_pic_sci_set_trigger()
400 * use ELCR to set PIC-mode trigger type for SCI
402 * If a PIC-mode SCI is not recognized or gives spurious IRQ7's
403 * it may require Edge Trigger -- use "acpi_sci=edge"
405 * Port 0x4d0-4d1 are ECLR1 and ECLR2, the Edge/Level Control Registers
406 * for the 8259 PIC. bit[n] = 1 means irq[n] is Level, otherwise Edge.
407 * ECLR1 is IRQs 0-7 (IRQ 0, 1, 2 must be 0)
408 * ECLR2 is IRQs 8-15 (IRQ 8, 13 must be 0)
411 void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
413 unsigned int mask = 1 << irq;
414 unsigned int old, new;
416 /* Real old ELCR mask */
417 old = inb(0x4d0) | (inb(0x4d1) << 8);
420 * If we use ACPI to set PCI IRQs, then we should clear ELCR
421 * since we will set it correctly as we enable the PCI irq
422 * routing.
424 new = acpi_noirq ? old : 0;
427 * Update SCI information in the ELCR, it isn't in the PCI
428 * routing tables..
430 switch (trigger) {
431 case 1: /* Edge - clear */
432 new &= ~mask;
433 break;
434 case 3: /* Level - set */
435 new |= mask;
436 break;
439 if (old == new)
440 return;
442 printk(PREFIX "setting ELCR to %04x (from %04x)\n", new, old);
443 outb(new, 0x4d0);
444 outb(new >> 8, 0x4d1);
447 int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
449 *irq = gsi;
451 #ifdef CONFIG_X86_IO_APIC
452 if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC)
453 setup_IO_APIC_irq_extra(gsi);
454 #endif
456 return 0;
460 * success: return IRQ number (>=0)
461 * failure: return < 0
463 int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity)
465 unsigned int irq;
466 unsigned int plat_gsi = gsi;
468 #ifdef CONFIG_PCI
470 * Make sure all (legacy) PCI IRQs are set as level-triggered.
472 if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
473 if (trigger == ACPI_LEVEL_SENSITIVE)
474 eisa_set_level_irq(gsi);
476 #endif
478 #ifdef CONFIG_X86_IO_APIC
479 if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) {
480 plat_gsi = mp_register_gsi(dev, gsi, trigger, polarity);
482 #endif
483 irq = plat_gsi;
485 return irq;
489 * ACPI based hotplug support for CPU
491 #ifdef CONFIG_ACPI_HOTPLUG_CPU
493 static int __cpuinit _acpi_map_lsapic(acpi_handle handle, int *pcpu)
495 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
496 union acpi_object *obj;
497 struct acpi_madt_local_apic *lapic;
498 cpumask_var_t tmp_map, new_map;
499 u8 physid;
500 int cpu;
501 int retval = -ENOMEM;
503 if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
504 return -EINVAL;
506 if (!buffer.length || !buffer.pointer)
507 return -EINVAL;
509 obj = buffer.pointer;
510 if (obj->type != ACPI_TYPE_BUFFER ||
511 obj->buffer.length < sizeof(*lapic)) {
512 kfree(buffer.pointer);
513 return -EINVAL;
516 lapic = (struct acpi_madt_local_apic *)obj->buffer.pointer;
518 if (lapic->header.type != ACPI_MADT_TYPE_LOCAL_APIC ||
519 !(lapic->lapic_flags & ACPI_MADT_ENABLED)) {
520 kfree(buffer.pointer);
521 return -EINVAL;
524 physid = lapic->id;
526 kfree(buffer.pointer);
527 buffer.length = ACPI_ALLOCATE_BUFFER;
528 buffer.pointer = NULL;
530 if (!alloc_cpumask_var(&tmp_map, GFP_KERNEL))
531 goto out;
533 if (!alloc_cpumask_var(&new_map, GFP_KERNEL))
534 goto free_tmp_map;
536 cpumask_copy(tmp_map, cpu_present_mask);
537 acpi_register_lapic(physid, lapic->lapic_flags & ACPI_MADT_ENABLED);
540 * If mp_register_lapic successfully generates a new logical cpu
541 * number, then the following will get us exactly what was mapped
543 cpumask_andnot(new_map, cpu_present_mask, tmp_map);
544 if (cpumask_empty(new_map)) {
545 printk ("Unable to map lapic to logical cpu number\n");
546 retval = -EINVAL;
547 goto free_new_map;
550 cpu = cpumask_first(new_map);
552 *pcpu = cpu;
553 retval = 0;
555 free_new_map:
556 free_cpumask_var(new_map);
557 free_tmp_map:
558 free_cpumask_var(tmp_map);
559 out:
560 return retval;
563 /* wrapper to silence section mismatch warning */
564 int __ref acpi_map_lsapic(acpi_handle handle, int *pcpu)
566 return _acpi_map_lsapic(handle, pcpu);
568 EXPORT_SYMBOL(acpi_map_lsapic);
570 int acpi_unmap_lsapic(int cpu)
572 per_cpu(x86_cpu_to_apicid, cpu) = -1;
573 set_cpu_present(cpu, false);
574 num_processors--;
576 return (0);
579 EXPORT_SYMBOL(acpi_unmap_lsapic);
580 #endif /* CONFIG_ACPI_HOTPLUG_CPU */
582 int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
584 /* TBD */
585 return -EINVAL;
588 EXPORT_SYMBOL(acpi_register_ioapic);
590 int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
592 /* TBD */
593 return -EINVAL;
596 EXPORT_SYMBOL(acpi_unregister_ioapic);
598 static int __init acpi_parse_sbf(struct acpi_table_header *table)
600 struct acpi_table_boot *sb;
602 sb = (struct acpi_table_boot *)table;
603 if (!sb) {
604 printk(KERN_WARNING PREFIX "Unable to map SBF\n");
605 return -ENODEV;
608 sbf_port = sb->cmos_index; /* Save CMOS port */
610 return 0;
613 #ifdef CONFIG_HPET_TIMER
614 #include <asm/hpet.h>
616 static struct __initdata resource *hpet_res;
618 static int __init acpi_parse_hpet(struct acpi_table_header *table)
620 struct acpi_table_hpet *hpet_tbl;
622 hpet_tbl = (struct acpi_table_hpet *)table;
623 if (!hpet_tbl) {
624 printk(KERN_WARNING PREFIX "Unable to map HPET\n");
625 return -ENODEV;
628 if (hpet_tbl->address.space_id != ACPI_SPACE_MEM) {
629 printk(KERN_WARNING PREFIX "HPET timers must be located in "
630 "memory.\n");
631 return -1;
634 hpet_address = hpet_tbl->address.address;
635 hpet_blockid = hpet_tbl->sequence;
638 * Some broken BIOSes advertise HPET at 0x0. We really do not
639 * want to allocate a resource there.
641 if (!hpet_address) {
642 printk(KERN_WARNING PREFIX
643 "HPET id: %#x base: %#lx is invalid\n",
644 hpet_tbl->id, hpet_address);
645 return 0;
647 #ifdef CONFIG_X86_64
649 * Some even more broken BIOSes advertise HPET at
650 * 0xfed0000000000000 instead of 0xfed00000. Fix it up and add
651 * some noise:
653 if (hpet_address == 0xfed0000000000000UL) {
654 if (!hpet_force_user) {
655 printk(KERN_WARNING PREFIX "HPET id: %#x "
656 "base: 0xfed0000000000000 is bogus\n "
657 "try hpet=force on the kernel command line to "
658 "fix it up to 0xfed00000.\n", hpet_tbl->id);
659 hpet_address = 0;
660 return 0;
662 printk(KERN_WARNING PREFIX
663 "HPET id: %#x base: 0xfed0000000000000 fixed up "
664 "to 0xfed00000.\n", hpet_tbl->id);
665 hpet_address >>= 32;
667 #endif
668 printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
669 hpet_tbl->id, hpet_address);
672 * Allocate and initialize the HPET firmware resource for adding into
673 * the resource tree during the lateinit timeframe.
675 #define HPET_RESOURCE_NAME_SIZE 9
676 hpet_res = alloc_bootmem(sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE);
678 hpet_res->name = (void *)&hpet_res[1];
679 hpet_res->flags = IORESOURCE_MEM;
680 snprintf((char *)hpet_res->name, HPET_RESOURCE_NAME_SIZE, "HPET %u",
681 hpet_tbl->sequence);
683 hpet_res->start = hpet_address;
684 hpet_res->end = hpet_address + (1 * 1024) - 1;
686 return 0;
690 * hpet_insert_resource inserts the HPET resources used into the resource
691 * tree.
693 static __init int hpet_insert_resource(void)
695 if (!hpet_res)
696 return 1;
698 return insert_resource(&iomem_resource, hpet_res);
701 late_initcall(hpet_insert_resource);
703 #else
704 #define acpi_parse_hpet NULL
705 #endif
707 static int __init acpi_parse_fadt(struct acpi_table_header *table)
710 #ifdef CONFIG_X86_PM_TIMER
711 /* detect the location of the ACPI PM Timer */
712 if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID) {
713 /* FADT rev. 2 */
714 if (acpi_gbl_FADT.xpm_timer_block.space_id !=
715 ACPI_ADR_SPACE_SYSTEM_IO)
716 return 0;
718 pmtmr_ioport = acpi_gbl_FADT.xpm_timer_block.address;
720 * "X" fields are optional extensions to the original V1.0
721 * fields, so we must selectively expand V1.0 fields if the
722 * corresponding X field is zero.
724 if (!pmtmr_ioport)
725 pmtmr_ioport = acpi_gbl_FADT.pm_timer_block;
726 } else {
727 /* FADT rev. 1 */
728 pmtmr_ioport = acpi_gbl_FADT.pm_timer_block;
730 if (pmtmr_ioport)
731 printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n",
732 pmtmr_ioport);
733 #endif
734 return 0;
737 #ifdef CONFIG_X86_LOCAL_APIC
739 * Parse LAPIC entries in MADT
740 * returns 0 on success, < 0 on error
743 static void __init acpi_register_lapic_address(unsigned long address)
745 mp_lapic_addr = address;
747 set_fixmap_nocache(FIX_APIC_BASE, address);
748 if (boot_cpu_physical_apicid == -1U) {
749 boot_cpu_physical_apicid = read_apic_id();
750 apic_version[boot_cpu_physical_apicid] =
751 GET_APIC_VERSION(apic_read(APIC_LVR));
755 static int __init early_acpi_parse_madt_lapic_addr_ovr(void)
757 int count;
759 if (!cpu_has_apic)
760 return -ENODEV;
763 * Note that the LAPIC address is obtained from the MADT (32-bit value)
764 * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value).
767 count =
768 acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE,
769 acpi_parse_lapic_addr_ovr, 0);
770 if (count < 0) {
771 printk(KERN_ERR PREFIX
772 "Error parsing LAPIC address override entry\n");
773 return count;
776 acpi_register_lapic_address(acpi_lapic_addr);
778 return count;
781 static int __init acpi_parse_madt_lapic_entries(void)
783 int count;
784 int x2count = 0;
786 if (!cpu_has_apic)
787 return -ENODEV;
790 * Note that the LAPIC address is obtained from the MADT (32-bit value)
791 * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value).
794 count =
795 acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE,
796 acpi_parse_lapic_addr_ovr, 0);
797 if (count < 0) {
798 printk(KERN_ERR PREFIX
799 "Error parsing LAPIC address override entry\n");
800 return count;
803 acpi_register_lapic_address(acpi_lapic_addr);
805 count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_SAPIC,
806 acpi_parse_sapic, MAX_APICS);
808 if (!count) {
809 x2count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_X2APIC,
810 acpi_parse_x2apic, MAX_APICS);
811 count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC,
812 acpi_parse_lapic, MAX_APICS);
814 if (!count && !x2count) {
815 printk(KERN_ERR PREFIX "No LAPIC entries present\n");
816 /* TBD: Cleanup to allow fallback to MPS */
817 return -ENODEV;
818 } else if (count < 0 || x2count < 0) {
819 printk(KERN_ERR PREFIX "Error parsing LAPIC entry\n");
820 /* TBD: Cleanup to allow fallback to MPS */
821 return count;
824 x2count =
825 acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_X2APIC_NMI,
826 acpi_parse_x2apic_nmi, 0);
827 count =
828 acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_NMI, acpi_parse_lapic_nmi, 0);
829 if (count < 0 || x2count < 0) {
830 printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");
831 /* TBD: Cleanup to allow fallback to MPS */
832 return count;
834 return 0;
836 #endif /* CONFIG_X86_LOCAL_APIC */
838 #ifdef CONFIG_X86_IO_APIC
839 #define MP_ISA_BUS 0
841 #ifdef CONFIG_X86_ES7000
842 extern int es7000_plat;
843 #endif
845 int __init acpi_probe_gsi(void)
847 int idx;
848 int gsi;
849 int max_gsi = 0;
851 if (acpi_disabled)
852 return 0;
854 if (!acpi_ioapic)
855 return 0;
857 max_gsi = 0;
858 for (idx = 0; idx < nr_ioapics; idx++) {
859 gsi = mp_gsi_routing[idx].gsi_end;
861 if (gsi > max_gsi)
862 max_gsi = gsi;
865 return max_gsi + 1;
868 static void assign_to_mp_irq(struct mpc_intsrc *m,
869 struct mpc_intsrc *mp_irq)
871 memcpy(mp_irq, m, sizeof(struct mpc_intsrc));
874 static int mp_irq_cmp(struct mpc_intsrc *mp_irq,
875 struct mpc_intsrc *m)
877 return memcmp(mp_irq, m, sizeof(struct mpc_intsrc));
880 static void save_mp_irq(struct mpc_intsrc *m)
882 int i;
884 for (i = 0; i < mp_irq_entries; i++) {
885 if (!mp_irq_cmp(&mp_irqs[i], m))
886 return;
889 assign_to_mp_irq(m, &mp_irqs[mp_irq_entries]);
890 if (++mp_irq_entries == MAX_IRQ_SOURCES)
891 panic("Max # of irq sources exceeded!!\n");
894 void __init mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, u32 gsi)
896 int ioapic;
897 int pin;
898 struct mpc_intsrc mp_irq;
901 * Convert 'gsi' to 'ioapic.pin'.
903 ioapic = mp_find_ioapic(gsi);
904 if (ioapic < 0)
905 return;
906 pin = mp_find_ioapic_pin(ioapic, gsi);
909 * TBD: This check is for faulty timer entries, where the override
910 * erroneously sets the trigger to level, resulting in a HUGE
911 * increase of timer interrupts!
913 if ((bus_irq == 0) && (trigger == 3))
914 trigger = 1;
916 mp_irq.type = MP_INTSRC;
917 mp_irq.irqtype = mp_INT;
918 mp_irq.irqflag = (trigger << 2) | polarity;
919 mp_irq.srcbus = MP_ISA_BUS;
920 mp_irq.srcbusirq = bus_irq; /* IRQ */
921 mp_irq.dstapic = mp_ioapics[ioapic].apicid; /* APIC ID */
922 mp_irq.dstirq = pin; /* INTIN# */
924 save_mp_irq(&mp_irq);
927 void __init mp_config_acpi_legacy_irqs(void)
929 int i;
930 int ioapic;
931 unsigned int dstapic;
932 struct mpc_intsrc mp_irq;
934 #if defined (CONFIG_MCA) || defined (CONFIG_EISA)
936 * Fabricate the legacy ISA bus (bus #31).
938 mp_bus_id_to_type[MP_ISA_BUS] = MP_BUS_ISA;
939 #endif
940 set_bit(MP_ISA_BUS, mp_bus_not_pci);
941 pr_debug("Bus #%d is ISA\n", MP_ISA_BUS);
943 #ifdef CONFIG_X86_ES7000
945 * Older generations of ES7000 have no legacy identity mappings
947 if (es7000_plat == 1)
948 return;
949 #endif
952 * Locate the IOAPIC that manages the ISA IRQs (0-15).
954 ioapic = mp_find_ioapic(0);
955 if (ioapic < 0)
956 return;
957 dstapic = mp_ioapics[ioapic].apicid;
960 * Use the default configuration for the IRQs 0-15. Unless
961 * overridden by (MADT) interrupt source override entries.
963 for (i = 0; i < 16; i++) {
964 int idx;
966 for (idx = 0; idx < mp_irq_entries; idx++) {
967 struct mpc_intsrc *irq = mp_irqs + idx;
969 /* Do we already have a mapping for this ISA IRQ? */
970 if (irq->srcbus == MP_ISA_BUS && irq->srcbusirq == i)
971 break;
973 /* Do we already have a mapping for this IOAPIC pin */
974 if (irq->dstapic == dstapic && irq->dstirq == i)
975 break;
978 if (idx != mp_irq_entries) {
979 printk(KERN_DEBUG "ACPI: IRQ%d used by override.\n", i);
980 continue; /* IRQ already used */
983 mp_irq.type = MP_INTSRC;
984 mp_irq.irqflag = 0; /* Conforming */
985 mp_irq.srcbus = MP_ISA_BUS;
986 mp_irq.dstapic = dstapic;
987 mp_irq.irqtype = mp_INT;
988 mp_irq.srcbusirq = i; /* Identity mapped */
989 mp_irq.dstirq = i;
991 save_mp_irq(&mp_irq);
995 static int mp_config_acpi_gsi(struct device *dev, u32 gsi, int trigger,
996 int polarity)
998 #ifdef CONFIG_X86_MPPARSE
999 struct mpc_intsrc mp_irq;
1000 struct pci_dev *pdev;
1001 unsigned char number;
1002 unsigned int devfn;
1003 int ioapic;
1004 u8 pin;
1006 if (!acpi_ioapic)
1007 return 0;
1008 if (!dev)
1009 return 0;
1010 if (dev->bus != &pci_bus_type)
1011 return 0;
1013 pdev = to_pci_dev(dev);
1014 number = pdev->bus->number;
1015 devfn = pdev->devfn;
1016 pin = pdev->pin;
1017 /* print the entry should happen on mptable identically */
1018 mp_irq.type = MP_INTSRC;
1019 mp_irq.irqtype = mp_INT;
1020 mp_irq.irqflag = (trigger == ACPI_EDGE_SENSITIVE ? 4 : 0x0c) |
1021 (polarity == ACPI_ACTIVE_HIGH ? 1 : 3);
1022 mp_irq.srcbus = number;
1023 mp_irq.srcbusirq = (((devfn >> 3) & 0x1f) << 2) | ((pin - 1) & 3);
1024 ioapic = mp_find_ioapic(gsi);
1025 mp_irq.dstapic = mp_ioapics[ioapic].apicid;
1026 mp_irq.dstirq = mp_find_ioapic_pin(ioapic, gsi);
1028 save_mp_irq(&mp_irq);
1029 #endif
1030 return 0;
1033 int mp_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity)
1035 int ioapic;
1036 int ioapic_pin;
1037 struct io_apic_irq_attr irq_attr;
1039 if (acpi_irq_model != ACPI_IRQ_MODEL_IOAPIC)
1040 return gsi;
1042 /* Don't set up the ACPI SCI because it's already set up */
1043 if (acpi_gbl_FADT.sci_interrupt == gsi)
1044 return gsi;
1046 ioapic = mp_find_ioapic(gsi);
1047 if (ioapic < 0) {
1048 printk(KERN_WARNING "No IOAPIC for GSI %u\n", gsi);
1049 return gsi;
1052 ioapic_pin = mp_find_ioapic_pin(ioapic, gsi);
1054 #ifdef CONFIG_X86_32
1055 if (ioapic_renumber_irq)
1056 gsi = ioapic_renumber_irq(ioapic, gsi);
1057 #endif
1059 if (ioapic_pin > MP_MAX_IOAPIC_PIN) {
1060 printk(KERN_ERR "Invalid reference to IOAPIC pin "
1061 "%d-%d\n", mp_ioapics[ioapic].apicid,
1062 ioapic_pin);
1063 return gsi;
1066 if (enable_update_mptable)
1067 mp_config_acpi_gsi(dev, gsi, trigger, polarity);
1069 set_io_apic_irq_attr(&irq_attr, ioapic, ioapic_pin,
1070 trigger == ACPI_EDGE_SENSITIVE ? 0 : 1,
1071 polarity == ACPI_ACTIVE_HIGH ? 0 : 1);
1072 io_apic_set_pci_routing(dev, gsi, &irq_attr);
1074 return gsi;
1078 * Parse IOAPIC related entries in MADT
1079 * returns 0 on success, < 0 on error
1081 static int __init acpi_parse_madt_ioapic_entries(void)
1083 int count;
1086 * ACPI interpreter is required to complete interrupt setup,
1087 * so if it is off, don't enumerate the io-apics with ACPI.
1088 * If MPS is present, it will handle them,
1089 * otherwise the system will stay in PIC mode
1091 if (acpi_disabled || acpi_noirq)
1092 return -ENODEV;
1094 if (!cpu_has_apic)
1095 return -ENODEV;
1098 * if "noapic" boot option, don't look for IO-APICs
1100 if (skip_ioapic_setup) {
1101 printk(KERN_INFO PREFIX "Skipping IOAPIC probe "
1102 "due to 'noapic' option.\n");
1103 return -ENODEV;
1106 count =
1107 acpi_table_parse_madt(ACPI_MADT_TYPE_IO_APIC, acpi_parse_ioapic,
1108 MAX_IO_APICS);
1109 if (!count) {
1110 printk(KERN_ERR PREFIX "No IOAPIC entries present\n");
1111 return -ENODEV;
1112 } else if (count < 0) {
1113 printk(KERN_ERR PREFIX "Error parsing IOAPIC entry\n");
1114 return count;
1117 count =
1118 acpi_table_parse_madt(ACPI_MADT_TYPE_INTERRUPT_OVERRIDE, acpi_parse_int_src_ovr,
1119 nr_irqs);
1120 if (count < 0) {
1121 printk(KERN_ERR PREFIX
1122 "Error parsing interrupt source overrides entry\n");
1123 /* TBD: Cleanup to allow fallback to MPS */
1124 return count;
1128 * If BIOS did not supply an INT_SRC_OVR for the SCI
1129 * pretend we got one so we can set the SCI flags.
1131 if (!acpi_sci_override_gsi)
1132 acpi_sci_ioapic_setup(acpi_gbl_FADT.sci_interrupt, 0, 0);
1134 /* Fill in identity legacy mappings where no override */
1135 mp_config_acpi_legacy_irqs();
1137 count =
1138 acpi_table_parse_madt(ACPI_MADT_TYPE_NMI_SOURCE, acpi_parse_nmi_src,
1139 nr_irqs);
1140 if (count < 0) {
1141 printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n");
1142 /* TBD: Cleanup to allow fallback to MPS */
1143 return count;
1146 return 0;
1148 #else
1149 static inline int acpi_parse_madt_ioapic_entries(void)
1151 return -1;
1153 #endif /* !CONFIG_X86_IO_APIC */
1155 static void __init early_acpi_process_madt(void)
1157 #ifdef CONFIG_X86_LOCAL_APIC
1158 int error;
1160 if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) {
1163 * Parse MADT LAPIC entries
1165 error = early_acpi_parse_madt_lapic_addr_ovr();
1166 if (!error) {
1167 acpi_lapic = 1;
1168 smp_found_config = 1;
1170 if (error == -EINVAL) {
1172 * Dell Precision Workstation 410, 610 come here.
1174 printk(KERN_ERR PREFIX
1175 "Invalid BIOS MADT, disabling ACPI\n");
1176 disable_acpi();
1179 #endif
1182 static void __init acpi_process_madt(void)
1184 #ifdef CONFIG_X86_LOCAL_APIC
1185 int error;
1187 if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) {
1190 * Parse MADT LAPIC entries
1192 error = acpi_parse_madt_lapic_entries();
1193 if (!error) {
1194 acpi_lapic = 1;
1197 * Parse MADT IO-APIC entries
1199 error = acpi_parse_madt_ioapic_entries();
1200 if (!error) {
1201 acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC;
1202 acpi_ioapic = 1;
1204 smp_found_config = 1;
1207 if (error == -EINVAL) {
1209 * Dell Precision Workstation 410, 610 come here.
1211 printk(KERN_ERR PREFIX
1212 "Invalid BIOS MADT, disabling ACPI\n");
1213 disable_acpi();
1215 } else {
1217 * ACPI found no MADT, and so ACPI wants UP PIC mode.
1218 * In the event an MPS table was found, forget it.
1219 * Boot with "acpi=off" to use MPS on such a system.
1221 if (smp_found_config) {
1222 printk(KERN_WARNING PREFIX
1223 "No APIC-table, disabling MPS\n");
1224 smp_found_config = 0;
1229 * ACPI supports both logical (e.g. Hyper-Threading) and physical
1230 * processors, where MPS only supports physical.
1232 if (acpi_lapic && acpi_ioapic)
1233 printk(KERN_INFO "Using ACPI (MADT) for SMP configuration "
1234 "information\n");
1235 else if (acpi_lapic)
1236 printk(KERN_INFO "Using ACPI for processor (LAPIC) "
1237 "configuration information\n");
1238 #endif
1239 return;
1242 static int __init disable_acpi_irq(const struct dmi_system_id *d)
1244 if (!acpi_force) {
1245 printk(KERN_NOTICE "%s detected: force use of acpi=noirq\n",
1246 d->ident);
1247 acpi_noirq_set();
1249 return 0;
1252 static int __init disable_acpi_pci(const struct dmi_system_id *d)
1254 if (!acpi_force) {
1255 printk(KERN_NOTICE "%s detected: force use of pci=noacpi\n",
1256 d->ident);
1257 acpi_disable_pci();
1259 return 0;
1262 static int __init dmi_disable_acpi(const struct dmi_system_id *d)
1264 if (!acpi_force) {
1265 printk(KERN_NOTICE "%s detected: acpi off\n", d->ident);
1266 disable_acpi();
1267 } else {
1268 printk(KERN_NOTICE
1269 "Warning: DMI blacklist says broken, but acpi forced\n");
1271 return 0;
1275 * Limit ACPI to CPU enumeration for HT
1277 static int __init force_acpi_ht(const struct dmi_system_id *d)
1279 if (!acpi_force) {
1280 printk(KERN_NOTICE "%s detected: force use of acpi=ht\n",
1281 d->ident);
1282 disable_acpi();
1283 acpi_ht = 1;
1284 } else {
1285 printk(KERN_NOTICE
1286 "Warning: acpi=force overrules DMI blacklist: acpi=ht\n");
1288 return 0;
1292 * Force ignoring BIOS IRQ0 pin2 override
1294 static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
1297 * The ati_ixp4x0_rev() early PCI quirk should have set
1298 * the acpi_skip_timer_override flag already:
1300 if (!acpi_skip_timer_override) {
1301 WARN(1, KERN_ERR "ati_ixp4x0 quirk not complete.\n");
1302 pr_notice("%s detected: Ignoring BIOS IRQ0 pin2 override\n",
1303 d->ident);
1304 acpi_skip_timer_override = 1;
1306 return 0;
1310 * If your system is blacklisted here, but you find that acpi=force
1311 * works for you, please contact linux-acpi@vger.kernel.org
1313 static struct dmi_system_id __initdata acpi_dmi_table[] = {
1315 * Boxes that need ACPI disabled
1318 .callback = dmi_disable_acpi,
1319 .ident = "IBM Thinkpad",
1320 .matches = {
1321 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1322 DMI_MATCH(DMI_BOARD_NAME, "2629H1G"),
1327 * Boxes that need acpi=ht
1330 .callback = force_acpi_ht,
1331 .ident = "FSC Primergy T850",
1332 .matches = {
1333 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
1334 DMI_MATCH(DMI_PRODUCT_NAME, "PRIMERGY T850"),
1338 .callback = force_acpi_ht,
1339 .ident = "HP VISUALIZE NT Workstation",
1340 .matches = {
1341 DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
1342 DMI_MATCH(DMI_PRODUCT_NAME, "HP VISUALIZE NT Workstation"),
1346 .callback = force_acpi_ht,
1347 .ident = "Compaq Workstation W8000",
1348 .matches = {
1349 DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
1350 DMI_MATCH(DMI_PRODUCT_NAME, "Workstation W8000"),
1354 .callback = force_acpi_ht,
1355 .ident = "ASUS P2B-DS",
1356 .matches = {
1357 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
1358 DMI_MATCH(DMI_BOARD_NAME, "P2B-DS"),
1362 .callback = force_acpi_ht,
1363 .ident = "ASUS CUR-DLS",
1364 .matches = {
1365 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
1366 DMI_MATCH(DMI_BOARD_NAME, "CUR-DLS"),
1370 .callback = force_acpi_ht,
1371 .ident = "ABIT i440BX-W83977",
1372 .matches = {
1373 DMI_MATCH(DMI_BOARD_VENDOR, "ABIT <http://www.abit.com>"),
1374 DMI_MATCH(DMI_BOARD_NAME, "i440BX-W83977 (BP6)"),
1378 .callback = force_acpi_ht,
1379 .ident = "IBM Bladecenter",
1380 .matches = {
1381 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1382 DMI_MATCH(DMI_BOARD_NAME, "IBM eServer BladeCenter HS20"),
1386 .callback = force_acpi_ht,
1387 .ident = "IBM eServer xSeries 360",
1388 .matches = {
1389 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1390 DMI_MATCH(DMI_BOARD_NAME, "eServer xSeries 360"),
1394 .callback = force_acpi_ht,
1395 .ident = "IBM eserver xSeries 330",
1396 .matches = {
1397 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1398 DMI_MATCH(DMI_BOARD_NAME, "eserver xSeries 330"),
1402 .callback = force_acpi_ht,
1403 .ident = "IBM eserver xSeries 440",
1404 .matches = {
1405 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1406 DMI_MATCH(DMI_PRODUCT_NAME, "eserver xSeries 440"),
1411 * Boxes that need ACPI PCI IRQ routing disabled
1414 .callback = disable_acpi_irq,
1415 .ident = "ASUS A7V",
1416 .matches = {
1417 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC"),
1418 DMI_MATCH(DMI_BOARD_NAME, "<A7V>"),
1419 /* newer BIOS, Revision 1011, does work */
1420 DMI_MATCH(DMI_BIOS_VERSION,
1421 "ASUS A7V ACPI BIOS Revision 1007"),
1426 * Latest BIOS for IBM 600E (1.16) has bad pcinum
1427 * for LPC bridge, which is needed for the PCI
1428 * interrupt links to work. DSDT fix is in bug 5966.
1429 * 2645, 2646 model numbers are shared with 600/600E/600X
1431 .callback = disable_acpi_irq,
1432 .ident = "IBM Thinkpad 600 Series 2645",
1433 .matches = {
1434 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1435 DMI_MATCH(DMI_BOARD_NAME, "2645"),
1439 .callback = disable_acpi_irq,
1440 .ident = "IBM Thinkpad 600 Series 2646",
1441 .matches = {
1442 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1443 DMI_MATCH(DMI_BOARD_NAME, "2646"),
1447 * Boxes that need ACPI PCI IRQ routing and PCI scan disabled
1449 { /* _BBN 0 bug */
1450 .callback = disable_acpi_pci,
1451 .ident = "ASUS PR-DLS",
1452 .matches = {
1453 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
1454 DMI_MATCH(DMI_BOARD_NAME, "PR-DLS"),
1455 DMI_MATCH(DMI_BIOS_VERSION,
1456 "ASUS PR-DLS ACPI BIOS Revision 1010"),
1457 DMI_MATCH(DMI_BIOS_DATE, "03/21/2003")
1461 .callback = disable_acpi_pci,
1462 .ident = "Acer TravelMate 36x Laptop",
1463 .matches = {
1464 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
1465 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
1471 /* second table for DMI checks that should run after early-quirks */
1472 static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
1474 * HP laptops which use a DSDT reporting as HP/SB400/10000,
1475 * which includes some code which overrides all temperature
1476 * trip points to 16C if the INTIN2 input of the I/O APIC
1477 * is enabled. This input is incorrectly designated the
1478 * ISA IRQ 0 via an interrupt source override even though
1479 * it is wired to the output of the master 8259A and INTIN0
1480 * is not connected at all. Force ignoring BIOS IRQ0 pin2
1481 * override in that cases.
1484 .callback = dmi_ignore_irq0_timer_override,
1485 .ident = "HP nx6115 laptop",
1486 .matches = {
1487 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1488 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6115"),
1492 .callback = dmi_ignore_irq0_timer_override,
1493 .ident = "HP NX6125 laptop",
1494 .matches = {
1495 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1496 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6125"),
1500 .callback = dmi_ignore_irq0_timer_override,
1501 .ident = "HP NX6325 laptop",
1502 .matches = {
1503 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1504 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6325"),
1508 .callback = dmi_ignore_irq0_timer_override,
1509 .ident = "HP 6715b laptop",
1510 .matches = {
1511 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1512 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq 6715b"),
1519 * acpi_boot_table_init() and acpi_boot_init()
1520 * called from setup_arch(), always.
1521 * 1. checksums all tables
1522 * 2. enumerates lapics
1523 * 3. enumerates io-apics
1525 * acpi_table_init() is separate to allow reading SRAT without
1526 * other side effects.
1528 * side effects of acpi_boot_init:
1529 * acpi_lapic = 1 if LAPIC found
1530 * acpi_ioapic = 1 if IOAPIC found
1531 * if (acpi_lapic && acpi_ioapic) smp_found_config = 1;
1532 * if acpi_blacklisted() acpi_disabled = 1;
1533 * acpi_irq_model=...
1534 * ...
1537 void __init acpi_boot_table_init(void)
1539 dmi_check_system(acpi_dmi_table);
1542 * If acpi_disabled, bail out
1543 * One exception: acpi=ht continues far enough to enumerate LAPICs
1545 if (acpi_disabled && !acpi_ht)
1546 return;
1549 * Initialize the ACPI boot-time table parser.
1551 if (acpi_table_init()) {
1552 disable_acpi();
1553 return;
1556 acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
1559 * blacklist may disable ACPI entirely
1561 if (acpi_blacklisted()) {
1562 if (acpi_force) {
1563 printk(KERN_WARNING PREFIX "acpi=force override\n");
1564 } else {
1565 printk(KERN_WARNING PREFIX "Disabling ACPI support\n");
1566 disable_acpi();
1567 return;
1572 int __init early_acpi_boot_init(void)
1575 * If acpi_disabled, bail out
1576 * One exception: acpi=ht continues far enough to enumerate LAPICs
1578 if (acpi_disabled && !acpi_ht)
1579 return 1;
1582 * Process the Multiple APIC Description Table (MADT), if present
1584 early_acpi_process_madt();
1586 return 0;
1589 int __init acpi_boot_init(void)
1591 /* those are executed after early-quirks are executed */
1592 dmi_check_system(acpi_dmi_table_late);
1595 * If acpi_disabled, bail out
1596 * One exception: acpi=ht continues far enough to enumerate LAPICs
1598 if (acpi_disabled && !acpi_ht)
1599 return 1;
1601 acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
1604 * set sci_int and PM timer address
1606 acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt);
1609 * Process the Multiple APIC Description Table (MADT), if present
1611 acpi_process_madt();
1613 acpi_table_parse(ACPI_SIG_HPET, acpi_parse_hpet);
1615 if (!acpi_noirq)
1616 x86_init.pci.init = pci_acpi_init;
1618 return 0;
1621 static int __init parse_acpi(char *arg)
1623 if (!arg)
1624 return -EINVAL;
1626 /* "acpi=off" disables both ACPI table parsing and interpreter */
1627 if (strcmp(arg, "off") == 0) {
1628 disable_acpi();
1630 /* acpi=force to over-ride black-list */
1631 else if (strcmp(arg, "force") == 0) {
1632 acpi_force = 1;
1633 acpi_ht = 1;
1634 acpi_disabled = 0;
1636 /* acpi=strict disables out-of-spec workarounds */
1637 else if (strcmp(arg, "strict") == 0) {
1638 acpi_strict = 1;
1640 /* Limit ACPI just to boot-time to enable HT */
1641 else if (strcmp(arg, "ht") == 0) {
1642 if (!acpi_force)
1643 disable_acpi();
1644 acpi_ht = 1;
1646 /* acpi=rsdt use RSDT instead of XSDT */
1647 else if (strcmp(arg, "rsdt") == 0) {
1648 acpi_rsdt_forced = 1;
1650 /* "acpi=noirq" disables ACPI interrupt routing */
1651 else if (strcmp(arg, "noirq") == 0) {
1652 acpi_noirq_set();
1653 } else {
1654 /* Core will printk when we return error. */
1655 return -EINVAL;
1657 return 0;
1659 early_param("acpi", parse_acpi);
1661 /* FIXME: Using pci= for an ACPI parameter is a travesty. */
1662 static int __init parse_pci(char *arg)
1664 if (arg && strcmp(arg, "noacpi") == 0)
1665 acpi_disable_pci();
1666 return 0;
1668 early_param("pci", parse_pci);
1670 int __init acpi_mps_check(void)
1672 #if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_X86_MPPARSE)
1673 /* mptable code is not built-in*/
1674 if (acpi_disabled || acpi_noirq) {
1675 printk(KERN_WARNING "MPS support code is not built-in.\n"
1676 "Using acpi=off or acpi=noirq or pci=noacpi "
1677 "may have problem\n");
1678 return 1;
1680 #endif
1681 return 0;
1684 #ifdef CONFIG_X86_IO_APIC
1685 static int __init parse_acpi_skip_timer_override(char *arg)
1687 acpi_skip_timer_override = 1;
1688 return 0;
1690 early_param("acpi_skip_timer_override", parse_acpi_skip_timer_override);
1692 static int __init parse_acpi_use_timer_override(char *arg)
1694 acpi_use_timer_override = 1;
1695 return 0;
1697 early_param("acpi_use_timer_override", parse_acpi_use_timer_override);
1698 #endif /* CONFIG_X86_IO_APIC */
1700 static int __init setup_acpi_sci(char *s)
1702 if (!s)
1703 return -EINVAL;
1704 if (!strcmp(s, "edge"))
1705 acpi_sci_flags = ACPI_MADT_TRIGGER_EDGE |
1706 (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK);
1707 else if (!strcmp(s, "level"))
1708 acpi_sci_flags = ACPI_MADT_TRIGGER_LEVEL |
1709 (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK);
1710 else if (!strcmp(s, "high"))
1711 acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_HIGH |
1712 (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK);
1713 else if (!strcmp(s, "low"))
1714 acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_LOW |
1715 (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK);
1716 else
1717 return -EINVAL;
1718 return 0;
1720 early_param("acpi_sci", setup_acpi_sci);
1722 int __acpi_acquire_global_lock(unsigned int *lock)
1724 unsigned int old, new, val;
1725 do {
1726 old = *lock;
1727 new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1));
1728 val = cmpxchg(lock, old, new);
1729 } while (unlikely (val != old));
1730 return (new < 3) ? -1 : 0;
1733 int __acpi_release_global_lock(unsigned int *lock)
1735 unsigned int old, new, val;
1736 do {
1737 old = *lock;
1738 new = old & ~0x3;
1739 val = cmpxchg(lock, old, new);
1740 } while (unlikely (val != old));
1741 return old & 0x1;