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");
44 /* put back the original value for config space*/
46 pci_write_config_byte(dev, 0xf4, config);
48 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7320_MCH,
49 quirk_intel_irqbalance);
50 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7525_MCH,
51 quirk_intel_irqbalance);
52 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7520_MCH,
53 quirk_intel_irqbalance);
56 #if defined(CONFIG_HPET_TIMER)
57 unsigned long force_hpet_address;
60 NONE_FORCE_HPET_RESUME,
61 OLD_ICH_FORCE_HPET_RESUME,
62 ICH_FORCE_HPET_RESUME,
63 VT8237_FORCE_HPET_RESUME,
64 NVIDIA_FORCE_HPET_RESUME,
65 ATI_FORCE_HPET_RESUME,
66 } force_hpet_resume_type;
68 static void __iomem *rcba_base;
70 static void ich_force_hpet_resume(void)
74 if (!force_hpet_address)
77 if (rcba_base == NULL)
80 /* read the Function Disable register, dword mode only */
81 val = readl(rcba_base + 0x3404);
83 /* HPET disabled in HPTC. Trying to enable */
84 writel(val | 0x80, rcba_base + 0x3404);
87 val = readl(rcba_base + 0x3404);
91 printk(KERN_DEBUG "Force enabled HPET at resume\n");
96 static void ich_force_enable_hpet(struct pci_dev *dev)
99 u32 uninitialized_var(rcba);
102 if (hpet_address || force_hpet_address)
105 pci_read_config_dword(dev, 0xF0, &rcba);
108 dev_printk(KERN_DEBUG, &dev->dev, "RCBA disabled; "
109 "cannot force enable HPET\n");
113 /* use bits 31:14, 16 kB aligned */
114 rcba_base = ioremap_nocache(rcba, 0x4000);
115 if (rcba_base == NULL) {
116 dev_printk(KERN_DEBUG, &dev->dev, "ioremap failed; "
117 "cannot force enable HPET\n");
121 /* read the Function Disable register, dword mode only */
122 val = readl(rcba_base + 0x3404);
125 /* HPET is enabled in HPTC. Just not reported by BIOS */
127 force_hpet_address = 0xFED00000 | (val << 12);
128 dev_printk(KERN_DEBUG, &dev->dev, "Force enabled HPET at "
129 "0x%lx\n", force_hpet_address);
134 /* HPET disabled in HPTC. Trying to enable */
135 writel(val | 0x80, rcba_base + 0x3404);
137 val = readl(rcba_base + 0x3404);
142 force_hpet_address = 0xFED00000 | (val << 12);
146 force_hpet_address = 0;
148 dev_printk(KERN_DEBUG, &dev->dev,
149 "Failed to force enable HPET\n");
151 force_hpet_resume_type = ICH_FORCE_HPET_RESUME;
152 dev_printk(KERN_DEBUG, &dev->dev, "Force enabled HPET at "
153 "0x%lx\n", force_hpet_address);
157 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB2_0,
158 ich_force_enable_hpet);
159 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_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 hpet_print_force_info(void)
179 printk(KERN_INFO "HPET not enabled in BIOS. "
180 "You might try hpet=force boot option\n");
183 static void old_ich_force_hpet_resume(void)
186 u32 uninitialized_var(gen_cntl);
188 if (!force_hpet_address || !cached_dev)
191 pci_read_config_dword(cached_dev, 0xD0, &gen_cntl);
192 gen_cntl &= (~(0x7 << 15));
193 gen_cntl |= (0x4 << 15);
195 pci_write_config_dword(cached_dev, 0xD0, gen_cntl);
196 pci_read_config_dword(cached_dev, 0xD0, &gen_cntl);
197 val = gen_cntl >> 15;
200 printk(KERN_DEBUG "Force enabled HPET at resume\n");
205 static void old_ich_force_enable_hpet(struct pci_dev *dev)
208 u32 uninitialized_var(gen_cntl);
210 if (hpet_address || force_hpet_address)
213 pci_read_config_dword(dev, 0xD0, &gen_cntl);
215 * Bit 17 is HPET enable bit.
216 * Bit 16:15 control the HPET base address.
218 val = gen_cntl >> 15;
222 force_hpet_address = 0xFED00000 | (val << 12);
223 dev_printk(KERN_DEBUG, &dev->dev, "HPET at 0x%lx\n",
229 * HPET is disabled. Trying enabling at FED00000 and check
232 gen_cntl &= (~(0x7 << 15));
233 gen_cntl |= (0x4 << 15);
234 pci_write_config_dword(dev, 0xD0, gen_cntl);
236 pci_read_config_dword(dev, 0xD0, &gen_cntl);
238 val = gen_cntl >> 15;
241 /* HPET is enabled in HPTC. Just not reported by BIOS */
243 force_hpet_address = 0xFED00000 | (val << 12);
244 dev_printk(KERN_DEBUG, &dev->dev, "Force enabled HPET at "
245 "0x%lx\n", force_hpet_address);
247 force_hpet_resume_type = OLD_ICH_FORCE_HPET_RESUME;
251 dev_printk(KERN_DEBUG, &dev->dev, "Failed to force enable HPET\n");
255 * Undocumented chipset features. Make sure that the user enforced
258 static void old_ich_force_enable_hpet_user(struct pci_dev *dev)
261 old_ich_force_enable_hpet(dev);
263 hpet_print_force_info();
266 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_1,
267 old_ich_force_enable_hpet_user);
268 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_0,
269 old_ich_force_enable_hpet_user);
270 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_12,
271 old_ich_force_enable_hpet_user);
272 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_0,
273 old_ich_force_enable_hpet_user);
274 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_12,
275 old_ich_force_enable_hpet_user);
276 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0,
277 old_ich_force_enable_hpet);
278 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_12,
279 old_ich_force_enable_hpet);
282 static void vt8237_force_hpet_resume(void)
286 if (!force_hpet_address || !cached_dev)
289 val = 0xfed00000 | 0x80;
290 pci_write_config_dword(cached_dev, 0x68, val);
292 pci_read_config_dword(cached_dev, 0x68, &val);
294 printk(KERN_DEBUG "Force enabled HPET at resume\n");
299 static void vt8237_force_enable_hpet(struct pci_dev *dev)
301 u32 uninitialized_var(val);
303 if (hpet_address || force_hpet_address)
306 if (!hpet_force_user) {
307 hpet_print_force_info();
311 pci_read_config_dword(dev, 0x68, &val);
313 * Bit 7 is HPET enable bit.
314 * Bit 31:10 is HPET base address (contrary to what datasheet claims)
317 force_hpet_address = (val & ~0x3ff);
318 dev_printk(KERN_DEBUG, &dev->dev, "HPET at 0x%lx\n",
324 * HPET is disabled. Trying enabling at FED00000 and check
327 val = 0xfed00000 | 0x80;
328 pci_write_config_dword(dev, 0x68, val);
330 pci_read_config_dword(dev, 0x68, &val);
332 force_hpet_address = (val & ~0x3ff);
333 dev_printk(KERN_DEBUG, &dev->dev, "Force enabled HPET at "
334 "0x%lx\n", force_hpet_address);
336 force_hpet_resume_type = VT8237_FORCE_HPET_RESUME;
340 dev_printk(KERN_DEBUG, &dev->dev, "Failed to force enable HPET\n");
343 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8235,
344 vt8237_force_enable_hpet);
345 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237,
346 vt8237_force_enable_hpet);
348 static void ati_force_hpet_resume(void)
350 pci_write_config_dword(cached_dev, 0x14, 0xfed00000);
351 printk(KERN_DEBUG "Force enabled HPET at resume\n");
354 static u32 ati_ixp4x0_rev(struct pci_dev *dev)
359 pci_read_config_byte(dev, 0xac, &b);
361 pci_write_config_byte(dev, 0xac, b);
362 pci_read_config_dword(dev, 0x70, &d);
364 pci_write_config_dword(dev, 0x70, d);
365 pci_read_config_dword(dev, 0x8, &d);
367 dev_printk(KERN_DEBUG, &dev->dev, "SB4X0 revision 0x%x\n", d);
371 static void ati_force_enable_hpet(struct pci_dev *dev)
376 if (hpet_address || force_hpet_address)
379 if (!hpet_force_user) {
380 hpet_print_force_info();
384 d = ati_ixp4x0_rev(dev);
389 pci_write_config_dword(dev, 0x14, 0xfed00000);
390 pci_read_config_dword(dev, 0x14, &val);
392 /* enable interrupt */
393 outb(0x72, 0xcd6); b = inb(0xcd7);
395 outb(0x72, 0xcd6); outb(b, 0xcd7);
396 outb(0x72, 0xcd6); b = inb(0xcd7);
399 pci_read_config_dword(dev, 0x64, &d);
401 pci_write_config_dword(dev, 0x64, d);
402 pci_read_config_dword(dev, 0x64, &d);
406 force_hpet_address = val;
407 force_hpet_resume_type = ATI_FORCE_HPET_RESUME;
408 dev_printk(KERN_DEBUG, &dev->dev, "Force enabled HPET at 0x%lx\n",
412 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP400_SMBUS,
413 ati_force_enable_hpet);
416 * Undocumented chipset feature taken from LinuxBIOS.
418 static void nvidia_force_hpet_resume(void)
420 pci_write_config_dword(cached_dev, 0x44, 0xfed00001);
421 printk(KERN_DEBUG "Force enabled HPET at resume\n");
424 static void nvidia_force_enable_hpet(struct pci_dev *dev)
426 u32 uninitialized_var(val);
428 if (hpet_address || force_hpet_address)
431 if (!hpet_force_user) {
432 hpet_print_force_info();
436 pci_write_config_dword(dev, 0x44, 0xfed00001);
437 pci_read_config_dword(dev, 0x44, &val);
438 force_hpet_address = val & 0xfffffffe;
439 force_hpet_resume_type = NVIDIA_FORCE_HPET_RESUME;
440 dev_printk(KERN_DEBUG, &dev->dev, "Force enabled HPET at 0x%lx\n",
447 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0050,
448 nvidia_force_enable_hpet);
449 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0051,
450 nvidia_force_enable_hpet);
453 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0260,
454 nvidia_force_enable_hpet);
455 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0360,
456 nvidia_force_enable_hpet);
457 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0361,
458 nvidia_force_enable_hpet);
459 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0362,
460 nvidia_force_enable_hpet);
461 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0363,
462 nvidia_force_enable_hpet);
463 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0364,
464 nvidia_force_enable_hpet);
465 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0365,
466 nvidia_force_enable_hpet);
467 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0366,
468 nvidia_force_enable_hpet);
469 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0367,
470 nvidia_force_enable_hpet);
472 void force_hpet_resume(void)
474 switch (force_hpet_resume_type) {
475 case ICH_FORCE_HPET_RESUME:
476 ich_force_hpet_resume();
478 case OLD_ICH_FORCE_HPET_RESUME:
479 old_ich_force_hpet_resume();
481 case VT8237_FORCE_HPET_RESUME:
482 vt8237_force_hpet_resume();
484 case NVIDIA_FORCE_HPET_RESUME:
485 nvidia_force_hpet_resume();
487 case ATI_FORCE_HPET_RESUME:
488 ati_force_hpet_resume();