123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- #include <linux/irqdomain.h>
- #include <linux/kernel.h>
- #include <linux/pci.h>
- #include <linux/of.h>
- #include <linux/of_irq.h>
- #include <linux/of_pci.h>
- #include "pci.h"
- void pci_set_of_node(struct pci_dev *dev)
- {
- if (!dev->bus->dev.of_node)
- return;
- dev->dev.of_node = of_pci_find_child_device(dev->bus->dev.of_node,
- dev->devfn);
- }
- void pci_release_of_node(struct pci_dev *dev)
- {
- of_node_put(dev->dev.of_node);
- dev->dev.of_node = NULL;
- }
- void pci_set_bus_of_node(struct pci_bus *bus)
- {
- if (bus->self == NULL)
- bus->dev.of_node = pcibios_get_phb_of_node(bus);
- else
- bus->dev.of_node = of_node_get(bus->self->dev.of_node);
- }
- void pci_release_bus_of_node(struct pci_bus *bus)
- {
- of_node_put(bus->dev.of_node);
- bus->dev.of_node = NULL;
- }
- struct device_node * __weak pcibios_get_phb_of_node(struct pci_bus *bus)
- {
-
- if (WARN_ON(bus->self || bus->parent))
- return NULL;
-
- if (bus->bridge->of_node)
- return of_node_get(bus->bridge->of_node);
- if (bus->bridge->parent && bus->bridge->parent->of_node)
- return of_node_get(bus->bridge->parent->of_node);
- return NULL;
- }
- struct irq_domain *pci_host_bridge_of_msi_domain(struct pci_bus *bus)
- {
- #ifdef CONFIG_IRQ_DOMAIN
- struct irq_domain *d;
- if (!bus->dev.of_node)
- return NULL;
-
- d = of_msi_get_domain(&bus->dev, bus->dev.of_node, DOMAIN_BUS_PCI_MSI);
- if (d)
- return d;
-
- d = irq_find_matching_host(bus->dev.of_node, DOMAIN_BUS_PCI_MSI);
- if (d)
- return d;
- return irq_find_host(bus->dev.of_node);
- #else
- return NULL;
- #endif
- }
|