btcoex.c 2.0 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/*
 * Copyright (c) 2009 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.
 */

#include "ath9k.h"

void ath9k_hw_btcoex_init(struct ath_hw *ah)
{
21 22
	struct ath_btcoex_info *btcoex_info = &ah->ah_sc->btcoex_info;

23 24 25 26 27 28 29 30 31 32 33
	/* connect bt_active to baseband */
	REG_CLR_BIT(ah, AR_GPIO_INPUT_EN_VAL,
			(AR_GPIO_INPUT_EN_VAL_BT_PRIORITY_DEF |
			 AR_GPIO_INPUT_EN_VAL_BT_FREQUENCY_DEF));

	REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL,
			AR_GPIO_INPUT_EN_VAL_BT_ACTIVE_BB);

	/* Set input mux for bt_active to gpio pin */
	REG_RMW_FIELD(ah, AR_GPIO_INPUT_MUX1,
			AR_GPIO_INPUT_MUX1_BT_ACTIVE,
34
			btcoex_info->btactive_gpio);
35 36

	/* Configure the desired gpio port for input */
37
	ath9k_hw_cfg_gpio_input(ah, btcoex_info->btactive_gpio);
38 39 40 41
}

void ath9k_hw_btcoex_enable(struct ath_hw *ah)
{
42 43
	struct ath_btcoex_info *btcoex_info = &ah->ah_sc->btcoex_info;

44
	/* Configure the desired GPIO port for TX_FRAME output */
45
	ath9k_hw_cfg_output(ah, btcoex_info->wlanactive_gpio,
46 47 48 49 50 51 52
			    AR_GPIO_OUTPUT_MUX_AS_TX_FRAME);

	ah->ah_sc->sc_flags |= SC_OP_BTCOEX_ENABLED;
}

void ath9k_hw_btcoex_disable(struct ath_hw *ah)
{
53 54 55
	struct ath_btcoex_info *btcoex_info = &ah->ah_sc->btcoex_info;

	ath9k_hw_set_gpio(ah, btcoex_info->wlanactive_gpio, 0);
56

57
	ath9k_hw_cfg_output(ah, btcoex_info->wlanactive_gpio,
58 59 60 61
			AR_GPIO_OUTPUT_MUX_AS_OUTPUT);

	ah->ah_sc->sc_flags &= ~SC_OP_BTCOEX_ENABLED;
}