earlyquirk.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * Do early PCI probing for bug detection when the main PCI subsystem is
  3. * not up yet.
  4. */
  5. #include <linux/init.h>
  6. #include <linux/kernel.h>
  7. #include <linux/pci.h>
  8. #include <linux/acpi.h>
  9. #include <asm/pci-direct.h>
  10. #include <asm/acpi.h>
  11. #include <asm/apic.h>
  12. #include <asm/irq.h>
  13. #ifdef CONFIG_ACPI
  14. static int nvidia_hpet_detected __initdata;
  15. static int __init nvidia_hpet_check(struct acpi_table_header *header)
  16. {
  17. nvidia_hpet_detected = 1;
  18. return 0;
  19. }
  20. #endif
  21. static int __init check_bridge(int vendor, int device)
  22. {
  23. #ifdef CONFIG_ACPI
  24. /* According to Nvidia all timer overrides are bogus unless HPET
  25. is enabled. */
  26. if (!acpi_use_timer_override && vendor == PCI_VENDOR_ID_NVIDIA) {
  27. nvidia_hpet_detected = 0;
  28. acpi_table_parse(ACPI_SIG_HPET, nvidia_hpet_check);
  29. if (nvidia_hpet_detected == 0) {
  30. acpi_skip_timer_override = 1;
  31. printk(KERN_INFO "Nvidia board "
  32. "detected. Ignoring ACPI "
  33. "timer override.\n");
  34. printk(KERN_INFO "If you got timer trouble "
  35. "try acpi_use_timer_override\n");
  36. }
  37. }
  38. #endif
  39. if (vendor == PCI_VENDOR_ID_ATI && timer_over_8254 == 1) {
  40. timer_over_8254 = 0;
  41. printk(KERN_INFO "ATI board detected. Disabling timer routing "
  42. "over 8254.\n");
  43. }
  44. return 0;
  45. }
  46. static void check_intel(void)
  47. {
  48. u16 vendor, device;
  49. vendor = read_pci_config_16(0, 0, 0, PCI_VENDOR_ID);
  50. if (vendor != PCI_VENDOR_ID_INTEL)
  51. return;
  52. device = read_pci_config_16(0, 0, 0, PCI_DEVICE_ID);
  53. #ifdef CONFIG_SMP
  54. if (device == PCI_DEVICE_ID_INTEL_E7320_MCH ||
  55. device == PCI_DEVICE_ID_INTEL_E7520_MCH ||
  56. device == PCI_DEVICE_ID_INTEL_E7525_MCH)
  57. quirk_intel_irqbalance();
  58. #endif
  59. }
  60. void __init check_acpi_pci(void)
  61. {
  62. int num, slot, func;
  63. /* Assume the machine supports type 1. If not it will
  64. always read ffffffff and should not have any side effect.
  65. Actually a few buggy systems can machine check. Allow the user
  66. to disable it by command line option at least -AK */
  67. if (!early_pci_allowed())
  68. return;
  69. check_intel();
  70. /* Poor man's PCI discovery */
  71. for (num = 0; num < 32; num++) {
  72. for (slot = 0; slot < 32; slot++) {
  73. for (func = 0; func < 8; func++) {
  74. u32 class;
  75. u32 vendor;
  76. class = read_pci_config(num, slot, func,
  77. PCI_CLASS_REVISION);
  78. if (class == 0xffffffff)
  79. break;
  80. if ((class >> 16) != PCI_CLASS_BRIDGE_PCI)
  81. continue;
  82. vendor = read_pci_config(num, slot, func,
  83. PCI_VENDOR_ID);
  84. if (check_bridge(vendor & 0xffff, vendor >> 16))
  85. return;
  86. }
  87. }
  88. }
  89. }