diff options
-rw-r--r-- | src/northbridge/intel/haswell/pcie.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/northbridge/intel/haswell/pcie.c b/src/northbridge/intel/haswell/pcie.c index cea3f6ac84..95c0240ed3 100644 --- a/src/northbridge/intel/haswell/pcie.c +++ b/src/northbridge/intel/haswell/pcie.c @@ -46,15 +46,28 @@ static const char *pcie_acpi_name(const struct device *dev) } #endif -static void peg_enable(struct device *dev) +static const struct peg_config *get_peg_config(struct device *dev, const uint8_t func) { - const struct northbridge_intel_haswell_config *config = config_of(dev); + static const struct peg_config default_config = { 0 }; - const uint8_t func = PCI_FUNC(dev->path.pci.devfn); + if (!dev || !dev->chip_info) + return &default_config; + + const struct northbridge_intel_haswell_config *config = dev->chip_info; - assert(func < ARRAY_SIZE(config->peg_cfg)); + if (func >= ARRAY_SIZE(config->peg_cfg)) { + printk(BIOS_ERR, "%s: Found PEG function %u, which doesn't exist on Haswell\n", + __func__, func); + return &default_config; + } + return &config->peg_cfg[func]; +} + +static void peg_enable(struct device *dev) +{ + const uint8_t func = PCI_FUNC(dev->path.pci.devfn); - const struct peg_config *peg_cfg = &config->peg_cfg[func]; + const struct peg_config *peg_cfg = get_peg_config(dev, func); const bool slot_implemented = !peg_cfg->is_onboard; |