blob: 49802f1bee9487484b066915160388d5d683234a [file] [log] [blame]
Andi Kleendfa46982006-09-26 10:52:30 +02001/* 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/proto.h>
17#include <asm/dma.h>
18
19static void via_bugs(void)
20{
21#ifdef CONFIG_IOMMU
22 if ((end_pfn > MAX_DMA32_PFN || force_iommu) &&
23 !iommu_aperture_allowed) {
24 printk(KERN_INFO
25 "Looks like a VIA chipset. Disabling IOMMU. Override with iommu=allowed\n");
26 iommu_aperture_disabled = 1;
27 }
28#endif
29}
30
31#ifdef CONFIG_ACPI
32
33static int nvidia_hpet_detected __initdata;
34
35static int __init nvidia_hpet_check(unsigned long phys, unsigned long size)
36{
37 nvidia_hpet_detected = 1;
38 return 0;
39}
40#endif
41
42static void nvidia_bugs(void)
43{
44#ifdef CONFIG_ACPI
45 /*
46 * All timer overrides on Nvidia are
47 * wrong unless HPET is enabled.
Andi Kleenfa18f472006-11-14 16:57:46 +010048 * Unfortunately that's not true on many Asus boards.
49 * We don't know yet how to detect this automatically, but
50 * at least allow a command line override.
Andi Kleendfa46982006-09-26 10:52:30 +020051 */
Andi Kleenfa18f472006-11-14 16:57:46 +010052 if (acpi_use_timer_override)
53 return;
54
Andi Kleendfa46982006-09-26 10:52:30 +020055 nvidia_hpet_detected = 0;
56 acpi_table_parse(ACPI_HPET, nvidia_hpet_check);
57 if (nvidia_hpet_detected == 0) {
58 acpi_skip_timer_override = 1;
59 printk(KERN_INFO "Nvidia board "
60 "detected. Ignoring ACPI "
61 "timer override.\n");
Andi Kleenfa18f472006-11-14 16:57:46 +010062 printk(KERN_INFO "If you got timer trouble "
63 "try acpi_use_timer_override\n");
Andi Kleendfa46982006-09-26 10:52:30 +020064 }
65#endif
66 /* RED-PEN skip them on mptables too? */
67
68}
69
70static void ati_bugs(void)
71{
Linus Torvaldsfea5f1e2007-01-08 15:04:46 -080072 if (timer_over_8254 == 1) {
73 timer_over_8254 = 0;
74 printk(KERN_INFO
75 "ATI board detected. Disabling timer routing over 8254.\n");
76 }
Andi Kleendfa46982006-09-26 10:52:30 +020077}
78
Siddha, Suresh Bb0d0a4b2006-12-07 02:14:10 +010079static void intel_bugs(void)
80{
81 u16 device = read_pci_config_16(0, 0, 0, PCI_DEVICE_ID);
82
83#ifdef CONFIG_SMP
84 if (device == PCI_DEVICE_ID_INTEL_E7320_MCH ||
85 device == PCI_DEVICE_ID_INTEL_E7520_MCH ||
86 device == PCI_DEVICE_ID_INTEL_E7525_MCH)
87 quirk_intel_irqbalance();
88#endif
89}
90
Andi Kleendfa46982006-09-26 10:52:30 +020091struct chipset {
92 u16 vendor;
93 void (*f)(void);
94};
95
96static struct chipset early_qrk[] = {
97 { PCI_VENDOR_ID_NVIDIA, nvidia_bugs },
98 { PCI_VENDOR_ID_VIA, via_bugs },
99 { PCI_VENDOR_ID_ATI, ati_bugs },
Siddha, Suresh Bb0d0a4b2006-12-07 02:14:10 +0100100 { PCI_VENDOR_ID_INTEL, intel_bugs},
Andi Kleendfa46982006-09-26 10:52:30 +0200101 {}
102};
103
104void __init early_quirks(void)
105{
106 int num, slot, func;
Andi Kleen0637a702006-09-26 10:52:41 +0200107
108 if (!early_pci_allowed())
109 return;
110
Andi Kleendfa46982006-09-26 10:52:30 +0200111 /* Poor man's PCI discovery */
112 for (num = 0; num < 32; num++) {
113 for (slot = 0; slot < 32; slot++) {
114 for (func = 0; func < 8; func++) {
115 u32 class;
116 u32 vendor;
117 u8 type;
118 int i;
119 class = read_pci_config(num,slot,func,
120 PCI_CLASS_REVISION);
121 if (class == 0xffffffff)
122 break;
123
124 if ((class >> 16) != PCI_CLASS_BRIDGE_PCI)
125 continue;
126
127 vendor = read_pci_config(num, slot, func,
128 PCI_VENDOR_ID);
129 vendor &= 0xffff;
130
131 for (i = 0; early_qrk[i].f; i++)
132 if (early_qrk[i].vendor == vendor) {
133 early_qrk[i].f();
134 return;
135 }
136
137 type = read_pci_config_byte(num, slot, func,
138 PCI_HEADER_TYPE);
139 if (!(type & 0x80))
140 break;
141 }
142 }
143 }
144}