diff --git a/arch/x86/core/pcie.c b/arch/x86/core/pcie.c index de2c1d113c3..9d6b7895e2a 100644 --- a/arch/x86/core/pcie.c +++ b/arch/x86/core/pcie.c @@ -17,6 +17,7 @@ #endif /* PCI Express Extended Configuration Mechanism (MMIO) */ +#ifdef CONFIG_PCIE_MMIO_CFG #define MAX_PCI_BUS_SEGMENTS 4 @@ -26,6 +27,8 @@ static struct { uint8_t *mmio; } bus_segs[MAX_PCI_BUS_SEGMENTS]; +static bool do_pcie_mmio_cfg; + static void pcie_mm_init(void) { #ifdef CONFIG_ACPI @@ -49,6 +52,8 @@ static void pcie_mm_init(void) device_map((mm_reg_t *)&bus_segs[i].mmio, phys_addr, size, K_MEM_CACHE_NONE); } + + do_pcie_mmio_cfg = true; } #endif } @@ -60,6 +65,10 @@ static inline void pcie_mm_conf(pcie_bdf_t bdf, unsigned int reg, pcie_mm_init(); } + if (do_pcie_mmio_cfg == false) { + return; + } + for (int i = 0; i < ARRAY_SIZE(bus_segs); i++) { int off = PCIE_BDF_TO_BUS(bdf) - bus_segs[i].start_bus; @@ -80,6 +89,8 @@ static inline void pcie_mm_conf(pcie_bdf_t bdf, unsigned int reg, } } +#endif /* CONFIG_PCIE_MMIO_CFG */ + /* Traditional Configuration Mechanism */ #define PCIE_X86_CAP 0xCF8U /* Configuration Address Port */ @@ -122,10 +133,13 @@ static inline void pcie_conf(pcie_bdf_t bdf, unsigned int reg, { #ifdef CONFIG_PCIE_MMIO_CFG - pcie_mm_conf(bdf, reg, write, data); -#else - pcie_io_conf(bdf, reg, write, data); + if (do_pcie_mmio_cfg) { + pcie_mm_conf(bdf, reg, write, data); + } else #endif + { + pcie_io_conf(bdf, reg, write, data); + } } /* these functions are explained in include/drivers/pcie/pcie.h */