earlyquirk.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. #ifdef CONFIG_ACPI
  13. static int nvidia_hpet_detected __initdata;
  14. static int __init nvidia_hpet_check(unsigned long phys, unsigned long size)
  15. {
  16. nvidia_hpet_detected = 1;
  17. return 0;
  18. }
  19. #endif
  20. static int __init check_bridge(int vendor, int device)
  21. {
  22. #ifdef CONFIG_ACPI
  23. /* According to Nvidia all timer overrides are bogus unless HPET
  24. is enabled. */
  25. if (!acpi_use_timer_override && vendor == PCI_VENDOR_ID_NVIDIA) {
  26. nvidia_hpet_detected = 0;
  27. acpi_table_parse(ACPI_HPET, nvidia_hpet_check);
  28. if (nvidia_hpet_detected == 0) {
  29. acpi_skip_timer_override = 1;
  30. printk(KERN_INFO "Nvidia board "
  31. "detected. Ignoring ACPI "
  32. "timer override.\n");
  33. printk(KERN_INFO "If you got timer trouble "
  34. "try acpi_use_timer_override\n");
  35. }
  36. }
  37. #endif
  38. if (vendor == PCI_VENDOR_ID_ATI && timer_over_8254 == 1) {
  39. timer_over_8254 = 0;
  40. printk(KERN_INFO "ATI board detected. Disabling timer routing "
  41. "over 8254.\n");
  42. }
  43. return 0;
  44. }
  45. void __init check_acpi_pci(void)
  46. {
  47. int num, slot, func;
  48. /* Assume the machine supports type 1. If not it will
  49. always read ffffffff and should not have any side effect.
  50. Actually a few buggy systems can machine check. Allow the user
  51. to disable it by command line option at least -AK */
  52. if (!early_pci_allowed())
  53. return;
  54. /* Poor man's PCI discovery */
  55. for (num = 0; num < 32; num++) {
  56. for (slot = 0; slot < 32; slot++) {
  57. for (func = 0; func < 8; func++) {
  58. u32 class;
  59. u32 vendor;
  60. class = read_pci_config(num, slot, func,
  61. PCI_CLASS_REVISION);
  62. if (class == 0xffffffff)
  63. break;
  64. if ((class >> 16) != PCI_CLASS_BRIDGE_PCI)
  65. continue;
  66. vendor = read_pci_config(num, slot, func,
  67. PCI_VENDOR_ID);
  68. if (check_bridge(vendor & 0xffff, vendor >> 16))
  69. return;
  70. }
  71. }
  72. }
  73. }