rpcd: iwinfo plugin fixes
[openwrt/svn-archive/archive.git] / package / kernel / mac80211 / patches / 344-0015-brcmfmac-move-platform-data-retrieval-code-to-common.patch
1 From: Hante Meuleman <meuleman@broadcom.com>
2 Date: Wed, 17 Feb 2016 11:27:04 +0100
3 Subject: [PATCH] brcmfmac: move platform data retrieval code to common
4
5 In preparation of module parameters for all devices the module
6 platform data retrieval is moved from sdio to common. It is still
7 only used for sdio devices.
8
9 Reviewed-by: Arend Van Spriel <arend@broadcom.com>
10 Reviewed-by: Franky (Zhenhui) Lin <frankyl@broadcom.com>
11 Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
12 Signed-off-by: Hante Meuleman <meuleman@broadcom.com>
13 Signed-off-by: Arend van Spriel <arend@broadcom.com>
14 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
15 ---
16
17 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
18 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
19 @@ -27,8 +27,6 @@
20 #include <linux/mmc/sdio_func.h>
21 #include <linux/mmc/card.h>
22 #include <linux/mmc/host.h>
23 -#include <linux/platform_device.h>
24 -#include <linux/platform_data/brcmfmac-sdio.h>
25 #include <linux/pm_runtime.h>
26 #include <linux/suspend.h>
27 #include <linux/errno.h>
28 @@ -46,7 +44,6 @@
29 #include "bus.h"
30 #include "debug.h"
31 #include "sdio.h"
32 -#include "of.h"
33 #include "core.h"
34 #include "common.h"
35
36 @@ -106,18 +103,18 @@ static void brcmf_sdiod_dummy_irqhandler
37
38 int brcmf_sdiod_intr_register(struct brcmf_sdio_dev *sdiodev)
39 {
40 + struct brcmfmac_sdio_platform_data *pdata;
41 int ret = 0;
42 u8 data;
43 u32 addr, gpiocontrol;
44 unsigned long flags;
45
46 - if ((sdiodev->pdata) && (sdiodev->pdata->oob_irq_supported)) {
47 + pdata = sdiodev->pdata;
48 + if ((pdata) && (pdata->oob_irq_supported)) {
49 brcmf_dbg(SDIO, "Enter, register OOB IRQ %d\n",
50 - sdiodev->pdata->oob_irq_nr);
51 - ret = request_irq(sdiodev->pdata->oob_irq_nr,
52 - brcmf_sdiod_oob_irqhandler,
53 - sdiodev->pdata->oob_irq_flags,
54 - "brcmf_oob_intr",
55 + pdata->oob_irq_nr);
56 + ret = request_irq(pdata->oob_irq_nr, brcmf_sdiod_oob_irqhandler,
57 + pdata->oob_irq_flags, "brcmf_oob_intr",
58 &sdiodev->func[1]->dev);
59 if (ret != 0) {
60 brcmf_err("request_irq failed %d\n", ret);
61 @@ -129,7 +126,7 @@ int brcmf_sdiod_intr_register(struct brc
62 sdiodev->irq_en = true;
63 spin_unlock_irqrestore(&sdiodev->irq_en_lock, flags);
64
65 - ret = enable_irq_wake(sdiodev->pdata->oob_irq_nr);
66 + ret = enable_irq_wake(pdata->oob_irq_nr);
67 if (ret != 0) {
68 brcmf_err("enable_irq_wake failed %d\n", ret);
69 return ret;
70 @@ -158,7 +155,7 @@ int brcmf_sdiod_intr_register(struct brc
71
72 /* redirect, configure and enable io for interrupt signal */
73 data = SDIO_SEPINT_MASK | SDIO_SEPINT_OE;
74 - if (sdiodev->pdata->oob_irq_flags & IRQF_TRIGGER_HIGH)
75 + if (pdata->oob_irq_flags & IRQF_TRIGGER_HIGH)
76 data |= SDIO_SEPINT_ACT_HI;
77 brcmf_sdiod_regwb(sdiodev, SDIO_CCCR_BRCM_SEPINT, data, &ret);
78
79 @@ -176,9 +173,12 @@ int brcmf_sdiod_intr_register(struct brc
80
81 int brcmf_sdiod_intr_unregister(struct brcmf_sdio_dev *sdiodev)
82 {
83 + struct brcmfmac_sdio_platform_data *pdata;
84 +
85 brcmf_dbg(SDIO, "Entering\n");
86
87 - if ((sdiodev->pdata) && (sdiodev->pdata->oob_irq_supported)) {
88 + pdata = sdiodev->pdata;
89 + if ((pdata) && (pdata->oob_irq_supported)) {
90 sdio_claim_host(sdiodev->func[1]);
91 brcmf_sdiod_regwb(sdiodev, SDIO_CCCR_BRCM_SEPINT, 0, NULL);
92 brcmf_sdiod_regwb(sdiodev, SDIO_CCCR_IENx, 0, NULL);
93 @@ -187,11 +187,10 @@ int brcmf_sdiod_intr_unregister(struct b
94 if (sdiodev->oob_irq_requested) {
95 sdiodev->oob_irq_requested = false;
96 if (sdiodev->irq_wake) {
97 - disable_irq_wake(sdiodev->pdata->oob_irq_nr);
98 + disable_irq_wake(pdata->oob_irq_nr);
99 sdiodev->irq_wake = false;
100 }
101 - free_irq(sdiodev->pdata->oob_irq_nr,
102 - &sdiodev->func[1]->dev);
103 + free_irq(pdata->oob_irq_nr, &sdiodev->func[1]->dev);
104 sdiodev->irq_en = false;
105 }
106 } else {
107 @@ -1103,8 +1102,6 @@ static const struct sdio_device_id brcmf
108 };
109 MODULE_DEVICE_TABLE(sdio, brcmf_sdmmc_ids);
110
111 -static struct brcmfmac_sdio_platform_data *brcmfmac_sdio_pdata;
112 -
113
114 static void brcmf_sdiod_acpi_set_power_manageable(struct device *dev,
115 int val)
116 @@ -1167,10 +1164,7 @@ static int brcmf_ops_sdio_probe(struct s
117 dev_set_drvdata(&func->dev, bus_if);
118 dev_set_drvdata(&sdiodev->func[1]->dev, bus_if);
119 sdiodev->dev = &sdiodev->func[1]->dev;
120 - sdiodev->pdata = brcmfmac_sdio_pdata;
121 -
122 - if (!sdiodev->pdata)
123 - brcmf_of_probe(sdiodev);
124 + sdiodev->pdata = brcmf_get_module_param(sdiodev->dev);
125
126 #ifdef CONFIG_PM_SLEEP
127 /* wowl can be supported when KEEP_POWER is true and (WAKE_SDIO_IRQ
128 @@ -1296,7 +1290,7 @@ static const struct dev_pm_ops brcmf_sdi
129 static struct sdio_driver brcmf_sdmmc_driver = {
130 .probe = brcmf_ops_sdio_probe,
131 .remove = brcmf_ops_sdio_remove,
132 - .name = BRCMFMAC_SDIO_PDATA_NAME,
133 + .name = KBUILD_MODNAME,
134 .id_table = brcmf_sdmmc_ids,
135 .drv = {
136 .owner = THIS_MODULE,
137 @@ -1306,37 +1300,6 @@ static struct sdio_driver brcmf_sdmmc_dr
138 },
139 };
140
141 -static int __init brcmf_sdio_pd_probe(struct platform_device *pdev)
142 -{
143 - brcmf_dbg(SDIO, "Enter\n");
144 -
145 - brcmfmac_sdio_pdata = dev_get_platdata(&pdev->dev);
146 -
147 - if (brcmfmac_sdio_pdata->power_on)
148 - brcmfmac_sdio_pdata->power_on();
149 -
150 - return 0;
151 -}
152 -
153 -static int brcmf_sdio_pd_remove(struct platform_device *pdev)
154 -{
155 - brcmf_dbg(SDIO, "Enter\n");
156 -
157 - if (brcmfmac_sdio_pdata->power_off)
158 - brcmfmac_sdio_pdata->power_off();
159 -
160 - sdio_unregister_driver(&brcmf_sdmmc_driver);
161 -
162 - return 0;
163 -}
164 -
165 -static struct platform_driver brcmf_sdio_pd = {
166 - .remove = brcmf_sdio_pd_remove,
167 - .driver = {
168 - .name = BRCMFMAC_SDIO_PDATA_NAME,
169 - }
170 -};
171 -
172 void brcmf_sdio_register(void)
173 {
174 int ret;
175 @@ -1350,19 +1313,6 @@ void brcmf_sdio_exit(void)
176 {
177 brcmf_dbg(SDIO, "Enter\n");
178
179 - if (brcmfmac_sdio_pdata)
180 - platform_driver_unregister(&brcmf_sdio_pd);
181 - else
182 - sdio_unregister_driver(&brcmf_sdmmc_driver);
183 + sdio_unregister_driver(&brcmf_sdmmc_driver);
184 }
185
186 -void __init brcmf_sdio_init(void)
187 -{
188 - int ret;
189 -
190 - brcmf_dbg(SDIO, "Enter\n");
191 -
192 - ret = platform_driver_probe(&brcmf_sdio_pd, brcmf_sdio_pd_probe);
193 - if (ret == -ENODEV)
194 - brcmf_dbg(SDIO, "No platform data available.\n");
195 -}
196 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
197 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
198 @@ -27,6 +27,7 @@
199 #include "fwil_types.h"
200 #include "tracepoint.h"
201 #include "common.h"
202 +#include "of.h"
203
204 MODULE_AUTHOR("Broadcom Corporation");
205 MODULE_DESCRIPTION("Broadcom 802.11 wireless LAN fullmac driver.");
206 @@ -79,6 +80,7 @@ module_param_named(ignore_probe_fail, br
207 MODULE_PARM_DESC(ignore_probe_fail, "always succeed probe for debugging");
208 #endif
209
210 +static struct brcmfmac_sdio_platform_data *brcmfmac_pdata;
211 struct brcmf_mp_global_t brcmf_mp_global;
212
213 int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
214 @@ -231,6 +233,13 @@ static void brcmf_mp_attach(void)
215 BRCMF_FW_ALTPATH_LEN);
216 }
217
218 +struct brcmfmac_sdio_platform_data *brcmf_get_module_param(struct device *dev)
219 +{
220 + if (!brcmfmac_pdata)
221 + brcmf_of_probe(dev, &brcmfmac_pdata);
222 + return brcmfmac_pdata;
223 +}
224 +
225 int brcmf_mp_device_attach(struct brcmf_pub *drvr)
226 {
227 drvr->settings = kzalloc(sizeof(*drvr->settings), GFP_ATOMIC);
228 @@ -253,6 +262,35 @@ void brcmf_mp_device_detach(struct brcmf
229 kfree(drvr->settings);
230 }
231
232 +static int __init brcmf_common_pd_probe(struct platform_device *pdev)
233 +{
234 + brcmf_dbg(INFO, "Enter\n");
235 +
236 + brcmfmac_pdata = dev_get_platdata(&pdev->dev);
237 +
238 + if (brcmfmac_pdata->power_on)
239 + brcmfmac_pdata->power_on();
240 +
241 + return 0;
242 +}
243 +
244 +static int brcmf_common_pd_remove(struct platform_device *pdev)
245 +{
246 + brcmf_dbg(INFO, "Enter\n");
247 +
248 + if (brcmfmac_pdata->power_off)
249 + brcmfmac_pdata->power_off();
250 +
251 + return 0;
252 +}
253 +
254 +static struct platform_driver brcmf_pd = {
255 + .remove = brcmf_common_pd_remove,
256 + .driver = {
257 + .name = BRCMFMAC_SDIO_PDATA_NAME,
258 + }
259 +};
260 +
261 static int __init brcmfmac_module_init(void)
262 {
263 int err;
264 @@ -260,16 +298,21 @@ static int __init brcmfmac_module_init(v
265 /* Initialize debug system first */
266 brcmf_debugfs_init();
267
268 -#ifdef CPTCFG_BRCMFMAC_SDIO
269 - brcmf_sdio_init();
270 -#endif
271 + /* Get the platform data (if available) for our devices */
272 + err = platform_driver_probe(&brcmf_pd, brcmf_common_pd_probe);
273 + if (err == -ENODEV)
274 + brcmf_dbg(INFO, "No platform data available.\n");
275 +
276 /* Initialize global module paramaters */
277 brcmf_mp_attach();
278
279 /* Continue the initialization by registering the different busses */
280 err = brcmf_core_init();
281 - if (err)
282 + if (err) {
283 brcmf_debugfs_exit();
284 + if (brcmfmac_pdata)
285 + platform_driver_unregister(&brcmf_pd);
286 + }
287
288 return err;
289 }
290 @@ -277,6 +320,8 @@ static int __init brcmfmac_module_init(v
291 static void __exit brcmfmac_module_exit(void)
292 {
293 brcmf_core_exit();
294 + if (brcmfmac_pdata)
295 + platform_driver_unregister(&brcmf_pd);
296 brcmf_debugfs_exit();
297 }
298
299 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h
300 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h
301 @@ -15,6 +15,8 @@
302 #ifndef BRCMFMAC_COMMON_H
303 #define BRCMFMAC_COMMON_H
304
305 +#include <linux/platform_device.h>
306 +#include <linux/platform_data/brcmfmac-sdio.h>
307 #include "fwil_types.h"
308
309 extern const u8 ALLFFMAC[ETH_ALEN];
310 @@ -89,6 +91,7 @@ struct brcmf_mp_device {
311 struct cc_translate *country_codes;
312 };
313
314 +struct brcmfmac_sdio_platform_data *brcmf_get_module_param(struct device *dev);
315 int brcmf_mp_device_attach(struct brcmf_pub *drvr);
316 void brcmf_mp_device_detach(struct brcmf_pub *drvr);
317 #ifdef DEBUG
318 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
319 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
320 @@ -16,17 +16,16 @@
321 #include <linux/init.h>
322 #include <linux/of.h>
323 #include <linux/of_irq.h>
324 -#include <linux/mmc/card.h>
325 -#include <linux/platform_data/brcmfmac-sdio.h>
326 -#include <linux/mmc/sdio_func.h>
327
328 #include <defs.h>
329 #include "debug.h"
330 -#include "sdio.h"
331 +#include "core.h"
332 +#include "common.h"
333 +#include "of.h"
334
335 -void brcmf_of_probe(struct brcmf_sdio_dev *sdiodev)
336 +void
337 +brcmf_of_probe(struct device *dev, struct brcmfmac_sdio_platform_data **sdio)
338 {
339 - struct device *dev = sdiodev->dev;
340 struct device_node *np = dev->of_node;
341 int irq;
342 u32 irqf;
343 @@ -35,12 +34,12 @@ void brcmf_of_probe(struct brcmf_sdio_de
344 if (!np || !of_device_is_compatible(np, "brcm,bcm4329-fmac"))
345 return;
346
347 - sdiodev->pdata = devm_kzalloc(dev, sizeof(*sdiodev->pdata), GFP_KERNEL);
348 - if (!sdiodev->pdata)
349 + *sdio = devm_kzalloc(dev, sizeof(*sdio), GFP_KERNEL);
350 + if (!(*sdio))
351 return;
352
353 if (of_property_read_u32(np, "brcm,drive-strength", &val) == 0)
354 - sdiodev->pdata->drive_strength = val;
355 + (*sdio)->drive_strength = val;
356
357 /* make sure there are interrupts defined in the node */
358 if (!of_find_property(np, "interrupts", NULL))
359 @@ -53,7 +52,7 @@ void brcmf_of_probe(struct brcmf_sdio_de
360 }
361 irqf = irqd_get_trigger_type(irq_get_irq_data(irq));
362
363 - sdiodev->pdata->oob_irq_supported = true;
364 - sdiodev->pdata->oob_irq_nr = irq;
365 - sdiodev->pdata->oob_irq_flags = irqf;
366 + (*sdio)->oob_irq_supported = true;
367 + (*sdio)->oob_irq_nr = irq;
368 + (*sdio)->oob_irq_flags = irqf;
369 }
370 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.h
371 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.h
372 @@ -14,9 +14,11 @@
373 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
374 */
375 #ifdef CONFIG_OF
376 -void brcmf_of_probe(struct brcmf_sdio_dev *sdiodev);
377 +void
378 +brcmf_of_probe(struct device *dev, struct brcmfmac_sdio_platform_data **sdio);
379 #else
380 -static void brcmf_of_probe(struct brcmf_sdio_dev *sdiodev)
381 +static void brcmf_of_probe(struct device *dev,
382 + struct brcmfmac_sdio_platform_data **sdio)
383 {
384 }
385 #endif /* CONFIG_OF */