18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright (c) 2009-2011 Atheros Communications Inc.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Permission to use, copy, modify, and/or distribute this software for any
58c2ecf20Sopenharmony_ci * purpose with or without fee is hereby granted, provided that the above
68c2ecf20Sopenharmony_ci * copyright notice and this permission notice appear in all copies.
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
98c2ecf20Sopenharmony_ci * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
108c2ecf20Sopenharmony_ci * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
118c2ecf20Sopenharmony_ci * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
128c2ecf20Sopenharmony_ci * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
138c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
148c2ecf20Sopenharmony_ci * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
158c2ecf20Sopenharmony_ci */
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#ifndef BTCOEX_H
188c2ecf20Sopenharmony_ci#define BTCOEX_H
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci#include "hw.h"
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#define ATH_WLANACTIVE_GPIO_9280     5
238c2ecf20Sopenharmony_ci#define ATH_BTACTIVE_GPIO_9280       6
248c2ecf20Sopenharmony_ci#define ATH_BTPRIORITY_GPIO_9285     7
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#define ATH_WLANACTIVE_GPIO_9300     5
278c2ecf20Sopenharmony_ci#define ATH_BTACTIVE_GPIO_9300       4
288c2ecf20Sopenharmony_ci#define ATH_BTPRIORITY_GPIO_9300     8
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci#define ATH_BTCOEX_DEF_BT_PERIOD  45
318c2ecf20Sopenharmony_ci#define ATH_BTCOEX_DEF_DUTY_CYCLE 55
328c2ecf20Sopenharmony_ci#define ATH_BTCOEX_BTSCAN_DUTY_CYCLE 90
338c2ecf20Sopenharmony_ci#define ATH_BTCOEX_BMISS_THRESH   50
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci#define ATH_BT_PRIORITY_TIME_THRESHOLD 1000 /* ms */
368c2ecf20Sopenharmony_ci#define ATH_BT_CNT_THRESHOLD	       3
378c2ecf20Sopenharmony_ci#define ATH_BT_CNT_SCAN_THRESHOLD      15
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci#define ATH_BTCOEX_RX_WAIT_TIME       100
408c2ecf20Sopenharmony_ci#define ATH_BTCOEX_STOMP_FTP_THRESH   5
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci#define ATH_BTCOEX_HT20_MAX_TXPOWER   0x14
438c2ecf20Sopenharmony_ci#define ATH_BTCOEX_HT40_MAX_TXPOWER   0x10
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci#define AR9300_NUM_BT_WEIGHTS   4
468c2ecf20Sopenharmony_ci#define AR9300_NUM_WLAN_WEIGHTS 4
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci#define ATH_AIC_MAX_BT_CHANNEL  79
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci/* Defines the BT AR_BT_COEX_WGHT used */
518c2ecf20Sopenharmony_cienum ath_stomp_type {
528c2ecf20Sopenharmony_ci	ATH_BTCOEX_STOMP_ALL,
538c2ecf20Sopenharmony_ci	ATH_BTCOEX_STOMP_LOW,
548c2ecf20Sopenharmony_ci	ATH_BTCOEX_STOMP_NONE,
558c2ecf20Sopenharmony_ci	ATH_BTCOEX_STOMP_LOW_FTP,
568c2ecf20Sopenharmony_ci	ATH_BTCOEX_STOMP_AUDIO,
578c2ecf20Sopenharmony_ci	ATH_BTCOEX_STOMP_MAX
588c2ecf20Sopenharmony_ci};
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_cienum ath_btcoex_scheme {
618c2ecf20Sopenharmony_ci	ATH_BTCOEX_CFG_NONE,
628c2ecf20Sopenharmony_ci	ATH_BTCOEX_CFG_2WIRE,
638c2ecf20Sopenharmony_ci	ATH_BTCOEX_CFG_3WIRE,
648c2ecf20Sopenharmony_ci	ATH_BTCOEX_CFG_MCI,
658c2ecf20Sopenharmony_ci};
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_cistruct ath9k_hw_mci {
688c2ecf20Sopenharmony_ci	u32 raw_intr;
698c2ecf20Sopenharmony_ci	u32 rx_msg_intr;
708c2ecf20Sopenharmony_ci	u32 cont_status;
718c2ecf20Sopenharmony_ci	u32 gpm_addr;
728c2ecf20Sopenharmony_ci	u32 gpm_len;
738c2ecf20Sopenharmony_ci	u32 gpm_idx;
748c2ecf20Sopenharmony_ci	u32 sched_addr;
758c2ecf20Sopenharmony_ci	u32 wlan_channels[4];
768c2ecf20Sopenharmony_ci	u32 wlan_cal_seq;
778c2ecf20Sopenharmony_ci	u32 wlan_cal_done;
788c2ecf20Sopenharmony_ci	u32 config;
798c2ecf20Sopenharmony_ci	u8 *gpm_buf;
808c2ecf20Sopenharmony_ci	bool ready;
818c2ecf20Sopenharmony_ci	bool update_2g5g;
828c2ecf20Sopenharmony_ci	bool is_2g;
838c2ecf20Sopenharmony_ci	bool query_bt;
848c2ecf20Sopenharmony_ci	bool unhalt_bt_gpm; /* need send UNHALT */
858c2ecf20Sopenharmony_ci	bool halted_bt_gpm; /* HALT sent */
868c2ecf20Sopenharmony_ci	bool need_flush_btinfo;
878c2ecf20Sopenharmony_ci	bool bt_version_known;
888c2ecf20Sopenharmony_ci	bool wlan_channels_update;
898c2ecf20Sopenharmony_ci	u8 wlan_ver_major;
908c2ecf20Sopenharmony_ci	u8 wlan_ver_minor;
918c2ecf20Sopenharmony_ci	u8 bt_ver_major;
928c2ecf20Sopenharmony_ci	u8 bt_ver_minor;
938c2ecf20Sopenharmony_ci	u8 bt_state;
948c2ecf20Sopenharmony_ci	u8 stomp_ftp;
958c2ecf20Sopenharmony_ci	bool concur_tx;
968c2ecf20Sopenharmony_ci	u32 last_recovery;
978c2ecf20Sopenharmony_ci};
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_cistruct ath9k_hw_aic {
1008c2ecf20Sopenharmony_ci	bool aic_enabled;
1018c2ecf20Sopenharmony_ci	u8 aic_cal_state;
1028c2ecf20Sopenharmony_ci	u8 aic_caled_chan;
1038c2ecf20Sopenharmony_ci	u32 aic_sram[ATH_AIC_MAX_BT_CHANNEL];
1048c2ecf20Sopenharmony_ci	u32 aic_cal_start_time;
1058c2ecf20Sopenharmony_ci};
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_cistruct ath_btcoex_hw {
1088c2ecf20Sopenharmony_ci	enum ath_btcoex_scheme scheme;
1098c2ecf20Sopenharmony_ci	struct ath9k_hw_mci mci;
1108c2ecf20Sopenharmony_ci	struct ath9k_hw_aic aic;
1118c2ecf20Sopenharmony_ci	bool enabled;
1128c2ecf20Sopenharmony_ci	u8 wlanactive_gpio;
1138c2ecf20Sopenharmony_ci	u8 btactive_gpio;
1148c2ecf20Sopenharmony_ci	u8 btpriority_gpio;
1158c2ecf20Sopenharmony_ci	u32 bt_coex_mode; 	/* Register setting for AR_BT_COEX_MODE */
1168c2ecf20Sopenharmony_ci	u32 bt_coex_weights; 	/* Register setting for AR_BT_COEX_WEIGHT */
1178c2ecf20Sopenharmony_ci	u32 bt_coex_mode2; 	/* Register setting for AR_BT_COEX_MODE2 */
1188c2ecf20Sopenharmony_ci	u32 bt_coex_mode3;	/* Register setting for AR_BT_COEX_MODE3 */
1198c2ecf20Sopenharmony_ci	u32 bt_weight[AR9300_NUM_BT_WEIGHTS];
1208c2ecf20Sopenharmony_ci	u32 wlan_weight[AR9300_NUM_WLAN_WEIGHTS];
1218c2ecf20Sopenharmony_ci	u8 tx_prio[ATH_BTCOEX_STOMP_MAX];
1228c2ecf20Sopenharmony_ci};
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_civoid ath9k_hw_btcoex_init_scheme(struct ath_hw *ah);
1258c2ecf20Sopenharmony_civoid ath9k_hw_btcoex_init_2wire(struct ath_hw *ah);
1268c2ecf20Sopenharmony_civoid ath9k_hw_btcoex_init_3wire(struct ath_hw *ah);
1278c2ecf20Sopenharmony_civoid ath9k_hw_btcoex_deinit(struct ath_hw *ah);
1288c2ecf20Sopenharmony_civoid ath9k_hw_btcoex_init_mci(struct ath_hw *ah);
1298c2ecf20Sopenharmony_civoid ath9k_hw_init_btcoex_hw(struct ath_hw *ah, int qnum);
1308c2ecf20Sopenharmony_civoid ath9k_hw_btcoex_set_weight(struct ath_hw *ah,
1318c2ecf20Sopenharmony_ci				u32 bt_weight,
1328c2ecf20Sopenharmony_ci				u32 wlan_weight,
1338c2ecf20Sopenharmony_ci				enum ath_stomp_type stomp_type);
1348c2ecf20Sopenharmony_civoid ath9k_hw_btcoex_disable(struct ath_hw *ah);
1358c2ecf20Sopenharmony_civoid ath9k_hw_btcoex_bt_stomp(struct ath_hw *ah,
1368c2ecf20Sopenharmony_ci			      enum ath_stomp_type stomp_type);
1378c2ecf20Sopenharmony_civoid ath9k_hw_btcoex_set_concur_txprio(struct ath_hw *ah, u8 *stomp_txprio);
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_ci#endif
140