legacy.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. if (pci_root_bus)
  43. pci_bus_add_devices(pci_root_bus);
  44. pcibios_fixup_peer_bridges();
  45. return 0;
  46. }
  47. subsys_initcall(pci_legacy_init);