bcm53xx: add initial support for ARM based BCM47XX and BCM53XX SoCs
[oweals/openwrt.git] / target / linux / bcm53xx / patches-3.10 / 0009-bcma-register-bcma-as-device-tree-driver.patch
1 From d16de2a4ffeaf62fb3d838365a29b80f330bffe0 Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Thu, 4 Jul 2013 22:26:58 +0200
4 Subject: [PATCH 09/17] bcma: register bcma as device tree driver
5
6 This driver is used by the bcm53xx ARM SoC code.Now it is possible to
7 give the address of the chipcommon core in device tree.
8
9 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
10 ---
11  drivers/bcma/host_soc.c |   73 +++++++++++++++++++++++++++++++++++++++++++++++
12  1 file changed, 73 insertions(+)
13
14 --- a/drivers/bcma/host_soc.c
15 +++ b/drivers/bcma/host_soc.c
16 @@ -7,6 +7,9 @@
17  
18  #include "bcma_private.h"
19  #include "scan.h"
20 +#include <linux/slab.h>
21 +#include <linux/module.h>
22 +#include <linux/of_address.h>
23  #include <linux/bcma/bcma.h>
24  #include <linux/bcma/bcma_soc.h>
25  
26 @@ -181,3 +184,73 @@ int __init bcma_host_soc_register(struct
27  
28         return err;
29  }
30 +
31 +#ifdef CONFIG_OF
32 +static int bcma_host_soc_probe(struct platform_device *pdev)
33 +{
34 +       struct device *dev = &pdev->dev;
35 +       struct device_node *np = dev->of_node;
36 +       struct bcma_bus *bus;
37 +       int err;
38 +
39 +       /* Alloc */
40 +       bus = kzalloc(sizeof(*bus), GFP_KERNEL);
41 +       if (!bus)
42 +               return -ENOMEM;
43 +
44 +       /* Map MMIO */
45 +       err = -ENOMEM;
46 +       bus->mmio = of_iomap(np, 0);
47 +       if (!bus->mmio)
48 +               goto err_kfree_bus;
49 +
50 +       /* Host specific */
51 +       bus->hosttype = BCMA_HOSTTYPE_SOC;
52 +       bus->ops = &bcma_host_soc_ops;
53 +
54 +
55 +       /* Register */
56 +       err = bcma_bus_register(bus);
57 +       if (err)
58 +               goto err_unmap_mmio;
59 +
60 +       platform_set_drvdata(pdev, bus);
61 +
62 +       return err;
63 +
64 +err_unmap_mmio:
65 +       iounmap(bus->mmio);
66 +err_kfree_bus:
67 +       kfree(bus);
68 +       return err;
69 +}
70 +
71 +static int bcma_host_soc_remove(struct platform_device *pdev)
72 +{
73 +       struct bcma_bus *bus = platform_get_drvdata(pdev);
74 +
75 +       bcma_bus_unregister(bus);
76 +       iounmap(bus->mmio);
77 +       kfree(bus);
78 +       platform_set_drvdata(pdev, NULL);
79 +
80 +       return 0;
81 +}
82 +
83 +static const struct of_device_id bcma_host_soc_of_match[] = {
84 +       { .compatible = "brcm,bus-aix", },
85 +       {},
86 +};
87 +MODULE_DEVICE_TABLE(of, bcma_host_soc_of_match);
88 +
89 +static struct platform_driver bcma_host_soc_driver = {
90 +       .driver = {
91 +               .name = "bcma-host-soc",
92 +               .owner = THIS_MODULE,
93 +               .of_match_table = bcma_host_soc_of_match,
94 +       },
95 +       .probe          = bcma_host_soc_probe,
96 +       .remove         = bcma_host_soc_remove,
97 +};
98 +module_platform_driver(bcma_host_soc_driver);
99 +#endif /* CONFIG_OF */