summaryrefslogtreecommitdiff
path: root/src/device/pci_early.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/device/pci_early.c')
-rw-r--r--src/device/pci_early.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/device/pci_early.c b/src/device/pci_early.c
index 9086e64b85..ea2ebd5033 100644
--- a/src/device/pci_early.c
+++ b/src/device/pci_early.c
@@ -165,3 +165,34 @@ void pci_early_bridge_init(void)
pci_early_mmio_window(p2p_bridge, CONFIG_EARLY_PCI_MMIO_BASE, 0x4000);
}
+
+/* FIXME: A lot of issues using the following, please avoid.
+ * Assumes 256 PCI busses, scans them all even when PCI bridges are still
+ * disabled. Probes all functions even if 0 is not present.
+ */
+pci_devfn_t pci_locate_device(unsigned int pci_id, pci_devfn_t dev)
+{
+ for (; dev <= PCI_DEV(255, 31, 7); dev += PCI_DEV(0, 0, 1)) {
+ unsigned int id;
+ id = pci_read_config32(dev, 0);
+ if (id == pci_id)
+ return dev;
+ }
+ return PCI_DEV_INVALID;
+}
+
+pci_devfn_t pci_locate_device_on_bus(unsigned int pci_id, unsigned int bus)
+{
+ pci_devfn_t dev, last;
+
+ dev = PCI_DEV(bus, 0, 0);
+ last = PCI_DEV(bus, 31, 7);
+
+ for (; dev <= last; dev += PCI_DEV(0, 0, 1)) {
+ unsigned int id;
+ id = pci_read_config32(dev, 0);
+ if (id == pci_id)
+ return dev;
+ }
+ return PCI_DEV_INVALID;
+}