0001
0002
0003
0004 #ifndef __RTL8821AE_PHY_H__
0005 #define __RTL8821AE_PHY_H__
0006
0007
0008
0009
0010 #define MAX_TX_COUNT 4
0011 #define TX_1S 0
0012 #define TX_2S 1
0013 #define TX_3S 2
0014 #define TX_4S 3
0015
0016 #define MAX_POWER_INDEX 0x3F
0017
0018 #define MAX_PRECMD_CNT 16
0019 #define MAX_RFDEPENDCMD_CNT 16
0020 #define MAX_POSTCMD_CNT 16
0021
0022 #define MAX_DOZE_WAITING_TIMES_9x 64
0023
0024 #define RT_CANNOT_IO(hw) false
0025 #define HIGHPOWER_RADIOA_ARRAYLEN 22
0026
0027 #define IQK_ADDA_REG_NUM 16
0028 #define IQK_BB_REG_NUM 9
0029 #define MAX_TOLERANCE 5
0030 #define IQK_DELAY_TIME 10
0031 #define index_mapping_NUM 15
0032
0033 #define APK_BB_REG_NUM 5
0034 #define APK_AFE_REG_NUM 16
0035 #define APK_CURVE_REG_NUM 4
0036 #define PATH_NUM 2
0037
0038 #define LOOP_LIMIT 5
0039 #define MAX_STALL_TIME 50
0040 #define ANTENNADIVERSITYVALUE 0x80
0041 #define MAX_TXPWR_IDX_NMODE_92S 63
0042 #define RESET_CNT_LIMIT 3
0043
0044 #define IQK_ADDA_REG_NUM 16
0045 #define IQK_MAC_REG_NUM 4
0046
0047 #define RF6052_MAX_PATH 2
0048
0049 #define CT_OFFSET_MAC_ADDR 0X16
0050
0051 #define CT_OFFSET_CCK_TX_PWR_IDX 0x5A
0052 #define CT_OFFSET_HT401S_TX_PWR_IDX 0x60
0053 #define CT_OFFSET_HT402S_TX_PWR_IDX_DIFF 0x66
0054 #define CT_OFFSET_HT20_TX_PWR_IDX_DIFF 0x69
0055 #define CT_OFFSET_OFDM_TX_PWR_IDX_DIFF 0x6C
0056
0057 #define CT_OFFSET_HT40_MAX_PWR_OFFSET 0x6F
0058 #define CT_OFFSET_HT20_MAX_PWR_OFFSET 0x72
0059
0060 #define CT_OFFSET_CHANNEL_PLAH 0x75
0061 #define CT_OFFSET_THERMAL_METER 0x78
0062 #define CT_OFFSET_RF_OPTION 0x79
0063 #define CT_OFFSET_VERSION 0x7E
0064 #define CT_OFFSET_CUSTOMER_ID 0x7F
0065
0066 #define RTL8821AE_MAX_PATH_NUM 2
0067
0068 #define TARGET_CHNL_NUM_2G_5G_8812 59
0069
0070 enum swchnlcmd_id {
0071 CMDID_END,
0072 CMDID_SET_TXPOWEROWER_LEVEL,
0073 CMDID_BBREGWRITE10,
0074 CMDID_WRITEPORT_ULONG,
0075 CMDID_WRITEPORT_USHORT,
0076 CMDID_WRITEPORT_UCHAR,
0077 CMDID_RF_WRITEREG,
0078 };
0079
0080 struct swchnlcmd {
0081 enum swchnlcmd_id cmdid;
0082 u32 para1;
0083 u32 para2;
0084 u32 msdelay;
0085 };
0086
0087 enum hw90_block_e {
0088 HW90_BLOCK_MAC = 0,
0089 HW90_BLOCK_PHY0 = 1,
0090 HW90_BLOCK_PHY1 = 2,
0091 HW90_BLOCK_RF = 3,
0092 HW90_BLOCK_MAXIMUM = 4,
0093 };
0094
0095 enum baseband_config_type {
0096 BASEBAND_CONFIG_PHY_REG = 0,
0097 BASEBAND_CONFIG_AGC_TAB = 1,
0098 };
0099
0100 enum ra_offset_area {
0101 RA_OFFSET_LEGACY_OFDM1,
0102 RA_OFFSET_LEGACY_OFDM2,
0103 RA_OFFSET_HT_OFDM1,
0104 RA_OFFSET_HT_OFDM2,
0105 RA_OFFSET_HT_OFDM3,
0106 RA_OFFSET_HT_OFDM4,
0107 RA_OFFSET_HT_CCK,
0108 };
0109
0110 enum antenna_path {
0111 ANTENNA_NONE,
0112 ANTENNA_D,
0113 ANTENNA_C,
0114 ANTENNA_CD,
0115 ANTENNA_B,
0116 ANTENNA_BD,
0117 ANTENNA_BC,
0118 ANTENNA_BCD,
0119 ANTENNA_A,
0120 ANTENNA_AD,
0121 ANTENNA_AC,
0122 ANTENNA_ACD,
0123 ANTENNA_AB,
0124 ANTENNA_ABD,
0125 ANTENNA_ABC,
0126 ANTENNA_ABCD
0127 };
0128
0129 struct r_antenna_select_ofdm {
0130 u32 r_tx_antenna:4;
0131 u32 r_ant_l:4;
0132 u32 r_ant_non_ht:4;
0133 u32 r_ant_ht1:4;
0134 u32 r_ant_ht2:4;
0135 u32 r_ant_ht_s1:4;
0136 u32 r_ant_non_ht_s1:4;
0137 u32 ofdm_txsc:2;
0138 u32 reserved:2;
0139 };
0140
0141 struct r_antenna_select_cck {
0142 u8 r_cckrx_enable_2:2;
0143 u8 r_cckrx_enable:2;
0144 u8 r_ccktx_enable:4;
0145 };
0146
0147 struct efuse_contents {
0148 u8 mac_addr[ETH_ALEN];
0149 u8 cck_tx_power_idx[6];
0150 u8 ht40_1s_tx_power_idx[6];
0151 u8 ht40_2s_tx_power_idx_diff[3];
0152 u8 ht20_tx_power_idx_diff[3];
0153 u8 ofdm_tx_power_idx_diff[3];
0154 u8 ht40_max_power_offset[3];
0155 u8 ht20_max_power_offset[3];
0156 u8 channel_plan;
0157 u8 thermal_meter;
0158 u8 rf_option[5];
0159 u8 version;
0160 u8 oem_id;
0161 u8 regulatory;
0162 };
0163
0164 struct tx_power_struct {
0165 u8 cck[RTL8821AE_MAX_PATH_NUM][CHANNEL_MAX_NUMBER];
0166 u8 ht40_1s[RTL8821AE_MAX_PATH_NUM][CHANNEL_MAX_NUMBER];
0167 u8 ht40_2s[RTL8821AE_MAX_PATH_NUM][CHANNEL_MAX_NUMBER];
0168 u8 ht20_diff[RTL8821AE_MAX_PATH_NUM][CHANNEL_MAX_NUMBER];
0169 u8 legacy_ht_diff[RTL8821AE_MAX_PATH_NUM][CHANNEL_MAX_NUMBER];
0170 u8 legacy_ht_txpowerdiff;
0171 u8 groupht20[RTL8821AE_MAX_PATH_NUM][CHANNEL_MAX_NUMBER];
0172 u8 groupht40[RTL8821AE_MAX_PATH_NUM][CHANNEL_MAX_NUMBER];
0173 u8 pwrgroup_cnt;
0174 u32 mcs_original_offset[4][16];
0175 };
0176 enum _ANT_DIV_TYPE {
0177 NO_ANTDIV = 0xFF,
0178 CG_TRX_HW_ANTDIV = 0x01,
0179 CGCS_RX_HW_ANTDIV = 0x02,
0180 FIXED_HW_ANTDIV = 0x03,
0181 CG_TRX_SMART_ANTDIV = 0x04,
0182 CGCS_RX_SW_ANTDIV = 0x05,
0183
0184 };
0185
0186 u32 rtl8821ae_phy_query_bb_reg(struct ieee80211_hw *hw,
0187 u32 regaddr, u32 bitmask);
0188 void rtl8821ae_phy_set_bb_reg(struct ieee80211_hw *hw,
0189 u32 regaddr, u32 bitmask, u32 data);
0190 u32 rtl8821ae_phy_query_rf_reg(struct ieee80211_hw *hw,
0191 enum radio_path rfpath, u32 regaddr,
0192 u32 bitmask);
0193 void rtl8821ae_phy_set_rf_reg(struct ieee80211_hw *hw,
0194 enum radio_path rfpath, u32 regaddr,
0195 u32 bitmask, u32 data);
0196 bool rtl8821ae_phy_mac_config(struct ieee80211_hw *hw);
0197 bool rtl8821ae_phy_bb_config(struct ieee80211_hw *hw);
0198 bool rtl8821ae_phy_rf_config(struct ieee80211_hw *hw);
0199 void rtl8821ae_phy_switch_wirelessband(struct ieee80211_hw *hw,
0200 u8 band);
0201 void rtl8821ae_phy_get_hw_reg_originalvalue(struct ieee80211_hw *hw);
0202 void rtl8821ae_phy_get_txpower_level(struct ieee80211_hw *hw,
0203 long *powerlevel);
0204 void rtl8821ae_phy_set_txpower_level(struct ieee80211_hw *hw,
0205 u8 channel);
0206 void rtl8821ae_phy_scan_operation_backup(struct ieee80211_hw *hw,
0207 u8 operation);
0208 void rtl8821ae_phy_set_bw_mode_callback(struct ieee80211_hw *hw);
0209 void rtl8821ae_phy_set_bw_mode(struct ieee80211_hw *hw,
0210 enum nl80211_channel_type ch_type);
0211 void rtl8821ae_phy_sw_chnl_callback(struct ieee80211_hw *hw);
0212 u8 rtl8821ae_phy_sw_chnl(struct ieee80211_hw *hw);
0213 void rtl8821ae_phy_iq_calibrate(struct ieee80211_hw *hw,
0214 bool b_recovery);
0215 void rtl8812ae_phy_iq_calibrate(struct ieee80211_hw *hw,
0216 bool b_recovery);
0217 void rtl8821ae_phy_ap_calibrate(struct ieee80211_hw *hw, s8 delta);
0218 void rtl8821ae_phy_lc_calibrate(struct ieee80211_hw *hw);
0219 void rtl8821ae_phy_set_rfpath_switch(struct ieee80211_hw *hw, bool bmain);
0220 bool rtl8812ae_phy_config_rf_with_headerfile(struct ieee80211_hw *hw,
0221 enum radio_path rfpath);
0222 bool rtl8821ae_phy_config_rf_with_headerfile(struct ieee80211_hw *hw,
0223 enum radio_path rfpath);
0224 bool rtl8821ae_phy_set_io_cmd(struct ieee80211_hw *hw, enum io_type iotype);
0225 bool rtl8821ae_phy_set_rf_power_state(struct ieee80211_hw *hw,
0226 enum rf_pwrstate rfpwr_state);
0227 u8 _rtl8812ae_get_right_chnl_place_for_iqk(u8 chnl);
0228 void rtl8821ae_phy_set_txpower_level_by_path(struct ieee80211_hw *hw,
0229 u8 channel, u8 path);
0230 void rtl8812ae_do_iqk(struct ieee80211_hw *hw, u8 delta_thermal_index,
0231 u8 thermal_value, u8 threshold);
0232 void rtl8821ae_do_iqk(struct ieee80211_hw *hw, u8 delta_thermal_index,
0233 u8 thermal_value, u8 threshold);
0234 void rtl8821ae_reset_iqk_result(struct ieee80211_hw *hw);
0235 u32 phy_get_tx_swing_8812A(struct ieee80211_hw *hw, u8 band, u8 rf_path);
0236
0237 #endif