From ad7674ed00a810b472b2f66b3f5b2e0edbea02de Mon Sep 17 00:00:00 2001 From: Kyösti Mälkki Date: Sun, 20 May 2018 10:31:23 +0300 Subject: device: Introduce pcidev_on_root() and friends MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Semantics of dev_find_slot() are ill in the sense that it only works after device enumeration has completed in ramstage. Plan is to declare it as deprecated. Introduce pcidev_on_root() and pcidev_path_on_root() functions to replace cases where this was called with static argument bus == 0. New implementation only walks the root bus of the PCI tree, while old one walked the entire linked list of devices. Introduce pcidev_path_behind() to replace cases where argument bus != 0. The required parent node is typically one of the PCIe root functions that you locate using pcidev_on_root() above. New forms are safe to use with early devicetree and before PCI bus numbers have been assigned. Change-Id: Ie20598d48b4cf6e35e45fc90804bad4728437fc6 Signed-off-by: Kyösti Mälkki Reviewed-on: https://review.coreboot.org/c/26447 Tested-by: build bot (Jenkins) Reviewed-by: Werner Zeh --- src/include/device/device.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/include') diff --git a/src/include/device/device.h b/src/include/device/device.h index 5e539ea339..540b7e3899 100644 --- a/src/include/device/device.h +++ b/src/include/device/device.h @@ -276,6 +276,11 @@ DEVTREE_CONST struct device *dev_find_slot_pnp(u16 port, u16 device); DEVTREE_CONST struct device *dev_bus_each_child(const struct bus *parent, DEVTREE_CONST struct device *prev_child); +DEVTREE_CONST struct device *pcidev_path_behind(const struct bus *parent, + pci_devfn_t devfn); +DEVTREE_CONST struct device *pcidev_path_on_root(pci_devfn_t devfn); +DEVTREE_CONST struct device *pcidev_on_root(uint8_t dev, uint8_t fn); + void scan_smbus(struct device *bus); void scan_generic_bus(struct device *bus); void scan_static_bus(struct device *bus); -- cgit v1.2.3