31 #include <linux/module.h>
34 #include <linux/slab.h>
37 #include <linux/pci.h>
40 #include <asm/pgtable.h>
57 #define BAD_MADT_ENTRY(entry, end) ( \
58 (!entry) || (unsigned long)entry + sizeof(*entry) > end || \
59 ((struct acpi_subtable_header *)entry)->length < sizeof(*entry))
61 #define PREFIX "ACPI: "
77 #ifdef CONFIG_X86_LOCAL_APIC
81 #ifndef __HAVE_ARCH_CMPXCHG
82 #warning ACPI uses CMPXCHG, i486 and later hardware
101 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
110 if (isa_irq_to_gsi[i] == gsi) {
119 if (gsi >= NR_IRQS_LEGACY)
127 static u32 irq_to_gsi(
int irq)
131 if (irq < NR_IRQS_LEGACY)
132 gsi = isa_irq_to_gsi[irq];
135 else if (irq < (
gsi_top + NR_IRQS_LEGACY))
171 #ifdef CONFIG_X86_LOCAL_APIC
193 madt->
header.oem_table_id);
200 unsigned int ver = 0;
234 #ifdef CONFIG_X86_X2APIC
245 acpi_register_lapic(apic_id, enabled);
272 acpi_register_lapic(processor->
id,
290 acpi_register_lapic((processor->
id << 8) | processor->
eid,
298 const unsigned long end)
307 acpi_lapic_addr = lapic_addr_ovr->
address;
314 const unsigned long end)
325 if (x2apic_nmi->
lint != 1)
343 if (lapic_nmi->
lint != 1)
351 #ifdef CONFIG_X86_IO_APIC
394 mp_override_legacy_irq(bus_irq, polarity, trigger, gsi);
400 acpi_sci_override_gsi =
gsi;
406 const unsigned long end)
420 (intsrc->
inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2,
426 if (acpi_skip_timer_override) {
431 if ((intsrc->
global_irq == 2) && acpi_fix_pin2_polarity
434 printk(
PREFIX "BIOS IRQ0 pin2 override: forcing polarity to high active.\n");
440 (intsrc->
inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2,
481 unsigned int mask = 1 << irq;
482 unsigned int old,
new;
485 old =
inb(0x4d0) | (
inb(0x4d1) << 8);
510 printk(
PREFIX "setting ELCR to %04x (from %04x)\n",
new, old);
512 outb(
new >> 8, 0x4d1);
519 #ifdef CONFIG_X86_IO_APIC
532 *gsi = irq_to_gsi(isa_irq);
536 static int acpi_register_gsi_pic(
struct device *
dev,
u32 gsi,
537 int trigger,
int polarity)
550 static int acpi_register_gsi_ioapic(
struct device *dev,
u32 gsi,
551 int trigger,
int polarity)
553 #ifdef CONFIG_X86_IO_APIC
554 gsi = mp_register_gsi(dev, gsi, trigger, polarity);
570 unsigned int plat_gsi =
gsi;
595 #ifdef CONFIG_ACPI_HOTPLUG_CPU
600 #ifdef CONFIG_ACPI_NUMA
606 set_apicid_to_node(physid, nid);
629 obj->
buffer.length <
sizeof(*lapic)) {
655 cpumask_copy(tmp_map, cpu_present_mask);
662 cpumask_andnot(new_map, cpu_present_mask, tmp_map);
663 if (cpumask_empty(new_map)) {
664 printk (
"Unable to map lapic to logical cpu number\n");
671 cpu = cpumask_first(new_map);
672 acpi_map_cpu2node(handle, cpu, physid);
678 free_cpumask_var(new_map);
680 free_cpumask_var(tmp_map);
688 return _acpi_map_lsapic(handle, pcpu);
692 int acpi_unmap_lsapic(
int cpu)
694 per_cpu(x86_cpu_to_apicid, cpu) = -1;
735 #ifdef CONFIG_HPET_TIMER
750 if (hpet_tbl->
address.space_id != ACPI_SPACE_MEM) {
765 "HPET id: %#x base: %#lx is invalid\n",
778 "base: 0xfed0000000000000 is bogus\n "
779 "try hpet=force on the kernel command line to "
780 "fix it up to 0xfed00000.\n", hpet_tbl->
id);
785 "HPET id: %#x base: 0xfed0000000000000 fixed up "
786 "to 0xfed00000.\n", hpet_tbl->
id);
797 #define HPET_RESOURCE_NAME_SIZE 9
798 hpet_res =
alloc_bootmem(
sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE);
800 hpet_res->name = (
void *)&hpet_res[1];
802 snprintf((
char *)hpet_res->name, HPET_RESOURCE_NAME_SIZE,
"HPET %u",
815 static __init int hpet_insert_resource(
void)
826 #define acpi_parse_hpet NULL
832 #ifdef CONFIG_X86_PM_TIMER
859 #ifdef CONFIG_X86_LOCAL_APIC
865 static int __init early_acpi_parse_madt_lapic_addr_ovr(
void)
879 acpi_parse_lapic_addr_ovr, 0);
882 "Error parsing LAPIC address override entry\n");
891 static int __init acpi_parse_madt_lapic_entries(
void)
906 acpi_parse_lapic_addr_ovr, 0);
909 "Error parsing LAPIC address override entry\n");
924 if (!count && !x2count) {
928 }
else if (count < 0 || x2count < 0) {
936 acpi_parse_x2apic_nmi, 0);
939 if (count < 0 || x2count < 0) {
948 #ifdef CONFIG_X86_IO_APIC
951 #ifdef CONFIG_X86_ES7000
955 void __init mp_override_legacy_irq(
u8 bus_irq,
u8 polarity,
u8 trigger,
u32 gsi)
974 if ((bus_irq == 0) && (trigger == 3))
979 mp_irq.irqflag = (trigger << 2) | polarity;
980 mp_irq.srcbus = MP_ISA_BUS;
981 mp_irq.srcbusirq = bus_irq;
987 isa_irq_to_gsi[bus_irq] =
gsi;
990 void __init mp_config_acpi_legacy_irqs(
void)
1001 set_bit(MP_ISA_BUS, mp_bus_not_pci);
1002 pr_debug(
"Bus #%d is ISA\n", MP_ISA_BUS);
1004 #ifdef CONFIG_X86_ES7000
1008 if (es7000_plat == 1)
1016 for (i = 0; i < 16; i++) {
1047 if (idx != mp_irq_entries) {
1054 mp_irq.srcbus = MP_ISA_BUS;
1057 mp_irq.srcbusirq =
i;
1058 mp_irq.dstirq =
pin;
1064 static int mp_config_acpi_gsi(
struct device *dev,
u32 gsi,
int trigger,
1067 #ifdef CONFIG_X86_MPPARSE
1083 number = pdev->
bus->number;
1084 devfn = pdev->
devfn;
1091 mp_irq.srcbus = number;
1092 mp_irq.srcbusirq = (((devfn >> 3) & 0x1f) << 2) | ((pin - 1) & 3);
1102 int mp_register_gsi(
struct device *dev,
u32 gsi,
int trigger,
int polarity)
1123 if (ioapic_pin > MP_MAX_IOAPIC_PIN) {
1131 mp_config_acpi_gsi(dev, gsi, trigger, polarity);
1133 set_io_apic_irq_attr(&irq_attr, ioapic, ioapic_pin,
1145 static int __init acpi_parse_madt_ioapic_entries(
void)
1166 "due to 'noapic' option.\n");
1176 }
else if (count < 0) {
1186 "Error parsing interrupt source overrides entry\n");
1195 if (!acpi_sci_override_gsi)
1200 mp_config_acpi_legacy_irqs();
1214 static inline int acpi_parse_madt_ioapic_entries(
void)
1220 static void __init early_acpi_process_madt(
void)
1222 #ifdef CONFIG_X86_LOCAL_APIC
1230 error = early_acpi_parse_madt_lapic_addr_ovr();
1240 "Invalid BIOS MADT, disabling ACPI\n");
1247 static void __init acpi_process_madt(
void)
1249 #ifdef CONFIG_X86_LOCAL_APIC
1257 error = acpi_parse_madt_lapic_entries();
1264 error = acpi_parse_madt_ioapic_entries();
1276 "Invalid BIOS MADT, disabling ACPI\n");
1287 "No APIC-table, disabling MPS\n");
1301 "configuration information\n");
1333 "Warning: DMI blacklist says broken, but acpi forced\n");
1343 if (!acpi_skip_timer_override) {
1344 pr_notice(
"%s detected: Ignoring BIOS IRQ0 override\n",
1346 acpi_skip_timer_override = 1;
1360 .callback = dmi_disable_acpi,
1361 .ident =
"IBM Thinkpad",
1372 .callback = disable_acpi_irq,
1373 .ident =
"ASUS A7V",
1379 "ASUS A7V ACPI BIOS Revision 1007"),
1389 .callback = disable_acpi_irq,
1390 .ident =
"IBM Thinkpad 600 Series 2645",
1397 .callback = disable_acpi_irq,
1398 .ident =
"IBM Thinkpad 600 Series 2646",
1408 .callback = disable_acpi_pci,
1409 .ident =
"ASUS PR-DLS",
1414 "ASUS PR-DLS ACPI BIOS Revision 1010"),
1419 .callback = disable_acpi_pci,
1420 .ident =
"Acer TravelMate 36x Laptop",
1442 .callback = dmi_ignore_irq0_timer_override,
1443 .ident =
"HP nx6115 laptop",
1450 .callback = dmi_ignore_irq0_timer_override,
1451 .ident =
"HP NX6125 laptop",
1458 .callback = dmi_ignore_irq0_timer_override,
1459 .ident =
"HP NX6325 laptop",
1466 .callback = dmi_ignore_irq0_timer_override,
1467 .ident =
"HP 6715b laptop",
1474 .callback = dmi_ignore_irq0_timer_override,
1475 .ident =
"FUJITSU SIEMENS",
1548 early_acpi_process_madt();
1574 acpi_process_madt();
1590 if (
strcmp(arg,
"off") == 0) {
1594 else if (
strcmp(arg,
"force") == 0) {
1599 else if (
strcmp(arg,
"strict") == 0) {
1603 else if (
strcmp(arg,
"rsdt") == 0) {
1607 else if (
strcmp(arg,
"noirq") == 0) {
1611 else if (
strcmp(arg,
"copy_dsdt") == 0) {
1622 static int __init parse_pci(
char *arg)
1624 if (arg &&
strcmp(arg,
"noacpi") == 0)
1632 #if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_X86_MPPARSE)
1636 "Using acpi=off or acpi=noirq or pci=noacpi "
1637 "may have problem\n");
1644 #ifdef CONFIG_X86_IO_APIC
1645 static int __init parse_acpi_skip_timer_override(
char *arg)
1647 acpi_skip_timer_override = 1;
1650 early_param(
"acpi_skip_timer_override", parse_acpi_skip_timer_override);
1652 static int __init parse_acpi_use_timer_override(
char *arg)
1654 acpi_use_timer_override = 1;
1657 early_param(
"acpi_use_timer_override", parse_acpi_use_timer_override);
1660 static int __init setup_acpi_sci(
char *
s)
1666 (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK);
1667 else if (!
strcmp(s,
"level"))
1669 (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK);
1670 else if (!
strcmp(s,
"high"))
1673 else if (!
strcmp(s,
"low"))
1684 unsigned int old,
new,
val;
1687 new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1));
1688 val =
cmpxchg(lock, old,
new);
1690 return (
new < 3) ? -1 : 0;
1695 unsigned int old,
new,
val;
1699 val =
cmpxchg(lock, old,
new);