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