30 #include <linux/export.h>
32 #include "../rtl8192ce/reg.h"
33 #include "../rtl8192ce/def.h"
38 #define MCS_TXPWR mcs_txpwrlevel_origoffset
43 u32 returnvalue, originalvalue, bitshift;
47 originalvalue = rtl_read_dword(rtlpriv, regaddr);
49 returnvalue = (originalvalue &
bitmask) >> bitshift;
52 "BBR MASK=0x%x Addr[0x%x]=0x%x\n",
53 bitmask, regaddr, originalvalue);
64 u32 originalvalue, bitshift;
67 "regaddr(%#x), bitmask(%#x), data(%#x)\n",
68 regaddr, bitmask, data);
71 originalvalue = rtl_read_dword(rtlpriv, regaddr);
73 data = ((originalvalue & (~bitmask)) | (data << bitshift));
76 rtl_write_dword(rtlpriv, regaddr, data);
79 "regaddr(%#x), bitmask(%#x), data(%#x)\n",
80 regaddr, bitmask, data);
88 RT_ASSERT(
false,
"deprecated!\n");
98 RT_ASSERT(
false,
"deprecated!\n");
109 u32 tmplong, tmplong2;
168 data_and_addr = ((newoffset << 20) | (data & 0x000fffff)) & 0x0fffffff;
179 for (i = 0; i <= 31; i++) {
180 if ((bitmask >> i) & 0x1)
194 rtl_set_bbreg(hw, 0xe74, 0x0c000000, 0x2);
195 rtl_set_bbreg(hw, 0xe78, 0x0c000000, 0x2);
196 rtl_set_bbreg(hw, 0xe7c, 0x0c000000, 0x2);
197 rtl_set_bbreg(hw, 0xe80, 0x0c000000, 0x2);
198 rtl_set_bbreg(hw, 0xe88, 0x0c000000, 0x2);
205 return rtlpriv->
cfg->ops->phy_rf6052_config(hw);
217 rtstatus = rtlpriv->
cfg->ops->config_bb_with_headerfile(hw,
224 _rtl92c_phy_bb_config_1t(hw);
229 rtstatus = rtlpriv->
cfg->ops->config_bb_with_pgheaderfile(hw,
236 rtstatus = rtlpriv->
cfg->ops->config_bb_with_headerfile(hw,
295 "MCSTxPowerLevelOriginalOffset[%d][%d] = 0x%x\n",
319 "Default initial gain (c50=0x%x, c58=0x%x, c60=0x%x, c68=0x%x\n",
331 "Default framesync (0x%x) = 0x%x\n",
456 txpwr_level) > txpwr_dbm)
463 txpwr_level) > txpwr_dbm)
467 *powerlevel = txpwr_dbm;
471 u8 *cckpowerlevel,
u8 *ofdmpowerlevel)
482 if (get_rf_type(rtlphy) ==
RF_1T2R || get_rf_type(rtlphy) ==
RF_1T1R) {
487 }
else if (get_rf_type(rtlphy) ==
RF_2T2R) {
495 static void _rtl92c_ccxpower_index_check(
struct ieee80211_hw *hw,
496 u8 channel,
u8 *cckpowerlevel,
511 u8 cckpowerlevel[2], ofdmpowerlevel[2];
515 _rtl92c_get_txpower_index(hw, channel,
516 &cckpowerlevel[0], &ofdmpowerlevel[0]);
517 _rtl92c_ccxpower_index_check(hw,
518 channel, &cckpowerlevel[0],
520 rtlpriv->
cfg->ops->phy_rf6052_set_cck_txpower(hw, &cckpowerlevel[0]);
521 rtlpriv->
cfg->ops->phy_rf6052_set_ofdm_txpower(hw, &ofdmpowerlevel[0],
544 "%lx dBm, ccktxpwridx = %d, ofdmtxpwridx = %d\n",
545 power_indbm, ccktxpwridx, ofdmtxpwridx);
546 for (idx = 0; idx < 14; idx++) {
547 for (rf_path = 0; rf_path < 2; rf_path++) {
567 switch (wirelessmode) {
580 if ((power_indbm - offset) > 0)
581 txpwridx = (
u8) ((power_indbm - offset) * 2);
599 switch (wirelessmode) {
611 pwrout_dbm = txpwridx / 2 +
offset;
622 if (!is_hal_stop(rtlhal)) {
626 rtlpriv->
cfg->ops->set_hw_reg(hw,
633 rtlpriv->
cfg->ops->set_hw_reg(hw,
639 "Unknown Scan Backup operation\n");
658 rtlpriv->
cfg->ops->phy_set_bw_mode_callback(hw);
661 "FALSE driver sleep or unload\n");
677 if (is_hal_stop(rtlhal))
709 "WIRELESS_MODE_G but channel>14\n");
716 "sw_chnl_inprogress false schdule workitem\n");
720 "sw_chnl_inprogress false driver sleep or unload\n");
727 static bool _rtl92c_phy_set_sw_chnl_cmdarray(
struct swchnlcmd *cmdtable,
728 u32 cmdtableidx,
u32 cmdtablesz,
734 if (cmdtable ==
NULL) {
735 RT_ASSERT(
false,
"cmdtable cannot be NULL\n");
739 if (cmdtableidx >= cmdtablesz)
742 pcmd = cmdtable + cmdtableidx;
756 struct swchnlcmd precommoncmd[MAX_PRECMD_CNT];
758 struct swchnlcmd postcommoncmd[MAX_POSTCMD_CNT];
759 u32 postcommoncmdcnt;
760 struct swchnlcmd rfdependcmd[MAX_RFDEPENDCMD_CNT];
767 _rtl92c_phy_set_sw_chnl_cmdarray(precommoncmd, precommoncmdcnt++,
770 _rtl92c_phy_set_sw_chnl_cmdarray(precommoncmd, precommoncmdcnt++,
773 postcommoncmdcnt = 0;
775 _rtl92c_phy_set_sw_chnl_cmdarray(postcommoncmd, postcommoncmdcnt++,
780 RT_ASSERT((channel >= 1 && channel <= 14),
781 "invalid channel for Zebra: %d\n", channel);
783 _rtl92c_phy_set_sw_chnl_cmdarray(rfdependcmd, rfdependcmdcnt++,
787 _rtl92c_phy_set_sw_chnl_cmdarray(rfdependcmd, rfdependcmdcnt++,
794 currentcmd = &precommoncmd[*
step];
797 currentcmd = &rfdependcmd[*
step];
800 currentcmd = &postcommoncmd[*
step];
814 switch (currentcmd->
cmdid) {
819 rtl_write_dword(rtlpriv, currentcmd->
para1,
823 rtl_write_word(rtlpriv, currentcmd->
para1,
827 rtl_write_byte(rtlpriv, currentcmd->
para1,
831 for (rfpath = 0; rfpath < num_total_rfpath; rfpath++) {
834 0xfffffc00) | currentcmd->
para2);
844 "switch case not processed\n");
851 (*delay) = currentcmd->
msdelay;
862 static u8 _rtl92c_phy_path_a_iqk(
struct ieee80211_hw *hw,
bool config_pathb)
864 u32 reg_eac, reg_e94, reg_e9c, reg_ea4;
867 rtl_set_bbreg(hw, 0xe30,
MASKDWORD, 0x10008c1f);
868 rtl_set_bbreg(hw, 0xe34,
MASKDWORD, 0x10008c1f);
869 rtl_set_bbreg(hw, 0xe38,
MASKDWORD, 0x82140102);
871 config_pathb ? 0x28160202 : 0x28160502);
874 rtl_set_bbreg(hw, 0xe50,
MASKDWORD, 0x10008c22);
875 rtl_set_bbreg(hw, 0xe54,
MASKDWORD, 0x10008c22);
876 rtl_set_bbreg(hw, 0xe58,
MASKDWORD, 0x82140102);
877 rtl_set_bbreg(hw, 0xe5c,
MASKDWORD, 0x28160202);
880 rtl_set_bbreg(hw, 0xe4c,
MASKDWORD, 0x001028d1);
881 rtl_set_bbreg(hw, 0xe48,
MASKDWORD, 0xf9000000);
882 rtl_set_bbreg(hw, 0xe48,
MASKDWORD, 0xf8000000);
886 reg_eac = rtl_get_bbreg(hw, 0xeac,
MASKDWORD);
887 reg_e94 = rtl_get_bbreg(hw, 0xe94,
MASKDWORD);
888 reg_e9c = rtl_get_bbreg(hw, 0xe9c,
MASKDWORD);
889 reg_ea4 = rtl_get_bbreg(hw, 0xea4,
MASKDWORD);
891 if (!(reg_eac &
BIT(28)) &&
892 (((reg_e94 & 0x03FF0000) >> 16) != 0x142) &&
893 (((reg_e9c & 0x03FF0000) >> 16) != 0x42))
898 if (!(reg_eac &
BIT(27)) &&
899 (((reg_ea4 & 0x03FF0000) >> 16) != 0x132) &&
900 (((reg_eac & 0x03FF0000) >> 16) != 0x36))
907 u32 reg_eac, reg_eb4, reg_ebc, reg_ec4, reg_ecc;
910 rtl_set_bbreg(hw, 0xe60,
MASKDWORD, 0x00000002);
911 rtl_set_bbreg(hw, 0xe60,
MASKDWORD, 0x00000000);
913 reg_eac = rtl_get_bbreg(hw, 0xeac,
MASKDWORD);
914 reg_eb4 = rtl_get_bbreg(hw, 0xeb4,
MASKDWORD);
915 reg_ebc = rtl_get_bbreg(hw, 0xebc,
MASKDWORD);
916 reg_ec4 = rtl_get_bbreg(hw, 0xec4,
MASKDWORD);
917 reg_ecc = rtl_get_bbreg(hw, 0xecc,
MASKDWORD);
919 if (!(reg_eac &
BIT(31)) &&
920 (((reg_eb4 & 0x03FF0000) >> 16) != 0x142) &&
921 (((reg_ebc & 0x03FF0000) >> 16) != 0x42))
925 if (!(reg_eac &
BIT(30)) &&
926 (((reg_ec4 & 0x03FF0000) >> 16) != 0x132) &&
927 (((reg_ecc & 0x03FF0000) >> 16) != 0x36))
932 static void _rtl92c_phy_path_a_fill_iqk_matrix(
struct ieee80211_hw *hw,
933 bool iqk_ok,
long result[][8],
934 u8 final_candidate,
bool btxonly)
939 if (final_candidate == 0xFF) {
944 x = result[final_candidate][0];
945 if ((x & 0x00000200) != 0)
947 tx0_a = (x * oldval_0) >> 8;
950 ((x * oldval_0 >> 7) & 0x1));
951 y = result[final_candidate][1];
952 if ((y & 0x00000200) != 0)
954 tx0_c = (y * oldval_0) >> 8;
956 ((tx0_c & 0x3C0) >> 6));
960 ((y * oldval_0 >> 7) & 0x1));
963 reg = result[final_candidate][2];
965 reg = result[final_candidate][3] & 0x3F;
967 reg = (result[final_candidate][3] >> 6) & 0xF;
968 rtl_set_bbreg(hw, 0xca0, 0xF0000000, reg);
972 static void _rtl92c_phy_path_b_fill_iqk_matrix(
struct ieee80211_hw *hw,
973 bool iqk_ok,
long result[][8],
974 u8 final_candidate,
bool btxonly)
979 if (final_candidate == 0xFF) {
984 x = result[final_candidate][4];
985 if ((x & 0x00000200) != 0)
987 tx1_a = (x * oldval_1) >> 8;
990 ((x * oldval_1 >> 7) & 0x1));
991 y = result[final_candidate][5];
992 if ((y & 0x00000200) != 0)
994 tx1_c = (y * oldval_1) >> 8;
996 ((tx1_c & 0x3C0) >> 6));
1000 ((y * oldval_1 >> 7) & 0x1));
1003 reg = result[final_candidate][6];
1005 reg = result[final_candidate][7] & 0x3F;
1007 reg = (result[final_candidate][7] >> 6) & 0xF;
1012 static void _rtl92c_phy_save_adda_registers(
struct ieee80211_hw *hw,
1013 u32 *addareg,
u32 *addabackup,
1018 for (i = 0; i < registernum; i++)
1019 addabackup[i] = rtl_get_bbreg(hw, addareg[i],
MASKDWORD);
1022 static void _rtl92c_phy_save_mac_registers(
struct ieee80211_hw *hw,
1023 u32 *macreg,
u32 *macbackup)
1029 macbackup[i] = rtl_read_byte(rtlpriv, macreg[i]);
1030 macbackup[
i] = rtl_read_dword(rtlpriv, macreg[i]);
1033 static void _rtl92c_phy_reload_adda_registers(
struct ieee80211_hw *hw,
1034 u32 *addareg,
u32 *addabackup,
1039 for (i = 0; i < regiesternum; i++)
1040 rtl_set_bbreg(hw, addareg[i],
MASKDWORD, addabackup[i]);
1043 static void _rtl92c_phy_reload_mac_registers(
struct ieee80211_hw *hw,
1044 u32 *macreg,
u32 *macbackup)
1050 rtl_write_byte(rtlpriv, macreg[i], (
u8) macbackup[
i]);
1051 rtl_write_dword(rtlpriv, macreg[i], macbackup[i]);
1054 static void _rtl92c_phy_path_adda_on(
struct ieee80211_hw *hw,
1055 u32 *addareg,
bool is_patha_on,
bool is2t)
1060 pathOn = is_patha_on ? 0x04db25a4 : 0x0b1b25a4;
1061 if (
false == is2t) {
1062 pathOn = 0x0bdb25a0;
1063 rtl_set_bbreg(hw, addareg[0],
MASKDWORD, 0x0b1b25a0);
1065 rtl_set_bbreg(hw, addareg[0],
MASKDWORD, pathOn);
1069 rtl_set_bbreg(hw, addareg[i],
MASKDWORD, pathOn);
1072 static void _rtl92c_phy_mac_setting_calibration(
struct ieee80211_hw *hw,
1073 u32 *macreg,
u32 *macbackup)
1078 rtl_write_byte(rtlpriv, macreg[0], 0x3F);
1081 rtl_write_byte(rtlpriv, macreg[i],
1082 (
u8) (macbackup[
i] & (~
BIT(3))));
1083 rtl_write_byte(rtlpriv, macreg[i], (
u8) (macbackup[i] & (~
BIT(5))));
1086 static void _rtl92c_phy_path_a_standby(
struct ieee80211_hw *hw)
1088 rtl_set_bbreg(hw, 0xe28,
MASKDWORD, 0x0);
1089 rtl_set_bbreg(hw, 0x840,
MASKDWORD, 0x00010000);
1090 rtl_set_bbreg(hw, 0xe28,
MASKDWORD, 0x80800000);
1093 static void _rtl92c_phy_pi_mode_switch(
struct ieee80211_hw *hw,
bool pi_mode)
1097 mode = pi_mode ? 0x01000100 : 0x01000000;
1098 rtl_set_bbreg(hw, 0x820,
MASKDWORD, mode);
1099 rtl_set_bbreg(hw, 0x828,
MASKDWORD, mode);
1102 static bool _rtl92c_phy_simularity_compare(
struct ieee80211_hw *hw,
1103 long result[][8],
u8 c1,
u8 c2)
1105 u32 i,
j, diff, simularity_bitmap, bound;
1108 u8 final_candidate[2] = { 0xFF, 0xFF };
1116 simularity_bitmap = 0;
1118 for (i = 0; i < bound; i++) {
1119 diff = (result[c1][
i] > result[c2][
i]) ?
1120 (result[c1][i] - result[c2][i]) :
1121 (result[c2][
i] - result[c1][
i]);
1124 if ((i == 2 || i == 6) && !simularity_bitmap) {
1125 if (result[c1][i] + result[c1][i + 1] == 0)
1126 final_candidate[(i / 4)] = c2;
1127 else if (result[c2][i] + result[c2][i + 1] == 0)
1128 final_candidate[(i / 4)] = c1;
1130 simularity_bitmap = simularity_bitmap |
1134 simularity_bitmap | (1 <<
i);
1138 if (simularity_bitmap == 0) {
1139 for (i = 0; i < (bound / 4); i++) {
1140 if (final_candidate[i] != 0xFF) {
1141 for (j = i * 4; j < (i + 1) * 4 - 2; j++)
1143 result[final_candidate[i]][j];
1148 }
else if (!(simularity_bitmap & 0x0F)) {
1149 for (i = 0; i < 4; i++)
1150 result[3][i] = result[c1][i];
1152 }
else if (!(simularity_bitmap & 0xF0) && is2t) {
1153 for (i = 4; i < 8; i++)
1154 result[3][i] = result[c1][i];
1162 static void _rtl92c_phy_iq_calibrate(
struct ieee80211_hw *hw,
1163 long result[][8],
u8 t,
bool is2t)
1168 u8 patha_ok, pathb_ok;
1170 0x85c, 0xe6c, 0xe70, 0xe74,
1171 0xe78, 0xe7c, 0xe80, 0xe84,
1172 0xe88, 0xe8c, 0xed0, 0xed4,
1173 0xed8, 0xedc, 0xee0, 0xeec
1177 0x522, 0x550, 0x551, 0x040
1180 const u32 retrycount = 2;
1186 _rtl92c_phy_save_adda_registers(hw, adda_reg,
1188 _rtl92c_phy_save_mac_registers(hw, iqk_mac_reg,
1191 _rtl92c_phy_path_adda_on(hw, adda_reg,
true, is2t);
1199 _rtl92c_phy_pi_mode_switch(hw,
true);
1205 rtl_set_bbreg(hw, 0xc04,
MASKDWORD, 0x03a05600);
1206 rtl_set_bbreg(hw, 0xc08,
MASKDWORD, 0x000800e4);
1207 rtl_set_bbreg(hw, 0x874,
MASKDWORD, 0x22204000);
1209 rtl_set_bbreg(hw, 0x840,
MASKDWORD, 0x00010000);
1210 rtl_set_bbreg(hw, 0x844,
MASKDWORD, 0x00010000);
1212 _rtl92c_phy_mac_setting_calibration(hw, iqk_mac_reg,
1214 rtl_set_bbreg(hw, 0xb68,
MASKDWORD, 0x00080000);
1216 rtl_set_bbreg(hw, 0xb6c,
MASKDWORD, 0x00080000);
1217 rtl_set_bbreg(hw, 0xe28,
MASKDWORD, 0x80800000);
1218 rtl_set_bbreg(hw, 0xe40,
MASKDWORD, 0x01007c00);
1219 rtl_set_bbreg(hw, 0xe44,
MASKDWORD, 0x01004800);
1220 for (i = 0; i < retrycount; i++) {
1221 patha_ok = _rtl92c_phy_path_a_iqk(hw, is2t);
1222 if (patha_ok == 0x03) {
1223 result[
t][0] = (rtl_get_bbreg(hw, 0xe94,
MASKDWORD) &
1225 result[
t][1] = (rtl_get_bbreg(hw, 0xe9c,
MASKDWORD) &
1227 result[
t][2] = (rtl_get_bbreg(hw, 0xea4,
MASKDWORD) &
1229 result[
t][3] = (rtl_get_bbreg(hw, 0xeac,
MASKDWORD) &
1232 }
else if (i == (retrycount - 1) && patha_ok == 0x01)
1234 result[t][0] = (rtl_get_bbreg(hw, 0xe94,
1238 (rtl_get_bbreg(hw, 0xe9c,
MASKDWORD) & 0x3FF0000) >> 16;
1243 _rtl92c_phy_path_a_standby(hw);
1244 _rtl92c_phy_path_adda_on(hw, adda_reg,
false, is2t);
1245 for (i = 0; i < retrycount; i++) {
1246 pathb_ok = _rtl92c_phy_path_b_iqk(hw);
1247 if (pathb_ok == 0x03) {
1248 result[
t][4] = (rtl_get_bbreg(hw,
1262 }
else if (i == (retrycount - 1) && pathb_ok == 0x01) {
1263 result[
t][4] = (rtl_get_bbreg(hw,
1268 result[
t][5] = (rtl_get_bbreg(hw, 0xebc,
MASKDWORD) &
1276 rtl_set_bbreg(hw, 0x840,
MASKDWORD, 0x00032ed3);
1278 rtl_set_bbreg(hw, 0x844,
MASKDWORD, 0x00032ed3);
1281 _rtl92c_phy_pi_mode_switch(hw,
false);
1282 _rtl92c_phy_reload_adda_registers(hw, adda_reg,
1284 _rtl92c_phy_reload_mac_registers(hw, iqk_mac_reg,
1289 static void _rtl92c_phy_ap_calibrate(
struct ieee80211_hw *hw,
1290 char delta,
bool is2t)
1302 0x904, 0xc04, 0x800, 0xc08, 0x874
1305 0x00000020, 0x00a05430, 0x02040000,
1306 0x000800e4, 0x00204000
1309 0x00000020, 0x00a05430, 0x02040000,
1310 0x000800e4, 0x22204000
1315 0x85c, 0xe6c, 0xe70, 0xe74, 0xe78,
1316 0xe7c, 0xe80, 0xe84, 0xe88, 0xe8c,
1317 0xed0, 0xed4, 0xed8, 0xedc, 0xee0,
1323 0x522, 0x550, 0x551, 0x040
1327 {0x0852c, 0x1852c, 0x5852c, 0x1852c, 0x5852c},
1328 {0x2852e, 0x0852e, 0x3852e, 0x0852e, 0x0852e}
1332 {0x0852c, 0x0a52c, 0x3a52c, 0x5a52c, 0x5a52c},
1333 {0x0852c, 0x0a52c, 0x5a52c, 0x5a52c, 0x5a52c}
1337 {0x52019, 0x52014, 0x52013, 0x5200f, 0x5208d},
1338 {0x5201a, 0x52019, 0x52016, 0x52033, 0x52050}
1342 {0x52019, 0x52017, 0x52010, 0x5200d, 0x5206a},
1343 {0x52019, 0x52017, 0x52010, 0x5200d, 0x5206a}
1347 0x04db25a4, 0x0b1b25a4
1350 const u32 apk_offset[
PATH_NUM] = { 0xb68, 0xb6c };
1352 u32 apk_normal_offset[
PATH_NUM] = { 0xb28, 0xb98 };
1354 u32 apk_value[
PATH_NUM] = { 0x92fc0000, 0x12fc0000 };
1356 u32 apk_normal_value[
PATH_NUM] = { 0x92680000, 0x12680000 };
1359 {-4, -3, -2, -2, -1, -1, 0, 1, 2, 3, 4, 5, 6},
1360 {-4, -3, -2, -2, -1, -1, 0, 1, 2, 3, 4, 5, 6},
1361 {-6, -4, -2, -2, -1, -1, 0, 1, 2, 3, 4, 5, 6},
1362 {-1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6},
1363 {-11, -9, -7, -5, -3, -1, 0, 0, 0, 0, 0, 0, 0}
1366 const u32 apk_normal_setting_value_1[13] = {
1367 0x01017018, 0xf7ed8f84, 0x1b1a1816, 0x2522201e, 0x322e2b28,
1368 0x433f3a36, 0x5b544e49, 0x7b726a62, 0xa69a8f84, 0xdfcfc0b3,
1369 0x12680000, 0x00880000, 0x00880000
1372 const u32 apk_normal_setting_value_2[16] = {
1373 0x01c7021d, 0x01670183, 0x01000123, 0x00bf00e2, 0x008d00a3,
1374 0x0068007b, 0x004d0059, 0x003a0042, 0x002b0031, 0x001f0025,
1375 0x0017001b, 0x00110014, 0x000c000f, 0x0009000b, 0x00070008,
1381 long bb_offset, delta_v, delta_offset;
1388 for (index = 0; index <
PATH_NUM; index++) {
1389 apk_offset[
index] = apk_normal_offset[
index];
1391 afe_on_off[
index] = 0x6fdb25a4;
1395 for (path = 0; path < pathbound; path++) {
1401 bb_ap_mode[
index] = bb_normal_ap_mode[
index];
1412 _rtl92c_phy_save_mac_registers(hw, mac_reg, mac_backup);
1414 _rtl92c_phy_save_adda_registers(hw, afe_reg, afe_backup, 16);
1416 for (path = 0; path < pathbound; path++) {
1419 for (index = 0; index < 11; index++) {
1421 apk_normal_setting_value_1
1427 rtl_set_bbreg(hw, 0xb98,
MASKDWORD, 0x12680000);
1430 for (; index < 13; index++) {
1432 apk_normal_setting_value_1
1438 rtl_set_bbreg(hw, 0xe28,
MASKDWORD, 0x40000000);
1441 for (index = 0; index < 16; index++) {
1443 apk_normal_setting_value_2
1448 rtl_set_bbreg(hw, 0xe28,
MASKDWORD, 0x00000000);
1451 for (index = 0; index < 10; index++) {
1453 apk_normal_setting_value_1
1458 rtl_set_bbreg(hw, 0xb28,
MASKDWORD, 0x12680000);
1459 rtl_set_bbreg(hw, 0xb98,
MASKDWORD, 0x12680000);
1463 for (; index < 13; index++) {
1465 apk_normal_setting_value_1
1471 rtl_set_bbreg(hw, 0xe28,
MASKDWORD, 0x40000000);
1474 for (index = 0; index < 16; index++) {
1476 apk_normal_setting_value_2
1481 rtl_set_bbreg(hw, 0xe28,
MASKDWORD, 0x00000000);
1488 rtl_set_bbreg(hw, afe_reg[index],
MASKDWORD,
1495 rtl_set_bbreg(hw, bb_reg[index],
MASKDWORD,
1500 _rtl92c_phy_mac_setting_calibration(hw, mac_reg, mac_backup);
1513 delta_offset = ((delta + 14) / 2);
1514 if (delta_offset < 0)
1516 else if (delta_offset > 12)
1523 tmpreg = apk_rf_init_value[
path][
index];
1526 bb_offset = (tmpreg & 0xF0000) >> 16;
1528 if (!(tmpreg &
BIT(15)))
1529 bb_offset = -bb_offset;
1532 apk_delta_mapping[
index][delta_offset];
1534 bb_offset += delta_v;
1536 if (bb_offset < 0) {
1537 tmpreg = tmpreg & (~
BIT(15));
1538 bb_offset = -bb_offset;
1540 tmpreg = tmpreg |
BIT(15);
1544 (tmpreg & 0xFFF0FFFF) | (bb_offset << 16);
1549 rtl_set_rfreg(hw, (
enum radio_path)path, 0x0,
1550 MASKDWORD, apk_rf_value_0[path][index]);
1551 rtl_set_rfreg(hw, (
enum radio_path)path, 0xd,
1556 rtl_set_bbreg(hw, 0xe28,
MASKDWORD, 0x80000000);
1557 rtl_set_bbreg(hw, apk_offset[path],
1560 (
"PHY_APCalibrate() offset 0x%x "
1563 rtl_get_bbreg(hw, apk_offset[path],
1568 rtl_set_bbreg(hw, apk_offset[path],
1571 (
"PHY_APCalibrate() offset 0x%x "
1574 rtl_get_bbreg(hw, apk_offset[path],
1579 rtl_set_bbreg(hw, 0xe28,
MASKDWORD, 0x00000000);
1582 tmpreg = rtl_get_bbreg(hw, 0xbd8,
1585 tmpreg = rtl_get_bbreg(hw, 0xbd8,
1589 (
"PHY_APCalibrate() offset "
1590 "0xbd8[25:21] %x\n", tmpreg));
1594 }
while (tmpreg > apkbound && i < 4);
1600 _rtl92c_phy_reload_mac_registers(hw, mac_reg, mac_backup);
1605 rtl_set_bbreg(hw, bb_reg[index],
MASKDWORD, bb_backup[index]);
1608 _rtl92c_phy_reload_adda_registers(hw, afe_reg, afe_backup, 16);
1610 for (path = 0; path < pathbound; path++) {
1611 rtl_set_rfreg(hw, (
enum radio_path)path, 0xd,
1621 if (apk_result[path][1] > 6)
1622 apk_result[
path][1] = 6;
1625 for (path = 0; path < pathbound; path++) {
1627 ((apk_result[path][1] << 15) |
1628 (apk_result[path][1] << 10) |
1629 (apk_result[path][1] << 5) |
1630 apk_result[path][1]));
1634 ((apk_result[path][1] << 15) |
1635 (apk_result[path][1] << 10) |
1636 (0x00 << 5) | 0x05));
1639 ((apk_result[path][1] << 15) |
1640 (apk_result[path][1] << 10) |
1641 (0x02 << 5) | 0x05));
1644 ((0x08 << 15) | (0x08 << 10) | (0x08 << 5) |
1648 rtlphy->b_apk_done =
true;
1652 static void _rtl92c_phy_set_rfpath_switch(
struct ieee80211_hw *hw,
1653 bool bmain,
bool is2t)
1657 if (is_hal_stop(rtlhal)) {
1678 #undef IQK_ADDA_REG_NUM
1679 #undef IQK_DELAY_TIME
1688 u8 i, final_candidate;
1689 bool patha_ok, pathb_ok;
1690 long reg_e94, reg_e9c, reg_ea4, reg_eb4, reg_ebc, reg_ec4, reg_tmp = 0;
1691 bool is12simular, is13simular, is23simular;
1692 bool start_conttx =
false, singletone =
false;
1693 u32 iqk_bb_reg[10] = {
1707 _rtl92c_phy_reload_adda_registers(hw,
1712 if (start_conttx || singletone)
1714 for (i = 0; i < 8; i++) {
1720 final_candidate = 0xff;
1723 is12simular =
false;
1724 is23simular =
false;
1725 is13simular =
false;
1726 for (i = 0; i < 3; i++) {
1728 _rtl92c_phy_iq_calibrate(hw, result, i,
true);
1730 _rtl92c_phy_iq_calibrate(hw, result, i,
false);
1732 is12simular = _rtl92c_phy_simularity_compare(hw,
1736 final_candidate = 0;
1741 is13simular = _rtl92c_phy_simularity_compare(hw,
1745 final_candidate = 0;
1748 is23simular = _rtl92c_phy_simularity_compare(hw,
1752 final_candidate = 1;
1754 for (i = 0; i < 8; i++)
1755 reg_tmp += result[3][i];
1758 final_candidate = 3;
1760 final_candidate = 0xFF;
1764 for (i = 0; i < 4; i++) {
1765 reg_e94 = result[
i][0];
1766 reg_e9c = result[
i][1];
1767 reg_ea4 = result[
i][2];
1768 reg_eb4 = result[
i][4];
1769 reg_ebc = result[
i][5];
1770 reg_ec4 = result[
i][6];
1772 if (final_candidate != 0xff) {
1773 rtlphy->
reg_e94 = reg_e94 = result[final_candidate][0];
1774 rtlphy->
reg_e9c = reg_e9c = result[final_candidate][1];
1775 reg_ea4 = result[final_candidate][2];
1776 rtlphy->
reg_eb4 = reg_eb4 = result[final_candidate][4];
1777 rtlphy->
reg_ebc = reg_ebc = result[final_candidate][5];
1778 reg_ec4 = result[final_candidate][6];
1779 patha_ok = pathb_ok =
true;
1785 _rtl92c_phy_path_a_fill_iqk_matrix(hw, patha_ok, result,
1790 _rtl92c_phy_path_b_fill_iqk_matrix(hw, pathb_ok,
1795 _rtl92c_phy_save_adda_registers(hw, iqk_bb_reg,
1804 bool start_conttx =
false, singletone =
false;
1806 if (start_conttx || singletone)
1809 rtlpriv->
cfg->ops->phy_lc_calibrate(hw,
true);
1811 rtlpriv->
cfg->ops->phy_lc_calibrate(hw,
false);
1824 _rtl92c_phy_ap_calibrate(hw, delta,
true);
1826 _rtl92c_phy_ap_calibrate(hw, delta,
false);
1835 _rtl92c_phy_set_rfpath_switch(hw, bmain,
true);
1837 _rtl92c_phy_set_rfpath_switch(hw, bmain,
false);
1845 bool postprocessing =
false;
1848 "-->IO Cmd(%#x), set_io_inprogress(%d)\n",
1854 "[IO CMD] Resume DM after scan\n");
1855 postprocessing =
true;
1859 "[IO CMD] Pause DM before scan\n");
1860 postprocessing =
true;
1864 "switch case not processed\n");
1887 "--->Cmd(%#x), set_io_inprogress(%d)\n",
1902 "switch case not processed\n");
1934 while (u4b_tmp != 0 && delay > 0) {
1947 "Switch RF timeout !!!\n");