ath9k: fix sleep mode handling issues, should improve client mode reliability (backpo...
[openwrt/svn-archive/archive.git] / package / mac80211 / patches / 571-ath9k_btcoex_optional.patch
1 --- a/drivers/net/wireless/ath/ath9k/Kconfig
2 +++ b/drivers/net/wireless/ath/ath9k/Kconfig
3 @@ -59,6 +59,14 @@ config ATH9K_RATE_CONTROL
4 Say Y, if you want to use the ath9k specific rate control
5 module instead of minstrel_ht.
6
7 +config ATH9K_BTCOEX_SUPPORT
8 + bool "Atheros ath9k bluetooth coexistence support"
9 + depends on ATH9K
10 + default y
11 + ---help---
12 + Say Y, if you want to use the ath9k radios together with
13 + Bluetooth modules in the same system.
14 +
15 config ATH9K_HTC
16 tristate "Atheros HTC based wireless cards support"
17 depends on USB && MAC80211
18 --- a/drivers/net/wireless/ath/ath9k/hw.h
19 +++ b/drivers/net/wireless/ath/ath9k/hw.h
20 @@ -210,7 +210,11 @@ enum ath9k_hw_caps {
21 ATH9K_HW_CAP_5GHZ = BIT(14),
22 ATH9K_HW_CAP_APM = BIT(15),
23 ATH9K_HW_CAP_RTT = BIT(16),
24 +#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
25 ATH9K_HW_CAP_MCI = BIT(17),
26 +#else
27 + ATH9K_HW_CAP_MCI = 0,
28 +#endif
29 };
30
31 struct ath9k_hw_capabilities {
32 @@ -1229,6 +1233,16 @@ void ar9003_mci_sync_bt_state(struct ath
33 void ar9003_mci_get_interrupt(struct ath_hw *ah, u32 *raw_intr,
34 u32 *rx_msg_intr);
35
36 +#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
37 +static inline enum ath_btcoex_scheme
38 +ath9k_hw_get_btcoex_scheme(struct ath_hw *ah)
39 +{
40 + return ah->btcoex_hw.scheme;
41 +}
42 +#else
43 +#define ath9k_hw_get_btcoex_scheme(...) ATH_BTCOEX_CFG_NONE
44 +#endif
45 +
46 #define ATH9K_CLOCK_RATE_CCK 22
47 #define ATH9K_CLOCK_RATE_5GHZ_OFDM 40
48 #define ATH9K_CLOCK_RATE_2GHZ_OFDM 44
49 --- a/drivers/net/wireless/ath/ath9k/init.c
50 +++ b/drivers/net/wireless/ath/ath9k/init.c
51 @@ -411,7 +411,7 @@ static int ath9k_init_btcoex(struct ath_
52 struct ath_hw *ah = sc->sc_ah;
53 int r;
54
55 - switch (sc->sc_ah->btcoex_hw.scheme) {
56 + switch (ath9k_hw_get_btcoex_scheme(sc->sc_ah)) {
57 case ATH_BTCOEX_CFG_NONE:
58 break;
59 case ATH_BTCOEX_CFG_2WIRE:
60 @@ -866,10 +866,10 @@ static void ath9k_deinit_softc(struct at
61 kfree(sc->sbands[IEEE80211_BAND_5GHZ].channels);
62
63 if ((sc->btcoex.no_stomp_timer) &&
64 - sc->sc_ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE)
65 + ath9k_hw_get_btcoex_scheme(sc->sc_ah) == ATH_BTCOEX_CFG_3WIRE)
66 ath_gen_timer_free(sc->sc_ah, sc->btcoex.no_stomp_timer);
67
68 - if (sc->sc_ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_MCI)
69 + if (ath9k_hw_get_btcoex_scheme(sc->sc_ah) == ATH_BTCOEX_CFG_MCI)
70 ath_mci_cleanup(sc);
71
72 for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++)
73 --- a/drivers/net/wireless/ath/ath9k/pci.c
74 +++ b/drivers/net/wireless/ath/ath9k/pci.c
75 @@ -121,7 +121,7 @@ static void ath_pci_aspm_init(struct ath
76 if (!parent)
77 return;
78
79 - if (ah->btcoex_hw.scheme != ATH_BTCOEX_CFG_NONE) {
80 + if (ath9k_hw_get_btcoex_scheme(ah) != ATH_BTCOEX_CFG_NONE) {
81 /* Bluetooth coexistance requires disabling ASPM. */
82 pci_read_config_byte(pdev, pos + PCI_EXP_LNKCTL, &aspm);
83 aspm &= ~(PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1);
84 --- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c
85 +++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
86 @@ -610,7 +610,7 @@ static void ath9k_init_btcoex(struct ath
87 {
88 int qnum;
89
90 - switch (priv->ah->btcoex_hw.scheme) {
91 + switch (ath9k_hw_get_btcoex_scheme(priv->ah)) {
92 case ATH_BTCOEX_CFG_NONE:
93 break;
94 case ATH_BTCOEX_CFG_3WIRE:
95 @@ -704,7 +704,8 @@ static int ath9k_init_priv(struct ath9k_
96
97 if (product && strncmp(product, ATH_HTC_BTCOEX_PRODUCT_ID, 5) == 0) {
98 ah->btcoex_hw.scheme = ATH_BTCOEX_CFG_3WIRE;
99 - ath9k_init_btcoex(priv);
100 + if (ath9k_hw_get_btcoex_scheme(ah) != ATH_BTCOEX_CFG_NONE)
101 + ath9k_init_btcoex(priv);
102 }
103
104 return 0;
105 --- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
106 +++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
107 @@ -958,7 +958,7 @@ static int ath9k_htc_start(struct ieee80
108 mod_timer(&priv->tx.cleanup_timer,
109 jiffies + msecs_to_jiffies(ATH9K_HTC_TX_CLEANUP_INTERVAL));
110
111 - if (ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE) {
112 + if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_3WIRE) {
113 ath9k_hw_btcoex_set_weight(ah, AR_BT_COEX_WGHT,
114 AR_STOMP_LOW_WLAN_WGHT);
115 ath9k_hw_btcoex_enable(ah);
116 @@ -1010,7 +1010,8 @@ static void ath9k_htc_stop(struct ieee80
117
118 mutex_lock(&priv->mutex);
119
120 - if (ah->btcoex_hw.enabled) {
121 + if (ah->btcoex_hw.enabled &&
122 + ath9k_hw_get_btcoex_scheme(ah) != ATH_BTCOEX_CFG_NONE) {
123 ath9k_hw_btcoex_disable(ah);
124 if (ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE)
125 ath_htc_cancel_btcoex_work(priv);
126 --- a/drivers/net/wireless/ath/ath9k/main.c
127 +++ b/drivers/net/wireless/ath/ath9k/main.c
128 @@ -742,11 +742,11 @@ void ath9k_tasklet(unsigned long data)
129 ath_tx_tasklet(sc);
130 }
131
132 - if (ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE)
133 + if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_3WIRE)
134 if (status & ATH9K_INT_GENTIMER)
135 ath_gen_timer_isr(sc->sc_ah);
136
137 - if (status & ATH9K_INT_MCI)
138 + if ((status & ATH9K_INT_MCI) && ATH9K_HW_CAP_MCI)
139 ath_mci_intr(sc);
140
141 out:
142 @@ -1083,14 +1083,14 @@ static int ath9k_start(struct ieee80211_
143
144 spin_unlock_bh(&sc->sc_pcu_lock);
145
146 - if ((ah->btcoex_hw.scheme != ATH_BTCOEX_CFG_NONE) &&
147 + if ((ath9k_hw_get_btcoex_scheme(ah) != ATH_BTCOEX_CFG_NONE) &&
148 !ah->btcoex_hw.enabled) {
149 if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_MCI))
150 ath9k_hw_btcoex_set_weight(ah, AR_BT_COEX_WGHT,
151 AR_STOMP_LOW_WLAN_WGHT);
152 ath9k_hw_btcoex_enable(ah);
153
154 - if (ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE)
155 + if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_3WIRE)
156 ath9k_btcoex_timer_resume(sc);
157 }
158
159 @@ -1194,9 +1194,10 @@ static void ath9k_stop(struct ieee80211_
160 /* Ensure HW is awake when we try to shut it down. */
161 ath9k_ps_wakeup(sc);
162
163 - if (ah->btcoex_hw.enabled) {
164 + if (ah->btcoex_hw.enabled &&
165 + ath9k_hw_get_btcoex_scheme(ah) != ATH_BTCOEX_CFG_NONE) {
166 ath9k_hw_btcoex_disable(ah);
167 - if (ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE)
168 + if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_3WIRE)
169 ath9k_btcoex_timer_pause(sc);
170 ath_mci_flush_profile(&sc->btcoex.mci);
171 }
172 --- a/drivers/net/wireless/ath/ath9k/gpio.c
173 +++ b/drivers/net/wireless/ath/ath9k/gpio.c
174 @@ -253,6 +253,9 @@ int ath_init_btcoex_timer(struct ath_sof
175 {
176 struct ath_btcoex *btcoex = &sc->btcoex;
177
178 + if (ath9k_hw_get_btcoex_scheme(sc->sc_ah) == ATH_BTCOEX_CFG_NONE)
179 + return 0;
180 +
181 btcoex->btcoex_period = ATH_BTCOEX_DEF_BT_PERIOD * 1000;
182 btcoex->btcoex_no_stomp = (100 - ATH_BTCOEX_DEF_DUTY_CYCLE) *
183 btcoex->btcoex_period / 100;
184 @@ -286,6 +289,9 @@ void ath9k_btcoex_timer_resume(struct at
185 ath_dbg(ath9k_hw_common(ah), ATH_DBG_BTCOEX,
186 "Starting btcoex timers\n");
187
188 + if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_NONE)
189 + return;
190 +
191 /* make sure duty cycle timer is also stopped when resuming */
192 if (btcoex->hw_timer_enabled)
193 ath9k_gen_timer_stop(sc->sc_ah, btcoex->no_stomp_timer);
194 @@ -306,6 +312,9 @@ void ath9k_btcoex_timer_pause(struct ath
195 struct ath_btcoex *btcoex = &sc->btcoex;
196 struct ath_hw *ah = sc->sc_ah;
197
198 + if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_NONE)
199 + return;
200 +
201 del_timer_sync(&btcoex->period_timer);
202
203 if (btcoex->hw_timer_enabled)
204 --- a/drivers/net/wireless/ath/ath9k/hw.c
205 +++ b/drivers/net/wireless/ath/ath9k/hw.c
206 @@ -1932,7 +1932,8 @@ int ath9k_hw_reset(struct ath_hw *ah, st
207 #endif
208 }
209
210 - if (ah->btcoex_hw.enabled)
211 + if (ah->btcoex_hw.enabled &&
212 + ath9k_hw_get_btcoex_scheme(ah) != ATH_BTCOEX_CFG_NONE)
213 ath9k_hw_btcoex_enable(ah);
214
215 if (mci && mci_hw->ready) {
216 --- a/drivers/net/wireless/ath/ath9k/htc_drv_gpio.c
217 +++ b/drivers/net/wireless/ath/ath9k/htc_drv_gpio.c
218 @@ -116,6 +116,9 @@ void ath_htc_init_btcoex_work(struct ath
219 {
220 struct ath_btcoex *btcoex = &priv->btcoex;
221
222 + if (ath9k_hw_get_btcoex_scheme(priv->ah) == ATH_BTCOEX_CFG_NONE)
223 + return;
224 +
225 btcoex->btcoex_period = ATH_BTCOEX_DEF_BT_PERIOD;
226 btcoex->btcoex_no_stomp = (100 - ATH_BTCOEX_DEF_DUTY_CYCLE) *
227 btcoex->btcoex_period / 100;
228 @@ -134,6 +137,9 @@ void ath_htc_resume_btcoex_work(struct a
229 struct ath_btcoex *btcoex = &priv->btcoex;
230 struct ath_hw *ah = priv->ah;
231
232 + if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_NONE)
233 + return;
234 +
235 ath_dbg(ath9k_hw_common(ah), ATH_DBG_BTCOEX, "Starting btcoex work\n");
236
237 btcoex->bt_priority_cnt = 0;
238 @@ -148,6 +154,9 @@ void ath_htc_resume_btcoex_work(struct a
239 */
240 void ath_htc_cancel_btcoex_work(struct ath9k_htc_priv *priv)
241 {
242 + if (ath9k_hw_get_btcoex_scheme(priv->ah) == ATH_BTCOEX_CFG_NONE)
243 + return;
244 +
245 cancel_delayed_work_sync(&priv->coex_period_work);
246 cancel_delayed_work_sync(&priv->duty_cycle_work);
247 }
248 --- a/drivers/net/wireless/ath/ath9k/btcoex.c
249 +++ b/drivers/net/wireless/ath/ath9k/btcoex.c
250 @@ -68,6 +68,9 @@ void ath9k_hw_init_btcoex_hw(struct ath_
251 u32 i, idx;
252 bool rxclear_polarity = ath_bt_config.bt_rxclear_polarity;
253
254 + if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_NONE)
255 + return;
256 +
257 if (AR_SREV_9300_20_OR_LATER(ah))
258 rxclear_polarity = !ath_bt_config.bt_rxclear_polarity;
259
260 @@ -99,6 +102,9 @@ void ath9k_hw_btcoex_init_2wire(struct a
261 {
262 struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw;
263
264 + if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_NONE)
265 + return;
266 +
267 /* connect bt_active to baseband */
268 REG_CLR_BIT(ah, AR_GPIO_INPUT_EN_VAL,
269 (AR_GPIO_INPUT_EN_VAL_BT_PRIORITY_DEF |
270 @@ -121,6 +127,9 @@ void ath9k_hw_btcoex_init_3wire(struct a
271 {
272 struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw;
273
274 + if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_NONE)
275 + return;
276 +
277 /* btcoex 3-wire */
278 REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL,
279 (AR_GPIO_INPUT_EN_VAL_BT_PRIORITY_BB |
280 @@ -147,6 +156,9 @@ static void ath9k_hw_btcoex_enable_2wire
281 {
282 struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw;
283
284 + if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_NONE)
285 + return;
286 +
287 /* Configure the desired GPIO port for TX_FRAME output */
288 ath9k_hw_cfg_output(ah, btcoex_hw->wlanactive_gpio,
289 AR_GPIO_OUTPUT_MUX_AS_TX_FRAME);
290 @@ -158,6 +170,9 @@ void ath9k_hw_btcoex_set_weight(struct a
291 {
292 struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw;
293
294 + if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_NONE)
295 + return;
296 +
297 btcoex_hw->bt_coex_weights = SM(bt_weight, AR_BTCOEX_BT_WGHT) |
298 SM(wlan_weight, AR_BTCOEX_WL_WGHT);
299 }
300 @@ -219,9 +234,9 @@ void ath9k_hw_btcoex_enable(struct ath_h
301 {
302 struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw;
303
304 - switch (btcoex_hw->scheme) {
305 + switch (ath9k_hw_get_btcoex_scheme(ah)) {
306 case ATH_BTCOEX_CFG_NONE:
307 - break;
308 + return;
309 case ATH_BTCOEX_CFG_2WIRE:
310 ath9k_hw_btcoex_enable_2wire(ah);
311 break;
312 @@ -246,6 +261,9 @@ void ath9k_hw_btcoex_disable(struct ath_
313 struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw;
314 int i;
315
316 + if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_NONE)
317 + return;
318 +
319 btcoex_hw->enabled = false;
320 if (btcoex_hw->scheme == ATH_BTCOEX_CFG_MCI) {
321 ath9k_hw_btcoex_bt_stomp(ah, ATH_BTCOEX_STOMP_NONE);
322 @@ -294,6 +312,9 @@ static void ar9003_btcoex_bt_stomp(struc
323 void ath9k_hw_btcoex_bt_stomp(struct ath_hw *ah,
324 enum ath_stomp_type stomp_type)
325 {
326 + if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_NONE)
327 + return;
328 +
329 if (AR_SREV_9300_20_OR_LATER(ah)) {
330 ar9003_btcoex_bt_stomp(ah, stomp_type);
331 return;
332 --- a/drivers/net/wireless/ath/ath9k/ar9003_mci.c
333 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mci.c
334 @@ -85,6 +85,9 @@ void ar9003_mci_remote_reset(struct ath_
335 {
336 u32 payload[4] = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffff00};
337
338 + if (!ATH9K_HW_CAP_MCI)
339 + return;
340 +
341 ar9003_mci_send_message(ah, MCI_REMOTE_RESET, 0, payload, 16,
342 wait_done, false);
343 udelay(5);
344 @@ -94,6 +97,9 @@ void ar9003_mci_send_lna_transfer(struct
345 {
346 u32 payload = 0x00000000;
347
348 + if (!ATH9K_HW_CAP_MCI)
349 + return;
350 +
351 ar9003_mci_send_message(ah, MCI_LNA_TRANS, 0, &payload, 1,
352 wait_done, false);
353 }
354 @@ -107,6 +113,9 @@ static void ar9003_mci_send_req_wake(str
355
356 void ar9003_mci_send_sys_waking(struct ath_hw *ah, bool wait_done)
357 {
358 + if (!ATH9K_HW_CAP_MCI)
359 + return;
360 +
361 ar9003_mci_send_message(ah, MCI_SYS_WAKING, MCI_FLAG_DISABLE_TIMESTAMP,
362 NULL, 0, wait_done, false);
363 }
364 @@ -221,6 +230,9 @@ void ar9003_mci_send_coex_halt_bt_gpm(st
365 struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
366 u32 payload[4] = {0, 0, 0, 0};
367
368 + if (!ATH9K_HW_CAP_MCI)
369 + return;
370 +
371 ath_dbg(common, ATH_DBG_MCI, "MCI Send Coex %s BT GPM.\n",
372 (halt) ? "halt" : "unhalt");
373
374 @@ -381,12 +393,17 @@ static void ar9003_mci_prep_interface(st
375
376 void ar9003_mci_disable_interrupt(struct ath_hw *ah)
377 {
378 + if (!ATH9K_HW_CAP_MCI)
379 + return;
380 +
381 REG_WRITE(ah, AR_MCI_INTERRUPT_EN, 0);
382 REG_WRITE(ah, AR_MCI_INTERRUPT_RX_MSG_EN, 0);
383 }
384
385 void ar9003_mci_enable_interrupt(struct ath_hw *ah)
386 {
387 + if (!ATH9K_HW_CAP_MCI)
388 + return;
389
390 REG_WRITE(ah, AR_MCI_INTERRUPT_EN, AR_MCI_INTERRUPT_DEFAULT);
391 REG_WRITE(ah, AR_MCI_INTERRUPT_RX_MSG_EN,
392 @@ -397,6 +414,9 @@ bool ar9003_mci_check_int(struct ath_hw
393 {
394 u32 intr;
395
396 + if (!ATH9K_HW_CAP_MCI)
397 + return false;
398 +
399 intr = REG_READ(ah, AR_MCI_INTERRUPT_RX_MSG_RAW);
400 return ((intr & ints) == ints);
401 }
402 @@ -405,6 +425,10 @@ void ar9003_mci_get_interrupt(struct ath
403 u32 *rx_msg_intr)
404 {
405 struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
406 +
407 + if (!ATH9K_HW_CAP_MCI)
408 + return;
409 +
410 *raw_intr = mci->raw_intr;
411 *rx_msg_intr = mci->rx_msg_intr;
412
413 @@ -418,6 +442,9 @@ void ar9003_mci_2g5g_changed(struct ath_
414 {
415 struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
416
417 + if (!ATH9K_HW_CAP_MCI)
418 + return;
419 +
420 if (!mci->update_2g5g &&
421 (mci->is_2g != is_2g))
422 mci->update_2g5g = true;
423 @@ -531,6 +558,9 @@ void ar9003_mci_reset(struct ath_hw *ah,
424 struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
425 u32 regval, thresh;
426
427 + if (!ATH9K_HW_CAP_MCI)
428 + return;
429 +
430 ath_dbg(common, ATH_DBG_MCI, "MCI full_sleep = %d, is_2g = %d\n",
431 is_full_sleep, is_2g);
432
433 @@ -661,6 +691,9 @@ void ar9003_mci_mute_bt(struct ath_hw *a
434 {
435 struct ath_common *common = ath9k_hw_common(ah);
436
437 + if (!ATH9K_HW_CAP_MCI)
438 + return;
439 +
440 /* disable all MCI messages */
441 REG_WRITE(ah, AR_MCI_MSG_ATTRIBUTES_TABLE, 0xffff0000);
442 REG_WRITE(ah, AR_BTCOEX_WL_WEIGHTS0, 0xffffffff);
443 @@ -693,6 +726,9 @@ void ar9003_mci_sync_bt_state(struct ath
444 struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
445 u32 cur_bt_state;
446
447 + if (!ATH9K_HW_CAP_MCI)
448 + return;
449 +
450 cur_bt_state = ar9003_mci_state(ah, MCI_STATE_REMOTE_SLEEP, NULL);
451
452 if (mci->bt_state != cur_bt_state) {
453 @@ -857,6 +893,9 @@ void ar9003_mci_2g5g_switch(struct ath_h
454 struct ath_common *common = ath9k_hw_common(ah);
455 struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
456
457 + if (!ATH9K_HW_CAP_MCI)
458 + return;
459 +
460 if (mci->update_2g5g) {
461 if (mci->is_2g) {
462
463 @@ -908,6 +947,9 @@ bool ar9003_mci_send_message(struct ath_
464 u32 saved_mci_int_en;
465 int i;
466
467 + if (!ATH9K_HW_CAP_MCI)
468 + return false;
469 +
470 saved_mci_int_en = REG_READ(ah, AR_MCI_INTERRUPT_EN);
471 regval = REG_READ(ah, AR_BTCOEX_CTRL);
472
473 @@ -973,6 +1015,9 @@ void ar9003_mci_setup(struct ath_hw *ah,
474 struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
475 void *sched_buf = (void *)((char *) gpm_buf + (sched_addr - gpm_addr));
476
477 + if (!ATH9K_HW_CAP_MCI)
478 + return;
479 +
480 mci->gpm_addr = gpm_addr;
481 mci->gpm_buf = gpm_buf;
482 mci->gpm_len = len;
483 @@ -987,6 +1032,9 @@ void ar9003_mci_cleanup(struct ath_hw *a
484 {
485 struct ath_common *common = ath9k_hw_common(ah);
486
487 + if (!ATH9K_HW_CAP_MCI)
488 + return;
489 +
490 /* Turn off MCI and Jupiter mode. */
491 REG_WRITE(ah, AR_BTCOEX_CTRL, 0x00);
492 ath_dbg(common, ATH_DBG_MCI, "MCI ar9003_mci_cleanup\n");
493 @@ -1056,6 +1104,9 @@ u32 ar9003_mci_wait_for_gpm(struct ath_h
494 u8 recv_type = 0, recv_opcode = 0;
495 bool b_is_bt_cal_done = (gpm_type == MCI_GPM_BT_CAL_DONE);
496
497 + if (!ATH9K_HW_CAP_MCI)
498 + return 0;
499 +
500 more_data = time_out ? MCI_GPM_NOMORE : MCI_GPM_MORE;
501
502 while (time_out > 0) {
503 @@ -1188,6 +1239,9 @@ u32 ar9003_mci_state(struct ath_hw *ah,
504 u32 value = 0, more_gpm = 0, gpm_ptr;
505 u8 query_type;
506
507 + if (!ATH9K_HW_CAP_MCI)
508 + return 0;
509 +
510 switch (state_type) {
511 case MCI_STATE_ENABLE:
512 if (mci->ready) {
513 --- a/drivers/net/wireless/ath/ath9k/mci.c
514 +++ b/drivers/net/wireless/ath/ath9k/mci.c
515 @@ -425,6 +425,9 @@ int ath_mci_setup(struct ath_softc *sc)
516 struct ath_mci_coex *mci = &sc->mci_coex;
517 int error = 0;
518
519 + if (!ATH9K_HW_CAP_MCI)
520 + return 0;
521 +
522 mci->sched_buf.bf_len = ATH_MCI_SCHED_BUF_SIZE + ATH_MCI_GPM_BUF_SIZE;
523
524 if (ath_mci_buf_alloc(sc, &mci->sched_buf)) {
525 @@ -458,6 +461,9 @@ void ath_mci_cleanup(struct ath_softc *s
526 struct ath_hw *ah = sc->sc_ah;
527 struct ath_mci_coex *mci = &sc->mci_coex;
528
529 + if (!ATH9K_HW_CAP_MCI)
530 + return;
531 +
532 /*
533 * both schedule and gpm buffers will be released
534 */
535 @@ -476,6 +482,9 @@ void ath_mci_intr(struct ath_softc *sc)
536 u32 more_data = MCI_GPM_MORE;
537 bool skip_gpm = false;
538
539 + if (!ATH9K_HW_CAP_MCI)
540 + return;
541 +
542 ar9003_mci_get_interrupt(sc->sc_ah, &mci_int, &mci_int_rxmsg);
543
544 if (ar9003_mci_state(ah, MCI_STATE_ENABLE, NULL) == 0) {