legacy.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 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. return 1;
  25. pr_info("PCI: Probing PCI hardware\n");
  26. pcibios_scan_root(0);
  27. return 0;
  28. }
  29. void pcibios_scan_specific_bus(int busn)
  30. {
  31. int devfn;
  32. u32 l;
  33. if (pci_find_bus(0, busn))
  34. return;
  35. for (devfn = 0; devfn < 256; devfn += 8) {
  36. if (!raw_pci_read(0, busn, devfn, PCI_VENDOR_ID, 2, &l) &&
  37. l != 0x0000 && l != 0xffff) {
  38. DBG("Found device at %02x:%02x [%04x]\n", busn, devfn, l);
  39. pr_info("PCI: Discovered peer bus %02x\n", busn);
  40. pcibios_scan_root(busn);
  41. return;
  42. }
  43. }
  44. }
  45. EXPORT_SYMBOL_GPL(pcibios_scan_specific_bus);
  46. static int __init pci_subsys_init(void)
  47. {
  48. /*
  49. * The init function returns an non zero value when
  50. * pci_legacy_init should be invoked.
  51. */
  52. if (x86_init.pci.init()) {
  53. if (pci_legacy_init()) {
  54. pr_info("PCI: System does not support PCI\n");
  55. return -ENODEV;
  56. }
  57. }
  58. pcibios_fixup_peer_bridges();
  59. x86_init.pci.init_irq();
  60. pcibios_init();
  61. return 0;
  62. }
  63. subsys_initcall(pci_subsys_init);