bcm53xx: update patches adding bcma support
[openwrt/staging/yousong.git] / target / linux / bcm53xx / patches-3.14 / 121-bcma-get-irqs-from-dt.patch
1 From 6611afa6c49434780096cdf2c1028f0ac277f9bc 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 v3 2/2] bcma: get IRQ numbers from dt
5
6 It is not possible to auto detect the irq numbers used by the cores on
7 an arm SoC. If bcma was registered with device tree it will search for
8 some device tree nodes with the irq number and add it to the core
9 configuration.
10
11 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
12 ---
13 drivers/bcma/main.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++-
14 1 file changed, 48 insertions(+), 1 deletion(-)
15
16 --- a/drivers/bcma/main.c
17 +++ b/drivers/bcma/main.c
18 @@ -10,6 +10,8 @@
19 #include <linux/platform_device.h>
20 #include <linux/bcma/bcma.h>
21 #include <linux/slab.h>
22 +#include <linux/of_irq.h>
23 +#include <linux/of_address.h>
24
25 MODULE_DESCRIPTION("Broadcom's specific AMBA driver");
26 MODULE_LICENSE("GPL");
27 @@ -131,6 +133,45 @@ static bool bcma_is_core_needed_early(u1
28 return false;
29 }
30
31 +#ifdef CONFIG_OF
32 +static struct device_node *bcma_of_find_child_device(struct platform_device *parent,
33 + struct bcma_device *core)
34 +{
35 + struct device_node *node;
36 + u64 size;
37 + const __be32 *reg;
38 +
39 + if (!parent || !parent->dev.of_node)
40 + return NULL;
41 +
42 + for_each_child_of_node(parent->dev.of_node, node) {
43 + reg = of_get_address(node, 0, &size, NULL);
44 + if (!reg)
45 + continue;
46 + if (of_translate_address(node, reg) == core->addr)
47 + return node;
48 + }
49 + return NULL;
50 +}
51 +
52 +static void bcma_of_fill_device(struct platform_device *parent,
53 + struct bcma_device *core)
54 +{
55 + struct device_node *node;
56 +
57 + node = bcma_of_find_child_device(parent, core);
58 + if (!node)
59 + return;
60 + core->dev.of_node = node;
61 + core->irq = irq_of_parse_and_map(node, 0);
62 +}
63 +#else
64 +static void bcma_of_fill_device(struct platform_device *parent,
65 + struct bcma_device *core)
66 +{
67 +}
68 +#endif /* CONFIG_OF */
69 +
70 static void bcma_register_core(struct bcma_bus *bus, struct bcma_device *core)
71 {
72 int err;
73 @@ -147,7 +188,13 @@ static void bcma_register_core(struct bc
74 break;
75 case BCMA_HOSTTYPE_SOC:
76 core->dev.dma_mask = &core->dev.coherent_dma_mask;
77 - core->dma_dev = &core->dev;
78 + if (bus->host_pdev) {
79 + core->dma_dev = &bus->host_pdev->dev;
80 + core->dev.parent = &bus->host_pdev->dev;
81 + bcma_of_fill_device(bus->host_pdev, core);
82 + } else {
83 + core->dma_dev = &core->dev;
84 + }
85 break;
86 case BCMA_HOSTTYPE_SDIO:
87 break;