ath9k: Fix BTCOEX weight initialization
authorSujith Manoharan <c_manoha@qualcomm.com>
Fri, 28 Sep 2012 05:43:51 +0000 (11:13 +0530)
committerJohn W. Linville <linville@tuxdriver.com>
Fri, 28 Sep 2012 17:54:10 +0000 (13:54 -0400)
The WLAN/BT weights have to set correctly before BTCOEX
is initialized. Currently, this is not done for all chips
in the AR9003 family. This patch fixes this issue by setting
the weights in the init path. While at it, rename ar9462_wlan_weights
to mci_wlan_weights since it is common to both AR9462 and AR9565.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath/ath9k/btcoex.c
drivers/net/wireless/ath/ath9k/btcoex.h
drivers/net/wireless/ath/ath9k/gpio.c
drivers/net/wireless/ath/ath9k/htc_drv_gpio.c

index 4ef610e63fcbee45037b422c68786fb0932500e5..419e9a3f2feda6c20fc7a504120f26b0820bb9ca 100644 (file)
@@ -43,8 +43,8 @@ static const u32 ar9003_wlan_weights[ATH_BTCOEX_STOMP_MAX]
        { 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, /* STOMP_NONE */
 };
 
-static const u32 ar9462_wlan_weights[ATH_BTCOEX_STOMP_MAX]
-                                   [AR9300_NUM_WLAN_WEIGHTS] = {
+static const u32 mci_wlan_weights[ATH_BTCOEX_STOMP_MAX]
+                                [AR9300_NUM_WLAN_WEIGHTS] = {
        { 0x01017d01, 0x41414101, 0x41414101, 0x41414141 }, /* STOMP_ALL */
        { 0x01017d01, 0x3b3b3b01, 0x3b3b3b01, 0x3b3b3b3b }, /* STOMP_LOW */
        { 0x01017d01, 0x01010101, 0x01010101, 0x01010101 }, /* STOMP_NONE */
@@ -208,14 +208,37 @@ static void ath9k_hw_btcoex_enable_2wire(struct ath_hw *ah)
                            AR_GPIO_OUTPUT_MUX_AS_TX_FRAME);
 }
 
+/*
+ * For AR9002, bt_weight/wlan_weight are used.
+ * For AR9003 and above, stomp_type is used.
+ */
 void ath9k_hw_btcoex_set_weight(struct ath_hw *ah,
                                u32 bt_weight,
-                               u32 wlan_weight)
+                               u32 wlan_weight,
+                               enum ath_stomp_type stomp_type)
 {
        struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw;
 
-       btcoex_hw->bt_coex_weights = SM(bt_weight, AR_BTCOEX_BT_WGHT) |
-                                    SM(wlan_weight, AR_BTCOEX_WL_WGHT);
+       if (AR_SREV_9300_20_OR_LATER(ah)) {
+               const u32 *weight = ar9003_wlan_weights[stomp_type];
+               int i;
+
+               if (AR_SREV_9462(ah) || AR_SREV_9565(ah)) {
+                       if ((stomp_type == ATH_BTCOEX_STOMP_LOW) &&
+                           btcoex_hw->mci.stomp_ftp)
+                               stomp_type = ATH_BTCOEX_STOMP_LOW_FTP;
+                       weight = mci_wlan_weights[stomp_type];
+               }
+
+               for (i = 0; i < AR9300_NUM_WLAN_WEIGHTS; i++) {
+                       btcoex_hw->bt_weight[i] = AR9300_BT_WGHT;
+                       btcoex_hw->wlan_weight[i] = weight[i];
+               }
+       } else {
+               btcoex_hw->bt_coex_weights =
+                       SM(bt_weight, AR_BTCOEX_BT_WGHT) |
+                       SM(wlan_weight, AR_BTCOEX_WL_WGHT);
+       }
 }
 EXPORT_SYMBOL(ath9k_hw_btcoex_set_weight);
 
@@ -332,26 +355,6 @@ void ath9k_hw_btcoex_disable(struct ath_hw *ah)
 }
 EXPORT_SYMBOL(ath9k_hw_btcoex_disable);
 
