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