gpio.c 15.4 KB
Newer Older
S
Sujith 已提交
1
/*
2
 * Copyright (c) 2008-2011 Atheros Communications Inc.
S
Sujith 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
 *
 * 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		*/
/********************************/

23
#ifdef CONFIG_MAC80211_LEDS
S
Sujith 已提交
24 25 26
static void ath_led_brightness(struct led_classdev *led_cdev,
			       enum led_brightness brightness)
{
27 28
	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));
S
Sujith 已提交
29 30 31 32
}

void ath_deinit_leds(struct ath_softc *sc)
{
33 34 35 36 37
	if (!sc->led_registered)
		return;

	ath_led_brightness(&sc->led_cdev, LED_OFF);
	led_classdev_unregister(&sc->led_cdev);
S
Sujith 已提交
38 39 40 41 42 43
}

void ath_init_leds(struct ath_softc *sc)
{
	int ret;

44 45 46
	if (AR_SREV_9100(sc->sc_ah))
		return;

47 48 49 50 51 52 53 54 55 56 57 58 59 60
	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;
S
Sujith 已提交
61
}
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86

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);
}
87
#endif
S
Sujith 已提交
88 89 90 91 92 93 94 95

/*******************/
/*	Rfkill	   */
/*******************/

static bool ath_is_rfkill_set(struct ath_softc *sc)
{
	struct ath_hw *ah = sc->sc_ah;
96
	bool is_blocked;
S
Sujith 已提交
97

98 99
	ath9k_ps_wakeup(sc);
	is_blocked = ath9k_hw_gpio_get(ah, ah->rfkill_gpio) ==
S
Sujith 已提交
100
				  ah->rfkill_polarity;
101 102 103
	ath9k_ps_restore(sc);

	return is_blocked;
S
Sujith 已提交
104 105 106 107
}

void ath9k_rfkill_poll_state(struct ieee80211_hw *hw)
{
108
	struct ath_softc *sc = hw->priv;
S
Sujith 已提交
109 110 111 112 113 114 115 116 117 118 119 120 121
	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);
}

122 123
#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT

S
Sujith 已提交
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
/******************/
/*     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))) {
141 142
		clear_bit(BT_OP_PRIORITY_DETECTED, &btcoex->op_flags);
		clear_bit(BT_OP_SCAN, &btcoex->op_flags);
143 144
		/* Detect if colocated bt started scanning */
		if (btcoex->bt_priority_cnt >= ATH_BT_CNT_SCAN_THRESHOLD) {
145
			ath_dbg(ath9k_hw_common(sc->sc_ah), BTCOEX,
J
Joe Perches 已提交
146
				"BT scan detected\n");
147 148
			set_bit(BT_OP_PRIORITY_DETECTED, &btcoex->op_flags);
			set_bit(BT_OP_SCAN, &btcoex->op_flags);
149
		} else if (btcoex->bt_priority_cnt >= ATH_BT_CNT_THRESHOLD) {
150
			ath_dbg(ath9k_hw_common(sc->sc_ah), BTCOEX,
J
Joe Perches 已提交
151
				"BT priority traffic detected\n");
152
			set_bit(BT_OP_PRIORITY_DETECTED, &btcoex->op_flags);
S
Sujith 已提交
153 154 155 156 157 158 159 160 161
		}

		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,
162
				  u32 trig_timeout,
S
Sujith 已提交
163 164
				  u32 timer_period)
{
165
	ath9k_hw_gen_timer_start(ah, timer, trig_timeout, timer_period);
S
Sujith 已提交
166

P
Pavel Roskin 已提交
167
	if ((ah->imask & ATH9K_INT_GENTIMER) == 0) {
168
		ath9k_hw_disable_interrupts(ah);
P
Pavel Roskin 已提交
169
		ah->imask |= ATH9K_INT_GENTIMER;
170
		ath9k_hw_set_interrupts(ah);
171
		ath9k_hw_enable_interrupts(ah);
S
Sujith 已提交
172 173 174 175 176 177 178 179 180 181 182
	}
}

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) {
183
		ath9k_hw_disable_interrupts(ah);
P
Pavel Roskin 已提交
184
		ah->imask &= ~ATH9K_INT_GENTIMER;
185
		ath9k_hw_set_interrupts(ah);
186
		ath9k_hw_enable_interrupts(ah);
S
Sujith 已提交
187 188 189
	}
}

190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
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;
	}
}

S
Sujith 已提交
208 209 210 211 212 213 214 215 216 217
/*
 * 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;
S
Sujith Manoharan 已提交
218
	enum ath_stomp_type stomp_type;
219
	u32 timer_period;
220 221 222 223
	unsigned long flags;

	spin_lock_irqsave(&sc->sc_pm_lock, flags);
	if (sc->sc_ah->power_mode == ATH9K_PM_NETWORK_SLEEP) {
224
		btcoex->bt_wait_time += btcoex->btcoex_period;
225 226 227 228
		spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
		goto skip_hw_wakeup;
	}
	spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
S
Sujith 已提交
229

230 231
	ath9k_mci_update_rssi(sc);

232
	ath9k_ps_wakeup(sc);
S
Sujith Manoharan 已提交
233

234 235
	if (!(ah->caps.hw_caps & ATH9K_HW_CAP_MCI))
		ath_detect_bt_priority(sc);
236

237 238
	if (ah->caps.hw_caps & ATH9K_HW_CAP_MCI)
		ath_mci_ftp_adjust(sc);
239

S
Sujith 已提交
240 241
	spin_lock_bh(&btcoex->btcoex_lock);

S
Sujith Manoharan 已提交
242 243 244 245 246 247 248 249
	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;
		}
250 251 252
	} else if (btcoex->stomp_audio >= 5) {
		stomp_type = ATH_BTCOEX_STOMP_AUDIO;
		btcoex->stomp_audio = 0;
S
Sujith Manoharan 已提交
253
	}
S
Sujith 已提交
254

S
Sujith Manoharan 已提交
255
	ath9k_hw_btcoex_bt_stomp(ah, stomp_type);
256
	ath9k_hw_btcoex_enable(ah);
S
Sujith Manoharan 已提交
257

S
Sujith 已提交
258 259
	spin_unlock_bh(&btcoex->btcoex_lock);

260 261 262 263 264 265
	/*
	 * 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) {
S
Sujith 已提交
266 267 268
		if (btcoex->hw_timer_enabled)
			ath9k_gen_timer_stop(ah, btcoex->no_stomp_timer);

269
		ath9k_gen_timer_start(ah, btcoex->no_stomp_timer, timer_period,
270
				      timer_period * 10);
S
Sujith 已提交
271 272 273
		btcoex->hw_timer_enabled = true;
	}

274
	ath9k_ps_restore(sc);
S
Sujith Manoharan 已提交
275

276
skip_hw_wakeup:
S
Sujith Manoharan 已提交
277 278
	mod_timer(&btcoex->period_timer,
		  jiffies + msecs_to_jiffies(btcoex->btcoex_period));
S
Sujith 已提交
279 280 281 282 283 284 285 286 287 288 289
}

/*
 * 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;
290
	struct ath_common *common = ath9k_hw_common(ah);
S
Sujith 已提交
291

292
	ath_dbg(common, BTCOEX, "no stomp timer running\n");
S
Sujith 已提交
293

294
	ath9k_ps_wakeup(sc);
S
Sujith 已提交
295 296
	spin_lock_bh(&btcoex->btcoex_lock);

297
	if (btcoex->bt_stomp_type == ATH_BTCOEX_STOMP_LOW ||
S
Sujith Manoharan 已提交
298 299
	    (!(ah->caps.hw_caps & ATH9K_HW_CAP_MCI) &&
	     test_bit(BT_OP_SCAN, &btcoex->op_flags)))
300
		ath9k_hw_btcoex_bt_stomp(ah, ATH_BTCOEX_STOMP_NONE);
301
	else if (btcoex->bt_stomp_type == ATH_BTCOEX_STOMP_ALL)
302
		ath9k_hw_btcoex_bt_stomp(ah, ATH_BTCOEX_STOMP_LOW);
S
Sujith 已提交
303

304
	ath9k_hw_btcoex_enable(ah);
S
Sujith 已提交
305
	spin_unlock_bh(&btcoex->btcoex_lock);
306
	ath9k_ps_restore(sc);
S
Sujith 已提交
307 308
}

309
static int ath_init_btcoex_timer(struct ath_softc *sc)
S
Sujith 已提交
310 311 312
{
	struct ath_btcoex *btcoex = &sc->btcoex;

313 314
	btcoex->btcoex_period = ATH_BTCOEX_DEF_BT_PERIOD;
	btcoex->btcoex_no_stomp = (100 - ATH_BTCOEX_DEF_DUTY_CYCLE) * 1000 *
S
Sujith 已提交
315
		btcoex->btcoex_period / 100;
316
	btcoex->btscan_no_stomp = (100 - ATH_BTCOEX_BTSCAN_DUTY_CYCLE) * 1000 *
317
				   btcoex->btcoex_period / 100;
S
Sujith 已提交
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342

	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;

343
	ath_dbg(ath9k_hw_common(ah), BTCOEX, "Starting btcoex timers\n");
S
Sujith 已提交
344 345

	/* make sure duty cycle timer is also stopped when resuming */
346
	if (btcoex->hw_timer_enabled) {
S
Sujith 已提交
347
		ath9k_gen_timer_stop(sc->sc_ah, btcoex->no_stomp_timer);
348 349
		btcoex->hw_timer_enabled = false;
	}
S
Sujith 已提交
350 351 352

	btcoex->bt_priority_cnt = 0;
	btcoex->bt_priority_time = jiffies;
353 354
	clear_bit(BT_OP_PRIORITY_DETECTED, &btcoex->op_flags);
	clear_bit(BT_OP_SCAN, &btcoex->op_flags);
S
Sujith 已提交
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369

	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);

370
	if (btcoex->hw_timer_enabled) {
S
Sujith 已提交
371
		ath9k_gen_timer_stop(ah, btcoex->no_stomp_timer);
372 373
		btcoex->hw_timer_enabled = false;
	}
S
Sujith 已提交
374
}
375

376 377 378 379
void ath9k_btcoex_stop_gen_timer(struct ath_softc *sc)
{
	struct ath_btcoex *btcoex = &sc->btcoex;

380
	if (btcoex->hw_timer_enabled) {
381
		ath9k_gen_timer_stop(sc->sc_ah, btcoex->no_stomp_timer);
382 383
		btcoex->hw_timer_enabled = false;
	}
384 385
}

386 387
u16 ath9k_btcoex_aggr_limit(struct ath_softc *sc, u32 max_4ms_framelen)
{
388
	struct ath_btcoex *btcoex = &sc->btcoex;
389 390 391 392 393
	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;
394
	else if (test_bit(BT_OP_PRIORITY_DETECTED, &btcoex->op_flags))
395 396 397 398 399 400
		aggr_limit = min((max_4ms_framelen * 3) / 8,
				 (u32)ATH_AMPDU_LIMIT_MAX);

	return aggr_limit;
}

401 402 403 404 405 406 407 408
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);

409
	if (status & ATH9K_INT_MCI)
410 411 412
		ath_mci_intr(sc);
}

413 414 415 416 417 418 419 420
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,
421 422 423 424
						   AR_STOMP_LOW_WLAN_WGHT, 0);
		else
			ath9k_hw_btcoex_set_weight(ah, 0, 0,
						   ATH_BTCOEX_STOMP_NONE);
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
		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);
440
		ath9k_hw_btcoex_disable(ah);
B
Bala Shanmugam 已提交
441
		if (AR_SREV_9462(ah) || AR_SREV_9565(ah))
S
Sujith Manoharan 已提交
442
			ath_mci_flush_profile(&sc->btcoex.mci);
443 444 445
	}
}

446 447
void ath9k_deinit_btcoex(struct ath_softc *sc)
{
448 449
	struct ath_hw *ah = sc->sc_ah;

450 451 452 453
        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);

454
	if (ath9k_hw_mci_is_enabled(ah))
455 456 457 458 459 460 461 462 463
		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;

464 465
	ath9k_hw_btcoex_init_scheme(ah);

466 467 468 469 470 471 472 473 474 475 476 477 478 479
	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;
		txq = sc->tx.txq_map[WME_AC_BE];
		ath9k_hw_init_btcoex_hw(sc->sc_ah, txq->axq_qnum);
		sc->btcoex.bt_stomp_type = ATH_BTCOEX_STOMP_LOW;
480
		if (ath9k_hw_mci_is_enabled(ah)) {
481 482
			sc->btcoex.duty_cycle = ATH_BTCOEX_DEF_DUTY_CYCLE;
			INIT_LIST_HEAD(&sc->btcoex.mci.info);
483

484 485 486
			r = ath_mci_setup(sc);
			if (r)
				return r;
487

488 489
			ath9k_hw_btcoex_init_mci(ah);
		}
490 491 492 493 494 495 496 497 498

		break;
	default:
		WARN_ON(1);
		break;
	}

	return 0;
}
499

500
static int ath9k_dump_mci_btcoex(struct ath_softc *sc, u8 *buf, u32 size)
501 502 503 504 505
{
	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;
506
	u32 len = 0;
507 508 509
	int i;

	ATH_DUMP_BTCOEX("Total BT profiles", NUM_PROF(mci));
510 511 512 513 514 515 516
	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);
517 518 519 520 521 522
	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);
523 524
	ATH_DUMP_BTCOEX("Concurrent RSSI cnt", btcoex->rssi_count);

525 526 527 528 529 530 531 532 533 534 535 536 537 538
	len += snprintf(buf + len, size - len, "BT Weights: ");
	for (i = 0; i < AR9300_NUM_BT_WEIGHTS; i++)
		len += snprintf(buf + len, size - len, "%08x ",
				btcoex_hw->bt_weight[i]);
	len += snprintf(buf + len, size - len, "\n");
	len += snprintf(buf + len, size - len, "WLAN Weights: ");
	for (i = 0; i < AR9300_NUM_BT_WEIGHTS; i++)
		len += snprintf(buf + len, size - len, "%08x ",
				btcoex_hw->wlan_weight[i]);
	len += snprintf(buf + len, size - len, "\n");
	len += snprintf(buf + len, size - len, "Tx Priorities: ");
	for (i = 0; i < ATH_BTCOEX_STOMP_MAX; i++)
		len += snprintf(buf + len, size - len, "%08x ",
				btcoex_hw->tx_prio[i]);
539

540 541 542 543
	len += snprintf(buf + len, size - len, "\n");

	return len;
}
544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566

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);
}

567
#endif /* CONFIG_ATH9K_BTCOEX_SUPPORT */