legacy.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. printk("PCI: System does not support PCI\n");
  25. return 0;
  26. }
  27. printk("PCI: Probing PCI hardware\n");
  28. pcibios_scan_root(0);
  29. return 0;
  30. }
  31. void pcibios_scan_specific_bus(int busn)
  32. {
  33. int devfn;
  34. u32 l;
  35. if (pci_find_bus(0, busn))
  36. return;
  37. for (devfn = 0; devfn < 256; devfn += 8) {
  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. printk(KERN_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. pci_legacy_init();
  56. pcibios_fixup_peer_bridges();
  57. x86_init.pci.init_irq();
  58. pcibios_init();
  59. return 0;
  60. }
  61. subsys_initcall(pci_subsys_init);