xref: /linux/drivers/net/wireless/ath/ath9k/btcoex.c (revision ee40fa0656a730491765545ff7550f3c1ceb0fbc)
117d50d1dSVasanthakumar Thiagarajan /*
25b68138eSSujith Manoharan  * Copyright (c) 2009-2011 Atheros Communications Inc.
317d50d1dSVasanthakumar Thiagarajan  *
417d50d1dSVasanthakumar Thiagarajan  * Permission to use, copy, modify, and/or distribute this software for any
517d50d1dSVasanthakumar Thiagarajan  * purpose with or without fee is hereby granted, provided that the above
617d50d1dSVasanthakumar Thiagarajan  * copyright notice and this permission notice appear in all copies.
717d50d1dSVasanthakumar Thiagarajan  *
817d50d1dSVasanthakumar Thiagarajan  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
917d50d1dSVasanthakumar Thiagarajan  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1017d50d1dSVasanthakumar Thiagarajan  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1117d50d1dSVasanthakumar Thiagarajan  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1217d50d1dSVasanthakumar Thiagarajan  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1317d50d1dSVasanthakumar Thiagarajan  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1417d50d1dSVasanthakumar Thiagarajan  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1517d50d1dSVasanthakumar Thiagarajan  */
1617d50d1dSVasanthakumar Thiagarajan 
17*ee40fa06SPaul Gortmaker #include <linux/export.h>
18cfe8cba9SLuis R. Rodriguez #include "hw.h"
1917d50d1dSVasanthakumar Thiagarajan 
208b4fc5baSLuis R. Rodriguez enum ath_bt_mode {
218b4fc5baSLuis R. Rodriguez 	ATH_BT_COEX_MODE_LEGACY,        /* legacy rx_clear mode */
228b4fc5baSLuis R. Rodriguez 	ATH_BT_COEX_MODE_UNSLOTTED,     /* untimed/unslotted mode */
238b4fc5baSLuis R. Rodriguez 	ATH_BT_COEX_MODE_SLOTTED,       /* slotted mode */
248b4fc5baSLuis R. Rodriguez 	ATH_BT_COEX_MODE_DISALBED,      /* coexistence disabled */
258b4fc5baSLuis R. Rodriguez };
268b4fc5baSLuis R. Rodriguez 
278b4fc5baSLuis R. Rodriguez struct ath_btcoex_config {
288b4fc5baSLuis R. Rodriguez 	u8 bt_time_extend;
298b4fc5baSLuis R. Rodriguez 	bool bt_txstate_extend;
308b4fc5baSLuis R. Rodriguez 	bool bt_txframe_extend;
318b4fc5baSLuis R. Rodriguez 	enum ath_bt_mode bt_mode; /* coexistence mode */
328b4fc5baSLuis R. Rodriguez 	bool bt_quiet_collision;
338b4fc5baSLuis R. Rodriguez 	bool bt_rxclear_polarity; /* invert rx_clear as WLAN_ACTIVE*/
348b4fc5baSLuis R. Rodriguez 	u8 bt_priority_time;
358b4fc5baSLuis R. Rodriguez 	u8 bt_first_slot_time;
368b4fc5baSLuis R. Rodriguez 	bool bt_hold_rx_clear;
378b4fc5baSLuis R. Rodriguez };
381773912bSVasanthakumar Thiagarajan 
391773912bSVasanthakumar Thiagarajan 
40766ec4a9SLuis R. Rodriguez void ath9k_hw_init_btcoex_hw(struct ath_hw *ah, int qnum)
41af03abecSLuis R. Rodriguez {
42766ec4a9SLuis R. Rodriguez 	struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw;
438b4fc5baSLuis R. Rodriguez 	const struct ath_btcoex_config ath_bt_config = {
448b4fc5baSLuis R. Rodriguez 		.bt_time_extend = 0,
458b4fc5baSLuis R. Rodriguez 		.bt_txstate_extend = true,
468b4fc5baSLuis R. Rodriguez 		.bt_txframe_extend = true,
478b4fc5baSLuis R. Rodriguez 		.bt_mode = ATH_BT_COEX_MODE_SLOTTED,
488b4fc5baSLuis R. Rodriguez 		.bt_quiet_collision = true,
498b4fc5baSLuis R. Rodriguez 		.bt_rxclear_polarity = true,
508b4fc5baSLuis R. Rodriguez 		.bt_priority_time = 2,
518b4fc5baSLuis R. Rodriguez 		.bt_first_slot_time = 5,
528b4fc5baSLuis R. Rodriguez 		.bt_hold_rx_clear = true,
538b4fc5baSLuis R. Rodriguez 	};
5402c5172cSRajkumar Manoharan 	u32 i, idx;
55a6ef530fSVivek Natarajan 	bool rxclear_polarity = ath_bt_config.bt_rxclear_polarity;
56a6ef530fSVivek Natarajan 
57a6ef530fSVivek Natarajan 	if (AR_SREV_9300_20_OR_LATER(ah))
58a6ef530fSVivek Natarajan 		rxclear_polarity = !ath_bt_config.bt_rxclear_polarity;
591773912bSVasanthakumar Thiagarajan 
60766ec4a9SLuis R. Rodriguez 	btcoex_hw->bt_coex_mode =
61766ec4a9SLuis R. Rodriguez 		(btcoex_hw->bt_coex_mode & AR_BT_QCU_THRESH) |
621773912bSVasanthakumar Thiagarajan 		SM(ath_bt_config.bt_time_extend, AR_BT_TIME_EXTEND) |
631773912bSVasanthakumar Thiagarajan 		SM(ath_bt_config.bt_txstate_extend, AR_BT_TXSTATE_EXTEND) |
641773912bSVasanthakumar Thiagarajan 		SM(ath_bt_config.bt_txframe_extend, AR_BT_TX_FRAME_EXTEND) |
651773912bSVasanthakumar Thiagarajan 		SM(ath_bt_config.bt_mode, AR_BT_MODE) |
661773912bSVasanthakumar Thiagarajan 		SM(ath_bt_config.bt_quiet_collision, AR_BT_QUIET) |
67a6ef530fSVivek Natarajan 		SM(rxclear_polarity, AR_BT_RX_CLEAR_POLARITY) |
681773912bSVasanthakumar Thiagarajan 		SM(ath_bt_config.bt_priority_time, AR_BT_PRIORITY_TIME) |
691773912bSVasanthakumar Thiagarajan 		SM(ath_bt_config.bt_first_slot_time, AR_BT_FIRST_SLOT_TIME) |
701773912bSVasanthakumar Thiagarajan 		SM(qnum, AR_BT_QCU_THRESH);
711773912bSVasanthakumar Thiagarajan 
72766ec4a9SLuis R. Rodriguez 	btcoex_hw->bt_coex_mode2 =
731773912bSVasanthakumar Thiagarajan 		SM(ath_bt_config.bt_hold_rx_clear, AR_BT_HOLD_RX_CLEAR) |
741773912bSVasanthakumar Thiagarajan 		SM(ATH_BTCOEX_BMISS_THRESH, AR_BT_BCN_MISS_THRESH) |
751773912bSVasanthakumar Thiagarajan 		AR_BT_DISABLE_BT_ANT;
761773912bSVasanthakumar Thiagarajan 
7702c5172cSRajkumar Manoharan 	for (i = 0; i < 32; i++) {
7802c5172cSRajkumar Manoharan 		idx = (debruijn32 << i) >> 27;
7902c5172cSRajkumar Manoharan 		ah->hw_gen_timers.gen_timer_index[idx] = i;
8002c5172cSRajkumar Manoharan 	}
811773912bSVasanthakumar Thiagarajan }
827322fd19SLuis R. Rodriguez EXPORT_SYMBOL(ath9k_hw_init_btcoex_hw);
831773912bSVasanthakumar Thiagarajan 
8475d7839fSLuis R. Rodriguez void ath9k_hw_btcoex_init_2wire(struct ath_hw *ah)
8517d50d1dSVasanthakumar Thiagarajan {
86766ec4a9SLuis R. Rodriguez 	struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw;
87f14462c6SVasanthakumar Thiagarajan 
8817d50d1dSVasanthakumar Thiagarajan 	/* connect bt_active to baseband */
8917d50d1dSVasanthakumar Thiagarajan 	REG_CLR_BIT(ah, AR_GPIO_INPUT_EN_VAL,
9017d50d1dSVasanthakumar Thiagarajan 		    (AR_GPIO_INPUT_EN_VAL_BT_PRIORITY_DEF |
9117d50d1dSVasanthakumar Thiagarajan 		     AR_GPIO_INPUT_EN_VAL_BT_FREQUENCY_DEF));
9217d50d1dSVasanthakumar Thiagarajan 
9317d50d1dSVasanthakumar Thiagarajan 	REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL,
9417d50d1dSVasanthakumar Thiagarajan 		    AR_GPIO_INPUT_EN_VAL_BT_ACTIVE_BB);
9517d50d1dSVasanthakumar Thiagarajan 
9617d50d1dSVasanthakumar Thiagarajan 	/* Set input mux for bt_active to gpio pin */
9717d50d1dSVasanthakumar Thiagarajan 	REG_RMW_FIELD(ah, AR_GPIO_INPUT_MUX1,
9817d50d1dSVasanthakumar Thiagarajan 		      AR_GPIO_INPUT_MUX1_BT_ACTIVE,
99766ec4a9SLuis R. Rodriguez 		      btcoex_hw->btactive_gpio);
10017d50d1dSVasanthakumar Thiagarajan 
10117d50d1dSVasanthakumar Thiagarajan 	/* Configure the desired gpio port for input */
102766ec4a9SLuis R. Rodriguez 	ath9k_hw_cfg_gpio_input(ah, btcoex_hw->btactive_gpio);
1037a2f0f58SLuis R. Rodriguez }
1047322fd19SLuis R. Rodriguez EXPORT_SYMBOL(ath9k_hw_btcoex_init_2wire);
1057a2f0f58SLuis R. Rodriguez 
10675d7839fSLuis R. Rodriguez void ath9k_hw_btcoex_init_3wire(struct ath_hw *ah)
1077a2f0f58SLuis R. Rodriguez {
108766ec4a9SLuis R. Rodriguez 	struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw;
1097a2f0f58SLuis R. Rodriguez 
1101773912bSVasanthakumar Thiagarajan 	/* btcoex 3-wire */
1111773912bSVasanthakumar Thiagarajan 	REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL,
1121773912bSVasanthakumar Thiagarajan 			(AR_GPIO_INPUT_EN_VAL_BT_PRIORITY_BB |
1131773912bSVasanthakumar Thiagarajan 			 AR_GPIO_INPUT_EN_VAL_BT_ACTIVE_BB));
1141773912bSVasanthakumar Thiagarajan 
1151773912bSVasanthakumar Thiagarajan 	/* Set input mux for bt_prority_async and
1161773912bSVasanthakumar Thiagarajan 	 *                  bt_active_async to GPIO pins */
1171773912bSVasanthakumar Thiagarajan 	REG_RMW_FIELD(ah, AR_GPIO_INPUT_MUX1,
1181773912bSVasanthakumar Thiagarajan 			AR_GPIO_INPUT_MUX1_BT_ACTIVE,
119766ec4a9SLuis R. Rodriguez 			btcoex_hw->btactive_gpio);
1201773912bSVasanthakumar Thiagarajan 
1211773912bSVasanthakumar Thiagarajan 	REG_RMW_FIELD(ah, AR_GPIO_INPUT_MUX1,
1221773912bSVasanthakumar Thiagarajan 			AR_GPIO_INPUT_MUX1_BT_PRIORITY,
123766ec4a9SLuis R. Rodriguez 			btcoex_hw->btpriority_gpio);
1241773912bSVasanthakumar Thiagarajan 
1251773912bSVasanthakumar Thiagarajan 	/* Configure the desired GPIO ports for input */
1261773912bSVasanthakumar Thiagarajan 
127766ec4a9SLuis R. Rodriguez 	ath9k_hw_cfg_gpio_input(ah, btcoex_hw->btactive_gpio);
128766ec4a9SLuis R. Rodriguez 	ath9k_hw_cfg_gpio_input(ah, btcoex_hw->btpriority_gpio);
1297a2f0f58SLuis R. Rodriguez }
1307322fd19SLuis R. Rodriguez EXPORT_SYMBOL(ath9k_hw_btcoex_init_3wire);
1311773912bSVasanthakumar Thiagarajan 
132bc74bf8fSLuis R. Rodriguez static void ath9k_hw_btcoex_enable_2wire(struct ath_hw *ah)
13317d50d1dSVasanthakumar Thiagarajan {
134766ec4a9SLuis R. Rodriguez 	struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw;
135f14462c6SVasanthakumar Thiagarajan 
13617d50d1dSVasanthakumar Thiagarajan 	/* Configure the desired GPIO port for TX_FRAME output */
137766ec4a9SLuis R. Rodriguez 	ath9k_hw_cfg_output(ah, btcoex_hw->wlanactive_gpio,
13817d50d1dSVasanthakumar Thiagarajan 			    AR_GPIO_OUTPUT_MUX_AS_TX_FRAME);
139bc74bf8fSLuis R. Rodriguez }
140bc74bf8fSLuis R. Rodriguez 
1415e197292SLuis R. Rodriguez void ath9k_hw_btcoex_set_weight(struct ath_hw *ah,
1425e197292SLuis R. Rodriguez 				u32 bt_weight,
1435e197292SLuis R. Rodriguez 				u32 wlan_weight)
1445e197292SLuis R. Rodriguez {
1455e197292SLuis R. Rodriguez 	struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw;
1465e197292SLuis R. Rodriguez 
1475e197292SLuis R. Rodriguez 	btcoex_hw->bt_coex_weights = SM(bt_weight, AR_BTCOEX_BT_WGHT) |
1485e197292SLuis R. Rodriguez 				     SM(wlan_weight, AR_BTCOEX_WL_WGHT);
1495e197292SLuis R. Rodriguez }
1507322fd19SLuis R. Rodriguez EXPORT_SYMBOL(ath9k_hw_btcoex_set_weight);
1515e197292SLuis R. Rodriguez 
152a6ef530fSVivek Natarajan 
153bc74bf8fSLuis R. Rodriguez static void ath9k_hw_btcoex_enable_3wire(struct ath_hw *ah)
154bc74bf8fSLuis R. Rodriguez {
155766ec4a9SLuis R. Rodriguez 	struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw;
15621cb9879SVivek Natarajan 	u32  val;
157bc74bf8fSLuis R. Rodriguez 
1581773912bSVasanthakumar Thiagarajan 	/*
1591773912bSVasanthakumar Thiagarajan 	 * Program coex mode and weight registers to
1601773912bSVasanthakumar Thiagarajan 	 * enable coex 3-wire
1611773912bSVasanthakumar Thiagarajan 	 */
162766ec4a9SLuis R. Rodriguez 	REG_WRITE(ah, AR_BT_COEX_MODE, btcoex_hw->bt_coex_mode);
163766ec4a9SLuis R. Rodriguez 	REG_WRITE(ah, AR_BT_COEX_MODE2, btcoex_hw->bt_coex_mode2);
1641773912bSVasanthakumar Thiagarajan 
165a6ef530fSVivek Natarajan 
166a6ef530fSVivek Natarajan 	if (AR_SREV_9300_20_OR_LATER(ah)) {
167a6ef530fSVivek Natarajan 		REG_WRITE(ah, AR_BT_COEX_WL_WEIGHTS0, ah->bt_coex_wlan_weight[0]);
168a6ef530fSVivek Natarajan 		REG_WRITE(ah, AR_BT_COEX_WL_WEIGHTS1, ah->bt_coex_wlan_weight[1]);
169a6ef530fSVivek Natarajan 		REG_WRITE(ah, AR_BT_COEX_BT_WEIGHTS0, ah->bt_coex_bt_weight[0]);
170a6ef530fSVivek Natarajan 		REG_WRITE(ah, AR_BT_COEX_BT_WEIGHTS1, ah->bt_coex_bt_weight[1]);
171a6ef530fSVivek Natarajan 		REG_WRITE(ah, AR_BT_COEX_BT_WEIGHTS2, ah->bt_coex_bt_weight[2]);
172a6ef530fSVivek Natarajan 		REG_WRITE(ah, AR_BT_COEX_BT_WEIGHTS3, ah->bt_coex_bt_weight[3]);
173a6ef530fSVivek Natarajan 
174a6ef530fSVivek Natarajan 	} else
175a6ef530fSVivek Natarajan 		REG_WRITE(ah, AR_BT_COEX_WEIGHT, btcoex_hw->bt_coex_weights);
176a6ef530fSVivek Natarajan 
177a6ef530fSVivek Natarajan 
178a6ef530fSVivek Natarajan 
17921cb9879SVivek Natarajan 	if (AR_SREV_9271(ah)) {
18021cb9879SVivek Natarajan 		val = REG_READ(ah, 0x50040);
18121cb9879SVivek Natarajan 		val &= 0xFFFFFEFF;
18221cb9879SVivek Natarajan 		REG_WRITE(ah, 0x50040, val);
18321cb9879SVivek Natarajan 	}
18421cb9879SVivek Natarajan 
185bc74bf8fSLuis R. Rodriguez 	REG_RMW_FIELD(ah, AR_QUIET1, AR_QUIET1_QUIET_ACK_CTS_ENABLE, 1);
186bc74bf8fSLuis R. Rodriguez 	REG_RMW_FIELD(ah, AR_PCU_MISC, AR_PCU_BT_ANT_PREVENT_RX, 0);
1871773912bSVasanthakumar Thiagarajan 
188766ec4a9SLuis R. Rodriguez 	ath9k_hw_cfg_output(ah, btcoex_hw->wlanactive_gpio,
1891773912bSVasanthakumar Thiagarajan 			    AR_GPIO_OUTPUT_MUX_AS_RX_CLEAR_EXTERNAL);
1901773912bSVasanthakumar Thiagarajan }
1911773912bSVasanthakumar Thiagarajan 
192bc74bf8fSLuis R. Rodriguez void ath9k_hw_btcoex_enable(struct ath_hw *ah)
193bc74bf8fSLuis R. Rodriguez {
194766ec4a9SLuis R. Rodriguez 	struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw;
195bc74bf8fSLuis R. Rodriguez 
196766ec4a9SLuis R. Rodriguez 	switch (btcoex_hw->scheme) {
197bc74bf8fSLuis R. Rodriguez 	case ATH_BTCOEX_CFG_NONE:
198bc74bf8fSLuis R. Rodriguez 		break;
199bc74bf8fSLuis R. Rodriguez 	case ATH_BTCOEX_CFG_2WIRE:
200bc74bf8fSLuis R. Rodriguez 		ath9k_hw_btcoex_enable_2wire(ah);
201bc74bf8fSLuis R. Rodriguez 		break;
202bc74bf8fSLuis R. Rodriguez 	case ATH_BTCOEX_CFG_3WIRE:
203bc74bf8fSLuis R. Rodriguez 		ath9k_hw_btcoex_enable_3wire(ah);
204bc74bf8fSLuis R. Rodriguez 		break;
205bc74bf8fSLuis R. Rodriguez 	}
206bc74bf8fSLuis R. Rodriguez 
2071773912bSVasanthakumar Thiagarajan 	REG_RMW(ah, AR_GPIO_PDPU,
208766ec4a9SLuis R. Rodriguez 		(0x2 << (btcoex_hw->btactive_gpio * 2)),
209766ec4a9SLuis R. Rodriguez 		(0x3 << (btcoex_hw->btactive_gpio * 2)));
21017d50d1dSVasanthakumar Thiagarajan 
211766ec4a9SLuis R. Rodriguez 	ah->btcoex_hw.enabled = true;
21217d50d1dSVasanthakumar Thiagarajan }
2137322fd19SLuis R. Rodriguez EXPORT_SYMBOL(ath9k_hw_btcoex_enable);
21417d50d1dSVasanthakumar Thiagarajan 
21517d50d1dSVasanthakumar Thiagarajan void ath9k_hw_btcoex_disable(struct ath_hw *ah)
21617d50d1dSVasanthakumar Thiagarajan {
217766ec4a9SLuis R. Rodriguez 	struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw;
21817d50d1dSVasanthakumar Thiagarajan 
219766ec4a9SLuis R. Rodriguez 	ath9k_hw_set_gpio(ah, btcoex_hw->wlanactive_gpio, 0);
220f14462c6SVasanthakumar Thiagarajan 
221766ec4a9SLuis R. Rodriguez 	ath9k_hw_cfg_output(ah, btcoex_hw->wlanactive_gpio,
22217d50d1dSVasanthakumar Thiagarajan 			AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
22317d50d1dSVasanthakumar Thiagarajan 
224766ec4a9SLuis R. Rodriguez 	if (btcoex_hw->scheme == ATH_BTCOEX_CFG_3WIRE) {
2251773912bSVasanthakumar Thiagarajan 		REG_WRITE(ah, AR_BT_COEX_MODE, AR_BT_QUIET | AR_BT_MODE);
2261773912bSVasanthakumar Thiagarajan 		REG_WRITE(ah, AR_BT_COEX_MODE2, 0);
227a6ef530fSVivek Natarajan 
228a6ef530fSVivek Natarajan 		if (AR_SREV_9300_20_OR_LATER(ah)) {
229a6ef530fSVivek Natarajan 			REG_WRITE(ah, AR_BT_COEX_WL_WEIGHTS0, 0);
230a6ef530fSVivek Natarajan 			REG_WRITE(ah, AR_BT_COEX_WL_WEIGHTS1, 0);
231a6ef530fSVivek Natarajan 			REG_WRITE(ah, AR_BT_COEX_BT_WEIGHTS0, 0);
232a6ef530fSVivek Natarajan 			REG_WRITE(ah, AR_BT_COEX_BT_WEIGHTS1, 0);
233a6ef530fSVivek Natarajan 			REG_WRITE(ah, AR_BT_COEX_BT_WEIGHTS2, 0);
234a6ef530fSVivek Natarajan 			REG_WRITE(ah, AR_BT_COEX_BT_WEIGHTS3, 0);
235a6ef530fSVivek Natarajan 		} else
236a6ef530fSVivek Natarajan 			REG_WRITE(ah, AR_BT_COEX_WEIGHT, 0);
237a6ef530fSVivek Natarajan 
2381773912bSVasanthakumar Thiagarajan 	}
2391773912bSVasanthakumar Thiagarajan 
240766ec4a9SLuis R. Rodriguez 	ah->btcoex_hw.enabled = false;
24117d50d1dSVasanthakumar Thiagarajan }
2427322fd19SLuis R. Rodriguez EXPORT_SYMBOL(ath9k_hw_btcoex_disable);
243978f78bfSVivek Natarajan 
244978f78bfSVivek Natarajan static void ar9003_btcoex_bt_stomp(struct ath_hw *ah,
245978f78bfSVivek Natarajan 			 enum ath_stomp_type stomp_type)
246978f78bfSVivek Natarajan {
247978f78bfSVivek Natarajan 	ah->bt_coex_bt_weight[0] = AR9300_BT_WGHT;
248978f78bfSVivek Natarajan 	ah->bt_coex_bt_weight[1] = AR9300_BT_WGHT;
249978f78bfSVivek Natarajan 	ah->bt_coex_bt_weight[2] = AR9300_BT_WGHT;
250978f78bfSVivek Natarajan 	ah->bt_coex_bt_weight[3] = AR9300_BT_WGHT;
251978f78bfSVivek Natarajan 
252978f78bfSVivek Natarajan 
253978f78bfSVivek Natarajan 	switch (stomp_type) {
254978f78bfSVivek Natarajan 	case ATH_BTCOEX_STOMP_ALL:
255978f78bfSVivek Natarajan 		ah->bt_coex_wlan_weight[0] = AR9300_STOMP_ALL_WLAN_WGHT0;
256978f78bfSVivek Natarajan 		ah->bt_coex_wlan_weight[1] = AR9300_STOMP_ALL_WLAN_WGHT1;
257978f78bfSVivek Natarajan 		break;
258978f78bfSVivek Natarajan 	case ATH_BTCOEX_STOMP_LOW:
259978f78bfSVivek Natarajan 		ah->bt_coex_wlan_weight[0] = AR9300_STOMP_LOW_WLAN_WGHT0;
260978f78bfSVivek Natarajan 		ah->bt_coex_wlan_weight[1] = AR9300_STOMP_LOW_WLAN_WGHT1;
261978f78bfSVivek Natarajan 		break;
262978f78bfSVivek Natarajan 	case ATH_BTCOEX_STOMP_NONE:
263978f78bfSVivek Natarajan 		ah->bt_coex_wlan_weight[0] = AR9300_STOMP_NONE_WLAN_WGHT0;
264978f78bfSVivek Natarajan 		ah->bt_coex_wlan_weight[1] = AR9300_STOMP_NONE_WLAN_WGHT1;
265978f78bfSVivek Natarajan 		break;
266978f78bfSVivek Natarajan 
267978f78bfSVivek Natarajan 	default:
268978f78bfSVivek Natarajan 		ath_dbg(ath9k_hw_common(ah), ATH_DBG_BTCOEX,
269978f78bfSVivek Natarajan 				"Invalid Stomptype\n");
270978f78bfSVivek Natarajan 		break;
271978f78bfSVivek Natarajan 	}
272978f78bfSVivek Natarajan 
273978f78bfSVivek Natarajan 	ath9k_hw_btcoex_enable(ah);
274978f78bfSVivek Natarajan }
275978f78bfSVivek Natarajan 
276978f78bfSVivek Natarajan /*
277978f78bfSVivek Natarajan  * Configures appropriate weight based on stomp type.
278978f78bfSVivek Natarajan  */
279978f78bfSVivek Natarajan void ath9k_hw_btcoex_bt_stomp(struct ath_hw *ah,
280978f78bfSVivek Natarajan 			      enum ath_stomp_type stomp_type)
281978f78bfSVivek Natarajan {
282978f78bfSVivek Natarajan 	if (AR_SREV_9300_20_OR_LATER(ah)) {
283978f78bfSVivek Natarajan 		ar9003_btcoex_bt_stomp(ah, stomp_type);
284978f78bfSVivek Natarajan 		return;
285978f78bfSVivek Natarajan 	}
286978f78bfSVivek Natarajan 
287978f78bfSVivek Natarajan 	switch (stomp_type) {
288978f78bfSVivek Natarajan 	case ATH_BTCOEX_STOMP_ALL:
289978f78bfSVivek Natarajan 		ath9k_hw_btcoex_set_weight(ah, AR_BT_COEX_WGHT,
290978f78bfSVivek Natarajan 				AR_STOMP_ALL_WLAN_WGHT);
291978f78bfSVivek Natarajan 		break;
292978f78bfSVivek Natarajan 	case ATH_BTCOEX_STOMP_LOW:
293978f78bfSVivek Natarajan 		ath9k_hw_btcoex_set_weight(ah, AR_BT_COEX_WGHT,
294978f78bfSVivek Natarajan 				AR_STOMP_LOW_WLAN_WGHT);
295978f78bfSVivek Natarajan 		break;
296978f78bfSVivek Natarajan 	case ATH_BTCOEX_STOMP_NONE:
297978f78bfSVivek Natarajan 		ath9k_hw_btcoex_set_weight(ah, AR_BT_COEX_WGHT,
298978f78bfSVivek Natarajan 				AR_STOMP_NONE_WLAN_WGHT);
299978f78bfSVivek Natarajan 		break;
300978f78bfSVivek Natarajan 	default:
301978f78bfSVivek Natarajan 		ath_dbg(ath9k_hw_common(ah), ATH_DBG_BTCOEX,
302978f78bfSVivek Natarajan 				"Invalid Stomptype\n");
303978f78bfSVivek Natarajan 		break;
304978f78bfSVivek Natarajan 	}
305978f78bfSVivek Natarajan 
306978f78bfSVivek Natarajan 	ath9k_hw_btcoex_enable(ah);
307978f78bfSVivek Natarajan }
308978f78bfSVivek Natarajan EXPORT_SYMBOL(ath9k_hw_btcoex_bt_stomp);
309