summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/device/pciexp_device.c20
-rw-r--r--src/include/device/pciexp.h2
-rw-r--r--src/mainboard/ocp/deltalake/ramstage.c11
-rw-r--r--src/soc/intel/xeon_sp/pcie_root_port.c11
4 files changed, 27 insertions, 17 deletions
diff --git a/src/device/pciexp_device.c b/src/device/pciexp_device.c
index db351efd49..8686e38a86 100644
--- a/src/device/pciexp_device.c
+++ b/src/device/pciexp_device.c
@@ -144,6 +144,26 @@ struct device *pcie_find_dsn(const uint64_t serial, const uint16_t vid,
return from;
}
+/**
+ * Returns true if the device is a hot-plug capable PCIe device.
+ *
+ * @param dev Pointer to the device structure.
+ *
+ * @return True when marked hot-plug capable.
+ */
+bool pciexp_dev_is_slot_hot_plug_cap(struct device *dev)
+{
+ u16 sltcap;
+ unsigned int pcie_cap = pci_find_capability(dev, PCI_CAP_ID_PCIE);
+
+ if (!pcie_cap)
+ return 0;
+
+ sltcap = pci_read_config16(dev, pcie_cap + PCI_EXP_SLTCAP);
+ sltcap &= PCI_EXP_SLTCAP_HPC;
+ return !!sltcap;
+}
+
static bool pcie_is_root_port(struct device *dev)
{
unsigned int pcie_pos, pcie_type;
diff --git a/src/include/device/pciexp.h b/src/include/device/pciexp.h
index 05d3873238..2618c02f32 100644
--- a/src/include/device/pciexp.h
+++ b/src/include/device/pciexp.h
@@ -45,6 +45,8 @@ static inline bool pciexp_is_downstream_port(int type)
type == PCI_EXP_TYPE_PCIE_BRIDGE;
}
+bool pciexp_dev_is_slot_hot_plug_cap(struct device *dev);
+
struct device *pcie_find_dsn(const uint64_t serial, const uint16_t vid,
struct device *from);
diff --git a/src/mainboard/ocp/deltalake/ramstage.c b/src/mainboard/ocp/deltalake/ramstage.c
index ebb9a4b7a0..6b1863a9af 100644
--- a/src/mainboard/ocp/deltalake/ramstage.c
+++ b/src/mainboard/ocp/deltalake/ramstage.c
@@ -6,9 +6,7 @@
#include <cpu/cpu.h>
#include <cpu/x86/smm.h>
#include <cpxsp_dl_gpio.h>
-#include <device/device.h>
-#include <device/pci_def.h>
-#include <device/pci_ops.h>
+#include <device/pciexp.h>
#include <drivers/ipmi/ipmi_ops.h>
#include <drivers/ocp/dmi/ocp_dmi.h>
#include <drivers/vpd/vpd.h>
@@ -24,7 +22,6 @@
#include <stdio.h>
#include <string.h>
#include <types.h>
-
#include "ipmi.h"
#include "vpd.h"
@@ -186,8 +183,6 @@ static int create_smbios_type9(int *handle, unsigned long *current)
uint8_t slot_usage;
uint8_t pcie_config = 0;
struct device *slot_dev;
- unsigned int cap;
- uint16_t sltcap;
if (ipmi_get_pcie_config(&pcie_config) != CB_SUCCESS)
printk(BIOS_ERR, "Failed to get IPMI PCIe config\n");
@@ -250,9 +245,7 @@ static int create_smbios_type9(int *handle, unsigned long *current)
characteristics_2 |= SMBIOS_SLOT_PME; // PmeSiganalSupported
/* Read IIO root port device CSR for slot capabilities */
- cap = pci_find_capability(slot_dev, PCI_CAP_ID_PCIE);
- sltcap = pci_read_config16(slot_dev, cap + PCI_EXP_SLTCAP);
- if (sltcap & PCI_EXP_SLTCAP_HPC)
+ if (CONFIG(PCIEXP_PLUGIN_SUPPORT) && pciexp_dev_is_slot_hot_plug_cap(slot_dev))
characteristics_2 |= SMBIOS_SLOT_HOTPLUG;
const uint16_t slot_id = index + 1;
diff --git a/src/soc/intel/xeon_sp/pcie_root_port.c b/src/soc/intel/xeon_sp/pcie_root_port.c
index 6ecbcecb59..8085b3e437 100644
--- a/src/soc/intel/xeon_sp/pcie_root_port.c
+++ b/src/soc/intel/xeon_sp/pcie_root_port.c
@@ -19,14 +19,9 @@ static const char *pcie_device_get_acpi_name(const struct device *dev)
static void soc_pciexp_scan_bridge(struct device *dev)
{
- if (CONFIG(PCIEXP_HOTPLUG)) {
- unsigned int pciexpos = pci_find_capability(dev, PCI_CAP_ID_PCIE);
- u16 sltcap = pci_read_config16(dev, pciexpos + PCI_EXP_SLTCAP);
- if (sltcap & PCI_EXP_SLTCAP_HPC) {
- pciexp_hotplug_scan_bridge(dev);
- return;
- }
- } else
+ if (CONFIG(PCIEXP_HOTPLUG) && pciexp_dev_is_slot_hot_plug_cap(dev))
+ pciexp_hotplug_scan_bridge(dev);
+ else
pciexp_scan_bridge(dev);
}