blob: f3761b98c8dd88cdd8fa600881ecd002317c7f08 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * boot.c - Architecture-Specific Low-Level ACPI Boot Support
3 *
4 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
5 * Copyright (C) 2001 Jun Nakajima <jun.nakajima@intel.com>
6 *
7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24 */
25
26#include <linux/init.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#include <linux/acpi.h>
28#include <linux/efi.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#include <linux/module.h>
Andrey Paninaea00142005-06-25 14:54:42 -070030#include <linux/dmi.h>
Nick Pigginb33fa1f2005-10-01 02:34:42 +100031#include <linux/irq.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
33#include <asm/pgtable.h>
34#include <asm/io_apic.h>
35#include <asm/apic.h>
36#include <asm/io.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070037#include <asm/mpspec.h>
38
Rusty Russell1a3f2392006-09-26 10:52:32 +020039int __initdata acpi_force = 0;
40
Andi Kleendf3bb572006-09-26 10:52:33 +020041#ifdef CONFIG_ACPI
42int acpi_disabled = 0;
43#else
44int acpi_disabled = 1;
45#endif
46EXPORT_SYMBOL(acpi_disabled);
47
Linus Torvalds1da177e2005-04-16 15:20:36 -070048#ifdef CONFIG_X86_64
49
Linus Torvalds1da177e2005-04-16 15:20:36 -070050extern void __init clustered_apic_check(void);
Len Brown4be44fc2005-08-05 00:44:28 -040051
James Cleverdon6004e1b2005-11-05 17:25:53 +010052extern int gsi_irq_sharing(int gsi);
Linus Torvalds1da177e2005-04-16 15:20:36 -070053#include <asm/proto.h>
54
Linus Torvalds637029c2006-02-27 20:41:56 -080055static inline int acpi_madt_oem_check(char *oem_id, char *oem_table_id) { return 0; }
56
57
Len Brown4be44fc2005-08-05 00:44:28 -040058#else /* X86 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
60#ifdef CONFIG_X86_LOCAL_APIC
61#include <mach_apic.h>
62#include <mach_mpparse.h>
Len Brown4be44fc2005-08-05 00:44:28 -040063#endif /* CONFIG_X86_LOCAL_APIC */
Linus Torvalds1da177e2005-04-16 15:20:36 -070064
James Cleverdon6004e1b2005-11-05 17:25:53 +010065static inline int gsi_irq_sharing(int gsi) { return gsi; }
66
Len Brown4be44fc2005-08-05 00:44:28 -040067#endif /* X86 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
69#define BAD_MADT_ENTRY(entry, end) ( \
70 (!entry) || (unsigned long)entry + sizeof(*entry) > end || \
Starikovskiy, Alexey Ydf6fd312006-08-18 11:23:00 -040071 ((acpi_table_entry_header *)entry)->length < sizeof(*entry))
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
73#define PREFIX "ACPI: "
74
Linus Torvalds1da177e2005-04-16 15:20:36 -070075int acpi_noirq __initdata; /* skip ACPI IRQ initialization */
Len Brown4be44fc2005-08-05 00:44:28 -040076int acpi_pci_disabled __initdata; /* skip ACPI PCI scan and IRQ initialization */
Linus Torvalds1da177e2005-04-16 15:20:36 -070077int acpi_ht __initdata = 1; /* enable HT */
78
79int acpi_lapic;
80int acpi_ioapic;
81int acpi_strict;
82EXPORT_SYMBOL(acpi_strict);
83
84acpi_interrupt_flags acpi_sci_flags __initdata;
85int acpi_sci_override_gsi __initdata;
86int acpi_skip_timer_override __initdata;
87
88#ifdef CONFIG_X86_LOCAL_APIC
89static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
90#endif
91
92#ifndef __HAVE_ARCH_CMPXCHG
93#warning ACPI uses CMPXCHG, i486 and later hardware
94#endif
95
96#define MAX_MADT_ENTRIES 256
97u8 x86_acpiid_to_apicid[MAX_MADT_ENTRIES] =
Len Brown1f3a7302005-08-05 03:33:14 -040098 {[0 ... MAX_MADT_ENTRIES - 1] = 0xff };
Linus Torvalds1da177e2005-04-16 15:20:36 -070099EXPORT_SYMBOL(x86_acpiid_to_apicid);
100
101/* --------------------------------------------------------------------------
102 Boot-time Configuration
103 -------------------------------------------------------------------------- */
104
105/*
106 * The default interrupt routing model is PIC (8259). This gets
107 * overriden if IOAPICs are enumerated (below).
108 */
Len Brown4be44fc2005-08-05 00:44:28 -0400109enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110
111#ifdef CONFIG_X86_64
112
113/* rely on all ACPI tables being in the direct mapping */
114char *__acpi_map_table(unsigned long phys_addr, unsigned long size)
115{
116 if (!phys_addr || !size)
Len Brown4be44fc2005-08-05 00:44:28 -0400117 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118
Andi Kleen7a4a76c2006-01-11 22:43:39 +0100119 if (phys_addr+size <= (end_pfn_map << PAGE_SHIFT) + PAGE_SIZE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 return __va(phys_addr);
121
122 return NULL;
123}
124
125#else
126
127/*
128 * Temporarily use the virtual area starting from FIX_IO_APIC_BASE_END,
129 * to map the target physical address. The problem is that set_fixmap()
130 * provides a single page, and it is possible that the page is not
131 * sufficient.
132 * By using this area, we can map up to MAX_IO_APICS pages temporarily,
133 * i.e. until the next __va_range() call.
134 *
135 * Important Safety Note: The fixed I/O APIC page numbers are *subtracted*
136 * from the fixed base. That's why we start at FIX_IO_APIC_BASE_END and
137 * count idx down while incrementing the phys address.
138 */
139char *__acpi_map_table(unsigned long phys, unsigned long size)
140{
141 unsigned long base, offset, mapped_size;
142 int idx;
143
Len Brown4be44fc2005-08-05 00:44:28 -0400144 if (phys + size < 8 * 1024 * 1024)
145 return __va(phys);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
147 offset = phys & (PAGE_SIZE - 1);
148 mapped_size = PAGE_SIZE - offset;
149 set_fixmap(FIX_ACPI_END, phys);
150 base = fix_to_virt(FIX_ACPI_END);
151
152 /*
153 * Most cases can be covered by the below.
154 */
155 idx = FIX_ACPI_END;
156 while (mapped_size < size) {
157 if (--idx < FIX_ACPI_BEGIN)
158 return NULL; /* cannot handle this */
159 phys += PAGE_SIZE;
160 set_fixmap(idx, phys);
161 mapped_size += PAGE_SIZE;
162 }
163
Len Brown4be44fc2005-08-05 00:44:28 -0400164 return ((unsigned char *)base + offset);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165}
166#endif
167
168#ifdef CONFIG_PCI_MMCONFIG
Greg Kroah-Hartman54549392005-06-23 17:35:56 -0700169/* The physical address of the MMCONFIG aperture. Set from ACPI tables. */
170struct acpi_table_mcfg_config *pci_mmcfg_config;
171int pci_mmcfg_config_num;
172
173int __init acpi_parse_mcfg(unsigned long phys_addr, unsigned long size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174{
175 struct acpi_table_mcfg *mcfg;
Greg Kroah-Hartman54549392005-06-23 17:35:56 -0700176 unsigned long i;
177 int config_size;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178
Andi Kleen87cb23a2006-04-18 12:35:10 +0200179 if (!phys_addr || !size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180 return -EINVAL;
181
Len Brown4be44fc2005-08-05 00:44:28 -0400182 mcfg = (struct acpi_table_mcfg *)__acpi_map_table(phys_addr, size);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183 if (!mcfg) {
184 printk(KERN_WARNING PREFIX "Unable to map MCFG\n");
185 return -ENODEV;
186 }
187
Greg Kroah-Hartman54549392005-06-23 17:35:56 -0700188 /* how many config structures do we have */
189 pci_mmcfg_config_num = 0;
190 i = size - sizeof(struct acpi_table_mcfg);
191 while (i >= sizeof(struct acpi_table_mcfg_config)) {
192 ++pci_mmcfg_config_num;
193 i -= sizeof(struct acpi_table_mcfg_config);
194 };
195 if (pci_mmcfg_config_num == 0) {
196 printk(KERN_ERR PREFIX "MMCONFIG has no entries\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 return -ENODEV;
198 }
199
Greg Kroah-Hartman54549392005-06-23 17:35:56 -0700200 config_size = pci_mmcfg_config_num * sizeof(*pci_mmcfg_config);
201 pci_mmcfg_config = kmalloc(config_size, GFP_KERNEL);
202 if (!pci_mmcfg_config) {
203 printk(KERN_WARNING PREFIX
204 "No memory for MCFG config tables\n");
205 return -ENOMEM;
206 }
207
208 memcpy(pci_mmcfg_config, &mcfg->config, config_size);
209 for (i = 0; i < pci_mmcfg_config_num; ++i) {
210 if (mcfg->config[i].base_reserved) {
211 printk(KERN_ERR PREFIX
212 "MMCONFIG not in low 4GB of memory\n");
Konrad Rzeszutekacc7c2e2006-06-15 12:08:30 -0400213 kfree(pci_mmcfg_config);
214 pci_mmcfg_config_num = 0;
Greg Kroah-Hartman54549392005-06-23 17:35:56 -0700215 return -ENODEV;
216 }
217 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218
219 return 0;
220}
Len Brown4be44fc2005-08-05 00:44:28 -0400221#endif /* CONFIG_PCI_MMCONFIG */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222
223#ifdef CONFIG_X86_LOCAL_APIC
Len Brown4be44fc2005-08-05 00:44:28 -0400224static int __init acpi_parse_madt(unsigned long phys_addr, unsigned long size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225{
Len Brown4be44fc2005-08-05 00:44:28 -0400226 struct acpi_table_madt *madt = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227
Andi Kleen9cfda2c2006-03-27 02:24:32 -0500228 if (!phys_addr || !size || !cpu_has_apic)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229 return -EINVAL;
230
Len Brown4be44fc2005-08-05 00:44:28 -0400231 madt = (struct acpi_table_madt *)__acpi_map_table(phys_addr, size);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232 if (!madt) {
233 printk(KERN_WARNING PREFIX "Unable to map MADT\n");
234 return -ENODEV;
235 }
236
237 if (madt->lapic_address) {
238 acpi_lapic_addr = (u64) madt->lapic_address;
239
240 printk(KERN_DEBUG PREFIX "Local APIC address 0x%08x\n",
Len Brown4be44fc2005-08-05 00:44:28 -0400241 madt->lapic_address);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242 }
243
244 acpi_madt_oem_check(madt->header.oem_id, madt->header.oem_table_id);
Len Brown4be44fc2005-08-05 00:44:28 -0400245
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246 return 0;
247}
248
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249static int __init
Len Brown4be44fc2005-08-05 00:44:28 -0400250acpi_parse_lapic(acpi_table_entry_header * header, const unsigned long end)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251{
Len Brown4be44fc2005-08-05 00:44:28 -0400252 struct acpi_table_lapic *processor = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253
Len Brown4be44fc2005-08-05 00:44:28 -0400254 processor = (struct acpi_table_lapic *)header;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255
256 if (BAD_MADT_ENTRY(processor, end))
257 return -EINVAL;
258
259 acpi_table_print_madt_entry(header);
260
Ashok Raj7f66ae42006-02-03 21:51:50 +0100261 /* Record local apic id only when enabled */
262 if (processor->flags.enabled)
263 x86_acpiid_to_apicid[processor->acpi_id] = processor->id;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264
Ashok Raj7f66ae42006-02-03 21:51:50 +0100265 /*
266 * We need to register disabled CPU as well to permit
267 * counting disabled CPUs. This allows us to size
268 * cpus_possible_map more accurately, to permit
269 * to not preallocating memory for all NR_CPUS
270 * when we use CPU hotplug.
271 */
Len Brown4be44fc2005-08-05 00:44:28 -0400272 mp_register_lapic(processor->id, /* APIC ID */
273 processor->flags.enabled); /* Enabled? */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274
275 return 0;
276}
277
278static int __init
Len Brown4be44fc2005-08-05 00:44:28 -0400279acpi_parse_lapic_addr_ovr(acpi_table_entry_header * header,
280 const unsigned long end)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281{
282 struct acpi_table_lapic_addr_ovr *lapic_addr_ovr = NULL;
283
Len Brown4be44fc2005-08-05 00:44:28 -0400284 lapic_addr_ovr = (struct acpi_table_lapic_addr_ovr *)header;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285
286 if (BAD_MADT_ENTRY(lapic_addr_ovr, end))
287 return -EINVAL;
288
289 acpi_lapic_addr = lapic_addr_ovr->address;
290
291 return 0;
292}
293
294static int __init
Len Brown4be44fc2005-08-05 00:44:28 -0400295acpi_parse_lapic_nmi(acpi_table_entry_header * header, const unsigned long end)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296{
297 struct acpi_table_lapic_nmi *lapic_nmi = NULL;
298
Len Brown4be44fc2005-08-05 00:44:28 -0400299 lapic_nmi = (struct acpi_table_lapic_nmi *)header;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300
301 if (BAD_MADT_ENTRY(lapic_nmi, end))
302 return -EINVAL;
303
304 acpi_table_print_madt_entry(header);
305
306 if (lapic_nmi->lint != 1)
307 printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n");
308
309 return 0;
310}
311
Len Brown4be44fc2005-08-05 00:44:28 -0400312#endif /*CONFIG_X86_LOCAL_APIC */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313
Len Brown84663612005-08-24 12:09:07 -0400314#ifdef CONFIG_X86_IO_APIC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315
316static int __init
Len Brown4be44fc2005-08-05 00:44:28 -0400317acpi_parse_ioapic(acpi_table_entry_header * header, const unsigned long end)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318{
319 struct acpi_table_ioapic *ioapic = NULL;
320
Len Brown4be44fc2005-08-05 00:44:28 -0400321 ioapic = (struct acpi_table_ioapic *)header;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322
323 if (BAD_MADT_ENTRY(ioapic, end))
324 return -EINVAL;
Len Brown4be44fc2005-08-05 00:44:28 -0400325
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326 acpi_table_print_madt_entry(header);
327
Len Brown4be44fc2005-08-05 00:44:28 -0400328 mp_register_ioapic(ioapic->id,
329 ioapic->address, ioapic->global_irq_base);
330
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331 return 0;
332}
333
334/*
335 * Parse Interrupt Source Override for the ACPI SCI
336 */
Len Brown4be44fc2005-08-05 00:44:28 -0400337static void acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338{
339 if (trigger == 0) /* compatible SCI trigger is level */
340 trigger = 3;
341
342 if (polarity == 0) /* compatible SCI polarity is low */
343 polarity = 3;
344
345 /* Command-line over-ride via acpi_sci= */
346 if (acpi_sci_flags.trigger)
347 trigger = acpi_sci_flags.trigger;
348
349 if (acpi_sci_flags.polarity)
350 polarity = acpi_sci_flags.polarity;
351
352 /*
Len Brown4be44fc2005-08-05 00:44:28 -0400353 * mp_config_acpi_legacy_irqs() already setup IRQs < 16
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354 * If GSI is < 16, this will update its flags,
355 * else it will create a new mp_irqs[] entry.
356 */
357 mp_override_legacy_irq(gsi, polarity, trigger, gsi);
358
359 /*
360 * stash over-ride to indicate we've been here
361 * and for later update of acpi_fadt
362 */
363 acpi_sci_override_gsi = gsi;
364 return;
365}
366
367static int __init
Len Brown4be44fc2005-08-05 00:44:28 -0400368acpi_parse_int_src_ovr(acpi_table_entry_header * header,
369 const unsigned long end)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370{
371 struct acpi_table_int_src_ovr *intsrc = NULL;
372
Len Brown4be44fc2005-08-05 00:44:28 -0400373 intsrc = (struct acpi_table_int_src_ovr *)header;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374
375 if (BAD_MADT_ENTRY(intsrc, end))
376 return -EINVAL;
377
378 acpi_table_print_madt_entry(header);
379
380 if (intsrc->bus_irq == acpi_fadt.sci_int) {
381 acpi_sci_ioapic_setup(intsrc->global_irq,
Len Brown4be44fc2005-08-05 00:44:28 -0400382 intsrc->flags.polarity,
383 intsrc->flags.trigger);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384 return 0;
385 }
386
387 if (acpi_skip_timer_override &&
Len Brown4be44fc2005-08-05 00:44:28 -0400388 intsrc->bus_irq == 0 && intsrc->global_irq == 2) {
389 printk(PREFIX "BIOS IRQ0 pin2 override ignored.\n");
390 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391 }
392
Len Brown4be44fc2005-08-05 00:44:28 -0400393 mp_override_legacy_irq(intsrc->bus_irq,
394 intsrc->flags.polarity,
395 intsrc->flags.trigger, intsrc->global_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396
397 return 0;
398}
399
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400static int __init
Len Brown4be44fc2005-08-05 00:44:28 -0400401acpi_parse_nmi_src(acpi_table_entry_header * header, const unsigned long end)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402{
403 struct acpi_table_nmi_src *nmi_src = NULL;
404
Len Brown4be44fc2005-08-05 00:44:28 -0400405 nmi_src = (struct acpi_table_nmi_src *)header;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406
407 if (BAD_MADT_ENTRY(nmi_src, end))
408 return -EINVAL;
409
410 acpi_table_print_madt_entry(header);
411
412 /* TBD: Support nimsrc entries? */
413
414 return 0;
415}
416
Len Brown4be44fc2005-08-05 00:44:28 -0400417#endif /* CONFIG_X86_IO_APIC */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419/*
420 * acpi_pic_sci_set_trigger()
421 *
422 * use ELCR to set PIC-mode trigger type for SCI
423 *
424 * If a PIC-mode SCI is not recognized or gives spurious IRQ7's
425 * it may require Edge Trigger -- use "acpi_sci=edge"
426 *
427 * Port 0x4d0-4d1 are ECLR1 and ECLR2, the Edge/Level Control Registers
428 * for the 8259 PIC. bit[n] = 1 means irq[n] is Level, otherwise Edge.
429 * ECLR1 is IRQ's 0-7 (IRQ 0, 1, 2 must be 0)
430 * ECLR2 is IRQ's 8-15 (IRQ 8, 13 must be 0)
431 */
432
Len Brown4be44fc2005-08-05 00:44:28 -0400433void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434{
435 unsigned int mask = 1 << irq;
436 unsigned int old, new;
437
438 /* Real old ELCR mask */
439 old = inb(0x4d0) | (inb(0x4d1) << 8);
440
441 /*
442 * If we use ACPI to set PCI irq's, then we should clear ELCR
443 * since we will set it correctly as we enable the PCI irq
444 * routing.
445 */
446 new = acpi_noirq ? old : 0;
447
448 /*
449 * Update SCI information in the ELCR, it isn't in the PCI
450 * routing tables..
451 */
452 switch (trigger) {
Len Brown4be44fc2005-08-05 00:44:28 -0400453 case 1: /* Edge - clear */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454 new &= ~mask;
455 break;
Len Brown4be44fc2005-08-05 00:44:28 -0400456 case 3: /* Level - set */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457 new |= mask;
458 break;
459 }
460
461 if (old == new)
462 return;
463
464 printk(PREFIX "setting ELCR to %04x (from %04x)\n", new, old);
465 outb(new, 0x4d0);
466 outb(new >> 8, 0x4d1);
467}
468
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
470{
471#ifdef CONFIG_X86_IO_APIC
472 if (use_pci_vector() && !platform_legacy_irq(gsi))
Len Brown4be44fc2005-08-05 00:44:28 -0400473 *irq = IO_APIC_VECTOR(gsi);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 else
475#endif
James Cleverdon6004e1b2005-11-05 17:25:53 +0100476 *irq = gsi_irq_sharing(gsi);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 return 0;
478}
479
Kenji Kaneshige1f3a6a12005-07-28 14:42:00 -0400480/*
481 * success: return IRQ number (>=0)
482 * failure: return < 0
483 */
Len Browncb654692005-12-28 02:43:51 -0500484int acpi_register_gsi(u32 gsi, int triggering, int polarity)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485{
486 unsigned int irq;
487 unsigned int plat_gsi = gsi;
488
489#ifdef CONFIG_PCI
490 /*
491 * Make sure all (legacy) PCI IRQs are set as level-triggered.
492 */
493 if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
494 extern void eisa_set_level_irq(unsigned int irq);
495
Len Browncb654692005-12-28 02:43:51 -0500496 if (triggering == ACPI_LEVEL_SENSITIVE)
Len Brown4be44fc2005-08-05 00:44:28 -0400497 eisa_set_level_irq(gsi);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498 }
499#endif
500
501#ifdef CONFIG_X86_IO_APIC
502 if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) {
Len Browncb654692005-12-28 02:43:51 -0500503 plat_gsi = mp_register_gsi(gsi, triggering, polarity);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504 }
505#endif
506 acpi_gsi_to_irq(plat_gsi, &irq);
507 return irq;
508}
Len Brown4be44fc2005-08-05 00:44:28 -0400509
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510EXPORT_SYMBOL(acpi_register_gsi);
511
512/*
513 * ACPI based hotplug support for CPU
514 */
515#ifdef CONFIG_ACPI_HOTPLUG_CPU
Len Brown4be44fc2005-08-05 00:44:28 -0400516int acpi_map_lsapic(acpi_handle handle, int *pcpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700517{
518 /* TBD */
519 return -EINVAL;
520}
Len Brown4be44fc2005-08-05 00:44:28 -0400521
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522EXPORT_SYMBOL(acpi_map_lsapic);
523
Len Brown4be44fc2005-08-05 00:44:28 -0400524int acpi_unmap_lsapic(int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525{
526 /* TBD */
527 return -EINVAL;
528}
Len Brown4be44fc2005-08-05 00:44:28 -0400529
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530EXPORT_SYMBOL(acpi_unmap_lsapic);
Len Brown4be44fc2005-08-05 00:44:28 -0400531#endif /* CONFIG_ACPI_HOTPLUG_CPU */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532
Len Brown4be44fc2005-08-05 00:44:28 -0400533int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
Kenji Kaneshigeb1bb2482005-04-28 00:25:58 -0700534{
535 /* TBD */
536 return -EINVAL;
537}
Len Brown4be44fc2005-08-05 00:44:28 -0400538
Kenji Kaneshigeb1bb2482005-04-28 00:25:58 -0700539EXPORT_SYMBOL(acpi_register_ioapic);
540
Len Brown4be44fc2005-08-05 00:44:28 -0400541int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
Kenji Kaneshigeb1bb2482005-04-28 00:25:58 -0700542{
543 /* TBD */
544 return -EINVAL;
545}
Len Brown4be44fc2005-08-05 00:44:28 -0400546
Kenji Kaneshigeb1bb2482005-04-28 00:25:58 -0700547EXPORT_SYMBOL(acpi_unregister_ioapic);
548
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549static unsigned long __init
Len Brown4be44fc2005-08-05 00:44:28 -0400550acpi_scan_rsdp(unsigned long start, unsigned long length)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551{
Len Brown4be44fc2005-08-05 00:44:28 -0400552 unsigned long offset = 0;
553 unsigned long sig_len = sizeof("RSD PTR ") - 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700554
555 /*
556 * Scan all 16-byte boundaries of the physical memory region for the
557 * RSDP signature.
558 */
559 for (offset = 0; offset < length; offset += 16) {
Siddha, Suresh Bf6c2e332005-11-05 17:25:53 +0100560 if (strncmp((char *)(phys_to_virt(start) + offset), "RSD PTR ", sig_len))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561 continue;
562 return (start + offset);
563 }
564
565 return 0;
566}
567
568static int __init acpi_parse_sbf(unsigned long phys_addr, unsigned long size)
569{
570 struct acpi_table_sbf *sb;
571
572 if (!phys_addr || !size)
Len Brown4be44fc2005-08-05 00:44:28 -0400573 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574
Len Brown4be44fc2005-08-05 00:44:28 -0400575 sb = (struct acpi_table_sbf *)__acpi_map_table(phys_addr, size);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576 if (!sb) {
577 printk(KERN_WARNING PREFIX "Unable to map SBF\n");
578 return -ENODEV;
579 }
580
Len Brown4be44fc2005-08-05 00:44:28 -0400581 sbf_port = sb->sbf_cmos; /* Save CMOS port */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582
583 return 0;
584}
585
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586#ifdef CONFIG_HPET_TIMER
587
588static int __init acpi_parse_hpet(unsigned long phys, unsigned long size)
589{
590 struct acpi_table_hpet *hpet_tbl;
591
592 if (!phys || !size)
593 return -EINVAL;
594
Len Brown4be44fc2005-08-05 00:44:28 -0400595 hpet_tbl = (struct acpi_table_hpet *)__acpi_map_table(phys, size);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596 if (!hpet_tbl) {
597 printk(KERN_WARNING PREFIX "Unable to map HPET\n");
598 return -ENODEV;
599 }
600
601 if (hpet_tbl->addr.space_id != ACPI_SPACE_MEM) {
602 printk(KERN_WARNING PREFIX "HPET timers must be located in "
603 "memory.\n");
604 return -1;
605 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700606#ifdef CONFIG_X86_64
Len Brown4be44fc2005-08-05 00:44:28 -0400607 vxtime.hpet_address = hpet_tbl->addr.addrl |
608 ((long)hpet_tbl->addr.addrh << 32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700609
Len Brown4be44fc2005-08-05 00:44:28 -0400610 printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
611 hpet_tbl->id, vxtime.hpet_address);
612#else /* X86 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613 {
614 extern unsigned long hpet_address;
615
616 hpet_address = hpet_tbl->addr.addrl;
617 printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
Len Brown4be44fc2005-08-05 00:44:28 -0400618 hpet_tbl->id, hpet_address);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619 }
Len Brown4be44fc2005-08-05 00:44:28 -0400620#endif /* X86 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621
622 return 0;
623}
624#else
625#define acpi_parse_hpet NULL
626#endif
627
628#ifdef CONFIG_X86_PM_TIMER
629extern u32 pmtmr_ioport;
630#endif
631
632static int __init acpi_parse_fadt(unsigned long phys, unsigned long size)
633{
Bob Moore793c2382006-03-31 00:00:00 -0500634 struct fadt_descriptor *fadt = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635
Bob Moore793c2382006-03-31 00:00:00 -0500636 fadt = (struct fadt_descriptor *)__acpi_map_table(phys, size);
Len Brown4be44fc2005-08-05 00:44:28 -0400637 if (!fadt) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638 printk(KERN_WARNING PREFIX "Unable to map FADT\n");
639 return 0;
640 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641 /* initialize sci_int early for INT_SRC_OVR MADT parsing */
642 acpi_fadt.sci_int = fadt->sci_int;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643
Jason Davis90660ec2005-04-16 15:24:53 -0700644 /* initialize rev and apic_phys_dest_mode for x86_64 genapic */
645 acpi_fadt.revision = fadt->revision;
Len Brown4be44fc2005-08-05 00:44:28 -0400646 acpi_fadt.force_apic_physical_destination_mode =
647 fadt->force_apic_physical_destination_mode;
Jason Davis90660ec2005-04-16 15:24:53 -0700648
Linus Torvalds1da177e2005-04-16 15:20:36 -0700649#ifdef CONFIG_X86_PM_TIMER
650 /* detect the location of the ACPI PM Timer */
651 if (fadt->revision >= FADT2_REVISION_ID) {
652 /* FADT rev. 2 */
Len Brown4be44fc2005-08-05 00:44:28 -0400653 if (fadt->xpm_tmr_blk.address_space_id !=
654 ACPI_ADR_SPACE_SYSTEM_IO)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655 return 0;
656
657 pmtmr_ioport = fadt->xpm_tmr_blk.address;
David Shaohua Lie6e87b42005-09-21 01:35:00 -0400658 /*
659 * "X" fields are optional extensions to the original V1.0
660 * fields, so we must selectively expand V1.0 fields if the
661 * corresponding X field is zero.
662 */
663 if (!pmtmr_ioport)
664 pmtmr_ioport = fadt->V1_pm_tmr_blk;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665 } else {
666 /* FADT rev. 1 */
667 pmtmr_ioport = fadt->V1_pm_tmr_blk;
668 }
669 if (pmtmr_ioport)
Len Brown4be44fc2005-08-05 00:44:28 -0400670 printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n",
671 pmtmr_ioport);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672#endif
673 return 0;
674}
675
Len Brown4be44fc2005-08-05 00:44:28 -0400676unsigned long __init acpi_find_rsdp(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700677{
Len Brown4be44fc2005-08-05 00:44:28 -0400678 unsigned long rsdp_phys = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679
680 if (efi_enabled) {
Bjorn Helgaasb2c99e32006-03-26 01:37:08 -0800681 if (efi.acpi20 != EFI_INVALID_TABLE_ADDR)
682 return efi.acpi20;
683 else if (efi.acpi != EFI_INVALID_TABLE_ADDR)
684 return efi.acpi;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700685 }
686 /*
687 * Scan memory looking for the RSDP signature. First search EBDA (low
688 * memory) paragraphs and then search upper memory (E0000-FFFFF).
689 */
Len Brown4be44fc2005-08-05 00:44:28 -0400690 rsdp_phys = acpi_scan_rsdp(0, 0x400);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700691 if (!rsdp_phys)
Len Brown4be44fc2005-08-05 00:44:28 -0400692 rsdp_phys = acpi_scan_rsdp(0xE0000, 0x20000);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700693
694 return rsdp_phys;
695}
696
697#ifdef CONFIG_X86_LOCAL_APIC
698/*
699 * Parse LAPIC entries in MADT
700 * returns 0 on success, < 0 on error
701 */
Len Brown4be44fc2005-08-05 00:44:28 -0400702static int __init acpi_parse_madt_lapic_entries(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700703{
704 int count;
705
Andi Kleen0fcd2702006-04-11 12:54:36 +0200706 if (!cpu_has_apic)
707 return -ENODEV;
708
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709 /*
710 * Note that the LAPIC address is obtained from the MADT (32-bit value)
711 * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value).
712 */
713
Len Brown4be44fc2005-08-05 00:44:28 -0400714 count =
715 acpi_table_parse_madt(ACPI_MADT_LAPIC_ADDR_OVR,
716 acpi_parse_lapic_addr_ovr, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700717 if (count < 0) {
Len Brown4be44fc2005-08-05 00:44:28 -0400718 printk(KERN_ERR PREFIX
719 "Error parsing LAPIC address override entry\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700720 return count;
721 }
722
723 mp_register_lapic_address(acpi_lapic_addr);
724
725 count = acpi_table_parse_madt(ACPI_MADT_LAPIC, acpi_parse_lapic,
Len Brown4be44fc2005-08-05 00:44:28 -0400726 MAX_APICS);
727 if (!count) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700728 printk(KERN_ERR PREFIX "No LAPIC entries present\n");
729 /* TBD: Cleanup to allow fallback to MPS */
730 return -ENODEV;
Len Brown4be44fc2005-08-05 00:44:28 -0400731 } else if (count < 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732 printk(KERN_ERR PREFIX "Error parsing LAPIC entry\n");
733 /* TBD: Cleanup to allow fallback to MPS */
734 return count;
735 }
736
Len Brown4be44fc2005-08-05 00:44:28 -0400737 count =
738 acpi_table_parse_madt(ACPI_MADT_LAPIC_NMI, acpi_parse_lapic_nmi, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739 if (count < 0) {
740 printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");
741 /* TBD: Cleanup to allow fallback to MPS */
742 return count;
743 }
744 return 0;
745}
Len Brown4be44fc2005-08-05 00:44:28 -0400746#endif /* CONFIG_X86_LOCAL_APIC */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747
Len Brown84663612005-08-24 12:09:07 -0400748#ifdef CONFIG_X86_IO_APIC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749/*
750 * Parse IOAPIC related entries in MADT
751 * returns 0 on success, < 0 on error
752 */
Len Brown4be44fc2005-08-05 00:44:28 -0400753static int __init acpi_parse_madt_ioapic_entries(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700754{
755 int count;
756
757 /*
758 * ACPI interpreter is required to complete interrupt setup,
759 * so if it is off, don't enumerate the io-apics with ACPI.
760 * If MPS is present, it will handle them,
761 * otherwise the system will stay in PIC mode
762 */
763 if (acpi_disabled || acpi_noirq) {
764 return -ENODEV;
Len Brown4be44fc2005-08-05 00:44:28 -0400765 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700766
Andi Kleen9cfda2c2006-03-27 02:24:32 -0500767 if (!cpu_has_apic)
Andi Kleend3b6a342006-04-07 19:49:39 +0200768 return -ENODEV;
769
Linus Torvalds1da177e2005-04-16 15:20:36 -0700770 /*
Len Brown4be44fc2005-08-05 00:44:28 -0400771 * if "noapic" boot option, don't look for IO-APICs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700772 */
773 if (skip_ioapic_setup) {
774 printk(KERN_INFO PREFIX "Skipping IOAPIC probe "
Len Brown4be44fc2005-08-05 00:44:28 -0400775 "due to 'noapic' option.\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700776 return -ENODEV;
777 }
778
Len Brown4be44fc2005-08-05 00:44:28 -0400779 count =
780 acpi_table_parse_madt(ACPI_MADT_IOAPIC, acpi_parse_ioapic,
781 MAX_IO_APICS);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700782 if (!count) {
783 printk(KERN_ERR PREFIX "No IOAPIC entries present\n");
784 return -ENODEV;
Len Brown4be44fc2005-08-05 00:44:28 -0400785 } else if (count < 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700786 printk(KERN_ERR PREFIX "Error parsing IOAPIC entry\n");
787 return count;
788 }
789
Len Brown4be44fc2005-08-05 00:44:28 -0400790 count =
791 acpi_table_parse_madt(ACPI_MADT_INT_SRC_OVR, acpi_parse_int_src_ovr,
792 NR_IRQ_VECTORS);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700793 if (count < 0) {
Len Brown4be44fc2005-08-05 00:44:28 -0400794 printk(KERN_ERR PREFIX
795 "Error parsing interrupt source overrides entry\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700796 /* TBD: Cleanup to allow fallback to MPS */
797 return count;
798 }
799
800 /*
801 * If BIOS did not supply an INT_SRC_OVR for the SCI
802 * pretend we got one so we can set the SCI flags.
803 */
804 if (!acpi_sci_override_gsi)
805 acpi_sci_ioapic_setup(acpi_fadt.sci_int, 0, 0);
806
807 /* Fill in identity legacy mapings where no override */
808 mp_config_acpi_legacy_irqs();
809
Len Brown4be44fc2005-08-05 00:44:28 -0400810 count =
811 acpi_table_parse_madt(ACPI_MADT_NMI_SRC, acpi_parse_nmi_src,
812 NR_IRQ_VECTORS);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700813 if (count < 0) {
814 printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n");
815 /* TBD: Cleanup to allow fallback to MPS */
816 return count;
817 }
818
819 return 0;
820}
821#else
822static inline int acpi_parse_madt_ioapic_entries(void)
823{
824 return -1;
825}
Len Brown84663612005-08-24 12:09:07 -0400826#endif /* !CONFIG_X86_IO_APIC */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700827
Len Brown4be44fc2005-08-05 00:44:28 -0400828static void __init acpi_process_madt(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700829{
830#ifdef CONFIG_X86_LOCAL_APIC
831 int count, error;
832
833 count = acpi_table_parse(ACPI_APIC, acpi_parse_madt);
834 if (count >= 1) {
835
836 /*
837 * Parse MADT LAPIC entries
838 */
839 error = acpi_parse_madt_lapic_entries();
840 if (!error) {
841 acpi_lapic = 1;
842
Venkatesh Pallipadi911a62d2005-09-03 15:56:31 -0700843#ifdef CONFIG_X86_GENERICARCH
844 generic_bigsmp_probe();
845#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700846 /*
847 * Parse MADT IO-APIC entries
848 */
849 error = acpi_parse_madt_ioapic_entries();
850 if (!error) {
851 acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC;
852 acpi_irq_balance_set(NULL);
853 acpi_ioapic = 1;
854
855 smp_found_config = 1;
856 clustered_apic_check();
857 }
858 }
859 if (error == -EINVAL) {
860 /*
861 * Dell Precision Workstation 410, 610 come here.
862 */
Len Brown4be44fc2005-08-05 00:44:28 -0400863 printk(KERN_ERR PREFIX
864 "Invalid BIOS MADT, disabling ACPI\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700865 disable_acpi();
866 }
867 }
868#endif
869 return;
870}
871
Andrey Paninaea00142005-06-25 14:54:42 -0700872#ifdef __i386__
873
Andrey Paninaea00142005-06-25 14:54:42 -0700874static int __init disable_acpi_irq(struct dmi_system_id *d)
875{
876 if (!acpi_force) {
877 printk(KERN_NOTICE "%s detected: force use of acpi=noirq\n",
878 d->ident);
879 acpi_noirq_set();
880 }
881 return 0;
882}
883
884static int __init disable_acpi_pci(struct dmi_system_id *d)
885{
886 if (!acpi_force) {
887 printk(KERN_NOTICE "%s detected: force use of pci=noacpi\n",
888 d->ident);
889 acpi_disable_pci();
890 }
891 return 0;
892}
Andrey Paninaea00142005-06-25 14:54:42 -0700893
894static int __init dmi_disable_acpi(struct dmi_system_id *d)
895{
896 if (!acpi_force) {
Len Brown4be44fc2005-08-05 00:44:28 -0400897 printk(KERN_NOTICE "%s detected: acpi off\n", d->ident);
Andrey Paninaea00142005-06-25 14:54:42 -0700898 disable_acpi();
899 } else {
900 printk(KERN_NOTICE
901 "Warning: DMI blacklist says broken, but acpi forced\n");
902 }
903 return 0;
904}
905
906/*
907 * Limit ACPI to CPU enumeration for HT
908 */
909static int __init force_acpi_ht(struct dmi_system_id *d)
910{
911 if (!acpi_force) {
Len Brown4be44fc2005-08-05 00:44:28 -0400912 printk(KERN_NOTICE "%s detected: force use of acpi=ht\n",
913 d->ident);
Andrey Paninaea00142005-06-25 14:54:42 -0700914 disable_acpi();
915 acpi_ht = 1;
916 } else {
917 printk(KERN_NOTICE
918 "Warning: acpi=force overrules DMI blacklist: acpi=ht\n");
919 }
920 return 0;
921}
922
923/*
924 * If your system is blacklisted here, but you find that acpi=force
925 * works for you, please contact acpi-devel@sourceforge.net
926 */
927static struct dmi_system_id __initdata acpi_dmi_table[] = {
928 /*
929 * Boxes that need ACPI disabled
930 */
931 {
Len Brown4be44fc2005-08-05 00:44:28 -0400932 .callback = dmi_disable_acpi,
933 .ident = "IBM Thinkpad",
934 .matches = {
935 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
936 DMI_MATCH(DMI_BOARD_NAME, "2629H1G"),
937 },
938 },
Andrey Paninaea00142005-06-25 14:54:42 -0700939
940 /*
941 * Boxes that need acpi=ht
942 */
943 {
Len Brown4be44fc2005-08-05 00:44:28 -0400944 .callback = force_acpi_ht,
945 .ident = "FSC Primergy T850",
946 .matches = {
947 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
948 DMI_MATCH(DMI_PRODUCT_NAME, "PRIMERGY T850"),
949 },
950 },
Andrey Paninaea00142005-06-25 14:54:42 -0700951 {
Len Brown4be44fc2005-08-05 00:44:28 -0400952 .callback = force_acpi_ht,
953 .ident = "DELL GX240",
954 .matches = {
955 DMI_MATCH(DMI_BOARD_VENDOR, "Dell Computer Corporation"),
956 DMI_MATCH(DMI_BOARD_NAME, "OptiPlex GX240"),
957 },
958 },
Andrey Paninaea00142005-06-25 14:54:42 -0700959 {
Len Brown4be44fc2005-08-05 00:44:28 -0400960 .callback = force_acpi_ht,
961 .ident = "HP VISUALIZE NT Workstation",
962 .matches = {
963 DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
964 DMI_MATCH(DMI_PRODUCT_NAME, "HP VISUALIZE NT Workstation"),
965 },
966 },
Andrey Paninaea00142005-06-25 14:54:42 -0700967 {
Len Brown4be44fc2005-08-05 00:44:28 -0400968 .callback = force_acpi_ht,
969 .ident = "Compaq Workstation W8000",
970 .matches = {
971 DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
972 DMI_MATCH(DMI_PRODUCT_NAME, "Workstation W8000"),
973 },
974 },
Andrey Paninaea00142005-06-25 14:54:42 -0700975 {
Len Brown4be44fc2005-08-05 00:44:28 -0400976 .callback = force_acpi_ht,
977 .ident = "ASUS P4B266",
978 .matches = {
979 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
980 DMI_MATCH(DMI_BOARD_NAME, "P4B266"),
981 },
982 },
Andrey Paninaea00142005-06-25 14:54:42 -0700983 {
Len Brown4be44fc2005-08-05 00:44:28 -0400984 .callback = force_acpi_ht,
985 .ident = "ASUS P2B-DS",
986 .matches = {
987 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
988 DMI_MATCH(DMI_BOARD_NAME, "P2B-DS"),
989 },
990 },
Andrey Paninaea00142005-06-25 14:54:42 -0700991 {
Len Brown4be44fc2005-08-05 00:44:28 -0400992 .callback = force_acpi_ht,
993 .ident = "ASUS CUR-DLS",
994 .matches = {
995 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
996 DMI_MATCH(DMI_BOARD_NAME, "CUR-DLS"),
997 },
998 },
Andrey Paninaea00142005-06-25 14:54:42 -0700999 {
Len Brown4be44fc2005-08-05 00:44:28 -04001000 .callback = force_acpi_ht,
1001 .ident = "ABIT i440BX-W83977",
1002 .matches = {
1003 DMI_MATCH(DMI_BOARD_VENDOR, "ABIT <http://www.abit.com>"),
1004 DMI_MATCH(DMI_BOARD_NAME, "i440BX-W83977 (BP6)"),
1005 },
1006 },
Andrey Paninaea00142005-06-25 14:54:42 -07001007 {
Len Brown4be44fc2005-08-05 00:44:28 -04001008 .callback = force_acpi_ht,
1009 .ident = "IBM Bladecenter",
1010 .matches = {
1011 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1012 DMI_MATCH(DMI_BOARD_NAME, "IBM eServer BladeCenter HS20"),
1013 },
1014 },
Andrey Paninaea00142005-06-25 14:54:42 -07001015 {
Len Brown4be44fc2005-08-05 00:44:28 -04001016 .callback = force_acpi_ht,
1017 .ident = "IBM eServer xSeries 360",
1018 .matches = {
1019 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1020 DMI_MATCH(DMI_BOARD_NAME, "eServer xSeries 360"),
1021 },
1022 },
Andrey Paninaea00142005-06-25 14:54:42 -07001023 {
Len Brown4be44fc2005-08-05 00:44:28 -04001024 .callback = force_acpi_ht,
1025 .ident = "IBM eserver xSeries 330",
1026 .matches = {
1027 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1028 DMI_MATCH(DMI_BOARD_NAME, "eserver xSeries 330"),
1029 },
1030 },
Andrey Paninaea00142005-06-25 14:54:42 -07001031 {
Len Brown4be44fc2005-08-05 00:44:28 -04001032 .callback = force_acpi_ht,
1033 .ident = "IBM eserver xSeries 440",
1034 .matches = {
1035 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1036 DMI_MATCH(DMI_PRODUCT_NAME, "eserver xSeries 440"),
1037 },
1038 },
Andrey Paninaea00142005-06-25 14:54:42 -07001039
Andrey Paninaea00142005-06-25 14:54:42 -07001040 /*
1041 * Boxes that need ACPI PCI IRQ routing disabled
1042 */
1043 {
Len Brown4be44fc2005-08-05 00:44:28 -04001044 .callback = disable_acpi_irq,
1045 .ident = "ASUS A7V",
1046 .matches = {
1047 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC"),
1048 DMI_MATCH(DMI_BOARD_NAME, "<A7V>"),
1049 /* newer BIOS, Revision 1011, does work */
1050 DMI_MATCH(DMI_BIOS_VERSION,
1051 "ASUS A7V ACPI BIOS Revision 1007"),
1052 },
1053 },
Andrey Paninaea00142005-06-25 14:54:42 -07001054
1055 /*
1056 * Boxes that need ACPI PCI IRQ routing and PCI scan disabled
1057 */
Len Brown4be44fc2005-08-05 00:44:28 -04001058 { /* _BBN 0 bug */
1059 .callback = disable_acpi_pci,
1060 .ident = "ASUS PR-DLS",
1061 .matches = {
1062 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
1063 DMI_MATCH(DMI_BOARD_NAME, "PR-DLS"),
1064 DMI_MATCH(DMI_BIOS_VERSION,
1065 "ASUS PR-DLS ACPI BIOS Revision 1010"),
1066 DMI_MATCH(DMI_BIOS_DATE, "03/21/2003")
1067 },
1068 },
Andrey Paninaea00142005-06-25 14:54:42 -07001069 {
Len Brown4be44fc2005-08-05 00:44:28 -04001070 .callback = disable_acpi_pci,
1071 .ident = "Acer TravelMate 36x Laptop",
1072 .matches = {
1073 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
1074 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
1075 },
1076 },
Len Brown4be44fc2005-08-05 00:44:28 -04001077 {}
Andrey Paninaea00142005-06-25 14:54:42 -07001078};
1079
Len Brown4be44fc2005-08-05 00:44:28 -04001080#endif /* __i386__ */
Andrey Paninaea00142005-06-25 14:54:42 -07001081
Linus Torvalds1da177e2005-04-16 15:20:36 -07001082/*
1083 * acpi_boot_table_init() and acpi_boot_init()
1084 * called from setup_arch(), always.
1085 * 1. checksums all tables
1086 * 2. enumerates lapics
1087 * 3. enumerates io-apics
1088 *
1089 * acpi_table_init() is separate to allow reading SRAT without
1090 * other side effects.
1091 *
1092 * side effects of acpi_boot_init:
1093 * acpi_lapic = 1 if LAPIC found
1094 * acpi_ioapic = 1 if IOAPIC found
1095 * if (acpi_lapic && acpi_ioapic) smp_found_config = 1;
1096 * if acpi_blacklisted() acpi_disabled = 1;
1097 * acpi_irq_model=...
1098 * ...
1099 *
1100 * return value: (currently ignored)
1101 * 0: success
1102 * !0: failure
1103 */
1104
Len Brown4be44fc2005-08-05 00:44:28 -04001105int __init acpi_boot_table_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001106{
1107 int error;
1108
Andrey Paninaea00142005-06-25 14:54:42 -07001109#ifdef __i386__
1110 dmi_check_system(acpi_dmi_table);
1111#endif
1112
Linus Torvalds1da177e2005-04-16 15:20:36 -07001113 /*
1114 * If acpi_disabled, bail out
1115 * One exception: acpi=ht continues far enough to enumerate LAPICs
1116 */
1117 if (acpi_disabled && !acpi_ht)
Len Brown4be44fc2005-08-05 00:44:28 -04001118 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001119
1120 /*
1121 * Initialize the ACPI boot-time table parser.
1122 */
1123 error = acpi_table_init();
1124 if (error) {
1125 disable_acpi();
1126 return error;
1127 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001128
1129 acpi_table_parse(ACPI_BOOT, acpi_parse_sbf);
1130
1131 /*
1132 * blacklist may disable ACPI entirely
1133 */
1134 error = acpi_blacklisted();
1135 if (error) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001136 if (acpi_force) {
1137 printk(KERN_WARNING PREFIX "acpi=force override\n");
1138 } else {
1139 printk(KERN_WARNING PREFIX "Disabling ACPI support\n");
1140 disable_acpi();
1141 return error;
1142 }
1143 }
1144
1145 return 0;
1146}
1147
Linus Torvalds1da177e2005-04-16 15:20:36 -07001148int __init acpi_boot_init(void)
1149{
1150 /*
1151 * If acpi_disabled, bail out
1152 * One exception: acpi=ht continues far enough to enumerate LAPICs
1153 */
1154 if (acpi_disabled && !acpi_ht)
Len Brown4be44fc2005-08-05 00:44:28 -04001155 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001156
1157 acpi_table_parse(ACPI_BOOT, acpi_parse_sbf);
1158
1159 /*
1160 * set sci_int and PM timer address
1161 */
1162 acpi_table_parse(ACPI_FADT, acpi_parse_fadt);
1163
1164 /*
1165 * Process the Multiple APIC Description Table (MADT), if present
1166 */
1167 acpi_process_madt();
1168
1169 acpi_table_parse(ACPI_HPET, acpi_parse_hpet);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001170
1171 return 0;
1172}
Rusty Russell1a3f2392006-09-26 10:52:32 +02001173
1174static int __init parse_acpi(char *arg)
1175{
1176 if (!arg)
1177 return -EINVAL;
1178
1179 /* "acpi=off" disables both ACPI table parsing and interpreter */
1180 if (strcmp(arg, "off") == 0) {
1181 disable_acpi();
1182 }
1183 /* acpi=force to over-ride black-list */
1184 else if (strcmp(arg, "force") == 0) {
1185 acpi_force = 1;
1186 acpi_ht = 1;
1187 acpi_disabled = 0;
1188 }
1189 /* acpi=strict disables out-of-spec workarounds */
1190 else if (strcmp(arg, "strict") == 0) {
1191 acpi_strict = 1;
1192 }
1193 /* Limit ACPI just to boot-time to enable HT */
1194 else if (strcmp(arg, "ht") == 0) {
1195 if (!acpi_force)
1196 disable_acpi();
1197 acpi_ht = 1;
1198 }
1199 /* "acpi=noirq" disables ACPI interrupt routing */
1200 else if (strcmp(arg, "noirq") == 0) {
1201 acpi_noirq_set();
1202 } else {
1203 /* Core will printk when we return error. */
1204 return -EINVAL;
1205 }
1206 return 0;
1207}
1208early_param("acpi", parse_acpi);
1209
1210/* FIXME: Using pci= for an ACPI parameter is a travesty. */
1211static int __init parse_pci(char *arg)
1212{
1213 if (arg && strcmp(arg, "noacpi") == 0)
1214 acpi_disable_pci();
1215 return 0;
1216}
1217early_param("pci", parse_pci);
1218
1219#ifdef CONFIG_X86_IO_APIC
1220static int __init parse_acpi_skip_timer_override(char *arg)
1221{
1222 acpi_skip_timer_override = 1;
1223 return 0;
1224}
1225early_param("acpi_skip_timer_override", parse_acpi_skip_timer_override);
1226#endif /* CONFIG_X86_IO_APIC */
1227
1228static int __init setup_acpi_sci(char *s)
1229{
1230 if (!s)
1231 return -EINVAL;
1232 if (!strcmp(s, "edge"))
1233 acpi_sci_flags.trigger = 1;
1234 else if (!strcmp(s, "level"))
1235 acpi_sci_flags.trigger = 3;
1236 else if (!strcmp(s, "high"))
1237 acpi_sci_flags.polarity = 1;
1238 else if (!strcmp(s, "low"))
1239 acpi_sci_flags.polarity = 3;
1240 else
1241 return -EINVAL;
1242 return 0;
1243}
1244early_param("acpi_sci", setup_acpi_sci);