earlyquirk.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. /* Poor man's PCI discovery */
  46. for (num = 0; num < 32; num++) {
  47. for (slot = 0; slot < 32; slot++) {
  48. for (func = 0; func < 8; func++) {
  49. u32 class;
  50. u32 vendor;
  51. class = read_pci_config(num, slot, func,
  52. PCI_CLASS_REVISION);
  53. if (class == 0xffffffff)
  54. break;
  55. if ((class >> 16) != PCI_CLASS_BRIDGE_PCI)
  56. continue;
  57. vendor = read_pci_config(num, slot, func,
  58. PCI_VENDOR_ID);
  59. if (check_bridge(vendor & 0xffff, vendor >> 16))
  60. return;
  61. }
  62. }
  63. }
  64. }