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