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