]> Pileus Git - ~andy/linux/blobdiff - drivers/net/wireless/ath/ath9k/mci.c
ath9k: Stop the BTCOEX timers before disabling BTCOEX
[~andy/linux] / drivers / net / wireless / ath / ath9k / mci.c
index f0c8fa48d79eff930c95d75951c384ff1dafa395..87acff7fdaaea0271dd88d50b1f1c2638cd5c836 100644 (file)
@@ -174,8 +174,8 @@ skip_tuning:
                        btcoex->btcoex_period >>= 1;
        }
 
-       ath9k_hw_btcoex_disable(sc->sc_ah);
        ath9k_btcoex_timer_pause(sc);
+       ath9k_hw_btcoex_disable(sc->sc_ah);
 
        if (IS_CHAN_5GHZ(sc->sc_ah->curchan))
                return;
@@ -195,20 +195,16 @@ static void ath_mci_cal_msg(struct ath_softc *sc, u8 opcode, u8 *rx_payload)
 {
        struct ath_hw *ah = sc->sc_ah;
        struct ath_common *common = ath9k_hw_common(ah);
+       struct ath9k_hw_mci *mci_hw = &ah->btcoex_hw.mci;
        u32 payload[4] = {0, 0, 0, 0};
 
        switch (opcode) {
        case MCI_GPM_BT_CAL_REQ:
-               if (ar9003_mci_state(ah, MCI_STATE_BT, NULL) == MCI_BT_AWAKE) {
-                       ar9003_mci_state(ah, MCI_STATE_SET_BT_CAL_START, NULL);
+               if (mci_hw->bt_state == MCI_BT_AWAKE) {
+                       ar9003_mci_state(ah, MCI_STATE_SET_BT_CAL_START);
                        ieee80211_queue_work(sc->hw, &sc->hw_reset_work);
-               } else {
-                       ath_dbg(common, MCI, "MCI State mismatch: %d\n",
-                               ar9003_mci_state(ah, MCI_STATE_BT, NULL));
                }
-               break;
-       case MCI_GPM_BT_CAL_DONE:
-               ar9003_mci_state(ah, MCI_STATE_BT, NULL);
+               ath_dbg(common, MCI, "MCI State : %d\n", mci_hw->bt_state);
                break;
        case MCI_GPM_BT_CAL_GRANT:
                MCI_GPM_SET_CAL_TYPE(payload, MCI_GPM_WLAN_CAL_DONE);
@@ -237,8 +233,21 @@ static void ath_mci_process_profile(struct ath_softc *sc,
        struct ath_mci_profile_info *entry = NULL;
 
        entry = ath_mci_find_profile(mci, info);
-       if (entry)
+       if (entry) {
+               /*
+                * Two MCI interrupts are generated while connecting to
+                * headset and A2DP profile, but only one MCI interrupt
+                * is generated with last added profile type while disconnecting
+                * both profiles.
+                * So while adding second profile type decrement
+                * the first one.
+                */
+               if (entry->type != info->type) {
+                       DEC_PROF(mci, entry);
+                       INC_PROF(mci, info);
+               }
                memcpy(entry, info, 10);
+       }
 
        if (info->start) {
                if (!entry && !ath_mci_add_profile(common, mci, info))
@@ -299,25 +308,20 @@ static void ath_mci_msg(struct ath_softc *sc, u8 opcode, u8 *rx_payload)
        struct ath_mci_profile_info profile_info;
        struct ath_mci_profile_status profile_status;
        struct ath_common *common = ath9k_hw_common(sc->sc_ah);
-       u32 version;
-       u8 major;
-       u8 minor;
+       u8 major, minor;
        u32 seq_num;
 
        switch (opcode) {
        case MCI_GPM_COEX_VERSION_QUERY:
-               version = ar9003_mci_state(ah, MCI_STATE_SEND_WLAN_COEX_VERSION,
-                                          NULL);
+               ar9003_mci_state(ah, MCI_STATE_SEND_WLAN_COEX_VERSION);
                break;
        case MCI_GPM_COEX_VERSION_RESPONSE:
                major = *(rx_payload + MCI_GPM_COEX_B_MAJOR_VERSION);
                minor = *(rx_payload + MCI_GPM_COEX_B_MINOR_VERSION);
-               version = (major << 8) + minor;
-               version = ar9003_mci_state(ah, MCI_STATE_SET_BT_COEX_VERSION,
-                                          &version);
+               ar9003_mci_set_bt_version(ah, major, minor);
                break;
        case MCI_GPM_COEX_STATUS_QUERY:
-               ar9003_mci_state(ah, MCI_STATE_SEND_WLAN_CHANNELS, NULL);
+               ar9003_mci_send_wlan_channels(ah);
                break;
        case MCI_GPM_COEX_BT_PROFILE_INFO:
                memcpy(&profile_info,
@@ -344,7 +348,7 @@ static void ath_mci_msg(struct ath_softc *sc, u8 opcode, u8 *rx_payload)
 
                seq_num = *((u32 *)(rx_payload + 12));
                ath_dbg(common, MCI,
-                       "BT_Status_Update: is_link=%d, linkId=%d, state=%d, SEQ=%d\n",
+                       "BT_Status_Update: is_link=%d, linkId=%d, state=%d, SEQ=%u\n",
                        profile_status.is_link, profile_status.conn_handle,
                        profile_status.is_critical, seq_num);
 
@@ -412,6 +416,7 @@ void ath_mci_intr(struct ath_softc *sc)
        struct ath_mci_coex *mci = &sc->mci_coex;
        struct ath_hw *ah = sc->sc_ah;
        struct ath_common *common = ath9k_hw_common(ah);
+       struct ath9k_hw_mci *mci_hw = &ah->btcoex_hw.mci;
        u32 mci_int, mci_int_rxmsg;
        u32 offset, subtype, opcode;
        u32 *pgpm;
@@ -420,8 +425,8 @@ void ath_mci_intr(struct ath_softc *sc)
 
        ar9003_mci_get_interrupt(sc->sc_ah, &mci_int, &mci_int_rxmsg);
 
-       if (ar9003_mci_state(ah, MCI_STATE_ENABLE, NULL) == 0) {
-               ar9003_mci_state(ah, MCI_STATE_INIT_GPM_OFFSET, NULL);
+       if (ar9003_mci_state(ah, MCI_STATE_ENABLE) == 0) {
+               ar9003_mci_get_next_gpm_offset(ah, true, NULL);
                return;
        }
 
@@ -440,46 +445,41 @@ void ath_mci_intr(struct ath_softc *sc)
                                        NULL, 0, true, false);
 
                mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_REQ_WAKE;
-               ar9003_mci_state(ah, MCI_STATE_RESET_REQ_WAKE, NULL);
+               ar9003_mci_state(ah, MCI_STATE_RESET_REQ_WAKE);
 
                /*
                 * always do this for recovery and 2G/5G toggling and LNA_TRANS
                 */
-               ar9003_mci_state(ah, MCI_STATE_SET_BT_AWAKE, NULL);
+               ar9003_mci_state(ah, MCI_STATE_SET_BT_AWAKE);
        }
 
        if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_SYS_WAKING) {
                mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_SYS_WAKING;
 
-               if (ar9003_mci_state(ah, MCI_STATE_BT, NULL) == MCI_BT_SLEEP) {
-                       if (ar9003_mci_state(ah, MCI_STATE_REMOTE_SLEEP, NULL) !=
-                           MCI_BT_SLEEP)
-                               ar9003_mci_state(ah, MCI_STATE_SET_BT_AWAKE,
-                                                NULL);
-               }
+               if ((mci_hw->bt_state == MCI_BT_SLEEP) &&
+                   (ar9003_mci_state(ah, MCI_STATE_REMOTE_SLEEP) !=
+                    MCI_BT_SLEEP))
+                       ar9003_mci_state(ah, MCI_STATE_SET_BT_AWAKE);
        }
 
        if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_SYS_SLEEPING) {
                mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_SYS_SLEEPING;
 
-               if (ar9003_mci_state(ah, MCI_STATE_BT, NULL) == MCI_BT_AWAKE) {
-                       if (ar9003_mci_state(ah, MCI_STATE_REMOTE_SLEEP, NULL) !=
-                           MCI_BT_AWAKE)
-                               ar9003_mci_state(ah, MCI_STATE_SET_BT_SLEEP,
-                                                NULL);
-               }
+               if ((mci_hw->bt_state == MCI_BT_AWAKE) &&
+                   (ar9003_mci_state(ah, MCI_STATE_REMOTE_SLEEP) !=
+                    MCI_BT_AWAKE))
+                       mci_hw->bt_state = MCI_BT_SLEEP;
        }
 
        if ((mci_int & AR_MCI_INTERRUPT_RX_INVALID_HDR) ||
            (mci_int & AR_MCI_INTERRUPT_CONT_INFO_TIMEOUT)) {
-               ar9003_mci_state(ah, MCI_STATE_RECOVER_RX, NULL);
+               ar9003_mci_state(ah, MCI_STATE_RECOVER_RX);
                skip_gpm = true;
        }
 
        if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_SCHD_INFO) {
                mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_SCHD_INFO;
-               offset = ar9003_mci_state(ah, MCI_STATE_LAST_SCHD_MSG_OFFSET,
-                                         NULL);
+               offset = ar9003_mci_state(ah, MCI_STATE_LAST_SCHD_MSG_OFFSET);
        }
 
        if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_GPM) {
@@ -488,8 +488,8 @@ void ath_mci_intr(struct ath_softc *sc)
                while (more_data == MCI_GPM_MORE) {
 
                        pgpm = mci->gpm_buf.bf_addr;
-                       offset = ar9003_mci_state(ah, MCI_STATE_NEXT_GPM_OFFSET,
-                                                 &more_data);
+                       offset = ar9003_mci_get_next_gpm_offset(ah, false,
+                                                               &more_data);
 
                        if (offset == MCI_GPM_INVALID)
                                break;
@@ -530,23 +530,17 @@ void ath_mci_intr(struct ath_softc *sc)
                        mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_LNA_INFO;
 
                if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_CONT_INFO) {
-                       int value_dbm = ar9003_mci_state(ah,
-                                                MCI_STATE_CONT_RSSI_POWER, NULL);
+                       int value_dbm = MS(mci_hw->cont_status,
+                                          AR_MCI_CONT_RSSI_POWER);
 
                        mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_CONT_INFO;
 
-                       if (ar9003_mci_state(ah, MCI_STATE_CONT_TXRX, NULL))
-                               ath_dbg(common, MCI,
-                                       "MCI CONT_INFO: (tx) pri = %d, pwr = %d dBm\n",
-                                       ar9003_mci_state(ah,
-                                                MCI_STATE_CONT_PRIORITY, NULL),
-                                       value_dbm);
-                       else
-                               ath_dbg(common, MCI,
-                                       "MCI CONT_INFO: (rx) pri = %d,pwr = %d dBm\n",
-                                       ar9003_mci_state(ah,
-                                                MCI_STATE_CONT_PRIORITY, NULL),
-                                       value_dbm);
+                       ath_dbg(common, MCI,
+                               "MCI CONT_INFO: (%s) pri = %d pwr = %d dBm\n",
+                               MS(mci_hw->cont_status, AR_MCI_CONT_TXRX) ?
+                               "tx" : "rx",
+                               MS(mci_hw->cont_status, AR_MCI_CONT_PRIORITY),
+                               value_dbm);
                }
 
                if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_CONT_NACK)