legacy.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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/jailhouse_para.h>
  8. #include <asm/pci_x86.h>
  9. /*
  10. * Discover remaining PCI buses in case there are peer host bridges.
  11. * We use the number of last PCI bus provided by the PCI BIOS.
  12. */
  13. static void pcibios_fixup_peer_bridges(void)
  14. {
  15. int n;
  16. if (pcibios_last_bus <= 0 || pcibios_last_bus > 0xff)
  17. return;
  18. DBG("PCI: Peer bridge fixup\n");
  19. for (n=0; n <= pcibios_last_bus; n++)
  20. pcibios_scan_specific_bus(n);
  21. }
  22. int __init pci_legacy_init(void)
  23. {
  24. if (!raw_pci_ops)
  25. return 1;
  26. pr_info("PCI: Probing PCI hardware\n");
  27. pcibios_scan_root(0);
  28. return 0;
  29. }
  30. void pcibios_scan_specific_bus(int busn)
  31. {
  32. int stride = jailhouse_paravirt() ? 1 : 8;
  33. int devfn;
  34. u32 l;
  35. if (pci_find_bus(0, busn))
  36. return;
  37. for (devfn = 0; devfn < 256; devfn += stride) {
  38. if (!raw_pci_read(0, busn, devfn, PCI_VENDOR_ID, 2, &l) &&
  39. l != 0x0000 && l != 0xffff) {
  40. DBG("Found device at %02x:%02x [%04x]\n", busn, devfn, l);
  41. pr_info("PCI: Discovered peer bus %02x\n", busn);
  42. pcibios_scan_root(busn);
  43. return;
  44. }
  45. }
  46. }
  47. EXPORT_SYMBOL_GPL(pcibios_scan_specific_bus);
  48. static int __init pci_subsys_init(void)
  49. {
  50. /*
  51. * The init function returns an non zero value when
  52. * pci_legacy_init should be invoked.
  53. */
  54. if (x86_init.pci.init()) {
  55. if (pci_legacy_init()) {
  56. pr_info("PCI: System does not support PCI\n");
  57. return -ENODEV;
  58. }
  59. }
  60. pcibios_fixup_peer_bridges();
  61. x86_init.pci.init_irq();
  62. pcibios_init();
  63. return 0;
  64. }
  65. subsys_initcall(pci_subsys_init);