1 /****************************************************************************** 2 * 3 * Copyright(c) 2012 Realtek Corporation. 4 * 5 * This program is free software; you can redistribute it and/or modify it 6 * under the terms of version 2 of the GNU General Public License as 7 * published by the Free Software Foundation. 8 * 9 * This program is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 * more details. 13 * 14 * The full GNU General Public License is included in this distribution in the 15 * file called LICENSE. 16 * 17 * Contact Information: 18 * wlanfae <wlanfae@realtek.com> 19 * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, 20 * Hsinchu 300, Taiwan. 21 * 22 * Larry Finger <Larry.Finger@lwfinger.net> 23 * 24 *****************************************************************************/ 25 26 /*=========================================== 27 * The following is for 8821A 2Ant BT Co-exist definition 28 *=========================================== 29 */ 30 #define BT_INFO_8821A_2ANT_B_FTP BIT7 31 #define BT_INFO_8821A_2ANT_B_A2DP BIT6 32 #define BT_INFO_8821A_2ANT_B_HID BIT5 33 #define BT_INFO_8821A_2ANT_B_SCO_BUSY BIT4 34 #define BT_INFO_8821A_2ANT_B_ACL_BUSY BIT3 35 #define BT_INFO_8821A_2ANT_B_INQ_PAGE BIT2 36 #define BT_INFO_8821A_2ANT_B_SCO_ESCO BIT1 37 #define BT_INFO_8821A_2ANT_B_CONNECTION BIT0 38 39 #define BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT 2 40 41 /* WiFi RSSI Threshold for 2-Ant TDMA/1-Ant PS-TDMA translation */ 42 #define BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES 42 43 /* BT RSSI Threshold for 2-Ant TDMA/1-Ant PS-TDMA translation */ 44 #define BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES 46 45 46 enum _BT_INFO_SRC_8821A_2ANT { 47 BT_INFO_SRC_8821A_2ANT_WIFI_FW = 0x0, 48 BT_INFO_SRC_8821A_2ANT_BT_RSP = 0x1, 49 BT_INFO_SRC_8821A_2ANT_BT_ACTIVE_SEND = 0x2, 50 BT_INFO_SRC_8821A_2ANT_MAX 51 }; 52 53 enum _BT_8821A_2ANT_BT_STATUS { 54 BT_8821A_2ANT_BT_STATUS_IDLE = 0x0, 55 BT_8821A_2ANT_BT_STATUS_CON_IDLE = 0x1, 56 BT_8821A_2ANT_BT_STATUS_NON_IDLE = 0x2, 57 BT_8821A_2ANT_BT_STATUS_MAX 58 }; 59 60 enum _BT_8821A_2ANT_COEX_ALGO { 61 BT_8821A_2ANT_COEX_ALGO_UNDEFINED = 0x0, 62 BT_8821A_2ANT_COEX_ALGO_SCO = 0x1, 63 BT_8821A_2ANT_COEX_ALGO_HID = 0x2, 64 BT_8821A_2ANT_COEX_ALGO_A2DP = 0x3, 65 BT_8821A_2ANT_COEX_ALGO_A2DP_PANHS = 0x4, 66 BT_8821A_2ANT_COEX_ALGO_PANEDR = 0x5, 67 BT_8821A_2ANT_COEX_ALGO_PANHS = 0x6, 68 BT_8821A_2ANT_COEX_ALGO_PANEDR_A2DP = 0x7, 69 BT_8821A_2ANT_COEX_ALGO_PANEDR_HID = 0x8, 70 BT_8821A_2ANT_COEX_ALGO_HID_A2DP_PANEDR = 0x9, 71 BT_8821A_2ANT_COEX_ALGO_HID_A2DP = 0xa, 72 BT_8821A_2ANT_COEX_ALGO_MAX = 0xb, 73 }; 74 75 struct coex_dm_8821a_2ant { 76 /* fw mechanism */ 77 bool pre_dec_bt_pwr_lvl; 78 bool cur_dec_bt_pwr_lvl; 79 bool pre_bt_lna_constrain; 80 bool cur_bt_lna_constrain; 81 u8 pre_bt_psd_mode; 82 u8 cur_bt_psd_mode; 83 u8 pre_fw_dac_swing_lvl; 84 u8 cur_fw_dac_swing_lvl; 85 bool cur_ignore_wlan_act; 86 bool pre_ignore_wlan_act; 87 u8 pre_ps_tdma; 88 u8 cur_ps_tdma; 89 u8 ps_tdma_para[5]; 90 u8 ps_tdma_du_adj_type; 91 bool reset_tdma_adjust; 92 bool auto_tdma_adjust; 93 bool pre_ps_tdma_on; 94 bool cur_ps_tdma_on; 95 bool pre_bt_auto_report; 96 bool cur_bt_auto_report; 97 98 /* sw mechanism */ 99 bool pre_rf_rx_lpf_shrink; 100 bool cur_rf_rx_lpf_shrink; 101 u32 bt_rf0x1e_backup; 102 bool pre_low_penalty_ra; 103 bool cur_low_penalty_ra; 104 bool pre_dac_swing_on; 105 u32 pre_dac_swing_lvl; 106 bool cur_dac_swing_on; 107 u32 cur_dac_swing_lvl; 108 bool pre_adc_back_off; 109 bool cur_adc_back_off; 110 bool pre_agc_table_en; 111 bool cur_agc_table_en; 112 u32 pre_val0x6c0; 113 u32 cur_val0x6c0; 114 u32 pre_val0x6c4; 115 u32 cur_val0x6c4; 116 u32 pre_val0x6c8; 117 u32 cur_val0x6c8; 118 u8 pre_val0x6cc; 119 u8 cur_val0x6cc; 120 bool limited_dig; 121 122 /* algorithm related */ 123 u8 pre_algorithm; 124 u8 cur_algorithm; 125 u8 bt_status; 126 u8 wifi_chnl_info[3]; 127 u8 pre_lps; 128 u8 cur_lps; 129 u8 pre_rpwm; 130 u8 cur_rpwm; 131 }; 132 133 struct coex_sta_8821a_2ant { 134 bool bt_link_exist; 135 bool sco_exist; 136 bool a2dp_exist; 137 bool hid_exist; 138 bool pan_exist; 139 bool under_lps; 140 bool under_ips; 141 u32 high_priority_tx; 142 u32 high_priority_rx; 143 u32 low_priority_tx; 144 u32 low_priority_rx; 145 u8 bt_rssi; 146 u8 pre_bt_rssi_state; 147 u8 pre_wifi_rssi_state[4]; 148 bool c2h_bt_info_req_sent; 149 u8 bt_info_c2h[BT_INFO_SRC_8821A_2ANT_MAX][10]; 150 u32 bt_info_c2h_cnt[BT_INFO_SRC_8821A_2ANT_MAX]; 151 bool c2h_bt_inquiry_page; 152 u8 bt_retry_cnt; 153 u8 bt_info_ext; 154 155 u32 crc_ok_cck; 156 u32 crc_ok_11g; 157 u32 crc_ok_11n; 158 u32 crc_ok_11n_agg; 159 160 u32 crc_err_cck; 161 u32 crc_err_11g; 162 u32 crc_err_11n; 163 u32 crc_err_11n_agg; 164 165 u8 coex_table_type; 166 bool force_lps_on; 167 }; 168 169 /*=========================================== 170 * The following is interface which will notify coex module. 171 *=========================================== 172 */ 173 void 174 ex_halbtc8821a2ant_init_hwconfig( 175 struct btc_coexist *btcoexist 176 ); 177 void 178 ex_halbtc8821a2ant_init_coex_dm( 179 struct btc_coexist *btcoexist 180 ); 181 void 182 ex_halbtc8821a2ant_ips_notify( 183 struct btc_coexist *btcoexist, 184 u8 type 185 ); 186 void 187 ex_halbtc8821a2ant_lps_notify( 188 struct btc_coexist *btcoexist, 189 u8 type 190 ); 191 void 192 ex_halbtc8821a2ant_scan_notify( 193 struct btc_coexist *btcoexist, 194 u8 type 195 ); 196 void 197 ex_halbtc8821a2ant_connect_notify( 198 struct btc_coexist *btcoexist, 199 u8 type 200 ); 201 void 202 ex_halbtc8821a2ant_media_status_notify( 203 struct btc_coexist *btcoexist, 204 u8 type 205 ); 206 void 207 ex_halbtc8821a2ant_special_packet_notify( 208 struct btc_coexist *btcoexist, 209 u8 type 210 ); 211 void 212 ex_halbtc8821a2ant_bt_info_notify( 213 struct btc_coexist *btcoexist, 214 u8 *tmp_buf, 215 u8 length 216 ); 217 void 218 ex_halbtc8821a2ant_halt_notify( 219 struct btc_coexist *btcoexist 220 ); 221 void 222 ex_halbtc8821a2ant_periodical( 223 struct btc_coexist *btcoexist 224 ); 225 void 226 ex_halbtc8821a2ant_display_coex_info( 227 struct btc_coexist *btcoexist 228 ); 229