kernel: update bcma and ssb to version master-2014-07-22
[15.05/openwrt.git] / target / linux / bcm53xx / patches-3.10 / 112-bcma-get-irqs-from-dt.patch
1 From 06a21484198df9a4d34fe5062878d3bf4fc14340 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 7/8] bcma: get irqs from dt
5
6 ---
7  drivers/bcma/main.c |   42 +++++++++++++++++++++++++++++++++++++++++-
8  1 file changed, 41 insertions(+), 1 deletion(-)
9
10 --- a/drivers/bcma/main.c
11 +++ b/drivers/bcma/main.c
12 @@ -10,6 +10,8 @@
13  #include <linux/platform_device.h>
14  #include <linux/bcma/bcma.h>
15  #include <linux/slab.h>
16 +#include <linux/of_irq.h>
17 +#include <linux/of_address.h>
18  
19  MODULE_DESCRIPTION("Broadcom's specific AMBA driver");
20  MODULE_LICENSE("GPL");
21 @@ -111,6 +113,38 @@ static void bcma_release_core_dev(struct
22         kfree(core);
23  }
24  
25 +static struct device_node *bcma_of_find_child_device(struct platform_device *parent,
26 +                                                    struct bcma_device *core)
27 +{
28 +       struct device_node *node;
29 +       u64 size;
30 +       const __be32 *reg;
31 +
32 +       if (!parent || !parent->dev.of_node)
33 +               return NULL;
34 +
35 +       for_each_child_of_node(parent->dev.of_node, node) {
36 +               reg = of_get_address(node, 0, &size, 0);
37 +               if (!reg)
38 +                       continue;
39 +               if (be32_to_cpup(reg) == core->addr)
40 +                       return node;
41 +       }
42 +       return NULL;
43 +}
44 +
45 +static void bcma_of_fill_device(struct platform_device *parent,
46 +                               struct bcma_device *core)
47 +{
48 +       struct device_node *node;
49 +
50 +       node = bcma_of_find_child_device(parent, core);
51 +       if (!node)
52 +               return;
53 +       core->dev.of_node = node;
54 +       core->irq = irq_of_parse_and_map(node, 0);
55 +}
56 +
57  static int bcma_register_cores(struct bcma_bus *bus)
58  {
59         struct bcma_device *core;
60 @@ -146,7 +180,13 @@ static int bcma_register_cores(struct bc
61                         break;
62                 case BCMA_HOSTTYPE_SOC:
63                         core->dev.dma_mask = &core->dev.coherent_dma_mask;
64 -                       core->dma_dev = &core->dev;
65 +                       if (bus->host_pdev) {
66 +                               core->dma_dev = &bus->host_pdev->dev;
67 +                               core->dev.parent = &bus->host_pdev->dev;
68 +                               bcma_of_fill_device(bus->host_pdev, core);
69 +                       } else {
70 +                               core->dma_dev = &core->dev;
71 +                       }
72                         break;
73                 case BCMA_HOSTTYPE_SDIO:
74                         break;