MLK-20681 brcmfmac: add brcmfmac platform device pinctrl state support
authorAndy Duan <fugang.duan@nxp.com>
Fri, 4 Jan 2019 06:48:59 +0000 (14:48 +0800)
committerLeonard Crestez <leonard.crestez@nxp.com>
Thu, 18 Apr 2019 00:00:38 +0000 (03:00 +0300)
Add brcmfmac platform device pinctrl state support. That is useful
for dynamically configurate pin group for different wlan chips.

Reviewed-by: Richard Zhu <hongxing.zhu@nxp.com>
Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
(cherry picked from commit 88f2834cd5b8cb8864af68d265b5bdee3000c4bf)

drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
include/linux/platform_data/brcmfmac.h

index 9e8d424..5834168 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/netdevice.h>
 #include <linux/module.h>
 #include <linux/firmware.h>
+#include <linux/pinctrl/consumer.h>
 #include <brcmu_wifi.h>
 #include <brcmu_utils.h>
 #include "core.h"
@@ -450,6 +451,7 @@ struct brcmf_mp_device *brcmf_get_module_param(struct device *dev,
        /* See if there is any device specific platform data configured */
        found = false;
        if (brcmfmac_pdata) {
+               pinctrl_pm_select_default_state(brcmfmac_pdata->dev);
                for (i = 0; i < brcmfmac_pdata->device_count; i++) {
                        device_pd = &brcmfmac_pdata->devices[i];
                        if ((device_pd->bus_type == bus_type) &&
@@ -482,10 +484,30 @@ void brcmf_release_module_param(struct brcmf_mp_device *module_param)
 
 static int __init brcmf_common_pd_probe(struct platform_device *pdev)
 {
+       int err;
+       struct brcmfmac_platform_data pdata = {
+               .power_on = NULL,
+               .power_off = NULL,
+               .fw_alternative_path = NULL,
+               .device_count = 0,
+       };
+
        brcmf_dbg(INFO, "Enter\n");
 
        brcmfmac_pdata = dev_get_platdata(&pdev->dev);
+       if (!brcmfmac_pdata) {
+               err = platform_device_add_data(pdev, &pdata,
+                                              sizeof(pdata));
+               if (err)
+                       brcmf_err("platform data allocation failed\n");
+               brcmfmac_pdata = dev_get_platdata(&pdev->dev);
+               pinctrl_pm_select_idle_state(&pdev->dev);
+       }
+
+       if (!brcmfmac_pdata)
+               return 0;
 
+       brcmfmac_pdata->dev = &pdev->dev;
        if (brcmfmac_pdata->power_on)
                brcmfmac_pdata->power_on();
 
@@ -496,7 +518,7 @@ static int brcmf_common_pd_remove(struct platform_device *pdev)
 {
        brcmf_dbg(INFO, "Enter\n");
 
-       if (brcmfmac_pdata->power_off)
+       if (brcmfmac_pdata && brcmfmac_pdata->power_off)
                brcmfmac_pdata->power_off();
 
        return 0;
index 1d30bf2..b737c0a 100644 (file)
@@ -178,6 +178,7 @@ struct brcmfmac_platform_data {
        void    (*power_off)(void);
        char    *fw_alternative_path;
        int     device_count;
+       struct device *dev;
        struct brcmfmac_pd_device devices[0];
 };