diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/device/pci_device.c | 24 | ||||
-rw-r--r-- | src/include/device/pci.h | 1 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/device/pci_device.c b/src/device/pci_device.c index fda088b020..44c47a7548 100644 --- a/src/device/pci_device.c +++ b/src/device/pci_device.c @@ -6,6 +6,7 @@ */ #include <acpi/acpi.h> +#include <assert.h> #include <device/pci_ops.h> #include <bootmode.h> #include <console/console.h> @@ -1299,6 +1300,29 @@ unsigned int pci_match_simple_dev(struct device *dev, pci_devfn_t sdev) } /** + * Test whether a capability is available along the whole path from the given + * device to the host bridge. + * + * @param dev Pointer to the device structure. + * @param cap PCI_CAP_LIST_ID of the PCI capability we're looking for. + * @return The next matching capability of the given device, if it is available + * along the whole path, or zero if not. + */ +uint16_t pci_find_cap_recursive(const struct device *dev, uint16_t cap) +{ + assert(dev->bus); + uint16_t pos = pci_find_capability(dev, cap); + const struct device *bridge = dev->bus->dev; + while (bridge && (bridge->path.type == DEVICE_PATH_PCI)) { + assert(bridge->bus); + if (!pci_find_capability(bridge, cap)) + return 0; + bridge = bridge->bus->dev; + } + return pos; +} + +/** * PCI devices that are marked as "hidden" do not get probed. However, the same * initialization logic is still performed as if it were. This is useful when * devices would like to be described in the devicetree.cb file, and/or present diff --git a/src/include/device/pci.h b/src/include/device/pci.h index f2e250631e..f28f319d8c 100644 --- a/src/include/device/pci.h +++ b/src/include/device/pci.h @@ -97,6 +97,7 @@ void pci_dev_set_subsystem(struct device *dev, unsigned int vendor, unsigned int device); void pci_dev_init(struct device *dev); unsigned int pci_match_simple_dev(struct device *dev, pci_devfn_t sdev); +uint16_t pci_find_cap_recursive(const struct device *dev, uint16_t cap); const char *pin_to_str(int pin); int get_pci_irq_pins(struct device *dev, struct device **parent_bdg); |