summaryrefslogtreecommitdiffstats
path: root/src/device/device_util.c
diff options
context:
space:
mode:
authorPatrick Rudolph <patrick.rudolph@9elements.com>2024-01-19 08:24:36 +0100
committerLean Sheng Tan <sheng.tan@9elements.com>2024-01-24 08:51:07 +0000
commitab6bcd2c1a3e47f3bd1ad5c7f1b984a1b38f6da1 (patch)
tree95db294d1db1e5e540428a7d8c16a110e721409b /src/device/device_util.c
parentf95dbcee713d3a8a081644ee345ce0f6fedf39ac (diff)
downloadcoreboot-ab6bcd2c1a3e47f3bd1ad5c7f1b984a1b38f6da1.tar.gz
coreboot-ab6bcd2c1a3e47f3bd1ad5c7f1b984a1b38f6da1.tar.bz2
coreboot-ab6bcd2c1a3e47f3bd1ad5c7f1b984a1b38f6da1.zip
device/device_util: Add method to retrieve the domain
Add a function to return the PCI domain device for the specified device. On multi PCI domain platforms this function allows to determine which domain and thus which socket the PCI device belongs to. Change-Id: I0068b82e139fe7a35e6b1b91b7d386b750c80748 Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/80090 Reviewed-by: Lean Sheng Tan <sheng.tan@9elements.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
Diffstat (limited to 'src/device/device_util.c')
-rw-r--r--src/device/device_util.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/device/device_util.c b/src/device/device_util.c
index edf053d0dd40..260c9b43eedc 100644
--- a/src/device/device_util.c
+++ b/src/device/device_util.c
@@ -249,6 +249,19 @@ const char *dev_name(const struct device *dev)
return "unknown";
}
+/* Returns the PCI domain for the given PCI device */
+struct device *dev_get_pci_domain(struct device *dev)
+{
+ /* Walk up the tree up to the PCI domain */
+ while (dev && dev->bus && !is_root_device(dev)) {
+ dev = dev->bus->dev;
+ if (dev->path.type == DEVICE_PATH_DOMAIN)
+ return dev;
+ }
+
+ return NULL;
+}
+
/**
* Allocate 64 more resources to the free list.
*