2 * This file contains work-arounds for x86 and x86_64 platform bugs.
9 #if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_SMP) && defined(CONFIG_PCI)
11 static void __devinit
quirk_intel_irqbalance(struct pci_dev
*dev
)
16 /* BIOS may enable hardware IRQ balancing for
17 * E7520/E7320/E7525(revision ID 0x9 and below)
19 * Disable SW irqbalance/affinity on those platforms.
21 pci_read_config_byte(dev
, PCI_CLASS_REVISION
, &rev
);
25 /* enable access to config space*/
26 pci_read_config_byte(dev
, 0xf4, &config
);
27 pci_write_config_byte(dev
, 0xf4, config
|0x2);
30 * read xTPR register. We may not have a pci_dev for device 8
31 * because it might be hidden until the above write.
33 pci_bus_read_config_word(dev
->bus
, PCI_DEVFN(8, 0), 0x4c, &word
);
35 if (!(word
& (1 << 13))) {
36 dev_info(&dev
->dev
, "Intel E7520/7320/7525 detected; "
37 "disabling irq balancing and affinity\n");
38 #ifdef CONFIG_IRQBALANCE
39 irqbalance_disable("");
47 /* put back the original value for config space*/
49 pci_write_config_byte(dev
, 0xf4, config
);
51 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL
, PCI_DEVICE_ID_INTEL_E7320_MCH
,
52 quirk_intel_irqbalance
);
53 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL
, PCI_DEVICE_ID_INTEL_E7525_MCH
,
54 quirk_intel_irqbalance
);
55 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL
, PCI_DEVICE_ID_INTEL_E7520_MCH
,
56 quirk_intel_irqbalance
);
59 #if defined(CONFIG_HPET_TIMER)
60 unsigned long force_hpet_address
;
63 NONE_FORCE_HPET_RESUME
,
64 OLD_ICH_FORCE_HPET_RESUME
,
65 ICH_FORCE_HPET_RESUME
,
66 VT8237_FORCE_HPET_RESUME
,
67 NVIDIA_FORCE_HPET_RESUME
,
68 } force_hpet_resume_type
;
70 static void __iomem
*rcba_base
;
72 static void ich_force_hpet_resume(void)
76 if (!force_hpet_address
)
79 if (rcba_base
== NULL
)
82 /* read the Function Disable register, dword mode only */
83 val
= readl(rcba_base
+ 0x3404);
85 /* HPET disabled in HPTC. Trying to enable */
86 writel(val
| 0x80, rcba_base
+ 0x3404);
89 val
= readl(rcba_base
+ 0x3404);
93 printk(KERN_DEBUG
"Force enabled HPET at resume\n");
98 static void ich_force_enable_hpet(struct pci_dev
*dev
)
101 u32
uninitialized_var(rcba
);
104 if (hpet_address
|| force_hpet_address
)
107 pci_read_config_dword(dev
, 0xF0, &rcba
);
110 dev_printk(KERN_DEBUG
, &dev
->dev
, "RCBA disabled; "
111 "cannot force enable HPET\n");
115 /* use bits 31:14, 16 kB aligned */
116 rcba_base
= ioremap_nocache(rcba
, 0x4000);
117 if (rcba_base
== NULL
) {
118 dev_printk(KERN_DEBUG
, &dev
->dev
, "ioremap failed; "
119 "cannot force enable HPET\n");
123 /* read the Function Disable register, dword mode only */
124 val
= readl(rcba_base
+ 0x3404);
127 /* HPET is enabled in HPTC. Just not reported by BIOS */
129 force_hpet_address
= 0xFED00000 | (val
<< 12);
130 dev_printk(KERN_DEBUG
, &dev
->dev
, "Force enabled HPET at "
131 "0x%lx\n", force_hpet_address
);
136 /* HPET disabled in HPTC. Trying to enable */
137 writel(val
| 0x80, rcba_base
+ 0x3404);
139 val
= readl(rcba_base
+ 0x3404);
144 force_hpet_address
= 0xFED00000 | (val
<< 12);
148 force_hpet_address
= 0;
150 dev_printk(KERN_DEBUG
, &dev
->dev
,
151 "Failed to force enable HPET\n");
153 force_hpet_resume_type
= ICH_FORCE_HPET_RESUME
;
154 dev_printk(KERN_DEBUG
, &dev
->dev
, "Force enabled HPET at "
155 "0x%lx\n", force_hpet_address
);
159 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL
, PCI_DEVICE_ID_INTEL_ESB2_0
,
160 ich_force_enable_hpet
);
161 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL
, PCI_DEVICE_ID_INTEL_ICH6_1
,
162 ich_force_enable_hpet
);
163 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL
, PCI_DEVICE_ID_INTEL_ICH7_0
,
164 ich_force_enable_hpet
);
165 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL
, PCI_DEVICE_ID_INTEL_ICH7_1
,
166 ich_force_enable_hpet
);
167 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL
, PCI_DEVICE_ID_INTEL_ICH7_31
,
168 ich_force_enable_hpet
);
169 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL
, PCI_DEVICE_ID_INTEL_ICH8_1
,
170 ich_force_enable_hpet
);
171 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL
, PCI_DEVICE_ID_INTEL_ICH9_7
,
172 ich_force_enable_hpet
);
175 static struct pci_dev
*cached_dev
;
177 static void old_ich_force_hpet_resume(void)
180 u32
uninitialized_var(gen_cntl
);
182 if (!force_hpet_address
|| !cached_dev
)
185 pci_read_config_dword(cached_dev
, 0xD0, &gen_cntl
);
186 gen_cntl
&= (~(0x7 << 15));
187 gen_cntl
|= (0x4 << 15);
189 pci_write_config_dword(cached_dev
, 0xD0, gen_cntl
);
190 pci_read_config_dword(cached_dev
, 0xD0, &gen_cntl
);
191 val
= gen_cntl
>> 15;
194 printk(KERN_DEBUG
"Force enabled HPET at resume\n");
199 static void old_ich_force_enable_hpet(struct pci_dev
*dev
)
202 u32
uninitialized_var(gen_cntl
);
204 if (hpet_address
|| force_hpet_address
)
207 pci_read_config_dword(dev
, 0xD0, &gen_cntl
);
209 * Bit 17 is HPET enable bit.
210 * Bit 16:15 control the HPET base address.
212 val
= gen_cntl
>> 15;
216 force_hpet_address
= 0xFED00000 | (val
<< 12);
217 dev_printk(KERN_DEBUG
, &dev
->dev
, "HPET at 0x%lx\n",
223 * HPET is disabled. Trying enabling at FED00000 and check
226 gen_cntl
&= (~(0x7 << 15));
227 gen_cntl
|= (0x4 << 15);
228 pci_write_config_dword(dev
, 0xD0, gen_cntl
);
230 pci_read_config_dword(dev
, 0xD0, &gen_cntl
);
232 val
= gen_cntl
>> 15;
235 /* HPET is enabled in HPTC. Just not reported by BIOS */
237 force_hpet_address
= 0xFED00000 | (val
<< 12);
238 dev_printk(KERN_DEBUG
, &dev
->dev
, "Force enabled HPET at "
239 "0x%lx\n", force_hpet_address
);
241 force_hpet_resume_type
= OLD_ICH_FORCE_HPET_RESUME
;
245 dev_printk(KERN_DEBUG
, &dev
->dev
, "Failed to force enable HPET\n");
249 * Undocumented chipset features. Make sure that the user enforced
252 static void old_ich_force_enable_hpet_user(struct pci_dev
*dev
)
255 old_ich_force_enable_hpet(dev
);
258 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL
, PCI_DEVICE_ID_INTEL_82801CA_0
,
259 old_ich_force_enable_hpet_user
);
260 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL
, PCI_DEVICE_ID_INTEL_82801CA_12
,
261 old_ich_force_enable_hpet_user
);
262 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL
, PCI_DEVICE_ID_INTEL_82801DB_0
,
263 old_ich_force_enable_hpet_user
);
264 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL
, PCI_DEVICE_ID_INTEL_82801DB_12
,
265 old_ich_force_enable_hpet_user
);
266 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL
, PCI_DEVICE_ID_INTEL_82801EB_0
,
267 old_ich_force_enable_hpet
);
268 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL
, PCI_DEVICE_ID_INTEL_82801EB_12
,
269 old_ich_force_enable_hpet
);
272 static void vt8237_force_hpet_resume(void)
276 if (!force_hpet_address
|| !cached_dev
)
279 val
= 0xfed00000 | 0x80;
280 pci_write_config_dword(cached_dev
, 0x68, val
);
282 pci_read_config_dword(cached_dev
, 0x68, &val
);
284 printk(KERN_DEBUG
"Force enabled HPET at resume\n");
289 static void vt8237_force_enable_hpet(struct pci_dev
*dev
)
291 u32
uninitialized_var(val
);
293 if (!hpet_force_user
|| hpet_address
|| force_hpet_address
)
296 pci_read_config_dword(dev
, 0x68, &val
);
298 * Bit 7 is HPET enable bit.
299 * Bit 31:10 is HPET base address (contrary to what datasheet claims)
302 force_hpet_address
= (val
& ~0x3ff);
303 dev_printk(KERN_DEBUG
, &dev
->dev
, "HPET at 0x%lx\n",
309 * HPET is disabled. Trying enabling at FED00000 and check
312 val
= 0xfed00000 | 0x80;
313 pci_write_config_dword(dev
, 0x68, val
);
315 pci_read_config_dword(dev
, 0x68, &val
);
317 force_hpet_address
= (val
& ~0x3ff);
318 dev_printk(KERN_DEBUG
, &dev
->dev
, "Force enabled HPET at "
319 "0x%lx\n", force_hpet_address
);
321 force_hpet_resume_type
= VT8237_FORCE_HPET_RESUME
;
325 dev_printk(KERN_DEBUG
, &dev
->dev
, "Failed to force enable HPET\n");
328 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA
, PCI_DEVICE_ID_VIA_8235
,
329 vt8237_force_enable_hpet
);
330 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA
, PCI_DEVICE_ID_VIA_8237
,
331 vt8237_force_enable_hpet
);
334 * Undocumented chipset feature taken from LinuxBIOS.
336 static void nvidia_force_hpet_resume(void)
338 pci_write_config_dword(cached_dev
, 0x44, 0xfed00001);
339 printk(KERN_DEBUG
"Force enabled HPET at resume\n");
342 static void nvidia_force_enable_hpet(struct pci_dev
*dev
)
344 u32
uninitialized_var(val
);
346 if (!hpet_force_user
|| hpet_address
|| force_hpet_address
)
349 pci_write_config_dword(dev
, 0x44, 0xfed00001);
350 pci_read_config_dword(dev
, 0x44, &val
);
351 force_hpet_address
= val
& 0xfffffffe;
352 force_hpet_resume_type
= NVIDIA_FORCE_HPET_RESUME
;
353 dev_printk(KERN_DEBUG
, &dev
->dev
, "Force enabled HPET at 0x%lx\n",
360 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA
, 0x0050,
361 nvidia_force_enable_hpet
);
362 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA
, 0x0051,
363 nvidia_force_enable_hpet
);
366 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA
, 0x0260,
367 nvidia_force_enable_hpet
);
368 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA
, 0x0360,
369 nvidia_force_enable_hpet
);
370 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA
, 0x0361,
371 nvidia_force_enable_hpet
);
372 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA
, 0x0362,
373 nvidia_force_enable_hpet
);
374 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA
, 0x0363,
375 nvidia_force_enable_hpet
);
376 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA
, 0x0364,
377 nvidia_force_enable_hpet
);
378 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA
, 0x0365,
379 nvidia_force_enable_hpet
);
380 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA
, 0x0366,
381 nvidia_force_enable_hpet
);
382 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA
, 0x0367,
383 nvidia_force_enable_hpet
);
385 void force_hpet_resume(void)
387 switch (force_hpet_resume_type
) {
388 case ICH_FORCE_HPET_RESUME
:
389 ich_force_hpet_resume();
391 case OLD_ICH_FORCE_HPET_RESUME
:
392 old_ich_force_hpet_resume();
394 case VT8237_FORCE_HPET_RESUME
:
395 vt8237_force_hpet_resume();
397 case NVIDIA_FORCE_HPET_RESUME
:
398 nvidia_force_hpet_resume();