mwl8k: handle loading AP firmware images
authorLennert Buytenhek <buytenh@wantstofly.org>
Thu, 22 Oct 2009 18:20:53 +0000 (20:20 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Fri, 6 Nov 2009 21:54:36 +0000 (16:54 -0500)
AP and STA firmware images provide a different signature in the
HIU_INT_CODE register after loading.  Record which of the signatures
we saw, as it determines which command sequences to use later on.

Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/mwl8k.c

index b0080ae98a8385f4aa74cb26a38860618c5113c6..8bec4652fda1aa690ea408efa88724a5b0052432 100644 (file)
@@ -130,6 +130,7 @@ struct mwl8k_priv {
        struct pci_dev *pdev;
 
        struct mwl8k_device_info *device_info;
+       bool ap_fw;
 
        /* firmware files and meta data */
        struct mwl8k_firmware fw;
@@ -534,6 +535,7 @@ static int mwl8k_load_firmware(struct ieee80211_hw *hw)
 {
        struct mwl8k_priv *priv = hw->priv;
        struct firmware *fw = priv->fw.ucode;
+       struct mwl8k_device_info *di = priv->device_info;
        int rc;
        int loops;
 
@@ -565,14 +567,26 @@ static int mwl8k_load_firmware(struct ieee80211_hw *hw)
                return rc;
        }
 
-       iowrite32(MWL8K_MODE_STA, priv->regs + MWL8K_HIU_GEN_PTR);
+       if (di->modes & BIT(NL80211_IFTYPE_AP))
+               iowrite32(MWL8K_MODE_AP, priv->regs + MWL8K_HIU_GEN_PTR);
+       else
+               iowrite32(MWL8K_MODE_STA, priv->regs + MWL8K_HIU_GEN_PTR);
        msleep(1);
 
        loops = 200000;
        do {
-               if (ioread32(priv->regs + MWL8K_HIU_INT_CODE)
-                                               == MWL8K_FWSTA_READY)
+               u32 ready_code;
+
+               ready_code = ioread32(priv->regs + MWL8K_HIU_INT_CODE);
+               if (ready_code == MWL8K_FWAP_READY) {
+                       priv->ap_fw = 1;
+                       break;
+               } else if (ready_code == MWL8K_FWSTA_READY) {
+                       priv->ap_fw = 0;
                        break;
+               }
+
+               cond_resched();
                udelay(1);
        } while (--loops);
 
@@ -3165,9 +3179,10 @@ static int __devinit mwl8k_probe(struct pci_dev *pdev,
                goto err_stop_firmware;
        }
 
-       printk(KERN_INFO "%s: %s v%d, %pM, firmware version %u.%u.%u.%u\n",
+       printk(KERN_INFO "%s: %s v%d, %pM, %s firmware %u.%u.%u.%u\n",
               wiphy_name(hw->wiphy), priv->device_info->part_name,
               priv->hw_rev, hw->wiphy->perm_addr,
+              priv->ap_fw ? "AP" : "STA",
               (priv->fw_rev >> 24) & 0xff, (priv->fw_rev >> 16) & 0xff,
               (priv->fw_rev >> 8) & 0xff, priv->fw_rev & 0xff);