aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/early-quirks.c
diff options
context:
space:
mode:
authorAndi Kleen <ak@suse.de>2007-10-19 14:35:03 -0400
committerThomas Gleixner <tglx@linutronix.de>2007-10-19 14:35:03 -0400
commit54ef34009a69f95c25685247e73673dfeb435c71 (patch)
tree2a8e01d4bcfd24f467a1a30218005ccfe9c06a70 /arch/x86/kernel/early-quirks.c
parent158ad3260ba3b006e3c6dfad05298e9d7889c5b1 (diff)
x86: Unify i386 and x86-64 early quirks
They were already very similar; just use the same file now. [ tglx: arch/x86 adaptation ] Cc: lenb@kernel.org Signed-off-by: Andi Kleen <ak@suse.de> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/kernel/early-quirks.c')
-rw-r--r--arch/x86/kernel/early-quirks.c136
1 files changed, 136 insertions, 0 deletions
diff --git a/arch/x86/kernel/early-quirks.c b/arch/x86/kernel/early-quirks.c
new file mode 100644
index 000000000000..dc34acbd54aa
--- /dev/null
+++ b/arch/x86/kernel/early-quirks.c
@@ -0,0 +1,136 @@
1/* Various workarounds for chipset bugs.
2 This code runs very early and can't use the regular PCI subsystem
3 The entries are keyed to PCI bridges which usually identify chipsets
4 uniquely.
5 This is only for whole classes of chipsets with specific problems which
6 need early invasive action (e.g. before the timers are initialized).
7 Most PCI device specific workarounds can be done later and should be
8 in standard PCI quirks
9 Mainboard specific bugs should be handled by DMI entries.
10 CPU specific bugs in setup.c */
11
12#include <linux/pci.h>
13#include <linux/acpi.h>
14#include <linux/pci_ids.h>
15#include <asm/pci-direct.h>
16#include <asm/dma.h>
17#include <asm/io_apic.h>
18#include <asm/apic.h>
19
20#ifdef CONFIG_IOMMU
21#include <asm/iommu.h>
22#endif
23
24static void __init via_bugs(void)
25{
26#ifdef CONFIG_IOMMU
27 if ((end_pfn > MAX_DMA32_PFN || force_iommu) &&
28 !iommu_aperture_allowed) {
29 printk(KERN_INFO
30 "Looks like a VIA chipset. Disabling IOMMU."
31 " Override with iommu=allowed\n");
32 iommu_aperture_disabled = 1;
33 }
34#endif
35}
36
37#ifdef CONFIG_ACPI
38
39static int __init nvidia_hpet_check(struct acpi_table_header *header)
40{
41 return 0;
42}
43#endif
44
45static void __init nvidia_bugs(void)
46{
47#ifdef CONFIG_ACPI
48#ifdef CONFIG_X86_IO_APIC
49 /*
50 * All timer overrides on Nvidia are
51 * wrong unless HPET is enabled.
52 * Unfortunately that's not true on many Asus boards.
53 * We don't know yet how to detect this automatically, but
54 * at least allow a command line override.
55 */
56 if (acpi_use_timer_override)
57 return;
58
59 if (acpi_table_parse(ACPI_SIG_HPET, nvidia_hpet_check)) {
60 acpi_skip_timer_override = 1;
61 printk(KERN_INFO "Nvidia board "
62 "detected. Ignoring ACPI "
63 "timer override.\n");
64 printk(KERN_INFO "If you got timer trouble "
65 "try acpi_use_timer_override\n");
66 }
67#endif
68#endif
69 /* RED-PEN skip them on mptables too? */
70
71}
72
73static void __init ati_bugs(void)
74{
75#ifdef CONFIG_X86_IO_APIC
76 if (timer_over_8254 == 1) {
77 timer_over_8254 = 0;
78 printk(KERN_INFO
79 "ATI board detected. Disabling timer routing over 8254.\n");
80 }
81#endif
82}
83
84struct chipset {
85 u16 vendor;
86 void (*f)(void);
87};
88
89static struct chipset early_qrk[] __initdata = {
90 { PCI_VENDOR_ID_NVIDIA, nvidia_bugs },
91 { PCI_VENDOR_ID_VIA, via_bugs },
92 { PCI_VENDOR_ID_ATI, ati_bugs },
93 {}
94};
95
96void __init early_quirks(void)
97{
98 int num, slot, func;
99
100 if (!early_pci_allowed())
101 return;
102
103 /* Poor man's PCI discovery */
104 for (num = 0; num < 32; num++) {
105 for (slot = 0; slot < 32; slot++) {
106 for (func = 0; func < 8; func++) {
107 u32 class;
108 u32 vendor;
109 u8 type;
110 int i;
111 class = read_pci_config(num,slot,func,
112 PCI_CLASS_REVISION);
113 if (class == 0xffffffff)
114 break;
115
116 if ((class >> 16) != PCI_CLASS_BRIDGE_PCI)
117 continue;
118
119 vendor = read_pci_config(num, slot, func,
120 PCI_VENDOR_ID);
121 vendor &= 0xffff;
122
123 for (i = 0; early_qrk[i].f; i++)
124 if (early_qrk[i].vendor == vendor) {
125 early_qrk[i].f();
126 return;
127 }
128
129 type = read_pci_config_byte(num, slot, func,
130 PCI_HEADER_TYPE);
131 if (!(type & 0x80))
132 break;
133 }
134 }
135 }
136}