gpio.c revision 7b27ba4e9c8053ca73e2b21ece804f7e80c07ba3
10fca65c1c0569d6a143e978b6f4974c519033e63Sujith/*
25b68138e5659cbfd5df2879d17f9ba0b66477fecSujith Manoharan * Copyright (c) 2008-2011 Atheros Communications Inc.
30fca65c1c0569d6a143e978b6f4974c519033e63Sujith *
40fca65c1c0569d6a143e978b6f4974c519033e63Sujith * Permission to use, copy, modify, and/or distribute this software for any
50fca65c1c0569d6a143e978b6f4974c519033e63Sujith * purpose with or without fee is hereby granted, provided that the above
60fca65c1c0569d6a143e978b6f4974c519033e63Sujith * copyright notice and this permission notice appear in all copies.
70fca65c1c0569d6a143e978b6f4974c519033e63Sujith *
80fca65c1c0569d6a143e978b6f4974c519033e63Sujith * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
90fca65c1c0569d6a143e978b6f4974c519033e63Sujith * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
100fca65c1c0569d6a143e978b6f4974c519033e63Sujith * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
110fca65c1c0569d6a143e978b6f4974c519033e63Sujith * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
120fca65c1c0569d6a143e978b6f4974c519033e63Sujith * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
130fca65c1c0569d6a143e978b6f4974c519033e63Sujith * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
140fca65c1c0569d6a143e978b6f4974c519033e63Sujith * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
150fca65c1c0569d6a143e978b6f4974c519033e63Sujith */
160fca65c1c0569d6a143e978b6f4974c519033e63Sujith
170fca65c1c0569d6a143e978b6f4974c519033e63Sujith#include "ath9k.h"
180fca65c1c0569d6a143e978b6f4974c519033e63Sujith
190fca65c1c0569d6a143e978b6f4974c519033e63Sujith/********************************/
200fca65c1c0569d6a143e978b6f4974c519033e63Sujith/*	 LED functions		*/
210fca65c1c0569d6a143e978b6f4974c519033e63Sujith/********************************/
220fca65c1c0569d6a143e978b6f4974c519033e63Sujith
230cf55c21ec401632043db2b8acb7cd3bef64c9e6Felix Fietkau#ifdef CONFIG_MAC80211_LEDS
240fca65c1c0569d6a143e978b6f4974c519033e63Sujithstatic void ath_led_brightness(struct led_classdev *led_cdev,
250fca65c1c0569d6a143e978b6f4974c519033e63Sujith			       enum led_brightness brightness)
260fca65c1c0569d6a143e978b6f4974c519033e63Sujith{
270cf55c21ec401632043db2b8acb7cd3bef64c9e6Felix Fietkau	struct ath_softc *sc = container_of(led_cdev, struct ath_softc, led_cdev);
280cf55c21ec401632043db2b8acb7cd3bef64c9e6Felix Fietkau	ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, (brightness == LED_OFF));
290fca65c1c0569d6a143e978b6f4974c519033e63Sujith}
300fca65c1c0569d6a143e978b6f4974c519033e63Sujith
310fca65c1c0569d6a143e978b6f4974c519033e63Sujithvoid ath_deinit_leds(struct ath_softc *sc)
320fca65c1c0569d6a143e978b6f4974c519033e63Sujith{
330cf55c21ec401632043db2b8acb7cd3bef64c9e6Felix Fietkau	if (!sc->led_registered)
340cf55c21ec401632043db2b8acb7cd3bef64c9e6Felix Fietkau		return;
350cf55c21ec401632043db2b8acb7cd3bef64c9e6Felix Fietkau
360cf55c21ec401632043db2b8acb7cd3bef64c9e6Felix Fietkau	ath_led_brightness(&sc->led_cdev, LED_OFF);
370cf55c21ec401632043db2b8acb7cd3bef64c9e6Felix Fietkau	led_classdev_unregister(&sc->led_cdev);
380fca65c1c0569d6a143e978b6f4974c519033e63Sujith}
390fca65c1c0569d6a143e978b6f4974c519033e63Sujith
400fca65c1c0569d6a143e978b6f4974c519033e63Sujithvoid ath_init_leds(struct ath_softc *sc)
410fca65c1c0569d6a143e978b6f4974c519033e63Sujith{
420fca65c1c0569d6a143e978b6f4974c519033e63Sujith	int ret;
430fca65c1c0569d6a143e978b6f4974c519033e63Sujith
447b27ba4e9c8053ca73e2b21ece804f7e80c07ba3Felix Fietkau	if (AR_SREV_9100(sc->sc_ah))
457b27ba4e9c8053ca73e2b21ece804f7e80c07ba3Felix Fietkau		return;
467b27ba4e9c8053ca73e2b21ece804f7e80c07ba3Felix Fietkau
476de66dd963ddd669667a81a2401f2fd6472ff55cFelix Fietkau	if (sc->sc_ah->led_pin < 0) {
486de66dd963ddd669667a81a2401f2fd6472ff55cFelix Fietkau		if (AR_SREV_9287(sc->sc_ah))
496de66dd963ddd669667a81a2401f2fd6472ff55cFelix Fietkau			sc->sc_ah->led_pin = ATH_LED_PIN_9287;
506de66dd963ddd669667a81a2401f2fd6472ff55cFelix Fietkau		else if (AR_SREV_9485(sc->sc_ah))
516de66dd963ddd669667a81a2401f2fd6472ff55cFelix Fietkau			sc->sc_ah->led_pin = ATH_LED_PIN_9485;
52353e5019e048562dc8f434c6237d41ef5e758922Senthil Balasubramanian		else if (AR_SREV_9300(sc->sc_ah))
53353e5019e048562dc8f434c6237d41ef5e758922Senthil Balasubramanian			sc->sc_ah->led_pin = ATH_LED_PIN_9300;
54423e38e8079f8f4fe0bf66d4f9a7d61beb232acaRajkumar Manoharan		else if (AR_SREV_9462(sc->sc_ah))
55423e38e8079f8f4fe0bf66d4f9a7d61beb232acaRajkumar Manoharan			sc->sc_ah->led_pin = ATH_LED_PIN_9462;
566de66dd963ddd669667a81a2401f2fd6472ff55cFelix Fietkau		else
576de66dd963ddd669667a81a2401f2fd6472ff55cFelix Fietkau			sc->sc_ah->led_pin = ATH_LED_PIN_DEF;
586de66dd963ddd669667a81a2401f2fd6472ff55cFelix Fietkau	}
590fca65c1c0569d6a143e978b6f4974c519033e63Sujith
600fca65c1c0569d6a143e978b6f4974c519033e63Sujith	/* Configure gpio 1 for output */
610fca65c1c0569d6a143e978b6f4974c519033e63Sujith	ath9k_hw_cfg_output(sc->sc_ah, sc->sc_ah->led_pin,
620fca65c1c0569d6a143e978b6f4974c519033e63Sujith			    AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
630fca65c1c0569d6a143e978b6f4974c519033e63Sujith	/* LED off, active low */
640fca65c1c0569d6a143e978b6f4974c519033e63Sujith	ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 1);
650fca65c1c0569d6a143e978b6f4974c519033e63Sujith
660cf55c21ec401632043db2b8acb7cd3bef64c9e6Felix Fietkau	if (!led_blink)
670cf55c21ec401632043db2b8acb7cd3bef64c9e6Felix Fietkau		sc->led_cdev.default_trigger =
680cf55c21ec401632043db2b8acb7cd3bef64c9e6Felix Fietkau			ieee80211_get_radio_led_name(sc->hw);
690cf55c21ec401632043db2b8acb7cd3bef64c9e6Felix Fietkau
700cf55c21ec401632043db2b8acb7cd3bef64c9e6Felix Fietkau	snprintf(sc->led_name, sizeof(sc->led_name),
710cf55c21ec401632043db2b8acb7cd3bef64c9e6Felix Fietkau		"ath9k-%s", wiphy_name(sc->hw->wiphy));
720cf55c21ec401632043db2b8acb7cd3bef64c9e6Felix Fietkau	sc->led_cdev.name = sc->led_name;
730cf55c21ec401632043db2b8acb7cd3bef64c9e6Felix Fietkau	sc->led_cdev.brightness_set = ath_led_brightness;
740cf55c21ec401632043db2b8acb7cd3bef64c9e6Felix Fietkau
750cf55c21ec401632043db2b8acb7cd3bef64c9e6Felix Fietkau	ret = led_classdev_register(wiphy_dev(sc->hw->wiphy), &sc->led_cdev);
760cf55c21ec401632043db2b8acb7cd3bef64c9e6Felix Fietkau	if (ret < 0)
770cf55c21ec401632043db2b8acb7cd3bef64c9e6Felix Fietkau		return;
780cf55c21ec401632043db2b8acb7cd3bef64c9e6Felix Fietkau
790cf55c21ec401632043db2b8acb7cd3bef64c9e6Felix Fietkau	sc->led_registered = true;
800fca65c1c0569d6a143e978b6f4974c519033e63Sujith}
810cf55c21ec401632043db2b8acb7cd3bef64c9e6Felix Fietkau#endif
820fca65c1c0569d6a143e978b6f4974c519033e63Sujith
830fca65c1c0569d6a143e978b6f4974c519033e63Sujith/*******************/
840fca65c1c0569d6a143e978b6f4974c519033e63Sujith/*	Rfkill	   */
850fca65c1c0569d6a143e978b6f4974c519033e63Sujith/*******************/
860fca65c1c0569d6a143e978b6f4974c519033e63Sujith
870fca65c1c0569d6a143e978b6f4974c519033e63Sujithstatic bool ath_is_rfkill_set(struct ath_softc *sc)
880fca65c1c0569d6a143e978b6f4974c519033e63Sujith{
890fca65c1c0569d6a143e978b6f4974c519033e63Sujith	struct ath_hw *ah = sc->sc_ah;
9090826313fd69d198da7574779460f793765abfa5Mohammed Shafi Shajakhan	bool is_blocked;
910fca65c1c0569d6a143e978b6f4974c519033e63Sujith
9290826313fd69d198da7574779460f793765abfa5Mohammed Shafi Shajakhan	ath9k_ps_wakeup(sc);
9390826313fd69d198da7574779460f793765abfa5Mohammed Shafi Shajakhan	is_blocked = ath9k_hw_gpio_get(ah, ah->rfkill_gpio) ==
940fca65c1c0569d6a143e978b6f4974c519033e63Sujith				  ah->rfkill_polarity;
9590826313fd69d198da7574779460f793765abfa5Mohammed Shafi Shajakhan	ath9k_ps_restore(sc);
9690826313fd69d198da7574779460f793765abfa5Mohammed Shafi Shajakhan
9790826313fd69d198da7574779460f793765abfa5Mohammed Shafi Shajakhan	return is_blocked;
980fca65c1c0569d6a143e978b6f4974c519033e63Sujith}
990fca65c1c0569d6a143e978b6f4974c519033e63Sujith
1000fca65c1c0569d6a143e978b6f4974c519033e63Sujithvoid ath9k_rfkill_poll_state(struct ieee80211_hw *hw)
1010fca65c1c0569d6a143e978b6f4974c519033e63Sujith{
1029ac58615d93c8a28b1c649a90a5e2ede4dfd368aFelix Fietkau	struct ath_softc *sc = hw->priv;
1030fca65c1c0569d6a143e978b6f4974c519033e63Sujith	bool blocked = !!ath_is_rfkill_set(sc);
1040fca65c1c0569d6a143e978b6f4974c519033e63Sujith
1050fca65c1c0569d6a143e978b6f4974c519033e63Sujith	wiphy_rfkill_set_hw_state(hw->wiphy, blocked);
1060fca65c1c0569d6a143e978b6f4974c519033e63Sujith}
1070fca65c1c0569d6a143e978b6f4974c519033e63Sujith
1080fca65c1c0569d6a143e978b6f4974c519033e63Sujithvoid ath_start_rfkill_poll(struct ath_softc *sc)
1090fca65c1c0569d6a143e978b6f4974c519033e63Sujith{
1100fca65c1c0569d6a143e978b6f4974c519033e63Sujith	struct ath_hw *ah = sc->sc_ah;
1110fca65c1c0569d6a143e978b6f4974c519033e63Sujith
1120fca65c1c0569d6a143e978b6f4974c519033e63Sujith	if (ah->caps.hw_caps & ATH9K_HW_CAP_RFSILENT)
1130fca65c1c0569d6a143e978b6f4974c519033e63Sujith		wiphy_rfkill_start_polling(sc->hw->wiphy);
1140fca65c1c0569d6a143e978b6f4974c519033e63Sujith}
1150fca65c1c0569d6a143e978b6f4974c519033e63Sujith
1164daa7760e2da9324e740f7d872970fa91c8ea6f0Sujith Manoharan#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
1174daa7760e2da9324e740f7d872970fa91c8ea6f0Sujith Manoharan
1180fca65c1c0569d6a143e978b6f4974c519033e63Sujith/******************/
1190fca65c1c0569d6a143e978b6f4974c519033e63Sujith/*     BTCOEX     */
1200fca65c1c0569d6a143e978b6f4974c519033e63Sujith/******************/
1210fca65c1c0569d6a143e978b6f4974c519033e63Sujith
1220fca65c1c0569d6a143e978b6f4974c519033e63Sujith/*
1230fca65c1c0569d6a143e978b6f4974c519033e63Sujith * Detects if there is any priority bt traffic
1240fca65c1c0569d6a143e978b6f4974c519033e63Sujith */
1250fca65c1c0569d6a143e978b6f4974c519033e63Sujithstatic void ath_detect_bt_priority(struct ath_softc *sc)
1260fca65c1c0569d6a143e978b6f4974c519033e63Sujith{
1270fca65c1c0569d6a143e978b6f4974c519033e63Sujith	struct ath_btcoex *btcoex = &sc->btcoex;
1280fca65c1c0569d6a143e978b6f4974c519033e63Sujith	struct ath_hw *ah = sc->sc_ah;
1290fca65c1c0569d6a143e978b6f4974c519033e63Sujith
1300fca65c1c0569d6a143e978b6f4974c519033e63Sujith	if (ath9k_hw_gpio_get(sc->sc_ah, ah->btcoex_hw.btpriority_gpio))
1310fca65c1c0569d6a143e978b6f4974c519033e63Sujith		btcoex->bt_priority_cnt++;
1320fca65c1c0569d6a143e978b6f4974c519033e63Sujith
1330fca65c1c0569d6a143e978b6f4974c519033e63Sujith	if (time_after(jiffies, btcoex->bt_priority_time +
1340fca65c1c0569d6a143e978b6f4974c519033e63Sujith			msecs_to_jiffies(ATH_BT_PRIORITY_TIME_THRESHOLD))) {
13558da1318ee92ad3fe7917278d596768bbe441850Vasanthakumar Thiagarajan		sc->sc_flags &= ~(SC_OP_BT_PRIORITY_DETECTED | SC_OP_BT_SCAN);
13658da1318ee92ad3fe7917278d596768bbe441850Vasanthakumar Thiagarajan		/* Detect if colocated bt started scanning */
13758da1318ee92ad3fe7917278d596768bbe441850Vasanthakumar Thiagarajan		if (btcoex->bt_priority_cnt >= ATH_BT_CNT_SCAN_THRESHOLD) {
138d2182b69dcb6a68b1ef6070b2efd094e13dea3f1Joe Perches			ath_dbg(ath9k_hw_common(sc->sc_ah), BTCOEX,
139226afe68fdbd1aa3680158aca0a3631cbd019626Joe Perches				"BT scan detected\n");
14058da1318ee92ad3fe7917278d596768bbe441850Vasanthakumar Thiagarajan			sc->sc_flags |= (SC_OP_BT_SCAN |
14158da1318ee92ad3fe7917278d596768bbe441850Vasanthakumar Thiagarajan					 SC_OP_BT_PRIORITY_DETECTED);
14258da1318ee92ad3fe7917278d596768bbe441850Vasanthakumar Thiagarajan		} else if (btcoex->bt_priority_cnt >= ATH_BT_CNT_THRESHOLD) {
143d2182b69dcb6a68b1ef6070b2efd094e13dea3f1Joe Perches			ath_dbg(ath9k_hw_common(sc->sc_ah), BTCOEX,
144226afe68fdbd1aa3680158aca0a3631cbd019626Joe Perches				"BT priority traffic detected\n");
1450fca65c1c0569d6a143e978b6f4974c519033e63Sujith			sc->sc_flags |= SC_OP_BT_PRIORITY_DETECTED;
1460fca65c1c0569d6a143e978b6f4974c519033e63Sujith		}
1470fca65c1c0569d6a143e978b6f4974c519033e63Sujith
1480fca65c1c0569d6a143e978b6f4974c519033e63Sujith		btcoex->bt_priority_cnt = 0;
1490fca65c1c0569d6a143e978b6f4974c519033e63Sujith		btcoex->bt_priority_time = jiffies;
1500fca65c1c0569d6a143e978b6f4974c519033e63Sujith	}
1510fca65c1c0569d6a143e978b6f4974c519033e63Sujith}
1520fca65c1c0569d6a143e978b6f4974c519033e63Sujith
1530fca65c1c0569d6a143e978b6f4974c519033e63Sujithstatic void ath9k_gen_timer_start(struct ath_hw *ah,
1540fca65c1c0569d6a143e978b6f4974c519033e63Sujith				  struct ath_gen_timer *timer,
155788f6875fcf5d2bce221fbfd2318ac48df299031Vasanthakumar Thiagarajan				  u32 trig_timeout,
1560fca65c1c0569d6a143e978b6f4974c519033e63Sujith				  u32 timer_period)
1570fca65c1c0569d6a143e978b6f4974c519033e63Sujith{
158788f6875fcf5d2bce221fbfd2318ac48df299031Vasanthakumar Thiagarajan	ath9k_hw_gen_timer_start(ah, timer, trig_timeout, timer_period);
1590fca65c1c0569d6a143e978b6f4974c519033e63Sujith
1603069168c82d65f88e4ac76eda09baff02adfd743Pavel Roskin	if ((ah->imask & ATH9K_INT_GENTIMER) == 0) {
1614df3071ebd92ef7115b409da64d0eb405d24a631Felix Fietkau		ath9k_hw_disable_interrupts(ah);
1623069168c82d65f88e4ac76eda09baff02adfd743Pavel Roskin		ah->imask |= ATH9K_INT_GENTIMER;
16372d874c67c3cdf21ca95045baabac6a5843222d8Felix Fietkau		ath9k_hw_set_interrupts(ah);
164b037b693265e5c83ddc3f003a713d19b9832bf24Rajkumar Manoharan		ath9k_hw_enable_interrupts(ah);
1650fca65c1c0569d6a143e978b6f4974c519033e63Sujith	}
1660fca65c1c0569d6a143e978b6f4974c519033e63Sujith}
1670fca65c1c0569d6a143e978b6f4974c519033e63Sujith
1680fca65c1c0569d6a143e978b6f4974c519033e63Sujithstatic void ath9k_gen_timer_stop(struct ath_hw *ah, struct ath_gen_timer *timer)
1690fca65c1c0569d6a143e978b6f4974c519033e63Sujith{
1700fca65c1c0569d6a143e978b6f4974c519033e63Sujith	struct ath_gen_timer_table *timer_table = &ah->hw_gen_timers;
1710fca65c1c0569d6a143e978b6f4974c519033e63Sujith
1720fca65c1c0569d6a143e978b6f4974c519033e63Sujith	ath9k_hw_gen_timer_stop(ah, timer);
1730fca65c1c0569d6a143e978b6f4974c519033e63Sujith
1740fca65c1c0569d6a143e978b6f4974c519033e63Sujith	/* if no timer is enabled, turn off interrupt mask */
1750fca65c1c0569d6a143e978b6f4974c519033e63Sujith	if (timer_table->timer_mask.val == 0) {
1764df3071ebd92ef7115b409da64d0eb405d24a631Felix Fietkau		ath9k_hw_disable_interrupts(ah);
1773069168c82d65f88e4ac76eda09baff02adfd743Pavel Roskin		ah->imask &= ~ATH9K_INT_GENTIMER;
17872d874c67c3cdf21ca95045baabac6a5843222d8Felix Fietkau		ath9k_hw_set_interrupts(ah);
179b037b693265e5c83ddc3f003a713d19b9832bf24Rajkumar Manoharan		ath9k_hw_enable_interrupts(ah);
1800fca65c1c0569d6a143e978b6f4974c519033e63Sujith	}
1810fca65c1c0569d6a143e978b6f4974c519033e63Sujith}
1820fca65c1c0569d6a143e978b6f4974c519033e63Sujith
1830fca65c1c0569d6a143e978b6f4974c519033e63Sujith/*
1840fca65c1c0569d6a143e978b6f4974c519033e63Sujith * This is the master bt coex timer which runs for every
1850fca65c1c0569d6a143e978b6f4974c519033e63Sujith * 45ms, bt traffic will be given priority during 55% of this
1860fca65c1c0569d6a143e978b6f4974c519033e63Sujith * period while wlan gets remaining 45%
1870fca65c1c0569d6a143e978b6f4974c519033e63Sujith */
1880fca65c1c0569d6a143e978b6f4974c519033e63Sujithstatic void ath_btcoex_period_timer(unsigned long data)
1890fca65c1c0569d6a143e978b6f4974c519033e63Sujith{
1900fca65c1c0569d6a143e978b6f4974c519033e63Sujith	struct ath_softc *sc = (struct ath_softc *) data;
1910fca65c1c0569d6a143e978b6f4974c519033e63Sujith	struct ath_hw *ah = sc->sc_ah;
1920fca65c1c0569d6a143e978b6f4974c519033e63Sujith	struct ath_btcoex *btcoex = &sc->btcoex;
19358da1318ee92ad3fe7917278d596768bbe441850Vasanthakumar Thiagarajan	u32 timer_period;
19458da1318ee92ad3fe7917278d596768bbe441850Vasanthakumar Thiagarajan	bool is_btscan;
1950fca65c1c0569d6a143e978b6f4974c519033e63Sujith
196a039a993496d79d09ae9709c82b545b9800954c9Vivek Natarajan	ath9k_ps_wakeup(sc);
1977dc181c273861c4d96991f59a4fdcda3a3eaccaeRajkumar Manoharan	if (!(ah->caps.hw_caps & ATH9K_HW_CAP_MCI))
1987dc181c273861c4d96991f59a4fdcda3a3eaccaeRajkumar Manoharan		ath_detect_bt_priority(sc);
19958da1318ee92ad3fe7917278d596768bbe441850Vasanthakumar Thiagarajan	is_btscan = sc->sc_flags & SC_OP_BT_SCAN;
20058da1318ee92ad3fe7917278d596768bbe441850Vasanthakumar Thiagarajan
2010fca65c1c0569d6a143e978b6f4974c519033e63Sujith	spin_lock_bh(&btcoex->btcoex_lock);
2020fca65c1c0569d6a143e978b6f4974c519033e63Sujith
203978f78bf71372a48785ac9407ebc10170f14f56cVivek Natarajan	ath9k_hw_btcoex_bt_stomp(ah, is_btscan ? ATH_BTCOEX_STOMP_ALL :
20458da1318ee92ad3fe7917278d596768bbe441850Vasanthakumar Thiagarajan			      btcoex->bt_stomp_type);
2050fca65c1c0569d6a143e978b6f4974c519033e63Sujith
206bc6d5c29afa724901c2feb7e4446c6eec7788cecRajkumar Manoharan	ath9k_hw_btcoex_enable(ah);
2070fca65c1c0569d6a143e978b6f4974c519033e63Sujith	spin_unlock_bh(&btcoex->btcoex_lock);
2080fca65c1c0569d6a143e978b6f4974c519033e63Sujith
2090fca65c1c0569d6a143e978b6f4974c519033e63Sujith	if (btcoex->btcoex_period != btcoex->btcoex_no_stomp) {
2100fca65c1c0569d6a143e978b6f4974c519033e63Sujith		if (btcoex->hw_timer_enabled)
2110fca65c1c0569d6a143e978b6f4974c519033e63Sujith			ath9k_gen_timer_stop(ah, btcoex->no_stomp_timer);
2120fca65c1c0569d6a143e978b6f4974c519033e63Sujith
21358da1318ee92ad3fe7917278d596768bbe441850Vasanthakumar Thiagarajan		timer_period = is_btscan ? btcoex->btscan_no_stomp :
21458da1318ee92ad3fe7917278d596768bbe441850Vasanthakumar Thiagarajan					   btcoex->btcoex_no_stomp;
215788f6875fcf5d2bce221fbfd2318ac48df299031Vasanthakumar Thiagarajan		ath9k_gen_timer_start(ah, btcoex->no_stomp_timer, timer_period,
2168eb1dabbd10e067cff671935d3e0c819f8e80d54Felix Fietkau				      timer_period * 10);
2170fca65c1c0569d6a143e978b6f4974c519033e63Sujith		btcoex->hw_timer_enabled = true;
2180fca65c1c0569d6a143e978b6f4974c519033e63Sujith	}
2190fca65c1c0569d6a143e978b6f4974c519033e63Sujith
220a039a993496d79d09ae9709c82b545b9800954c9Vivek Natarajan	ath9k_ps_restore(sc);
2217dc181c273861c4d96991f59a4fdcda3a3eaccaeRajkumar Manoharan	timer_period = btcoex->btcoex_period / 1000;
2220fca65c1c0569d6a143e978b6f4974c519033e63Sujith	mod_timer(&btcoex->period_timer, jiffies +
2237dc181c273861c4d96991f59a4fdcda3a3eaccaeRajkumar Manoharan				  msecs_to_jiffies(timer_period));
2240fca65c1c0569d6a143e978b6f4974c519033e63Sujith}
2250fca65c1c0569d6a143e978b6f4974c519033e63Sujith
2260fca65c1c0569d6a143e978b6f4974c519033e63Sujith/*
2270fca65c1c0569d6a143e978b6f4974c519033e63Sujith * Generic tsf based hw timer which configures weight
2280fca65c1c0569d6a143e978b6f4974c519033e63Sujith * registers to time slice between wlan and bt traffic
2290fca65c1c0569d6a143e978b6f4974c519033e63Sujith */
2300fca65c1c0569d6a143e978b6f4974c519033e63Sujithstatic void ath_btcoex_no_stomp_timer(void *arg)
2310fca65c1c0569d6a143e978b6f4974c519033e63Sujith{
2320fca65c1c0569d6a143e978b6f4974c519033e63Sujith	struct ath_softc *sc = (struct ath_softc *)arg;
2330fca65c1c0569d6a143e978b6f4974c519033e63Sujith	struct ath_hw *ah = sc->sc_ah;
2340fca65c1c0569d6a143e978b6f4974c519033e63Sujith	struct ath_btcoex *btcoex = &sc->btcoex;
235d99eeb87420a6da1f87064c7fa70bdf299699d90Vivek Natarajan	struct ath_common *common = ath9k_hw_common(ah);
23658da1318ee92ad3fe7917278d596768bbe441850Vasanthakumar Thiagarajan	bool is_btscan = sc->sc_flags & SC_OP_BT_SCAN;
2370fca65c1c0569d6a143e978b6f4974c519033e63Sujith
238d2182b69dcb6a68b1ef6070b2efd094e13dea3f1Joe Perches	ath_dbg(common, BTCOEX, "no stomp timer running\n");
2390fca65c1c0569d6a143e978b6f4974c519033e63Sujith
240a039a993496d79d09ae9709c82b545b9800954c9Vivek Natarajan	ath9k_ps_wakeup(sc);
2410fca65c1c0569d6a143e978b6f4974c519033e63Sujith	spin_lock_bh(&btcoex->btcoex_lock);
2420fca65c1c0569d6a143e978b6f4974c519033e63Sujith
24358da1318ee92ad3fe7917278d596768bbe441850Vasanthakumar Thiagarajan	if (btcoex->bt_stomp_type == ATH_BTCOEX_STOMP_LOW || is_btscan)
244978f78bf71372a48785ac9407ebc10170f14f56cVivek Natarajan		ath9k_hw_btcoex_bt_stomp(ah, ATH_BTCOEX_STOMP_NONE);
2450fca65c1c0569d6a143e978b6f4974c519033e63Sujith	 else if (btcoex->bt_stomp_type == ATH_BTCOEX_STOMP_ALL)
246978f78bf71372a48785ac9407ebc10170f14f56cVivek Natarajan		ath9k_hw_btcoex_bt_stomp(ah, ATH_BTCOEX_STOMP_LOW);
2470fca65c1c0569d6a143e978b6f4974c519033e63Sujith
248bc6d5c29afa724901c2feb7e4446c6eec7788cecRajkumar Manoharan	ath9k_hw_btcoex_enable(ah);
2490fca65c1c0569d6a143e978b6f4974c519033e63Sujith	spin_unlock_bh(&btcoex->btcoex_lock);
250a039a993496d79d09ae9709c82b545b9800954c9Vivek Natarajan	ath9k_ps_restore(sc);
2510fca65c1c0569d6a143e978b6f4974c519033e63Sujith}
2520fca65c1c0569d6a143e978b6f4974c519033e63Sujith
253df198b172f7a14ecf7aefaadb3761c273600333eSujith Manoharanstatic int ath_init_btcoex_timer(struct ath_softc *sc)
2540fca65c1c0569d6a143e978b6f4974c519033e63Sujith{
2550fca65c1c0569d6a143e978b6f4974c519033e63Sujith	struct ath_btcoex *btcoex = &sc->btcoex;
2560fca65c1c0569d6a143e978b6f4974c519033e63Sujith
2570fca65c1c0569d6a143e978b6f4974c519033e63Sujith	btcoex->btcoex_period = ATH_BTCOEX_DEF_BT_PERIOD * 1000;
2580fca65c1c0569d6a143e978b6f4974c519033e63Sujith	btcoex->btcoex_no_stomp = (100 - ATH_BTCOEX_DEF_DUTY_CYCLE) *
2590fca65c1c0569d6a143e978b6f4974c519033e63Sujith		btcoex->btcoex_period / 100;
26058da1318ee92ad3fe7917278d596768bbe441850Vasanthakumar Thiagarajan	btcoex->btscan_no_stomp = (100 - ATH_BTCOEX_BTSCAN_DUTY_CYCLE) *
26158da1318ee92ad3fe7917278d596768bbe441850Vasanthakumar Thiagarajan				   btcoex->btcoex_period / 100;
2620fca65c1c0569d6a143e978b6f4974c519033e63Sujith
2630fca65c1c0569d6a143e978b6f4974c519033e63Sujith	setup_timer(&btcoex->period_timer, ath_btcoex_period_timer,
2640fca65c1c0569d6a143e978b6f4974c519033e63Sujith			(unsigned long) sc);
2650fca65c1c0569d6a143e978b6f4974c519033e63Sujith
2660fca65c1c0569d6a143e978b6f4974c519033e63Sujith	spin_lock_init(&btcoex->btcoex_lock);
2670fca65c1c0569d6a143e978b6f4974c519033e63Sujith
2680fca65c1c0569d6a143e978b6f4974c519033e63Sujith	btcoex->no_stomp_timer = ath_gen_timer_alloc(sc->sc_ah,
2690fca65c1c0569d6a143e978b6f4974c519033e63Sujith			ath_btcoex_no_stomp_timer,
2700fca65c1c0569d6a143e978b6f4974c519033e63Sujith			ath_btcoex_no_stomp_timer,
2710fca65c1c0569d6a143e978b6f4974c519033e63Sujith			(void *) sc, AR_FIRST_NDP_TIMER);
2720fca65c1c0569d6a143e978b6f4974c519033e63Sujith
2730fca65c1c0569d6a143e978b6f4974c519033e63Sujith	if (!btcoex->no_stomp_timer)
2740fca65c1c0569d6a143e978b6f4974c519033e63Sujith		return -ENOMEM;
2750fca65c1c0569d6a143e978b6f4974c519033e63Sujith
2760fca65c1c0569d6a143e978b6f4974c519033e63Sujith	return 0;
2770fca65c1c0569d6a143e978b6f4974c519033e63Sujith}
2780fca65c1c0569d6a143e978b6f4974c519033e63Sujith
2790fca65c1c0569d6a143e978b6f4974c519033e63Sujith/*
2800fca65c1c0569d6a143e978b6f4974c519033e63Sujith * (Re)start btcoex timers
2810fca65c1c0569d6a143e978b6f4974c519033e63Sujith */
2820fca65c1c0569d6a143e978b6f4974c519033e63Sujithvoid ath9k_btcoex_timer_resume(struct ath_softc *sc)
2830fca65c1c0569d6a143e978b6f4974c519033e63Sujith{
2840fca65c1c0569d6a143e978b6f4974c519033e63Sujith	struct ath_btcoex *btcoex = &sc->btcoex;
2850fca65c1c0569d6a143e978b6f4974c519033e63Sujith	struct ath_hw *ah = sc->sc_ah;
2860fca65c1c0569d6a143e978b6f4974c519033e63Sujith
287d2182b69dcb6a68b1ef6070b2efd094e13dea3f1Joe Perches	ath_dbg(ath9k_hw_common(ah), BTCOEX, "Starting btcoex timers\n");
2880fca65c1c0569d6a143e978b6f4974c519033e63Sujith
2890fca65c1c0569d6a143e978b6f4974c519033e63Sujith	/* make sure duty cycle timer is also stopped when resuming */
2900fca65c1c0569d6a143e978b6f4974c519033e63Sujith	if (btcoex->hw_timer_enabled)
2910fca65c1c0569d6a143e978b6f4974c519033e63Sujith		ath9k_gen_timer_stop(sc->sc_ah, btcoex->no_stomp_timer);
2920fca65c1c0569d6a143e978b6f4974c519033e63Sujith
2930fca65c1c0569d6a143e978b6f4974c519033e63Sujith	btcoex->bt_priority_cnt = 0;
2940fca65c1c0569d6a143e978b6f4974c519033e63Sujith	btcoex->bt_priority_time = jiffies;
29558da1318ee92ad3fe7917278d596768bbe441850Vasanthakumar Thiagarajan	sc->sc_flags &= ~(SC_OP_BT_PRIORITY_DETECTED | SC_OP_BT_SCAN);
2960fca65c1c0569d6a143e978b6f4974c519033e63Sujith
2970fca65c1c0569d6a143e978b6f4974c519033e63Sujith	mod_timer(&btcoex->period_timer, jiffies);
2980fca65c1c0569d6a143e978b6f4974c519033e63Sujith}
2990fca65c1c0569d6a143e978b6f4974c519033e63Sujith
3000fca65c1c0569d6a143e978b6f4974c519033e63Sujith
3010fca65c1c0569d6a143e978b6f4974c519033e63Sujith/*
3020fca65c1c0569d6a143e978b6f4974c519033e63Sujith * Pause btcoex timer and bt duty cycle timer
3030fca65c1c0569d6a143e978b6f4974c519033e63Sujith */
3040fca65c1c0569d6a143e978b6f4974c519033e63Sujithvoid ath9k_btcoex_timer_pause(struct ath_softc *sc)
3050fca65c1c0569d6a143e978b6f4974c519033e63Sujith{
3060fca65c1c0569d6a143e978b6f4974c519033e63Sujith	struct ath_btcoex *btcoex = &sc->btcoex;
3070fca65c1c0569d6a143e978b6f4974c519033e63Sujith	struct ath_hw *ah = sc->sc_ah;
3080fca65c1c0569d6a143e978b6f4974c519033e63Sujith
3090fca65c1c0569d6a143e978b6f4974c519033e63Sujith	del_timer_sync(&btcoex->period_timer);
3100fca65c1c0569d6a143e978b6f4974c519033e63Sujith
3110fca65c1c0569d6a143e978b6f4974c519033e63Sujith	if (btcoex->hw_timer_enabled)
3120fca65c1c0569d6a143e978b6f4974c519033e63Sujith		ath9k_gen_timer_stop(ah, btcoex->no_stomp_timer);
3130fca65c1c0569d6a143e978b6f4974c519033e63Sujith
3140fca65c1c0569d6a143e978b6f4974c519033e63Sujith	btcoex->hw_timer_enabled = false;
3150fca65c1c0569d6a143e978b6f4974c519033e63Sujith}
3165908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan
317c0ac53fa5725aa9e571386d3e7249c1be50eca10Sujith Manoharanu16 ath9k_btcoex_aggr_limit(struct ath_softc *sc, u32 max_4ms_framelen)
318c0ac53fa5725aa9e571386d3e7249c1be50eca10Sujith Manoharan{
319c0ac53fa5725aa9e571386d3e7249c1be50eca10Sujith Manoharan	struct ath_mci_profile *mci = &sc->btcoex.mci;
320c0ac53fa5725aa9e571386d3e7249c1be50eca10Sujith Manoharan	u16 aggr_limit = 0;
321c0ac53fa5725aa9e571386d3e7249c1be50eca10Sujith Manoharan
322c0ac53fa5725aa9e571386d3e7249c1be50eca10Sujith Manoharan	if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_MCI) && mci->aggr_limit)
323c0ac53fa5725aa9e571386d3e7249c1be50eca10Sujith Manoharan		aggr_limit = (max_4ms_framelen * mci->aggr_limit) >> 4;
324c0ac53fa5725aa9e571386d3e7249c1be50eca10Sujith Manoharan	else if (sc->sc_flags & SC_OP_BT_PRIORITY_DETECTED)
325c0ac53fa5725aa9e571386d3e7249c1be50eca10Sujith Manoharan		aggr_limit = min((max_4ms_framelen * 3) / 8,
326c0ac53fa5725aa9e571386d3e7249c1be50eca10Sujith Manoharan				 (u32)ATH_AMPDU_LIMIT_MAX);
327c0ac53fa5725aa9e571386d3e7249c1be50eca10Sujith Manoharan
328c0ac53fa5725aa9e571386d3e7249c1be50eca10Sujith Manoharan	return aggr_limit;
329c0ac53fa5725aa9e571386d3e7249c1be50eca10Sujith Manoharan}
330c0ac53fa5725aa9e571386d3e7249c1be50eca10Sujith Manoharan
33156ca0dba9d5fbc2948ed0c3a4fffc51cd875abb9Sujith Manoharanvoid ath9k_btcoex_handle_interrupt(struct ath_softc *sc, u32 status)
33256ca0dba9d5fbc2948ed0c3a4fffc51cd875abb9Sujith Manoharan{
33356ca0dba9d5fbc2948ed0c3a4fffc51cd875abb9Sujith Manoharan	struct ath_hw *ah = sc->sc_ah;
33456ca0dba9d5fbc2948ed0c3a4fffc51cd875abb9Sujith Manoharan
33556ca0dba9d5fbc2948ed0c3a4fffc51cd875abb9Sujith Manoharan	if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_3WIRE)
33656ca0dba9d5fbc2948ed0c3a4fffc51cd875abb9Sujith Manoharan		if (status & ATH9K_INT_GENTIMER)
33756ca0dba9d5fbc2948ed0c3a4fffc51cd875abb9Sujith Manoharan			ath_gen_timer_isr(sc->sc_ah);
33856ca0dba9d5fbc2948ed0c3a4fffc51cd875abb9Sujith Manoharan
3399a15858f0cb9432e29db08dd936c39d20019a484Sujith Manoharan	if (status & ATH9K_INT_MCI)
34056ca0dba9d5fbc2948ed0c3a4fffc51cd875abb9Sujith Manoharan		ath_mci_intr(sc);
34156ca0dba9d5fbc2948ed0c3a4fffc51cd875abb9Sujith Manoharan}
34256ca0dba9d5fbc2948ed0c3a4fffc51cd875abb9Sujith Manoharan
343df198b172f7a14ecf7aefaadb3761c273600333eSujith Manoharanvoid ath9k_start_btcoex(struct ath_softc *sc)
344df198b172f7a14ecf7aefaadb3761c273600333eSujith Manoharan{
345df198b172f7a14ecf7aefaadb3761c273600333eSujith Manoharan	struct ath_hw *ah = sc->sc_ah;
346df198b172f7a14ecf7aefaadb3761c273600333eSujith Manoharan
347df198b172f7a14ecf7aefaadb3761c273600333eSujith Manoharan	if ((ath9k_hw_get_btcoex_scheme(ah) != ATH_BTCOEX_CFG_NONE) &&
348df198b172f7a14ecf7aefaadb3761c273600333eSujith Manoharan	    !ah->btcoex_hw.enabled) {
349df198b172f7a14ecf7aefaadb3761c273600333eSujith Manoharan		if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_MCI))
350df198b172f7a14ecf7aefaadb3761c273600333eSujith Manoharan			ath9k_hw_btcoex_set_weight(ah, AR_BT_COEX_WGHT,
351df198b172f7a14ecf7aefaadb3761c273600333eSujith Manoharan						   AR_STOMP_LOW_WLAN_WGHT);
352df198b172f7a14ecf7aefaadb3761c273600333eSujith Manoharan		ath9k_hw_btcoex_enable(ah);
353df198b172f7a14ecf7aefaadb3761c273600333eSujith Manoharan
354df198b172f7a14ecf7aefaadb3761c273600333eSujith Manoharan		if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_3WIRE)
355df198b172f7a14ecf7aefaadb3761c273600333eSujith Manoharan			ath9k_btcoex_timer_resume(sc);
356df198b172f7a14ecf7aefaadb3761c273600333eSujith Manoharan	}
357df198b172f7a14ecf7aefaadb3761c273600333eSujith Manoharan}
358df198b172f7a14ecf7aefaadb3761c273600333eSujith Manoharan
359df198b172f7a14ecf7aefaadb3761c273600333eSujith Manoharanvoid ath9k_stop_btcoex(struct ath_softc *sc)
360df198b172f7a14ecf7aefaadb3761c273600333eSujith Manoharan{
361df198b172f7a14ecf7aefaadb3761c273600333eSujith Manoharan	struct ath_hw *ah = sc->sc_ah;
362df198b172f7a14ecf7aefaadb3761c273600333eSujith Manoharan
363df198b172f7a14ecf7aefaadb3761c273600333eSujith Manoharan	if (ah->btcoex_hw.enabled &&
364df198b172f7a14ecf7aefaadb3761c273600333eSujith Manoharan	    ath9k_hw_get_btcoex_scheme(ah) != ATH_BTCOEX_CFG_NONE) {
365df198b172f7a14ecf7aefaadb3761c273600333eSujith Manoharan		ath9k_hw_btcoex_disable(ah);
366df198b172f7a14ecf7aefaadb3761c273600333eSujith Manoharan		if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_3WIRE)
367df198b172f7a14ecf7aefaadb3761c273600333eSujith Manoharan			ath9k_btcoex_timer_pause(sc);
368bff2ec2b916cc85628f3025e08660c0350f03650Sujith Manoharan		if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_MCI)
369bff2ec2b916cc85628f3025e08660c0350f03650Sujith Manoharan			ath_mci_flush_profile(&sc->btcoex.mci);
370df198b172f7a14ecf7aefaadb3761c273600333eSujith Manoharan	}
371df198b172f7a14ecf7aefaadb3761c273600333eSujith Manoharan}
372df198b172f7a14ecf7aefaadb3761c273600333eSujith Manoharan
3735908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharanvoid ath9k_deinit_btcoex(struct ath_softc *sc)
3745908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan{
3755908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan        if ((sc->btcoex.no_stomp_timer) &&
3765908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan	    ath9k_hw_get_btcoex_scheme(sc->sc_ah) == ATH_BTCOEX_CFG_3WIRE)
3775908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan		ath_gen_timer_free(sc->sc_ah, sc->btcoex.no_stomp_timer);
3785908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan
3795908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan	if (ath9k_hw_get_btcoex_scheme(sc->sc_ah) == ATH_BTCOEX_CFG_MCI)
3805908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan		ath_mci_cleanup(sc);
3815908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan}
3825908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan
3835908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharanint ath9k_init_btcoex(struct ath_softc *sc)
3845908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan{
3855908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan	struct ath_txq *txq;
3865908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan	struct ath_hw *ah = sc->sc_ah;
3875908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan	int r;
3885908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan
389d68475de9637a476ad8e5870060ccc69a80f2299Sujith Manoharan	ath9k_hw_btcoex_init_scheme(ah);
390d68475de9637a476ad8e5870060ccc69a80f2299Sujith Manoharan
3915908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan	switch (ath9k_hw_get_btcoex_scheme(sc->sc_ah)) {
3925908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan	case ATH_BTCOEX_CFG_NONE:
3935908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan		break;
3945908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan	case ATH_BTCOEX_CFG_2WIRE:
3955908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan		ath9k_hw_btcoex_init_2wire(sc->sc_ah);
3965908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan		break;
3975908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan	case ATH_BTCOEX_CFG_3WIRE:
3985908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan		ath9k_hw_btcoex_init_3wire(sc->sc_ah);
3995908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan		r = ath_init_btcoex_timer(sc);
4005908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan		if (r)
4015908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan			return -1;
4025908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan		txq = sc->tx.txq_map[WME_AC_BE];
4035908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan		ath9k_hw_init_btcoex_hw(sc->sc_ah, txq->axq_qnum);
4045908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan		sc->btcoex.bt_stomp_type = ATH_BTCOEX_STOMP_LOW;
4055908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan		break;
4065908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan	case ATH_BTCOEX_CFG_MCI:
4075908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan		sc->btcoex.bt_stomp_type = ATH_BTCOEX_STOMP_LOW;
4085908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan		sc->btcoex.duty_cycle = ATH_BTCOEX_DEF_DUTY_CYCLE;
4095908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan		INIT_LIST_HEAD(&sc->btcoex.mci.info);
4105908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan
4115908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan		r = ath_mci_setup(sc);
4125908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan		if (r)
4135908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan			return r;
4145908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan
4155908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan		ath9k_hw_btcoex_init_mci(ah);
4165908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan
4175908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan		break;
4185908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan	default:
4195908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan		WARN_ON(1);
4205908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan		break;
4215908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan	}
4225908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan
4235908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan	return 0;
4245908120fdc2aac0cb1be4059b40ec256d55934bcSujith Manoharan}
4254daa7760e2da9324e740f7d872970fa91c8ea6f0Sujith Manoharan
4264daa7760e2da9324e740f7d872970fa91c8ea6f0Sujith Manoharan#endif /* CONFIG_ATH9K_BTCOEX_SUPPORT */
427