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
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.
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>
17 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
18 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
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>
36 @@ -106,18 +103,18 @@ static void brcmf_sdiod_dummy_irqhandler
38 int brcmf_sdiod_intr_register(struct brcmf_sdio_dev *sdiodev)
40 + struct brcmfmac_sdio_platform_data *pdata;
43 u32 addr, gpiocontrol;
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,
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);
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);
65 - ret = enable_irq_wake(sdiodev->pdata->oob_irq_nr);
66 + ret = enable_irq_wake(pdata->oob_irq_nr);
68 brcmf_err("enable_irq_wake failed %d\n", ret);
70 @@ -158,7 +155,7 @@ int brcmf_sdiod_intr_register(struct brc
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);
79 @@ -176,9 +173,12 @@ int brcmf_sdiod_intr_register(struct brc
81 int brcmf_sdiod_intr_unregister(struct brcmf_sdio_dev *sdiodev)
83 + struct brcmfmac_sdio_platform_data *pdata;
85 brcmf_dbg(SDIO, "Entering\n");
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;
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;
107 @@ -1103,8 +1102,6 @@ static const struct sdio_device_id brcmf
109 MODULE_DEVICE_TABLE(sdio, brcmf_sdmmc_ids);
111 -static struct brcmfmac_sdio_platform_data *brcmfmac_sdio_pdata;
114 static void brcmf_sdiod_acpi_set_power_manageable(struct device *dev,
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;
122 - if (!sdiodev->pdata)
123 - brcmf_of_probe(sdiodev);
124 + sdiodev->pdata = brcmf_get_module_param(sdiodev->dev);
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,
136 .owner = THIS_MODULE,
137 @@ -1306,37 +1300,6 @@ static struct sdio_driver brcmf_sdmmc_dr
141 -static int __init brcmf_sdio_pd_probe(struct platform_device *pdev)
143 - brcmf_dbg(SDIO, "Enter\n");
145 - brcmfmac_sdio_pdata = dev_get_platdata(&pdev->dev);
147 - if (brcmfmac_sdio_pdata->power_on)
148 - brcmfmac_sdio_pdata->power_on();
153 -static int brcmf_sdio_pd_remove(struct platform_device *pdev)
155 - brcmf_dbg(SDIO, "Enter\n");
157 - if (brcmfmac_sdio_pdata->power_off)
158 - brcmfmac_sdio_pdata->power_off();
160 - sdio_unregister_driver(&brcmf_sdmmc_driver);
165 -static struct platform_driver brcmf_sdio_pd = {
166 - .remove = brcmf_sdio_pd_remove,
168 - .name = BRCMFMAC_SDIO_PDATA_NAME,
172 void brcmf_sdio_register(void)
175 @@ -1350,19 +1313,6 @@ void brcmf_sdio_exit(void)
177 brcmf_dbg(SDIO, "Enter\n");
179 - if (brcmfmac_sdio_pdata)
180 - platform_driver_unregister(&brcmf_sdio_pd);
182 - sdio_unregister_driver(&brcmf_sdmmc_driver);
183 + sdio_unregister_driver(&brcmf_sdmmc_driver);
186 -void __init brcmf_sdio_init(void)
190 - brcmf_dbg(SDIO, "Enter\n");
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");
196 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
197 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
199 #include "fwil_types.h"
200 #include "tracepoint.h"
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");
210 +static struct brcmfmac_sdio_platform_data *brcmfmac_pdata;
211 struct brcmf_mp_global_t brcmf_mp_global;
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);
218 +struct brcmfmac_sdio_platform_data *brcmf_get_module_param(struct device *dev)
220 + if (!brcmfmac_pdata)
221 + brcmf_of_probe(dev, &brcmfmac_pdata);
222 + return brcmfmac_pdata;
225 int brcmf_mp_device_attach(struct brcmf_pub *drvr)
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);
232 +static int __init brcmf_common_pd_probe(struct platform_device *pdev)
234 + brcmf_dbg(INFO, "Enter\n");
236 + brcmfmac_pdata = dev_get_platdata(&pdev->dev);
238 + if (brcmfmac_pdata->power_on)
239 + brcmfmac_pdata->power_on();
244 +static int brcmf_common_pd_remove(struct platform_device *pdev)
246 + brcmf_dbg(INFO, "Enter\n");
248 + if (brcmfmac_pdata->power_off)
249 + brcmfmac_pdata->power_off();
254 +static struct platform_driver brcmf_pd = {
255 + .remove = brcmf_common_pd_remove,
257 + .name = BRCMFMAC_SDIO_PDATA_NAME,
261 static int __init brcmfmac_module_init(void)
264 @@ -260,16 +298,21 @@ static int __init brcmfmac_module_init(v
265 /* Initialize debug system first */
266 brcmf_debugfs_init();
268 -#ifdef CPTCFG_BRCMFMAC_SDIO
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");
276 /* Initialize global module paramaters */
279 /* Continue the initialization by registering the different busses */
280 err = brcmf_core_init();
283 brcmf_debugfs_exit();
284 + if (brcmfmac_pdata)
285 + platform_driver_unregister(&brcmf_pd);
290 @@ -277,6 +320,8 @@ static int __init brcmfmac_module_init(v
291 static void __exit brcmfmac_module_exit(void)
294 + if (brcmfmac_pdata)
295 + platform_driver_unregister(&brcmf_pd);
296 brcmf_debugfs_exit();
299 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h
300 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h
302 #ifndef BRCMFMAC_COMMON_H
303 #define BRCMFMAC_COMMON_H
305 +#include <linux/platform_device.h>
306 +#include <linux/platform_data/brcmfmac-sdio.h>
307 #include "fwil_types.h"
309 extern const u8 ALLFFMAC[ETH_ALEN];
310 @@ -89,6 +91,7 @@ struct brcmf_mp_device {
311 struct cc_translate *country_codes;
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);
318 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
319 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
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>
335 -void brcmf_of_probe(struct brcmf_sdio_dev *sdiodev)
337 +brcmf_of_probe(struct device *dev, struct brcmfmac_sdio_platform_data **sdio)
339 - struct device *dev = sdiodev->dev;
340 struct device_node *np = dev->of_node;
343 @@ -35,12 +34,12 @@ void brcmf_of_probe(struct brcmf_sdio_de
344 if (!np || !of_device_is_compatible(np, "brcm,bcm4329-fmac"))
347 - sdiodev->pdata = devm_kzalloc(dev, sizeof(*sdiodev->pdata), GFP_KERNEL);
348 - if (!sdiodev->pdata)
349 + *sdio = devm_kzalloc(dev, sizeof(*sdio), GFP_KERNEL);
353 if (of_property_read_u32(np, "brcm,drive-strength", &val) == 0)
354 - sdiodev->pdata->drive_strength = val;
355 + (*sdio)->drive_strength = val;
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
361 irqf = irqd_get_trigger_type(irq_get_irq_data(irq));
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;
370 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.h
371 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.h
373 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
376 -void brcmf_of_probe(struct brcmf_sdio_dev *sdiodev);
378 +brcmf_of_probe(struct device *dev, struct brcmfmac_sdio_platform_data **sdio);
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)
385 #endif /* CONFIG_OF */