ath9k: Split ath9k_hw_btcoex_enable() into two logical pieces
authorVasanthakumar Thiagarajan <vasanth@atheros.com>
Wed, 26 Aug 2009 15:38:43 +0000 (21:08 +0530)
committerJohn W. Linville <linville@tuxdriver.com>
Fri, 28 Aug 2009 18:40:48 +0000 (14:40 -0400)
This function currently does initialization + enable the
btcoex support. Split it into two logical functions which
does the above operations separately. Btcoex initialization
is done during attach time and enabling this feature is done
in start(). Also, add code to disable btcoex support in stop().

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath/ath9k/ath9k.h
drivers/net/wireless/ath/ath9k/hw.c
drivers/net/wireless/ath/ath9k/hw.h
drivers/net/wireless/ath/ath9k/main.c

index 7705da1103f486f603e0179fe2f43d4fcbc3dacb..086880083360fed770ab4e4a6ec142e6e5e5150f 100644 (file)
@@ -521,6 +521,7 @@ struct ath_led {
 #define SC_OP_WAIT_FOR_PSPOLL_DATA BIT(17)
 #define SC_OP_WAIT_FOR_TX_ACK   BIT(18)
 #define SC_OP_BEACON_SYNC       BIT(19)
+#define SC_OP_BTCOEX_ENABLED    BIT(20)
 
 struct ath_bus_ops {
        void            (*read_cachesize)(struct ath_softc *sc, int *csz);
index 4f3d5ea3481205b716b7396ea35a7afc4aa6e6ea..d81e826b682aa99d9f73302c0c13e8ab1e328ddf 100644 (file)
@@ -4073,7 +4073,7 @@ void ath9k_hw_set11nmac2040(struct ath_hw *ah, enum ath9k_ht_macmode mode)
 /*  Bluetooth Coexistence  */
 /***************************/
 
-void ath9k_hw_btcoex_enable(struct ath_hw *ah)
+void ath9k_hw_btcoex_init(struct ath_hw *ah)
 {
        /* connect bt_active to baseband */
        REG_CLR_BIT(ah, AR_GPIO_INPUT_EN_VAL,
@@ -4090,8 +4090,23 @@ void ath9k_hw_btcoex_enable(struct ath_hw *ah)
 
        /* Configure the desired gpio port for input */
        ath9k_hw_cfg_gpio_input(ah, ah->btactive_gpio);
+}
 
+void ath9k_hw_btcoex_enable(struct ath_hw *ah)
+{
        /* Configure the desired GPIO port for TX_FRAME output */
        ath9k_hw_cfg_output(ah, ah->wlanactive_gpio,
                            AR_GPIO_OUTPUT_MUX_AS_TX_FRAME);
+
+       ah->ah_sc->sc_flags |= SC_OP_BTCOEX_ENABLED;
+}
+
+void ath9k_hw_btcoex_disable(struct ath_hw *ah)
+{
+       ath9k_hw_set_gpio(ah, ah->wlanactive_gpio, 0);
+
+       ath9k_hw_cfg_output(ah, ah->wlanactive_gpio,
+                       AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
+
+       ah->ah_sc->sc_flags &= ~SC_OP_BTCOEX_ENABLED;
 }
index b24150a1b4add4a78bd6fea1f0cd6e5be69b5ff1..e634cb448ca07c59a64103af55a2536256830c82 100644 (file)
@@ -614,6 +614,8 @@ bool ath9k_hw_intrpend(struct ath_hw *ah);
 bool ath9k_hw_getisr(struct ath_hw *ah, enum ath9k_int *masked);
 enum ath9k_int ath9k_hw_set_interrupts(struct ath_hw *ah, enum ath9k_int ints);
 
+void ath9k_hw_btcoex_init(struct ath_hw *ah);
 void ath9k_hw_btcoex_enable(struct ath_hw *ah);
+void ath9k_hw_btcoex_disable(struct ath_hw *ah);
 
 #endif
index eb8d673cde596b782a23c43a3e8213ed1a1530fc..878d3be7c717395bdaeec1f0543dfefff47311b9 100644 (file)
@@ -1509,8 +1509,8 @@ static int ath_init_softc(u16 devid, struct ath_softc *sc)
                        ARRAY_SIZE(ath9k_5ghz_chantable);
        }
 
-       if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_BT_COEX)
-               ath9k_hw_btcoex_enable(sc->sc_ah);
+       if (ah->caps.hw_caps & ATH9K_HW_CAP_BT_COEX)
+               ath9k_hw_btcoex_init(ah);
 
        return 0;
 bad2:
@@ -1992,6 +1992,10 @@ static int ath9k_start(struct ieee80211_hw *hw)
 
        ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0);
 
+       if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_BT_COEX) &&
+           !(sc->sc_flags & SC_OP_BTCOEX_ENABLED))
+               ath9k_hw_btcoex_enable(sc->sc_ah);
+
 mutex_unlock:
        mutex_unlock(&sc->mutex);
 
@@ -2138,6 +2142,9 @@ static void ath9k_stop(struct ieee80211_hw *hw)
 
        wiphy_rfkill_stop_polling(sc->hw->wiphy);
 
+       if (sc->sc_flags & SC_OP_BTCOEX_ENABLED)
+               ath9k_hw_btcoex_disable(sc->sc_ah);
+
        /* disable HAL and put h/w to sleep */
        ath9k_hw_disable(sc->sc_ah);
        ath9k_hw_configpcipowersave(sc->sc_ah, 1);