aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2011-12-17 10:47:56 -0500
committerJohn W. Linville <linville@tuxdriver.com>2011-12-19 14:46:55 -0500
commit8a30930563521c9dba73c93b5631be1d0993f78f (patch)
tree859d5bd92689fc934aa6c7eea98f1d37891fb293 /drivers/net/wireless/ath
parent104cfa881006c18af9b118e1631dcf1f8378994a (diff)
ath9k_hw: make bluetooth coexistence support optional at compile time
Many systems (e.g. embedded systems) do not have wifi modules connected to bluetooth modules, so bluetooth coexistence is irrelevant there. With the addition of MCI support, ath9k picked up quite a bit of extra code that can be compiled out this way. This patch redefines ATH9K_HW_CAP_MCI and adds an inline wrapper for querying the bluetooth coexistence scheme, allowing the compiler to eliminate code that uses it, with only very little use of #ifdef. On MIPS this reduces the total size for the modules by about 20k. Signed-off-by: Felix Fietkau <nbd@openwrt.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath')
-rw-r--r--drivers/net/wireless/ath/ath9k/Kconfig8
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_mci.c54
-rw-r--r--drivers/net/wireless/ath/ath9k/btcoex.c25
-rw-r--r--drivers/net/wireless/ath/ath9k/gpio.c9
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_gpio.c9
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_init.c5
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_main.c5
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.c3
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.h14
-rw-r--r--drivers/net/wireless/ath/ath9k/init.c6
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c13
-rw-r--r--drivers/net/wireless/ath/ath9k/mci.c9
-rw-r--r--drivers/net/wireless/ath/ath9k/pci.c2
13 files changed, 145 insertions, 17 deletions
diff --git a/drivers/net/wireless/ath/ath9k/Kconfig b/drivers/net/wireless/ath/ath9k/Kconfig
index 1b4786ae00ac..dc6be4afe8eb 100644
--- a/drivers/net/wireless/ath/ath9k/Kconfig
+++ b/drivers/net/wireless/ath/ath9k/Kconfig
@@ -81,6 +81,14 @@ config ATH9K_RATE_CONTROL
81 Say Y, if you want to use the ath9k specific rate control 81 Say Y, if you want to use the ath9k specific rate control
82 module instead of minstrel_ht. 82 module instead of minstrel_ht.
83 83
84config ATH9K_BTCOEX_SUPPORT
85 bool "Atheros ath9k bluetooth coexistence support"
86 depends on ATH9K
87 default y
88 ---help---
89 Say Y, if you want to use the ath9k radios together with
90 Bluetooth modules in the same system.
91
84config ATH9K_HTC 92config ATH9K_HTC
85 tristate "Atheros HTC based wireless cards support" 93 tristate "Atheros HTC based wireless cards support"
86 depends on USB && MAC80211 94 depends on USB && MAC80211
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mci.c b/drivers/net/wireless/ath/ath9k/ar9003_mci.c
index fdd0f815cf83..709520c6835b 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_mci.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_mci.c
@@ -85,6 +85,9 @@ void ar9003_mci_remote_reset(struct ath_hw *ah, bool wait_done)
85{ 85{
86 u32 payload[4] = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffff00}; 86 u32 payload[4] = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffff00};
87 87
88 if (!ATH9K_HW_CAP_MCI)
89 return;
90
88 ar9003_mci_send_message(ah, MCI_REMOTE_RESET, 0, payload, 16, 91 ar9003_mci_send_message(ah, MCI_REMOTE_RESET, 0, payload, 16,
89 wait_done, false); 92 wait_done, false);
90 udelay(5); 93 udelay(5);
@@ -94,6 +97,9 @@ void ar9003_mci_send_lna_transfer(struct ath_hw *ah, bool wait_done)
94{ 97{
95 u32 payload = 0x00000000; 98 u32 payload = 0x00000000;
96 99
100 if (!ATH9K_HW_CAP_MCI)
101 return;
102
97 ar9003_mci_send_message(ah, MCI_LNA_TRANS, 0, &payload, 1, 103 ar9003_mci_send_message(ah, MCI_LNA_TRANS, 0, &payload, 1,
98 wait_done, false); 104 wait_done, false);
99} 105}
@@ -107,6 +113,9 @@ static void ar9003_mci_send_req_wake(struct ath_hw *ah, bool wait_done)
107 113
108void ar9003_mci_send_sys_waking(struct ath_hw *ah, bool wait_done) 114void ar9003_mci_send_sys_waking(struct ath_hw *ah, bool wait_done)
109{ 115{
116 if (!ATH9K_HW_CAP_MCI)
117 return;
118
110 ar9003_mci_send_message(ah, MCI_SYS_WAKING, MCI_FLAG_DISABLE_TIMESTAMP, 119 ar9003_mci_send_message(ah, MCI_SYS_WAKING, MCI_FLAG_DISABLE_TIMESTAMP,
111 NULL, 0, wait_done, false); 120 NULL, 0, wait_done, false);
112} 121}
@@ -220,6 +229,9 @@ void ar9003_mci_send_coex_halt_bt_gpm(struct ath_hw *ah, bool halt,
220 struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; 229 struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
221 u32 payload[4] = {0, 0, 0, 0}; 230 u32 payload[4] = {0, 0, 0, 0};
222 231
232 if (!ATH9K_HW_CAP_MCI)
233 return;
234
223 ath_dbg(common, MCI, "MCI Send Coex %s BT GPM\n", 235 ath_dbg(common, MCI, "MCI Send Coex %s BT GPM\n",
224 (halt) ? "halt" : "unhalt"); 236 (halt) ? "halt" : "unhalt");
225 237
@@ -374,12 +386,17 @@ static void ar9003_mci_prep_interface(struct ath_hw *ah)
374 386
375void ar9003_mci_disable_interrupt(struct ath_hw *ah) 387void ar9003_mci_disable_interrupt(struct ath_hw *ah)
376{ 388{
389 if (!ATH9K_HW_CAP_MCI)
390 return;
391
377 REG_WRITE(ah, AR_MCI_INTERRUPT_EN, 0); 392 REG_WRITE(ah, AR_MCI_INTERRUPT_EN, 0);
378 REG_WRITE(ah, AR_MCI_INTERRUPT_RX_MSG_EN, 0); 393 REG_WRITE(ah, AR_MCI_INTERRUPT_RX_MSG_EN, 0);
379} 394}
380 395
381void ar9003_mci_enable_interrupt(struct ath_hw *ah) 396void ar9003_mci_enable_interrupt(struct ath_hw *ah)
382{ 397{
398 if (!ATH9K_HW_CAP_MCI)
399 return;
383 400
384 REG_WRITE(ah, AR_MCI_INTERRUPT_EN, AR_MCI_INTERRUPT_DEFAULT); 401 REG_WRITE(ah, AR_MCI_INTERRUPT_EN, AR_MCI_INTERRUPT_DEFAULT);
385 REG_WRITE(ah, AR_MCI_INTERRUPT_RX_MSG_EN, 402 REG_WRITE(ah, AR_MCI_INTERRUPT_RX_MSG_EN,
@@ -390,6 +407,9 @@ bool ar9003_mci_check_int(struct ath_hw *ah, u32 ints)
390{ 407{
391 u32 intr; 408 u32 intr;
392 409
410 if (!ATH9K_HW_CAP_MCI)
411 return false;
412
393 intr = REG_READ(ah, AR_MCI_INTERRUPT_RX_MSG_RAW); 413 intr = REG_READ(ah, AR_MCI_INTERRUPT_RX_MSG_RAW);
394 return ((intr & ints) == ints); 414 return ((intr & ints) == ints);
395} 415}
@@ -398,6 +418,10 @@ void ar9003_mci_get_interrupt(struct ath_hw *ah, u32 *raw_intr,
398 u32 *rx_msg_intr) 418 u32 *rx_msg_intr)
399{ 419{
400 struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; 420 struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
421
422 if (!ATH9K_HW_CAP_MCI)
423 return;
424
401 *raw_intr = mci->raw_intr; 425 *raw_intr = mci->raw_intr;
402 *rx_msg_intr = mci->rx_msg_intr; 426 *rx_msg_intr = mci->rx_msg_intr;
403 427
@@ -411,6 +435,9 @@ void ar9003_mci_2g5g_changed(struct ath_hw *ah, bool is_2g)
411{ 435{
412 struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; 436 struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
413 437
438 if (!ATH9K_HW_CAP_MCI)
439 return;
440
414 if (!mci->update_2g5g && 441 if (!mci->update_2g5g &&
415 (mci->is_2g != is_2g)) 442 (mci->is_2g != is_2g))
416 mci->update_2g5g = true; 443 mci->update_2g5g = true;
@@ -524,6 +551,9 @@ void ar9003_mci_reset(struct ath_hw *ah, bool en_int, bool is_2g,
524 struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; 551 struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
525 u32 regval, thresh; 552 u32 regval, thresh;
526 553
554 if (!ATH9K_HW_CAP_MCI)
555 return;
556
527 ath_dbg(common, MCI, "MCI full_sleep = %d, is_2g = %d\n", 557 ath_dbg(common, MCI, "MCI full_sleep = %d, is_2g = %d\n",
528 is_full_sleep, is_2g); 558 is_full_sleep, is_2g);
529 559
@@ -650,6 +680,9 @@ void ar9003_mci_mute_bt(struct ath_hw *ah)
650{ 680{
651 struct ath_common *common = ath9k_hw_common(ah); 681 struct ath_common *common = ath9k_hw_common(ah);
652 682
683 if (!ATH9K_HW_CAP_MCI)
684 return;
685
653 /* disable all MCI messages */ 686 /* disable all MCI messages */
654 REG_WRITE(ah, AR_MCI_MSG_ATTRIBUTES_TABLE, 0xffff0000); 687 REG_WRITE(ah, AR_MCI_MSG_ATTRIBUTES_TABLE, 0xffff0000);
655 REG_WRITE(ah, AR_BTCOEX_WL_WEIGHTS0, 0xffffffff); 688 REG_WRITE(ah, AR_BTCOEX_WL_WEIGHTS0, 0xffffffff);
@@ -682,6 +715,9 @@ void ar9003_mci_sync_bt_state(struct ath_hw *ah)
682 struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; 715 struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
683 u32 cur_bt_state; 716 u32 cur_bt_state;
684 717
718 if (!ATH9K_HW_CAP_MCI)
719 return;
720
685 cur_bt_state = ar9003_mci_state(ah, MCI_STATE_REMOTE_SLEEP, NULL); 721 cur_bt_state = ar9003_mci_state(ah, MCI_STATE_REMOTE_SLEEP, NULL);
686 722
687 if (mci->bt_state != cur_bt_state) { 723 if (mci->bt_state != cur_bt_state) {
@@ -844,6 +880,9 @@ void ar9003_mci_2g5g_switch(struct ath_hw *ah, bool wait_done)
844 struct ath_common *common = ath9k_hw_common(ah); 880 struct ath_common *common = ath9k_hw_common(ah);
845 struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; 881 struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
846 882
883 if (!ATH9K_HW_CAP_MCI)
884 return;
885
847 if (mci->update_2g5g) { 886 if (mci->update_2g5g) {
848 if (mci->is_2g) { 887 if (mci->is_2g) {
849 888
@@ -895,6 +934,9 @@ bool ar9003_mci_send_message(struct ath_hw *ah, u8 header, u32 flag,
895 u32 saved_mci_int_en; 934 u32 saved_mci_int_en;
896 int i; 935 int i;
897 936
937 if (!ATH9K_HW_CAP_MCI)
938 return false;
939
898 saved_mci_int_en = REG_READ(ah, AR_MCI_INTERRUPT_EN); 940 saved_mci_int_en = REG_READ(ah, AR_MCI_INTERRUPT_EN);
899 regval = REG_READ(ah, AR_BTCOEX_CTRL); 941 regval = REG_READ(ah, AR_BTCOEX_CTRL);
900 942
@@ -961,6 +1003,9 @@ void ar9003_mci_setup(struct ath_hw *ah, u32 gpm_addr, void *gpm_buf,
961 struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; 1003 struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
962 void *sched_buf = (void *)((char *) gpm_buf + (sched_addr - gpm_addr)); 1004 void *sched_buf = (void *)((char *) gpm_buf + (sched_addr - gpm_addr));
963 1005
1006 if (!ATH9K_HW_CAP_MCI)
1007 return;
1008
964 mci->gpm_addr = gpm_addr; 1009 mci->gpm_addr = gpm_addr;
965 mci->gpm_buf = gpm_buf; 1010 mci->gpm_buf = gpm_buf;
966 mci->gpm_len = len; 1011 mci->gpm_len = len;
@@ -975,6 +1020,9 @@ void ar9003_mci_cleanup(struct ath_hw *ah)
975{ 1020{
976 struct ath_common *common = ath9k_hw_common(ah); 1021 struct ath_common *common = ath9k_hw_common(ah);
977 1022
1023 if (!ATH9K_HW_CAP_MCI)
1024 return;
1025
978 /* Turn off MCI and Jupiter mode. */ 1026 /* Turn off MCI and Jupiter mode. */
979 REG_WRITE(ah, AR_BTCOEX_CTRL, 0x00); 1027 REG_WRITE(ah, AR_BTCOEX_CTRL, 0x00);
980 ath_dbg(common, MCI, "MCI ar9003_mci_cleanup\n"); 1028 ath_dbg(common, MCI, "MCI ar9003_mci_cleanup\n");
@@ -1039,6 +1087,9 @@ u32 ar9003_mci_wait_for_gpm(struct ath_hw *ah, u8 gpm_type,
1039 u8 recv_type = 0, recv_opcode = 0; 1087 u8 recv_type = 0, recv_opcode = 0;
1040 bool b_is_bt_cal_done = (gpm_type == MCI_GPM_BT_CAL_DONE); 1088 bool b_is_bt_cal_done = (gpm_type == MCI_GPM_BT_CAL_DONE);
1041 1089
1090 if (!ATH9K_HW_CAP_MCI)
1091 return 0;
1092
1042 more_data = time_out ? MCI_GPM_NOMORE : MCI_GPM_MORE; 1093 more_data = time_out ? MCI_GPM_NOMORE : MCI_GPM_MORE;
1043 1094
1044 while (time_out > 0) { 1095 while (time_out > 0) {
@@ -1168,6 +1219,9 @@ u32 ar9003_mci_state(struct ath_hw *ah, u32 state_type, u32 *p_data)
1168 u32 value = 0, more_gpm = 0, gpm_ptr; 1219 u32 value = 0, more_gpm = 0, gpm_ptr;
1169 u8 query_type; 1220 u8 query_type;
1170 1221
1222 if (!ATH9K_HW_CAP_MCI)
1223 return 0;
1224
1171 switch (state_type) { 1225 switch (state_type) {
1172 case MCI_STATE_ENABLE: 1226 case MCI_STATE_ENABLE:
1173 if (mci->ready) { 1227 if (mci->ready) {
diff --git a/drivers/net/wireless/ath/ath9k/btcoex.c b/drivers/net/wireless/ath/ath9k/btcoex.c
index 553d279cc5ee..a6712a95d76a 100644
--- a/drivers/net/wireless/ath/ath9k/btcoex.c
+++ b/drivers/net/wireless/ath/ath9k/btcoex.c
@@ -68,6 +68,9 @@ void ath9k_hw_init_btcoex_hw(struct ath_hw *ah, int qnum)
68 u32 i, idx; 68 u32 i, idx;
69 bool rxclear_polarity = ath_bt_config.bt_rxclear_polarity; 69 bool rxclear_polarity = ath_bt_config.bt_rxclear_polarity;
70 70
71 if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_NONE)
72 return;
73
71 if (AR_SREV_9300_20_OR_LATER(ah)) 74 if (AR_SREV_9300_20_OR_LATER(ah))
72 rxclear_polarity = !ath_bt_config.bt_rxclear_polarity; 75 rxclear_polarity = !ath_bt_config.bt_rxclear_polarity;
73 76
@@ -99,6 +102,9 @@ void ath9k_hw_btcoex_init_2wire(struct ath_hw *ah)
99{ 102{
100 struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw; 103 struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw;
101 104
105 if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_NONE)
106 return;
107
102 /* connect bt_active to baseband */ 108 /* connect bt_active to baseband */
103 REG_CLR_BIT(ah, AR_GPIO_INPUT_EN_VAL, 109 REG_CLR_BIT(ah, AR_GPIO_INPUT_EN_VAL,
104 (AR_GPIO_INPUT_EN_VAL_BT_PRIORITY_DEF | 110 (AR_GPIO_INPUT_EN_VAL_BT_PRIORITY_DEF |
@@ -121,6 +127,9 @@ void ath9k_hw_btcoex_init_3wire(struct ath_hw *ah)
121{ 127{
122 struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw; 128 struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw;
123 129
130 if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_NONE)
131 return;
132
124 /* btcoex 3-wire */ 133 /* btcoex 3-wire */
125 REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL, 134 REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL,
126 (AR_GPIO_INPUT_EN_VAL_BT_PRIORITY_BB | 135 (AR_GPIO_INPUT_EN_VAL_BT_PRIORITY_BB |
@@ -147,6 +156,9 @@ static void ath9k_hw_btcoex_enable_2wire(struct ath_hw *ah)
147{ 156{
148 struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw; 157 struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw;
149 158
159 if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_NONE)
160 return;
161
150 /* Configure the desired GPIO port for TX_FRAME output */ 162 /* Configure the desired GPIO port for TX_FRAME output */
151 ath9k_hw_cfg_output(ah, btcoex_hw->wlanactive_gpio, 163 ath9k_hw_cfg_output(ah, btcoex_hw->wlanactive_gpio,
152 AR_GPIO_OUTPUT_MUX_AS_TX_FRAME); 164 AR_GPIO_OUTPUT_MUX_AS_TX_FRAME);
@@ -158,6 +170,9 @@ void ath9k_hw_btcoex_set_weight(struct ath_hw *ah,
158{ 170{
159 struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw; 171 struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw;
160 172
173 if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_NONE)
174 return;
175
161 btcoex_hw->bt_coex_weights = SM(bt_weight, AR_BTCOEX_BT_WGHT) | 176 btcoex_hw->bt_coex_weights = SM(bt_weight, AR_BTCOEX_BT_WGHT) |
162 SM(wlan_weight, AR_BTCOEX_WL_WGHT); 177 SM(wlan_weight, AR_BTCOEX_WL_WGHT);
163} 178}
@@ -219,9 +234,9 @@ void ath9k_hw_btcoex_enable(struct ath_hw *ah)
219{ 234{
220 struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw; 235 struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw;
221 236
222 switch (btcoex_hw->scheme) { 237 switch (ath9k_hw_get_btcoex_scheme(ah)) {
223 case ATH_BTCOEX_CFG_NONE: 238 case ATH_BTCOEX_CFG_NONE:
224 break; 239 return;
225 case ATH_BTCOEX_CFG_2WIRE: 240 case ATH_BTCOEX_CFG_2WIRE:
226 ath9k_hw_btcoex_enable_2wire(ah); 241 ath9k_hw_btcoex_enable_2wire(ah);
227 break; 242 break;
@@ -246,6 +261,9 @@ void ath9k_hw_btcoex_disable(struct ath_hw *ah)
246 struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw; 261 struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw;
247 int i; 262 int i;
248 263
264 if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_NONE)
265 return;
266
249 btcoex_hw->enabled = false; 267 btcoex_hw->enabled = false;
250 if (btcoex_hw->scheme == ATH_BTCOEX_CFG_MCI) { 268 if (btcoex_hw->scheme == ATH_BTCOEX_CFG_MCI) {
251 ath9k_hw_btcoex_bt_stomp(ah, ATH_BTCOEX_STOMP_NONE); 269 ath9k_hw_btcoex_bt_stomp(ah, ATH_BTCOEX_STOMP_NONE);
@@ -294,6 +312,9 @@ static void ar9003_btcoex_bt_stomp(struct ath_hw *ah,
294void ath9k_hw_btcoex_bt_stomp(struct ath_hw *ah, 312void ath9k_hw_btcoex_bt_stomp(struct ath_hw *ah,
295 enum ath_stomp_type stomp_type) 313 enum ath_stomp_type stomp_type)
296{ 314{
315 if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_NONE)
316 return;
317
297 if (AR_SREV_9300_20_OR_LATER(ah)) { 318 if (AR_SREV_9300_20_OR_LATER(ah)) {
298 ar9003_btcoex_bt_stomp(ah, stomp_type); 319 ar9003_btcoex_bt_stomp(ah, stomp_type);
299 return; 320 return;
diff --git a/drivers/net/wireless/ath/ath9k/gpio.c b/drivers/net/wireless/ath/ath9k/gpio.c
index 7834d70a190d..597c84e31adb 100644
--- a/drivers/net/wireless/ath/ath9k/gpio.c
+++ b/drivers/net/wireless/ath/ath9k/gpio.c
@@ -249,6 +249,9 @@ int ath_init_btcoex_timer(struct ath_softc *sc)
249{ 249{
250 struct ath_btcoex *btcoex = &sc->btcoex; 250 struct ath_btcoex *btcoex = &sc->btcoex;
251 251
252 if (ath9k_hw_get_btcoex_scheme(sc->sc_ah) == ATH_BTCOEX_CFG_NONE)
253 return 0;
254
252 btcoex->btcoex_period = ATH_BTCOEX_DEF_BT_PERIOD * 1000; 255 btcoex->btcoex_period = ATH_BTCOEX_DEF_BT_PERIOD * 1000;
253 btcoex->btcoex_no_stomp = (100 - ATH_BTCOEX_DEF_DUTY_CYCLE) * 256 btcoex->btcoex_no_stomp = (100 - ATH_BTCOEX_DEF_DUTY_CYCLE) *
254 btcoex->btcoex_period / 100; 257 btcoex->btcoex_period / 100;
@@ -281,6 +284,9 @@ void ath9k_btcoex_timer_resume(struct ath_softc *sc)
281 284
282 ath_dbg(ath9k_hw_common(ah), BTCOEX, "Starting btcoex timers\n"); 285 ath_dbg(ath9k_hw_common(ah), BTCOEX, "Starting btcoex timers\n");
283 286
287 if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_NONE)
288 return;
289
284 /* make sure duty cycle timer is also stopped when resuming */ 290 /* make sure duty cycle timer is also stopped when resuming */
285 if (btcoex->hw_timer_enabled) 291 if (btcoex->hw_timer_enabled)
286 ath9k_gen_timer_stop(sc->sc_ah, btcoex->no_stomp_timer); 292 ath9k_gen_timer_stop(sc->sc_ah, btcoex->no_stomp_timer);
@@ -301,6 +307,9 @@ void ath9k_btcoex_timer_pause(struct ath_softc *sc)
301 struct ath_btcoex *btcoex = &sc->btcoex; 307 struct ath_btcoex *btcoex = &sc->btcoex;
302 struct ath_hw *ah = sc->sc_ah; 308 struct ath_hw *ah = sc->sc_ah;
303 309
310 if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_NONE)
311 return;
312
304 del_timer_sync(&btcoex->period_timer); 313 del_timer_sync(&btcoex->period_timer);
305 314
306 if (btcoex->hw_timer_enabled) 315 if (btcoex->hw_timer_enabled)
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_gpio.c b/drivers/net/wireless/ath/ath9k/htc_drv_gpio.c
index b7c030018403..6506e1fd5036 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_gpio.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_gpio.c
@@ -115,6 +115,9 @@ void ath_htc_init_btcoex_work(struct ath9k_htc_priv *priv)
115{ 115{
116 struct ath_btcoex *btcoex = &priv->btcoex; 116 struct ath_btcoex *btcoex = &priv->btcoex;
117 117
118 if (ath9k_hw_get_btcoex_scheme(priv->ah) == ATH_BTCOEX_CFG_NONE)
119 return;
120
118 btcoex->btcoex_period = ATH_BTCOEX_DEF_BT_PERIOD; 121 btcoex->btcoex_period = ATH_BTCOEX_DEF_BT_PERIOD;
119 btcoex->btcoex_no_stomp = (100 - ATH_BTCOEX_DEF_DUTY_CYCLE) * 122 btcoex->btcoex_no_stomp = (100 - ATH_BTCOEX_DEF_DUTY_CYCLE) *
120 btcoex->btcoex_period / 100; 123 btcoex->btcoex_period / 100;
@@ -133,6 +136,9 @@ void ath_htc_resume_btcoex_work(struct ath9k_htc_priv *priv)
133 struct ath_btcoex *btcoex = &priv->btcoex; 136 struct ath_btcoex *btcoex = &priv->btcoex;
134 struct ath_hw *ah = priv->ah; 137 struct ath_hw *ah = priv->ah;
135 138
139 if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_NONE)
140 return;
141
136 ath_dbg(ath9k_hw_common(ah), BTCOEX, "Starting btcoex work\n"); 142 ath_dbg(ath9k_hw_common(ah), BTCOEX, "Starting btcoex work\n");
137 143
138 btcoex->bt_priority_cnt = 0; 144 btcoex->bt_priority_cnt = 0;
@@ -147,6 +153,9 @@ void ath_htc_resume_btcoex_work(struct ath9k_htc_priv *priv)
147 */ 153 */
148void ath_htc_cancel_btcoex_work(struct ath9k_htc_priv *priv) 154void ath_htc_cancel_btcoex_work(struct ath9k_htc_priv *priv)
149{ 155{
156 if (ath9k_hw_get_btcoex_scheme(priv->ah) == ATH_BTCOEX_CFG_NONE)
157 return;
158
150 cancel_delayed_work_sync(&priv->coex_period_work); 159 cancel_delayed_work_sync(&priv->coex_period_work);
151 cancel_delayed_work_sync(&priv->duty_cycle_work); 160 cancel_delayed_work_sync(&priv->duty_cycle_work);
152} 161}
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_init.c b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
index 6cbad73f9f2a..9be10a2da1c2 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
@@ -607,7 +607,7 @@ static void ath9k_init_btcoex(struct ath9k_htc_priv *priv)
607{ 607{
608 int qnum; 608 int qnum;
609 609
610 switch (priv->ah->btcoex_hw.scheme) { 610 switch (ath9k_hw_get_btcoex_scheme(priv->ah)) {
611 case ATH_BTCOEX_CFG_NONE: 611 case ATH_BTCOEX_CFG_NONE:
612 break; 612 break;
613 case ATH_BTCOEX_CFG_3WIRE: 613 case ATH_BTCOEX_CFG_3WIRE:
@@ -701,7 +701,8 @@ static int ath9k_init_priv(struct ath9k_htc_priv *priv,
701 701
702 if (product && strncmp(product, ATH_HTC_BTCOEX_PRODUCT_ID, 5) == 0) { 702 if (product && strncmp(product, ATH_HTC_BTCOEX_PRODUCT_ID, 5) == 0) {
703 ah->btcoex_hw.scheme = ATH_BTCOEX_CFG_3WIRE; 703 ah->btcoex_hw.scheme = ATH_BTCOEX_CFG_3WIRE;
704 ath9k_init_btcoex(priv); 704 if (ath9k_hw_get_btcoex_scheme(ah) != ATH_BTCOEX_CFG_NONE)
705 ath9k_init_btcoex(priv);
705 } 706 }
706 707
707 return 0; 708 return 0;
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_main.c b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
index 539f4455076e..ef4c60661290 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
@@ -957,7 +957,7 @@ static int ath9k_htc_start(struct ieee80211_hw *hw)
957 mod_timer(&priv->tx.cleanup_timer, 957 mod_timer(&priv->tx.cleanup_timer,
958 jiffies + msecs_to_jiffies(ATH9K_HTC_TX_CLEANUP_INTERVAL)); 958 jiffies + msecs_to_jiffies(ATH9K_HTC_TX_CLEANUP_INTERVAL));
959 959
960 if (ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE) { 960 if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_3WIRE) {
961 ath9k_hw_btcoex_set_weight(ah, AR_BT_COEX_WGHT, 961 ath9k_hw_btcoex_set_weight(ah, AR_BT_COEX_WGHT,
962 AR_STOMP_LOW_WLAN_WGHT); 962 AR_STOMP_LOW_WLAN_WGHT);
963 ath9k_hw_btcoex_enable(ah); 963 ath9k_hw_btcoex_enable(ah);
@@ -1009,7 +1009,8 @@ static void ath9k_htc_stop(struct ieee80211_hw *hw)
1009 1009
1010 mutex_lock(&priv->mutex); 1010 mutex_lock(&priv->mutex);
1011 1011
1012 if (ah->btcoex_hw.enabled) { 1012 if (ah->btcoex_hw.enabled &&
1013 ath9k_hw_get_btcoex_scheme(ah) != ATH_BTCOEX_CFG_NONE) {
1013 ath9k_hw_btcoex_disable(ah); 1014 ath9k_hw_btcoex_disable(ah);
1014 if (ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE) 1015 if (ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE)
1015 ath_htc_cancel_btcoex_work(priv); 1016 ath_htc_cancel_btcoex_work(priv);
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 0fde03104ef0..ee7759575050 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -1891,7 +1891,8 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
1891#endif 1891#endif
1892 } 1892 }
1893 1893
1894 if (ah->btcoex_hw.enabled) 1894 if (ah->btcoex_hw.enabled &&
1895 ath9k_hw_get_btcoex_scheme(ah) != ATH_BTCOEX_CFG_NONE)
1895 ath9k_hw_btcoex_enable(ah); 1896 ath9k_hw_btcoex_enable(ah);
1896 1897
1897 if (mci && mci_hw->ready) { 1898 if (mci && mci_hw->ready) {
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index 615cc839f0de..48205c2960b5 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -209,7 +209,11 @@ enum ath9k_hw_caps {
209 ATH9K_HW_CAP_5GHZ = BIT(12), 209 ATH9K_HW_CAP_5GHZ = BIT(12),
210 ATH9K_HW_CAP_APM = BIT(13), 210 ATH9K_HW_CAP_APM = BIT(13),
211 ATH9K_HW_CAP_RTT = BIT(14), 211 ATH9K_HW_CAP_RTT = BIT(14),
212#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
212 ATH9K_HW_CAP_MCI = BIT(15), 213 ATH9K_HW_CAP_MCI = BIT(15),
214#else
215 ATH9K_HW_CAP_MCI = 0,
216#endif
213 ATH9K_HW_CAP_DFS = BIT(16), 217 ATH9K_HW_CAP_DFS = BIT(16),
214}; 218};
215 219
@@ -1228,6 +1232,16 @@ void ar9003_mci_sync_bt_state(struct ath_hw *ah);
1228void ar9003_mci_get_interrupt(struct ath_hw *ah, u32 *raw_intr, 1232void ar9003_mci_get_interrupt(struct ath_hw *ah, u32 *raw_intr,
1229 u32 *rx_msg_intr); 1233 u32 *rx_msg_intr);
1230 1234
1235#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
1236static inline enum ath_btcoex_scheme
1237ath9k_hw_get_btcoex_scheme(struct ath_hw *ah)
1238{
1239 return ah->btcoex_hw.scheme;
1240}
1241#else
1242#define ath9k_hw_get_btcoex_scheme(...) ATH_BTCOEX_CFG_NONE
1243#endif
1244
1231#define ATH9K_CLOCK_RATE_CCK 22 1245#define ATH9K_CLOCK_RATE_CCK 22
1232#define ATH9K_CLOCK_RATE_5GHZ_OFDM 40 1246#define ATH9K_CLOCK_RATE_5GHZ_OFDM 40
1233#define ATH9K_CLOCK_RATE_2GHZ_OFDM 44 1247#define ATH9K_CLOCK_RATE_2GHZ_OFDM 44
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
index 58ce67f976f9..abf943557dee 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -425,7 +425,7 @@ static int ath9k_init_btcoex(struct ath_softc *sc)
425 struct ath_hw *ah = sc->sc_ah; 425 struct ath_hw *ah = sc->sc_ah;
426 int r; 426 int r;
427 427
428 switch (sc->sc_ah->btcoex_hw.scheme) { 428 switch (ath9k_hw_get_btcoex_scheme(sc->sc_ah)) {
429 case ATH_BTCOEX_CFG_NONE: 429 case ATH_BTCOEX_CFG_NONE:
430 break; 430 break;
431 case ATH_BTCOEX_CFG_2WIRE: 431 case ATH_BTCOEX_CFG_2WIRE:
@@ -880,10 +880,10 @@ static void ath9k_deinit_softc(struct ath_softc *sc)
880 kfree(sc->sbands[IEEE80211_BAND_5GHZ].channels); 880 kfree(sc->sbands[IEEE80211_BAND_5GHZ].channels);
881 881
882 if ((sc->btcoex.no_stomp_timer) && 882 if ((sc->btcoex.no_stomp_timer) &&
883 sc->sc_ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE) 883 ath9k_hw_get_btcoex_scheme(sc->sc_ah) == ATH_BTCOEX_CFG_3WIRE)
884 ath_gen_timer_free(sc->sc_ah, sc->btcoex.no_stomp_timer); 884 ath_gen_timer_free(sc->sc_ah, sc->btcoex.no_stomp_timer);
885 885
886 if (sc->sc_ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_MCI) 886 if (ath9k_hw_get_btcoex_scheme(sc->sc_ah) == ATH_BTCOEX_CFG_MCI)
887 ath_mci_cleanup(sc); 887 ath_mci_cleanup(sc);
888 888
889 for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) 889 for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++)
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index eb06e4fdf5b2..6e3d8384e081 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -741,11 +741,11 @@ void ath9k_tasklet(unsigned long data)
741 ath_tx_tasklet(sc); 741 ath_tx_tasklet(sc);
742 } 742 }
743 743
744 if (ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE) 744 if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_3WIRE)
745 if (status & ATH9K_INT_GENTIMER) 745 if (status & ATH9K_INT_GENTIMER)
746 ath_gen_timer_isr(sc->sc_ah); 746 ath_gen_timer_isr(sc->sc_ah);
747 747
748 if (status & ATH9K_INT_MCI) 748 if ((status & ATH9K_INT_MCI) && ATH9K_HW_CAP_MCI)
749 ath_mci_intr(sc); 749 ath_mci_intr(sc);
750 750
751out: 751out:
@@ -1081,14 +1081,14 @@ static int ath9k_start(struct ieee80211_hw *hw)
1081 1081
1082 spin_unlock_bh(&sc->sc_pcu_lock); 1082 spin_unlock_bh(&sc->sc_pcu_lock);
1083 1083
1084 if ((ah->btcoex_hw.scheme != ATH_BTCOEX_CFG_NONE) && 1084 if ((ath9k_hw_get_btcoex_scheme(ah) != ATH_BTCOEX_CFG_NONE) &&
1085 !ah->btcoex_hw.enabled) { 1085 !ah->btcoex_hw.enabled) {
1086 if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_MCI)) 1086 if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_MCI))
1087 ath9k_hw_btcoex_set_weight(ah, AR_BT_COEX_WGHT, 1087 ath9k_hw_btcoex_set_weight(ah, AR_BT_COEX_WGHT,
1088 AR_STOMP_LOW_WLAN_WGHT); 1088 AR_STOMP_LOW_WLAN_WGHT);
1089 ath9k_hw_btcoex_enable(ah); 1089 ath9k_hw_btcoex_enable(ah);
1090 1090
1091 if (ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE) 1091 if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_3WIRE)
1092 ath9k_btcoex_timer_resume(sc); 1092 ath9k_btcoex_timer_resume(sc);
1093 } 1093 }
1094 1094
@@ -1191,9 +1191,10 @@ static void ath9k_stop(struct ieee80211_hw *hw)
1191 /* Ensure HW is awake when we try to shut it down. */ 1191 /* Ensure HW is awake when we try to shut it down. */
1192 ath9k_ps_wakeup(sc); 1192 ath9k_ps_wakeup(sc);
1193 1193
1194 if (ah->btcoex_hw.enabled) { 1194 if (ah->btcoex_hw.enabled &&
1195 ath9k_hw_get_btcoex_scheme(ah) != ATH_BTCOEX_CFG_NONE) {
1195 ath9k_hw_btcoex_disable(ah); 1196 ath9k_hw_btcoex_disable(ah);
1196 if (ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE) 1197 if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_3WIRE)
1197 ath9k_btcoex_timer_pause(sc); 1198 ath9k_btcoex_timer_pause(sc);
1198 ath_mci_flush_profile(&sc->btcoex.mci); 1199 ath_mci_flush_profile(&sc->btcoex.mci);
1199 } 1200 }
diff --git a/drivers/net/wireless/ath/ath9k/mci.c b/drivers/net/wireless/ath/ath9k/mci.c
index ca9b53cc4001..fee8c6f0b251 100644
--- a/drivers/net/wireless/ath/ath9k/mci.c
+++ b/drivers/net/wireless/ath/ath9k/mci.c
@@ -417,6 +417,9 @@ int ath_mci_setup(struct ath_softc *sc)
417 struct ath_mci_coex *mci = &sc->mci_coex; 417 struct ath_mci_coex *mci = &sc->mci_coex;
418 int error = 0; 418 int error = 0;
419 419
420 if (!ATH9K_HW_CAP_MCI)
421 return 0;
422
420 mci->sched_buf.bf_len = ATH_MCI_SCHED_BUF_SIZE + ATH_MCI_GPM_BUF_SIZE; 423 mci->sched_buf.bf_len = ATH_MCI_SCHED_BUF_SIZE + ATH_MCI_GPM_BUF_SIZE;
421 424
422 if (ath_mci_buf_alloc(sc, &mci->sched_buf)) { 425 if (ath_mci_buf_alloc(sc, &mci->sched_buf)) {
@@ -450,6 +453,9 @@ void ath_mci_cleanup(struct ath_softc *sc)
450 struct ath_hw *ah = sc->sc_ah; 453 struct ath_hw *ah = sc->sc_ah;
451 struct ath_mci_coex *mci = &sc->mci_coex; 454 struct ath_mci_coex *mci = &sc->mci_coex;
452 455
456 if (!ATH9K_HW_CAP_MCI)
457 return;
458
453 /* 459 /*
454 * both schedule and gpm buffers will be released 460 * both schedule and gpm buffers will be released
455 */ 461 */
@@ -468,6 +474,9 @@ void ath_mci_intr(struct ath_softc *sc)
468 u32 more_data = MCI_GPM_MORE; 474 u32 more_data = MCI_GPM_MORE;
469 bool skip_gpm = false; 475 bool skip_gpm = false;
470 476
477 if (!ATH9K_HW_CAP_MCI)
478 return;
479
471 ar9003_mci_get_interrupt(sc->sc_ah, &mci_int, &mci_int_rxmsg); 480 ar9003_mci_get_interrupt(sc->sc_ah, &mci_int, &mci_int_rxmsg);
472 481
473 if (ar9003_mci_state(ah, MCI_STATE_ENABLE, NULL) == 0) { 482 if (ar9003_mci_state(ah, MCI_STATE_ENABLE, NULL) == 0) {
diff --git a/drivers/net/wireless/ath/ath9k/pci.c b/drivers/net/wireless/ath/ath9k/pci.c
index a439edc5dc06..77dc327def8d 100644
--- a/drivers/net/wireless/ath/ath9k/pci.c
+++ b/drivers/net/wireless/ath/ath9k/pci.c
@@ -121,7 +121,7 @@ static void ath_pci_aspm_init(struct ath_common *common)
121 if (!parent) 121 if (!parent)
122 return; 122 return;
123 123
124 if (ah->btcoex_hw.scheme != ATH_BTCOEX_CFG_NONE) { 124 if (ath9k_hw_get_btcoex_scheme(ah) != ATH_BTCOEX_CFG_NONE) {
125 /* Bluetooth coexistance requires disabling ASPM. */ 125 /* Bluetooth coexistance requires disabling ASPM. */
126 pci_read_config_byte(pdev, pos + PCI_EXP_LNKCTL, &aspm); 126 pci_read_config_byte(pdev, pos + PCI_EXP_LNKCTL, &aspm);
127 aspm &= ~(PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1); 127 aspm &= ~(PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1);