device/pciexp: Add hot-plug capable helper function
Add and use a new helper function to determine if a device is 1) a PCIe device 2) it's mark hot-plug capable Change-Id: I61cc013844024b43808cd2f054310cb6676ba69e Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/84792 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Shuo Liu <shuo.liu@intel.com>
This commit is contained in:
parent
407799f879
commit
5d6355efcf
4 changed files with 27 additions and 17 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue