quirks.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * This file contains work-arounds for x86 and x86_64 platform bugs.
  3. */
  4. #include <linux/pci.h>
  5. #include <linux/irq.h>
  6. #include <asm/hpet.h>
  7. #if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_SMP) && defined(CONFIG_PCI)
  8. static void __devinit quirk_intel_irqbalance(struct pci_dev *dev)
  9. {
  10. u8 config, rev;
  11. u32 word;
  12. /* BIOS may enable hardware IRQ balancing for
  13. * E7520/E7320/E7525(revision ID 0x9 and below)
  14. * based platforms.
  15. * Disable SW irqbalance/affinity on those platforms.
  16. */
  17. pci_read_config_byte(dev, PCI_CLASS_REVISION, &rev);
  18. if (rev > 0x9)
  19. return;
  20. /* enable access to config space*/
  21. pci_read_config_byte(dev, 0xf4, &config);
  22. pci_write_config_byte(dev, 0xf4, config|0x2);
  23. /* read xTPR register */
  24. raw_pci_ops->read(0, 0, 0x40, 0x4c, 2, &word);
  25. if (!(word & (1 << 13))) {
  26. printk(KERN_INFO "Intel E7520/7320/7525 detected. "
  27. "Disabling irq balancing and affinity\n");
  28. #ifdef CONFIG_IRQBALANCE
  29. irqbalance_disable("");
  30. #endif
  31. noirqdebug_setup("");
  32. #ifdef CONFIG_PROC_FS
  33. no_irq_affinity = 1;
  34. #endif
  35. }
  36. /* put back the original value for config space*/
  37. if (!(config & 0x2))
  38. pci_write_config_byte(dev, 0xf4, config);
  39. }
  40. DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7320_MCH, quirk_intel_irqbalance);
  41. DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7525_MCH, quirk_intel_irqbalance);
  42. DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7520_MCH, quirk_intel_irqbalance);
  43. #endif
  44. #if defined(CONFIG_HPET_TIMER)
  45. unsigned long force_hpet_address;
  46. static void __iomem *rcba_base;
  47. void ich_force_hpet_resume(void)
  48. {
  49. u32 val;
  50. if (!force_hpet_address)
  51. return;
  52. if (rcba_base == NULL)
  53. BUG();
  54. /* read the Function Disable register, dword mode only */
  55. val = readl(rcba_base + 0x3404);
  56. if (!(val & 0x80)) {
  57. /* HPET disabled in HPTC. Trying to enable */
  58. writel(val | 0x80, rcba_base + 0x3404);
  59. }
  60. val = readl(rcba_base + 0x3404);
  61. if (!(val & 0x80))
  62. BUG();
  63. else
  64. printk(KERN_DEBUG "Force enabled HPET at resume\n");
  65. return;
  66. }
  67. static void ich_force_enable_hpet(struct pci_dev *dev)
  68. {
  69. u32 val;
  70. u32 uninitialized_var(rcba);
  71. int err = 0;
  72. if (hpet_address || force_hpet_address)
  73. return;
  74. pci_read_config_dword(dev, 0xF0, &rcba);
  75. rcba &= 0xFFFFC000;
  76. if (rcba == 0) {
  77. printk(KERN_DEBUG "RCBA disabled. Cannot force enable HPET\n");
  78. return;
  79. }
  80. /* use bits 31:14, 16 kB aligned */
  81. rcba_base = ioremap_nocache(rcba, 0x4000);
  82. if (rcba_base == NULL) {
  83. printk(KERN_DEBUG "ioremap failed. Cannot force enable HPET\n");
  84. return;
  85. }
  86. /* read the Function Disable register, dword mode only */
  87. val = readl(rcba_base + 0x3404);
  88. if (val & 0x80) {
  89. /* HPET is enabled in HPTC. Just not reported by BIOS */
  90. val = val & 0x3;
  91. force_hpet_address = 0xFED00000 | (val << 12);
  92. printk(KERN_DEBUG "Force enabled HPET at base address 0x%lx\n",
  93. force_hpet_address);
  94. iounmap(rcba_base);
  95. return;
  96. }
  97. /* HPET disabled in HPTC. Trying to enable */
  98. writel(val | 0x80, rcba_base + 0x3404);
  99. val = readl(rcba_base + 0x3404);
  100. if (!(val & 0x80)) {
  101. err = 1;
  102. } else {
  103. val = val & 0x3;
  104. force_hpet_address = 0xFED00000 | (val << 12);
  105. }
  106. if (err) {
  107. force_hpet_address = 0;
  108. iounmap(rcba_base);
  109. printk(KERN_DEBUG "Failed to force enable HPET\n");
  110. } else {
  111. printk(KERN_DEBUG "Force enabled HPET at base address 0x%lx\n",
  112. force_hpet_address);
  113. }
  114. }
  115. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB2_0,
  116. ich_force_enable_hpet);
  117. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_1,
  118. ich_force_enable_hpet);
  119. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_1,
  120. ich_force_enable_hpet);
  121. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_31,
  122. ich_force_enable_hpet);
  123. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_1,
  124. ich_force_enable_hpet);
  125. #endif