@@ -301,6 +301,23 @@ int pci_get_host_bridge_segment(const struct dt_device_node *node,
return -EINVAL;
}
+/*
+ * Get host bridge node given a device attached to it.
+ */
+struct dt_device_node *pci_find_host_bridge_node(struct device *dev)
+{
+ struct pci_host_bridge *bridge;
+ struct pci_dev *pdev = dev_to_pci(dev);
+
+ bridge = pci_find_host_bridge(pdev->seg, pdev->bus);
+ if ( unlikely(!bridge) )
+ {
+ printk(XENLOG_ERR "Unable to find PCI bridge for "PRI_pci"\n",
+ pdev->seg, pdev->bus, pdev->sbdf.dev, pdev->sbdf.fn);
+ return NULL;
+ }
+ return bridge->dt_node;
+}
/*
* Local variables:
* mode: C
@@ -105,6 +105,7 @@ void __iomem *pci_ecam_map_bus(struct pci_host_bridge *bridge,
struct pci_host_bridge *pci_find_host_bridge(uint16_t segment, uint8_t bus);
int pci_get_host_bridge_segment(const struct dt_device_node *node,
uint16_t *segment);
+struct dt_device_node *pci_find_host_bridge_node(struct device *dev);
#else /*!CONFIG_HAS_PCI*/