bcm53xx: add support for the PCIe controller
[openwrt/svn-archive/archive.git] / target / linux / bcm53xx / patches-3.14 / 121-bcma-get-irqs-from-dt.patch
1 From 3e59da41882a408064cd23f4c9124a7938bdb91f Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Thu, 9 Jan 2014 19:40:14 +0100
4 Subject: [PATCH 06/15] bcma: get irqs from dt
5
6 If bcma was registered with device tree it will search for some nodes
7 with the irq number and add it to the core configuration.
8 ---
9 drivers/bcma/main.c | 42 +++++++++++++++++++++++++++++++++++++++++-
10 1 file changed, 41 insertions(+), 1 deletion(-)
11
12 --- a/drivers/bcma/main.c
13 +++ b/drivers/bcma/main.c
14 @@ -10,6 +10,8 @@
15 #include <linux/platform_device.h>
16 #include <linux/bcma/bcma.h>
17 #include <linux/slab.h>
18 +#include <linux/of_irq.h>
19 +#include <linux/of_address.h>
20
21 MODULE_DESCRIPTION("Broadcom's specific AMBA driver");
22 MODULE_LICENSE("GPL");
23 @@ -120,6 +122,38 @@ static void bcma_release_core_dev(struct
24 kfree(core);
25 }
26
27 +static struct device_node *bcma_of_find_child_device(struct platform_device *parent,
28 + struct bcma_device *core)
29 +{
30 + struct device_node *node;
31 + u64 size;
32 + const __be32 *reg;
33 +
34 + if (!parent || !parent->dev.of_node)
35 + return NULL;
36 +
37 + for_each_child_of_node(parent->dev.of_node, node) {
38 + reg = of_get_address(node, 0, &size, 0);
39 + if (!reg)
40 + continue;
41 + if (be32_to_cpup(reg) == core->addr)
42 + return node;
43 + }
44 + return NULL;
45 +}
46 +
47 +static void bcma_of_fill_device(struct platform_device *parent,
48 + struct bcma_device *core)
49 +{
50 + struct device_node *node;
51 +
52 + node = bcma_of_find_child_device(parent, core);
53 + if (!node)
54 + return;
55 + core->dev.of_node = node;
56 + core->irq = irq_of_parse_and_map(node, 0);
57 +}
58 +
59 static int bcma_register_cores(struct bcma_bus *bus)
60 {
61 struct bcma_device *core;
62 @@ -154,7 +188,13 @@ static int bcma_register_cores(struct bc
63 break;
64 case BCMA_HOSTTYPE_SOC:
65 core->dev.dma_mask = &core->dev.coherent_dma_mask;
66 - core->dma_dev = &core->dev;
67 + if (bus->host_pdev) {
68 + core->dma_dev = &bus->host_pdev->dev;
69 + core->dev.parent = &bus->host_pdev->dev;
70 + bcma_of_fill_device(bus->host_pdev, core);
71 + } else {
72 + core->dma_dev = &core->dev;
73 + }
74 break;
75 case BCMA_HOSTTYPE_SDIO:
76 break;