blob: 2b1245d8625849de6033eda814ed72b860faf232 [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.
48 */
49 nvidia_hpet_detected = 0;
50 acpi_table_parse(ACPI_HPET, nvidia_hpet_check);
51 if (nvidia_hpet_detected == 0) {
52 acpi_skip_timer_override = 1;
53 printk(KERN_INFO "Nvidia board "
54 "detected. Ignoring ACPI "
55 "timer override.\n");
56 }
57#endif
58 /* RED-PEN skip them on mptables too? */
59
60}
61
62static void ati_bugs(void)
63{
Andi Kleene70ea8c2006-10-21 18:37:03 +020064 if (timer_over_8254 == 1) {
65 timer_over_8254 = 0;
66 printk(KERN_INFO
67 "ATI board detected. Disabling timer routing over 8254.\n");
68 }
Andi Kleendfa46982006-09-26 10:52:30 +020069}
70
71struct chipset {
72 u16 vendor;
73 void (*f)(void);
74};
75
76static struct chipset early_qrk[] = {
77 { PCI_VENDOR_ID_NVIDIA, nvidia_bugs },
78 { PCI_VENDOR_ID_VIA, via_bugs },
79 { PCI_VENDOR_ID_ATI, ati_bugs },
80 {}
81};
82
83void __init early_quirks(void)
84{
85 int num, slot, func;
Andi Kleen0637a702006-09-26 10:52:41 +020086
87 if (!early_pci_allowed())
88 return;
89
Andi Kleendfa46982006-09-26 10:52:30 +020090 /* Poor man's PCI discovery */
91 for (num = 0; num < 32; num++) {
92 for (slot = 0; slot < 32; slot++) {
93 for (func = 0; func < 8; func++) {
94 u32 class;
95 u32 vendor;
96 u8 type;
97 int i;
98 class = read_pci_config(num,slot,func,
99 PCI_CLASS_REVISION);
100 if (class == 0xffffffff)
101 break;
102
103 if ((class >> 16) != PCI_CLASS_BRIDGE_PCI)
104 continue;
105
106 vendor = read_pci_config(num, slot, func,
107 PCI_VENDOR_ID);
108 vendor &= 0xffff;
109
110 for (i = 0; early_qrk[i].f; i++)
111 if (early_qrk[i].vendor == vendor) {
112 early_qrk[i].f();
113 return;
114 }
115
116 type = read_pci_config_byte(num, slot, func,
117 PCI_HEADER_TYPE);
118 if (!(type & 0x80))
119 break;
120 }
121 }
122 }
123}