summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
diff options
context:
space:
mode:
authorHante Meuleman <meuleman@broadcom.com>2016-02-17 13:27:04 +0300
committerKalle Valo <kvalo@codeaurora.org>2016-03-07 15:14:58 +0300
commit8ea56be0869f8230ed7b2779397225fe45080dd1 (patch)
treefe8876bd1b49f7b39c2067f0e74a9d10f5280806 /drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
parent5c22fb85102a751e5a305d8fd13a1856a725bf01 (diff)
downloadlinux-8ea56be0869f8230ed7b2779397225fe45080dd1.tar.xz
brcmfmac: move platform data retrieval code to common
In preparation of module parameters for all devices the module platform data retrieval is moved from sdio to common. It is still only used for sdio devices. Reviewed-by: Arend Van Spriel <arend@broadcom.com> Reviewed-by: Franky (Zhenhui) Lin <frankyl@broadcom.com> Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com> Signed-off-by: Hante Meuleman <meuleman@broadcom.com> Signed-off-by: Arend van Spriel <arend@broadcom.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Diffstat (limited to 'drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c')
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c53
1 files changed, 49 insertions, 4 deletions
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
index b8dc68db708f..020901c2e0ca 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
@@ -27,6 +27,7 @@
#include "fwil_types.h"
#include "tracepoint.h"
#include "common.h"
+#include "of.h"
MODULE_AUTHOR("Broadcom Corporation");
MODULE_DESCRIPTION("Broadcom 802.11 wireless LAN fullmac driver.");
@@ -79,6 +80,7 @@ module_param_named(ignore_probe_fail, brcmf_ignore_probe_fail, int, 0);
MODULE_PARM_DESC(ignore_probe_fail, "always succeed probe for debugging");
#endif
+static struct brcmfmac_sdio_platform_data *brcmfmac_pdata;
struct brcmf_mp_global_t brcmf_mp_global;
int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
@@ -231,6 +233,13 @@ static void brcmf_mp_attach(void)
BRCMF_FW_ALTPATH_LEN);
}
+struct brcmfmac_sdio_platform_data *brcmf_get_module_param(struct device *dev)
+{
+ if (!brcmfmac_pdata)
+ brcmf_of_probe(dev, &brcmfmac_pdata);
+ return brcmfmac_pdata;
+}
+
int brcmf_mp_device_attach(struct brcmf_pub *drvr)
{
drvr->settings = kzalloc(sizeof(*drvr->settings), GFP_ATOMIC);
@@ -253,6 +262,35 @@ void brcmf_mp_device_detach(struct brcmf_pub *drvr)
kfree(drvr->settings);
}
+static int __init brcmf_common_pd_probe(struct platform_device *pdev)
+{
+ brcmf_dbg(INFO, "Enter\n");
+
+ brcmfmac_pdata = dev_get_platdata(&pdev->dev);
+
+ if (brcmfmac_pdata->power_on)
+ brcmfmac_pdata->power_on();
+
+ return 0;
+}
+
+static int brcmf_common_pd_remove(struct platform_device *pdev)
+{
+ brcmf_dbg(INFO, "Enter\n");
+
+ if (brcmfmac_pdata->power_off)
+ brcmfmac_pdata->power_off();
+
+ return 0;
+}
+
+static struct platform_driver brcmf_pd = {
+ .remove = brcmf_common_pd_remove,
+ .driver = {
+ .name = BRCMFMAC_SDIO_PDATA_NAME,
+ }
+};
+
static int __init brcmfmac_module_init(void)
{
int err;
@@ -260,16 +298,21 @@ static int __init brcmfmac_module_init(void)
/* Initialize debug system first */
brcmf_debugfs_init();
-#ifdef CONFIG_BRCMFMAC_SDIO
- brcmf_sdio_init();
-#endif
+ /* Get the platform data (if available) for our devices */
+ err = platform_driver_probe(&brcmf_pd, brcmf_common_pd_probe);
+ if (err == -ENODEV)
+ brcmf_dbg(INFO, "No platform data available.\n");
+
/* Initialize global module paramaters */
brcmf_mp_attach();
/* Continue the initialization by registering the different busses */
err = brcmf_core_init();
- if (err)
+ if (err) {
brcmf_debugfs_exit();
+ if (brcmfmac_pdata)
+ platform_driver_unregister(&brcmf_pd);
+ }
return err;
}
@@ -277,6 +320,8 @@ static int __init brcmfmac_module_init(void)
static void __exit brcmfmac_module_exit(void)
{
brcmf_core_exit();
+ if (brcmfmac_pdata)
+ platform_driver_unregister(&brcmf_pd);
brcmf_debugfs_exit();
}