early-quirks.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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/proto.h>
  16. #include <asm/dma.h>
  17. static void via_bugs(void)
  18. {
  19. #ifdef CONFIG_IOMMU
  20. if ((end_pfn > MAX_DMA32_PFN || force_iommu) &&
  21. !iommu_aperture_allowed) {
  22. printk(KERN_INFO
  23. "Looks like a VIA chipset. Disabling IOMMU. Override with iommu=allowed\n");
  24. iommu_aperture_disabled = 1;
  25. }
  26. #endif
  27. }
  28. #ifdef CONFIG_ACPI
  29. static int nvidia_hpet_detected __initdata;
  30. static int __init nvidia_hpet_check(unsigned long phys, unsigned long size)
  31. {
  32. nvidia_hpet_detected = 1;
  33. return 0;
  34. }
  35. #endif
  36. static void nvidia_bugs(void)
  37. {
  38. #ifdef CONFIG_ACPI
  39. /*
  40. * All timer overrides on Nvidia are
  41. * wrong unless HPET is enabled.
  42. */
  43. nvidia_hpet_detected = 0;
  44. acpi_table_parse(ACPI_HPET, nvidia_hpet_check);
  45. if (nvidia_hpet_detected == 0) {
  46. acpi_skip_timer_override = 1;
  47. printk(KERN_INFO "Nvidia board "
  48. "detected. Ignoring ACPI "
  49. "timer override.\n");
  50. }
  51. #endif
  52. /* RED-PEN skip them on mptables too? */
  53. }
  54. static void ati_bugs(void)
  55. {
  56. if (timer_over_8254 == 1) {
  57. timer_over_8254 = 0;
  58. printk(KERN_INFO
  59. "ATI board detected. Disabling timer routing over 8254.\n");
  60. }
  61. }
  62. struct chipset {
  63. u16 vendor;
  64. void (*f)(void);
  65. };
  66. static struct chipset early_qrk[] = {
  67. { PCI_VENDOR_ID_NVIDIA, nvidia_bugs },
  68. { PCI_VENDOR_ID_VIA, via_bugs },
  69. { PCI_VENDOR_ID_ATI, ati_bugs },
  70. {}
  71. };
  72. void __init early_quirks(void)
  73. {
  74. int num, slot, func;
  75. if (!early_pci_allowed())
  76. return;
  77. /* Poor man's PCI discovery */
  78. for (num = 0; num < 32; num++) {
  79. for (slot = 0; slot < 32; slot++) {
  80. for (func = 0; func < 8; func++) {
  81. u32 class;
  82. u32 vendor;
  83. u8 type;
  84. int i;
  85. class = read_pci_config(num,slot,func,
  86. PCI_CLASS_REVISION);
  87. if (class == 0xffffffff)
  88. break;
  89. if ((class >> 16) != PCI_CLASS_BRIDGE_PCI)
  90. continue;
  91. vendor = read_pci_config(num, slot, func,
  92. PCI_VENDOR_ID);
  93. vendor &= 0xffff;
  94. for (i = 0; early_qrk[i].f; i++)
  95. if (early_qrk[i].vendor == vendor) {
  96. early_qrk[i].f();
  97. return;
  98. }
  99. type = read_pci_config_byte(num, slot, func,
  100. PCI_HEADER_TYPE);
  101. if (!(type & 0x80))
  102. break;
  103. }
  104. }
  105. }
  106. }