legacy.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. 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. printk("PCI: Probing PCI hardware\n");
  41. pci_root_bus = pcibios_scan_root(0);
  42. if (pci_root_bus)
  43. pci_bus_add_devices(pci_root_bus);
  44. return 0;
  45. }
  46. int __init pci_subsys_init(void)
  47. {
  48. /*
  49. * The init function returns an non zero value when
  50. * pci_legacy_init should be invoked.
  51. */
  52. if (x86_init.pci.init())
  53. pci_legacy_init();
  54. pcibios_fixup_peer_bridges();
  55. x86_init.pci.init_irq();
  56. pcibios_init();
  57. return 0;
  58. }
  59. subsys_initcall(pci_subsys_init);