bcm53xx: update bcma device tree intergeneration and fix nvram parsing
[openwrt/svn-archive/archive.git] / target / linux / bcm53xx / patches-3.14 / 120-bcma-register-bcma-as-device-tree-driver.patch
1 From 04b91da96d7c163fd39c0849d2034e2928103f4d 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 04/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 and bcma will
8 search for all the other cores.
9
10 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
11 ---
12 Documentation/devicetree/bindings/bus/bcma.txt | 46 +++++++++++++++++
13 drivers/bcma/host_soc.c | 70 ++++++++++++++++++++++++++
14 include/linux/bcma/bcma.h | 2 +
15 3 files changed, 118 insertions(+)
16 create mode 100644 Documentation/devicetree/bindings/bus/bcma.txt
17
18 --- /dev/null
19 +++ b/Documentation/devicetree/bindings/bus/bcma.txt
20 @@ -0,0 +1,46 @@
21 +Broadcom AIX bcma bus driver
22 +
23 +
24 +Required properties:
25 +
26 +- compatible : brcm,bus-aix
27 +
28 +- reg : iomem address range of chipcommon core
29 +
30 +Optional properties:
31 +
32 +- sprom: reference to a sprom driver. This is needed for sprom less devices.
33 + Use bcm47xx_sprom for example.
34 +
35 +
36 +The cores on the AIX bus are auto detected by bcma. Detection of the
37 +IRQ number is not supported on BCM47xx/BCM53xx ARM SoCs, so it is
38 +possible to provide the IRQ number over device tree. The IRQ number and
39 +the device tree child entry will be added to the core with the matching
40 +reg address.
41 +
42 +Example:
43 +
44 + aix@18000000 {
45 + compatible = "brcm,bus-aix";
46 + reg = <0x18000000 0x1000>;
47 + ranges = <0x00000000 0x18000000 0x00100000>;
48 + #address-cells = <1>;
49 + #size-cells = <1>;
50 + sprom = <&sprom0>;
51 +
52 + gmac@0 {
53 + reg = <0x18024000 0x1000>;
54 + interrupts = <GIC_SPI 147 IRQ_TYPE_LEVEL_HIGH>;
55 + };
56 +
57 + gmac@1 {
58 + reg = <0x18025000 0x1000>;
59 + interrupts = <GIC_SPI 148 IRQ_TYPE_LEVEL_HIGH>;
60 + };
61 +
62 + pcie@0 {
63 + reg = <0x18012000 0x1000>;
64 + interrupts = <GIC_SPI 131 IRQ_TYPE_LEVEL_HIGH>;
65 + };
66 + };
67 --- a/drivers/bcma/host_soc.c
68 +++ b/drivers/bcma/host_soc.c
69 @@ -7,6 +7,9 @@
70
71 #include "bcma_private.h"
72 #include "scan.h"
73 +#include <linux/slab.h>
74 +#include <linux/module.h>
75 +#include <linux/of_address.h>
76 #include <linux/bcma/bcma.h>
77 #include <linux/bcma/bcma_soc.h>
78
79 @@ -173,6 +176,7 @@ int __init bcma_host_soc_register(struct
80 /* Host specific */
81 bus->hosttype = BCMA_HOSTTYPE_SOC;
82 bus->ops = &bcma_host_soc_ops;
83 + bus->host_pdev = NULL;
84
85 /* Register */
86 err = bcma_bus_early_register(bus, &soc->core_cc, &soc->core_mips);
87 @@ -181,3 +185,69 @@ int __init bcma_host_soc_register(struct
88
89 return err;
90 }
91 +
92 +#ifdef CONFIG_OF
93 +static int bcma_host_soc_probe(struct platform_device *pdev)
94 +{
95 + struct device *dev = &pdev->dev;
96 + struct device_node *np = dev->of_node;
97 + struct bcma_bus *bus;
98 + int err;
99 +
100 + /* Alloc */
101 + bus = devm_kzalloc(dev, sizeof(*bus), GFP_KERNEL);
102 + if (!bus)
103 + return -ENOMEM;
104 +
105 + /* Map MMIO */
106 + bus->mmio = of_iomap(np, 0);
107 + if (!bus->mmio)
108 + return -ENOMEM;
109 +
110 + /* Host specific */
111 + bus->hosttype = BCMA_HOSTTYPE_SOC;
112 + bus->ops = &bcma_host_soc_ops;
113 + bus->host_pdev = pdev;
114 +
115 + /* Register */
116 + err = bcma_bus_register(bus);
117 + if (err)
118 + goto err_unmap_mmio;
119 +
120 + platform_set_drvdata(pdev, bus);
121 +
122 + return err;
123 +
124 +err_unmap_mmio:
125 + iounmap(bus->mmio);
126 + return err;
127 +}
128 +
129 +static int bcma_host_soc_remove(struct platform_device *pdev)
130 +{
131 + struct bcma_bus *bus = platform_get_drvdata(pdev);
132 +
133 + bcma_bus_unregister(bus);
134 + iounmap(bus->mmio);
135 + platform_set_drvdata(pdev, NULL);
136 +
137 + return 0;
138 +}
139 +
140 +static const struct of_device_id bcma_host_soc_of_match[] = {
141 + { .compatible = "brcm,bus-aix", },
142 + {},
143 +};
144 +MODULE_DEVICE_TABLE(of, bcma_host_soc_of_match);
145 +
146 +static struct platform_driver bcma_host_soc_driver = {
147 + .driver = {
148 + .name = "bcma-host-soc",
149 + .owner = THIS_MODULE,
150 + .of_match_table = bcma_host_soc_of_match,
151 + },
152 + .probe = bcma_host_soc_probe,
153 + .remove = bcma_host_soc_remove,
154 +};
155 +module_platform_driver(bcma_host_soc_driver);
156 +#endif /* CONFIG_OF */
157 --- a/include/linux/bcma/bcma.h
158 +++ b/include/linux/bcma/bcma.h
159 @@ -323,6 +323,8 @@ struct bcma_bus {
160 struct pci_dev *host_pci;
161 /* Pointer to the SDIO device (only for BCMA_HOSTTYPE_SDIO) */
162 struct sdio_func *host_sdio;
163 + /* Pointer to platform device (only for BCMA_HOSTTYPE_SOC) */
164 + struct platform_device *host_pdev;
165 };
166
167 struct bcma_chipinfo chipinfo;