1 /* 2 * boot.c - Architecture-Specific Low-Level ACPI Boot Support 3 * 4 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> 5 * Copyright (C) 2001 Jun Nakajima <jun.nakajima@intel.com> 6 * 7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 8 * 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. 13 * 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. 18 * 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 22 * 23 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 24 */ 25 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/slab.h> 35 #include <linux/bootmem.h> 36 #include <linux/ioport.h> 37 #include <linux/pci.h> 38 39 #include <asm/pci_x86.h> 40 #include <asm/pgtable.h> 41 #include <asm/io_apic.h> 42 #include <asm/apic.h> 43 #include <asm/io.h> 44 #include <asm/mpspec.h> 45 #include <asm/smp.h> 46 47 #include "sleep.h" /* To include x86_acpi_suspend_lowlevel */ 48 static int __initdata acpi_force = 0; 49 int acpi_disabled; 50 EXPORT_SYMBOL(acpi_disabled); 51 52 #ifdef CONFIG_X86_64 53 # include <asm/proto.h> 54 #endif /* X86 */ 55 56 #define PREFIX "ACPI: " 57 58 int acpi_noirq; /* skip ACPI IRQ initialization */ 59 int acpi_pci_disabled; /* skip ACPI PCI scan and IRQ initialization */ 60 EXPORT_SYMBOL(acpi_pci_disabled); 61 62 int acpi_lapic; 63 int acpi_ioapic; 64 int acpi_strict; 65 int acpi_disable_cmcff; 66 67 u8 acpi_sci_flags __initdata; 68 int acpi_sci_override_gsi __initdata; 69 int acpi_skip_timer_override __initdata; 70 int acpi_use_timer_override __initdata; 71 int acpi_fix_pin2_polarity __initdata; 72 73 #ifdef CONFIG_X86_LOCAL_APIC 74 static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE; 75 #endif 76 77 /* -------------------------------------------------------------------------- 78 Boot-time Configuration 79 -------------------------------------------------------------------------- */ 80 81 /* 82 * The default interrupt routing model is PIC (8259). This gets 83 * overridden if IOAPICs are enumerated (below). 84 */ 85 enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC; 86 87 88 /* 89 * ISA irqs by default are the first 16 gsis but can be 90 * any gsi as specified by an interrupt source override. 91 */ 92 static u32 isa_irq_to_gsi[NR_IRQS_LEGACY] __read_mostly = { 93 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 94 }; 95 96 static unsigned int gsi_to_irq(unsigned int gsi) 97 { 98 unsigned int irq = gsi + NR_IRQS_LEGACY; 99 unsigned int i; 100 101 for (i = 0; i < NR_IRQS_LEGACY; i++) { 102 if (isa_irq_to_gsi[i] == gsi) { 103 return i; 104 } 105 } 106 107 /* Provide an identity mapping of gsi == irq 108 * except on truly weird platforms that have 109 * non isa irqs in the first 16 gsis. 110 */ 111 if (gsi >= NR_IRQS_LEGACY) 112 irq = gsi; 113 else 114 irq = gsi_top + gsi; 115 116 return irq; 117 } 118 119 static u32 irq_to_gsi(int irq) 120 { 121 unsigned int gsi; 122 123 if (irq < NR_IRQS_LEGACY) 124 gsi = isa_irq_to_gsi[irq]; 125 else if (irq < gsi_top) 126 gsi = irq; 127 else if (irq < (gsi_top + NR_IRQS_LEGACY)) 128 gsi = irq - gsi_top; 129 else 130 gsi = 0xffffffff; 131 132 return gsi; 133 } 134 135 /* 136 * This is just a simple wrapper around early_ioremap(), 137 * with sanity checks for phys == 0 and size == 0. 138 */ 139 char *__init __acpi_map_table(unsigned long phys, unsigned long size) 140 { 141 142 if (!phys || !size) 143 return NULL; 144 145 return early_ioremap(phys, size); 146 } 147 148 void __init __acpi_unmap_table(char *map, unsigned long size) 149 { 150 if (!map || !size) 151 return; 152 153 early_iounmap(map, size); 154 } 155 156 #ifdef CONFIG_X86_LOCAL_APIC 157 static int __init acpi_parse_madt(struct acpi_table_header *table) 158 { 159 struct acpi_table_madt *madt = NULL; 160 161 if (!cpu_has_apic) 162 return -EINVAL; 163 164 madt = (struct acpi_table_madt *)table; 165 if (!madt) { 166 printk(KERN_WARNING PREFIX "Unable to map MADT\n"); 167 return -ENODEV; 168 } 169 170 if (madt->address) { 171 acpi_lapic_addr = (u64) madt->address; 172 173 printk(KERN_DEBUG PREFIX "Local APIC address 0x%08x\n", 174 madt->address); 175 } 176 177 default_acpi_madt_oem_check(madt->header.oem_id, 178 madt->header.oem_table_id); 179 180 return 0; 181 } 182 183 /** 184 * acpi_register_lapic - register a local apic and generates a logic cpu number 185 * @id: local apic id to register 186 * @enabled: this cpu is enabled or not 187 * 188 * Returns the logic cpu number which maps to the local apic 189 */ 190 static int acpi_register_lapic(int id, u8 enabled) 191 { 192 unsigned int ver = 0; 193 194 if (id >= MAX_LOCAL_APIC) { 195 printk(KERN_INFO PREFIX "skipped apicid that is too big\n"); 196 return -EINVAL; 197 } 198 199 if (!enabled) { 200 ++disabled_cpus; 201 return -EINVAL; 202 } 203 204 if (boot_cpu_physical_apicid != -1U) 205 ver = apic_version[boot_cpu_physical_apicid]; 206 207 return generic_processor_info(id, ver); 208 } 209 210 static int __init 211 acpi_parse_x2apic(struct acpi_subtable_header *header, const unsigned long end) 212 { 213 struct acpi_madt_local_x2apic *processor = NULL; 214 int apic_id; 215 u8 enabled; 216 217 processor = (struct acpi_madt_local_x2apic *)header; 218 219 if (BAD_MADT_ENTRY(processor, end)) 220 return -EINVAL; 221 222 acpi_table_print_madt_entry(header); 223 224 apic_id = processor->local_apic_id; 225 enabled = processor->lapic_flags & ACPI_MADT_ENABLED; 226 #ifdef CONFIG_X86_X2APIC 227 /* 228 * We need to register disabled CPU as well to permit 229 * counting disabled CPUs. This allows us to size 230 * cpus_possible_map more accurately, to permit 231 * to not preallocating memory for all NR_CPUS 232 * when we use CPU hotplug. 233 */ 234 if (!apic->apic_id_valid(apic_id) && enabled) 235 printk(KERN_WARNING PREFIX "x2apic entry ignored\n"); 236 else 237 acpi_register_lapic(apic_id, enabled); 238 #else 239 printk(KERN_WARNING PREFIX "x2apic entry ignored\n"); 240 #endif 241 242 return 0; 243 } 244 245 static int __init 246 acpi_parse_lapic(struct acpi_subtable_header * header, const unsigned long end) 247 { 248 struct acpi_madt_local_apic *processor = NULL; 249 250 processor = (struct acpi_madt_local_apic *)header; 251 252 if (BAD_MADT_ENTRY(processor, end)) 253 return -EINVAL; 254 255 acpi_table_print_madt_entry(header); 256 257 /* 258 * We need to register disabled CPU as well to permit 259 * counting disabled CPUs. This allows us to size 260 * cpus_possible_map more accurately, to permit 261 * to not preallocating memory for all NR_CPUS 262 * when we use CPU hotplug. 263 */ 264 acpi_register_lapic(processor->id, /* APIC ID */ 265 processor->lapic_flags & ACPI_MADT_ENABLED); 266 267 return 0; 268 } 269 270 static int __init 271 acpi_parse_sapic(struct acpi_subtable_header *header, const unsigned long end) 272 { 273 struct acpi_madt_local_sapic *processor = NULL; 274 275 processor = (struct acpi_madt_local_sapic *)header; 276 277 if (BAD_MADT_ENTRY(processor, end)) 278 return -EINVAL; 279 280 acpi_table_print_madt_entry(header); 281 282 acpi_register_lapic((processor->id << 8) | processor->eid,/* APIC ID */ 283 processor->lapic_flags & ACPI_MADT_ENABLED); 284 285 return 0; 286 } 287 288 static int __init 289 acpi_parse_lapic_addr_ovr(struct acpi_subtable_header * header, 290 const unsigned long end) 291 { 292 struct acpi_madt_local_apic_override *lapic_addr_ovr = NULL; 293 294 lapic_addr_ovr = (struct acpi_madt_local_apic_override *)header; 295 296 if (BAD_MADT_ENTRY(lapic_addr_ovr, end)) 297 return -EINVAL; 298 299 acpi_lapic_addr = lapic_addr_ovr->address; 300 301 return 0; 302 } 303 304 static int __init 305 acpi_parse_x2apic_nmi(struct acpi_subtable_header *header, 306 const unsigned long end) 307 { 308 struct acpi_madt_local_x2apic_nmi *x2apic_nmi = NULL; 309 310 x2apic_nmi = (struct acpi_madt_local_x2apic_nmi *)header; 311 312 if (BAD_MADT_ENTRY(x2apic_nmi, end)) 313 return -EINVAL; 314 315 acpi_table_print_madt_entry(header); 316 317 if (x2apic_nmi->lint != 1) 318 printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n"); 319 320 return 0; 321 } 322 323 static int __init 324 acpi_parse_lapic_nmi(struct acpi_subtable_header * header, const unsigned long end) 325 { 326 struct acpi_madt_local_apic_nmi *lapic_nmi = NULL; 327 328 lapic_nmi = (struct acpi_madt_local_apic_nmi *)header; 329 330 if (BAD_MADT_ENTRY(lapic_nmi, end)) 331 return -EINVAL; 332 333 acpi_table_print_madt_entry(header); 334 335 if (lapic_nmi->lint != 1) 336 printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n"); 337 338 return 0; 339 } 340 341 #endif /*CONFIG_X86_LOCAL_APIC */ 342 343 #ifdef CONFIG_X86_IO_APIC 344 345 static int __init 346 acpi_parse_ioapic(struct acpi_subtable_header * header, const unsigned long end) 347 { 348 struct acpi_madt_io_apic *ioapic = NULL; 349 350 ioapic = (struct acpi_madt_io_apic *)header; 351 352 if (BAD_MADT_ENTRY(ioapic, end)) 353 return -EINVAL; 354 355 acpi_table_print_madt_entry(header); 356 357 mp_register_ioapic(ioapic->id, 358 ioapic->address, ioapic->global_irq_base); 359 360 return 0; 361 } 362 363 /* 364 * Parse Interrupt Source Override for the ACPI SCI 365 */ 366 static void __init acpi_sci_ioapic_setup(u8 bus_irq, u16 polarity, u16 trigger, u32 gsi) 367 { 368 if (trigger == 0) /* compatible SCI trigger is level */ 369 trigger = 3; 370 371 if (polarity == 0) /* compatible SCI polarity is low */ 372 polarity = 3; 373 374 /* Command-line over-ride via acpi_sci= */ 375 if (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK) 376 trigger = (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK) >> 2; 377 378 if (acpi_sci_flags & ACPI_MADT_POLARITY_MASK) 379 polarity = acpi_sci_flags & ACPI_MADT_POLARITY_MASK; 380 381 /* 382 * mp_config_acpi_legacy_irqs() already setup IRQs < 16 383 * If GSI is < 16, this will update its flags, 384 * else it will create a new mp_irqs[] entry. 385 */ 386 mp_override_legacy_irq(bus_irq, polarity, trigger, gsi); 387 388 /* 389 * stash over-ride to indicate we've been here 390 * and for later update of acpi_gbl_FADT 391 */ 392 acpi_sci_override_gsi = gsi; 393 return; 394 } 395 396 static int __init 397 acpi_parse_int_src_ovr(struct acpi_subtable_header * header, 398 const unsigned long end) 399 { 400 struct acpi_madt_interrupt_override *intsrc = NULL; 401 402 intsrc = (struct acpi_madt_interrupt_override *)header; 403 404 if (BAD_MADT_ENTRY(intsrc, end)) 405 return -EINVAL; 406 407 acpi_table_print_madt_entry(header); 408 409 if (intsrc->source_irq == acpi_gbl_FADT.sci_interrupt) { 410 acpi_sci_ioapic_setup(intsrc->source_irq, 411 intsrc->inti_flags & ACPI_MADT_POLARITY_MASK, 412 (intsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2, 413 intsrc->global_irq); 414 return 0; 415 } 416 417 if (intsrc->source_irq == 0) { 418 if (acpi_skip_timer_override) { 419 printk(PREFIX "BIOS IRQ0 override ignored.\n"); 420 return 0; 421 } 422 423 if ((intsrc->global_irq == 2) && acpi_fix_pin2_polarity 424 && (intsrc->inti_flags & ACPI_MADT_POLARITY_MASK)) { 425 intsrc->inti_flags &= ~ACPI_MADT_POLARITY_MASK; 426 printk(PREFIX "BIOS IRQ0 pin2 override: forcing polarity to high active.\n"); 427 } 428 } 429 430 mp_override_legacy_irq(intsrc->source_irq, 431 intsrc->inti_flags & ACPI_MADT_POLARITY_MASK, 432 (intsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2, 433 intsrc->global_irq); 434 435 return 0; 436 } 437 438 static int __init 439 acpi_parse_nmi_src(struct acpi_subtable_header * header, const unsigned long end) 440 { 441 struct acpi_madt_nmi_source *nmi_src = NULL; 442 443 nmi_src = (struct acpi_madt_nmi_source *)header; 444 445 if (BAD_MADT_ENTRY(nmi_src, end)) 446 return -EINVAL; 447 448 acpi_table_print_madt_entry(header); 449 450 /* TBD: Support nimsrc entries? */ 451 452 return 0; 453 } 454 455 #endif /* CONFIG_X86_IO_APIC */ 456 457 /* 458 * acpi_pic_sci_set_trigger() 459 * 460 * use ELCR to set PIC-mode trigger type for SCI 461 * 462 * If a PIC-mode SCI is not recognized or gives spurious IRQ7's 463 * it may require Edge Trigger -- use "acpi_sci=edge" 464 * 465 * Port 0x4d0-4d1 are ECLR1 and ECLR2, the Edge/Level Control Registers 466 * for the 8259 PIC. bit[n] = 1 means irq[n] is Level, otherwise Edge. 467 * ECLR1 is IRQs 0-7 (IRQ 0, 1, 2 must be 0) 468 * ECLR2 is IRQs 8-15 (IRQ 8, 13 must be 0) 469 */ 470 471 void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger) 472 { 473 unsigned int mask = 1 << irq; 474 unsigned int old, new; 475 476 /* Real old ELCR mask */ 477 old = inb(0x4d0) | (inb(0x4d1) << 8); 478 479 /* 480 * If we use ACPI to set PCI IRQs, then we should clear ELCR 481 * since we will set it correctly as we enable the PCI irq 482 * routing. 483 */ 484 new = acpi_noirq ? old : 0; 485 486 /* 487 * Update SCI information in the ELCR, it isn't in the PCI 488 * routing tables.. 489 */ 490 switch (trigger) { 491 case 1: /* Edge - clear */ 492 new &= ~mask; 493 break; 494 case 3: /* Level - set */ 495 new |= mask; 496 break; 497 } 498 499 if (old == new) 500 return; 501 502 printk(PREFIX "setting ELCR to %04x (from %04x)\n", new, old); 503 outb(new, 0x4d0); 504 outb(new >> 8, 0x4d1); 505 } 506 507 int acpi_gsi_to_irq(u32 gsi, unsigned int *irq) 508 { 509 *irq = gsi_to_irq(gsi); 510 511 #ifdef CONFIG_X86_IO_APIC 512 if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) 513 setup_IO_APIC_irq_extra(gsi); 514 #endif 515 516 return 0; 517 } 518 EXPORT_SYMBOL_GPL(acpi_gsi_to_irq); 519 520 int acpi_isa_irq_to_gsi(unsigned isa_irq, u32 *gsi) 521 { 522 if (isa_irq >= 16) 523 return -1; 524 *gsi = irq_to_gsi(isa_irq); 525 return 0; 526 } 527 528 static int acpi_register_gsi_pic(struct device *dev, u32 gsi, 529 int trigger, int polarity) 530 { 531 #ifdef CONFIG_PCI 532 /* 533 * Make sure all (legacy) PCI IRQs are set as level-triggered. 534 */ 535 if (trigger == ACPI_LEVEL_SENSITIVE) 536 eisa_set_level_irq(gsi); 537 #endif 538 539 return gsi; 540 } 541 542 static int acpi_register_gsi_ioapic(struct device *dev, u32 gsi, 543 int trigger, int polarity) 544 { 545 #ifdef CONFIG_X86_IO_APIC 546 gsi = mp_register_gsi(dev, gsi, trigger, polarity); 547 #endif 548 549 return gsi; 550 } 551 552 int (*__acpi_register_gsi)(struct device *dev, u32 gsi, 553 int trigger, int polarity) = acpi_register_gsi_pic; 554 555 #ifdef CONFIG_ACPI_SLEEP 556 int (*acpi_suspend_lowlevel)(void) = x86_acpi_suspend_lowlevel; 557 #else 558 int (*acpi_suspend_lowlevel)(void); 559 #endif 560 561 /* 562 * success: return IRQ number (>=0) 563 * failure: return < 0 564 */ 565 int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity) 566 { 567 unsigned int irq; 568 unsigned int plat_gsi = gsi; 569 570 plat_gsi = (*__acpi_register_gsi)(dev, gsi, trigger, polarity); 571 irq = gsi_to_irq(plat_gsi); 572 573 return irq; 574 } 575 EXPORT_SYMBOL_GPL(acpi_register_gsi); 576 577 void acpi_unregister_gsi(u32 gsi) 578 { 579 } 580 EXPORT_SYMBOL_GPL(acpi_unregister_gsi); 581 582 void __init acpi_set_irq_model_pic(void) 583 { 584 acpi_irq_model = ACPI_IRQ_MODEL_PIC; 585 __acpi_register_gsi = acpi_register_gsi_pic; 586 acpi_ioapic = 0; 587 } 588 589 void __init acpi_set_irq_model_ioapic(void) 590 { 591 acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC; 592 __acpi_register_gsi = acpi_register_gsi_ioapic; 593 acpi_ioapic = 1; 594 } 595 596 /* 597 * ACPI based hotplug support for CPU 598 */ 599 #ifdef CONFIG_ACPI_HOTPLUG_CPU 600 #include <acpi/processor.h> 601 602 static void acpi_map_cpu2node(acpi_handle handle, int cpu, int physid) 603 { 604 #ifdef CONFIG_ACPI_NUMA 605 int nid; 606 607 nid = acpi_get_node(handle); 608 if (nid != -1) { 609 set_apicid_to_node(physid, nid); 610 numa_set_node(cpu, nid); 611 } 612 #endif 613 } 614 615 static int _acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu) 616 { 617 int cpu; 618 619 cpu = acpi_register_lapic(physid, ACPI_MADT_ENABLED); 620 if (cpu < 0) { 621 pr_info(PREFIX "Unable to map lapic to logical cpu number\n"); 622 return cpu; 623 } 624 625 acpi_processor_set_pdc(handle); 626 acpi_map_cpu2node(handle, cpu, physid); 627 628 *pcpu = cpu; 629 return 0; 630 } 631 632 /* wrapper to silence section mismatch warning */ 633 int __ref acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu) 634 { 635 return _acpi_map_lsapic(handle, physid, pcpu); 636 } 637 EXPORT_SYMBOL(acpi_map_lsapic); 638 639 int acpi_unmap_lsapic(int cpu) 640 { 641 #ifdef CONFIG_ACPI_NUMA 642 set_apicid_to_node(per_cpu(x86_cpu_to_apicid, cpu), NUMA_NO_NODE); 643 #endif 644 645 per_cpu(x86_cpu_to_apicid, cpu) = -1; 646 set_cpu_present(cpu, false); 647 num_processors--; 648 649 return (0); 650 } 651 652 EXPORT_SYMBOL(acpi_unmap_lsapic); 653 #endif /* CONFIG_ACPI_HOTPLUG_CPU */ 654 655 int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base) 656 { 657 /* TBD */ 658 return -EINVAL; 659 } 660 661 EXPORT_SYMBOL(acpi_register_ioapic); 662 663 int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base) 664 { 665 /* TBD */ 666 return -EINVAL; 667 } 668 669 EXPORT_SYMBOL(acpi_unregister_ioapic); 670 671 static int __init acpi_parse_sbf(struct acpi_table_header *table) 672 { 673 struct acpi_table_boot *sb; 674 675 sb = (struct acpi_table_boot *)table; 676 if (!sb) { 677 printk(KERN_WARNING PREFIX "Unable to map SBF\n"); 678 return -ENODEV; 679 } 680 681 sbf_port = sb->cmos_index; /* Save CMOS port */ 682 683 return 0; 684 } 685 686 #ifdef CONFIG_HPET_TIMER 687 #include <asm/hpet.h> 688 689 static struct resource *hpet_res __initdata; 690 691 static int __init acpi_parse_hpet(struct acpi_table_header *table) 692 { 693 struct acpi_table_hpet *hpet_tbl; 694 695 hpet_tbl = (struct acpi_table_hpet *)table; 696 if (!hpet_tbl) { 697 printk(KERN_WARNING PREFIX "Unable to map HPET\n"); 698 return -ENODEV; 699 } 700 701 if (hpet_tbl->address.space_id != ACPI_SPACE_MEM) { 702 printk(KERN_WARNING PREFIX "HPET timers must be located in " 703 "memory.\n"); 704 return -1; 705 } 706 707 hpet_address = hpet_tbl->address.address; 708 hpet_blockid = hpet_tbl->sequence; 709 710 /* 711 * Some broken BIOSes advertise HPET at 0x0. We really do not 712 * want to allocate a resource there. 713 */ 714 if (!hpet_address) { 715 printk(KERN_WARNING PREFIX 716 "HPET id: %#x base: %#lx is invalid\n", 717 hpet_tbl->id, hpet_address); 718 return 0; 719 } 720 #ifdef CONFIG_X86_64 721 /* 722 * Some even more broken BIOSes advertise HPET at 723 * 0xfed0000000000000 instead of 0xfed00000. Fix it up and add 724 * some noise: 725 */ 726 if (hpet_address == 0xfed0000000000000UL) { 727 if (!hpet_force_user) { 728 printk(KERN_WARNING PREFIX "HPET id: %#x " 729 "base: 0xfed0000000000000 is bogus\n " 730 "try hpet=force on the kernel command line to " 731 "fix it up to 0xfed00000.\n", hpet_tbl->id); 732 hpet_address = 0; 733 return 0; 734 } 735 printk(KERN_WARNING PREFIX 736 "HPET id: %#x base: 0xfed0000000000000 fixed up " 737 "to 0xfed00000.\n", hpet_tbl->id); 738 hpet_address >>= 32; 739 } 740 #endif 741 printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n", 742 hpet_tbl->id, hpet_address); 743 744 /* 745 * Allocate and initialize the HPET firmware resource for adding into 746 * the resource tree during the lateinit timeframe. 747 */ 748 #define HPET_RESOURCE_NAME_SIZE 9 749 hpet_res = alloc_bootmem(sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE); 750 751 hpet_res->name = (void *)&hpet_res[1]; 752 hpet_res->flags = IORESOURCE_MEM; 753 snprintf((char *)hpet_res->name, HPET_RESOURCE_NAME_SIZE, "HPET %u", 754 hpet_tbl->sequence); 755 756 hpet_res->start = hpet_address; 757 hpet_res->end = hpet_address + (1 * 1024) - 1; 758 759 return 0; 760 } 761 762 /* 763 * hpet_insert_resource inserts the HPET resources used into the resource 764 * tree. 765 */ 766 static __init int hpet_insert_resource(void) 767 { 768 if (!hpet_res) 769 return 1; 770 771 return insert_resource(&iomem_resource, hpet_res); 772 } 773 774 late_initcall(hpet_insert_resource); 775 776 #else 777 #define acpi_parse_hpet NULL 778 #endif 779 780 static int __init acpi_parse_fadt(struct acpi_table_header *table) 781 { 782 783 #ifdef CONFIG_X86_PM_TIMER 784 /* detect the location of the ACPI PM Timer */ 785 if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID) { 786 /* FADT rev. 2 */ 787 if (acpi_gbl_FADT.xpm_timer_block.space_id != 788 ACPI_ADR_SPACE_SYSTEM_IO) 789 return 0; 790 791 pmtmr_ioport = acpi_gbl_FADT.xpm_timer_block.address; 792 /* 793 * "X" fields are optional extensions to the original V1.0 794 * fields, so we must selectively expand V1.0 fields if the 795 * corresponding X field is zero. 796 */ 797 if (!pmtmr_ioport) 798 pmtmr_ioport = acpi_gbl_FADT.pm_timer_block; 799 } else { 800 /* FADT rev. 1 */ 801 pmtmr_ioport = acpi_gbl_FADT.pm_timer_block; 802 } 803 if (pmtmr_ioport) 804 printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n", 805 pmtmr_ioport); 806 #endif 807 return 0; 808 } 809 810 #ifdef CONFIG_X86_LOCAL_APIC 811 /* 812 * Parse LAPIC entries in MADT 813 * returns 0 on success, < 0 on error 814 */ 815 816 static int __init early_acpi_parse_madt_lapic_addr_ovr(void) 817 { 818 int count; 819 820 if (!cpu_has_apic) 821 return -ENODEV; 822 823 /* 824 * Note that the LAPIC address is obtained from the MADT (32-bit value) 825 * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value). 826 */ 827 828 count = 829 acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE, 830 acpi_parse_lapic_addr_ovr, 0); 831 if (count < 0) { 832 printk(KERN_ERR PREFIX 833 "Error parsing LAPIC address override entry\n"); 834 return count; 835 } 836 837 register_lapic_address(acpi_lapic_addr); 838 839 return count; 840 } 841 842 static int __init acpi_parse_madt_lapic_entries(void) 843 { 844 int count; 845 int x2count = 0; 846 847 if (!cpu_has_apic) 848 return -ENODEV; 849 850 /* 851 * Note that the LAPIC address is obtained from the MADT (32-bit value) 852 * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value). 853 */ 854 855 count = 856 acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE, 857 acpi_parse_lapic_addr_ovr, 0); 858 if (count < 0) { 859 printk(KERN_ERR PREFIX 860 "Error parsing LAPIC address override entry\n"); 861 return count; 862 } 863 864 register_lapic_address(acpi_lapic_addr); 865 866 count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_SAPIC, 867 acpi_parse_sapic, MAX_LOCAL_APIC); 868 869 if (!count) { 870 x2count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_X2APIC, 871 acpi_parse_x2apic, MAX_LOCAL_APIC); 872 count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC, 873 acpi_parse_lapic, MAX_LOCAL_APIC); 874 } 875 if (!count && !x2count) { 876 printk(KERN_ERR PREFIX "No LAPIC entries present\n"); 877 /* TBD: Cleanup to allow fallback to MPS */ 878 return -ENODEV; 879 } else if (count < 0 || x2count < 0) { 880 printk(KERN_ERR PREFIX "Error parsing LAPIC entry\n"); 881 /* TBD: Cleanup to allow fallback to MPS */ 882 return count; 883 } 884 885 x2count = 886 acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_X2APIC_NMI, 887 acpi_parse_x2apic_nmi, 0); 888 count = 889 acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_NMI, acpi_parse_lapic_nmi, 0); 890 if (count < 0 || x2count < 0) { 891 printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n"); 892 /* TBD: Cleanup to allow fallback to MPS */ 893 return count; 894 } 895 return 0; 896 } 897 #endif /* CONFIG_X86_LOCAL_APIC */ 898 899 #ifdef CONFIG_X86_IO_APIC 900 #define MP_ISA_BUS 0 901 902 void __init mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, u32 gsi) 903 { 904 int ioapic; 905 int pin; 906 struct mpc_intsrc mp_irq; 907 908 /* 909 * Convert 'gsi' to 'ioapic.pin'. 910 */ 911 ioapic = mp_find_ioapic(gsi); 912 if (ioapic < 0) 913 return; 914 pin = mp_find_ioapic_pin(ioapic, gsi); 915 916 /* 917 * TBD: This check is for faulty timer entries, where the override 918 * erroneously sets the trigger to level, resulting in a HUGE 919 * increase of timer interrupts! 920 */ 921 if ((bus_irq == 0) && (trigger == 3)) 922 trigger = 1; 923 924 mp_irq.type = MP_INTSRC; 925 mp_irq.irqtype = mp_INT; 926 mp_irq.irqflag = (trigger << 2) | polarity; 927 mp_irq.srcbus = MP_ISA_BUS; 928 mp_irq.srcbusirq = bus_irq; /* IRQ */ 929 mp_irq.dstapic = mpc_ioapic_id(ioapic); /* APIC ID */ 930 mp_irq.dstirq = pin; /* INTIN# */ 931 932 mp_save_irq(&mp_irq); 933 934 isa_irq_to_gsi[bus_irq] = gsi; 935 } 936 937 void __init mp_config_acpi_legacy_irqs(void) 938 { 939 int i; 940 struct mpc_intsrc mp_irq; 941 942 #ifdef CONFIG_EISA 943 /* 944 * Fabricate the legacy ISA bus (bus #31). 945 */ 946 mp_bus_id_to_type[MP_ISA_BUS] = MP_BUS_ISA; 947 #endif 948 set_bit(MP_ISA_BUS, mp_bus_not_pci); 949 pr_debug("Bus #%d is ISA\n", MP_ISA_BUS); 950 951 /* 952 * Use the default configuration for the IRQs 0-15. Unless 953 * overridden by (MADT) interrupt source override entries. 954 */ 955 for (i = 0; i < 16; i++) { 956 int ioapic, pin; 957 unsigned int dstapic; 958 int idx; 959 u32 gsi; 960 961 /* Locate the gsi that irq i maps to. */ 962 if (acpi_isa_irq_to_gsi(i, &gsi)) 963 continue; 964 965 /* 966 * Locate the IOAPIC that manages the ISA IRQ. 967 */ 968 ioapic = mp_find_ioapic(gsi); 969 if (ioapic < 0) 970 continue; 971 pin = mp_find_ioapic_pin(ioapic, gsi); 972 dstapic = mpc_ioapic_id(ioapic); 973 974 for (idx = 0; idx < mp_irq_entries; idx++) { 975 struct mpc_intsrc *irq = mp_irqs + idx; 976 977 /* Do we already have a mapping for this ISA IRQ? */ 978 if (irq->srcbus == MP_ISA_BUS && irq->srcbusirq == i) 979 break; 980 981 /* Do we already have a mapping for this IOAPIC pin */ 982 if (irq->dstapic == dstapic && irq->dstirq == pin) 983 break; 984 } 985 986 if (idx != mp_irq_entries) { 987 printk(KERN_DEBUG "ACPI: IRQ%d used by override.\n", i); 988 continue; /* IRQ already used */ 989 } 990 991 mp_irq.type = MP_INTSRC; 992 mp_irq.irqflag = 0; /* Conforming */ 993 mp_irq.srcbus = MP_ISA_BUS; 994 mp_irq.dstapic = dstapic; 995 mp_irq.irqtype = mp_INT; 996 mp_irq.srcbusirq = i; /* Identity mapped */ 997 mp_irq.dstirq = pin; 998 999 mp_save_irq(&mp_irq); 1000 } 1001 } 1002 1003 static int mp_config_acpi_gsi(struct device *dev, u32 gsi, int trigger, 1004 int polarity) 1005 { 1006 #ifdef CONFIG_X86_MPPARSE 1007 struct mpc_intsrc mp_irq; 1008 struct pci_dev *pdev; 1009 unsigned char number; 1010 unsigned int devfn; 1011 int ioapic; 1012 u8 pin; 1013 1014 if (!acpi_ioapic) 1015 return 0; 1016 if (!dev || !dev_is_pci(dev)) 1017 return 0; 1018 1019 pdev = to_pci_dev(dev); 1020 number = pdev->bus->number; 1021 devfn = pdev->devfn; 1022 pin = pdev->pin; 1023 /* print the entry should happen on mptable identically */ 1024 mp_irq.type = MP_INTSRC; 1025 mp_irq.irqtype = mp_INT; 1026 mp_irq.irqflag = (trigger == ACPI_EDGE_SENSITIVE ? 4 : 0x0c) | 1027 (polarity == ACPI_ACTIVE_HIGH ? 1 : 3); 1028 mp_irq.srcbus = number; 1029 mp_irq.srcbusirq = (((devfn >> 3) & 0x1f) << 2) | ((pin - 1) & 3); 1030 ioapic = mp_find_ioapic(gsi); 1031 mp_irq.dstapic = mpc_ioapic_id(ioapic); 1032 mp_irq.dstirq = mp_find_ioapic_pin(ioapic, gsi); 1033 1034 mp_save_irq(&mp_irq); 1035 #endif 1036 return 0; 1037 } 1038 1039 int mp_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity) 1040 { 1041 int ioapic; 1042 int ioapic_pin; 1043 struct io_apic_irq_attr irq_attr; 1044 int ret; 1045 1046 if (acpi_irq_model != ACPI_IRQ_MODEL_IOAPIC) 1047 return gsi; 1048 1049 /* Don't set up the ACPI SCI because it's already set up */ 1050 if (acpi_gbl_FADT.sci_interrupt == gsi) 1051 return gsi; 1052 1053 ioapic = mp_find_ioapic(gsi); 1054 if (ioapic < 0) { 1055 printk(KERN_WARNING "No IOAPIC for GSI %u\n", gsi); 1056 return gsi; 1057 } 1058 1059 ioapic_pin = mp_find_ioapic_pin(ioapic, gsi); 1060 1061 if (ioapic_pin > MP_MAX_IOAPIC_PIN) { 1062 printk(KERN_ERR "Invalid reference to IOAPIC pin " 1063 "%d-%d\n", mpc_ioapic_id(ioapic), 1064 ioapic_pin); 1065 return gsi; 1066 } 1067 1068 if (enable_update_mptable) 1069 mp_config_acpi_gsi(dev, gsi, trigger, polarity); 1070 1071 set_io_apic_irq_attr(&irq_attr, ioapic, ioapic_pin, 1072 trigger == ACPI_EDGE_SENSITIVE ? 0 : 1, 1073 polarity == ACPI_ACTIVE_HIGH ? 0 : 1); 1074 ret = io_apic_set_pci_routing(dev, gsi_to_irq(gsi), &irq_attr); 1075 if (ret < 0) 1076 gsi = INT_MIN; 1077 1078 return gsi; 1079 } 1080 1081 /* 1082 * Parse IOAPIC related entries in MADT 1083 * returns 0 on success, < 0 on error 1084 */ 1085 static int __init acpi_parse_madt_ioapic_entries(void) 1086 { 1087 int count; 1088 1089 /* 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 1094 */ 1095 if (acpi_disabled || acpi_noirq) 1096 return -ENODEV; 1097 1098 if (!cpu_has_apic) 1099 return -ENODEV; 1100 1101 /* 1102 * if "noapic" boot option, don't look for IO-APICs 1103 */ 1104 if (skip_ioapic_setup) { 1105 printk(KERN_INFO PREFIX "Skipping IOAPIC probe " 1106 "due to 'noapic' option.\n"); 1107 return -ENODEV; 1108 } 1109 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; 1119 } 1120 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; 1129 } 1130 1131 /* 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. 1134 */ 1135 if (!acpi_sci_override_gsi) 1136 acpi_sci_ioapic_setup(acpi_gbl_FADT.sci_interrupt, 0, 0, 1137 acpi_gbl_FADT.sci_interrupt); 1138 1139 /* Fill in identity legacy mappings where no override */ 1140 mp_config_acpi_legacy_irqs(); 1141 1142 count = 1143 acpi_table_parse_madt(ACPI_MADT_TYPE_NMI_SOURCE, acpi_parse_nmi_src, 1144 nr_irqs); 1145 if (count < 0) { 1146 printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n"); 1147 /* TBD: Cleanup to allow fallback to MPS */ 1148 return count; 1149 } 1150 1151 return 0; 1152 } 1153 #else 1154 static inline int acpi_parse_madt_ioapic_entries(void) 1155 { 1156 return -1; 1157 } 1158 #endif /* !CONFIG_X86_IO_APIC */ 1159 1160 static void __init early_acpi_process_madt(void) 1161 { 1162 #ifdef CONFIG_X86_LOCAL_APIC 1163 int error; 1164 1165 if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) { 1166 1167 /* 1168 * Parse MADT LAPIC entries 1169 */ 1170 error = early_acpi_parse_madt_lapic_addr_ovr(); 1171 if (!error) { 1172 acpi_lapic = 1; 1173 smp_found_config = 1; 1174 } 1175 if (error == -EINVAL) { 1176 /* 1177 * Dell Precision Workstation 410, 610 come here. 1178 */ 1179 printk(KERN_ERR PREFIX 1180 "Invalid BIOS MADT, disabling ACPI\n"); 1181 disable_acpi(); 1182 } 1183 } 1184 #endif 1185 } 1186 1187 static void __init acpi_process_madt(void) 1188 { 1189 #ifdef CONFIG_X86_LOCAL_APIC 1190 int error; 1191 1192 if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) { 1193 1194 /* 1195 * Parse MADT LAPIC entries 1196 */ 1197 error = acpi_parse_madt_lapic_entries(); 1198 if (!error) { 1199 acpi_lapic = 1; 1200 1201 /* 1202 * Parse MADT IO-APIC entries 1203 */ 1204 error = acpi_parse_madt_ioapic_entries(); 1205 if (!error) { 1206 acpi_set_irq_model_ioapic(); 1207 1208 smp_found_config = 1; 1209 } 1210 } 1211 if (error == -EINVAL) { 1212 /* 1213 * Dell Precision Workstation 410, 610 come here. 1214 */ 1215 printk(KERN_ERR PREFIX 1216 "Invalid BIOS MADT, disabling ACPI\n"); 1217 disable_acpi(); 1218 } 1219 } else { 1220 /* 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. 1224 */ 1225 if (smp_found_config) { 1226 printk(KERN_WARNING PREFIX 1227 "No APIC-table, disabling MPS\n"); 1228 smp_found_config = 0; 1229 } 1230 } 1231 1232 /* 1233 * ACPI supports both logical (e.g. Hyper-Threading) and physical 1234 * processors, where MPS only supports physical. 1235 */ 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; 1244 } 1245 1246 static int __init disable_acpi_irq(const struct dmi_system_id *d) 1247 { 1248 if (!acpi_force) { 1249 printk(KERN_NOTICE "%s detected: force use of acpi=noirq\n", 1250 d->ident); 1251 acpi_noirq_set(); 1252 } 1253 return 0; 1254 } 1255 1256 static int __init disable_acpi_pci(const struct dmi_system_id *d) 1257 { 1258 if (!acpi_force) { 1259 printk(KERN_NOTICE "%s detected: force use of pci=noacpi\n", 1260 d->ident); 1261 acpi_disable_pci(); 1262 } 1263 return 0; 1264 } 1265 1266 static int __init dmi_disable_acpi(const struct dmi_system_id *d) 1267 { 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"); 1274 } 1275 return 0; 1276 } 1277 1278 /* 1279 * Force ignoring BIOS IRQ0 override 1280 */ 1281 static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d) 1282 { 1283 if (!acpi_skip_timer_override) { 1284 pr_notice("%s detected: Ignoring BIOS IRQ0 override\n", 1285 d->ident); 1286 acpi_skip_timer_override = 1; 1287 } 1288 return 0; 1289 } 1290 1291 /* 1292 * If your system is blacklisted here, but you find that acpi=force 1293 * works for you, please contact linux-acpi@vger.kernel.org 1294 */ 1295 static struct dmi_system_id __initdata acpi_dmi_table[] = { 1296 /* 1297 * Boxes that need ACPI disabled 1298 */ 1299 { 1300 .callback = dmi_disable_acpi, 1301 .ident = "IBM Thinkpad", 1302 .matches = { 1303 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), 1304 DMI_MATCH(DMI_BOARD_NAME, "2629H1G"), 1305 }, 1306 }, 1307 1308 /* 1309 * Boxes that need ACPI PCI IRQ routing disabled 1310 */ 1311 { 1312 .callback = disable_acpi_irq, 1313 .ident = "ASUS A7V", 1314 .matches = { 1315 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC"), 1316 DMI_MATCH(DMI_BOARD_NAME, "<A7V>"), 1317 /* newer BIOS, Revision 1011, does work */ 1318 DMI_MATCH(DMI_BIOS_VERSION, 1319 "ASUS A7V ACPI BIOS Revision 1007"), 1320 }, 1321 }, 1322 { 1323 /* 1324 * Latest BIOS for IBM 600E (1.16) has bad pcinum 1325 * for LPC bridge, which is needed for the PCI 1326 * interrupt links to work. DSDT fix is in bug 5966. 1327 * 2645, 2646 model numbers are shared with 600/600E/600X 1328 */ 1329 .callback = disable_acpi_irq, 1330 .ident = "IBM Thinkpad 600 Series 2645", 1331 .matches = { 1332 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), 1333 DMI_MATCH(DMI_BOARD_NAME, "2645"), 1334 }, 1335 }, 1336 { 1337 .callback = disable_acpi_irq, 1338 .ident = "IBM Thinkpad 600 Series 2646", 1339 .matches = { 1340 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), 1341 DMI_MATCH(DMI_BOARD_NAME, "2646"), 1342 }, 1343 }, 1344 /* 1345 * Boxes that need ACPI PCI IRQ routing and PCI scan disabled 1346 */ 1347 { /* _BBN 0 bug */ 1348 .callback = disable_acpi_pci, 1349 .ident = "ASUS PR-DLS", 1350 .matches = { 1351 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."), 1352 DMI_MATCH(DMI_BOARD_NAME, "PR-DLS"), 1353 DMI_MATCH(DMI_BIOS_VERSION, 1354 "ASUS PR-DLS ACPI BIOS Revision 1010"), 1355 DMI_MATCH(DMI_BIOS_DATE, "03/21/2003") 1356 }, 1357 }, 1358 { 1359 .callback = disable_acpi_pci, 1360 .ident = "Acer TravelMate 36x Laptop", 1361 .matches = { 1362 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 1363 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"), 1364 }, 1365 }, 1366 {} 1367 }; 1368 1369 /* second table for DMI checks that should run after early-quirks */ 1370 static struct dmi_system_id __initdata acpi_dmi_table_late[] = { 1371 /* 1372 * HP laptops which use a DSDT reporting as HP/SB400/10000, 1373 * which includes some code which overrides all temperature 1374 * trip points to 16C if the INTIN2 input of the I/O APIC 1375 * is enabled. This input is incorrectly designated the 1376 * ISA IRQ 0 via an interrupt source override even though 1377 * it is wired to the output of the master 8259A and INTIN0 1378 * is not connected at all. Force ignoring BIOS IRQ0 1379 * override in that cases. 1380 */ 1381 { 1382 .callback = dmi_ignore_irq0_timer_override, 1383 .ident = "HP nx6115 laptop", 1384 .matches = { 1385 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), 1386 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6115"), 1387 }, 1388 }, 1389 { 1390 .callback = dmi_ignore_irq0_timer_override, 1391 .ident = "HP NX6125 laptop", 1392 .matches = { 1393 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), 1394 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6125"), 1395 }, 1396 }, 1397 { 1398 .callback = dmi_ignore_irq0_timer_override, 1399 .ident = "HP NX6325 laptop", 1400 .matches = { 1401 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), 1402 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6325"), 1403 }, 1404 }, 1405 { 1406 .callback = dmi_ignore_irq0_timer_override, 1407 .ident = "HP 6715b laptop", 1408 .matches = { 1409 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), 1410 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq 6715b"), 1411 }, 1412 }, 1413 { 1414 .callback = dmi_ignore_irq0_timer_override, 1415 .ident = "FUJITSU SIEMENS", 1416 .matches = { 1417 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), 1418 DMI_MATCH(DMI_PRODUCT_NAME, "AMILO PRO V2030"), 1419 }, 1420 }, 1421 {} 1422 }; 1423 1424 /* 1425 * acpi_boot_table_init() and acpi_boot_init() 1426 * called from setup_arch(), always. 1427 * 1. checksums all tables 1428 * 2. enumerates lapics 1429 * 3. enumerates io-apics 1430 * 1431 * acpi_table_init() is separate to allow reading SRAT without 1432 * other side effects. 1433 * 1434 * side effects of acpi_boot_init: 1435 * acpi_lapic = 1 if LAPIC found 1436 * acpi_ioapic = 1 if IOAPIC found 1437 * if (acpi_lapic && acpi_ioapic) smp_found_config = 1; 1438 * if acpi_blacklisted() acpi_disabled = 1; 1439 * acpi_irq_model=... 1440 * ... 1441 */ 1442 1443 void __init acpi_boot_table_init(void) 1444 { 1445 dmi_check_system(acpi_dmi_table); 1446 1447 /* 1448 * If acpi_disabled, bail out 1449 */ 1450 if (acpi_disabled) 1451 return; 1452 1453 /* 1454 * Initialize the ACPI boot-time table parser. 1455 */ 1456 if (acpi_table_init()) { 1457 disable_acpi(); 1458 return; 1459 } 1460 1461 acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf); 1462 1463 /* 1464 * blacklist may disable ACPI entirely 1465 */ 1466 if (acpi_blacklisted()) { 1467 if (acpi_force) { 1468 printk(KERN_WARNING PREFIX "acpi=force override\n"); 1469 } else { 1470 printk(KERN_WARNING PREFIX "Disabling ACPI support\n"); 1471 disable_acpi(); 1472 return; 1473 } 1474 } 1475 } 1476 1477 int __init early_acpi_boot_init(void) 1478 { 1479 /* 1480 * If acpi_disabled, bail out 1481 */ 1482 if (acpi_disabled) 1483 return 1; 1484 1485 /* 1486 * Process the Multiple APIC Description Table (MADT), if present 1487 */ 1488 early_acpi_process_madt(); 1489 1490 return 0; 1491 } 1492 1493 int __init acpi_boot_init(void) 1494 { 1495 /* those are executed after early-quirks are executed */ 1496 dmi_check_system(acpi_dmi_table_late); 1497 1498 /* 1499 * If acpi_disabled, bail out 1500 */ 1501 if (acpi_disabled) 1502 return 1; 1503 1504 acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf); 1505 1506 /* 1507 * set sci_int and PM timer address 1508 */ 1509 acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt); 1510 1511 /* 1512 * Process the Multiple APIC Description Table (MADT), if present 1513 */ 1514 acpi_process_madt(); 1515 1516 acpi_table_parse(ACPI_SIG_HPET, acpi_parse_hpet); 1517 1518 if (!acpi_noirq) 1519 x86_init.pci.init = pci_acpi_init; 1520 1521 return 0; 1522 } 1523 1524 static int __init parse_acpi(char *arg) 1525 { 1526 if (!arg) 1527 return -EINVAL; 1528 1529 /* "acpi=off" disables both ACPI table parsing and interpreter */ 1530 if (strcmp(arg, "off") == 0) { 1531 disable_acpi(); 1532 } 1533 /* acpi=force to over-ride black-list */ 1534 else if (strcmp(arg, "force") == 0) { 1535 acpi_force = 1; 1536 acpi_disabled = 0; 1537 } 1538 /* acpi=strict disables out-of-spec workarounds */ 1539 else if (strcmp(arg, "strict") == 0) { 1540 acpi_strict = 1; 1541 } 1542 /* acpi=rsdt use RSDT instead of XSDT */ 1543 else if (strcmp(arg, "rsdt") == 0) { 1544 acpi_gbl_do_not_use_xsdt = TRUE; 1545 } 1546 /* "acpi=noirq" disables ACPI interrupt routing */ 1547 else if (strcmp(arg, "noirq") == 0) { 1548 acpi_noirq_set(); 1549 } 1550 /* "acpi=copy_dsdt" copys DSDT */ 1551 else if (strcmp(arg, "copy_dsdt") == 0) { 1552 acpi_gbl_copy_dsdt_locally = 1; 1553 } 1554 /* "acpi=nocmcff" disables FF mode for corrected errors */ 1555 else if (strcmp(arg, "nocmcff") == 0) { 1556 acpi_disable_cmcff = 1; 1557 } else { 1558 /* Core will printk when we return error. */ 1559 return -EINVAL; 1560 } 1561 return 0; 1562 } 1563 early_param("acpi", parse_acpi); 1564 1565 /* FIXME: Using pci= for an ACPI parameter is a travesty. */ 1566 static int __init parse_pci(char *arg) 1567 { 1568 if (arg && strcmp(arg, "noacpi") == 0) 1569 acpi_disable_pci(); 1570 return 0; 1571 } 1572 early_param("pci", parse_pci); 1573 1574 int __init acpi_mps_check(void) 1575 { 1576 #if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_X86_MPPARSE) 1577 /* mptable code is not built-in*/ 1578 if (acpi_disabled || acpi_noirq) { 1579 printk(KERN_WARNING "MPS support code is not built-in.\n" 1580 "Using acpi=off or acpi=noirq or pci=noacpi " 1581 "may have problem\n"); 1582 return 1; 1583 } 1584 #endif 1585 return 0; 1586 } 1587 1588 #ifdef CONFIG_X86_IO_APIC 1589 static int __init parse_acpi_skip_timer_override(char *arg) 1590 { 1591 acpi_skip_timer_override = 1; 1592 return 0; 1593 } 1594 early_param("acpi_skip_timer_override", parse_acpi_skip_timer_override); 1595 1596 static int __init parse_acpi_use_timer_override(char *arg) 1597 { 1598 acpi_use_timer_override = 1; 1599 return 0; 1600 } 1601 early_param("acpi_use_timer_override", parse_acpi_use_timer_override); 1602 #endif /* CONFIG_X86_IO_APIC */ 1603 1604 static int __init setup_acpi_sci(char *s) 1605 { 1606 if (!s) 1607 return -EINVAL; 1608 if (!strcmp(s, "edge")) 1609 acpi_sci_flags = ACPI_MADT_TRIGGER_EDGE | 1610 (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK); 1611 else if (!strcmp(s, "level")) 1612 acpi_sci_flags = ACPI_MADT_TRIGGER_LEVEL | 1613 (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK); 1614 else if (!strcmp(s, "high")) 1615 acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_HIGH | 1616 (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK); 1617 else if (!strcmp(s, "low")) 1618 acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_LOW | 1619 (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK); 1620 else 1621 return -EINVAL; 1622 return 0; 1623 } 1624 early_param("acpi_sci", setup_acpi_sci); 1625 1626 int __acpi_acquire_global_lock(unsigned int *lock) 1627 { 1628 unsigned int old, new, val; 1629 do { 1630 old = *lock; 1631 new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1)); 1632 val = cmpxchg(lock, old, new); 1633 } while (unlikely (val != old)); 1634 return (new < 3) ? -1 : 0; 1635 } 1636 1637 int __acpi_release_global_lock(unsigned int *lock) 1638 { 1639 unsigned int old, new, val; 1640 do { 1641 old = *lock; 1642 new = old & ~0x3; 1643 val = cmpxchg(lock, old, new); 1644 } while (unlikely (val != old)); 1645 return old & 0x1; 1646 } 1647 1648 void __init arch_reserve_mem_area(acpi_physical_address addr, size_t size) 1649 { 1650 e820_add_region(addr, size, E820_ACPI); 1651 update_e820(); 1652 } 1653