legacy.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * legacy.c - traditional, old school PCI bus probing
  3. */
  4. #include <linux/init.h>
  5. #include <linux/pci.h>
  6. #include <asm/pci_x86.h>
  7. /*
  8. * Discover remaining PCI buses in case there are peer host bridges.
  9. * We use the number of last PCI bus provided by the PCI BIOS.
  10. */
  11. static void __devinit pcibios_fixup_peer_bridges(void)
  12. {
  13. int n, devfn;
  14. long node;
  15. if (pcibios_last_bus <= 0 || pcibios_last_bus > 0xff)
  16. return;
  17. DBG("PCI: Peer bridge fixup\n");
  18. for (n=0; n <= pcibios_last_bus; n++) {
  19. u32 l;
  20. if (pci_find_bus(0, n))
  21. continue;
  22. node = get_mp_bus_to_node(n);
  23. for (devfn = 0; devfn < 256; devfn += 8) {
  24. if (!raw_pci_read(0, n, devfn, PCI_VENDOR_ID, 2, &l) &&
  25. l != 0x0000 && l != 0xffff) {
  26. DBG("Found device at %02x:%02x [%04x]\n", n, devfn, l);
  27. printk(KERN_INFO "PCI: Discovered peer bus %02x\n", n);
  28. pci_scan_bus_on_node(n, &pci_root_ops, node);
  29. break;
  30. }
  31. }
  32. }
  33. }
  34. static int __init pci_legacy_init(void)
  35. {
  36. if (!raw_pci_ops) {
  37. printk("PCI: System does not support PCI\n");
  38. return 0;
  39. }
  40. if (pcibios_scanned++)
  41. return 0;
  42. printk("PCI: Probing PCI hardware\n");
  43. pci_root_bus = pcibios_scan_root(0);
  44. if (pci_root_bus)
  45. pci_bus_add_devices(pci_root_bus);
  46. return 0;
  47. }
  48. int __init pci_subsys_init(void)
  49. {
  50. #ifdef CONFIG_X86_NUMAQ
  51. pci_numaq_init();
  52. #endif
  53. #ifdef CONFIG_ACPI
  54. pci_acpi_init();
  55. #endif
  56. #ifdef CONFIG_X86_VISWS
  57. pci_visws_init();
  58. #endif
  59. pci_legacy_init();
  60. pcibios_fixup_peer_bridges();
  61. pcibios_irq_init();
  62. pcibios_init();
  63. return 0;
  64. }
  65. subsys_initcall(pci_subsys_init);