Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2010-2011 Atheros Communications Inc. |
| 3 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | * purpose with or without fee is hereby granted, provided that the above |
| 6 | * copyright notice and this permission notice appear in all copies. |
| 7 | * |
| 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 15 | */ |
| 16 | |
Mohammed Shafi Shajakhan | 9e25365 | 2011-11-30 10:41:23 +0530 | [diff] [blame] | 17 | #include <linux/dma-mapping.h> |
| 18 | #include <linux/slab.h> |
| 19 | |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 20 | #include "ath9k.h" |
| 21 | #include "mci.h" |
| 22 | |
Rajkumar Manoharan | a197b76 | 2012-06-12 10:13:54 +0530 | [diff] [blame] | 23 | static const u8 ath_mci_duty_cycle[] = { 55, 50, 60, 70, 80, 85, 90, 95, 98 }; |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 24 | |
| 25 | static struct ath_mci_profile_info* |
| 26 | ath_mci_find_profile(struct ath_mci_profile *mci, |
| 27 | struct ath_mci_profile_info *info) |
| 28 | { |
| 29 | struct ath_mci_profile_info *entry; |
| 30 | |
Rajkumar Manoharan | 9e2e0c8 | 2012-06-11 12:19:36 +0530 | [diff] [blame] | 31 | if (list_empty(&mci->info)) |
| 32 | return NULL; |
| 33 | |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 34 | list_for_each_entry(entry, &mci->info, list) { |
| 35 | if (entry->conn_handle == info->conn_handle) |
Rajkumar Manoharan | 9e2e0c8 | 2012-06-11 12:19:36 +0530 | [diff] [blame] | 36 | return entry; |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 37 | } |
Rajkumar Manoharan | 9e2e0c8 | 2012-06-11 12:19:36 +0530 | [diff] [blame] | 38 | return NULL; |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | static bool ath_mci_add_profile(struct ath_common *common, |
| 42 | struct ath_mci_profile *mci, |
| 43 | struct ath_mci_profile_info *info) |
| 44 | { |
| 45 | struct ath_mci_profile_info *entry; |
| 46 | |
| 47 | if ((mci->num_sco == ATH_MCI_MAX_SCO_PROFILE) && |
Sujith Manoharan | 682dd04 | 2012-02-22 14:43:52 +0530 | [diff] [blame] | 48 | (info->type == MCI_GPM_COEX_PROFILE_VOICE)) |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 49 | return false; |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 50 | |
| 51 | if (((NUM_PROF(mci) - mci->num_sco) == ATH_MCI_MAX_ACL_PROFILE) && |
Sujith Manoharan | 682dd04 | 2012-02-22 14:43:52 +0530 | [diff] [blame] | 52 | (info->type != MCI_GPM_COEX_PROFILE_VOICE)) |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 53 | return false; |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 54 | |
Rajkumar Manoharan | 3c7992e | 2012-06-12 10:13:53 +0530 | [diff] [blame] | 55 | entry = kzalloc(sizeof(*entry), GFP_ATOMIC); |
Rajkumar Manoharan | 9e2e0c8 | 2012-06-11 12:19:36 +0530 | [diff] [blame] | 56 | if (!entry) |
| 57 | return false; |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 58 | |
Rajkumar Manoharan | 9e2e0c8 | 2012-06-11 12:19:36 +0530 | [diff] [blame] | 59 | memcpy(entry, info, 10); |
| 60 | INC_PROF(mci, info); |
| 61 | list_add_tail(&entry->list, &mci->info); |
Sujith Manoharan | 682dd04 | 2012-02-22 14:43:52 +0530 | [diff] [blame] | 62 | |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 63 | return true; |
| 64 | } |
| 65 | |
| 66 | static void ath_mci_del_profile(struct ath_common *common, |
| 67 | struct ath_mci_profile *mci, |
Rajkumar Manoharan | 9e2e0c8 | 2012-06-11 12:19:36 +0530 | [diff] [blame] | 68 | struct ath_mci_profile_info *entry) |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 69 | { |
Sujith Manoharan | 682dd04 | 2012-02-22 14:43:52 +0530 | [diff] [blame] | 70 | if (!entry) |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 71 | return; |
Sujith Manoharan | 682dd04 | 2012-02-22 14:43:52 +0530 | [diff] [blame] | 72 | |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 73 | DEC_PROF(mci, entry); |
| 74 | list_del(&entry->list); |
| 75 | kfree(entry); |
| 76 | } |
| 77 | |
| 78 | void ath_mci_flush_profile(struct ath_mci_profile *mci) |
| 79 | { |
| 80 | struct ath_mci_profile_info *info, *tinfo; |
| 81 | |
Rajkumar Manoharan | 9e2e0c8 | 2012-06-11 12:19:36 +0530 | [diff] [blame] | 82 | mci->aggr_limit = 0; |
Rajkumar Manoharan | d92bb98 | 2012-09-12 18:59:21 +0530 | [diff] [blame^] | 83 | mci->num_mgmt = 0; |
Rajkumar Manoharan | 9e2e0c8 | 2012-06-11 12:19:36 +0530 | [diff] [blame] | 84 | |
| 85 | if (list_empty(&mci->info)) |
| 86 | return; |
| 87 | |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 88 | list_for_each_entry_safe(info, tinfo, &mci->info, list) { |
| 89 | list_del(&info->list); |
| 90 | DEC_PROF(mci, info); |
| 91 | kfree(info); |
| 92 | } |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | static void ath_mci_adjust_aggr_limit(struct ath_btcoex *btcoex) |
| 96 | { |
| 97 | struct ath_mci_profile *mci = &btcoex->mci; |
| 98 | u32 wlan_airtime = btcoex->btcoex_period * |
| 99 | (100 - btcoex->duty_cycle) / 100; |
| 100 | |
| 101 | /* |
| 102 | * Scale: wlan_airtime is in ms, aggr_limit is in 0.25 ms. |
| 103 | * When wlan_airtime is less than 4ms, aggregation limit has to be |
| 104 | * adjusted half of wlan_airtime to ensure that the aggregation can fit |
| 105 | * without collision with BT traffic. |
| 106 | */ |
| 107 | if ((wlan_airtime <= 4) && |
| 108 | (!mci->aggr_limit || (mci->aggr_limit > (2 * wlan_airtime)))) |
| 109 | mci->aggr_limit = 2 * wlan_airtime; |
| 110 | } |
| 111 | |
| 112 | static void ath_mci_update_scheme(struct ath_softc *sc) |
| 113 | { |
| 114 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
| 115 | struct ath_btcoex *btcoex = &sc->btcoex; |
| 116 | struct ath_mci_profile *mci = &btcoex->mci; |
Rajkumar Manoharan | 0603143 | 2012-06-04 16:28:36 +0530 | [diff] [blame] | 117 | struct ath9k_hw_mci *mci_hw = &sc->sc_ah->btcoex_hw.mci; |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 118 | struct ath_mci_profile_info *info; |
| 119 | u32 num_profile = NUM_PROF(mci); |
| 120 | |
Rajkumar Manoharan | 0603143 | 2012-06-04 16:28:36 +0530 | [diff] [blame] | 121 | if (mci_hw->config & ATH_MCI_CONFIG_DISABLE_TUNING) |
| 122 | goto skip_tuning; |
| 123 | |
Rajkumar Manoharan | a197b76 | 2012-06-12 10:13:54 +0530 | [diff] [blame] | 124 | btcoex->duty_cycle = ath_mci_duty_cycle[num_profile]; |
| 125 | |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 126 | if (num_profile == 1) { |
| 127 | info = list_first_entry(&mci->info, |
| 128 | struct ath_mci_profile_info, |
| 129 | list); |
Rajkumar Manoharan | 0603143 | 2012-06-04 16:28:36 +0530 | [diff] [blame] | 130 | if (mci->num_sco) { |
| 131 | if (info->T == 12) |
| 132 | mci->aggr_limit = 8; |
| 133 | else if (info->T == 6) { |
| 134 | mci->aggr_limit = 6; |
| 135 | btcoex->duty_cycle = 30; |
| 136 | } |
Joe Perches | d2182b6 | 2011-12-15 14:55:53 -0800 | [diff] [blame] | 137 | ath_dbg(common, MCI, |
Rajkumar Manoharan | 0603143 | 2012-06-04 16:28:36 +0530 | [diff] [blame] | 138 | "Single SCO, aggregation limit %d 1/4 ms\n", |
| 139 | mci->aggr_limit); |
| 140 | } else if (mci->num_pan || mci->num_other_acl) { |
| 141 | /* |
| 142 | * For single PAN/FTP profile, allocate 35% for BT |
| 143 | * to improve WLAN throughput. |
| 144 | */ |
| 145 | btcoex->duty_cycle = 35; |
| 146 | btcoex->btcoex_period = 53; |
Joe Perches | d2182b6 | 2011-12-15 14:55:53 -0800 | [diff] [blame] | 147 | ath_dbg(common, MCI, |
Rajkumar Manoharan | 0603143 | 2012-06-04 16:28:36 +0530 | [diff] [blame] | 148 | "Single PAN/FTP bt period %d ms dutycycle %d\n", |
| 149 | btcoex->duty_cycle, btcoex->btcoex_period); |
| 150 | } else if (mci->num_hid) { |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 151 | btcoex->duty_cycle = 30; |
Rajkumar Manoharan | 0603143 | 2012-06-04 16:28:36 +0530 | [diff] [blame] | 152 | mci->aggr_limit = 6; |
Joe Perches | d2182b6 | 2011-12-15 14:55:53 -0800 | [diff] [blame] | 153 | ath_dbg(common, MCI, |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 154 | "Multiple attempt/timeout single HID " |
Rajkumar Manoharan | 0603143 | 2012-06-04 16:28:36 +0530 | [diff] [blame] | 155 | "aggregation limit 1.5 ms dutycycle 30%%\n"); |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 156 | } |
Rajkumar Manoharan | 0603143 | 2012-06-04 16:28:36 +0530 | [diff] [blame] | 157 | } else if (num_profile == 2) { |
| 158 | if (mci->num_hid == 2) |
| 159 | btcoex->duty_cycle = 30; |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 160 | mci->aggr_limit = 6; |
Joe Perches | d2182b6 | 2011-12-15 14:55:53 -0800 | [diff] [blame] | 161 | ath_dbg(common, MCI, |
Rajkumar Manoharan | 0603143 | 2012-06-04 16:28:36 +0530 | [diff] [blame] | 162 | "Two BT profiles aggr limit 1.5 ms dutycycle %d%%\n", |
| 163 | btcoex->duty_cycle); |
| 164 | } else if (num_profile >= 3) { |
| 165 | mci->aggr_limit = 4; |
| 166 | ath_dbg(common, MCI, |
| 167 | "Three or more profiles aggregation limit 1 ms\n"); |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 168 | } |
| 169 | |
Rajkumar Manoharan | 0603143 | 2012-06-04 16:28:36 +0530 | [diff] [blame] | 170 | skip_tuning: |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 171 | if (IS_CHAN_2GHZ(sc->sc_ah->curchan)) { |
| 172 | if (IS_CHAN_HT(sc->sc_ah->curchan)) |
| 173 | ath_mci_adjust_aggr_limit(btcoex); |
| 174 | else |
| 175 | btcoex->btcoex_period >>= 1; |
| 176 | } |
| 177 | |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 178 | ath9k_btcoex_timer_pause(sc); |
Mohammed Shafi Shajakhan | c32cdbd | 2012-07-06 20:09:32 +0530 | [diff] [blame] | 179 | ath9k_hw_btcoex_disable(sc->sc_ah); |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 180 | |
| 181 | if (IS_CHAN_5GHZ(sc->sc_ah->curchan)) |
| 182 | return; |
| 183 | |
Rajkumar Manoharan | a197b76 | 2012-06-12 10:13:54 +0530 | [diff] [blame] | 184 | btcoex->duty_cycle += (mci->num_bdr ? ATH_MCI_BDR_DUTY_CYCLE : 0); |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 185 | if (btcoex->duty_cycle > ATH_MCI_MAX_DUTY_CYCLE) |
| 186 | btcoex->duty_cycle = ATH_MCI_MAX_DUTY_CYCLE; |
| 187 | |
Rajkumar Manoharan | dfd0587 | 2012-06-11 12:19:37 +0530 | [diff] [blame] | 188 | btcoex->btcoex_no_stomp = btcoex->btcoex_period * 1000 * |
Sujith Manoharan | 682dd04 | 2012-02-22 14:43:52 +0530 | [diff] [blame] | 189 | (100 - btcoex->duty_cycle) / 100; |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 190 | |
| 191 | ath9k_hw_btcoex_enable(sc->sc_ah); |
| 192 | ath9k_btcoex_timer_resume(sc); |
| 193 | } |
| 194 | |
Rajkumar Manoharan | 83ad49a | 2012-09-10 17:05:09 +0530 | [diff] [blame] | 195 | static void ath_mci_wait_btcal_done(struct ath_softc *sc) |
| 196 | { |
| 197 | struct ath_hw *ah = sc->sc_ah; |
| 198 | |
| 199 | /* Stop tx & rx */ |
| 200 | ieee80211_stop_queues(sc->hw); |
| 201 | ath_stoprecv(sc); |
| 202 | ath_drain_all_txq(sc, false); |
| 203 | |
| 204 | /* Wait for cal done */ |
| 205 | ar9003_mci_start_reset(ah, ah->curchan); |
| 206 | |
| 207 | /* Resume tx & rx */ |
| 208 | ath_startrecv(sc); |
| 209 | ieee80211_wake_queues(sc->hw); |
| 210 | } |
| 211 | |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 212 | static void ath_mci_cal_msg(struct ath_softc *sc, u8 opcode, u8 *rx_payload) |
| 213 | { |
| 214 | struct ath_hw *ah = sc->sc_ah; |
| 215 | struct ath_common *common = ath9k_hw_common(ah); |
Rajkumar Manoharan | 6d97be4 | 2012-06-12 20:18:21 +0530 | [diff] [blame] | 216 | struct ath9k_hw_mci *mci_hw = &ah->btcoex_hw.mci; |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 217 | u32 payload[4] = {0, 0, 0, 0}; |
| 218 | |
| 219 | switch (opcode) { |
| 220 | case MCI_GPM_BT_CAL_REQ: |
Rajkumar Manoharan | 6d97be4 | 2012-06-12 20:18:21 +0530 | [diff] [blame] | 221 | if (mci_hw->bt_state == MCI_BT_AWAKE) { |
Mohammed Shafi Shajakhan | 4653356 | 2012-08-24 16:27:06 +0530 | [diff] [blame] | 222 | mci_hw->bt_state = MCI_BT_CAL_START; |
Rajkumar Manoharan | 83ad49a | 2012-09-10 17:05:09 +0530 | [diff] [blame] | 223 | ath_mci_wait_btcal_done(sc); |
Sujith Manoharan | 682dd04 | 2012-02-22 14:43:52 +0530 | [diff] [blame] | 224 | } |
Rajkumar Manoharan | 6d97be4 | 2012-06-12 20:18:21 +0530 | [diff] [blame] | 225 | ath_dbg(common, MCI, "MCI State : %d\n", mci_hw->bt_state); |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 226 | break; |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 227 | case MCI_GPM_BT_CAL_GRANT: |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 228 | MCI_GPM_SET_CAL_TYPE(payload, MCI_GPM_WLAN_CAL_DONE); |
| 229 | ar9003_mci_send_message(sc->sc_ah, MCI_GPM, 0, payload, |
| 230 | 16, false, true); |
| 231 | break; |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 232 | default: |
Sujith Manoharan | 682dd04 | 2012-02-22 14:43:52 +0530 | [diff] [blame] | 233 | ath_dbg(common, MCI, "Unknown GPM CAL message\n"); |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 234 | break; |
| 235 | } |
| 236 | } |
| 237 | |
Rajkumar Manoharan | 3c7992e | 2012-06-12 10:13:53 +0530 | [diff] [blame] | 238 | static void ath9k_mci_work(struct work_struct *work) |
| 239 | { |
| 240 | struct ath_softc *sc = container_of(work, struct ath_softc, mci_work); |
| 241 | |
| 242 | ath_mci_update_scheme(sc); |
| 243 | } |
| 244 | |
Felix Fietkau | e5f0a27 | 2011-12-10 22:11:19 +0100 | [diff] [blame] | 245 | static void ath_mci_process_profile(struct ath_softc *sc, |
| 246 | struct ath_mci_profile_info *info) |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 247 | { |
| 248 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
| 249 | struct ath_btcoex *btcoex = &sc->btcoex; |
| 250 | struct ath_mci_profile *mci = &btcoex->mci; |
Rajkumar Manoharan | 9e2e0c8 | 2012-06-11 12:19:36 +0530 | [diff] [blame] | 251 | struct ath_mci_profile_info *entry = NULL; |
| 252 | |
| 253 | entry = ath_mci_find_profile(mci, info); |
Bala Shanmugam | 305dd09f | 2012-06-18 11:36:58 +0530 | [diff] [blame] | 254 | if (entry) { |
| 255 | /* |
| 256 | * Two MCI interrupts are generated while connecting to |
| 257 | * headset and A2DP profile, but only one MCI interrupt |
| 258 | * is generated with last added profile type while disconnecting |
| 259 | * both profiles. |
| 260 | * So while adding second profile type decrement |
| 261 | * the first one. |
| 262 | */ |
| 263 | if (entry->type != info->type) { |
| 264 | DEC_PROF(mci, entry); |
| 265 | INC_PROF(mci, info); |
| 266 | } |
Rajkumar Manoharan | 9e2e0c8 | 2012-06-11 12:19:36 +0530 | [diff] [blame] | 267 | memcpy(entry, info, 10); |
Bala Shanmugam | 305dd09f | 2012-06-18 11:36:58 +0530 | [diff] [blame] | 268 | } |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 269 | |
| 270 | if (info->start) { |
Rajkumar Manoharan | 9e2e0c8 | 2012-06-11 12:19:36 +0530 | [diff] [blame] | 271 | if (!entry && !ath_mci_add_profile(common, mci, info)) |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 272 | return; |
| 273 | } else |
Rajkumar Manoharan | 9e2e0c8 | 2012-06-11 12:19:36 +0530 | [diff] [blame] | 274 | ath_mci_del_profile(common, mci, entry); |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 275 | |
| 276 | btcoex->btcoex_period = ATH_MCI_DEF_BT_PERIOD; |
| 277 | mci->aggr_limit = mci->num_sco ? 6 : 0; |
Sujith Manoharan | 682dd04 | 2012-02-22 14:43:52 +0530 | [diff] [blame] | 278 | |
Rajkumar Manoharan | a197b76 | 2012-06-12 10:13:54 +0530 | [diff] [blame] | 279 | btcoex->duty_cycle = ath_mci_duty_cycle[NUM_PROF(mci)]; |
| 280 | if (NUM_PROF(mci)) |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 281 | btcoex->bt_stomp_type = ATH_BTCOEX_STOMP_LOW; |
Rajkumar Manoharan | a197b76 | 2012-06-12 10:13:54 +0530 | [diff] [blame] | 282 | else |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 283 | btcoex->bt_stomp_type = mci->num_mgmt ? ATH_BTCOEX_STOMP_ALL : |
| 284 | ATH_BTCOEX_STOMP_LOW; |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 285 | |
Rajkumar Manoharan | 3c7992e | 2012-06-12 10:13:53 +0530 | [diff] [blame] | 286 | ieee80211_queue_work(sc->hw, &sc->mci_work); |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 287 | } |
| 288 | |
Felix Fietkau | e5f0a27 | 2011-12-10 22:11:19 +0100 | [diff] [blame] | 289 | static void ath_mci_process_status(struct ath_softc *sc, |
| 290 | struct ath_mci_profile_status *status) |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 291 | { |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 292 | struct ath_btcoex *btcoex = &sc->btcoex; |
| 293 | struct ath_mci_profile *mci = &btcoex->mci; |
| 294 | struct ath_mci_profile_info info; |
| 295 | int i = 0, old_num_mgmt = mci->num_mgmt; |
| 296 | |
| 297 | /* Link status type are not handled */ |
Sujith Manoharan | 682dd04 | 2012-02-22 14:43:52 +0530 | [diff] [blame] | 298 | if (status->is_link) |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 299 | return; |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 300 | |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 301 | info.conn_handle = status->conn_handle; |
Sujith Manoharan | 682dd04 | 2012-02-22 14:43:52 +0530 | [diff] [blame] | 302 | if (ath_mci_find_profile(mci, &info)) |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 303 | return; |
Sujith Manoharan | 682dd04 | 2012-02-22 14:43:52 +0530 | [diff] [blame] | 304 | |
| 305 | if (status->conn_handle >= ATH_MCI_MAX_PROFILE) |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 306 | return; |
Sujith Manoharan | 682dd04 | 2012-02-22 14:43:52 +0530 | [diff] [blame] | 307 | |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 308 | if (status->is_critical) |
| 309 | __set_bit(status->conn_handle, mci->status); |
| 310 | else |
| 311 | __clear_bit(status->conn_handle, mci->status); |
| 312 | |
| 313 | mci->num_mgmt = 0; |
| 314 | do { |
| 315 | if (test_bit(i, mci->status)) |
| 316 | mci->num_mgmt++; |
| 317 | } while (++i < ATH_MCI_MAX_PROFILE); |
| 318 | |
| 319 | if (old_num_mgmt != mci->num_mgmt) |
Rajkumar Manoharan | 3c7992e | 2012-06-12 10:13:53 +0530 | [diff] [blame] | 320 | ieee80211_queue_work(sc->hw, &sc->mci_work); |
Rajkumar Manoharan | 7dc181c | 2011-10-24 18:19:49 +0530 | [diff] [blame] | 321 | } |
Mohammed Shafi Shajakhan | 9e25365 | 2011-11-30 10:41:23 +0530 | [diff] [blame] | 322 | |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 323 | static void ath_mci_msg(struct ath_softc *sc, u8 opcode, u8 *rx_payload) |
| 324 | { |
| 325 | struct ath_hw *ah = sc->sc_ah; |
| 326 | struct ath_mci_profile_info profile_info; |
| 327 | struct ath_mci_profile_status profile_status; |
| 328 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Rajkumar Manoharan | e1763d3 | 2012-06-12 20:18:17 +0530 | [diff] [blame] | 329 | u8 major, minor; |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 330 | u32 seq_num; |
| 331 | |
Rajkumar Manoharan | d92bb98 | 2012-09-12 18:59:21 +0530 | [diff] [blame^] | 332 | if (ar9003_mci_state(ah, MCI_STATE_NEED_FLUSH_BT_INFO) && |
| 333 | ar9003_mci_state(ah, MCI_STATE_ENABLE)) { |
| 334 | ath_dbg(common, MCI, "(MCI) Need to flush BT profiles\n"); |
| 335 | ath_mci_flush_profile(&sc->btcoex.mci); |
| 336 | ar9003_mci_state(ah, MCI_STATE_SEND_STATUS_QUERY); |
| 337 | } |
| 338 | |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 339 | switch (opcode) { |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 340 | case MCI_GPM_COEX_VERSION_QUERY: |
Rajkumar Manoharan | b98ccec | 2012-06-12 20:18:20 +0530 | [diff] [blame] | 341 | ar9003_mci_state(ah, MCI_STATE_SEND_WLAN_COEX_VERSION); |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 342 | break; |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 343 | case MCI_GPM_COEX_VERSION_RESPONSE: |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 344 | major = *(rx_payload + MCI_GPM_COEX_B_MAJOR_VERSION); |
| 345 | minor = *(rx_payload + MCI_GPM_COEX_B_MINOR_VERSION); |
Rajkumar Manoharan | e1763d3 | 2012-06-12 20:18:17 +0530 | [diff] [blame] | 346 | ar9003_mci_set_bt_version(ah, major, minor); |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 347 | break; |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 348 | case MCI_GPM_COEX_STATUS_QUERY: |
Rajkumar Manoharan | 2d340ac | 2012-06-12 20:18:18 +0530 | [diff] [blame] | 349 | ar9003_mci_send_wlan_channels(ah); |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 350 | break; |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 351 | case MCI_GPM_COEX_BT_PROFILE_INFO: |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 352 | memcpy(&profile_info, |
| 353 | (rx_payload + MCI_GPM_COEX_B_PROFILE_TYPE), 10); |
| 354 | |
Sujith Manoharan | 682dd04 | 2012-02-22 14:43:52 +0530 | [diff] [blame] | 355 | if ((profile_info.type == MCI_GPM_COEX_PROFILE_UNKNOWN) || |
| 356 | (profile_info.type >= MCI_GPM_COEX_PROFILE_MAX)) { |
Joe Perches | d2182b6 | 2011-12-15 14:55:53 -0800 | [diff] [blame] | 357 | ath_dbg(common, MCI, |
Sujith Manoharan | 682dd04 | 2012-02-22 14:43:52 +0530 | [diff] [blame] | 358 | "Illegal profile type = %d, state = %d\n", |
Joe Perches | d2182b6 | 2011-12-15 14:55:53 -0800 | [diff] [blame] | 359 | profile_info.type, |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 360 | profile_info.start); |
| 361 | break; |
| 362 | } |
| 363 | |
| 364 | ath_mci_process_profile(sc, &profile_info); |
| 365 | break; |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 366 | case MCI_GPM_COEX_BT_STATUS_UPDATE: |
| 367 | profile_status.is_link = *(rx_payload + |
| 368 | MCI_GPM_COEX_B_STATUS_TYPE); |
| 369 | profile_status.conn_handle = *(rx_payload + |
| 370 | MCI_GPM_COEX_B_STATUS_LINKID); |
| 371 | profile_status.is_critical = *(rx_payload + |
| 372 | MCI_GPM_COEX_B_STATUS_STATE); |
| 373 | |
| 374 | seq_num = *((u32 *)(rx_payload + 12)); |
Joe Perches | d2182b6 | 2011-12-15 14:55:53 -0800 | [diff] [blame] | 375 | ath_dbg(common, MCI, |
Mohammed Shafi Shajakhan | d8fffb4 | 2012-06-27 20:00:27 +0530 | [diff] [blame] | 376 | "BT_Status_Update: is_link=%d, linkId=%d, state=%d, SEQ=%u\n", |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 377 | profile_status.is_link, profile_status.conn_handle, |
| 378 | profile_status.is_critical, seq_num); |
| 379 | |
| 380 | ath_mci_process_status(sc, &profile_status); |
| 381 | break; |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 382 | default: |
Sujith Manoharan | 682dd04 | 2012-02-22 14:43:52 +0530 | [diff] [blame] | 383 | ath_dbg(common, MCI, "Unknown GPM COEX message = 0x%02x\n", opcode); |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 384 | break; |
| 385 | } |
| 386 | } |
Mohammed Shafi Shajakhan | 9e25365 | 2011-11-30 10:41:23 +0530 | [diff] [blame] | 387 | |
Mohammed Shafi Shajakhan | 9e25365 | 2011-11-30 10:41:23 +0530 | [diff] [blame] | 388 | int ath_mci_setup(struct ath_softc *sc) |
| 389 | { |
| 390 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
| 391 | struct ath_mci_coex *mci = &sc->mci_coex; |
Sujith Manoharan | ea510e4 | 2012-02-22 12:40:09 +0530 | [diff] [blame] | 392 | struct ath_mci_buf *buf = &mci->sched_buf; |
Mohammed Shafi Shajakhan | 9e25365 | 2011-11-30 10:41:23 +0530 | [diff] [blame] | 393 | |
Sujith Manoharan | ea510e4 | 2012-02-22 12:40:09 +0530 | [diff] [blame] | 394 | buf->bf_addr = dma_alloc_coherent(sc->dev, |
| 395 | ATH_MCI_SCHED_BUF_SIZE + ATH_MCI_GPM_BUF_SIZE, |
| 396 | &buf->bf_paddr, GFP_KERNEL); |
Mohammed Shafi Shajakhan | 9e25365 | 2011-11-30 10:41:23 +0530 | [diff] [blame] | 397 | |
Sujith Manoharan | ea510e4 | 2012-02-22 12:40:09 +0530 | [diff] [blame] | 398 | if (buf->bf_addr == NULL) { |
Joe Perches | d2182b6 | 2011-12-15 14:55:53 -0800 | [diff] [blame] | 399 | ath_dbg(common, FATAL, "MCI buffer alloc failed\n"); |
Sujith Manoharan | ea510e4 | 2012-02-22 12:40:09 +0530 | [diff] [blame] | 400 | return -ENOMEM; |
Mohammed Shafi Shajakhan | 9e25365 | 2011-11-30 10:41:23 +0530 | [diff] [blame] | 401 | } |
| 402 | |
Sujith Manoharan | ea510e4 | 2012-02-22 12:40:09 +0530 | [diff] [blame] | 403 | memset(buf->bf_addr, MCI_GPM_RSVD_PATTERN, |
| 404 | ATH_MCI_SCHED_BUF_SIZE + ATH_MCI_GPM_BUF_SIZE); |
| 405 | |
Mohammed Shafi Shajakhan | 9e25365 | 2011-11-30 10:41:23 +0530 | [diff] [blame] | 406 | mci->sched_buf.bf_len = ATH_MCI_SCHED_BUF_SIZE; |
| 407 | |
Mohammed Shafi Shajakhan | 9e25365 | 2011-11-30 10:41:23 +0530 | [diff] [blame] | 408 | mci->gpm_buf.bf_len = ATH_MCI_GPM_BUF_SIZE; |
Sujith Manoharan | ea510e4 | 2012-02-22 12:40:09 +0530 | [diff] [blame] | 409 | mci->gpm_buf.bf_addr = (u8 *)mci->sched_buf.bf_addr + mci->sched_buf.bf_len; |
Mohammed Shafi Shajakhan | 9e25365 | 2011-11-30 10:41:23 +0530 | [diff] [blame] | 410 | mci->gpm_buf.bf_paddr = mci->sched_buf.bf_paddr + mci->sched_buf.bf_len; |
| 411 | |
Mohammed Shafi Shajakhan | 9e25365 | 2011-11-30 10:41:23 +0530 | [diff] [blame] | 412 | ar9003_mci_setup(sc->sc_ah, mci->gpm_buf.bf_paddr, |
| 413 | mci->gpm_buf.bf_addr, (mci->gpm_buf.bf_len >> 4), |
| 414 | mci->sched_buf.bf_paddr); |
Sujith Manoharan | ea510e4 | 2012-02-22 12:40:09 +0530 | [diff] [blame] | 415 | |
Rajkumar Manoharan | 3c7992e | 2012-06-12 10:13:53 +0530 | [diff] [blame] | 416 | INIT_WORK(&sc->mci_work, ath9k_mci_work); |
Sujith Manoharan | ea510e4 | 2012-02-22 12:40:09 +0530 | [diff] [blame] | 417 | ath_dbg(common, MCI, "MCI Initialized\n"); |
| 418 | |
| 419 | return 0; |
Mohammed Shafi Shajakhan | 9e25365 | 2011-11-30 10:41:23 +0530 | [diff] [blame] | 420 | } |
| 421 | |
| 422 | void ath_mci_cleanup(struct ath_softc *sc) |
| 423 | { |
Sujith Manoharan | ea510e4 | 2012-02-22 12:40:09 +0530 | [diff] [blame] | 424 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Mohammed Shafi Shajakhan | 9e25365 | 2011-11-30 10:41:23 +0530 | [diff] [blame] | 425 | struct ath_hw *ah = sc->sc_ah; |
| 426 | struct ath_mci_coex *mci = &sc->mci_coex; |
Sujith Manoharan | ea510e4 | 2012-02-22 12:40:09 +0530 | [diff] [blame] | 427 | struct ath_mci_buf *buf = &mci->sched_buf; |
Mohammed Shafi Shajakhan | 9e25365 | 2011-11-30 10:41:23 +0530 | [diff] [blame] | 428 | |
Sujith Manoharan | ea510e4 | 2012-02-22 12:40:09 +0530 | [diff] [blame] | 429 | if (buf->bf_addr) |
| 430 | dma_free_coherent(sc->dev, |
| 431 | ATH_MCI_SCHED_BUF_SIZE + ATH_MCI_GPM_BUF_SIZE, |
| 432 | buf->bf_addr, buf->bf_paddr); |
| 433 | |
Mohammed Shafi Shajakhan | 9e25365 | 2011-11-30 10:41:23 +0530 | [diff] [blame] | 434 | ar9003_mci_cleanup(ah); |
Sujith Manoharan | ea510e4 | 2012-02-22 12:40:09 +0530 | [diff] [blame] | 435 | |
| 436 | ath_dbg(common, MCI, "MCI De-Initialized\n"); |
Mohammed Shafi Shajakhan | 9e25365 | 2011-11-30 10:41:23 +0530 | [diff] [blame] | 437 | } |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 438 | |
| 439 | void ath_mci_intr(struct ath_softc *sc) |
| 440 | { |
| 441 | struct ath_mci_coex *mci = &sc->mci_coex; |
| 442 | struct ath_hw *ah = sc->sc_ah; |
| 443 | struct ath_common *common = ath9k_hw_common(ah); |
Rajkumar Manoharan | 6d97be4 | 2012-06-12 20:18:21 +0530 | [diff] [blame] | 444 | struct ath9k_hw_mci *mci_hw = &ah->btcoex_hw.mci; |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 445 | u32 mci_int, mci_int_rxmsg; |
| 446 | u32 offset, subtype, opcode; |
| 447 | u32 *pgpm; |
| 448 | u32 more_data = MCI_GPM_MORE; |
| 449 | bool skip_gpm = false; |
| 450 | |
| 451 | ar9003_mci_get_interrupt(sc->sc_ah, &mci_int, &mci_int_rxmsg); |
| 452 | |
Rajkumar Manoharan | b98ccec | 2012-06-12 20:18:20 +0530 | [diff] [blame] | 453 | if (ar9003_mci_state(ah, MCI_STATE_ENABLE) == 0) { |
Rajkumar Manoharan | 506847a | 2012-06-12 20:18:16 +0530 | [diff] [blame] | 454 | ar9003_mci_get_next_gpm_offset(ah, true, NULL); |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 455 | return; |
| 456 | } |
| 457 | |
| 458 | if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_REQ_WAKE) { |
| 459 | u32 payload[4] = { 0xffffffff, 0xffffffff, |
| 460 | 0xffffffff, 0xffffff00}; |
| 461 | |
| 462 | /* |
| 463 | * The following REMOTE_RESET and SYS_WAKING used to sent |
| 464 | * only when BT wake up. Now they are always sent, as a |
| 465 | * recovery method to reset BT MCI's RX alignment. |
| 466 | */ |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 467 | ar9003_mci_send_message(ah, MCI_REMOTE_RESET, 0, |
| 468 | payload, 16, true, false); |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 469 | ar9003_mci_send_message(ah, MCI_SYS_WAKING, 0, |
| 470 | NULL, 0, true, false); |
| 471 | |
| 472 | mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_REQ_WAKE; |
Rajkumar Manoharan | b98ccec | 2012-06-12 20:18:20 +0530 | [diff] [blame] | 473 | ar9003_mci_state(ah, MCI_STATE_RESET_REQ_WAKE); |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 474 | |
| 475 | /* |
| 476 | * always do this for recovery and 2G/5G toggling and LNA_TRANS |
| 477 | */ |
Rajkumar Manoharan | b98ccec | 2012-06-12 20:18:20 +0530 | [diff] [blame] | 478 | ar9003_mci_state(ah, MCI_STATE_SET_BT_AWAKE); |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 479 | } |
| 480 | |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 481 | if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_SYS_WAKING) { |
| 482 | mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_SYS_WAKING; |
| 483 | |
Rajkumar Manoharan | 6d97be4 | 2012-06-12 20:18:21 +0530 | [diff] [blame] | 484 | if ((mci_hw->bt_state == MCI_BT_SLEEP) && |
Rajkumar Manoharan | b98ccec | 2012-06-12 20:18:20 +0530 | [diff] [blame] | 485 | (ar9003_mci_state(ah, MCI_STATE_REMOTE_SLEEP) != |
| 486 | MCI_BT_SLEEP)) |
| 487 | ar9003_mci_state(ah, MCI_STATE_SET_BT_AWAKE); |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 488 | } |
| 489 | |
| 490 | if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_SYS_SLEEPING) { |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 491 | mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_SYS_SLEEPING; |
| 492 | |
Rajkumar Manoharan | 6d97be4 | 2012-06-12 20:18:21 +0530 | [diff] [blame] | 493 | if ((mci_hw->bt_state == MCI_BT_AWAKE) && |
Rajkumar Manoharan | b98ccec | 2012-06-12 20:18:20 +0530 | [diff] [blame] | 494 | (ar9003_mci_state(ah, MCI_STATE_REMOTE_SLEEP) != |
| 495 | MCI_BT_AWAKE)) |
Rajkumar Manoharan | 9330969 | 2012-06-12 20:18:23 +0530 | [diff] [blame] | 496 | mci_hw->bt_state = MCI_BT_SLEEP; |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 497 | } |
| 498 | |
| 499 | if ((mci_int & AR_MCI_INTERRUPT_RX_INVALID_HDR) || |
| 500 | (mci_int & AR_MCI_INTERRUPT_CONT_INFO_TIMEOUT)) { |
Rajkumar Manoharan | b98ccec | 2012-06-12 20:18:20 +0530 | [diff] [blame] | 501 | ar9003_mci_state(ah, MCI_STATE_RECOVER_RX); |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 502 | skip_gpm = true; |
| 503 | } |
| 504 | |
| 505 | if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_SCHD_INFO) { |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 506 | mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_SCHD_INFO; |
Rajkumar Manoharan | b98ccec | 2012-06-12 20:18:20 +0530 | [diff] [blame] | 507 | offset = ar9003_mci_state(ah, MCI_STATE_LAST_SCHD_MSG_OFFSET); |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 508 | } |
| 509 | |
| 510 | if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_GPM) { |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 511 | mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_GPM; |
| 512 | |
| 513 | while (more_data == MCI_GPM_MORE) { |
| 514 | |
| 515 | pgpm = mci->gpm_buf.bf_addr; |
Rajkumar Manoharan | 506847a | 2012-06-12 20:18:16 +0530 | [diff] [blame] | 516 | offset = ar9003_mci_get_next_gpm_offset(ah, false, |
| 517 | &more_data); |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 518 | |
| 519 | if (offset == MCI_GPM_INVALID) |
| 520 | break; |
| 521 | |
| 522 | pgpm += (offset >> 2); |
| 523 | |
| 524 | /* |
| 525 | * The first dword is timer. |
| 526 | * The real data starts from 2nd dword. |
| 527 | */ |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 528 | subtype = MCI_GPM_TYPE(pgpm); |
| 529 | opcode = MCI_GPM_OPCODE(pgpm); |
| 530 | |
Sujith Manoharan | 682dd04 | 2012-02-22 14:43:52 +0530 | [diff] [blame] | 531 | if (skip_gpm) |
| 532 | goto recycle; |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 533 | |
Sujith Manoharan | 682dd04 | 2012-02-22 14:43:52 +0530 | [diff] [blame] | 534 | if (MCI_GPM_IS_CAL_TYPE(subtype)) { |
| 535 | ath_mci_cal_msg(sc, subtype, (u8 *)pgpm); |
| 536 | } else { |
| 537 | switch (subtype) { |
| 538 | case MCI_GPM_COEX_AGENT: |
| 539 | ath_mci_msg(sc, opcode, (u8 *)pgpm); |
| 540 | break; |
| 541 | default: |
| 542 | break; |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 543 | } |
| 544 | } |
Sujith Manoharan | 682dd04 | 2012-02-22 14:43:52 +0530 | [diff] [blame] | 545 | recycle: |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 546 | MCI_GPM_RECYCLE(pgpm); |
| 547 | } |
| 548 | } |
| 549 | |
| 550 | if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_HW_MSG_MASK) { |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 551 | if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_LNA_CONTROL) |
| 552 | mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_LNA_CONTROL; |
| 553 | |
Sujith Manoharan | 682dd04 | 2012-02-22 14:43:52 +0530 | [diff] [blame] | 554 | if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_LNA_INFO) |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 555 | mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_LNA_INFO; |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 556 | |
| 557 | if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_CONT_INFO) { |
Rajkumar Manoharan | 26e942b | 2012-06-12 20:18:22 +0530 | [diff] [blame] | 558 | int value_dbm = MS(mci_hw->cont_status, |
| 559 | AR_MCI_CONT_RSSI_POWER); |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 560 | |
| 561 | mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_CONT_INFO; |
| 562 | |
Rajkumar Manoharan | 26e942b | 2012-06-12 20:18:22 +0530 | [diff] [blame] | 563 | ath_dbg(common, MCI, |
| 564 | "MCI CONT_INFO: (%s) pri = %d pwr = %d dBm\n", |
| 565 | MS(mci_hw->cont_status, AR_MCI_CONT_TXRX) ? |
| 566 | "tx" : "rx", |
| 567 | MS(mci_hw->cont_status, AR_MCI_CONT_PRIORITY), |
| 568 | value_dbm); |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 569 | } |
| 570 | |
Sujith Manoharan | 682dd04 | 2012-02-22 14:43:52 +0530 | [diff] [blame] | 571 | if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_CONT_NACK) |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 572 | mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_CONT_NACK; |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 573 | |
Sujith Manoharan | 682dd04 | 2012-02-22 14:43:52 +0530 | [diff] [blame] | 574 | if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_CONT_RST) |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 575 | mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_CONT_RST; |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 576 | } |
| 577 | |
| 578 | if ((mci_int & AR_MCI_INTERRUPT_RX_INVALID_HDR) || |
Rajkumar Manoharan | d92bb98 | 2012-09-12 18:59:21 +0530 | [diff] [blame^] | 579 | (mci_int & AR_MCI_INTERRUPT_CONT_INFO_TIMEOUT)) { |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 580 | mci_int &= ~(AR_MCI_INTERRUPT_RX_INVALID_HDR | |
| 581 | AR_MCI_INTERRUPT_CONT_INFO_TIMEOUT); |
Rajkumar Manoharan | d92bb98 | 2012-09-12 18:59:21 +0530 | [diff] [blame^] | 582 | ath_mci_msg(sc, MCI_GPM_COEX_NOOP, NULL); |
| 583 | } |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 584 | } |
Sujith Manoharan | e270e77 | 2012-06-04 16:27:19 +0530 | [diff] [blame] | 585 | |
| 586 | void ath_mci_enable(struct ath_softc *sc) |
| 587 | { |
| 588 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
| 589 | |
| 590 | if (!common->btcoex_enabled) |
| 591 | return; |
| 592 | |
| 593 | if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_MCI) |
| 594 | sc->sc_ah->imask |= ATH9K_INT_MCI; |
| 595 | } |