fe44827082a8f2f0f625a340bb9ebbc7794b696f
[openwrt/staging/chunkeey.git] / target / linux / bcm53xx / patches-3.14 / 111-bcma-register-bcma-as-device-tree-driver.patch
1 From c046c19fc8f1af7cf253fea5b0253143c159948a Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Mon, 6 Jan 2014 23:29:15 +0100
4 Subject: [PATCH 6/8] 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 | 70 +++++++++++++++++++++++++++++++++++++++++++++
12 include/linux/bcma/bcma.h | 2 ++
13 2 files changed, 72 insertions(+)
14
15 --- a/drivers/bcma/host_soc.c
16 +++ b/drivers/bcma/host_soc.c
17 @@ -7,6 +7,9 @@
18
19 #include "bcma_private.h"
20 #include "scan.h"
21 +#include <linux/slab.h>
22 +#include <linux/module.h>
23 +#include <linux/of_address.h>
24 #include <linux/bcma/bcma.h>
25 #include <linux/bcma/bcma_soc.h>
26
27 @@ -173,6 +176,7 @@ int __init bcma_host_soc_register(struct
28 /* Host specific */
29 bus->hosttype = BCMA_HOSTTYPE_SOC;
30 bus->ops = &bcma_host_soc_ops;
31 + bus->host_pdev = NULL;
32
33 /* Register */
34 err = bcma_bus_early_register(bus, &soc->core_cc, &soc->core_mips);
35 @@ -181,3 +185,69 @@ int __init bcma_host_soc_register(struct
36
37 return err;
38 }
39 +
40 +#ifdef CONFIG_OF
41 +static int bcma_host_soc_probe(struct platform_device *pdev)
42 +{
43 + struct device *dev = &pdev->dev;
44 + struct device_node *np = dev->of_node;
45 + struct bcma_bus *bus;
46 + int err;
47 +
48 + /* Alloc */
49 + bus = devm_kzalloc(dev, sizeof(*bus), GFP_KERNEL);
50 + if (!bus)
51 + return -ENOMEM;
52 +
53 + /* Map MMIO */
54 + bus->mmio = of_iomap(np, 0);
55 + if (!bus->mmio)
56 + return -ENOMEM;
57 +
58 + /* Host specific */
59 + bus->hosttype = BCMA_HOSTTYPE_SOC;
60 + bus->ops = &bcma_host_soc_ops;
61 + bus->host_pdev = pdev;
62 +
63 + /* Register */
64 + err = bcma_bus_register(bus);
65 + if (err)
66 + goto err_unmap_mmio;
67 +
68 + platform_set_drvdata(pdev, bus);
69 +
70 + return err;
71 +
72 +err_unmap_mmio:
73 + iounmap(bus->mmio);
74 + return err;
75 +}
76 +
77 +static int bcma_host_soc_remove(struct platform_device *pdev)
78 +{
79 + struct bcma_bus *bus = platform_get_drvdata(pdev);
80 +
81 + bcma_bus_unregister(bus);
82 + iounmap(bus->mmio);
83 + platform_set_drvdata(pdev, NULL);
84 +
85 + return 0;
86 +}
87 +
88 +static const struct of_device_id bcma_host_soc_of_match[] = {
89 + { .compatible = "brcm,bus-aix", },
90 + {},
91 +};
92 +MODULE_DEVICE_TABLE(of, bcma_host_soc_of_match);
93 +
94 +static struct platform_driver bcma_host_soc_driver = {
95 + .driver = {
96 + .name = "bcma-host-soc",
97 + .owner = THIS_MODULE,
98 + .of_match_table = bcma_host_soc_of_match,
99 + },
100 + .probe = bcma_host_soc_probe,
101 + .remove = bcma_host_soc_remove,
102 +};
103 +module_platform_driver(bcma_host_soc_driver);
104 +#endif /* CONFIG_OF */
105 --- a/include/linux/bcma/bcma.h
106 +++ b/include/linux/bcma/bcma.h
107 @@ -319,6 +319,8 @@ struct bcma_bus {
108 struct pci_dev *host_pci;
109 /* Pointer to the SDIO device (only for BCMA_HOSTTYPE_SDIO) */
110 struct sdio_func *host_sdio;
111 + /* Pointer to platform device (only for BCMA_HOSTTYPE_SOC) */
112 + struct platform_device *host_pdev;
113 };
114
115 struct bcma_chipinfo chipinfo;