| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2011-05-17 13:36:18 +05:30
										 |  |  |  * Copyright (c) 2008-2011 Atheros Communications Inc. | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  |  * | 
					
						
							|  |  |  |  * Permission to use, copy, modify, and/or distribute this software for any | 
					
						
							|  |  |  |  * purpose with or without fee is hereby granted, provided that the above | 
					
						
							|  |  |  |  * copyright notice and this permission notice appear in all copies. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | 
					
						
							|  |  |  |  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | 
					
						
							|  |  |  |  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | 
					
						
							|  |  |  |  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | 
					
						
							|  |  |  |  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | 
					
						
							|  |  |  |  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | 
					
						
							|  |  |  |  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "ath9k.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /********************************/ | 
					
						
							|  |  |  | /*	 LED functions		*/ | 
					
						
							|  |  |  | /********************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-27 22:26:40 +01:00
										 |  |  | #ifdef CONFIG_MAC80211_LEDS
 | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | static void ath_led_brightness(struct led_classdev *led_cdev, | 
					
						
							|  |  |  | 			       enum led_brightness brightness) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2011-02-27 22:26:40 +01:00
										 |  |  | 	struct ath_softc *sc = container_of(led_cdev, struct ath_softc, led_cdev); | 
					
						
							|  |  |  | 	ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, (brightness == LED_OFF)); | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ath_deinit_leds(struct ath_softc *sc) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2011-02-27 22:26:40 +01:00
										 |  |  | 	if (!sc->led_registered) | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ath_led_brightness(&sc->led_cdev, LED_OFF); | 
					
						
							|  |  |  | 	led_classdev_unregister(&sc->led_cdev); | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ath_init_leds(struct ath_softc *sc) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int ret; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-12 22:35:57 +02:00
										 |  |  | 	if (AR_SREV_9100(sc->sc_ah)) | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-27 22:26:40 +01:00
										 |  |  | 	if (!led_blink) | 
					
						
							|  |  |  | 		sc->led_cdev.default_trigger = | 
					
						
							|  |  |  | 			ieee80211_get_radio_led_name(sc->hw); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	snprintf(sc->led_name, sizeof(sc->led_name), | 
					
						
							|  |  |  | 		"ath9k-%s", wiphy_name(sc->hw->wiphy)); | 
					
						
							|  |  |  | 	sc->led_cdev.name = sc->led_name; | 
					
						
							|  |  |  | 	sc->led_cdev.brightness_set = ath_led_brightness; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ret = led_classdev_register(wiphy_dev(sc->hw->wiphy), &sc->led_cdev); | 
					
						
							|  |  |  | 	if (ret < 0) | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	sc->led_registered = true; | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2012-09-12 18:59:23 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | void ath_fill_led_pin(struct ath_softc *sc) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct ath_hw *ah = sc->sc_ah; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (AR_SREV_9100(ah) || (ah->led_pin >= 0)) | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (AR_SREV_9287(ah)) | 
					
						
							|  |  |  | 		ah->led_pin = ATH_LED_PIN_9287; | 
					
						
							|  |  |  | 	else if (AR_SREV_9485(sc->sc_ah)) | 
					
						
							|  |  |  | 		ah->led_pin = ATH_LED_PIN_9485; | 
					
						
							|  |  |  | 	else if (AR_SREV_9300(sc->sc_ah)) | 
					
						
							|  |  |  | 		ah->led_pin = ATH_LED_PIN_9300; | 
					
						
							|  |  |  | 	else if (AR_SREV_9462(sc->sc_ah) || AR_SREV_9565(sc->sc_ah)) | 
					
						
							|  |  |  | 		ah->led_pin = ATH_LED_PIN_9462; | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		ah->led_pin = ATH_LED_PIN_DEF; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Configure gpio 1 for output */ | 
					
						
							|  |  |  | 	ath9k_hw_cfg_output(ah, ah->led_pin, AR_GPIO_OUTPUT_MUX_AS_OUTPUT); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* LED off, active low */ | 
					
						
							|  |  |  | 	ath9k_hw_set_gpio(ah, ah->led_pin, 1); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2011-02-27 22:26:40 +01:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | /*******************/ | 
					
						
							|  |  |  | /*	Rfkill	   */ | 
					
						
							|  |  |  | /*******************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static bool ath_is_rfkill_set(struct ath_softc *sc) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct ath_hw *ah = sc->sc_ah; | 
					
						
							| 
									
										
										
										
											2011-09-28 16:56:10 +05:30
										 |  |  | 	bool is_blocked; | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-28 16:56:10 +05:30
										 |  |  | 	ath9k_ps_wakeup(sc); | 
					
						
							|  |  |  | 	is_blocked = ath9k_hw_gpio_get(ah, ah->rfkill_gpio) == | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | 				  ah->rfkill_polarity; | 
					
						
							| 
									
										
										
										
											2011-09-28 16:56:10 +05:30
										 |  |  | 	ath9k_ps_restore(sc); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return is_blocked; | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ath9k_rfkill_poll_state(struct ieee80211_hw *hw) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2011-01-24 19:23:18 +01:00
										 |  |  | 	struct ath_softc *sc = hw->priv; | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | 	bool blocked = !!ath_is_rfkill_set(sc); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	wiphy_rfkill_set_hw_state(hw->wiphy, blocked); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ath_start_rfkill_poll(struct ath_softc *sc) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct ath_hw *ah = sc->sc_ah; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (ah->caps.hw_caps & ATH9K_HW_CAP_RFSILENT) | 
					
						
							|  |  |  | 		wiphy_rfkill_start_polling(sc->hw->wiphy); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-22 12:40:44 +05:30
										 |  |  | #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | /******************/ | 
					
						
							|  |  |  | /*     BTCOEX     */ | 
					
						
							|  |  |  | /******************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * Detects if there is any priority bt traffic | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | static void ath_detect_bt_priority(struct ath_softc *sc) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct ath_btcoex *btcoex = &sc->btcoex; | 
					
						
							|  |  |  | 	struct ath_hw *ah = sc->sc_ah; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (ath9k_hw_gpio_get(sc->sc_ah, ah->btcoex_hw.btpriority_gpio)) | 
					
						
							|  |  |  | 		btcoex->bt_priority_cnt++; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (time_after(jiffies, btcoex->bt_priority_time + | 
					
						
							|  |  |  | 			msecs_to_jiffies(ATH_BT_PRIORITY_TIME_THRESHOLD))) { | 
					
						
							| 
									
										
										
										
											2012-06-04 16:27:58 +05:30
										 |  |  | 		clear_bit(BT_OP_PRIORITY_DETECTED, &btcoex->op_flags); | 
					
						
							|  |  |  | 		clear_bit(BT_OP_SCAN, &btcoex->op_flags); | 
					
						
							| 
									
										
										
										
											2010-01-21 11:17:27 +05:30
										 |  |  | 		/* Detect if colocated bt started scanning */ | 
					
						
							|  |  |  | 		if (btcoex->bt_priority_cnt >= ATH_BT_CNT_SCAN_THRESHOLD) { | 
					
						
							| 
									
										
										
										
											2011-12-15 14:55:53 -08:00
										 |  |  | 			ath_dbg(ath9k_hw_common(sc->sc_ah), BTCOEX, | 
					
						
							| 
									
										
										
										
											2010-12-02 19:12:37 -08:00
										 |  |  | 				"BT scan detected\n"); | 
					
						
							| 
									
										
										
										
											2012-06-04 16:27:58 +05:30
										 |  |  | 			set_bit(BT_OP_PRIORITY_DETECTED, &btcoex->op_flags); | 
					
						
							|  |  |  | 			set_bit(BT_OP_SCAN, &btcoex->op_flags); | 
					
						
							| 
									
										
										
										
											2010-01-21 11:17:27 +05:30
										 |  |  | 		} else if (btcoex->bt_priority_cnt >= ATH_BT_CNT_THRESHOLD) { | 
					
						
							| 
									
										
										
										
											2011-12-15 14:55:53 -08:00
										 |  |  | 			ath_dbg(ath9k_hw_common(sc->sc_ah), BTCOEX, | 
					
						
							| 
									
										
										
										
											2010-12-02 19:12:37 -08:00
										 |  |  | 				"BT priority traffic detected\n"); | 
					
						
							| 
									
										
										
										
											2012-06-04 16:27:58 +05:30
										 |  |  | 			set_bit(BT_OP_PRIORITY_DETECTED, &btcoex->op_flags); | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		btcoex->bt_priority_cnt = 0; | 
					
						
							|  |  |  | 		btcoex->bt_priority_time = jiffies; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void ath9k_gen_timer_start(struct ath_hw *ah, | 
					
						
							|  |  |  | 				  struct ath_gen_timer *timer, | 
					
						
							| 
									
										
										
										
											2011-04-21 18:33:27 +05:30
										 |  |  | 				  u32 trig_timeout, | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | 				  u32 timer_period) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2011-04-21 18:33:27 +05:30
										 |  |  | 	ath9k_hw_gen_timer_start(ah, timer, trig_timeout, timer_period); | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-31 18:05:31 -04:00
										 |  |  | 	if ((ah->imask & ATH9K_INT_GENTIMER) == 0) { | 
					
						
							| 
									
										
										
										
											2010-11-08 20:54:47 +01:00
										 |  |  | 		ath9k_hw_disable_interrupts(ah); | 
					
						
							| 
									
										
										
										
											2010-03-31 18:05:31 -04:00
										 |  |  | 		ah->imask |= ATH9K_INT_GENTIMER; | 
					
						
							| 
									
										
										
										
											2011-10-08 20:06:19 +02:00
										 |  |  | 		ath9k_hw_set_interrupts(ah); | 
					
						
							| 
									
										
										
										
											2011-08-05 18:59:40 +05:30
										 |  |  | 		ath9k_hw_enable_interrupts(ah); | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void ath9k_gen_timer_stop(struct ath_hw *ah, struct ath_gen_timer *timer) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct ath_gen_timer_table *timer_table = &ah->hw_gen_timers; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ath9k_hw_gen_timer_stop(ah, timer); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* if no timer is enabled, turn off interrupt mask */ | 
					
						
							|  |  |  | 	if (timer_table->timer_mask.val == 0) { | 
					
						
							| 
									
										
										
										
											2010-11-08 20:54:47 +01:00
										 |  |  | 		ath9k_hw_disable_interrupts(ah); | 
					
						
							| 
									
										
										
										
											2010-03-31 18:05:31 -04:00
										 |  |  | 		ah->imask &= ~ATH9K_INT_GENTIMER; | 
					
						
							| 
									
										
										
										
											2011-10-08 20:06:19 +02:00
										 |  |  | 		ath9k_hw_set_interrupts(ah); | 
					
						
							| 
									
										
										
										
											2011-08-05 18:59:40 +05:30
										 |  |  | 		ath9k_hw_enable_interrupts(ah); | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-30 09:03:20 +05:30
										 |  |  | static void ath_mci_ftp_adjust(struct ath_softc *sc) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct ath_btcoex *btcoex = &sc->btcoex; | 
					
						
							|  |  |  | 	struct ath_mci_profile *mci = &btcoex->mci; | 
					
						
							|  |  |  | 	struct ath_hw *ah = sc->sc_ah; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (btcoex->bt_wait_time > ATH_BTCOEX_RX_WAIT_TIME) { | 
					
						
							|  |  |  | 		if (ar9003_mci_state(ah, MCI_STATE_NEED_FTP_STOMP) && | 
					
						
							|  |  |  | 		    (mci->num_pan || mci->num_other_acl)) | 
					
						
							|  |  |  | 			ah->btcoex_hw.mci.stomp_ftp = | 
					
						
							|  |  |  | 				(sc->rx.num_pkts < ATH_BTCOEX_STOMP_FTP_THRESH); | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 			ah->btcoex_hw.mci.stomp_ftp = false; | 
					
						
							|  |  |  | 		btcoex->bt_wait_time = 0; | 
					
						
							|  |  |  | 		sc->rx.num_pkts = 0; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | /*
 | 
					
						
							|  |  |  |  * This is the master bt coex timer which runs for every | 
					
						
							|  |  |  |  * 45ms, bt traffic will be given priority during 55% of this | 
					
						
							|  |  |  |  * period while wlan gets remaining 45% | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | static void ath_btcoex_period_timer(unsigned long data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct ath_softc *sc = (struct ath_softc *) data; | 
					
						
							|  |  |  | 	struct ath_hw *ah = sc->sc_ah; | 
					
						
							|  |  |  | 	struct ath_btcoex *btcoex = &sc->btcoex; | 
					
						
							| 
									
										
										
										
											2012-09-30 09:03:37 +05:30
										 |  |  | 	enum ath_stomp_type stomp_type; | 
					
						
							| 
									
										
										
										
											2010-01-21 11:17:27 +05:30
										 |  |  | 	u32 timer_period; | 
					
						
							| 
									
										
										
										
											2012-07-01 19:53:54 +05:30
										 |  |  | 	unsigned long flags; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	spin_lock_irqsave(&sc->sc_pm_lock, flags); | 
					
						
							|  |  |  | 	if (sc->sc_ah->power_mode == ATH9K_PM_NETWORK_SLEEP) { | 
					
						
							| 
									
										
										
										
											2012-10-08 21:30:51 +05:30
										 |  |  | 		btcoex->bt_wait_time += btcoex->btcoex_period; | 
					
						
							| 
									
										
										
										
											2012-07-01 19:53:54 +05:30
										 |  |  | 		spin_unlock_irqrestore(&sc->sc_pm_lock, flags); | 
					
						
							|  |  |  | 		goto skip_hw_wakeup; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	spin_unlock_irqrestore(&sc->sc_pm_lock, flags); | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-12 14:07:25 +05:30
										 |  |  | 	ath9k_mci_update_rssi(sc); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-04-26 10:39:55 +05:30
										 |  |  | 	ath9k_ps_wakeup(sc); | 
					
						
							| 
									
										
										
										
											2012-09-30 09:03:37 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-24 18:19:49 +05:30
										 |  |  | 	if (!(ah->caps.hw_caps & ATH9K_HW_CAP_MCI)) | 
					
						
							|  |  |  | 		ath_detect_bt_priority(sc); | 
					
						
							| 
									
										
										
										
											2010-01-21 11:17:27 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-30 09:03:20 +05:30
										 |  |  | 	if (ah->caps.hw_caps & ATH9K_HW_CAP_MCI) | 
					
						
							|  |  |  | 		ath_mci_ftp_adjust(sc); | 
					
						
							| 
									
										
										
										
											2012-06-04 16:28:52 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | 	spin_lock_bh(&btcoex->btcoex_lock); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-30 09:03:37 +05:30
										 |  |  | 	stomp_type = btcoex->bt_stomp_type; | 
					
						
							|  |  |  | 	timer_period = btcoex->btcoex_no_stomp; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!(ah->caps.hw_caps & ATH9K_HW_CAP_MCI)) { | 
					
						
							|  |  |  | 		if (test_bit(BT_OP_SCAN, &btcoex->op_flags)) { | 
					
						
							|  |  |  | 			stomp_type = ATH_BTCOEX_STOMP_ALL; | 
					
						
							|  |  |  | 			timer_period = btcoex->btscan_no_stomp; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2012-11-20 18:30:01 +05:30
										 |  |  | 	} else if (btcoex->stomp_audio >= 5) { | 
					
						
							|  |  |  | 		stomp_type = ATH_BTCOEX_STOMP_AUDIO; | 
					
						
							|  |  |  | 		btcoex->stomp_audio = 0; | 
					
						
							| 
									
										
										
										
											2012-09-30 09:03:37 +05:30
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-30 09:03:37 +05:30
										 |  |  | 	ath9k_hw_btcoex_bt_stomp(ah, stomp_type); | 
					
						
							| 
									
										
										
										
											2011-11-12 19:35:46 +05:30
										 |  |  | 	ath9k_hw_btcoex_enable(ah); | 
					
						
							| 
									
										
										
										
											2012-09-30 09:03:37 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | 	spin_unlock_bh(&btcoex->btcoex_lock); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-04 19:33:33 +05:30
										 |  |  | 	/*
 | 
					
						
							|  |  |  | 	 * btcoex_period is in msec while (btocex/btscan_)no_stomp are in usec, | 
					
						
							|  |  |  | 	 * ensure that we properly convert btcoex_period to usec | 
					
						
							|  |  |  | 	 * for any comparision with (btcoex/btscan_)no_stomp. | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	if (btcoex->btcoex_period * 1000 != btcoex->btcoex_no_stomp) { | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | 		if (btcoex->hw_timer_enabled) | 
					
						
							|  |  |  | 			ath9k_gen_timer_stop(ah, btcoex->no_stomp_timer); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-04-21 18:33:27 +05:30
										 |  |  | 		ath9k_gen_timer_start(ah, btcoex->no_stomp_timer, timer_period, | 
					
						
							| 
									
										
										
										
											2010-10-15 20:03:32 +02:00
										 |  |  | 				      timer_period * 10); | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | 		btcoex->hw_timer_enabled = true; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-04-26 10:39:55 +05:30
										 |  |  | 	ath9k_ps_restore(sc); | 
					
						
							| 
									
										
										
										
											2012-09-30 09:03:37 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-07-01 19:53:54 +05:30
										 |  |  | skip_hw_wakeup: | 
					
						
							| 
									
										
										
										
											2012-09-30 09:03:37 +05:30
										 |  |  | 	mod_timer(&btcoex->period_timer, | 
					
						
							|  |  |  | 		  jiffies + msecs_to_jiffies(btcoex->btcoex_period)); | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * Generic tsf based hw timer which configures weight | 
					
						
							|  |  |  |  * registers to time slice between wlan and bt traffic | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | static void ath_btcoex_no_stomp_timer(void *arg) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct ath_softc *sc = (struct ath_softc *)arg; | 
					
						
							|  |  |  | 	struct ath_hw *ah = sc->sc_ah; | 
					
						
							|  |  |  | 	struct ath_btcoex *btcoex = &sc->btcoex; | 
					
						
							| 
									
										
										
										
											2010-08-18 19:57:48 +05:30
										 |  |  | 	struct ath_common *common = ath9k_hw_common(ah); | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-15 14:55:53 -08:00
										 |  |  | 	ath_dbg(common, BTCOEX, "no stomp timer running\n"); | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-04-26 10:39:55 +05:30
										 |  |  | 	ath9k_ps_wakeup(sc); | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | 	spin_lock_bh(&btcoex->btcoex_lock); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-04 16:27:58 +05:30
										 |  |  | 	if (btcoex->bt_stomp_type == ATH_BTCOEX_STOMP_LOW || | 
					
						
							| 
									
										
										
										
											2012-09-30 09:03:37 +05:30
										 |  |  | 	    (!(ah->caps.hw_caps & ATH9K_HW_CAP_MCI) && | 
					
						
							|  |  |  | 	     test_bit(BT_OP_SCAN, &btcoex->op_flags))) | 
					
						
							| 
									
										
										
										
											2011-04-26 10:39:52 +05:30
										 |  |  | 		ath9k_hw_btcoex_bt_stomp(ah, ATH_BTCOEX_STOMP_NONE); | 
					
						
							| 
									
										
										
										
											2012-11-20 18:30:01 +05:30
										 |  |  | 	else if (btcoex->bt_stomp_type == ATH_BTCOEX_STOMP_ALL) | 
					
						
							| 
									
										
										
										
											2011-04-26 10:39:52 +05:30
										 |  |  | 		ath9k_hw_btcoex_bt_stomp(ah, ATH_BTCOEX_STOMP_LOW); | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-12 19:35:46 +05:30
										 |  |  | 	ath9k_hw_btcoex_enable(ah); | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | 	spin_unlock_bh(&btcoex->btcoex_lock); | 
					
						
							| 
									
										
										
										
											2011-04-26 10:39:55 +05:30
										 |  |  | 	ath9k_ps_restore(sc); | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-22 12:40:27 +05:30
										 |  |  | static int ath_init_btcoex_timer(struct ath_softc *sc) | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | { | 
					
						
							|  |  |  | 	struct ath_btcoex *btcoex = &sc->btcoex; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-11 12:19:37 +05:30
										 |  |  | 	btcoex->btcoex_period = ATH_BTCOEX_DEF_BT_PERIOD; | 
					
						
							|  |  |  | 	btcoex->btcoex_no_stomp = (100 - ATH_BTCOEX_DEF_DUTY_CYCLE) * 1000 * | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | 		btcoex->btcoex_period / 100; | 
					
						
							| 
									
										
										
										
											2012-06-11 12:19:37 +05:30
										 |  |  | 	btcoex->btscan_no_stomp = (100 - ATH_BTCOEX_BTSCAN_DUTY_CYCLE) * 1000 * | 
					
						
							| 
									
										
										
										
											2010-01-21 11:17:27 +05:30
										 |  |  | 				   btcoex->btcoex_period / 100; | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | 	setup_timer(&btcoex->period_timer, ath_btcoex_period_timer, | 
					
						
							|  |  |  | 			(unsigned long) sc); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	spin_lock_init(&btcoex->btcoex_lock); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	btcoex->no_stomp_timer = ath_gen_timer_alloc(sc->sc_ah, | 
					
						
							|  |  |  | 			ath_btcoex_no_stomp_timer, | 
					
						
							|  |  |  | 			ath_btcoex_no_stomp_timer, | 
					
						
							|  |  |  | 			(void *) sc, AR_FIRST_NDP_TIMER); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!btcoex->no_stomp_timer) | 
					
						
							|  |  |  | 		return -ENOMEM; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * (Re)start btcoex timers | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | void ath9k_btcoex_timer_resume(struct ath_softc *sc) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct ath_btcoex *btcoex = &sc->btcoex; | 
					
						
							|  |  |  | 	struct ath_hw *ah = sc->sc_ah; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-15 14:55:53 -08:00
										 |  |  | 	ath_dbg(ath9k_hw_common(ah), BTCOEX, "Starting btcoex timers\n"); | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* make sure duty cycle timer is also stopped when resuming */ | 
					
						
							| 
									
										
										
										
											2012-09-14 18:43:58 +05:30
										 |  |  | 	if (btcoex->hw_timer_enabled) { | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | 		ath9k_gen_timer_stop(sc->sc_ah, btcoex->no_stomp_timer); | 
					
						
							| 
									
										
										
										
											2012-09-14 18:43:58 +05:30
										 |  |  | 		btcoex->hw_timer_enabled = false; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | 	btcoex->bt_priority_cnt = 0; | 
					
						
							|  |  |  | 	btcoex->bt_priority_time = jiffies; | 
					
						
							| 
									
										
										
										
											2012-06-29 10:34:39 +05:30
										 |  |  | 	clear_bit(BT_OP_PRIORITY_DETECTED, &btcoex->op_flags); | 
					
						
							|  |  |  | 	clear_bit(BT_OP_SCAN, &btcoex->op_flags); | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | 	mod_timer(&btcoex->period_timer, jiffies); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * Pause btcoex timer and bt duty cycle timer | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | void ath9k_btcoex_timer_pause(struct ath_softc *sc) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct ath_btcoex *btcoex = &sc->btcoex; | 
					
						
							|  |  |  | 	struct ath_hw *ah = sc->sc_ah; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	del_timer_sync(&btcoex->period_timer); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-14 18:43:58 +05:30
										 |  |  | 	if (btcoex->hw_timer_enabled) { | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | 		ath9k_gen_timer_stop(ah, btcoex->no_stomp_timer); | 
					
						
							| 
									
										
										
										
											2012-09-14 18:43:58 +05:30
										 |  |  | 		btcoex->hw_timer_enabled = false; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2010-01-08 10:36:00 +05:30
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2012-02-22 12:40:21 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-07-01 19:53:54 +05:30
										 |  |  | void ath9k_btcoex_stop_gen_timer(struct ath_softc *sc) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct ath_btcoex *btcoex = &sc->btcoex; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-14 18:43:58 +05:30
										 |  |  | 	if (btcoex->hw_timer_enabled) { | 
					
						
							| 
									
										
										
										
											2012-08-28 12:14:48 +05:30
										 |  |  | 		ath9k_gen_timer_stop(sc->sc_ah, btcoex->no_stomp_timer); | 
					
						
							| 
									
										
										
										
											2012-09-14 18:43:58 +05:30
										 |  |  | 		btcoex->hw_timer_enabled = false; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-07-01 19:53:54 +05:30
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-22 12:40:38 +05:30
										 |  |  | u16 ath9k_btcoex_aggr_limit(struct ath_softc *sc, u32 max_4ms_framelen) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-06-04 16:27:58 +05:30
										 |  |  | 	struct ath_btcoex *btcoex = &sc->btcoex; | 
					
						
							| 
									
										
										
										
											2012-02-22 12:40:38 +05:30
										 |  |  | 	struct ath_mci_profile *mci = &sc->btcoex.mci; | 
					
						
							|  |  |  | 	u16 aggr_limit = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_MCI) && mci->aggr_limit) | 
					
						
							|  |  |  | 		aggr_limit = (max_4ms_framelen * mci->aggr_limit) >> 4; | 
					
						
							| 
									
										
										
										
											2012-06-04 16:27:58 +05:30
										 |  |  | 	else if (test_bit(BT_OP_PRIORITY_DETECTED, &btcoex->op_flags)) | 
					
						
							| 
									
										
										
										
											2012-02-22 12:40:38 +05:30
										 |  |  | 		aggr_limit = min((max_4ms_framelen * 3) / 8, | 
					
						
							|  |  |  | 				 (u32)ATH_AMPDU_LIMIT_MAX); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return aggr_limit; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-22 12:40:32 +05:30
										 |  |  | void ath9k_btcoex_handle_interrupt(struct ath_softc *sc, u32 status) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct ath_hw *ah = sc->sc_ah; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_3WIRE) | 
					
						
							|  |  |  | 		if (status & ATH9K_INT_GENTIMER) | 
					
						
							|  |  |  | 			ath_gen_timer_isr(sc->sc_ah); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-22 12:41:59 +05:30
										 |  |  | 	if (status & ATH9K_INT_MCI) | 
					
						
							| 
									
										
										
										
											2012-02-22 12:40:32 +05:30
										 |  |  | 		ath_mci_intr(sc); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-22 12:40:27 +05:30
										 |  |  | void ath9k_start_btcoex(struct ath_softc *sc) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct ath_hw *ah = sc->sc_ah; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if ((ath9k_hw_get_btcoex_scheme(ah) != ATH_BTCOEX_CFG_NONE) && | 
					
						
							|  |  |  | 	    !ah->btcoex_hw.enabled) { | 
					
						
							|  |  |  | 		if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_MCI)) | 
					
						
							|  |  |  | 			ath9k_hw_btcoex_set_weight(ah, AR_BT_COEX_WGHT, | 
					
						
							| 
									
										
										
										
											2012-09-28 11:13:51 +05:30
										 |  |  | 						   AR_STOMP_LOW_WLAN_WGHT, 0); | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 			ath9k_hw_btcoex_set_weight(ah, 0, 0, | 
					
						
							|  |  |  | 						   ATH_BTCOEX_STOMP_NONE); | 
					
						
							| 
									
										
										
										
											2012-02-22 12:40:27 +05:30
										 |  |  | 		ath9k_hw_btcoex_enable(ah); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_3WIRE) | 
					
						
							|  |  |  | 			ath9k_btcoex_timer_resume(sc); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ath9k_stop_btcoex(struct ath_softc *sc) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct ath_hw *ah = sc->sc_ah; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (ah->btcoex_hw.enabled && | 
					
						
							|  |  |  | 	    ath9k_hw_get_btcoex_scheme(ah) != ATH_BTCOEX_CFG_NONE) { | 
					
						
							|  |  |  | 		if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_3WIRE) | 
					
						
							|  |  |  | 			ath9k_btcoex_timer_pause(sc); | 
					
						
							| 
									
										
										
										
											2012-07-06 20:09:32 +05:30
										 |  |  | 		ath9k_hw_btcoex_disable(ah); | 
					
						
							| 
									
										
										
										
											2012-09-26 17:04:26 +05:30
										 |  |  | 		if (AR_SREV_9462(ah) || AR_SREV_9565(ah)) | 
					
						
							| 
									
										
										
										
											2012-03-12 07:51:07 +05:30
										 |  |  | 			ath_mci_flush_profile(&sc->btcoex.mci); | 
					
						
							| 
									
										
										
										
											2012-02-22 12:40:27 +05:30
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-22 12:40:21 +05:30
										 |  |  | void ath9k_deinit_btcoex(struct ath_softc *sc) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-07-06 20:09:16 +05:30
										 |  |  | 	struct ath_hw *ah = sc->sc_ah; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-22 12:40:21 +05:30
										 |  |  |         if ((sc->btcoex.no_stomp_timer) && | 
					
						
							|  |  |  | 	    ath9k_hw_get_btcoex_scheme(sc->sc_ah) == ATH_BTCOEX_CFG_3WIRE) | 
					
						
							|  |  |  | 		ath_gen_timer_free(sc->sc_ah, sc->btcoex.no_stomp_timer); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-07-06 20:09:16 +05:30
										 |  |  | 	if (ath9k_hw_mci_is_enabled(ah)) | 
					
						
							| 
									
										
										
										
											2012-02-22 12:40:21 +05:30
										 |  |  | 		ath_mci_cleanup(sc); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int ath9k_init_btcoex(struct ath_softc *sc) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct ath_txq *txq; | 
					
						
							|  |  |  | 	struct ath_hw *ah = sc->sc_ah; | 
					
						
							|  |  |  | 	int r; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-22 12:40:49 +05:30
										 |  |  | 	ath9k_hw_btcoex_init_scheme(ah); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-22 12:40:21 +05:30
										 |  |  | 	switch (ath9k_hw_get_btcoex_scheme(sc->sc_ah)) { | 
					
						
							|  |  |  | 	case ATH_BTCOEX_CFG_NONE: | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ATH_BTCOEX_CFG_2WIRE: | 
					
						
							|  |  |  | 		ath9k_hw_btcoex_init_2wire(sc->sc_ah); | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ATH_BTCOEX_CFG_3WIRE: | 
					
						
							|  |  |  | 		ath9k_hw_btcoex_init_3wire(sc->sc_ah); | 
					
						
							|  |  |  | 		r = ath_init_btcoex_timer(sc); | 
					
						
							|  |  |  | 		if (r) | 
					
						
							|  |  |  | 			return -1; | 
					
						
							| 
									
										
										
										
											2012-11-21 18:13:10 +05:30
										 |  |  | 		txq = sc->tx.txq_map[IEEE80211_AC_BE]; | 
					
						
							| 
									
										
										
										
											2012-02-22 12:40:21 +05:30
										 |  |  | 		ath9k_hw_init_btcoex_hw(sc->sc_ah, txq->axq_qnum); | 
					
						
							|  |  |  | 		sc->btcoex.bt_stomp_type = ATH_BTCOEX_STOMP_LOW; | 
					
						
							| 
									
										
										
										
											2012-06-27 20:00:26 +05:30
										 |  |  | 		if (ath9k_hw_mci_is_enabled(ah)) { | 
					
						
							| 
									
										
										
										
											2012-04-19 19:13:52 +05:30
										 |  |  | 			sc->btcoex.duty_cycle = ATH_BTCOEX_DEF_DUTY_CYCLE; | 
					
						
							|  |  |  | 			INIT_LIST_HEAD(&sc->btcoex.mci.info); | 
					
						
							| 
									
										
										
										
											2012-02-22 12:40:21 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-19 19:13:52 +05:30
										 |  |  | 			r = ath_mci_setup(sc); | 
					
						
							|  |  |  | 			if (r) | 
					
						
							|  |  |  | 				return r; | 
					
						
							| 
									
										
										
										
											2012-02-22 12:40:21 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-19 19:13:52 +05:30
										 |  |  | 			ath9k_hw_btcoex_init_mci(ah); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2012-02-22 12:40:21 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 		WARN_ON(1); | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2012-02-22 12:40:44 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-19 14:24:46 +05:30
										 |  |  | static int ath9k_dump_mci_btcoex(struct ath_softc *sc, u8 *buf, u32 size) | 
					
						
							| 
									
										
										
										
											2012-10-25 17:16:54 +05:30
										 |  |  | { | 
					
						
							|  |  |  | 	struct ath_btcoex *btcoex = &sc->btcoex; | 
					
						
							|  |  |  | 	struct ath_mci_profile *mci = &btcoex->mci; | 
					
						
							|  |  |  | 	struct ath_hw *ah = sc->sc_ah; | 
					
						
							|  |  |  | 	struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw; | 
					
						
							| 
									
										
										
										
											2012-11-19 14:24:46 +05:30
										 |  |  | 	u32 len = 0; | 
					
						
							| 
									
										
										
										
											2012-10-25 17:16:54 +05:30
										 |  |  | 	int i; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ATH_DUMP_BTCOEX("Total BT profiles", NUM_PROF(mci)); | 
					
						
							| 
									
										
										
										
											2012-11-19 14:24:46 +05:30
										 |  |  | 	ATH_DUMP_BTCOEX("MGMT", mci->num_mgmt); | 
					
						
							|  |  |  | 	ATH_DUMP_BTCOEX("SCO", mci->num_sco); | 
					
						
							|  |  |  | 	ATH_DUMP_BTCOEX("A2DP", mci->num_a2dp); | 
					
						
							|  |  |  | 	ATH_DUMP_BTCOEX("HID", mci->num_hid); | 
					
						
							|  |  |  | 	ATH_DUMP_BTCOEX("PAN", mci->num_pan); | 
					
						
							|  |  |  | 	ATH_DUMP_BTCOEX("ACL", mci->num_other_acl); | 
					
						
							|  |  |  | 	ATH_DUMP_BTCOEX("BDR", mci->num_bdr); | 
					
						
							| 
									
										
										
										
											2012-10-25 17:16:54 +05:30
										 |  |  | 	ATH_DUMP_BTCOEX("Aggr. Limit", mci->aggr_limit); | 
					
						
							|  |  |  | 	ATH_DUMP_BTCOEX("Stomp Type", btcoex->bt_stomp_type); | 
					
						
							|  |  |  | 	ATH_DUMP_BTCOEX("BTCoex Period (msec)", btcoex->btcoex_period); | 
					
						
							|  |  |  | 	ATH_DUMP_BTCOEX("Duty Cycle", btcoex->duty_cycle); | 
					
						
							|  |  |  | 	ATH_DUMP_BTCOEX("BT Wait time", btcoex->bt_wait_time); | 
					
						
							|  |  |  | 	ATH_DUMP_BTCOEX("Concurrent Tx", btcoex_hw->mci.concur_tx); | 
					
						
							| 
									
										
										
										
											2012-11-19 14:24:46 +05:30
										 |  |  | 	ATH_DUMP_BTCOEX("Concurrent RSSI cnt", btcoex->rssi_count); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-05 14:11:57 +02:00
										 |  |  | 	len += scnprintf(buf + len, size - len, "BT Weights: "); | 
					
						
							| 
									
										
										
										
											2012-10-25 17:16:54 +05:30
										 |  |  | 	for (i = 0; i < AR9300_NUM_BT_WEIGHTS; i++) | 
					
						
							| 
									
										
										
										
											2013-09-05 14:11:57 +02:00
										 |  |  | 		len += scnprintf(buf + len, size - len, "%08x ", | 
					
						
							|  |  |  | 				 btcoex_hw->bt_weight[i]); | 
					
						
							|  |  |  | 	len += scnprintf(buf + len, size - len, "\n"); | 
					
						
							|  |  |  | 	len += scnprintf(buf + len, size - len, "WLAN Weights: "); | 
					
						
							| 
									
										
										
										
											2012-10-25 17:16:54 +05:30
										 |  |  | 	for (i = 0; i < AR9300_NUM_BT_WEIGHTS; i++) | 
					
						
							| 
									
										
										
										
											2013-09-05 14:11:57 +02:00
										 |  |  | 		len += scnprintf(buf + len, size - len, "%08x ", | 
					
						
							|  |  |  | 				 btcoex_hw->wlan_weight[i]); | 
					
						
							|  |  |  | 	len += scnprintf(buf + len, size - len, "\n"); | 
					
						
							|  |  |  | 	len += scnprintf(buf + len, size - len, "Tx Priorities: "); | 
					
						
							| 
									
										
										
										
											2012-10-25 17:16:54 +05:30
										 |  |  | 	for (i = 0; i < ATH_BTCOEX_STOMP_MAX; i++) | 
					
						
							| 
									
										
										
										
											2013-09-05 14:11:57 +02:00
										 |  |  | 		len += scnprintf(buf + len, size - len, "%08x ", | 
					
						
							| 
									
										
										
										
											2012-10-25 17:16:54 +05:30
										 |  |  | 				btcoex_hw->tx_prio[i]); | 
					
						
							| 
									
										
										
										
											2012-11-19 14:24:46 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-05 14:11:57 +02:00
										 |  |  | 	len += scnprintf(buf + len, size - len, "\n"); | 
					
						
							| 
									
										
										
										
											2012-10-25 17:16:54 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | 	return len; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2012-11-19 14:24:46 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | static int ath9k_dump_legacy_btcoex(struct ath_softc *sc, u8 *buf, u32 size) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	struct ath_btcoex *btcoex = &sc->btcoex; | 
					
						
							|  |  |  | 	u32 len = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ATH_DUMP_BTCOEX("Stomp Type", btcoex->bt_stomp_type); | 
					
						
							|  |  |  | 	ATH_DUMP_BTCOEX("BTCoex Period (msec)", btcoex->btcoex_period); | 
					
						
							|  |  |  | 	ATH_DUMP_BTCOEX("Duty Cycle", btcoex->duty_cycle); | 
					
						
							|  |  |  | 	ATH_DUMP_BTCOEX("BT Wait time", btcoex->bt_wait_time); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return len; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int ath9k_dump_btcoex(struct ath_softc *sc, u8 *buf, u32 size) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (ath9k_hw_mci_is_enabled(sc->sc_ah)) | 
					
						
							|  |  |  | 		return ath9k_dump_mci_btcoex(sc, buf, size); | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		return ath9k_dump_legacy_btcoex(sc, buf, size); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-22 12:40:44 +05:30
										 |  |  | #endif /* CONFIG_ATH9K_BTCOEX_SUPPORT */
 |