^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #include <linux/pci.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #include <asm/pci_x86.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <asm/x86_init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <asm/irqdomain.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) /* arch_initcall has too random ordering, so call the initializers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) in the right sequence from here. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) static __init int pci_arch_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) int type, pcbios = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) type = pci_direct_probe();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) if (!(pci_probe & PCI_PROBE_NOEARLY))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) pci_mmcfg_early_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) if (x86_init.pci.arch_init)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) pcbios = x86_init.pci.arch_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * Must happen after x86_init.pci.arch_init(). Xen sets up the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * x86_init.irqs.create_pci_msi_domain there.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) x86_create_pci_msi_domain();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) if (!pcbios)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) pci_pcbios_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * don't check for raw_pci_ops here because we want pcbios as last
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * fallback, yet it's needed to run first to set pcibios_last_bus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * in case legacy PCI probing is used. otherwise detecting peer busses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * fails.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) pci_direct_init(type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) if (!raw_pci_ops && !raw_pci_ext_ops)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) printk(KERN_ERR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) "PCI: Fatal: No config space access function found\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) dmi_check_pciprobe();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) dmi_check_skip_isa_align();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) arch_initcall(pci_arch_init);