]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mwifiex: add manufacturing mode support
authorXinming Hu <huxm@marvell.com>
Fri, 2 Sep 2016 07:35:06 +0000 (13:05 +0530)
committerKalle Valo <kvalo@codeaurora.org>
Fri, 9 Sep 2016 09:05:03 +0000 (12:05 +0300)
By default normal mode is chosen when driver is loaded. This
patch adds a provision to choose manufacturing mode via module
parameters.

Below command loads driver in manufacturing mode
insmod mwifiex.ko mfg_mode=1.

Tested-by: chunfan chen <jeffc@marvell.com>
Signed-off-by: Xinming Hu <huxm@marvell.com>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/marvell/mwifiex/cmdevt.c
drivers/net/wireless/marvell/mwifiex/init.c
drivers/net/wireless/marvell/mwifiex/main.c
drivers/net/wireless/marvell/mwifiex/main.h
drivers/net/wireless/marvell/mwifiex/pcie.c
drivers/net/wireless/marvell/mwifiex/sdio.c
drivers/net/wireless/marvell/mwifiex/usb.c

index d433aa01fdbb9b86c7dfb422c3acb795a0269adf..53477280f39c21d6daab9effa2c31b474fd78461 100644 (file)
@@ -595,6 +595,14 @@ int mwifiex_send_cmd(struct mwifiex_private *priv, u16 cmd_no,
                        return -1;
                }
        }
+       /* We don't expect commands in manufacturing mode. They are cooked
+        * in application and ready to download buffer is passed to the driver
+        */
+       if (adapter->mfg_mode && cmd_no) {
+               dev_dbg(adapter->dev, "Ignoring commands in manufacturing mode\n");
+               return -1;
+       }
+
 
        /* Get a new command node */
        cmd_node = mwifiex_get_cmd_node(adapter);
index 1489c90192bd9f77ad6296159b718d61e1a63df7..82839d9f079fd5bba41effb4b7c8bf067feba09a 100644 (file)
@@ -298,6 +298,7 @@ static void mwifiex_init_adapter(struct mwifiex_adapter *adapter)
        memset(&adapter->arp_filter, 0, sizeof(adapter->arp_filter));
        adapter->arp_filter_size = 0;
        adapter->max_mgmt_ie_index = MAX_MGMT_IE_INDEX;
+       adapter->mfg_mode = mfg_mode;
        adapter->key_api_major_ver = 0;
        adapter->key_api_minor_ver = 0;
        eth_broadcast_addr(adapter->perm_addr);
@@ -553,15 +554,22 @@ int mwifiex_init_fw(struct mwifiex_adapter *adapter)
                                return -1;
                }
        }
