legacy.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. EXPORT_SYMBOL_GPL(pci_legacy_init);
  33. void pcibios_scan_specific_bus(int busn)
  34. {
  35. int devfn;
  36. long node;
  37. u32 l;
  38. if (pci_find_bus(0, busn))
  39. return;
  40. node = get_mp_bus_to_node(busn);
  41. for (devfn = 0; devfn < 256; devfn += 8) {
  42. if (!raw_pci_read(0, busn, devfn, PCI_VENDOR_ID, 2, &l) &&
  43. l != 0x0000 && l != 0xffff) {
  44. DBG("Found device at %02x:%02x [%04x]\n", busn, devfn, l);
  45. printk(KERN_INFO "PCI: Discovered peer bus %02x\n", busn);
  46. pci_scan_bus_on_node(busn, &pci_root_ops, node);
  47. return;
  48. }
  49. }
  50. }
  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);