diff options
author | Patrick Rudolph <patrick.rudolph@9elements.com> | 2024-10-16 12:14:06 +0200 |
---|---|---|
committer | Lean Sheng Tan <sheng.tan@9elements.com> | 2024-10-23 11:49:30 +0000 |
commit | 5d6355efcfc4ae1840574a5545fdbd74a16b6c6e (patch) | |
tree | b40742e7c76f6651de2e6f6bbc6aef7bdd4cd283 /src/device | |
parent | 407799f8792cb1cc8b3beedee2418df2b53f14fb (diff) |
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>
Diffstat (limited to 'src/device')
-rw-r--r-- | src/device/pciexp_device.c | 20 |
1 files changed, 20 insertions, 0 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; |