legacy.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * legacy.c - traditional, old school PCI bus probing
  3. */
  4. #include <linux/init.h>
  5. #include <linux/export.h>
  6. #include <linux/pci.h>
  7. #include <asm/pci_x86.h>
  8. /*
  9. * Discover remaining PCI buses in case there are peer host bridges.
  10. * We use the number of last PCI bus provided by the PCI BIOS.
  11. */
  12. static void __devinit pcibios_fixup_peer_bridges(void)
  13. {
  14. int n;
  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. pcibios_scan_specific_bus(n);
  20. }
  21. int __init pci_legacy_init(void)
  22. {
  23. if (!raw_pci_ops) {
  24. printk("PCI: System does not support PCI\n");
  25. return 0;
  26. }
  27. printk("PCI: Probing PCI hardware\n");
  28. pci_root_bus = pcibios_scan_root(0);
  29. return 0;
  30. }
  31. void __devinit pcibios_scan_specific_bus(int busn)
  32. {
  33. int devfn;
  34. long node;
  35. u32 l;
  36. if (pci_find_bus(0, busn))
  37. return;
  38. node = get_mp_bus_to_node(busn);
  39. for (devfn = 0; devfn < 256; devfn += 8) {
  40. if (!raw_pci_read(0, busn, devfn, PCI_VENDOR_ID, 2, &l) &&
  41. l != 0x0000 && l != 0xffff) {
  42. DBG("Found device at %02x:%02x [%04x]\n", busn, devfn, l);
  43. printk(KERN_INFO "PCI: Discovered peer bus %02x\n", busn);
  44. pci_scan_bus_on_node(busn, &pci_root_ops, node);
  45. return;
  46. }
  47. }
  48. }
  49. EXPORT_SYMBOL_GPL(pcibios_scan_specific_bus);
  50. int __init pci_subsys_init(void)
  51. {
  52. /*
  53. * The init function returns an non zero value when
  54. * pci_legacy_init should be invoked.
  55. */
  56. if (x86_init.pci.init())
  57. pci_legacy_init();
  58. pcibios_fixup_peer_bridges();
  59. x86_init.pci.init_irq();
  60. pcibios_init();
  61. return 0;
  62. }
  63. subsys_initcall(pci_subsys_init);