+       if (adapter->mfg_mode) {
+               adapter->hw_status = MWIFIEX_HW_STATUS_READY;
+               ret = -EINPROGRESS;
+       } else {
+               for (i = 0; i < adapter->priv_num; i++) {
+                       if (adapter->priv[i]) {
+                               ret = mwifiex_sta_init_cmd(adapter->priv[i],
+                                                          first_sta, true);
+                               if (ret == -1)
+                                       return -1;
+
+                               first_sta = false;
+                       }
+
 
-       for (i = 0; i < adapter->priv_num; i++) {
-               if (adapter->priv[i]) {
-                       ret = mwifiex_sta_init_cmd(adapter->priv[i], first_sta,
-                                                  true);
-                       if (ret == -1)
-                               return -1;
 
-                       first_sta = false;
                }
        }
 
index 51d4dfcf12143f36126167f203d52c9e62d850ea..029e5da1e6fd90658267005721cb6ccda86b5b88 100644 (file)
@@ -23,6 +23,7 @@
 #include "11n.h"
 
 #define VERSION        "1.0"
+#define MFG_FIRMWARE   "mwifiex_mfg.bin"
 
 static unsigned int debug_mask = MWIFIEX_DEFAULT_DEBUG_MASK;
 module_param(debug_mask, uint, 0);
@@ -37,6 +38,10 @@ module_param(driver_mode, ushort, 0);
 MODULE_PARM_DESC(driver_mode,
                 "station=0x1(default), ap-sta=0x3, station-p2p=0x5, ap-sta-p2p=0x7");
 
+bool mfg_mode;
+module_param(mfg_mode, bool, 0);
+MODULE_PARM_DESC(mfg_mode, "manufacturing mode enable:1, disable:0");
+
 /*
  * This function registers the device and performs all the necessary
  * initializations.
@@ -561,10 +566,12 @@ static void mwifiex_fw_dpc(const struct firmware *firmware, void *context)
                goto done;
        }
        /* Wait for mwifiex_init to complete */
-       wait_event_interruptible(adapter->init_wait_q,
-                                adapter->init_wait_q_woken);
-       if (adapter->hw_status != MWIFIEX_HW_STATUS_READY)
-               goto err_init_fw;
+       if (!adapter->mfg_mode) {
+               wait_event_interruptible(adapter->init_wait_q,
+                                        adapter->init_wait_q_woken);
+               if (adapter->hw_status != MWIFIEX_HW_STATUS_READY)
+                       goto err_init_fw;
+       }
 
        priv = adapter->priv[MWIFIEX_BSS_ROLE_STA];
        if (mwifiex_register_cfg80211(adapter)) {
@@ -668,6 +675,17 @@ static int mwifiex_init_hw_fw(struct mwifiex_adapter *adapter)
 {
        int ret;
 
+       /* Override default firmware with manufacturing one if
+        * manufacturing mode is enabled
+        */
+       if (mfg_mode) {
+               if (strlcpy(adapter->fw_name, MFG_FIRMWARE,
+                           sizeof(adapter->fw_name)) >=
+                           sizeof(adapter->fw_name)) {
+                       pr_err("%s: fw_name too long!\n", __func__);
+                       return -1;
+               }
+       }
        ret = request_firmware_nowait(THIS_MODULE, 1, adapter->fw_name,
                                      adapter->dev, GFP_KERNEL, adapter,
                                      mwifiex_fw_dpc);
index cd9a4f1525307519570f5cdce6b4ee2845090bec..17221c4f681fe4bc92e8abdfab3937e39324c3a4 100644 (file)
@@ -58,6 +58,7 @@
 #include "sdio.h"
 
 extern const char driver_version[];
+extern bool mfg_mode;
 
 struct mwifiex_adapter;
 struct mwifiex_private;
@@ -990,6 +991,7 @@ struct mwifiex_adapter {
        u32 drv_info_size;
        bool scan_chan_gap_enabled;
        struct sk_buff_head rx_data_q;
+       bool mfg_mode;
        struct mwifiex_chan_stats *chan_stats;
        u32 num_in_chan_stats;
        int survey_idx;
index 50a6a531ed184a3bda9fd3a6614990b6b05cf659..c1b3e8ef34ec204cd71e1ec24b2f49681db1ad81 100644 (file)
@@ -225,7 +225,7 @@ static void mwifiex_pcie_remove(struct pci_dev *pdev)
        if (!adapter || !adapter->priv_num)
                return;
 
-       if (user_rmmod) {
+       if (user_rmmod && !adapter->mfg_mode) {
 #ifdef CONFIG_PM_SLEEP
                if (adapter->is_suspended)
                        mwifiex_pcie_resume(&pdev->dev);
index d3e1561ca07508e5d35b71388a89dd40a5286622..6dba40998a6676a979e7666dd3489c61de4bfd3a 100644 (file)
@@ -289,7 +289,7 @@ mwifiex_sdio_remove(struct sdio_func *func)
 
        mwifiex_dbg(adapter, INFO, "info: SDIO func num=%d\n", func->num);
 
-       if (user_rmmod) {
+       if (user_rmmod && !adapter->mfg_mode) {
                if (adapter->is_suspended)
                        mwifiex_sdio_resume(adapter->dev);
 
index 3bd04f52f3698892d929599890cebb11463abb82..92135167a8220df377875b61cda4ebab725ae20f 100644 (file)
@@ -611,7 +611,7 @@ static void mwifiex_usb_disconnect(struct usb_interface *intf)
        if (!adapter->priv_num)
                return;
 
-       if (user_rmmod) {
+       if (user_rmmod && !adapter->mfg_mode) {
 #ifdef CONFIG_PM
                if (adapter->is_suspended)
                        mwifiex_usb_resume(intf);