ath9k: Fix GPM initialization
authorSujith Manoharan <c_manoha@qca.qualcomm.com>
Mon, 16 Feb 2015 05:20:00 +0000 (10:50 +0530)
committerKalle Valo <kvalo@codeaurora.org>
Tue, 3 Mar 2015 12:55:24 +0000 (14:55 +0200)
Handle MCI_STATE_INIT_GPM_OFFSET separately and do not
overload ar9003_mci_get_next_gpm_offset() with a special
case.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/ath/ath9k/ar9003_mci.c
drivers/net/wireless/ath/ath9k/ar9003_mci.h
drivers/net/wireless/ath/ath9k/mci.c

index 505dfe357d1535e7011c8ebbe62396016c5b9333..133b8674c920aab0de8c1e87c2fdeb9b926d7034 100644 (file)
@@ -593,7 +593,7 @@ static u32 ar9003_mci_wait_for_gpm(struct ath_hw *ah, u8 gpm_type,
                if (!time_out)
                        break;
 
-               offset = ar9003_mci_get_next_gpm_offset(ah, false, &more_data);
+               offset = ar9003_mci_get_next_gpm_offset(ah, &more_data);
 
                if (offset == MCI_GPM_INVALID)
                        continue;
@@ -657,7 +657,7 @@ static u32 ar9003_mci_wait_for_gpm(struct ath_hw *ah, u8 gpm_type,
                time_out = 0;
 
        while (more_data == MCI_GPM_MORE) {
-               offset = ar9003_mci_get_next_gpm_offset(ah, false, &more_data);
+               offset = ar9003_mci_get_next_gpm_offset(ah, &more_data);
                if (offset == MCI_GPM_INVALID)
                        break;
 
@@ -986,7 +986,8 @@ int ar9003_mci_reset(struct ath_hw *ah, bool en_int, bool is_2g,
        regval &= ~SM(1, AR_MCI_COMMAND2_RESET_RX);
        REG_WRITE(ah, AR_MCI_COMMAND2, regval);
 
-       ar9003_mci_get_next_gpm_offset(ah, true, NULL);
+       /* Init GPM offset after MCI Reset Rx */
+       ar9003_mci_state(ah, MCI_STATE_INIT_GPM_OFFSET);
 
        REG_WRITE(ah, AR_MCI_MSG_ATTRIBUTES_TABLE,
                  (SM(0xe801, AR_MCI_MSG_ATTRIBUTES_TABLE_INVALID_HDR) |
@@ -1280,6 +1281,14 @@ u32 ar9003_mci_state(struct ath_hw *ah, u32 state_type)
                }
                value &= AR_BTCOEX_CTRL_MCI_MODE_EN;
                break;
+       case MCI_STATE_INIT_GPM_OFFSET:
+               value = MS(REG_READ(ah, AR_MCI_GPM_1), AR_MCI_GPM_WRITE_PTR);
+
+               if (value < mci->gpm_len)
+                       mci->gpm_idx = value;
+               else
+                       mci->gpm_idx = 0;
+               break;
        case MCI_STATE_LAST_SCHD_MSG_OFFSET:
                value = MS(REG_READ(ah, AR_MCI_RX_STATUS),
                                    AR_MCI_RX_LAST_SCHD_MSG_INDEX);
@@ -1426,21 +1435,11 @@ void ar9003_mci_check_gpm_offset(struct ath_hw *ah)
        mci->gpm_idx = 0;
 }
 
-u32 ar9003_mci_get_next_gpm_offset(struct ath_hw *ah, bool first, u32 *more)
+u32 ar9003_mci_get_next_gpm_offset(struct ath_hw *ah, u32 *more)
 {
        struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
        u32 offset, more_gpm = 0, gpm_ptr;
 
-       if (first) {
-               gpm_ptr = MS(REG_READ(ah, AR_MCI_GPM_1), AR_MCI_GPM_WRITE_PTR);
-
-               if (gpm_ptr >= mci->gpm_len)
-                       gpm_ptr = 0;
-
-               mci->gpm_idx = gpm_ptr;
-               return gpm_ptr;
-       }
-
        /*
         * This could be useful to avoid new GPM message interrupt which
         * may lead to spurious interrupt after power sleep, or multiple
index 174ebea5db6f09bae7837e04372a1fea2fbde140..e288611c12d50de2959c8a0178597c60097ae6b9 100644 (file)
@@ -312,7 +312,7 @@ int ar9003_mci_setup(struct ath_hw *ah, u32 gpm_addr, void *gpm_buf,
 void ar9003_mci_cleanup(struct ath_hw *ah);
 void ar9003_mci_get_interrupt(struct ath_hw *ah, u32 *raw_intr,
                              u32 *rx_msg_intr);
-u32 ar9003_mci_get_next_gpm_offset(struct ath_hw *ah, bool first, u32 *more);
+u32 ar9003_mci_get_next_gpm_offset(struct ath_hw *ah, u32 *more);
 void ar9003_mci_set_bt_version(struct ath_hw *ah, u8 major, u8 minor);
 void ar9003_mci_send_wlan_channels(struct ath_hw *ah);
 /*
index 3f7a11edb82a77dedcfdc5f38fa4c6c832e9579e..66596b95273fe6f98eef7756c8ca55297e35d023 100644 (file)
@@ -495,7 +495,7 @@ 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) == 0) {
-               ar9003_mci_get_next_gpm_offset(ah, true, NULL);
+               ar9003_mci_state(ah, MCI_STATE_INIT_GPM_OFFSET);
                return;
        }
 
@@ -559,8 +559,7 @@ void ath_mci_intr(struct ath_softc *sc)
                                return;
 
                        pgpm = mci->gpm_buf.bf_addr;
-                       offset = ar9003_mci_get_next_gpm_offset(ah, false,
-                                                               &more_data);
+                       offset = ar9003_mci_get_next_gpm_offset(ah, &more_data);
 
                        if (offset == MCI_GPM_INVALID)
                                break;