1*8c086312SLarry Finger /* SPDX-License-Identifier: GPL-2.0 */ 2*8c086312SLarry Finger /* Copyright(c) 2012 Realtek Corporation.*/ 3f1d2b4d3SLarry Finger 4f1d2b4d3SLarry Finger /*=========================================== 5f1d2b4d3SLarry Finger * The following is for 8821A 2Ant BT Co-exist definition 6f1d2b4d3SLarry Finger *=========================================== 7f1d2b4d3SLarry Finger */ 8f1d2b4d3SLarry Finger #define BT_INFO_8821A_2ANT_B_FTP BIT7 9f1d2b4d3SLarry Finger #define BT_INFO_8821A_2ANT_B_A2DP BIT6 10f1d2b4d3SLarry Finger #define BT_INFO_8821A_2ANT_B_HID BIT5 11f1d2b4d3SLarry Finger #define BT_INFO_8821A_2ANT_B_SCO_BUSY BIT4 12f1d2b4d3SLarry Finger #define BT_INFO_8821A_2ANT_B_ACL_BUSY BIT3 13f1d2b4d3SLarry Finger #define BT_INFO_8821A_2ANT_B_INQ_PAGE BIT2 14f1d2b4d3SLarry Finger #define BT_INFO_8821A_2ANT_B_SCO_ESCO BIT1 15f1d2b4d3SLarry Finger #define BT_INFO_8821A_2ANT_B_CONNECTION BIT0 16f1d2b4d3SLarry Finger 17f1d2b4d3SLarry Finger #define BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT 2 18f1d2b4d3SLarry Finger 193fd7ba4cSYan-Hsuan Chuang /* WiFi RSSI Threshold for 2-Ant TDMA/1-Ant PS-TDMA translation */ 203fd7ba4cSYan-Hsuan Chuang #define BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES 42 213fd7ba4cSYan-Hsuan Chuang /* BT RSSI Threshold for 2-Ant TDMA/1-Ant PS-TDMA translation */ 223fd7ba4cSYan-Hsuan Chuang #define BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES 46 233fd7ba4cSYan-Hsuan Chuang 24f1d2b4d3SLarry Finger enum _BT_INFO_SRC_8821A_2ANT { 25f1d2b4d3SLarry Finger BT_INFO_SRC_8821A_2ANT_WIFI_FW = 0x0, 26f1d2b4d3SLarry Finger BT_INFO_SRC_8821A_2ANT_BT_RSP = 0x1, 27f1d2b4d3SLarry Finger BT_INFO_SRC_8821A_2ANT_BT_ACTIVE_SEND = 0x2, 28f1d2b4d3SLarry Finger BT_INFO_SRC_8821A_2ANT_MAX 29f1d2b4d3SLarry Finger }; 30f1d2b4d3SLarry Finger 31f1d2b4d3SLarry Finger enum _BT_8821A_2ANT_BT_STATUS { 32f1d2b4d3SLarry Finger BT_8821A_2ANT_BT_STATUS_IDLE = 0x0, 33f1d2b4d3SLarry Finger BT_8821A_2ANT_BT_STATUS_CON_IDLE = 0x1, 34f1d2b4d3SLarry Finger BT_8821A_2ANT_BT_STATUS_NON_IDLE = 0x2, 35a3b2ba86SYan-Hsuan Chuang BT_8821A_2ANT_BT_STATUS_ACL_BUSY = 0x3, 36a3b2ba86SYan-Hsuan Chuang BT_8821A_2ANT_BT_STATUS_SCO_BUSY = 0x4, 37a3b2ba86SYan-Hsuan Chuang BT_8821A_2ANT_BT_STATUS_ACL_SCO_BUSY = 0x5, 38f1d2b4d3SLarry Finger BT_8821A_2ANT_BT_STATUS_MAX 39f1d2b4d3SLarry Finger }; 40f1d2b4d3SLarry Finger 41f1d2b4d3SLarry Finger enum _BT_8821A_2ANT_COEX_ALGO { 42f1d2b4d3SLarry Finger BT_8821A_2ANT_COEX_ALGO_UNDEFINED = 0x0, 43f1d2b4d3SLarry Finger BT_8821A_2ANT_COEX_ALGO_SCO = 0x1, 44f1d2b4d3SLarry Finger BT_8821A_2ANT_COEX_ALGO_HID = 0x2, 45f1d2b4d3SLarry Finger BT_8821A_2ANT_COEX_ALGO_A2DP = 0x3, 46f1d2b4d3SLarry Finger BT_8821A_2ANT_COEX_ALGO_A2DP_PANHS = 0x4, 47f1d2b4d3SLarry Finger BT_8821A_2ANT_COEX_ALGO_PANEDR = 0x5, 48f1d2b4d3SLarry Finger BT_8821A_2ANT_COEX_ALGO_PANHS = 0x6, 49f1d2b4d3SLarry Finger BT_8821A_2ANT_COEX_ALGO_PANEDR_A2DP = 0x7, 50f1d2b4d3SLarry Finger BT_8821A_2ANT_COEX_ALGO_PANEDR_HID = 0x8, 51f1d2b4d3SLarry Finger BT_8821A_2ANT_COEX_ALGO_HID_A2DP_PANEDR = 0x9, 52f1d2b4d3SLarry Finger BT_8821A_2ANT_COEX_ALGO_HID_A2DP = 0xa, 53f1d2b4d3SLarry Finger BT_8821A_2ANT_COEX_ALGO_MAX = 0xb, 54f1d2b4d3SLarry Finger }; 55f1d2b4d3SLarry Finger 56f1d2b4d3SLarry Finger struct coex_dm_8821a_2ant { 57f1d2b4d3SLarry Finger /* fw mechanism */ 58aed6b11eSYan-Hsuan Chuang bool pre_dec_bt_pwr_lvl; 59aed6b11eSYan-Hsuan Chuang bool cur_dec_bt_pwr_lvl; 60f1d2b4d3SLarry Finger u8 pre_fw_dac_swing_lvl; 61f1d2b4d3SLarry Finger u8 cur_fw_dac_swing_lvl; 62f1d2b4d3SLarry Finger bool cur_ignore_wlan_act; 63f1d2b4d3SLarry Finger bool pre_ignore_wlan_act; 64f1d2b4d3SLarry Finger u8 pre_ps_tdma; 65f1d2b4d3SLarry Finger u8 cur_ps_tdma; 66f1d2b4d3SLarry Finger u8 ps_tdma_para[5]; 673f775d5cSYan-Hsuan Chuang u8 ps_tdma_du_adj_type; 68f1d2b4d3SLarry Finger bool reset_tdma_adjust; 693f775d5cSYan-Hsuan Chuang bool auto_tdma_adjust; 70f1d2b4d3SLarry Finger bool pre_ps_tdma_on; 71f1d2b4d3SLarry Finger bool cur_ps_tdma_on; 72f1d2b4d3SLarry Finger bool pre_bt_auto_report; 73f1d2b4d3SLarry Finger bool cur_bt_auto_report; 74f1d2b4d3SLarry Finger 75f1d2b4d3SLarry Finger /* sw mechanism */ 76f1d2b4d3SLarry Finger bool pre_rf_rx_lpf_shrink; 77f1d2b4d3SLarry Finger bool cur_rf_rx_lpf_shrink; 78f1d2b4d3SLarry Finger u32 bt_rf0x1e_backup; 79f1d2b4d3SLarry Finger bool pre_low_penalty_ra; 80f1d2b4d3SLarry Finger bool cur_low_penalty_ra; 81f1d2b4d3SLarry Finger bool pre_dac_swing_on; 82f1d2b4d3SLarry Finger u32 pre_dac_swing_lvl; 83f1d2b4d3SLarry Finger bool cur_dac_swing_on; 84f1d2b4d3SLarry Finger u32 cur_dac_swing_lvl; 85f1d2b4d3SLarry Finger bool pre_adc_back_off; 86f1d2b4d3SLarry Finger bool cur_adc_back_off; 87f1d2b4d3SLarry Finger bool pre_agc_table_en; 88f1d2b4d3SLarry Finger bool cur_agc_table_en; 89f1d2b4d3SLarry Finger u32 pre_val0x6c0; 90f1d2b4d3SLarry Finger u32 cur_val0x6c0; 91f1d2b4d3SLarry Finger u32 pre_val0x6c4; 92f1d2b4d3SLarry Finger u32 cur_val0x6c4; 93f1d2b4d3SLarry Finger u32 pre_val0x6c8; 94f1d2b4d3SLarry Finger u32 cur_val0x6c8; 95f1d2b4d3SLarry Finger u8 pre_val0x6cc; 96f1d2b4d3SLarry Finger u8 cur_val0x6cc; 97f1d2b4d3SLarry Finger bool limited_dig; 98f1d2b4d3SLarry Finger 99f1d2b4d3SLarry Finger /* algorithm related */ 100f1d2b4d3SLarry Finger u8 pre_algorithm; 101f1d2b4d3SLarry Finger u8 cur_algorithm; 102f1d2b4d3SLarry Finger u8 bt_status; 103f1d2b4d3SLarry Finger u8 wifi_chnl_info[3]; 104d9158ea1SYan-Hsuan Chuang u8 pre_lps; 105d9158ea1SYan-Hsuan Chuang u8 cur_lps; 106d9158ea1SYan-Hsuan Chuang u8 pre_rpwm; 107d9158ea1SYan-Hsuan Chuang u8 cur_rpwm; 108f1d2b4d3SLarry Finger }; 109f1d2b4d3SLarry Finger 110f1d2b4d3SLarry Finger struct coex_sta_8821a_2ant { 111f1d2b4d3SLarry Finger bool bt_link_exist; 112f1d2b4d3SLarry Finger bool sco_exist; 113f1d2b4d3SLarry Finger bool a2dp_exist; 114f1d2b4d3SLarry Finger bool hid_exist; 115f1d2b4d3SLarry Finger bool pan_exist; 116f1d2b4d3SLarry Finger bool under_lps; 117f1d2b4d3SLarry Finger bool under_ips; 118f1d2b4d3SLarry Finger u32 high_priority_tx; 119f1d2b4d3SLarry Finger u32 high_priority_rx; 120f1d2b4d3SLarry Finger u32 low_priority_tx; 121f1d2b4d3SLarry Finger u32 low_priority_rx; 122f1d2b4d3SLarry Finger u8 bt_rssi; 123a3b2ba86SYan-Hsuan Chuang bool bt_tx_rx_mask; 124f1d2b4d3SLarry Finger u8 pre_bt_rssi_state; 125f1d2b4d3SLarry Finger u8 pre_wifi_rssi_state[4]; 126f1d2b4d3SLarry Finger bool c2h_bt_info_req_sent; 127f1d2b4d3SLarry Finger u8 bt_info_c2h[BT_INFO_SRC_8821A_2ANT_MAX][10]; 128f1d2b4d3SLarry Finger u32 bt_info_c2h_cnt[BT_INFO_SRC_8821A_2ANT_MAX]; 129f1d2b4d3SLarry Finger bool c2h_bt_inquiry_page; 130f1d2b4d3SLarry Finger u8 bt_retry_cnt; 131f1d2b4d3SLarry Finger u8 bt_info_ext; 132eebc5878SYan-Hsuan Chuang 133eebc5878SYan-Hsuan Chuang u32 crc_ok_cck; 134eebc5878SYan-Hsuan Chuang u32 crc_ok_11g; 135eebc5878SYan-Hsuan Chuang u32 crc_ok_11n; 136eebc5878SYan-Hsuan Chuang u32 crc_ok_11n_agg; 137eebc5878SYan-Hsuan Chuang 138eebc5878SYan-Hsuan Chuang u32 crc_err_cck; 139eebc5878SYan-Hsuan Chuang u32 crc_err_11g; 140eebc5878SYan-Hsuan Chuang u32 crc_err_11n; 141eebc5878SYan-Hsuan Chuang u32 crc_err_11n_agg; 142d4acd81eSYan-Hsuan Chuang 143d4acd81eSYan-Hsuan Chuang u8 coex_table_type; 144d9158ea1SYan-Hsuan Chuang bool force_lps_on; 145e7dc3203SYan-Hsuan Chuang 146e7dc3203SYan-Hsuan Chuang u8 dis_ver_info_cnt; 147f1d2b4d3SLarry Finger }; 148f1d2b4d3SLarry Finger 149f1d2b4d3SLarry Finger /*=========================================== 150f1d2b4d3SLarry Finger * The following is interface which will notify coex module. 151f1d2b4d3SLarry Finger *=========================================== 152f1d2b4d3SLarry Finger */ 153f1d2b4d3SLarry Finger void 154753c953bSYan-Hsuan Chuang ex_btc8821a2ant_init_hwconfig( 155f1d2b4d3SLarry Finger struct btc_coexist *btcoexist 156f1d2b4d3SLarry Finger ); 157f1d2b4d3SLarry Finger void 158753c953bSYan-Hsuan Chuang ex_btc8821a2ant_init_coex_dm( 159f1d2b4d3SLarry Finger struct btc_coexist *btcoexist 160f1d2b4d3SLarry Finger ); 161f1d2b4d3SLarry Finger void 162753c953bSYan-Hsuan Chuang ex_btc8821a2ant_ips_notify( 163f1d2b4d3SLarry Finger struct btc_coexist *btcoexist, 164f1d2b4d3SLarry Finger u8 type 165f1d2b4d3SLarry Finger ); 166f1d2b4d3SLarry Finger void 167753c953bSYan-Hsuan Chuang ex_btc8821a2ant_lps_notify( 168f1d2b4d3SLarry Finger struct btc_coexist *btcoexist, 169f1d2b4d3SLarry Finger u8 type 170f1d2b4d3SLarry Finger ); 171f1d2b4d3SLarry Finger void 172753c953bSYan-Hsuan Chuang ex_btc8821a2ant_scan_notify( 173f1d2b4d3SLarry Finger struct btc_coexist *btcoexist, 174f1d2b4d3SLarry Finger u8 type 175f1d2b4d3SLarry Finger ); 176f1d2b4d3SLarry Finger void 177753c953bSYan-Hsuan Chuang ex_btc8821a2ant_connect_notify( 178f1d2b4d3SLarry Finger struct btc_coexist *btcoexist, 179f1d2b4d3SLarry Finger u8 type 180f1d2b4d3SLarry Finger ); 181f1d2b4d3SLarry Finger void 182753c953bSYan-Hsuan Chuang ex_btc8821a2ant_media_status_notify( 183f1d2b4d3SLarry Finger struct btc_coexist *btcoexist, 184f1d2b4d3SLarry Finger u8 type 185f1d2b4d3SLarry Finger ); 186f1d2b4d3SLarry Finger void 187753c953bSYan-Hsuan Chuang ex_btc8821a2ant_special_packet_notify( 188f1d2b4d3SLarry Finger struct btc_coexist *btcoexist, 189f1d2b4d3SLarry Finger u8 type 190f1d2b4d3SLarry Finger ); 191f1d2b4d3SLarry Finger void 192753c953bSYan-Hsuan Chuang ex_btc8821a2ant_bt_info_notify( 193f1d2b4d3SLarry Finger struct btc_coexist *btcoexist, 194f1d2b4d3SLarry Finger u8 *tmp_buf, 195f1d2b4d3SLarry Finger u8 length 196f1d2b4d3SLarry Finger ); 197f1d2b4d3SLarry Finger void 198753c953bSYan-Hsuan Chuang ex_btc8821a2ant_halt_notify( 199f1d2b4d3SLarry Finger struct btc_coexist *btcoexist 200f1d2b4d3SLarry Finger ); 201f1d2b4d3SLarry Finger void 202753c953bSYan-Hsuan Chuang ex_btc8821a2ant_periodical( 203f1d2b4d3SLarry Finger struct btc_coexist *btcoexist 204f1d2b4d3SLarry Finger ); 205f1d2b4d3SLarry Finger void 206753c953bSYan-Hsuan Chuang ex_btc8821a2ant_display_coex_info( 20708431b62SPing-Ke Shih struct btc_coexist *btcoexist, 20808431b62SPing-Ke Shih struct seq_file *m 209f1d2b4d3SLarry Finger ); 2106fbbc82aSYan-Hsuan Chuang void ex_btc8821a2ant_pnp_notify(struct btc_coexist *btcoexist, u8 pnp_state); 2116fbbc82aSYan-Hsuan Chuang void ex_btc8821a2ant_pre_load_firmware(struct btc_coexist *btcoexist); 212