aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/bcma
diff options
context:
space:
mode:
authorHauke Mehrtens <hauke@hauke-m.de>2014-11-01 11:54:56 -0400
committerJohn W. Linville <linville@tuxdriver.com>2014-11-11 16:31:11 -0500
commit71783576b5345d63df048c0f18974037eea6e4f9 (patch)
treea0f6b1c35b415172b6b525276bef359246786b77 /drivers/bcma
parent85eb92e81801d64686eb78928d500a4c83ee9623 (diff)
bcma: get IRQ numbers from dt
It is not possible to auto detect the irq numbers used by the cores on an arm SoC. If bcma was registered with device tree it will search for some device tree nodes with the irq number and add it to the core configuration. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/bcma')
-rw-r--r--drivers/bcma/main.c52
1 files changed, 51 insertions, 1 deletions
diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c
index 6d1cf5701452..122086ef9fe1 100644
--- a/drivers/bcma/main.c
+++ b/drivers/bcma/main.c
@@ -11,6 +11,7 @@
11#include <linux/bcma/bcma.h> 11#include <linux/bcma/bcma.h>
12#include <linux/slab.h> 12#include <linux/slab.h>
13#include <linux/of_address.h> 13#include <linux/of_address.h>
14#include <linux/of_irq.h>
14 15
15MODULE_DESCRIPTION("Broadcom's specific AMBA driver"); 16MODULE_DESCRIPTION("Broadcom's specific AMBA driver");
16MODULE_LICENSE("GPL"); 17MODULE_LICENSE("GPL");
@@ -153,6 +154,46 @@ static struct device_node *bcma_of_find_child_device(struct platform_device *par
153 return NULL; 154 return NULL;
154} 155}
155 156
157static int bcma_of_irq_parse(struct platform_device *parent,
158 struct bcma_device *core,
159 struct of_phandle_args *out_irq, int num)
160{
161 __be32 laddr[1];
162 int rc;
163
164 if (core->dev.of_node) {
165 rc = of_irq_parse_one(core->dev.of_node, num, out_irq);
166 if (!rc)
167 return rc;
168 }
169
170 out_irq->np = parent->dev.of_node;
171 out_irq->args_count = 1;
172 out_irq->args[0] = num;
173
174 laddr[0] = cpu_to_be32(core->addr);
175 return of_irq_parse_raw(laddr, out_irq);
176}
177
178static unsigned int bcma_of_get_irq(struct platform_device *parent,
179 struct bcma_device *core, int num)
180{
181 struct of_phandle_args out_irq;
182 int ret;
183
184 if (!parent || !parent->dev.of_node)
185 return 0;
186
187 ret = bcma_of_irq_parse(parent, core, &out_irq, num);
188 if (ret) {
189 bcma_debug(core->bus, "bcma_of_get_irq() failed with rc=%d\n",
190 ret);
191 return 0;
192 }
193
194 return irq_create_of_mapping(&out_irq);
195}
196
156static void bcma_of_fill_device(struct platform_device *parent, 197static void bcma_of_fill_device(struct platform_device *parent,
157 struct bcma_device *core) 198 struct bcma_device *core)
158{ 199{
@@ -161,12 +202,19 @@ static void bcma_of_fill_device(struct platform_device *parent,
161 node = bcma_of_find_child_device(parent, core); 202 node = bcma_of_find_child_device(parent, core);
162 if (node) 203 if (node)
163 core->dev.of_node = node; 204 core->dev.of_node = node;
205
206 core->irq = bcma_of_get_irq(parent, core, 0);
164} 207}
165#else 208#else
166static void bcma_of_fill_device(struct platform_device *parent, 209static void bcma_of_fill_device(struct platform_device *parent,
167 struct bcma_device *core) 210 struct bcma_device *core)
168{ 211{
169} 212}
213static inline unsigned int bcma_of_get_irq(struct platform_device *parent,
214 struct bcma_device *core, int num)
215{
216 return 0;
217}
170#endif /* CONFIG_OF */ 218#endif /* CONFIG_OF */
171 219
172unsigned int bcma_core_irq(struct bcma_device *core, int num) 220unsigned int bcma_core_irq(struct bcma_device *core, int num)
@@ -182,7 +230,9 @@ unsigned int bcma_core_irq(struct bcma_device *core, int num)
182 mips_irq = bcma_core_mips_irq(core); 230 mips_irq = bcma_core_mips_irq(core);
183 return mips_irq <= 4 ? mips_irq + 2 : 0; 231 return mips_irq <= 4 ? mips_irq + 2 : 0;
184 } 232 }
185 break; 233 if (bus->host_pdev)
234 return bcma_of_get_irq(bus->host_pdev, core, num);
235 return 0;
186 case BCMA_HOSTTYPE_SDIO: 236 case BCMA_HOSTTYPE_SDIO:
187 return 0; 237 return 0;
188 } 238 }