x86 quirk: Fix polarity for IRQ0 pin2 override on SB800 systems
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / x86 / kernel / acpi / boot.c
blob8ba08c7abd04577b9297b16065e710f0f9c9c17f
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/pgtable.h>
39 #include <asm/io_apic.h>
40 #include <asm/apic.h>
41 #include <asm/io.h>
42 #include <asm/mpspec.h>
43 #include <asm/smp.h>
45 static int __initdata acpi_force = 0;
46 u32 acpi_rsdt_forced;
47 int acpi_disabled;
48 EXPORT_SYMBOL(acpi_disabled);
50 #ifdef CONFIG_X86_64
51 # include <asm/proto.h>
52 #endif /* X86 */
54 #define BAD_MADT_ENTRY(entry, end) ( \
55 (!entry) || (unsigned long)entry + sizeof(*entry) > end || \
56 ((struct acpi_subtable_header *)entry)->length < sizeof(*entry))
58 #define PREFIX "ACPI: "
60 int acpi_noirq; /* skip ACPI IRQ initialization */
61 int acpi_pci_disabled; /* skip ACPI PCI scan and IRQ initialization */
62 EXPORT_SYMBOL(acpi_pci_disabled);
63 int acpi_ht __initdata = 1; /* enable HT */
65 int acpi_lapic;
66 int acpi_ioapic;
67 int acpi_strict;
69 u8 acpi_sci_flags __initdata;
70 int acpi_sci_override_gsi __initdata;
71 int acpi_skip_timer_override __initdata;
72 int acpi_use_timer_override __initdata;
73 int acpi_fix_pin2_polarity __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 (intsrc->source_irq == 0 && intsrc->global_irq == 2) {
365 if (acpi_skip_timer_override) {
366 printk(PREFIX "BIOS IRQ0 pin2 override ignored.\n");
367 return 0;
369 if (acpi_fix_pin2_polarity && (intsrc->inti_flags & ACPI_MADT_POLARITY_MASK)) {
370 intsrc->inti_flags &= ~ACPI_MADT_POLARITY_MASK;
371 printk(PREFIX "BIOS IRQ0 pin2 override: forcing polarity to high active.\n");
375 mp_override_legacy_irq(intsrc->source_irq,
376 intsrc->inti_flags & ACPI_MADT_POLARITY_MASK,
377 (intsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2,
378 intsrc->global_irq);
380 return 0;
383 static int __init
384 acpi_parse_nmi_src(struct acpi_subtable_header * header, const unsigned long end)
386 struct acpi_madt_nmi_source *nmi_src = NULL;
388 nmi_src = (struct acpi_madt_nmi_source *)header;
390 if (BAD_MADT_ENTRY(nmi_src, end))
391 return -EINVAL;
393 acpi_table_print_madt_entry(header);
395 /* TBD: Support nimsrc entries? */
397 return 0;
400 #endif /* CONFIG_X86_IO_APIC */
403 * acpi_pic_sci_set_trigger()
405 * use ELCR to set PIC-mode trigger type for SCI
407 * If a PIC-mode SCI is not recognized or gives spurious IRQ7's
408 * it may require Edge Trigger -- use "acpi_sci=edge"
410 * Port 0x4d0-4d1 are ECLR1 and ECLR2, the Edge/Level Control Registers
411 * for the 8259 PIC. bit[n] = 1 means irq[n] is Level, otherwise Edge.
412 * ECLR1 is IRQs 0-7 (IRQ 0, 1, 2 must be 0)
413 * ECLR2 is IRQs 8-15 (IRQ 8, 13 must be 0)
416 void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
418 unsigned int mask = 1 << irq;
419 unsigned int old, new;
421 /* Real old ELCR mask */
422 old = inb(0x4d0) | (inb(0x4d1) << 8);
425 * If we use ACPI to set PCI IRQs, then we should clear ELCR
426 * since we will set it correctly as we enable the PCI irq
427 * routing.
429 new = acpi_noirq ? old : 0;
432 * Update SCI information in the ELCR, it isn't in the PCI
433 * routing tables..
435 switch (trigger) {
436 case 1: /* Edge - clear */
437 new &= ~mask;
438 break;
439 case 3: /* Level - set */
440 new |= mask;
441 break;
444 if (old == new)
445 return;
447 printk(PREFIX "setting ELCR to %04x (from %04x)\n", new, old);
448 outb(new, 0x4d0);
449 outb(new >> 8, 0x4d1);
452 int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
454 *irq = gsi;
456 #ifdef CONFIG_X86_IO_APIC
457 if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC)
458 setup_IO_APIC_irq_extra(gsi);
459 #endif
461 return 0;
465 * success: return IRQ number (>=0)
466 * failure: return < 0
468 int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity)
470 unsigned int irq;
471 unsigned int plat_gsi = gsi;
473 #ifdef CONFIG_PCI
475 * Make sure all (legacy) PCI IRQs are set as level-triggered.
477 if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
478 if (trigger == ACPI_LEVEL_SENSITIVE)
479 eisa_set_level_irq(gsi);
481 #endif
483 #ifdef CONFIG_X86_IO_APIC
484 if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) {
485 plat_gsi = mp_register_gsi(dev, gsi, trigger, polarity);
487 #endif
488 irq = plat_gsi;
490 return irq;
494 * ACPI based hotplug support for CPU
496 #ifdef CONFIG_ACPI_HOTPLUG_CPU
498 static int __cpuinit _acpi_map_lsapic(acpi_handle handle, int *pcpu)
500 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
501 union acpi_object *obj;
502 struct acpi_madt_local_apic *lapic;
503 cpumask_var_t tmp_map, new_map;
504 u8 physid;
505 int cpu;
506 int retval = -ENOMEM;
508 if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
509 return -EINVAL;
511 if (!buffer.length || !buffer.pointer)
512 return -EINVAL;
514 obj = buffer.pointer;
515 if (obj->type != ACPI_TYPE_BUFFER ||
516 obj->buffer.length < sizeof(*lapic)) {
517 kfree(buffer.pointer);
518 return -EINVAL;
521 lapic = (struct acpi_madt_local_apic *)obj->buffer.pointer;
523 if (lapic->header.type != ACPI_MADT_TYPE_LOCAL_APIC ||
524 !(lapic->lapic_flags & ACPI_MADT_ENABLED)) {
525 kfree(buffer.pointer);
526 return -EINVAL;
529 physid = lapic->id;
531 kfree(buffer.pointer);
532 buffer.length = ACPI_ALLOCATE_BUFFER;
533 buffer.pointer = NULL;
535 if (!alloc_cpumask_var(&tmp_map, GFP_KERNEL))
536 goto out;
538 if (!alloc_cpumask_var(&new_map, GFP_KERNEL))
539 goto free_tmp_map;
541 cpumask_copy(tmp_map, cpu_present_mask);
542 acpi_register_lapic(physid, lapic->lapic_flags & ACPI_MADT_ENABLED);
545 * If mp_register_lapic successfully generates a new logical cpu
546 * number, then the following will get us exactly what was mapped
548 cpumask_andnot(new_map, cpu_present_mask, tmp_map);
549 if (cpumask_empty(new_map)) {
550 printk ("Unable to map lapic to logical cpu number\n");
551 retval = -EINVAL;
552 goto free_new_map;
555 cpu = cpumask_first(new_map);
557 *pcpu = cpu;
558 retval = 0;
560 free_new_map:
561 free_cpumask_var(new_map);
562 free_tmp_map:
563 free_cpumask_var(tmp_map);
564 out:
565 return retval;
568 /* wrapper to silence section mismatch warning */
569 int __ref acpi_map_lsapic(acpi_handle handle, int *pcpu)
571 return _acpi_map_lsapic(handle, pcpu);
573 EXPORT_SYMBOL(acpi_map_lsapic);
575 int acpi_unmap_lsapic(int cpu)
577 per_cpu(x86_cpu_to_apicid, cpu) = -1;
578 set_cpu_present(cpu, false);
579 num_processors--;
581 return (0);
584 EXPORT_SYMBOL(acpi_unmap_lsapic);
585 #endif /* CONFIG_ACPI_HOTPLUG_CPU */
587 int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
589 /* TBD */
590 return -EINVAL;
593 EXPORT_SYMBOL(acpi_register_ioapic);
595 int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
597 /* TBD */
598 return -EINVAL;
601 EXPORT_SYMBOL(acpi_unregister_ioapic);
603 static int __init acpi_parse_sbf(struct acpi_table_header *table)
605 struct acpi_table_boot *sb;
607 sb = (struct acpi_table_boot *)table;
608 if (!sb) {
609 printk(KERN_WARNING PREFIX "Unable to map SBF\n");
610 return -ENODEV;
613 sbf_port = sb->cmos_index; /* Save CMOS port */
615 return 0;
618 #ifdef CONFIG_HPET_TIMER
619 #include <asm/hpet.h>
621 static struct __initdata resource *hpet_res;
623 static int __init acpi_parse_hpet(struct acpi_table_header *table)
625 struct acpi_table_hpet *hpet_tbl;
627 hpet_tbl = (struct acpi_table_hpet *)table;
628 if (!hpet_tbl) {
629 printk(KERN_WARNING PREFIX "Unable to map HPET\n");
630 return -ENODEV;
633 if (hpet_tbl->address.space_id != ACPI_SPACE_MEM) {
634 printk(KERN_WARNING PREFIX "HPET timers must be located in "
635 "memory.\n");
636 return -1;
639 hpet_address = hpet_tbl->address.address;
642 * Some broken BIOSes advertise HPET at 0x0. We really do not
643 * want to allocate a resource there.
645 if (!hpet_address) {
646 printk(KERN_WARNING PREFIX
647 "HPET id: %#x base: %#lx is invalid\n",
648 hpet_tbl->id, hpet_address);
649 return 0;
651 #ifdef CONFIG_X86_64
653 * Some even more broken BIOSes advertise HPET at
654 * 0xfed0000000000000 instead of 0xfed00000. Fix it up and add
655 * some noise:
657 if (hpet_address == 0xfed0000000000000UL) {
658 if (!hpet_force_user) {
659 printk(KERN_WARNING PREFIX "HPET id: %#x "
660 "base: 0xfed0000000000000 is bogus\n "
661 "try hpet=force on the kernel command line to "
662 "fix it up to 0xfed00000.\n", hpet_tbl->id);
663 hpet_address = 0;
664 return 0;
666 printk(KERN_WARNING PREFIX
667 "HPET id: %#x base: 0xfed0000000000000 fixed up "
668 "to 0xfed00000.\n", hpet_tbl->id);
669 hpet_address >>= 32;
671 #endif
672 printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
673 hpet_tbl->id, hpet_address);
676 * Allocate and initialize the HPET firmware resource for adding into
677 * the resource tree during the lateinit timeframe.
679 #define HPET_RESOURCE_NAME_SIZE 9
680 hpet_res = alloc_bootmem(sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE);
682 hpet_res->name = (void *)&hpet_res[1];
683 hpet_res->flags = IORESOURCE_MEM;
684 snprintf((char *)hpet_res->name, HPET_RESOURCE_NAME_SIZE, "HPET %u",
685 hpet_tbl->sequence);
687 hpet_res->start = hpet_address;
688 hpet_res->end = hpet_address + (1 * 1024) - 1;
690 return 0;
694 * hpet_insert_resource inserts the HPET resources used into the resource
695 * tree.
697 static __init int hpet_insert_resource(void)
699 if (!hpet_res)
700 return 1;
702 return insert_resource(&iomem_resource, hpet_res);
705 late_initcall(hpet_insert_resource);
707 #else
708 #define acpi_parse_hpet NULL
709 #endif
711 static int __init acpi_parse_fadt(struct acpi_table_header *table)
714 #ifdef CONFIG_X86_PM_TIMER
715 /* detect the location of the ACPI PM Timer */
716 if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID) {
717 /* FADT rev. 2 */
718 if (acpi_gbl_FADT.xpm_timer_block.space_id !=
719 ACPI_ADR_SPACE_SYSTEM_IO)
720 return 0;
722 pmtmr_ioport = acpi_gbl_FADT.xpm_timer_block.address;
724 * "X" fields are optional extensions to the original V1.0
725 * fields, so we must selectively expand V1.0 fields if the
726 * corresponding X field is zero.
728 if (!pmtmr_ioport)
729 pmtmr_ioport = acpi_gbl_FADT.pm_timer_block;
730 } else {
731 /* FADT rev. 1 */
732 pmtmr_ioport = acpi_gbl_FADT.pm_timer_block;
734 if (pmtmr_ioport)
735 printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n",
736 pmtmr_ioport);
737 #endif
738 return 0;
741 #ifdef CONFIG_X86_LOCAL_APIC
743 * Parse LAPIC entries in MADT
744 * returns 0 on success, < 0 on error
747 static void __init acpi_register_lapic_address(unsigned long address)
749 mp_lapic_addr = address;
751 set_fixmap_nocache(FIX_APIC_BASE, address);
752 if (boot_cpu_physical_apicid == -1U) {
753 boot_cpu_physical_apicid = read_apic_id();
754 apic_version[boot_cpu_physical_apicid] =
755 GET_APIC_VERSION(apic_read(APIC_LVR));
759 static int __init early_acpi_parse_madt_lapic_addr_ovr(void)
761 int count;
763 if (!cpu_has_apic)
764 return -ENODEV;
767 * Note that the LAPIC address is obtained from the MADT (32-bit value)
768 * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value).
771 count =
772 acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE,
773 acpi_parse_lapic_addr_ovr, 0);
774 if (count < 0) {
775 printk(KERN_ERR PREFIX
776 "Error parsing LAPIC address override entry\n");
777 return count;
780 acpi_register_lapic_address(acpi_lapic_addr);
782 return count;
785 static int __init acpi_parse_madt_lapic_entries(void)
787 int count;
788 int x2count = 0;
790 if (!cpu_has_apic)
791 return -ENODEV;
794 * Note that the LAPIC address is obtained from the MADT (32-bit value)
795 * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value).
798 count =
799 acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE,
800 acpi_parse_lapic_addr_ovr, 0);
801 if (count < 0) {
802 printk(KERN_ERR PREFIX
803 "Error parsing LAPIC address override entry\n");
804 return count;
807 acpi_register_lapic_address(acpi_lapic_addr);
809 count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_SAPIC,
810 acpi_parse_sapic, MAX_APICS);
812 if (!count) {
813 x2count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_X2APIC,
814 acpi_parse_x2apic, MAX_APICS);
815 count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC,
816 acpi_parse_lapic, MAX_APICS);
818 if (!count && !x2count) {
819 printk(KERN_ERR PREFIX "No LAPIC entries present\n");
820 /* TBD: Cleanup to allow fallback to MPS */
821 return -ENODEV;
822 } else if (count < 0 || x2count < 0) {
823 printk(KERN_ERR PREFIX "Error parsing LAPIC entry\n");
824 /* TBD: Cleanup to allow fallback to MPS */
825 return count;
828 x2count =
829 acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_X2APIC_NMI,
830 acpi_parse_x2apic_nmi, 0);
831 count =
832 acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_NMI, acpi_parse_lapic_nmi, 0);
833 if (count < 0 || x2count < 0) {
834 printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");
835 /* TBD: Cleanup to allow fallback to MPS */
836 return count;
838 return 0;
840 #endif /* CONFIG_X86_LOCAL_APIC */
842 #ifdef CONFIG_X86_IO_APIC
843 #define MP_ISA_BUS 0
845 #ifdef CONFIG_X86_ES7000
846 extern int es7000_plat;
847 #endif
849 int __init acpi_probe_gsi(void)
851 int idx;
852 int gsi;
853 int max_gsi = 0;
855 if (acpi_disabled)
856 return 0;
858 if (!acpi_ioapic)
859 return 0;
861 max_gsi = 0;
862 for (idx = 0; idx < nr_ioapics; idx++) {
863 gsi = mp_gsi_routing[idx].gsi_end;
865 if (gsi > max_gsi)
866 max_gsi = gsi;
869 return max_gsi + 1;
872 static void assign_to_mp_irq(struct mpc_intsrc *m,
873 struct mpc_intsrc *mp_irq)
875 memcpy(mp_irq, m, sizeof(struct mpc_intsrc));
878 static int mp_irq_cmp(struct mpc_intsrc *mp_irq,
879 struct mpc_intsrc *m)
881 return memcmp(mp_irq, m, sizeof(struct mpc_intsrc));
884 static void save_mp_irq(struct mpc_intsrc *m)
886 int i;
888 for (i = 0; i < mp_irq_entries; i++) {
889 if (!mp_irq_cmp(&mp_irqs[i], m))
890 return;
893 assign_to_mp_irq(m, &mp_irqs[mp_irq_entries]);
894 if (++mp_irq_entries == MAX_IRQ_SOURCES)
895 panic("Max # of irq sources exceeded!!\n");
898 void __init mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, u32 gsi)
900 int ioapic;
901 int pin;
902 struct mpc_intsrc mp_irq;
905 * Convert 'gsi' to 'ioapic.pin'.
907 ioapic = mp_find_ioapic(gsi);
908 if (ioapic < 0)
909 return;
910 pin = mp_find_ioapic_pin(ioapic, gsi);
913 * TBD: This check is for faulty timer entries, where the override
914 * erroneously sets the trigger to level, resulting in a HUGE
915 * increase of timer interrupts!
917 if ((bus_irq == 0) && (trigger == 3))
918 trigger = 1;
920 mp_irq.type = MP_INTSRC;
921 mp_irq.irqtype = mp_INT;
922 mp_irq.irqflag = (trigger << 2) | polarity;
923 mp_irq.srcbus = MP_ISA_BUS;
924 mp_irq.srcbusirq = bus_irq; /* IRQ */
925 mp_irq.dstapic = mp_ioapics[ioapic].apicid; /* APIC ID */
926 mp_irq.dstirq = pin; /* INTIN# */
928 save_mp_irq(&mp_irq);
931 void __init mp_config_acpi_legacy_irqs(void)
933 int i;
934 int ioapic;
935 unsigned int dstapic;
936 struct mpc_intsrc mp_irq;
938 #if defined (CONFIG_MCA) || defined (CONFIG_EISA)
940 * Fabricate the legacy ISA bus (bus #31).
942 mp_bus_id_to_type[MP_ISA_BUS] = MP_BUS_ISA;
943 #endif
944 set_bit(MP_ISA_BUS, mp_bus_not_pci);
945 pr_debug("Bus #%d is ISA\n", MP_ISA_BUS);
947 #ifdef CONFIG_X86_ES7000
949 * Older generations of ES7000 have no legacy identity mappings
951 if (es7000_plat == 1)
952 return;
953 #endif
956 * Locate the IOAPIC that manages the ISA IRQs (0-15).
958 ioapic = mp_find_ioapic(0);
959 if (ioapic < 0)
960 return;
961 dstapic = mp_ioapics[ioapic].apicid;
964 * Use the default configuration for the IRQs 0-15. Unless
965 * overridden by (MADT) interrupt source override entries.
967 for (i = 0; i < 16; i++) {
968 int idx;
970 for (idx = 0; idx < mp_irq_entries; idx++) {
971 struct mpc_intsrc *irq = mp_irqs + idx;
973 /* Do we already have a mapping for this ISA IRQ? */
974 if (irq->srcbus == MP_ISA_BUS && irq->srcbusirq == i)
975 break;
977 /* Do we already have a mapping for this IOAPIC pin */
978 if (irq->dstapic == dstapic && irq->dstirq == i)
979 break;
982 if (idx != mp_irq_entries) {
983 printk(KERN_DEBUG "ACPI: IRQ%d used by override.\n", i);
984 continue; /* IRQ already used */
987 mp_irq.type = MP_INTSRC;
988 mp_irq.irqflag = 0; /* Conforming */
989 mp_irq.srcbus = MP_ISA_BUS;
990 mp_irq.dstapic = dstapic;
991 mp_irq.irqtype = mp_INT;
992 mp_irq.srcbusirq = i; /* Identity mapped */
993 mp_irq.dstirq = i;
995 save_mp_irq(&mp_irq);
999 static int mp_config_acpi_gsi(struct device *dev, u32 gsi, int trigger,
1000 int polarity)
1002 #ifdef CONFIG_X86_MPPARSE
1003 struct mpc_intsrc mp_irq;
1004 struct pci_dev *pdev;
1005 unsigned char number;
1006 unsigned int devfn;
1007 int ioapic;
1008 u8 pin;
1010 if (!acpi_ioapic)
1011 return 0;
1012 if (!dev)
1013 return 0;
1014 if (dev->bus != &pci_bus_type)
1015 return 0;
1017 pdev = to_pci_dev(dev);
1018 number = pdev->bus->number;
1019 devfn = pdev->devfn;
1020 pin = pdev->pin;
1021 /* print the entry should happen on mptable identically */
1022 mp_irq.type = MP_INTSRC;
1023 mp_irq.irqtype = mp_INT;
1024 mp_irq.irqflag = (trigger == ACPI_EDGE_SENSITIVE ? 4 : 0x0c) |
1025 (polarity == ACPI_ACTIVE_HIGH ? 1 : 3);
1026 mp_irq.srcbus = number;
1027 mp_irq.srcbusirq = (((devfn >> 3) & 0x1f) << 2) | ((pin - 1) & 3);
1028 ioapic = mp_find_ioapic(gsi);
1029 mp_irq.dstapic = mp_ioapics[ioapic].apicid;
1030 mp_irq.dstirq = mp_find_ioapic_pin(ioapic, gsi);
1032 save_mp_irq(&mp_irq);
1033 #endif
1034 return 0;
1037 int mp_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity)
1039 int ioapic;
1040 int ioapic_pin;
1041 struct io_apic_irq_attr irq_attr;
1043 if (acpi_irq_model != ACPI_IRQ_MODEL_IOAPIC)
1044 return gsi;
1046 /* Don't set up the ACPI SCI because it's already set up */
1047 if (acpi_gbl_FADT.sci_interrupt == gsi)
1048 return gsi;
1050 ioapic = mp_find_ioapic(gsi);
1051 if (ioapic < 0) {
1052 printk(KERN_WARNING "No IOAPIC for GSI %u\n", gsi);
1053 return gsi;
1056 ioapic_pin = mp_find_ioapic_pin(ioapic, gsi);
1058 #ifdef CONFIG_X86_32
1059 if (ioapic_renumber_irq)
1060 gsi = ioapic_renumber_irq(ioapic, gsi);
1061 #endif
1063 if (ioapic_pin > MP_MAX_IOAPIC_PIN) {
1064 printk(KERN_ERR "Invalid reference to IOAPIC pin "
1065 "%d-%d\n", mp_ioapics[ioapic].apicid,
1066 ioapic_pin);
1067 return gsi;
1070 if (enable_update_mptable)
1071 mp_config_acpi_gsi(dev, gsi, trigger, polarity);
1073 set_io_apic_irq_attr(&irq_attr, ioapic, ioapic_pin,
1074 trigger == ACPI_EDGE_SENSITIVE ? 0 : 1,
1075 polarity == ACPI_ACTIVE_HIGH ? 0 : 1);
1076 io_apic_set_pci_routing(dev, gsi, &irq_attr);
1078 return gsi;
1082 * Parse IOAPIC related entries in MADT
1083 * returns 0 on success, < 0 on error
1085 static int __init acpi_parse_madt_ioapic_entries(void)
1087 int count;
1090 * ACPI interpreter is required to complete interrupt setup,
1091 * so if it is off, don't enumerate the io-apics with ACPI.
1092 * If MPS is present, it will handle them,
1093 * otherwise the system will stay in PIC mode
1095 if (acpi_disabled || acpi_noirq)
1096 return -ENODEV;
1098 if (!cpu_has_apic)
1099 return -ENODEV;
1102 * if "noapic" boot option, don't look for IO-APICs
1104 if (skip_ioapic_setup) {
1105 printk(KERN_INFO PREFIX "Skipping IOAPIC probe "
1106 "due to 'noapic' option.\n");
1107 return -ENODEV;
1110 count =
1111 acpi_table_parse_madt(ACPI_MADT_TYPE_IO_APIC, acpi_parse_ioapic,
1112 MAX_IO_APICS);
1113 if (!count) {
1114 printk(KERN_ERR PREFIX "No IOAPIC entries present\n");
1115 return -ENODEV;
1116 } else if (count < 0) {
1117 printk(KERN_ERR PREFIX "Error parsing IOAPIC entry\n");
1118 return count;
1121 count =
1122 acpi_table_parse_madt(ACPI_MADT_TYPE_INTERRUPT_OVERRIDE, acpi_parse_int_src_ovr,
1123 nr_irqs);
1124 if (count < 0) {
1125 printk(KERN_ERR PREFIX
1126 "Error parsing interrupt source overrides entry\n");
1127 /* TBD: Cleanup to allow fallback to MPS */
1128 return count;
1132 * If BIOS did not supply an INT_SRC_OVR for the SCI
1133 * pretend we got one so we can set the SCI flags.
1135 if (!acpi_sci_override_gsi)
1136 acpi_sci_ioapic_setup(acpi_gbl_FADT.sci_interrupt, 0, 0);
1138 /* Fill in identity legacy mapings where no override */
1139 mp_config_acpi_legacy_irqs();
1141 count =
1142 acpi_table_parse_madt(ACPI_MADT_TYPE_NMI_SOURCE, acpi_parse_nmi_src,
1143 nr_irqs);
1144 if (count < 0) {
1145 printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n");
1146 /* TBD: Cleanup to allow fallback to MPS */
1147 return count;
1150 return 0;
1152 #else
1153 static inline int acpi_parse_madt_ioapic_entries(void)
1155 return -1;
1157 #endif /* !CONFIG_X86_IO_APIC */
1159 static void __init early_acpi_process_madt(void)
1161 #ifdef CONFIG_X86_LOCAL_APIC
1162 int error;
1164 if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) {
1167 * Parse MADT LAPIC entries
1169 error = early_acpi_parse_madt_lapic_addr_ovr();
1170 if (!error) {
1171 acpi_lapic = 1;
1172 smp_found_config = 1;
1174 if (error == -EINVAL) {
1176 * Dell Precision Workstation 410, 610 come here.
1178 printk(KERN_ERR PREFIX
1179 "Invalid BIOS MADT, disabling ACPI\n");
1180 disable_acpi();
1183 #endif
1186 static void __init acpi_process_madt(void)
1188 #ifdef CONFIG_X86_LOCAL_APIC
1189 int error;
1191 if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) {
1194 * Parse MADT LAPIC entries
1196 error = acpi_parse_madt_lapic_entries();
1197 if (!error) {
1198 acpi_lapic = 1;
1201 * Parse MADT IO-APIC entries
1203 error = acpi_parse_madt_ioapic_entries();
1204 if (!error) {
1205 acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC;
1206 acpi_ioapic = 1;
1208 smp_found_config = 1;
1211 if (error == -EINVAL) {
1213 * Dell Precision Workstation 410, 610 come here.
1215 printk(KERN_ERR PREFIX
1216 "Invalid BIOS MADT, disabling ACPI\n");
1217 disable_acpi();
1219 } else {
1221 * ACPI found no MADT, and so ACPI wants UP PIC mode.
1222 * In the event an MPS table was found, forget it.
1223 * Boot with "acpi=off" to use MPS on such a system.
1225 if (smp_found_config) {
1226 printk(KERN_WARNING PREFIX
1227 "No APIC-table, disabling MPS\n");
1228 smp_found_config = 0;
1233 * ACPI supports both logical (e.g. Hyper-Threading) and physical
1234 * processors, where MPS only supports physical.
1236 if (acpi_lapic && acpi_ioapic)
1237 printk(KERN_INFO "Using ACPI (MADT) for SMP configuration "
1238 "information\n");
1239 else if (acpi_lapic)
1240 printk(KERN_INFO "Using ACPI for processor (LAPIC) "
1241 "configuration information\n");
1242 #endif
1243 return;
1246 static int __init disable_acpi_irq(const struct dmi_system_id *d)
1248 if (!acpi_force) {
1249 printk(KERN_NOTICE "%s detected: force use of acpi=noirq\n",
1250 d->ident);
1251 acpi_noirq_set();
1253 return 0;
1256 static int __init disable_acpi_pci(const struct dmi_system_id *d)
1258 if (!acpi_force) {
1259 printk(KERN_NOTICE "%s detected: force use of pci=noacpi\n",
1260 d->ident);
1261 acpi_disable_pci();
1263 return 0;
1266 static int __init dmi_disable_acpi(const struct dmi_system_id *d)
1268 if (!acpi_force) {
1269 printk(KERN_NOTICE "%s detected: acpi off\n", d->ident);
1270 disable_acpi();
1271 } else {
1272 printk(KERN_NOTICE
1273 "Warning: DMI blacklist says broken, but acpi forced\n");
1275 return 0;
1279 * Limit ACPI to CPU enumeration for HT
1281 static int __init force_acpi_ht(const struct dmi_system_id *d)
1283 if (!acpi_force) {
1284 printk(KERN_NOTICE "%s detected: force use of acpi=ht\n",
1285 d->ident);
1286 disable_acpi();
1287 acpi_ht = 1;
1288 } else {
1289 printk(KERN_NOTICE
1290 "Warning: acpi=force overrules DMI blacklist: acpi=ht\n");
1292 return 0;
1296 * Force ignoring BIOS IRQ0 pin2 override
1298 static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
1301 * The ati_ixp4x0_rev() early PCI quirk should have set
1302 * the acpi_skip_timer_override flag already:
1304 if (!acpi_skip_timer_override) {
1305 WARN(1, KERN_ERR "ati_ixp4x0 quirk not complete.\n");
1306 pr_notice("%s detected: Ignoring BIOS IRQ0 pin2 override\n",
1307 d->ident);
1308 acpi_skip_timer_override = 1;
1310 return 0;
1314 * If your system is blacklisted here, but you find that acpi=force
1315 * works for you, please contact linux-acpi@vger.kernel.org
1317 static struct dmi_system_id __initdata acpi_dmi_table[] = {
1319 * Boxes that need ACPI disabled
1322 .callback = dmi_disable_acpi,
1323 .ident = "IBM Thinkpad",
1324 .matches = {
1325 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1326 DMI_MATCH(DMI_BOARD_NAME, "2629H1G"),
1331 * Boxes that need acpi=ht
1334 .callback = force_acpi_ht,
1335 .ident = "FSC Primergy T850",
1336 .matches = {
1337 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
1338 DMI_MATCH(DMI_PRODUCT_NAME, "PRIMERGY T850"),
1342 .callback = force_acpi_ht,
1343 .ident = "HP VISUALIZE NT Workstation",
1344 .matches = {
1345 DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
1346 DMI_MATCH(DMI_PRODUCT_NAME, "HP VISUALIZE NT Workstation"),
1350 .callback = force_acpi_ht,
1351 .ident = "Compaq Workstation W8000",
1352 .matches = {
1353 DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
1354 DMI_MATCH(DMI_PRODUCT_NAME, "Workstation W8000"),
1358 .callback = force_acpi_ht,
1359 .ident = "ASUS CUR-DLS",
1360 .matches = {
1361 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
1362 DMI_MATCH(DMI_BOARD_NAME, "CUR-DLS"),
1366 .callback = force_acpi_ht,
1367 .ident = "ABIT i440BX-W83977",
1368 .matches = {
1369 DMI_MATCH(DMI_BOARD_VENDOR, "ABIT <http://www.abit.com>"),
1370 DMI_MATCH(DMI_BOARD_NAME, "i440BX-W83977 (BP6)"),
1374 .callback = force_acpi_ht,
1375 .ident = "IBM Bladecenter",
1376 .matches = {
1377 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1378 DMI_MATCH(DMI_BOARD_NAME, "IBM eServer BladeCenter HS20"),
1382 .callback = force_acpi_ht,
1383 .ident = "IBM eServer xSeries 360",
1384 .matches = {
1385 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1386 DMI_MATCH(DMI_BOARD_NAME, "eServer xSeries 360"),
1390 .callback = force_acpi_ht,
1391 .ident = "IBM eserver xSeries 330",
1392 .matches = {
1393 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1394 DMI_MATCH(DMI_BOARD_NAME, "eserver xSeries 330"),
1398 .callback = force_acpi_ht,
1399 .ident = "IBM eserver xSeries 440",
1400 .matches = {
1401 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1402 DMI_MATCH(DMI_PRODUCT_NAME, "eserver xSeries 440"),
1407 * Boxes that need ACPI PCI IRQ routing disabled
1410 .callback = disable_acpi_irq,
1411 .ident = "ASUS A7V",
1412 .matches = {
1413 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC"),
1414 DMI_MATCH(DMI_BOARD_NAME, "<A7V>"),
1415 /* newer BIOS, Revision 1011, does work */
1416 DMI_MATCH(DMI_BIOS_VERSION,
1417 "ASUS A7V ACPI BIOS Revision 1007"),
1422 * Latest BIOS for IBM 600E (1.16) has bad pcinum
1423 * for LPC bridge, which is needed for the PCI
1424 * interrupt links to work. DSDT fix is in bug 5966.
1425 * 2645, 2646 model numbers are shared with 600/600E/600X
1427 .callback = disable_acpi_irq,
1428 .ident = "IBM Thinkpad 600 Series 2645",
1429 .matches = {
1430 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1431 DMI_MATCH(DMI_BOARD_NAME, "2645"),
1435 .callback = disable_acpi_irq,
1436 .ident = "IBM Thinkpad 600 Series 2646",
1437 .matches = {
1438 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1439 DMI_MATCH(DMI_BOARD_NAME, "2646"),
1443 * Boxes that need ACPI PCI IRQ routing and PCI scan disabled
1445 { /* _BBN 0 bug */
1446 .callback = disable_acpi_pci,
1447 .ident = "ASUS PR-DLS",
1448 .matches = {
1449 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
1450 DMI_MATCH(DMI_BOARD_NAME, "PR-DLS"),
1451 DMI_MATCH(DMI_BIOS_VERSION,
1452 "ASUS PR-DLS ACPI BIOS Revision 1010"),
1453 DMI_MATCH(DMI_BIOS_DATE, "03/21/2003")
1457 .callback = disable_acpi_pci,
1458 .ident = "Acer TravelMate 36x Laptop",
1459 .matches = {
1460 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
1461 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
1467 /* second table for DMI checks that should run after early-quirks */
1468 static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
1470 * HP laptops which use a DSDT reporting as HP/SB400/10000,
1471 * which includes some code which overrides all temperature
1472 * trip points to 16C if the INTIN2 input of the I/O APIC
1473 * is enabled. This input is incorrectly designated the
1474 * ISA IRQ 0 via an interrupt source override even though
1475 * it is wired to the output of the master 8259A and INTIN0
1476 * is not connected at all. Force ignoring BIOS IRQ0 pin2
1477 * override in that cases.
1480 .callback = dmi_ignore_irq0_timer_override,
1481 .ident = "HP nx6115 laptop",
1482 .matches = {
1483 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1484 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6115"),
1488 .callback = dmi_ignore_irq0_timer_override,
1489 .ident = "HP NX6125 laptop",
1490 .matches = {
1491 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1492 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6125"),
1496 .callback = dmi_ignore_irq0_timer_override,
1497 .ident = "HP NX6325 laptop",
1498 .matches = {
1499 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1500 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6325"),
1504 .callback = dmi_ignore_irq0_timer_override,
1505 .ident = "HP 6715b laptop",
1506 .matches = {
1507 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1508 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq 6715b"),
1515 * acpi_boot_table_init() and acpi_boot_init()
1516 * called from setup_arch(), always.
1517 * 1. checksums all tables
1518 * 2. enumerates lapics
1519 * 3. enumerates io-apics
1521 * acpi_table_init() is separate to allow reading SRAT without
1522 * other side effects.
1524 * side effects of acpi_boot_init:
1525 * acpi_lapic = 1 if LAPIC found
1526 * acpi_ioapic = 1 if IOAPIC found
1527 * if (acpi_lapic && acpi_ioapic) smp_found_config = 1;
1528 * if acpi_blacklisted() acpi_disabled = 1;
1529 * acpi_irq_model=...
1530 * ...
1532 * return value: (currently ignored)
1533 * 0: success
1534 * !0: failure
1537 int __init acpi_boot_table_init(void)
1539 int error;
1541 dmi_check_system(acpi_dmi_table);
1544 * If acpi_disabled, bail out
1545 * One exception: acpi=ht continues far enough to enumerate LAPICs
1547 if (acpi_disabled && !acpi_ht)
1548 return 1;
1551 * Initialize the ACPI boot-time table parser.
1553 error = acpi_table_init();
1554 if (error) {
1555 disable_acpi();
1556 return error;
1559 acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
1562 * blacklist may disable ACPI entirely
1564 error = acpi_blacklisted();
1565 if (error) {
1566 if (acpi_force) {
1567 printk(KERN_WARNING PREFIX "acpi=force override\n");
1568 } else {
1569 printk(KERN_WARNING PREFIX "Disabling ACPI support\n");
1570 disable_acpi();
1571 return error;
1575 return 0;
1578 int __init early_acpi_boot_init(void)
1581 * If acpi_disabled, bail out
1582 * One exception: acpi=ht continues far enough to enumerate LAPICs
1584 if (acpi_disabled && !acpi_ht)
1585 return 1;
1588 * Process the Multiple APIC Description Table (MADT), if present
1590 early_acpi_process_madt();
1592 return 0;
1595 int __init acpi_boot_init(void)
1597 /* those are executed after early-quirks are executed */
1598 dmi_check_system(acpi_dmi_table_late);
1601 * If acpi_disabled, bail out
1602 * One exception: acpi=ht continues far enough to enumerate LAPICs
1604 if (acpi_disabled && !acpi_ht)
1605 return 1;
1607 acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
1610 * set sci_int and PM timer address
1612 acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt);
1615 * Process the Multiple APIC Description Table (MADT), if present
1617 acpi_process_madt();
1619 acpi_table_parse(ACPI_SIG_HPET, acpi_parse_hpet);
1621 return 0;
1624 static int __init parse_acpi(char *arg)
1626 if (!arg)
1627 return -EINVAL;
1629 /* "acpi=off" disables both ACPI table parsing and interpreter */
1630 if (strcmp(arg, "off") == 0) {
1631 disable_acpi();
1633 /* acpi=force to over-ride black-list */
1634 else if (strcmp(arg, "force") == 0) {
1635 acpi_force = 1;
1636 acpi_ht = 1;
1637 acpi_disabled = 0;
1639 /* acpi=strict disables out-of-spec workarounds */
1640 else if (strcmp(arg, "strict") == 0) {
1641 acpi_strict = 1;
1643 /* Limit ACPI just to boot-time to enable HT */
1644 else if (strcmp(arg, "ht") == 0) {
1645 if (!acpi_force)
1646 disable_acpi();
1647 acpi_ht = 1;
1649 /* acpi=rsdt use RSDT instead of XSDT */
1650 else if (strcmp(arg, "rsdt") == 0) {
1651 acpi_rsdt_forced = 1;
1653 /* "acpi=noirq" disables ACPI interrupt routing */
1654 else if (strcmp(arg, "noirq") == 0) {
1655 acpi_noirq_set();
1656 } else {
1657 /* Core will printk when we return error. */
1658 return -EINVAL;
1660 return 0;
1662 early_param("acpi", parse_acpi);
1664 /* FIXME: Using pci= for an ACPI parameter is a travesty. */
1665 static int __init parse_pci(char *arg)
1667 if (arg && strcmp(arg, "noacpi") == 0)
1668 acpi_disable_pci();
1669 return 0;
1671 early_param("pci", parse_pci);
1673 int __init acpi_mps_check(void)
1675 #if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_X86_MPPARSE)
1676 /* mptable code is not built-in*/
1677 if (acpi_disabled || acpi_noirq) {
1678 printk(KERN_WARNING "MPS support code is not built-in.\n"
1679 "Using acpi=off or acpi=noirq or pci=noacpi "
1680 "may have problem\n");
1681 return 1;
1683 #endif
1684 return 0;
1687 #ifdef CONFIG_X86_IO_APIC
1688 static int __init parse_acpi_skip_timer_override(char *arg)
1690 acpi_skip_timer_override = 1;
1691 return 0;
1693 early_param("acpi_skip_timer_override", parse_acpi_skip_timer_override);
1695 static int __init parse_acpi_use_timer_override(char *arg)
1697 acpi_use_timer_override = 1;
1698 return 0;
1700 early_param("acpi_use_timer_override", parse_acpi_use_timer_override);
1701 #endif /* CONFIG_X86_IO_APIC */
1703 static int __init setup_acpi_sci(char *s)
1705 if (!s)
1706 return -EINVAL;
1707 if (!strcmp(s, "edge"))
1708 acpi_sci_flags = ACPI_MADT_TRIGGER_EDGE |
1709 (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK);
1710 else if (!strcmp(s, "level"))
1711 acpi_sci_flags = ACPI_MADT_TRIGGER_LEVEL |
1712 (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK);
1713 else if (!strcmp(s, "high"))
1714 acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_HIGH |
1715 (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK);
1716 else if (!strcmp(s, "low"))
1717 acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_LOW |
1718 (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK);
1719 else
1720 return -EINVAL;
1721 return 0;
1723 early_param("acpi_sci", setup_acpi_sci);
1725 int __acpi_acquire_global_lock(unsigned int *lock)
1727 unsigned int old, new, val;
1728 do {
1729 old = *lock;
1730 new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1));
1731 val = cmpxchg(lock, old, new);
1732 } while (unlikely (val != old));
1733 return (new < 3) ? -1 : 0;
1736 int __acpi_release_global_lock(unsigned int *lock)
1738 unsigned int old, new, val;
1739 do {
1740 old = *lock;
1741 new = old & ~0x3;
1742 val = cmpxchg(lock, old, new);
1743 } while (unlikely (val != old));
1744 return old & 0x1;