aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/of/of_pci.c
diff options
context:
space:
mode:
authorThomas Petazzoni <thomas.petazzoni@free-electrons.com>2013-08-09 16:27:09 -0400
committerJason Cooper <jason@lakedaemon.net>2013-08-12 11:27:01 -0400
commit0d5a6db3aa46faafd0212650bfd709d51240d9da (patch)
treedea9d680f4ae8aea5628ec8d69b72802f0a4bf28 /drivers/of/of_pci.c
parent0cbdcfcf427b63b9670e56760ef5e67cd7081b35 (diff)
of: pci: add registry of MSI chips
This commit adds a very basic registry of msi_chip structures, so that an IRQ controller driver can register an msi_chip, and a PCIe host controller can find it, based on a 'struct device_node'. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Acked-by: Rob Herring <rob.herring@calxeda.com> Signed-off-by: Jason Cooper <jason@lakedaemon.net>
Diffstat (limited to 'drivers/of/of_pci.c')
-rw-r--r--drivers/of/of_pci.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/drivers/of/of_pci.c b/drivers/of/of_pci.c
index 42c687a820ac..e5ca00893c0c 100644
--- a/drivers/of/of_pci.c
+++ b/drivers/of/of_pci.c
@@ -89,3 +89,48 @@ int of_pci_parse_bus_range(struct device_node *node, struct resource *res)
89 return 0; 89 return 0;
90} 90}
91EXPORT_SYMBOL_GPL(of_pci_parse_bus_range); 91EXPORT_SYMBOL_GPL(of_pci_parse_bus_range);
92
93#ifdef CONFIG_PCI_MSI
94
95static LIST_HEAD(of_pci_msi_chip_list);
96static DEFINE_MUTEX(of_pci_msi_chip_mutex);
97
98int of_pci_msi_chip_add(struct msi_chip *chip)
99{
100 if (!of_property_read_bool(chip->of_node, "msi-controller"))
101 return -EINVAL;
102
103 mutex_lock(&of_pci_msi_chip_mutex);
104 list_add(&chip->list, &of_pci_msi_chip_list);
105 mutex_unlock(&of_pci_msi_chip_mutex);
106
107 return 0;
108}
109EXPORT_SYMBOL_GPL(of_pci_msi_chip_add);
110
111void of_pci_msi_chip_remove(struct msi_chip *chip)
112{
113 mutex_lock(&of_pci_msi_chip_mutex);
114 list_del(&chip->list);
115 mutex_unlock(&of_pci_msi_chip_mutex);
116}
117EXPORT_SYMBOL_GPL(of_pci_msi_chip_remove);
118
119struct msi_chip *of_pci_find_msi_chip_by_node(struct device_node *of_node)
120{
121 struct msi_chip *c;
122
123 mutex_lock(&of_pci_msi_chip_mutex);
124 list_for_each_entry(c, &of_pci_msi_chip_list, list) {
125 if (c->of_node == of_node) {
126 mutex_unlock(&of_pci_msi_chip_mutex);
127 return c;
128 }
129 }
130 mutex_unlock(&of_pci_msi_chip_mutex);
131
132 return NULL;
133}
134EXPORT_SYMBOL_GPL(of_pci_find_msi_chip_by_node);
135
136#endif /* CONFIG_PCI_MSI */