early-quirks.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. #include <linux/pci.h>
  12. #include <linux/acpi.h>
  13. #include <linux/pci_ids.h>
  14. #include <asm/pci-direct.h>
  15. #include <asm/dma.h>
  16. #include <asm/io_apic.h>
  17. #include <asm/apic.h>
  18. #ifdef CONFIG_IOMMU
  19. #include <asm/iommu.h>
  20. #endif
  21. static void __init via_bugs(void)
  22. {
  23. #ifdef CONFIG_IOMMU
  24. if ((end_pfn > MAX_DMA32_PFN || force_iommu) &&
  25. !iommu_aperture_allowed) {
  26. printk(KERN_INFO
  27. "Looks like a VIA chipset. Disabling IOMMU."
  28. " Override with iommu=allowed\n");
  29. iommu_aperture_disabled = 1;
  30. }
  31. #endif
  32. }
  33. #ifdef CONFIG_ACPI
  34. static int __init nvidia_hpet_check(struct acpi_table_header *header)
  35. {
  36. return 0;
  37. }
  38. #endif
  39. static void __init nvidia_bugs(void)
  40. {
  41. #ifdef CONFIG_ACPI
  42. #ifdef CONFIG_X86_IO_APIC
  43. /*
  44. * All timer overrides on Nvidia are
  45. * wrong unless HPET is enabled.
  46. * Unfortunately that's not true on many Asus boards.
  47. * We don't know yet how to detect this automatically, but
  48. * at least allow a command line override.
  49. */
  50. if (acpi_use_timer_override)
  51. return;
  52. if (acpi_table_parse(ACPI_SIG_HPET, nvidia_hpet_check)) {
  53. acpi_skip_timer_override = 1;
  54. printk(KERN_INFO "Nvidia board "
  55. "detected. Ignoring ACPI "
  56. "timer override.\n");
  57. printk(KERN_INFO "If you got timer trouble "
  58. "try acpi_use_timer_override\n");
  59. }
  60. #endif
  61. #endif
  62. /* RED-PEN skip them on mptables too? */
  63. }
  64. static void __init ati_bugs(void)
  65. {
  66. #ifdef CONFIG_X86_IO_APIC
  67. if (timer_over_8254 == 1) {
  68. timer_over_8254 = 0;
  69. printk(KERN_INFO
  70. "ATI board detected. Disabling timer routing over 8254.\n");
  71. }
  72. #endif
  73. }
  74. struct chipset {
  75. u16 vendor;
  76. void (*f)(void);
  77. };
  78. static struct chipset early_qrk[] __initdata = {
  79. { PCI_VENDOR_ID_NVIDIA, nvidia_bugs },
  80. { PCI_VENDOR_ID_VIA, via_bugs },
  81. { PCI_VENDOR_ID_ATI, ati_bugs },
  82. {}
  83. };
  84. void __init early_quirks(void)
  85. {
  86. int num, slot, func;
  87. if (!early_pci_allowed())
  88. return;
  89. /* Poor man's PCI discovery */
  90. for (num = 0; num < 32; num++) {
  91. for (slot = 0; slot < 32; slot++) {
  92. for (func = 0; func < 8; func++) {
  93. u32 class;
  94. u32 vendor;
  95. u8 type;
  96. int i;
  97. class = read_pci_config(num,slot,func,
  98. PCI_CLASS_REVISION);
  99. if (class == 0xffffffff)
  100. break;
  101. if ((class >> 16) != PCI_CLASS_BRIDGE_PCI)
  102. continue;
  103. vendor = read_pci_config(num, slot, func,
  104. PCI_VENDOR_ID);
  105. vendor &= 0xffff;
  106. for (i = 0; early_qrk[i].f; i++)
  107. if (early_qrk[i].vendor == vendor) {
  108. early_qrk[i].f();
  109. return;
  110. }
  111. type = read_pci_config_byte(num, slot, func,
  112. PCI_HEADER_TYPE);
  113. if (!(type & 0x80))
  114. break;
  115. }
  116. }
  117. }
  118. }