1*93121c03SLarry Finger /* SPDX-License-Identifier: GPL-2.0 */ 2*93121c03SLarry Finger /* Copyright(c) 2009-2014 Realtek Corporation.*/ 3f1d2b4d3SLarry Finger 4f1d2b4d3SLarry Finger #ifndef __RTL8723BE_DM_H__ 5f1d2b4d3SLarry Finger #define __RTL8723BE_DM_H__ 6f1d2b4d3SLarry Finger 7f1d2b4d3SLarry Finger #define MAIN_ANT 0 8f1d2b4d3SLarry Finger #define AUX_ANT 1 9f1d2b4d3SLarry Finger #define MAIN_ANT_CG_TRX 1 10f1d2b4d3SLarry Finger #define AUX_ANT_CG_TRX 0 11f1d2b4d3SLarry Finger #define MAIN_ANT_CGCS_RX 0 12f1d2b4d3SLarry Finger #define AUX_ANT_CGCS_RX 1 13f1d2b4d3SLarry Finger 14f1d2b4d3SLarry Finger #define TXSCALE_TABLE_SIZE 30 15f1d2b4d3SLarry Finger 16f1d2b4d3SLarry Finger /*RF REG LIST*/ 17f1d2b4d3SLarry Finger #define DM_REG_RF_MODE_11N 0x00 18f1d2b4d3SLarry Finger #define DM_REG_RF_0B_11N 0x0B 19f1d2b4d3SLarry Finger #define DM_REG_CHNBW_11N 0x18 20f1d2b4d3SLarry Finger #define DM_REG_T_METER_11N 0x24 21f1d2b4d3SLarry Finger #define DM_REG_RF_25_11N 0x25 22f1d2b4d3SLarry Finger #define DM_REG_RF_26_11N 0x26 23f1d2b4d3SLarry Finger #define DM_REG_RF_27_11N 0x27 24f1d2b4d3SLarry Finger #define DM_REG_RF_2B_11N 0x2B 25f1d2b4d3SLarry Finger #define DM_REG_RF_2C_11N 0x2C 26f1d2b4d3SLarry Finger #define DM_REG_RXRF_A3_11N 0x3C 27f1d2b4d3SLarry Finger #define DM_REG_T_METER_92D_11N 0x42 28f1d2b4d3SLarry Finger #define DM_REG_T_METER_88E_11N 0x42 29f1d2b4d3SLarry Finger 30f1d2b4d3SLarry Finger /*BB REG LIST*/ 31f1d2b4d3SLarry Finger /*PAGE 8 */ 32f1d2b4d3SLarry Finger #define DM_REG_BB_CTRL_11N 0x800 33f1d2b4d3SLarry Finger #define DM_REG_RF_PIN_11N 0x804 34f1d2b4d3SLarry Finger #define DM_REG_PSD_CTRL_11N 0x808 35f1d2b4d3SLarry Finger #define DM_REG_TX_ANT_CTRL_11N 0x80C 36f1d2b4d3SLarry Finger #define DM_REG_BB_PWR_SAV5_11N 0x818 37f1d2b4d3SLarry Finger #define DM_REG_CCK_RPT_FORMAT_11N 0x824 38f1d2b4d3SLarry Finger #define DM_REG_RX_DEFUALT_A_11N 0x858 39f1d2b4d3SLarry Finger #define DM_REG_RX_DEFUALT_B_11N 0x85A 40f1d2b4d3SLarry Finger #define DM_REG_BB_PWR_SAV3_11N 0x85C 41f1d2b4d3SLarry Finger #define DM_REG_ANTSEL_CTRL_11N 0x860 42f1d2b4d3SLarry Finger #define DM_REG_RX_ANT_CTRL_11N 0x864 43f1d2b4d3SLarry Finger #define DM_REG_PIN_CTRL_11N 0x870 44f1d2b4d3SLarry Finger #define DM_REG_BB_PWR_SAV1_11N 0x874 45f1d2b4d3SLarry Finger #define DM_REG_ANTSEL_PATH_11N 0x878 46f1d2b4d3SLarry Finger #define DM_REG_BB_3WIRE_11N 0x88C 47f1d2b4d3SLarry Finger #define DM_REG_SC_CNT_11N 0x8C4 48f1d2b4d3SLarry Finger #define DM_REG_PSD_DATA_11N 0x8B4 49f1d2b4d3SLarry Finger /*PAGE 9*/ 50f1d2b4d3SLarry Finger #define DM_REG_ANT_MAPPING1_11N 0x914 51f1d2b4d3SLarry Finger #define DM_REG_ANT_MAPPING2_11N 0x918 52f1d2b4d3SLarry Finger /*PAGE A*/ 53f1d2b4d3SLarry Finger #define DM_REG_CCK_ANTDIV_PARA1_11N 0xA00 54f1d2b4d3SLarry Finger #define DM_REG_CCK_CCA_11N 0xA0A 55f1d2b4d3SLarry Finger #define DM_REG_CCK_ANTDIV_PARA2_11N 0xA0C 56f1d2b4d3SLarry Finger #define DM_REG_CCK_ANTDIV_PARA3_11N 0xA10 57f1d2b4d3SLarry Finger #define DM_REG_CCK_ANTDIV_PARA4_11N 0xA14 58f1d2b4d3SLarry Finger #define DM_REG_CCK_FILTER_PARA1_11N 0xA22 59f1d2b4d3SLarry Finger #define DM_REG_CCK_FILTER_PARA2_11N 0xA23 60f1d2b4d3SLarry Finger #define DM_REG_CCK_FILTER_PARA3_11N 0xA24 61f1d2b4d3SLarry Finger #define DM_REG_CCK_FILTER_PARA4_11N 0xA25 62f1d2b4d3SLarry Finger #define DM_REG_CCK_FILTER_PARA5_11N 0xA26 63f1d2b4d3SLarry Finger #define DM_REG_CCK_FILTER_PARA6_11N 0xA27 64f1d2b4d3SLarry Finger #define DM_REG_CCK_FILTER_PARA7_11N 0xA28 65f1d2b4d3SLarry Finger #define DM_REG_CCK_FILTER_PARA8_11N 0xA29 66f1d2b4d3SLarry Finger #define DM_REG_CCK_FA_RST_11N 0xA2C 67f1d2b4d3SLarry Finger #define DM_REG_CCK_FA_MSB_11N 0xA58 68f1d2b4d3SLarry Finger #define DM_REG_CCK_FA_LSB_11N 0xA5C 69f1d2b4d3SLarry Finger #define DM_REG_CCK_CCA_CNT_11N 0xA60 70f1d2b4d3SLarry Finger #define DM_REG_BB_PWR_SAV4_11N 0xA74 71f1d2b4d3SLarry Finger /*PAGE B */ 72f1d2b4d3SLarry Finger #define DM_REG_LNA_SWITCH_11N 0xB2C 73f1d2b4d3SLarry Finger #define DM_REG_PATH_SWITCH_11N 0xB30 74f1d2b4d3SLarry Finger #define DM_REG_RSSI_CTRL_11N 0xB38 75f1d2b4d3SLarry Finger #define DM_REG_CONFIG_ANTA_11N 0xB68 76f1d2b4d3SLarry Finger #define DM_REG_RSSI_BT_11N 0xB9C 77f1d2b4d3SLarry Finger /*PAGE C */ 78f1d2b4d3SLarry Finger #define DM_REG_OFDM_FA_HOLDC_11N 0xC00 79f1d2b4d3SLarry Finger #define DM_REG_RX_PATH_11N 0xC04 80f1d2b4d3SLarry Finger #define DM_REG_TRMUX_11N 0xC08 81f1d2b4d3SLarry Finger #define DM_REG_OFDM_FA_RSTC_11N 0xC0C 82f1d2b4d3SLarry Finger #define DM_REG_RXIQI_MATRIX_11N 0xC14 83f1d2b4d3SLarry Finger #define DM_REG_TXIQK_MATRIX_LSB1_11N 0xC4C 84f1d2b4d3SLarry Finger #define DM_REG_IGI_A_11N 0xC50 85f1d2b4d3SLarry Finger #define DM_REG_ANTDIV_PARA2_11N 0xC54 86f1d2b4d3SLarry Finger #define DM_REG_IGI_B_11N 0xC58 87f1d2b4d3SLarry Finger #define DM_REG_ANTDIV_PARA3_11N 0xC5C 88f1d2b4d3SLarry Finger #define DM_REG_BB_PWR_SAV2_11N 0xC70 89f1d2b4d3SLarry Finger #define DM_REG_RX_OFF_11N 0xC7C 90f1d2b4d3SLarry Finger #define DM_REG_TXIQK_MATRIXA_11N 0xC80 91f1d2b4d3SLarry Finger #define DM_REG_TXIQK_MATRIXB_11N 0xC88 92f1d2b4d3SLarry Finger #define DM_REG_TXIQK_MATRIXA_LSB2_11N 0xC94 93f1d2b4d3SLarry Finger #define DM_REG_TXIQK_MATRIXB_LSB2_11N 0xC9C 94f1d2b4d3SLarry Finger #define DM_REG_RXIQK_MATRIX_LSB_11N 0xCA0 95f1d2b4d3SLarry Finger #define DM_REG_ANTDIV_PARA1_11N 0xCA4 96f1d2b4d3SLarry Finger #define DM_REG_OFDM_FA_TYPE1_11N 0xCF0 97f1d2b4d3SLarry Finger /*PAGE D */ 98f1d2b4d3SLarry Finger #define DM_REG_OFDM_FA_RSTD_11N 0xD00 99f1d2b4d3SLarry Finger #define DM_REG_OFDM_FA_TYPE2_11N 0xDA0 100f1d2b4d3SLarry Finger #define DM_REG_OFDM_FA_TYPE3_11N 0xDA4 101f1d2b4d3SLarry Finger #define DM_REG_OFDM_FA_TYPE4_11N 0xDA8 102f1d2b4d3SLarry Finger /*PAGE E */ 103f1d2b4d3SLarry Finger #define DM_REG_TXAGC_A_6_18_11N 0xE00 104f1d2b4d3SLarry Finger #define DM_REG_TXAGC_A_24_54_11N 0xE04 105f1d2b4d3SLarry Finger #define DM_REG_TXAGC_A_1_MCS32_11N 0xE08 106f1d2b4d3SLarry Finger #define DM_REG_TXAGC_A_MCS0_3_11N 0xE10 107f1d2b4d3SLarry Finger #define DM_REG_TXAGC_A_MCS4_7_11N 0xE14 108f1d2b4d3SLarry Finger #define DM_REG_TXAGC_A_MCS8_11_11N 0xE18 109f1d2b4d3SLarry Finger #define DM_REG_TXAGC_A_MCS12_15_11N 0xE1C 110f1d2b4d3SLarry Finger #define DM_REG_FPGA0_IQK_11N 0xE28 111f1d2b4d3SLarry Finger #define DM_REG_TXIQK_TONE_A_11N 0xE30 112f1d2b4d3SLarry Finger #define DM_REG_RXIQK_TONE_A_11N 0xE34 113f1d2b4d3SLarry Finger #define DM_REG_TXIQK_PI_A_11N 0xE38 114f1d2b4d3SLarry Finger #define DM_REG_RXIQK_PI_A_11N 0xE3C 115f1d2b4d3SLarry Finger #define DM_REG_TXIQK_11N 0xE40 116f1d2b4d3SLarry Finger #define DM_REG_RXIQK_11N 0xE44 117f1d2b4d3SLarry Finger #define DM_REG_IQK_AGC_PTS_11N 0xE48 118f1d2b4d3SLarry Finger #define DM_REG_IQK_AGC_RSP_11N 0xE4C 119f1d2b4d3SLarry Finger #define DM_REG_BLUETOOTH_11N 0xE6C 120f1d2b4d3SLarry Finger #define DM_REG_RX_WAIT_CCA_11N 0xE70 121f1d2b4d3SLarry Finger #define DM_REG_TX_CCK_RFON_11N 0xE74 122f1d2b4d3SLarry Finger #define DM_REG_TX_CCK_BBON_11N 0xE78 123f1d2b4d3SLarry Finger #define DM_REG_OFDM_RFON_11N 0xE7C 124f1d2b4d3SLarry Finger #define DM_REG_OFDM_BBON_11N 0xE80 125f1d2b4d3SLarry Finger #define DM_REG_TX2RX_11N 0xE84 126f1d2b4d3SLarry Finger #define DM_REG_TX2TX_11N 0xE88 127f1d2b4d3SLarry Finger #define DM_REG_RX_CCK_11N 0xE8C 128f1d2b4d3SLarry Finger #define DM_REG_RX_OFDM_11N 0xED0 129f1d2b4d3SLarry Finger #define DM_REG_RX_WAIT_RIFS_11N 0xED4 130f1d2b4d3SLarry Finger #define DM_REG_RX2RX_11N 0xED8 131f1d2b4d3SLarry Finger #define DM_REG_STANDBY_11N 0xEDC 132f1d2b4d3SLarry Finger #define DM_REG_SLEEP_11N 0xEE0 133f1d2b4d3SLarry Finger #define DM_REG_PMPD_ANAEN_11N 0xEEC 134f1d2b4d3SLarry Finger 135f1d2b4d3SLarry Finger /*MAC REG LIST*/ 136f1d2b4d3SLarry Finger #define DM_REG_BB_RST_11N 0x02 137f1d2b4d3SLarry Finger #define DM_REG_ANTSEL_PIN_11N 0x4C 138f1d2b4d3SLarry Finger #define DM_REG_EARLY_MODE_11N 0x4D0 139f1d2b4d3SLarry Finger #define DM_REG_RSSI_MONITOR_11N 0x4FE 140f1d2b4d3SLarry Finger #define DM_REG_EDCA_VO_11N 0x500 141f1d2b4d3SLarry Finger #define DM_REG_EDCA_VI_11N 0x504 142f1d2b4d3SLarry Finger #define DM_REG_EDCA_BE_11N 0x508 143f1d2b4d3SLarry Finger #define DM_REG_EDCA_BK_11N 0x50C 144f1d2b4d3SLarry Finger #define DM_REG_TXPAUSE_11N 0x522 145f1d2b4d3SLarry Finger #define DM_REG_RESP_TX_11N 0x6D8 146f1d2b4d3SLarry Finger #define DM_REG_ANT_TRAIN_PARA1_11N 0x7b0 147f1d2b4d3SLarry Finger #define DM_REG_ANT_TRAIN_PARA2_11N 0x7b4 148f1d2b4d3SLarry Finger 149f1d2b4d3SLarry Finger /*DIG Related*/ 150f1d2b4d3SLarry Finger #define DM_BIT_IGI_11N 0x0000007F 151f1d2b4d3SLarry Finger 152f1d2b4d3SLarry Finger #define HAL_DM_DIG_DISABLE BIT(0) 153f1d2b4d3SLarry Finger #define HAL_DM_HIPWR_DISABLE BIT(1) 154f1d2b4d3SLarry Finger 155f1d2b4d3SLarry Finger #define OFDM_TABLE_LENGTH 43 156f1d2b4d3SLarry Finger #define CCK_TABLE_LENGTH 33 157f1d2b4d3SLarry Finger 158f1d2b4d3SLarry Finger #define OFDM_TABLE_SIZE 37 159f1d2b4d3SLarry Finger #define CCK_TABLE_SIZE 33 160f1d2b4d3SLarry Finger 161f1d2b4d3SLarry Finger #define BW_AUTO_SWITCH_HIGH_LOW 25 162f1d2b4d3SLarry Finger #define BW_AUTO_SWITCH_LOW_HIGH 30 163f1d2b4d3SLarry Finger 164f1d2b4d3SLarry Finger #define DM_DIG_FA_UPPER 0x3e 165f1d2b4d3SLarry Finger #define DM_DIG_FA_LOWER 0x1e 166f1d2b4d3SLarry Finger #define DM_DIG_FA_TH0 0x200 167f1d2b4d3SLarry Finger #define DM_DIG_FA_TH1 0x300 168f1d2b4d3SLarry Finger #define DM_DIG_FA_TH2 0x400 169f1d2b4d3SLarry Finger 170f1d2b4d3SLarry Finger #define RXPATHSELECTION_SS_TH_LOW 30 171f1d2b4d3SLarry Finger #define RXPATHSELECTION_DIFF_TH 18 172f1d2b4d3SLarry Finger 173f1d2b4d3SLarry Finger #define DM_RATR_STA_INIT 0 174f1d2b4d3SLarry Finger #define DM_RATR_STA_HIGH 1 175f1d2b4d3SLarry Finger #define DM_RATR_STA_MIDDLE 2 176f1d2b4d3SLarry Finger #define DM_RATR_STA_LOW 3 177f1d2b4d3SLarry Finger 178f1d2b4d3SLarry Finger #define CTS2SELF_THVAL 30 179f1d2b4d3SLarry Finger #define REGC38_TH 20 180f1d2b4d3SLarry Finger 181f1d2b4d3SLarry Finger #define WAIOTTHVAL 25 182f1d2b4d3SLarry Finger 183f1d2b4d3SLarry Finger #define TXHIGHPWRLEVEL_NORMAL 0 184f1d2b4d3SLarry Finger #define TXHIGHPWRLEVEL_LEVEL1 1 185f1d2b4d3SLarry Finger #define TXHIGHPWRLEVEL_LEVEL2 2 186f1d2b4d3SLarry Finger #define TXHIGHPWRLEVEL_BT1 3 187f1d2b4d3SLarry Finger #define TXHIGHPWRLEVEL_BT2 4 188f1d2b4d3SLarry Finger 189f1d2b4d3SLarry Finger #define DM_TYPE_BYFW 0 190f1d2b4d3SLarry Finger #define DM_TYPE_BYDRIVER 1 191f1d2b4d3SLarry Finger 192f1d2b4d3SLarry Finger #define TX_POWER_NEAR_FIELD_THRESH_LVL2 74 193f1d2b4d3SLarry Finger #define TX_POWER_NEAR_FIELD_THRESH_LVL1 67 194f1d2b4d3SLarry Finger #define TXPWRTRACK_MAX_IDX 6 195f1d2b4d3SLarry Finger 196f1d2b4d3SLarry Finger /* Dynamic ATC switch */ 197f1d2b4d3SLarry Finger #define ATC_STATUS_OFF 0x0 /* enable */ 198f1d2b4d3SLarry Finger #define ATC_STATUS_ON 0x1 /* disable */ 199f1d2b4d3SLarry Finger #define CFO_THRESHOLD_XTAL 10 /* kHz */ 200f1d2b4d3SLarry Finger #define CFO_THRESHOLD_ATC 80 /* kHz */ 201f1d2b4d3SLarry Finger 202f1d2b4d3SLarry Finger enum dm_1r_cca_e { 203f1d2b4d3SLarry Finger CCA_1R = 0, 204f1d2b4d3SLarry Finger CCA_2R = 1, 205f1d2b4d3SLarry Finger CCA_MAX = 2, 206f1d2b4d3SLarry Finger }; 207f1d2b4d3SLarry Finger 208f1d2b4d3SLarry Finger enum dm_rf_e { 209f1d2b4d3SLarry Finger RF_SAVE = 0, 210f1d2b4d3SLarry Finger RF_NORMAL = 1, 211f1d2b4d3SLarry Finger RF_MAX = 2, 212f1d2b4d3SLarry Finger }; 213f1d2b4d3SLarry Finger 214f1d2b4d3SLarry Finger enum dm_sw_ant_switch_e { 215f1d2b4d3SLarry Finger ANS_ANTENNA_B = 1, 216f1d2b4d3SLarry Finger ANS_ANTENNA_A = 2, 217f1d2b4d3SLarry Finger ANS_ANTENNA_MAX = 3, 218f1d2b4d3SLarry Finger }; 219f1d2b4d3SLarry Finger 220f1d2b4d3SLarry Finger enum pwr_track_control_method { 221f1d2b4d3SLarry Finger BBSWING, 222f1d2b4d3SLarry Finger TXAGC 223f1d2b4d3SLarry Finger }; 224f1d2b4d3SLarry Finger 225f1d2b4d3SLarry Finger #define BT_RSSI_STATE_NORMAL_POWER BIT_OFFSET_LEN_MASK_32(0, 1) 226f1d2b4d3SLarry Finger #define BT_RSSI_STATE_AMDPU_OFF BIT_OFFSET_LEN_MASK_32(1, 1) 227f1d2b4d3SLarry Finger #define BT_RSSI_STATE_SPECIAL_LOW BIT_OFFSET_LEN_MASK_32(2, 1) 228f1d2b4d3SLarry Finger #define BT_RSSI_STATE_BG_EDCA_LOW BIT_OFFSET_LEN_MASK_32(3, 1) 229f1d2b4d3SLarry Finger #define BT_RSSI_STATE_TXPOWER_LOW BIT_OFFSET_LEN_MASK_32(4, 1) 230f1d2b4d3SLarry Finger #define GET_UNDECORATED_AVERAGE_RSSI(_priv) \ 231f1d2b4d3SLarry Finger ((((struct rtl_priv *)(_priv))->mac80211.opmode == \ 232f1d2b4d3SLarry Finger NL80211_IFTYPE_ADHOC) ? \ 233f1d2b4d3SLarry Finger (((struct rtl_priv *)(_priv))->dm.entry_min_undecoratedsmoothed_pwdb) :\ 234f1d2b4d3SLarry Finger (((struct rtl_priv *)(_priv))->dm.undecorated_smoothed_pwdb)) 235f1d2b4d3SLarry Finger 236f1d2b4d3SLarry Finger void rtl8723be_dm_set_tx_ant_by_tx_info(struct ieee80211_hw *hw, u8 *pdesc, 237f1d2b4d3SLarry Finger u32 mac_id); 238f1d2b4d3SLarry Finger void rtl8723be_dm_ant_sel_statistics(struct ieee80211_hw *hw, u8 antsel_tr_mux, 239f1d2b4d3SLarry Finger u32 mac_id, u32 rx_pwdb_all); 240f1d2b4d3SLarry Finger void rtl8723be_dm_fast_antenna_training_callback(unsigned long data); 241f1d2b4d3SLarry Finger void rtl8723be_dm_init(struct ieee80211_hw *hw); 242f1d2b4d3SLarry Finger void rtl8723be_dm_watchdog(struct ieee80211_hw *hw); 243f1d2b4d3SLarry Finger void rtl8723be_dm_write_dig(struct ieee80211_hw *hw, u8 current_igi); 244f1d2b4d3SLarry Finger void rtl8723be_dm_check_txpower_tracking(struct ieee80211_hw *hw); 245f1d2b4d3SLarry Finger void rtl8723be_dm_init_rate_adaptive_mask(struct ieee80211_hw *hw); 246f1d2b4d3SLarry Finger void rtl8723be_dm_txpower_track_adjust(struct ieee80211_hw *hw, u8 type, 247f1d2b4d3SLarry Finger u8 *pdirection, u32 *poutwrite_val); 248f1d2b4d3SLarry Finger #endif 249