earlyquirk.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 (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. }
  31. }
  32. #endif
  33. if (vendor == PCI_VENDOR_ID_ATI && timer_over_8254 == 1) {
  34. timer_over_8254 = 0;
  35. printk(KERN_INFO "ATI board detected. Disabling timer routing "
  36. "over 8254.\n");
  37. }
  38. return 0;
  39. }
  40. void __init check_acpi_pci(void)
  41. {
  42. int num, slot, func;
  43. /* Assume the machine supports type 1. If not it will
  44. always read ffffffff and should not have any side effect.
  45. Actually a few buggy systems can machine check. Allow the user
  46. to disable it by command line option at least -AK */
  47. if (!early_pci_allowed())
  48. return;
  49. /* Poor man's PCI discovery */
  50. for (num = 0; num < 32; num++) {
  51. for (slot = 0; slot < 32; slot++) {
  52. for (func = 0; func < 8; func++) {
  53. u32 class;
  54. u32 vendor;
  55. class = read_pci_config(num, slot, func,
  56. PCI_CLASS_REVISION);
  57. if (class == 0xffffffff)
  58. break;
  59. if ((class >> 16) != PCI_CLASS_BRIDGE_PCI)
  60. continue;
  61. vendor = read_pci_config(num, slot, func,
  62. PCI_VENDOR_ID);
  63. if (check_bridge(vendor & 0xffff, vendor >> 16))
  64. return;
  65. }
  66. }
  67. }
  68. }