legacy.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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;
  14. if (pcibios_last_bus <= 0 || pcibios_last_bus > 0xff)
  15. return;
  16. DBG("PCI: Peer bridge fixup\n");
  17. for (n=0; n <= pcibios_last_bus; n++)
  18. pcibios_scan_specific_bus(n);
  19. }
  20. int __init pci_legacy_init(void)
  21. {
  22. if (!raw_pci_ops) {
  23. printk("PCI: System does not support PCI\n");
  24. return 0;
  25. }
  26. printk("PCI: Probing PCI hardware\n");
  27. pci_root_bus = pcibios_scan_root(0);
  28. if (pci_root_bus)
  29. pci_bus_add_devices(pci_root_bus);
  30. return 0;
  31. }
  32. void __devinit pcibios_scan_specific_bus(int busn)
  33. {
  34. int devfn;
  35. long node;
  36. u32 l;
  37. if (pci_find_bus(0, busn))
  38. return;
  39. node = get_mp_bus_to_node(busn);
  40. for (devfn = 0; devfn < 256; devfn += 8) {
  41. if (!raw_pci_read(0, busn, devfn, PCI_VENDOR_ID, 2, &l) &&
  42. l != 0x0000 && l != 0xffff) {
  43. DBG("Found device at %02x:%02x [%04x]\n", busn, devfn, l);
  44. printk(KERN_INFO "PCI: Discovered peer bus %02x\n", busn);
  45. pci_scan_bus_on_node(busn, &pci_root_ops, node);
  46. return;
  47. }
  48. }
  49. }
  50. EXPORT_SYMBOL_GPL(pcibios_scan_specific_bus);
  51. int __init pci_subsys_init(void)
  52. {
  53. /*
  54. * The init function returns an non zero value when
  55. * pci_legacy_init should be invoked.
  56. */
  57. if (x86_init.pci.init())
  58. pci_legacy_init();
  59. pcibios_fixup_peer_bridges();
  60. x86_init.pci.init_irq();
  61. pcibios_init();
  62. return 0;
  63. }
  64. subsys_initcall(pci_subsys_init);