117d50d1dSVasanthakumar Thiagarajan /* 25b68138eSSujith Manoharan * Copyright (c) 2009-2011 Atheros Communications Inc. 317d50d1dSVasanthakumar Thiagarajan * 417d50d1dSVasanthakumar Thiagarajan * Permission to use, copy, modify, and/or distribute this software for any 517d50d1dSVasanthakumar Thiagarajan * purpose with or without fee is hereby granted, provided that the above 617d50d1dSVasanthakumar Thiagarajan * copyright notice and this permission notice appear in all copies. 717d50d1dSVasanthakumar Thiagarajan * 817d50d1dSVasanthakumar Thiagarajan * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 917d50d1dSVasanthakumar Thiagarajan * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 1017d50d1dSVasanthakumar Thiagarajan * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 1117d50d1dSVasanthakumar Thiagarajan * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 1217d50d1dSVasanthakumar Thiagarajan * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 1317d50d1dSVasanthakumar Thiagarajan * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 1417d50d1dSVasanthakumar Thiagarajan * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 1517d50d1dSVasanthakumar Thiagarajan */ 1617d50d1dSVasanthakumar Thiagarajan 1717d50d1dSVasanthakumar Thiagarajan #ifndef BTCOEX_H 1817d50d1dSVasanthakumar Thiagarajan #define BTCOEX_H 1917d50d1dSVasanthakumar Thiagarajan 20af03abecSLuis R. Rodriguez #include "hw.h" 21af03abecSLuis R. Rodriguez 22a6ef530fSVivek Natarajan #define ATH_WLANACTIVE_GPIO_9280 5 23a6ef530fSVivek Natarajan #define ATH_BTACTIVE_GPIO_9280 6 24a6ef530fSVivek Natarajan #define ATH_BTPRIORITY_GPIO_9285 7 25a6ef530fSVivek Natarajan 26a6ef530fSVivek Natarajan #define ATH_WLANACTIVE_GPIO_9300 5 27a6ef530fSVivek Natarajan #define ATH_BTACTIVE_GPIO_9300 4 28a6ef530fSVivek Natarajan #define ATH_BTPRIORITY_GPIO_9300 8 29f14462c6SVasanthakumar Thiagarajan 301773912bSVasanthakumar Thiagarajan #define ATH_BTCOEX_DEF_BT_PERIOD 45 311773912bSVasanthakumar Thiagarajan #define ATH_BTCOEX_DEF_DUTY_CYCLE 55 3258da1318SVasanthakumar Thiagarajan #define ATH_BTCOEX_BTSCAN_DUTY_CYCLE 90 331773912bSVasanthakumar Thiagarajan #define ATH_BTCOEX_BMISS_THRESH 50 341773912bSVasanthakumar Thiagarajan 351773912bSVasanthakumar Thiagarajan #define ATH_BT_PRIORITY_TIME_THRESHOLD 1000 /* ms */ 361773912bSVasanthakumar Thiagarajan #define ATH_BT_CNT_THRESHOLD 3 3758da1318SVasanthakumar Thiagarajan #define ATH_BT_CNT_SCAN_THRESHOLD 15 381773912bSVasanthakumar Thiagarajan 396995fb80SRajkumar Manoharan #define ATH_BTCOEX_RX_WAIT_TIME 100 406995fb80SRajkumar Manoharan #define ATH_BTCOEX_STOMP_FTP_THRESH 5 416995fb80SRajkumar Manoharan 42e82cb03fSRajkumar Manoharan #define ATH_BTCOEX_HT20_MAX_TXPOWER 0x14 43e82cb03fSRajkumar Manoharan #define ATH_BTCOEX_HT40_MAX_TXPOWER 0x10 44e82cb03fSRajkumar Manoharan 4554f10b05SRajkumar Manoharan #define AR9300_NUM_BT_WEIGHTS 4 4654f10b05SRajkumar Manoharan #define AR9300_NUM_WLAN_WEIGHTS 4 47d3f193eeSSujith Manoharan 48d3f193eeSSujith Manoharan #define ATH_AIC_MAX_BT_CHANNEL 79 49d3f193eeSSujith Manoharan 50978f78bfSVivek Natarajan /* Defines the BT AR_BT_COEX_WGHT used */ 51978f78bfSVivek Natarajan enum ath_stomp_type { 52978f78bfSVivek Natarajan ATH_BTCOEX_STOMP_ALL, 53978f78bfSVivek Natarajan ATH_BTCOEX_STOMP_LOW, 5454f10b05SRajkumar Manoharan ATH_BTCOEX_STOMP_NONE, 558227bf45SRajkumar Manoharan ATH_BTCOEX_STOMP_LOW_FTP, 562884561aSRajkumar Manoharan ATH_BTCOEX_STOMP_AUDIO, 5754f10b05SRajkumar Manoharan ATH_BTCOEX_STOMP_MAX 58978f78bfSVivek Natarajan }; 59978f78bfSVivek Natarajan 6022f25d0dSVasanthakumar Thiagarajan enum ath_btcoex_scheme { 6122f25d0dSVasanthakumar Thiagarajan ATH_BTCOEX_CFG_NONE, 6222f25d0dSVasanthakumar Thiagarajan ATH_BTCOEX_CFG_2WIRE, 6322f25d0dSVasanthakumar Thiagarajan ATH_BTCOEX_CFG_3WIRE, 64e1ff147dSSujith Manoharan ATH_BTCOEX_CFG_MCI, 6522f25d0dSVasanthakumar Thiagarajan }; 6622f25d0dSVasanthakumar Thiagarajan 676af24c49SMohammed Shafi Shajakhan struct ath9k_hw_mci { 686af24c49SMohammed Shafi Shajakhan u32 raw_intr; 696af24c49SMohammed Shafi Shajakhan u32 rx_msg_intr; 706af24c49SMohammed Shafi Shajakhan u32 cont_status; 716af24c49SMohammed Shafi Shajakhan u32 gpm_addr; 726af24c49SMohammed Shafi Shajakhan u32 gpm_len; 736af24c49SMohammed Shafi Shajakhan u32 gpm_idx; 746af24c49SMohammed Shafi Shajakhan u32 sched_addr; 756af24c49SMohammed Shafi Shajakhan u32 wlan_channels[4]; 766af24c49SMohammed Shafi Shajakhan u32 wlan_cal_seq; 776af24c49SMohammed Shafi Shajakhan u32 wlan_cal_done; 786af24c49SMohammed Shafi Shajakhan u32 config; 796af24c49SMohammed Shafi Shajakhan u8 *gpm_buf; 806af24c49SMohammed Shafi Shajakhan bool ready; 816af24c49SMohammed Shafi Shajakhan bool update_2g5g; 826af24c49SMohammed Shafi Shajakhan bool is_2g; 836af24c49SMohammed Shafi Shajakhan bool query_bt; 846af24c49SMohammed Shafi Shajakhan bool unhalt_bt_gpm; /* need send UNHALT */ 856af24c49SMohammed Shafi Shajakhan bool halted_bt_gpm; /* HALT sent */ 866af24c49SMohammed Shafi Shajakhan bool need_flush_btinfo; 876af24c49SMohammed Shafi Shajakhan bool bt_version_known; 886af24c49SMohammed Shafi Shajakhan bool wlan_channels_update; 896af24c49SMohammed Shafi Shajakhan u8 wlan_ver_major; 906af24c49SMohammed Shafi Shajakhan u8 wlan_ver_minor; 916af24c49SMohammed Shafi Shajakhan u8 bt_ver_major; 926af24c49SMohammed Shafi Shajakhan u8 bt_ver_minor; 936af24c49SMohammed Shafi Shajakhan u8 bt_state; 946995fb80SRajkumar Manoharan u8 stomp_ftp; 95db60428bSRajkumar Manoharan bool concur_tx; 962097fdd7SRajkumar Manoharan u32 last_recovery; 976af24c49SMohammed Shafi Shajakhan }; 986af24c49SMohammed Shafi Shajakhan 99d3f193eeSSujith Manoharan struct ath9k_hw_aic { 100d3f193eeSSujith Manoharan bool aic_enabled; 101d3f193eeSSujith Manoharan u8 aic_cal_state; 102d3f193eeSSujith Manoharan u8 aic_caled_chan; 103d3f193eeSSujith Manoharan u32 aic_sram[ATH_AIC_MAX_BT_CHANNEL]; 104d3f193eeSSujith Manoharan u32 aic_cal_start_time; 105d3f193eeSSujith Manoharan }; 106d3f193eeSSujith Manoharan 107766ec4a9SLuis R. Rodriguez struct ath_btcoex_hw { 10846289e1eSLuis R. Rodriguez enum ath_btcoex_scheme scheme; 1096af24c49SMohammed Shafi Shajakhan struct ath9k_hw_mci mci; 110b6ab9ae2SSujith Manoharan struct ath9k_hw_aic aic; 1118c1b3954SLuis R. Rodriguez bool enabled; 112f14462c6SVasanthakumar Thiagarajan u8 wlanactive_gpio; 113f14462c6SVasanthakumar Thiagarajan u8 btactive_gpio; 1141773912bSVasanthakumar Thiagarajan u8 btpriority_gpio; 1151773912bSVasanthakumar Thiagarajan u32 bt_coex_mode; /* Register setting for AR_BT_COEX_MODE */ 1161773912bSVasanthakumar Thiagarajan u32 bt_coex_weights; /* Register setting for AR_BT_COEX_WEIGHT */ 1171773912bSVasanthakumar Thiagarajan u32 bt_coex_mode2; /* Register setting for AR_BT_COEX_MODE2 */ 118*c7212b71SMiaoqing Pan u32 bt_coex_mode3; /* Register setting for AR_BT_COEX_MODE3 */ 11954f10b05SRajkumar Manoharan u32 bt_weight[AR9300_NUM_BT_WEIGHTS]; 12054f10b05SRajkumar Manoharan u32 wlan_weight[AR9300_NUM_WLAN_WEIGHTS]; 121db60428bSRajkumar Manoharan u8 tx_prio[ATH_BTCOEX_STOMP_MAX]; 122f14462c6SVasanthakumar Thiagarajan }; 123f14462c6SVasanthakumar Thiagarajan 124d68475deSSujith Manoharan void ath9k_hw_btcoex_init_scheme(struct ath_hw *ah); 12575d7839fSLuis R. Rodriguez void ath9k_hw_btcoex_init_2wire(struct ath_hw *ah); 12675d7839fSLuis R. Rodriguez void ath9k_hw_btcoex_init_3wire(struct ath_hw *ah); 127db222190SMiaoqing Pan void ath9k_hw_btcoex_deinit(struct ath_hw *ah); 128d3c83ac1SSujith Manoharan void ath9k_hw_btcoex_init_mci(struct ath_hw *ah); 129766ec4a9SLuis R. Rodriguez void ath9k_hw_init_btcoex_hw(struct ath_hw *ah, int qnum); 1305e197292SLuis R. Rodriguez void ath9k_hw_btcoex_set_weight(struct ath_hw *ah, 1315e197292SLuis R. Rodriguez u32 bt_weight, 1325160b46fSSujith Manoharan u32 wlan_weight, 1335160b46fSSujith Manoharan enum ath_stomp_type stomp_type); 13417d50d1dSVasanthakumar Thiagarajan void ath9k_hw_btcoex_disable(struct ath_hw *ah); 135978f78bfSVivek Natarajan void ath9k_hw_btcoex_bt_stomp(struct ath_hw *ah, 136978f78bfSVivek Natarajan enum ath_stomp_type stomp_type); 137db60428bSRajkumar Manoharan void ath9k_hw_btcoex_set_concur_txprio(struct ath_hw *ah, u8 *stomp_txprio); 1382e20250aSLuis R. Rodriguez 13917d50d1dSVasanthakumar Thiagarajan #endif 140