1 From eaf1943a2c49cbc6eb0ffafa7b6ced45f2d328da 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 05/17] bcma: get IRQ numbers from dt
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
11 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
13 drivers/bcma/main.c | 42 +++++++++++++++++++++++++++++++++++++++++-
14 1 file changed, 41 insertions(+), 1 deletion(-)
16 --- a/drivers/bcma/main.c
17 +++ b/drivers/bcma/main.c
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>
25 MODULE_DESCRIPTION("Broadcom's specific AMBA driver");
26 MODULE_LICENSE("GPL");
27 @@ -131,6 +133,38 @@ static bool bcma_is_core_needed_early(u1
31 +static struct device_node *bcma_of_find_child_device(struct platform_device *parent,
32 + struct bcma_device *core)
34 + struct device_node *node;
38 + if (!parent || !parent->dev.of_node)
41 + for_each_child_of_node(parent->dev.of_node, node) {
42 + reg = of_get_address(node, 0, &size, NULL);
45 + if (be32_to_cpup(reg) == core->addr)
51 +static void bcma_of_fill_device(struct platform_device *parent,
52 + struct bcma_device *core)
54 + struct device_node *node;
56 + node = bcma_of_find_child_device(parent, core);
59 + core->dev.of_node = node;
60 + core->irq = irq_of_parse_and_map(node, 0);
63 static void bcma_register_core(struct bcma_bus *bus, struct bcma_device *core)
66 @@ -147,7 +181,13 @@ static void bcma_register_core(struct bc
68 case BCMA_HOSTTYPE_SOC:
69 core->dev.dma_mask = &core->dev.coherent_dma_mask;
70 - core->dma_dev = &core->dev;
71 + if (bus->host_pdev) {
72 + core->dma_dev = &bus->host_pdev->dev;
73 + core->dev.parent = &bus->host_pdev->dev;
74 + bcma_of_fill_device(bus->host_pdev, core);
76 + core->dma_dev = &core->dev;
79 case BCMA_HOSTTYPE_SDIO: