mci.c 15.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/*
 * Copyright (c) 2010-2011 Atheros Communications Inc.
 *
 * 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.
 */

17 18 19
#include <linux/dma-mapping.h>
#include <linux/slab.h>

20 21 22
#include "ath9k.h"
#include "mci.h"

23
static const u8 ath_mci_duty_cycle[] = { 55, 50, 60, 70, 80, 85, 90, 95, 98 };
24 25 26 27 28 29 30

static struct ath_mci_profile_info*
ath_mci_find_profile(struct ath_mci_profile *mci,
		     struct ath_mci_profile_info *info)
{
	struct ath_mci_profile_info *entry;

31 32 33
	if (list_empty(&mci->info))
		return NULL;

34 35
	list_for_each_entry(entry, &mci->info, list) {
		if (entry->conn_handle == info->conn_handle)
36
			return entry;
37
	}
38
	return NULL;
39 40 41 42 43 44 45 46 47
}

static bool ath_mci_add_profile(struct ath_common *common,
				struct ath_mci_profile *mci,
				struct ath_mci_profile_info *info)
{
	struct ath_mci_profile_info *entry;

	if ((mci->num_sco == ATH_MCI_MAX_SCO_PROFILE) &&
S
Sujith Manoharan 已提交
48
	    (info->type == MCI_GPM_COEX_PROFILE_VOICE))
49 50 51
		return false;

	if (((NUM_PROF(mci) - mci->num_sco) == ATH_MCI_MAX_ACL_PROFILE) &&
S
Sujith Manoharan 已提交
52
	    (info->type != MCI_GPM_COEX_PROFILE_VOICE))
53 54
		return false;

55
	entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
56 57
	if (!entry)
		return false;
58

59 60 61
	memcpy(entry, info, 10);
	INC_PROF(mci, info);
	list_add_tail(&entry->list, &mci->info);
S
Sujith Manoharan 已提交
62

63 64 65 66 67
	return true;
}

static void ath_mci_del_profile(struct ath_common *common,
				struct ath_mci_profile *mci,
68
				struct ath_mci_profile_info *entry)
69
{
S
Sujith Manoharan 已提交
70
	if (!entry)
71
		return;
S
Sujith Manoharan 已提交
72

73 74 75 76 77 78 79 80 81
	DEC_PROF(mci, entry);
	list_del(&entry->list);
	kfree(entry);
}

void ath_mci_flush_profile(struct ath_mci_profile *mci)
{
	struct ath_mci_profile_info *info, *tinfo;

82 83 84 85 86
	mci->aggr_limit = 0;

	if (list_empty(&mci->info))
		return;

87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
	list_for_each_entry_safe(info, tinfo, &mci->info, list) {
		list_del(&info->list);
		DEC_PROF(mci, info);
		kfree(info);
	}
}

static void ath_mci_adjust_aggr_limit(struct ath_btcoex *btcoex)
{
	struct ath_mci_profile *mci = &btcoex->mci;
	u32 wlan_airtime = btcoex->btcoex_period *
				(100 - btcoex->duty_cycle) / 100;

	/*
	 * Scale: wlan_airtime is in ms, aggr_limit is in 0.25 ms.
	 * When wlan_airtime is less than 4ms, aggregation limit has to be
	 * adjusted half of wlan_airtime to ensure that the aggregation can fit
	 * without collision with BT traffic.
	 */
	if ((wlan_airtime <= 4) &&
	    (!mci->aggr_limit || (mci->aggr_limit > (2 * wlan_airtime))))
		mci->aggr_limit = 2 * wlan_airtime;
}

static void ath_mci_update_scheme(struct ath_softc *sc)
{
	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
	struct ath_btcoex *btcoex = &sc->btcoex;
	struct ath_mci_profile *mci = &btcoex->mci;
116
	struct ath9k_hw_mci *mci_hw = &sc->sc_ah->btcoex_hw.mci;
117 118 119
	struct ath_mci_profile_info *info;
	u32 num_profile = NUM_PROF(mci);

120 121 122
	if (mci_hw->config & ATH_MCI_CONFIG_DISABLE_TUNING)
		goto skip_tuning;

123 124
	btcoex->duty_cycle = ath_mci_duty_cycle[num_profile];

125 126 127 128
	if (num_profile == 1) {
		info = list_first_entry(&mci->info,
					struct ath_mci_profile_info,
					list);
129 130 131 132 133 134 135
		if (mci->num_sco) {
			if (info->T == 12)
				mci->aggr_limit = 8;
			else if (info->T == 6) {
				mci->aggr_limit = 6;
				btcoex->duty_cycle = 30;
			}
136
			ath_dbg(common, MCI,
137 138 139 140 141 142 143 144 145
				"Single SCO, aggregation limit %d 1/4 ms\n",
				mci->aggr_limit);
		} else if (mci->num_pan || mci->num_other_acl) {
			/*
			 * For single PAN/FTP profile, allocate 35% for BT
			 * to improve WLAN throughput.
			 */
			btcoex->duty_cycle = 35;
			btcoex->btcoex_period = 53;
146
			ath_dbg(common, MCI,
147 148 149
				"Single PAN/FTP bt period %d ms dutycycle %d\n",
				btcoex->duty_cycle, btcoex->btcoex_period);
		} else if (mci->num_hid) {
150
			btcoex->duty_cycle = 30;
151
			mci->aggr_limit = 6;
152
			ath_dbg(common, MCI,
153
				"Multiple attempt/timeout single HID "
154
				"aggregation limit 1.5 ms dutycycle 30%%\n");
155
		}
156 157 158
	} else if (num_profile == 2) {
		if (mci->num_hid == 2)
			btcoex->duty_cycle = 30;
159
		mci->aggr_limit = 6;
160
		ath_dbg(common, MCI,
161 162 163 164 165 166
			"Two BT profiles aggr limit 1.5 ms dutycycle %d%%\n",
			btcoex->duty_cycle);
	} else if (num_profile >= 3) {
		mci->aggr_limit = 4;
		ath_dbg(common, MCI,
			"Three or more profiles aggregation limit 1 ms\n");
167 168
	}

169
skip_tuning:
170 171 172 173 174 175 176 177 178 179 180 181 182
	if (IS_CHAN_2GHZ(sc->sc_ah->curchan)) {
		if (IS_CHAN_HT(sc->sc_ah->curchan))
			ath_mci_adjust_aggr_limit(btcoex);
		else
			btcoex->btcoex_period >>= 1;
	}

	ath9k_hw_btcoex_disable(sc->sc_ah);
	ath9k_btcoex_timer_pause(sc);

	if (IS_CHAN_5GHZ(sc->sc_ah->curchan))
		return;

183
	btcoex->duty_cycle += (mci->num_bdr ? ATH_MCI_BDR_DUTY_CYCLE : 0);
184 185 186
	if (btcoex->duty_cycle > ATH_MCI_MAX_DUTY_CYCLE)
		btcoex->duty_cycle = ATH_MCI_MAX_DUTY_CYCLE;

187
	btcoex->btcoex_no_stomp =  btcoex->btcoex_period * 1000 *
S
Sujith Manoharan 已提交
188
		(100 - btcoex->duty_cycle) / 100;
189 190 191 192 193

	ath9k_hw_btcoex_enable(sc->sc_ah);
	ath9k_btcoex_timer_resume(sc);
}

194 195 196 197 198 199 200 201 202 203 204
static void ath_mci_cal_msg(struct ath_softc *sc, u8 opcode, u8 *rx_payload)
{
	struct ath_hw *ah = sc->sc_ah;
	struct ath_common *common = ath9k_hw_common(ah);
	u32 payload[4] = {0, 0, 0, 0};

	switch (opcode) {
	case MCI_GPM_BT_CAL_REQ:
		if (ar9003_mci_state(ah, MCI_STATE_BT, NULL) == MCI_BT_AWAKE) {
			ar9003_mci_state(ah, MCI_STATE_SET_BT_CAL_START, NULL);
			ieee80211_queue_work(sc->hw, &sc->hw_reset_work);
S
Sujith Manoharan 已提交
205 206
		} else {
			ath_dbg(common, MCI, "MCI State mismatch: %d\n",
207
				ar9003_mci_state(ah, MCI_STATE_BT, NULL));
S
Sujith Manoharan 已提交
208
		}
209 210
		break;
	case MCI_GPM_BT_CAL_DONE:
S
Sujith Manoharan 已提交
211
		ar9003_mci_state(ah, MCI_STATE_BT, NULL);
212 213 214 215 216 217 218
		break;
	case MCI_GPM_BT_CAL_GRANT:
		MCI_GPM_SET_CAL_TYPE(payload, MCI_GPM_WLAN_CAL_DONE);
		ar9003_mci_send_message(sc->sc_ah, MCI_GPM, 0, payload,
					16, false, true);
		break;
	default:
S
Sujith Manoharan 已提交
219
		ath_dbg(common, MCI, "Unknown GPM CAL message\n");
220 221 222 223
		break;
	}
}

224 225 226 227 228 229 230
static void ath9k_mci_work(struct work_struct *work)
{
	struct ath_softc *sc = container_of(work, struct ath_softc, mci_work);

	ath_mci_update_scheme(sc);
}

231 232
static void ath_mci_process_profile(struct ath_softc *sc,
				    struct ath_mci_profile_info *info)
233 234 235 236
{
	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
	struct ath_btcoex *btcoex = &sc->btcoex;
	struct ath_mci_profile *mci = &btcoex->mci;
237 238 239 240 241
	struct ath_mci_profile_info *entry = NULL;

	entry = ath_mci_find_profile(mci, info);
	if (entry)
		memcpy(entry, info, 10);
242 243

	if (info->start) {
244
		if (!entry && !ath_mci_add_profile(common, mci, info))
245 246
			return;
	} else
247
		ath_mci_del_profile(common, mci, entry);
248 249 250

	btcoex->btcoex_period = ATH_MCI_DEF_BT_PERIOD;
	mci->aggr_limit = mci->num_sco ? 6 : 0;
S
Sujith Manoharan 已提交
251

252 253
	btcoex->duty_cycle = ath_mci_duty_cycle[NUM_PROF(mci)];
	if (NUM_PROF(mci))
254
		btcoex->bt_stomp_type = ATH_BTCOEX_STOMP_LOW;
255
	else
256 257 258
		btcoex->bt_stomp_type = mci->num_mgmt ? ATH_BTCOEX_STOMP_ALL :
							ATH_BTCOEX_STOMP_LOW;

259
	ieee80211_queue_work(sc->hw, &sc->mci_work);
260 261
}

262 263
static void ath_mci_process_status(struct ath_softc *sc,
				   struct ath_mci_profile_status *status)
264 265 266 267 268 269 270
{
	struct ath_btcoex *btcoex = &sc->btcoex;
	struct ath_mci_profile *mci = &btcoex->mci;
	struct ath_mci_profile_info info;
	int i = 0, old_num_mgmt = mci->num_mgmt;

	/* Link status type are not handled */
S
Sujith Manoharan 已提交
271
	if (status->is_link)
272 273 274
		return;

	info.conn_handle = status->conn_handle;
S
Sujith Manoharan 已提交
275
	if (ath_mci_find_profile(mci, &info))
276
		return;
S
Sujith Manoharan 已提交
277 278

	if (status->conn_handle >= ATH_MCI_MAX_PROFILE)
279
		return;
S
Sujith Manoharan 已提交
280

281 282 283 284 285 286 287 288 289 290 291 292
	if (status->is_critical)
		__set_bit(status->conn_handle, mci->status);
	else
		__clear_bit(status->conn_handle, mci->status);

	mci->num_mgmt = 0;
	do {
		if (test_bit(i, mci->status))
			mci->num_mgmt++;
	} while (++i < ATH_MCI_MAX_PROFILE);

	if (old_num_mgmt != mci->num_mgmt)
293
		ieee80211_queue_work(sc->hw, &sc->mci_work);
294
}
295

296 297 298 299 300 301 302 303 304 305 306 307 308
static void ath_mci_msg(struct ath_softc *sc, u8 opcode, u8 *rx_payload)
{
	struct ath_hw *ah = sc->sc_ah;
	struct ath_mci_profile_info profile_info;
	struct ath_mci_profile_status profile_status;
	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
	u32 version;
	u8 major;
	u8 minor;
	u32 seq_num;

	switch (opcode) {
	case MCI_GPM_COEX_VERSION_QUERY:
S
Sujith Manoharan 已提交
309 310
		version = ar9003_mci_state(ah, MCI_STATE_SEND_WLAN_COEX_VERSION,
					   NULL);
311 312 313 314 315
		break;
	case MCI_GPM_COEX_VERSION_RESPONSE:
		major = *(rx_payload + MCI_GPM_COEX_B_MAJOR_VERSION);
		minor = *(rx_payload + MCI_GPM_COEX_B_MINOR_VERSION);
		version = (major << 8) + minor;
S
Sujith Manoharan 已提交
316 317
		version = ar9003_mci_state(ah, MCI_STATE_SET_BT_COEX_VERSION,
					   &version);
318 319
		break;
	case MCI_GPM_COEX_STATUS_QUERY:
S
Sujith Manoharan 已提交
320
		ar9003_mci_state(ah, MCI_STATE_SEND_WLAN_CHANNELS, NULL);
321 322 323 324 325
		break;
	case MCI_GPM_COEX_BT_PROFILE_INFO:
		memcpy(&profile_info,
		       (rx_payload + MCI_GPM_COEX_B_PROFILE_TYPE), 10);

S
Sujith Manoharan 已提交
326 327
		if ((profile_info.type == MCI_GPM_COEX_PROFILE_UNKNOWN) ||
		    (profile_info.type >= MCI_GPM_COEX_PROFILE_MAX)) {
328
			ath_dbg(common, MCI,
S
Sujith Manoharan 已提交
329
				"Illegal profile type = %d, state = %d\n",
330
				profile_info.type,
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345
				profile_info.start);
			break;
		}

		ath_mci_process_profile(sc, &profile_info);
		break;
	case MCI_GPM_COEX_BT_STATUS_UPDATE:
		profile_status.is_link = *(rx_payload +
					   MCI_GPM_COEX_B_STATUS_TYPE);
		profile_status.conn_handle = *(rx_payload +
					       MCI_GPM_COEX_B_STATUS_LINKID);
		profile_status.is_critical = *(rx_payload +
					       MCI_GPM_COEX_B_STATUS_STATE);

		seq_num = *((u32 *)(rx_payload + 12));
346
		ath_dbg(common, MCI,
S
Sujith Manoharan 已提交
347
			"BT_Status_Update: is_link=%d, linkId=%d, state=%d, SEQ=%d\n",
348 349 350 351 352 353
			profile_status.is_link, profile_status.conn_handle,
			profile_status.is_critical, seq_num);

		ath_mci_process_status(sc, &profile_status);
		break;
	default:
S
Sujith Manoharan 已提交
354
		ath_dbg(common, MCI, "Unknown GPM COEX message = 0x%02x\n", opcode);
355 356 357
		break;
	}
}
358 359 360 361 362

int ath_mci_setup(struct ath_softc *sc)
{
	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
	struct ath_mci_coex *mci = &sc->mci_coex;
363
	struct ath_mci_buf *buf = &mci->sched_buf;
364

365 366 367
	buf->bf_addr = dma_alloc_coherent(sc->dev,
				  ATH_MCI_SCHED_BUF_SIZE + ATH_MCI_GPM_BUF_SIZE,
				  &buf->bf_paddr, GFP_KERNEL);
368

369
	if (buf->bf_addr == NULL) {
370
		ath_dbg(common, FATAL, "MCI buffer alloc failed\n");
371
		return -ENOMEM;
372 373
	}

374 375
	memset(buf->bf_addr, MCI_GPM_RSVD_PATTERN,
	       ATH_MCI_SCHED_BUF_SIZE + ATH_MCI_GPM_BUF_SIZE);
376

377
	mci->sched_buf.bf_len = ATH_MCI_SCHED_BUF_SIZE;
378 379

	mci->gpm_buf.bf_len = ATH_MCI_GPM_BUF_SIZE;
380
	mci->gpm_buf.bf_addr = (u8 *)mci->sched_buf.bf_addr + mci->sched_buf.bf_len;
381 382 383 384 385
	mci->gpm_buf.bf_paddr = mci->sched_buf.bf_paddr + mci->sched_buf.bf_len;

	ar9003_mci_setup(sc->sc_ah, mci->gpm_buf.bf_paddr,
			 mci->gpm_buf.bf_addr, (mci->gpm_buf.bf_len >> 4),
			 mci->sched_buf.bf_paddr);
386

387
	INIT_WORK(&sc->mci_work, ath9k_mci_work);
388 389 390
	ath_dbg(common, MCI, "MCI Initialized\n");

	return 0;
391 392 393 394
}

void ath_mci_cleanup(struct ath_softc *sc)
{
395
	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
396 397
	struct ath_hw *ah = sc->sc_ah;
	struct ath_mci_coex *mci = &sc->mci_coex;
398
	struct ath_mci_buf *buf = &mci->sched_buf;
399

400 401 402 403 404
	if (buf->bf_addr)
		dma_free_coherent(sc->dev,
				  ATH_MCI_SCHED_BUF_SIZE + ATH_MCI_GPM_BUF_SIZE,
				  buf->bf_addr, buf->bf_paddr);

405
	ar9003_mci_cleanup(ah);
406 407

	ath_dbg(common, MCI, "MCI De-Initialized\n");
408
}
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423

void ath_mci_intr(struct ath_softc *sc)
{
	struct ath_mci_coex *mci = &sc->mci_coex;
	struct ath_hw *ah = sc->sc_ah;
	struct ath_common *common = ath9k_hw_common(ah);
	u32 mci_int, mci_int_rxmsg;
	u32 offset, subtype, opcode;
	u32 *pgpm;
	u32 more_data = MCI_GPM_MORE;
	bool skip_gpm = false;

	ar9003_mci_get_interrupt(sc->sc_ah, &mci_int, &mci_int_rxmsg);

	if (ar9003_mci_state(ah, MCI_STATE_ENABLE, NULL) == 0) {
424
		ar9003_mci_get_next_gpm_offset(ah, true, NULL);
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454
		return;
	}

	if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_REQ_WAKE) {
		u32 payload[4] = { 0xffffffff, 0xffffffff,
				   0xffffffff, 0xffffff00};

		/*
		 * The following REMOTE_RESET and SYS_WAKING used to sent
		 * only when BT wake up. Now they are always sent, as a
		 * recovery method to reset BT MCI's RX alignment.
		 */
		ar9003_mci_send_message(ah, MCI_REMOTE_RESET, 0,
					payload, 16, true, false);
		ar9003_mci_send_message(ah, MCI_SYS_WAKING, 0,
					NULL, 0, true, false);

		mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_REQ_WAKE;
		ar9003_mci_state(ah, MCI_STATE_RESET_REQ_WAKE, NULL);

		/*
		 * always do this for recovery and 2G/5G toggling and LNA_TRANS
		 */
		ar9003_mci_state(ah, MCI_STATE_SET_BT_AWAKE, NULL);
	}

	if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_SYS_WAKING) {
		mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_SYS_WAKING;

		if (ar9003_mci_state(ah, MCI_STATE_BT, NULL) == MCI_BT_SLEEP) {
S
Sujith Manoharan 已提交
455 456 457 458 459
			if (ar9003_mci_state(ah, MCI_STATE_REMOTE_SLEEP, NULL) !=
			    MCI_BT_SLEEP)
				ar9003_mci_state(ah, MCI_STATE_SET_BT_AWAKE,
						 NULL);
		}
460 461 462 463 464 465
	}

	if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_SYS_SLEEPING) {
		mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_SYS_SLEEPING;

		if (ar9003_mci_state(ah, MCI_STATE_BT, NULL) == MCI_BT_AWAKE) {
S
Sujith Manoharan 已提交
466 467
			if (ar9003_mci_state(ah, MCI_STATE_REMOTE_SLEEP, NULL) !=
			    MCI_BT_AWAKE)
468 469
				ar9003_mci_state(ah, MCI_STATE_SET_BT_SLEEP,
						 NULL);
S
Sujith Manoharan 已提交
470
		}
471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490
	}

	if ((mci_int & AR_MCI_INTERRUPT_RX_INVALID_HDR) ||
	    (mci_int & AR_MCI_INTERRUPT_CONT_INFO_TIMEOUT)) {
		ar9003_mci_state(ah, MCI_STATE_RECOVER_RX, NULL);
		skip_gpm = true;
	}

	if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_SCHD_INFO) {
		mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_SCHD_INFO;
		offset = ar9003_mci_state(ah, MCI_STATE_LAST_SCHD_MSG_OFFSET,
					  NULL);
	}

	if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_GPM) {
		mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_GPM;

		while (more_data == MCI_GPM_MORE) {

			pgpm = mci->gpm_buf.bf_addr;
491 492
			offset = ar9003_mci_get_next_gpm_offset(ah, false,
								&more_data);
493 494 495 496 497 498 499 500 501 502 503 504 505

			if (offset == MCI_GPM_INVALID)
				break;

			pgpm += (offset >> 2);

			/*
			 * The first dword is timer.
			 * The real data starts from 2nd dword.
			 */
			subtype = MCI_GPM_TYPE(pgpm);
			opcode = MCI_GPM_OPCODE(pgpm);

S
Sujith Manoharan 已提交
506 507 508 509 510 511 512 513 514 515 516 517
			if (skip_gpm)
				goto recycle;

			if (MCI_GPM_IS_CAL_TYPE(subtype)) {
				ath_mci_cal_msg(sc, subtype, (u8 *)pgpm);
			} else {
				switch (subtype) {
				case MCI_GPM_COEX_AGENT:
					ath_mci_msg(sc, opcode, (u8 *)pgpm);
					break;
				default:
					break;
518 519
				}
			}
S
Sujith Manoharan 已提交
520
		recycle:
521 522 523 524 525 526 527 528
			MCI_GPM_RECYCLE(pgpm);
		}
	}

	if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_HW_MSG_MASK) {
		if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_LNA_CONTROL)
			mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_LNA_CONTROL;

S
Sujith Manoharan 已提交
529
		if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_LNA_INFO)
530 531 532 533
			mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_LNA_INFO;

		if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_CONT_INFO) {
			int value_dbm = ar9003_mci_state(ah,
S
Sujith Manoharan 已提交
534
						 MCI_STATE_CONT_RSSI_POWER, NULL);
535 536 537 538

			mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_CONT_INFO;

			if (ar9003_mci_state(ah, MCI_STATE_CONT_TXRX, NULL))
539 540
				ath_dbg(common, MCI,
					"MCI CONT_INFO: (tx) pri = %d, pwr = %d dBm\n",
541
					ar9003_mci_state(ah,
S
Sujith Manoharan 已提交
542
						 MCI_STATE_CONT_PRIORITY, NULL),
543 544
					value_dbm);
			else
545 546
				ath_dbg(common, MCI,
					"MCI CONT_INFO: (rx) pri = %d,pwr = %d dBm\n",
547
					ar9003_mci_state(ah,
S
Sujith Manoharan 已提交
548
						 MCI_STATE_CONT_PRIORITY, NULL),
549 550 551
					value_dbm);
		}

S
Sujith Manoharan 已提交
552
		if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_CONT_NACK)
553 554
			mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_CONT_NACK;

S
Sujith Manoharan 已提交
555
		if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_CONT_RST)
556 557 558 559 560 561 562 563
			mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_CONT_RST;
	}

	if ((mci_int & AR_MCI_INTERRUPT_RX_INVALID_HDR) ||
	    (mci_int & AR_MCI_INTERRUPT_CONT_INFO_TIMEOUT))
		mci_int &= ~(AR_MCI_INTERRUPT_RX_INVALID_HDR |
			     AR_MCI_INTERRUPT_CONT_INFO_TIMEOUT);
}
564 565 566 567 568 569 570 571 572 573 574

void ath_mci_enable(struct ath_softc *sc)
{
	struct ath_common *common = ath9k_hw_common(sc->sc_ah);

	if (!common->btcoex_enabled)
		return;

	if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_MCI)
		sc->sc_ah->imask |= ATH9K_INT_MCI;
}