Commit | Line | Data |
---|---|---|
dfa4698c AK |
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> | |
dfa4698c | 16 | #include <asm/dma.h> |
54ef3400 AK |
17 | #include <asm/io_apic.h> |
18 | #include <asm/apic.h> | |
19 | ||
966396d3 | 20 | #ifdef CONFIG_GART_IOMMU |
395624fc | 21 | #include <asm/gart.h> |
54ef3400 | 22 | #endif |
dfa4698c | 23 | |
c6b48324 NH |
24 | static void __init fix_hypertransport_config(int num, int slot, int func) |
25 | { | |
26 | u32 htcfg; | |
27 | /* | |
28 | * we found a hypertransport bus | |
29 | * make sure that we are broadcasting | |
30 | * interrupts to all cpus on the ht bus | |
31 | * if we're using extended apic ids | |
32 | */ | |
33 | htcfg = read_pci_config(num, slot, func, 0x68); | |
34 | if (htcfg & (1 << 18)) { | |
7bcbc78d NH |
35 | printk(KERN_INFO "Detected use of extended apic ids " |
36 | "on hypertransport bus\n"); | |
c6b48324 | 37 | if ((htcfg & (1 << 17)) == 0) { |
7bcbc78d NH |
38 | printk(KERN_INFO "Enabling hypertransport extended " |
39 | "apic interrupt broadcast\n"); | |
40 | printk(KERN_INFO "Note this is a bios bug, " | |
41 | "please contact your hw vendor\n"); | |
c6b48324 NH |
42 | htcfg |= (1 << 17); |
43 | write_pci_config(num, slot, func, 0x68, htcfg); | |
44 | } | |
45 | } | |
46 | ||
47 | ||
48 | } | |
49 | ||
50 | static void __init via_bugs(int num, int slot, int func) | |
dfa4698c | 51 | { |
966396d3 | 52 | #ifdef CONFIG_GART_IOMMU |
c987d12f | 53 | if ((max_pfn > MAX_DMA32_PFN || force_iommu) && |
0440d4c0 | 54 | !gart_iommu_aperture_allowed) { |
dfa4698c | 55 | printk(KERN_INFO |
54ef3400 AK |
56 | "Looks like a VIA chipset. Disabling IOMMU." |
57 | " Override with iommu=allowed\n"); | |
0440d4c0 | 58 | gart_iommu_aperture_disabled = 1; |
dfa4698c AK |
59 | } |
60 | #endif | |
61 | } | |
62 | ||
63 | #ifdef CONFIG_ACPI | |
03d0d20e | 64 | #ifdef CONFIG_X86_IO_APIC |
dfa4698c | 65 | |
15a58ed1 | 66 | static int __init nvidia_hpet_check(struct acpi_table_header *header) |
dfa4698c | 67 | { |
dfa4698c AK |
68 | return 0; |
69 | } | |
03d0d20e JG |
70 | #endif /* CONFIG_X86_IO_APIC */ |
71 | #endif /* CONFIG_ACPI */ | |
dfa4698c | 72 | |
c6b48324 | 73 | static void __init nvidia_bugs(int num, int slot, int func) |
dfa4698c AK |
74 | { |
75 | #ifdef CONFIG_ACPI | |
54ef3400 | 76 | #ifdef CONFIG_X86_IO_APIC |
dfa4698c AK |
77 | /* |
78 | * All timer overrides on Nvidia are | |
79 | * wrong unless HPET is enabled. | |
fa18f477 AK |
80 | * Unfortunately that's not true on many Asus boards. |
81 | * We don't know yet how to detect this automatically, but | |
82 | * at least allow a command line override. | |
dfa4698c | 83 | */ |
fa18f477 AK |
84 | if (acpi_use_timer_override) |
85 | return; | |
86 | ||
fe699336 | 87 | if (acpi_table_parse(ACPI_SIG_HPET, nvidia_hpet_check)) { |
dfa4698c AK |
88 | acpi_skip_timer_override = 1; |
89 | printk(KERN_INFO "Nvidia board " | |
90 | "detected. Ignoring ACPI " | |
91 | "timer override.\n"); | |
fa18f477 AK |
92 | printk(KERN_INFO "If you got timer trouble " |
93 | "try acpi_use_timer_override\n"); | |
dfa4698c | 94 | } |
54ef3400 | 95 | #endif |
dfa4698c AK |
96 | #endif |
97 | /* RED-PEN skip them on mptables too? */ | |
98 | ||
99 | } | |
100 | ||
c6b48324 NH |
101 | #define QFLAG_APPLY_ONCE 0x1 |
102 | #define QFLAG_APPLIED 0x2 | |
103 | #define QFLAG_DONE (QFLAG_APPLY_ONCE|QFLAG_APPLIED) | |
dfa4698c | 104 | struct chipset { |
c6b48324 NH |
105 | u32 vendor; |
106 | u32 device; | |
107 | u32 class; | |
108 | u32 class_mask; | |
109 | u32 flags; | |
110 | void (*f)(int num, int slot, int func); | |
dfa4698c AK |
111 | }; |
112 | ||
c993c735 | 113 | static struct chipset early_qrk[] __initdata = { |
c6b48324 NH |
114 | { PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID, |
115 | PCI_CLASS_BRIDGE_PCI, PCI_ANY_ID, QFLAG_APPLY_ONCE, nvidia_bugs }, | |
116 | { PCI_VENDOR_ID_VIA, PCI_ANY_ID, | |
117 | PCI_CLASS_BRIDGE_PCI, PCI_ANY_ID, QFLAG_APPLY_ONCE, via_bugs }, | |
c6b48324 NH |
118 | { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB, |
119 | PCI_CLASS_BRIDGE_HOST, PCI_ANY_ID, 0, fix_hypertransport_config }, | |
dfa4698c AK |
120 | {} |
121 | }; | |
122 | ||
85b74d6c | 123 | static void __init check_dev_quirk(int num, int slot, int func) |
7bcbc78d NH |
124 | { |
125 | u16 class; | |
126 | u16 vendor; | |
127 | u16 device; | |
128 | u8 type; | |
129 | int i; | |
130 | ||
131 | class = read_pci_config_16(num, slot, func, PCI_CLASS_DEVICE); | |
132 | ||
133 | if (class == 0xffff) | |
134 | return; | |
135 | ||
136 | vendor = read_pci_config_16(num, slot, func, PCI_VENDOR_ID); | |
137 | ||
138 | device = read_pci_config_16(num, slot, func, PCI_DEVICE_ID); | |
139 | ||
140 | for (i = 0; early_qrk[i].f != NULL; i++) { | |
141 | if (((early_qrk[i].vendor == PCI_ANY_ID) || | |
142 | (early_qrk[i].vendor == vendor)) && | |
143 | ((early_qrk[i].device == PCI_ANY_ID) || | |
144 | (early_qrk[i].device == device)) && | |
145 | (!((early_qrk[i].class ^ class) & | |
146 | early_qrk[i].class_mask))) { | |
147 | if ((early_qrk[i].flags & | |
148 | QFLAG_DONE) != QFLAG_DONE) | |
149 | early_qrk[i].f(num, slot, func); | |
150 | early_qrk[i].flags |= QFLAG_APPLIED; | |
151 | } | |
152 | } | |
153 | ||
154 | type = read_pci_config_byte(num, slot, func, | |
155 | PCI_HEADER_TYPE); | |
156 | if (!(type & 0x80)) | |
157 | return; | |
158 | } | |
159 | ||
dfa4698c AK |
160 | void __init early_quirks(void) |
161 | { | |
162 | int num, slot, func; | |
0637a70a AK |
163 | |
164 | if (!early_pci_allowed()) | |
165 | return; | |
166 | ||
dfa4698c | 167 | /* Poor man's PCI discovery */ |
7bcbc78d NH |
168 | for (num = 0; num < 32; num++) |
169 | for (slot = 0; slot < 32; slot++) | |
170 | for (func = 0; func < 8; func++) | |
171 | check_dev_quirk(num, slot, func); | |
dfa4698c | 172 | } |