diff options
author | Kyösti Mälkki <kyosti.malkki@gmail.com> | 2019-07-04 07:16:59 +0300 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2019-07-12 08:52:50 +0000 |
commit | ab275f0915f2ba8abffed8f1384aa5353287c5ba (patch) | |
tree | f3f905967e412ec0db2add1f6863a8bbe1db92ba /src/device/device_const.c | |
parent | c19d6a6ce59873f2326b14bb4af69048cceb9300 (diff) | |
download | coreboot-ab275f0915f2ba8abffed8f1384aa5353287c5ba.tar.xz |
device/pci: Declare pcidev_path_on_bus()
It is recommended to never reference PCI busses
using a static number. There is exception with
OPROM execution, where we want to translate the
bus number captured from the actual IO operation
into a matching device node in the devicetree.
Change-Id: I733c645ac5581c000b4cd6cdc05829cd039324d5
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/34077
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Diffstat (limited to 'src/device/device_const.c')
-rw-r--r-- | src/device/device_const.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/device/device_const.c b/src/device/device_const.c index 1853b4c4d2..c1b0b063ff 100644 --- a/src/device/device_const.c +++ b/src/device/device_const.c @@ -183,6 +183,24 @@ DEVTREE_CONST struct device *pcidev_path_behind( return find_dev_path(parent, &path); } +DEVTREE_CONST struct device *pcidev_path_on_bus(unsigned int bus, pci_devfn_t devfn) +{ + DEVTREE_CONST struct bus *parent = pci_root_bus(); + DEVTREE_CONST struct device *dev = parent->children; + + /* FIXME: Write the loop with topology links. */ + while (dev) { + if (dev->path.type != DEVICE_PATH_PCI) { + dev = dev->next; + continue; + } + if (dev->bus->secondary == bus) + return pcidev_path_behind(dev->bus, devfn); + dev = dev->next; + } + return NULL; +} + DEVTREE_CONST struct bus *pci_root_bus(void) { DEVTREE_CONST struct device *pci_domain; |