summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@google.com>2020-04-16 08:25:58 -0700
committerFurquan Shaikh <furquan@google.com>2020-04-22 18:02:00 +0000
commit7778e5c55fbf1399a7d80aac38890a8351fcc573 (patch)
tree452f4315a2fe12f4f9f7d76d6fbf0e93711c9f62 /src
parent86803784d3a459170a1e73dfbd1ecdcfc0d853d5 (diff)
downloadcoreboot-7778e5c55fbf1399a7d80aac38890a8351fcc573.tar.xz
device: Add a helper to find device behind a PCI-to-PCI bridge device
This change adds a helper function to find PCI device with dev# and function# behind a PCI-to-PCI bridge device. BUG=b:153858769 BRANCH=None TEST=None Signed-off-by: Furquan Shaikh <furquan@google.com> Change-Id: Ie5672b35cda66431a0f1977f217bdf61d3012ace Reviewed-on: https://review.coreboot.org/c/coreboot/+/40474 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src')
-rw-r--r--src/device/device_const.c13
-rw-r--r--src/include/device/device.h4
2 files changed, 17 insertions, 0 deletions
diff --git a/src/device/device_const.c b/src/device/device_const.c
index 2e0ccc4c3b..de404dc0d1 100644
--- a/src/device/device_const.c
+++ b/src/device/device_const.c
@@ -232,6 +232,19 @@ DEVTREE_CONST struct device *pcidev_on_root(uint8_t dev, uint8_t fn)
return pcidev_path_on_root(PCI_DEVFN(dev, fn));
}
+DEVTREE_CONST struct device *pcidev_path_behind_pci2pci_bridge(
+ const struct device *bridge,
+ pci_devfn_t devfn)
+{
+ if (!bridge || (bridge->path.type != DEVICE_PATH_PCI)) {
+ assert(0);
+ /* Return NULL in case asserts are non-fatal. */
+ return NULL;
+ }
+
+ return pcidev_path_behind(bridge->link_list, devfn);
+}
+
DEVTREE_CONST struct device *pcidev_path_on_root_debug(pci_devfn_t devfn, const char *func)
{
DEVTREE_CONST struct device *dev = pcidev_path_on_root(devfn);
diff --git a/src/include/device/device.h b/src/include/device/device.h
index 4e9c594bc0..a33702a234 100644
--- a/src/include/device/device.h
+++ b/src/include/device/device.h
@@ -293,6 +293,10 @@ DEVTREE_CONST struct device *pcidev_path_on_root(pci_devfn_t devfn);
DEVTREE_CONST struct device *pcidev_path_on_bus(unsigned int bus, pci_devfn_t devfn);
DEVTREE_CONST struct device *pcidev_on_root(uint8_t dev, uint8_t fn);
DEVTREE_CONST struct bus *pci_root_bus(void);
+/* Find PCI device with given D#:F# sitting behind the given PCI-to-PCI bridge device. */
+DEVTREE_CONST struct device *pcidev_path_behind_pci2pci_bridge(
+ const struct device *bridge,
+ pci_devfn_t devfn);
/* To be deprecated, avoid using.
*