-static void ar9003_btcoex_bt_stomp(struct ath_hw *ah,
-                        enum ath_stomp_type stomp_type)
-{
-       struct ath_btcoex_hw *btcoex = &ah->btcoex_hw;
-       const u32 *weight = ar9003_wlan_weights[stomp_type];
-       int i;
-
-       if (AR_SREV_9462(ah) || AR_SREV_9565(ah)) {
-               if ((stomp_type == ATH_BTCOEX_STOMP_LOW) &&
-                   btcoex->mci.stomp_ftp)
-                       stomp_type = ATH_BTCOEX_STOMP_LOW_FTP;
-               weight = ar9462_wlan_weights[stomp_type];
-       }
-
-       for (i = 0; i < AR9300_NUM_WLAN_WEIGHTS; i++) {
-               btcoex->bt_weight[i] = AR9300_BT_WGHT;
-               btcoex->wlan_weight[i] = weight[i];
-       }
-}
-
 /*
  * Configures appropriate weight based on stomp type.
  */
@@ -359,22 +362,22 @@ void ath9k_hw_btcoex_bt_stomp(struct ath_hw *ah,
                              enum ath_stomp_type stomp_type)
 {
        if (AR_SREV_9300_20_OR_LATER(ah)) {
-               ar9003_btcoex_bt_stomp(ah, stomp_type);
+               ath9k_hw_btcoex_set_weight(ah, 0, 0, stomp_type);
                return;
        }
 
        switch (stomp_type) {
        case ATH_BTCOEX_STOMP_ALL:
                ath9k_hw_btcoex_set_weight(ah, AR_BT_COEX_WGHT,
-                               AR_STOMP_ALL_WLAN_WGHT);
+                                          AR_STOMP_ALL_WLAN_WGHT, 0);
                break;
        case ATH_BTCOEX_STOMP_LOW:
                ath9k_hw_btcoex_set_weight(ah, AR_BT_COEX_WGHT,
-                               AR_STOMP_LOW_WLAN_WGHT);
+                                          AR_STOMP_LOW_WLAN_WGHT, 0);
                break;
        case ATH_BTCOEX_STOMP_NONE:
                ath9k_hw_btcoex_set_weight(ah, AR_BT_COEX_WGHT,
-                               AR_STOMP_NONE_WLAN_WGHT);
+                                          AR_STOMP_NONE_WLAN_WGHT, 0);
                break;
        default:
                ath_dbg(ath9k_hw_common(ah), BTCOEX, "Invalid Stomptype\n");
index 20092f98658f84b3f0ad2429543f168de2d2866b..385197ad79b006f494c3659dc88efb343038c184 100644 (file)
@@ -107,7 +107,8 @@ void ath9k_hw_btcoex_init_mci(struct ath_hw *ah);
 void ath9k_hw_init_btcoex_hw(struct ath_hw *ah, int qnum);
 void ath9k_hw_btcoex_set_weight(struct ath_hw *ah,
                                u32 bt_weight,
-                               u32 wlan_weight);
+                               u32 wlan_weight,
+                               enum ath_stomp_type stomp_type);
 void ath9k_hw_btcoex_disable(struct ath_hw *ah);
 void ath9k_hw_btcoex_bt_stomp(struct ath_hw *ah,
                              enum ath_stomp_type stomp_type);
index 5faa4f777122ae384223f7f9f5f9048c60c73db4..d9ed141a053e6a885fcdf031866f9daa1e5918d2 100644 (file)
@@ -395,7 +395,10 @@ void ath9k_start_btcoex(struct ath_softc *sc)
            !ah->btcoex_hw.enabled) {
                if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_MCI))
                        ath9k_hw_btcoex_set_weight(ah, AR_BT_COEX_WGHT,
-                                                  AR_STOMP_LOW_WLAN_WGHT);
+                                                  AR_STOMP_LOW_WLAN_WGHT, 0);
+               else
+                       ath9k_hw_btcoex_set_weight(ah, 0, 0,
+                                                  ATH_BTCOEX_STOMP_NONE);
                ath9k_hw_btcoex_enable(ah);
 
                if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_3WIRE)
index 8fd64a6f0eb9cad1a1141bfec5976897a682d1cc..0eacfc13c9155feb4af8cb7c4d1e4b1918c0cd39 100644 (file)
@@ -161,7 +161,7 @@ void ath9k_htc_start_btcoex(struct ath9k_htc_priv *priv)
 
        if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_3WIRE) {
                ath9k_hw_btcoex_set_weight(ah, AR_BT_COEX_WGHT,
-                                          AR_STOMP_LOW_WLAN_WGHT);
+                                          AR_STOMP_LOW_WLAN_WGHT, 0);
                ath9k_hw_btcoex_enable(ah);
                ath_htc_resume_btcoex_work(priv);
        }