legacy.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * legacy.c - traditional, old school PCI bus probing
  3. */
  4. #include <linux/init.h>
  5. #include <linux/pci.h>
  6. #include "pci.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. 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. u32 l;
  19. if (pci_find_bus(0, n))
  20. continue;
  21. for (devfn = 0; devfn < 256; devfn += 8) {
  22. if (!raw_pci_ops->read(0, n, devfn, PCI_VENDOR_ID, 2, &l) &&
  23. l != 0x0000 && l != 0xffff) {
  24. DBG("Found device at %02x:%02x [%04x]\n", n, devfn, l);
  25. printk(KERN_INFO "PCI: Discovered peer bus %02x\n", n);
  26. pci_scan_bus(n, &pci_root_ops, NULL);
  27. break;
  28. }
  29. }
  30. }
  31. }
  32. static int __init pci_legacy_init(void)
  33. {
  34. if (!raw_pci_ops) {
  35. printk("PCI: System does not support PCI\n");
  36. return 0;
  37. }
  38. if (pcibios_scanned++)
  39. return 0;
  40. printk("PCI: Probing PCI hardware\n");
  41. pci_root_bus = pcibios_scan_root(0);
  42. pcibios_fixup_peer_bridges();
  43. return 0;
  44. }
  45. subsys_initcall(pci_legacy_init);