0001
0002
0003
0004 #ifndef __RTL8723BE_DM_H__
0005 #define __RTL8723BE_DM_H__
0006
0007 #define MAIN_ANT 0
0008 #define AUX_ANT 1
0009 #define MAIN_ANT_CG_TRX 1
0010 #define AUX_ANT_CG_TRX 0
0011 #define MAIN_ANT_CGCS_RX 0
0012 #define AUX_ANT_CGCS_RX 1
0013
0014 #define TXSCALE_TABLE_SIZE 30
0015
0016
0017 #define DM_REG_RF_MODE_11N 0x00
0018 #define DM_REG_RF_0B_11N 0x0B
0019 #define DM_REG_CHNBW_11N 0x18
0020 #define DM_REG_T_METER_11N 0x24
0021 #define DM_REG_RF_25_11N 0x25
0022 #define DM_REG_RF_26_11N 0x26
0023 #define DM_REG_RF_27_11N 0x27
0024 #define DM_REG_RF_2B_11N 0x2B
0025 #define DM_REG_RF_2C_11N 0x2C
0026 #define DM_REG_RXRF_A3_11N 0x3C
0027 #define DM_REG_T_METER_92D_11N 0x42
0028 #define DM_REG_T_METER_88E_11N 0x42
0029
0030
0031
0032 #define DM_REG_BB_CTRL_11N 0x800
0033 #define DM_REG_RF_PIN_11N 0x804
0034 #define DM_REG_PSD_CTRL_11N 0x808
0035 #define DM_REG_TX_ANT_CTRL_11N 0x80C
0036 #define DM_REG_BB_PWR_SAV5_11N 0x818
0037 #define DM_REG_CCK_RPT_FORMAT_11N 0x824
0038 #define DM_REG_RX_DEFUALT_A_11N 0x858
0039 #define DM_REG_RX_DEFUALT_B_11N 0x85A
0040 #define DM_REG_BB_PWR_SAV3_11N 0x85C
0041 #define DM_REG_ANTSEL_CTRL_11N 0x860
0042 #define DM_REG_RX_ANT_CTRL_11N 0x864
0043 #define DM_REG_PIN_CTRL_11N 0x870
0044 #define DM_REG_BB_PWR_SAV1_11N 0x874
0045 #define DM_REG_ANTSEL_PATH_11N 0x878
0046 #define DM_REG_BB_3WIRE_11N 0x88C
0047 #define DM_REG_SC_CNT_11N 0x8C4
0048 #define DM_REG_PSD_DATA_11N 0x8B4
0049
0050 #define DM_REG_ANT_MAPPING1_11N 0x914
0051 #define DM_REG_ANT_MAPPING2_11N 0x918
0052
0053 #define DM_REG_CCK_ANTDIV_PARA1_11N 0xA00
0054 #define DM_REG_CCK_CCA_11N 0xA0A
0055 #define DM_REG_CCK_ANTDIV_PARA2_11N 0xA0C
0056 #define DM_REG_CCK_ANTDIV_PARA3_11N 0xA10
0057 #define DM_REG_CCK_ANTDIV_PARA4_11N 0xA14
0058 #define DM_REG_CCK_FILTER_PARA1_11N 0xA22
0059 #define DM_REG_CCK_FILTER_PARA2_11N 0xA23
0060 #define DM_REG_CCK_FILTER_PARA3_11N 0xA24
0061 #define DM_REG_CCK_FILTER_PARA4_11N 0xA25
0062 #define DM_REG_CCK_FILTER_PARA5_11N 0xA26
0063 #define DM_REG_CCK_FILTER_PARA6_11N 0xA27
0064 #define DM_REG_CCK_FILTER_PARA7_11N 0xA28
0065 #define DM_REG_CCK_FILTER_PARA8_11N 0xA29
0066 #define DM_REG_CCK_FA_RST_11N 0xA2C
0067 #define DM_REG_CCK_FA_MSB_11N 0xA58
0068 #define DM_REG_CCK_FA_LSB_11N 0xA5C
0069 #define DM_REG_CCK_CCA_CNT_11N 0xA60
0070 #define DM_REG_BB_PWR_SAV4_11N 0xA74
0071
0072 #define DM_REG_LNA_SWITCH_11N 0xB2C
0073 #define DM_REG_PATH_SWITCH_11N 0xB30
0074 #define DM_REG_RSSI_CTRL_11N 0xB38
0075 #define DM_REG_CONFIG_ANTA_11N 0xB68
0076 #define DM_REG_RSSI_BT_11N 0xB9C
0077
0078 #define DM_REG_OFDM_FA_HOLDC_11N 0xC00
0079 #define DM_REG_RX_PATH_11N 0xC04
0080 #define DM_REG_TRMUX_11N 0xC08
0081 #define DM_REG_OFDM_FA_RSTC_11N 0xC0C
0082 #define DM_REG_RXIQI_MATRIX_11N 0xC14
0083 #define DM_REG_TXIQK_MATRIX_LSB1_11N 0xC4C
0084 #define DM_REG_IGI_A_11N 0xC50
0085 #define DM_REG_ANTDIV_PARA2_11N 0xC54
0086 #define DM_REG_IGI_B_11N 0xC58
0087 #define DM_REG_ANTDIV_PARA3_11N 0xC5C
0088 #define DM_REG_BB_PWR_SAV2_11N 0xC70
0089 #define DM_REG_RX_OFF_11N 0xC7C
0090 #define DM_REG_TXIQK_MATRIXA_11N 0xC80
0091 #define DM_REG_TXIQK_MATRIXB_11N 0xC88
0092 #define DM_REG_TXIQK_MATRIXA_LSB2_11N 0xC94
0093 #define DM_REG_TXIQK_MATRIXB_LSB2_11N 0xC9C
0094 #define DM_REG_RXIQK_MATRIX_LSB_11N 0xCA0
0095 #define DM_REG_ANTDIV_PARA1_11N 0xCA4
0096 #define DM_REG_OFDM_FA_TYPE1_11N 0xCF0
0097
0098 #define DM_REG_OFDM_FA_RSTD_11N 0xD00
0099 #define DM_REG_OFDM_FA_TYPE2_11N 0xDA0
0100 #define DM_REG_OFDM_FA_TYPE3_11N 0xDA4
0101 #define DM_REG_OFDM_FA_TYPE4_11N 0xDA8
0102
0103 #define DM_REG_TXAGC_A_6_18_11N 0xE00
0104 #define DM_REG_TXAGC_A_24_54_11N 0xE04
0105 #define DM_REG_TXAGC_A_1_MCS32_11N 0xE08
0106 #define DM_REG_TXAGC_A_MCS0_3_11N 0xE10
0107 #define DM_REG_TXAGC_A_MCS4_7_11N 0xE14
0108 #define DM_REG_TXAGC_A_MCS8_11_11N 0xE18
0109 #define DM_REG_TXAGC_A_MCS12_15_11N 0xE1C
0110 #define DM_REG_FPGA0_IQK_11N 0xE28
0111 #define DM_REG_TXIQK_TONE_A_11N 0xE30
0112 #define DM_REG_RXIQK_TONE_A_11N 0xE34
0113 #define DM_REG_TXIQK_PI_A_11N 0xE38
0114 #define DM_REG_RXIQK_PI_A_11N 0xE3C
0115 #define DM_REG_TXIQK_11N 0xE40
0116 #define DM_REG_RXIQK_11N 0xE44
0117 #define DM_REG_IQK_AGC_PTS_11N 0xE48
0118 #define DM_REG_IQK_AGC_RSP_11N 0xE4C
0119 #define DM_REG_BLUETOOTH_11N 0xE6C
0120 #define DM_REG_RX_WAIT_CCA_11N 0xE70
0121 #define DM_REG_TX_CCK_RFON_11N 0xE74
0122 #define DM_REG_TX_CCK_BBON_11N 0xE78
0123 #define DM_REG_OFDM_RFON_11N 0xE7C
0124 #define DM_REG_OFDM_BBON_11N 0xE80
0125 #define DM_REG_TX2RX_11N 0xE84
0126 #define DM_REG_TX2TX_11N 0xE88
0127 #define DM_REG_RX_CCK_11N 0xE8C
0128 #define DM_REG_RX_OFDM_11N 0xED0
0129 #define DM_REG_RX_WAIT_RIFS_11N 0xED4
0130 #define DM_REG_RX2RX_11N 0xED8
0131 #define DM_REG_STANDBY_11N 0xEDC
0132 #define DM_REG_SLEEP_11N 0xEE0
0133 #define DM_REG_PMPD_ANAEN_11N 0xEEC
0134
0135
0136 #define DM_REG_BB_RST_11N 0x02
0137 #define DM_REG_ANTSEL_PIN_11N 0x4C
0138 #define DM_REG_EARLY_MODE_11N 0x4D0
0139 #define DM_REG_RSSI_MONITOR_11N 0x4FE
0140 #define DM_REG_EDCA_VO_11N 0x500
0141 #define DM_REG_EDCA_VI_11N 0x504
0142 #define DM_REG_EDCA_BE_11N 0x508
0143 #define DM_REG_EDCA_BK_11N 0x50C
0144 #define DM_REG_TXPAUSE_11N 0x522
0145 #define DM_REG_RESP_TX_11N 0x6D8
0146 #define DM_REG_ANT_TRAIN_PARA1_11N 0x7b0
0147 #define DM_REG_ANT_TRAIN_PARA2_11N 0x7b4
0148
0149
0150 #define DM_BIT_IGI_11N 0x0000007F
0151
0152 #define HAL_DM_DIG_DISABLE BIT(0)
0153 #define HAL_DM_HIPWR_DISABLE BIT(1)
0154
0155 #define OFDM_TABLE_LENGTH 43
0156 #define CCK_TABLE_LENGTH 33
0157
0158 #define OFDM_TABLE_SIZE 37
0159 #define CCK_TABLE_SIZE 33
0160
0161 #define BW_AUTO_SWITCH_HIGH_LOW 25
0162 #define BW_AUTO_SWITCH_LOW_HIGH 30
0163
0164 #define DM_DIG_FA_UPPER 0x3e
0165 #define DM_DIG_FA_LOWER 0x1e
0166 #define DM_DIG_FA_TH0 0x200
0167 #define DM_DIG_FA_TH1 0x300
0168 #define DM_DIG_FA_TH2 0x400
0169
0170 #define RXPATHSELECTION_SS_TH_LOW 30
0171 #define RXPATHSELECTION_DIFF_TH 18
0172
0173 #define DM_RATR_STA_INIT 0
0174 #define DM_RATR_STA_HIGH 1
0175 #define DM_RATR_STA_MIDDLE 2
0176 #define DM_RATR_STA_LOW 3
0177
0178 #define CTS2SELF_THVAL 30
0179 #define REGC38_TH 20
0180
0181 #define WAIOTTHVAL 25
0182
0183 #define TXHIGHPWRLEVEL_NORMAL 0
0184 #define TXHIGHPWRLEVEL_LEVEL1 1
0185 #define TXHIGHPWRLEVEL_LEVEL2 2
0186 #define TXHIGHPWRLEVEL_BT1 3
0187 #define TXHIGHPWRLEVEL_BT2 4
0188
0189 #define DM_TYPE_BYFW 0
0190 #define DM_TYPE_BYDRIVER 1
0191
0192 #define TX_POWER_NEAR_FIELD_THRESH_LVL2 74
0193 #define TX_POWER_NEAR_FIELD_THRESH_LVL1 67
0194 #define TXPWRTRACK_MAX_IDX 6
0195
0196
0197 #define ATC_STATUS_OFF 0x0
0198 #define ATC_STATUS_ON 0x1
0199 #define CFO_THRESHOLD_XTAL 10
0200 #define CFO_THRESHOLD_ATC 80
0201
0202 enum dm_1r_cca_e {
0203 CCA_1R = 0,
0204 CCA_2R = 1,
0205 CCA_MAX = 2,
0206 };
0207
0208 enum dm_rf_e {
0209 RF_SAVE = 0,
0210 RF_NORMAL = 1,
0211 RF_MAX = 2,
0212 };
0213
0214 enum dm_sw_ant_switch_e {
0215 ANS_ANTENNA_B = 1,
0216 ANS_ANTENNA_A = 2,
0217 ANS_ANTENNA_MAX = 3,
0218 };
0219
0220 enum pwr_track_control_method {
0221 BBSWING,
0222 TXAGC
0223 };
0224
0225 #define BT_RSSI_STATE_NORMAL_POWER BIT_OFFSET_LEN_MASK_32(0, 1)
0226 #define BT_RSSI_STATE_AMDPU_OFF BIT_OFFSET_LEN_MASK_32(1, 1)
0227 #define BT_RSSI_STATE_SPECIAL_LOW BIT_OFFSET_LEN_MASK_32(2, 1)
0228 #define BT_RSSI_STATE_BG_EDCA_LOW BIT_OFFSET_LEN_MASK_32(3, 1)
0229 #define BT_RSSI_STATE_TXPOWER_LOW BIT_OFFSET_LEN_MASK_32(4, 1)
0230 #define GET_UNDECORATED_AVERAGE_RSSI(_priv) \
0231 ((((struct rtl_priv *)(_priv))->mac80211.opmode == \
0232 NL80211_IFTYPE_ADHOC) ? \
0233 (((struct rtl_priv *)(_priv))->dm.entry_min_undecoratedsmoothed_pwdb) :\
0234 (((struct rtl_priv *)(_priv))->dm.undecorated_smoothed_pwdb))
0235
0236 void rtl8723be_dm_set_tx_ant_by_tx_info(struct ieee80211_hw *hw, u8 *pdesc,
0237 u32 mac_id);
0238 void rtl8723be_dm_ant_sel_statistics(struct ieee80211_hw *hw, u8 antsel_tr_mux,
0239 u32 mac_id, u32 rx_pwdb_all);
0240 void rtl8723be_dm_fast_antenna_training_callback(unsigned long data);
0241 void rtl8723be_dm_init(struct ieee80211_hw *hw);
0242 void rtl8723be_dm_watchdog(struct ieee80211_hw *hw);
0243 void rtl8723be_dm_write_dig(struct ieee80211_hw *hw, u8 current_igi);
0244 void rtl8723be_dm_check_txpower_tracking(struct ieee80211_hw *hw);
0245 void rtl8723be_dm_init_rate_adaptive_mask(struct ieee80211_hw *hw);
0246 void rtl8723be_dm_txpower_track_adjust(struct ieee80211_hw *hw, u8 type,
0247 u8 *pdirection, u32 *poutwrite_val);
0248 #endif