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