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