legacy.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. long node;
  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. u32 l;
  20. if (pci_find_bus(0, n))
  21. continue;
  22. node = get_mp_bus_to_node(n);
  23. for (devfn = 0; devfn < 256; devfn += 8) {
  24. if (!raw_pci_read(0, n, devfn, PCI_VENDOR_ID, 2, &l) &&
  25. l != 0x0000 && l != 0xffff) {
  26. DBG("Found device at %02x:%02x [%04x]\n", n, devfn, l);
  27. printk(KERN_INFO "PCI: Discovered peer bus %02x\n", n);
  28. pci_scan_bus_on_node(n, &pci_root_ops, node);
  29. break;
  30. }
  31. }
  32. }
  33. }
  34. static int __init pci_legacy_init(void)
  35. {
  36. if (!raw_pci_ops) {
  37. printk("PCI: System does not support PCI\n");
  38. return 0;
  39. }
  40. if (pcibios_scanned++)
  41. return 0;
  42. printk("PCI: Probing PCI hardware\n");
  43. pci_root_bus = pcibios_scan_root(0);
  44. if (pci_root_bus)
  45. pci_bus_add_devices(pci_root_bus);
  46. pcibios_fixup_peer_bridges();
  47. return 0;
  48. }
  49. int __init pci_subsys_init(void)
  50. {
  51. #ifdef CONFIG_X86_NUMAQ
  52. pci_numaq_init();
  53. #endif
  54. #ifdef CONFIG_ACPI
  55. pci_acpi_init();
  56. #endif
  57. #ifdef CONFIG_X86_VISWS
  58. pci_visws_init();
  59. #endif
  60. pci_legacy_init();
  61. pcibios_irq_init();
  62. pcibios_init();
  63. return 0;
  64. }
  65. subsys_initcall(pci_subsys_init);