rtl8821c_phy.c 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2016 Realtek Corporation. All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  17. *
  18. *
  19. ******************************************************************************/
  20. #define _RTL8821C_PHY_C_
  21. #include <hal_data.h> /* HAL_DATA_TYPE */
  22. #include "../hal_halmac.h" /* REG_CCK_CHECK_8821C */
  23. #include "rtl8821c.h"
  24. /*
  25. * Description:
  26. * Initialize Register definition offset for Radio Path A/B/C/D
  27. * The initialization value is constant and it should never be changes
  28. */
  29. static void bb_rf_register_definition(PADAPTER adapter)
  30. {
  31. PHAL_DATA_TYPE hal = GET_HAL_DATA(adapter);
  32. /* RF Interface Sowrtware Control */
  33. hal->PHYRegDef[ODM_RF_PATH_A].rfintfs = rFPGA0_XAB_RFInterfaceSW;
  34. hal->PHYRegDef[ODM_RF_PATH_B].rfintfs = rFPGA0_XAB_RFInterfaceSW;
  35. /* RF Interface Output (and Enable) */
  36. hal->PHYRegDef[ODM_RF_PATH_A].rfintfo = rFPGA0_XA_RFInterfaceOE;
  37. hal->PHYRegDef[ODM_RF_PATH_B].rfintfo = rFPGA0_XB_RFInterfaceOE;
  38. /* RF Interface (Output and) Enable */
  39. hal->PHYRegDef[ODM_RF_PATH_A].rfintfe = rFPGA0_XA_RFInterfaceOE;
  40. hal->PHYRegDef[ODM_RF_PATH_B].rfintfe = rFPGA0_XB_RFInterfaceOE;
  41. hal->PHYRegDef[ODM_RF_PATH_A].rf3wireOffset = rA_LSSIWrite_Jaguar;
  42. hal->PHYRegDef[ODM_RF_PATH_B].rf3wireOffset = rB_LSSIWrite_Jaguar;
  43. hal->PHYRegDef[ODM_RF_PATH_A].rfHSSIPara2 = rHSSIRead_Jaguar;
  44. hal->PHYRegDef[ODM_RF_PATH_B].rfHSSIPara2 = rHSSIRead_Jaguar;
  45. /* Tranceiver Readback LSSI/HSPI mode */
  46. hal->PHYRegDef[ODM_RF_PATH_A].rfLSSIReadBack = rA_SIRead_Jaguar;
  47. hal->PHYRegDef[ODM_RF_PATH_B].rfLSSIReadBack = rB_SIRead_Jaguar;
  48. hal->PHYRegDef[ODM_RF_PATH_A].rfLSSIReadBackPi = rA_PIRead_Jaguar;
  49. hal->PHYRegDef[ODM_RF_PATH_B].rfLSSIReadBackPi = rB_PIRead_Jaguar;
  50. }
  51. static void init_bb_rf(PADAPTER adapter)
  52. {
  53. u8 val8;
  54. u16 val16;
  55. /* Enable BB and RF */
  56. val8 = rtw_read8(adapter, REG_SYS_FUNC_EN_8821C);
  57. if (IS_HARDWARE_TYPE_8821CU(adapter))
  58. val8 |= BIT_FEN_USBA_8821C;
  59. else if (IS_HARDWARE_TYPE_8821CE(adapter))
  60. val8 |= BIT_FEN_PCIEA_8821C;
  61. rtw_write8(adapter, REG_SYS_FUNC_EN_8821C, val8);
  62. /*
  63. * 8821C MP Chip => Reset BB/RF ??
  64. * Need to set BBRSTB and GLB_RSTB = 1->0->1 to generate a postive edge and negtive edge for BB
  65. */
  66. val8 |= BIT_FEN_BB_GLB_RSTN_8821C | BIT_FEN_BBRSTB_8821C;
  67. rtw_write8(adapter, REG_SYS_FUNC_EN_8821C, val8);
  68. val8 &= ~(BIT_FEN_BB_GLB_RSTN_8821C | BIT_FEN_BBRSTB_8821C);
  69. rtw_write8(adapter, REG_SYS_FUNC_EN_8821C, val8);
  70. val8 |= BIT_FEN_BB_GLB_RSTN_8821C | BIT_FEN_BBRSTB_8821C;
  71. rtw_write8(adapter, REG_SYS_FUNC_EN_8821C, val8);
  72. val8 = BIT_RF_EN_8821C | BIT_RF_RSTB_8821C | BIT_RF_SDMRSTB_8821C;
  73. /* 0x1F[7:0] = 0x07 PathA RF Power On */
  74. rtw_write8(adapter, REG_RF_CTRL_8821C, val8);
  75. rtw_usleep_os(10);
  76. /*0xEC [31:24],BIT_WLRF1_CTRL, For WLRF1 control*/
  77. /* 0xEF[7:0] = 0x07 for RFE Type=2,BTG RF Power On*/
  78. rtw_write8(adapter, REG_WLRF1_8821C + 3, val8);
  79. rtw_usleep_os(10);
  80. }
  81. u8 rtl8821c_init_phy_parameter_mac(PADAPTER adapter)
  82. {
  83. u8 ret = _FAIL;
  84. PHAL_DATA_TYPE hal;
  85. hal = GET_HAL_DATA(adapter);
  86. #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE
  87. ret = phy_ConfigMACWithParaFile(adapter, PHY_FILE_MAC_REG);
  88. if (ret == _FAIL)
  89. #endif /* CONFIG_LOAD_PHY_PARA_FROM_FILE */
  90. {
  91. odm_config_mac_with_header_file(&hal->odmpriv);
  92. ret = _SUCCESS;
  93. }
  94. return ret;
  95. }
  96. static u8 _init_phy_parameter_bb(PADAPTER Adapter)
  97. {
  98. PHAL_DATA_TYPE hal = GET_HAL_DATA(Adapter);
  99. u8 ret = _TRUE;
  100. int res;
  101. enum hal_status status;
  102. /*
  103. * 1. Read PHY_REG.TXT BB INIT!!
  104. */
  105. #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE
  106. res = phy_ConfigBBWithParaFile(Adapter, PHY_FILE_PHY_REG, CONFIG_BB_PHY_REG);
  107. if (res == _FAIL)
  108. #endif
  109. {
  110. ret = _FALSE;
  111. status = odm_config_bb_with_header_file(&hal->odmpriv, CONFIG_BB_PHY_REG);
  112. if (HAL_STATUS_SUCCESS == status)
  113. ret = _TRUE;
  114. }
  115. if (ret != _TRUE) {
  116. RTW_INFO("%s: Write BB Reg Fail!!", __FUNCTION__);
  117. goto exit;
  118. }
  119. #if 0 /* def CONFIG_MP_INCLUDED */ /* No parameter with MP using currently by BB@Stanley.*/
  120. if (Adapter->registrypriv.mp_mode == 1) {
  121. /*
  122. * 1.1 Read PHY_REG_MP.TXT BB INIT!!
  123. */
  124. #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE
  125. res = phy_ConfigBBWithMpParaFile(Adapter, PHY_FILE_PHY_REG_MP);
  126. if (res == _FAIL)
  127. #endif
  128. {
  129. ret = _FALSE;
  130. status = odm_config_bb_with_header_file(&hal->odmpriv, CONFIG_BB_PHY_REG_MP);
  131. if (HAL_STATUS_SUCCESS == status)
  132. ret = _TRUE;
  133. }
  134. if (ret != _TRUE) {
  135. RTW_INFO("%s : Write BB Reg MP Fail!!", __FUNCTION__);
  136. goto exit;
  137. }
  138. }
  139. #endif /* CONFIG_MP_INCLUDED */
  140. /*
  141. * 2. Read BB AGC table Initialization
  142. */
  143. #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE
  144. res = phy_ConfigBBWithParaFile(Adapter, PHY_FILE_AGC_TAB, CONFIG_BB_AGC_TAB);
  145. if (res == _FAIL)
  146. #endif
  147. {
  148. ret = _FALSE;
  149. status = odm_config_bb_with_header_file(&hal->odmpriv, CONFIG_BB_AGC_TAB);
  150. if (HAL_STATUS_SUCCESS == status)
  151. ret = _TRUE;
  152. }
  153. if (ret != _TRUE) {
  154. RTW_INFO("%s: AGC Table Fail\n", __FUNCTION__);
  155. goto exit;
  156. }
  157. exit:
  158. return ret;
  159. }
  160. static u8 init_bb_reg(PADAPTER adapter)
  161. {
  162. u8 ret = _TRUE;
  163. PHAL_DATA_TYPE hal = GET_HAL_DATA(adapter);
  164. /*
  165. * Config BB and AGC
  166. */
  167. ret = _init_phy_parameter_bb(adapter);
  168. hal_set_crystal_cap(adapter, hal->crystal_cap);
  169. phy_set_bb_reg(adapter, rCCK0_FalseAlarmReport + 2, BIT2 | BIT6, 0);
  170. return ret;
  171. }
  172. static u8 _init_phy_parameter_rf(PADAPTER adapter)
  173. {
  174. u32 val32 = 0;
  175. u8 eRFPath;
  176. PBB_REGISTER_DEFINITION_T pPhyReg;
  177. PHAL_DATA_TYPE hal = GET_HAL_DATA(adapter);
  178. enum hal_status status;
  179. int res;
  180. u8 ret = _TRUE;
  181. /*
  182. * Initialize RF
  183. */
  184. for (eRFPath = 0; eRFPath < hal->NumTotalRFPath; eRFPath++) {
  185. pPhyReg = &hal->PHYRegDef[eRFPath];
  186. /* Initialize RF from configuration file */
  187. switch (eRFPath) {
  188. case RF_PATH_A:
  189. #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE
  190. res = PHY_ConfigRFWithParaFile(adapter, PHY_FILE_RADIO_A, eRFPath);
  191. if (res == _FAIL)
  192. #endif
  193. {
  194. ret = _FALSE;
  195. status = odm_config_rf_with_header_file(&hal->odmpriv, CONFIG_RF_RADIO, (enum odm_rf_radio_path_e)eRFPath);
  196. if (HAL_STATUS_SUCCESS == status)
  197. ret = _TRUE;
  198. }
  199. break;
  200. case RF_PATH_B:
  201. #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE
  202. res = PHY_ConfigRFWithParaFile(adapter, PHY_FILE_RADIO_B, eRFPath);
  203. if (res == _FAIL)
  204. #endif
  205. {
  206. ret = _FALSE;
  207. status = odm_config_rf_with_header_file(&hal->odmpriv, CONFIG_RF_RADIO, (enum odm_rf_radio_path_e)eRFPath);
  208. if (HAL_STATUS_SUCCESS == status)
  209. ret = _TRUE;
  210. }
  211. break;
  212. case RF_PATH_C:
  213. break;
  214. case RF_PATH_D:
  215. break;
  216. }
  217. if (ret != _TRUE)
  218. goto exit;
  219. }
  220. /*
  221. * Configuration of Tx Power Tracking
  222. */
  223. #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE
  224. res = PHY_ConfigRFWithTxPwrTrackParaFile(adapter, PHY_FILE_TXPWR_TRACK);
  225. if (res == _FAIL)
  226. #endif
  227. {
  228. ret = _FALSE;
  229. status = odm_config_rf_with_tx_pwr_track_header_file(&hal->odmpriv);
  230. if (HAL_STATUS_SUCCESS == status)
  231. ret = _TRUE;
  232. }
  233. if (ret != _TRUE)
  234. goto exit;
  235. exit:
  236. return ret;
  237. }
  238. static u8 init_rf_reg(PADAPTER adapter)
  239. {
  240. u8 ret = _TRUE;
  241. ret = _init_phy_parameter_rf(adapter);
  242. return ret;
  243. }
  244. u8 rtl8821c_phy_init(PADAPTER adapter)
  245. {
  246. PHAL_DATA_TYPE hal;
  247. struct PHY_DM_STRUCT *phydm;
  248. hal = GET_HAL_DATA(adapter);
  249. phydm = &hal->odmpriv;
  250. bb_rf_register_definition(adapter);
  251. init_bb_rf(adapter);
  252. if (_FALSE == config_phydm_parameter_init_8821c(phydm, ODM_PRE_SETTING))
  253. return _FALSE;
  254. if (_FALSE == init_bb_reg(adapter))
  255. return _FALSE;
  256. if (_FALSE == init_rf_reg(adapter))
  257. return _FALSE;
  258. #if 0
  259. if (_FALSE = config_phydm_trx_mode_8821c(phydm, ODM_RF_A, ODM_RF_A, FALSE))
  260. return _FALSE;
  261. #endif
  262. if (_FALSE == config_phydm_parameter_init_8821c(phydm, ODM_POST_SETTING))
  263. return _FALSE;
  264. hal->phy_spec.trx_cap = query_phydm_trx_capability(phydm);
  265. hal->phy_spec.stbc_cap = query_phydm_stbc_capability(phydm);
  266. hal->phy_spec.ldpc_cap = query_phydm_ldpc_capability(phydm);
  267. hal->phy_spec.txbf_param = query_phydm_txbf_parameters(phydm);
  268. hal->phy_spec.txbf_cap = query_phydm_txbf_capability(phydm);
  269. /*rtw_dump_phy_cap(RTW_DBGDUMP, adapter);*/
  270. return _TRUE;
  271. }
  272. static u32 phy_calculatebitshift(u32 mask)
  273. {
  274. u32 i;
  275. for (i = 0; i <= 31; i++)
  276. if (mask & BIT(i))
  277. break;
  278. return i;
  279. }
  280. u32 rtl8821c_read_bb_reg(PADAPTER adapter, u32 addr, u32 mask)
  281. {
  282. u32 val = 0, val_org, shift;
  283. #if (DISABLE_BB_RF == 1)
  284. return 0;
  285. #endif
  286. val_org = rtw_read32(adapter, addr);
  287. shift = phy_calculatebitshift(mask);
  288. val = (val_org & mask) >> shift;
  289. return val;
  290. }
  291. void rtl8821c_write_bb_reg(PADAPTER adapter, u32 addr, u32 mask, u32 val)
  292. {
  293. u32 val_org, shift;
  294. #if (DISABLE_BB_RF == 1)
  295. return;
  296. #endif
  297. if (mask != 0xFFFFFFFF) {
  298. /* not "double word" write */
  299. val_org = rtw_read32(adapter, addr);
  300. shift = phy_calculatebitshift(mask);
  301. val = ((val_org & (~mask)) | ((val << shift) & mask));
  302. }
  303. rtw_write32(adapter, addr, val);
  304. }
  305. u32 rtl8821c_read_rf_reg(PADAPTER adapter, u8 path, u32 addr, u32 mask)
  306. {
  307. PHAL_DATA_TYPE hal;
  308. struct PHY_DM_STRUCT *phydm;
  309. u32 val = 0;
  310. hal = GET_HAL_DATA(adapter);
  311. phydm = &hal->odmpriv;
  312. val = config_phydm_read_rf_reg_8821c(phydm, path, addr, mask);
  313. if (!config_phydm_read_rf_check_8821c(val))
  314. RTW_INFO(FUNC_ADPT_FMT ": read RF reg path=%d addr=0x%x mask=0x%x FAIL!\n",
  315. FUNC_ADPT_ARG(adapter), path, addr, mask);
  316. return val;
  317. }
  318. void rtl8821c_write_rf_reg(PADAPTER adapter, u8 path, u32 addr, u32 mask, u32 val)
  319. {
  320. PHAL_DATA_TYPE hal;
  321. struct PHY_DM_STRUCT *phydm;
  322. u8 ret;
  323. hal = GET_HAL_DATA(adapter);
  324. phydm = &hal->odmpriv;
  325. ret = config_phydm_write_rf_reg_8821c(phydm, path, addr, mask, val);
  326. if (_FALSE == ret)
  327. RTW_INFO(FUNC_ADPT_FMT ": write RF reg path=%d addr=0x%x mask=0x%x val=0x%x FAIL!\n",
  328. FUNC_ADPT_ARG(adapter), path, addr, mask, val);
  329. }
  330. void rtl8821c_set_tx_power_level(PADAPTER adapter, u8 channel)
  331. {
  332. PHAL_DATA_TYPE hal = GET_HAL_DATA(adapter);
  333. u8 path = ODM_RF_PATH_A;
  334. struct PHY_DM_STRUCT *phydm = &hal->odmpriv;
  335. struct _FAST_ANTENNA_TRAINNING_ *pDM_FatTable = &phydm->dm_fat_table;
  336. /*((hal->RFEType == 2) || (hal->RFEType == 4) || (hal->RFEType == 7))*/
  337. if ((channel <= 14) && (SWITCH_TO_BTG == query_phydm_default_rf_set_8821c(phydm)))
  338. path = ODM_RF_PATH_B;
  339. /*if (adapter->registrypriv.mp_mode == 1)*/
  340. phy_set_tx_power_index_by_rate_section(adapter, path, channel, CCK);
  341. phy_set_tx_power_index_by_rate_section(adapter, path, channel, OFDM);
  342. phy_set_tx_power_index_by_rate_section(adapter, path, channel, HT_MCS0_MCS7);
  343. phy_set_tx_power_index_by_rate_section(adapter, path, channel, VHT_1SSMCS0_1SSMCS9);
  344. }
  345. void rtl8821c_get_tx_power_level(PADAPTER adapter, s32 *power)
  346. {
  347. }
  348. /*
  349. * Parameters:
  350. * padatper
  351. * powerindex power index for rate
  352. * rfpath Antenna(RF) path, type "enum odm_rf_radio_path_e"
  353. * rate data rate, type "enum MGN_RATE"
  354. */
  355. /*#define DBG_SET_TX_POWER_IDX*/
  356. void rtl8821c_set_tx_power_index(PADAPTER adapter, u32 powerindex, u8 rfpath, u8 rate)
  357. {
  358. PHAL_DATA_TYPE hal = GET_HAL_DATA(adapter);
  359. struct PHY_DM_STRUCT *phydm = &hal->odmpriv;
  360. u8 shift = 0;
  361. u8 hw_rate_idx;
  362. static u32 index = 0;
  363. /*hw_rate_idx = PHY_GetRateIndexOfTxPowerByRate(rate);*/
  364. hw_rate_idx = MRateToHwRate(rate);
  365. if (hw_rate_idx > DESC_RATEVHTSS1MCS9) {
  366. RTW_ERR(FUNC_ADPT_FMT"warn rate(%s)\n", FUNC_ADPT_ARG(adapter), HDATA_RATE(hw_rate_idx));
  367. rtw_warn_on(1);
  368. }
  369. if (rfpath > ODM_RF_PATH_A) {
  370. #ifdef DBG_SET_TX_POWER_IDX
  371. RTW_INFO(FUNC_ADPT_FMT" rfpath(%d) power index to ODM_RF_PATH_A\n", FUNC_ADPT_ARG(adapter), rfpath);
  372. #endif
  373. rfpath = ODM_RF_PATH_A;
  374. }
  375. /*
  376. * For 8821C, phydm api use 4 bytes txagc value
  377. * driver must combine every four 1 byte to one 4 byte and send to phydm api
  378. */
  379. shift = hw_rate_idx % 4;
  380. index |= ((powerindex & 0xff) << (shift * 8));
  381. if (shift == 3) {
  382. hw_rate_idx = hw_rate_idx - 3;
  383. if (!config_phydm_write_txagc_8821c(phydm, index, rfpath, hw_rate_idx)) {
  384. RTW_ERR(FUNC_ADPT_FMT" (power index:0x%02x, rfpath:%d, rate:0x%02x, disable api:%d) wite TX-AGC failed\n",
  385. FUNC_ADPT_ARG(adapter), index, rfpath, hw_rate_idx, phydm->is_disable_phy_api);
  386. rtw_warn_on(1);
  387. }
  388. #ifdef DBG_SET_TX_POWER_IDX
  389. RTW_INFO(FUNC_ADPT_FMT"Rate:%s ,tx_power_idx: 0x%08x\n", FUNC_ADPT_ARG(adapter), HDATA_RATE(hw_rate_idx), index);
  390. #endif
  391. index = 0;
  392. }
  393. if (MGN_VHT1SS_MCS9 == rate) {
  394. if (!config_phydm_write_txagc_8821c(phydm, index, rfpath, MRateToHwRate(MGN_VHT1SS_MCS8))) {
  395. RTW_ERR(FUNC_ADPT_FMT" (power index:0x%02x, rfpath:%d, rate:0x%02x, disable api:%d) wite TX-AGC failed\n",
  396. FUNC_ADPT_ARG(adapter), index, rfpath, hw_rate_idx, phydm->is_disable_phy_api);
  397. rtw_warn_on(1);
  398. }
  399. #ifdef DBG_SET_TX_POWER_IDX
  400. RTW_INFO(FUNC_ADPT_FMT"-Rate:%s ,tx_power_idx: 0x%08x\n", FUNC_ADPT_ARG(adapter), HDATA_RATE(MRateToHwRate(MGN_VHT1SS_MCS8)), index);
  401. #endif
  402. index = 0;
  403. }
  404. }
  405. static u8 rtl8821c_phy_get_current_tx_num(PADAPTER adapter, u8 rate)
  406. {
  407. u8 tx_num = 0;
  408. if ((rate >= MGN_MCS8 && rate <= MGN_MCS15) ||
  409. (rate >= MGN_VHT2SS_MCS0 && rate <= MGN_VHT2SS_MCS9))
  410. tx_num = RF_2TX;
  411. else
  412. tx_num = RF_1TX;
  413. return tx_num;
  414. }
  415. /*
  416. * Parameters:
  417. * padatper
  418. * rfpath Antenna(RF) path, type "enum odm_rf_radio_path_e"
  419. * rate data rate, type "enum MGN_RATE"
  420. * bandwidth Bandwidth, type "enum _CHANNEL_WIDTH"
  421. * channel Channel number
  422. *
  423. * Rteurn:
  424. * tx_power power index for rate
  425. */
  426. u8 rtl8821c_get_tx_power_index(PADAPTER adapter, u8 rfpath, u8 rate, u8 bandwidth, u8 channel, struct txpwr_idx_comp *tic)
  427. {
  428. PHAL_DATA_TYPE hal = GET_HAL_DATA(adapter);
  429. u8 base_idx = 0, power_idx = 0;
  430. s8 by_rate_diff = 0, limit = 0, tpt_offset = 0, extra_bias = 0;
  431. u8 tx_num = rtl8821c_phy_get_current_tx_num(adapter, rate);
  432. u8 bIn24G = _FALSE;
  433. base_idx = PHY_GetTxPowerIndexBase(adapter, rfpath, rate, bandwidth, channel, &bIn24G);
  434. by_rate_diff = PHY_GetTxPowerByRate(adapter, (u8)(!bIn24G), rfpath, tx_num, rate);
  435. limit = PHY_GetTxPowerLimit(adapter, adapter->registrypriv.RegPwrTblSel, (BAND_TYPE)(!bIn24G),
  436. hal->current_channel_bw, rfpath, rate, hal->current_channel);
  437. /* tpt_offset += PHY_GetTxPowerTrackingOffset(adapter, rfpath, rate); */
  438. if (tic) {
  439. tic->base = base_idx;
  440. tic->by_rate = by_rate_diff;
  441. tic->limit = limit;
  442. tic->tpt = tpt_offset;
  443. tic->ebias = extra_bias;
  444. }
  445. by_rate_diff = by_rate_diff > limit ? limit : by_rate_diff;
  446. power_idx = base_idx + by_rate_diff + tpt_offset + extra_bias;
  447. #if 0
  448. #if CCX_SUPPORT
  449. CCX_CellPowerLimit(adapter, channel, rate, (pu1Byte)&power_idx);
  450. #endif
  451. #endif
  452. if (power_idx > MAX_POWER_INDEX)
  453. power_idx = MAX_POWER_INDEX;
  454. return power_idx;
  455. }
  456. /*
  457. * Description:
  458. * Check need to switch band or not
  459. * Parameters:
  460. * channelToSW channel wiii be switch to
  461. * Return:
  462. * _TRUE need to switch band
  463. * _FALSE not need to switch band
  464. */
  465. static u8 need_switch_band(PADAPTER adapter, u8 channelToSW)
  466. {
  467. u8 u1tmp = 0;
  468. u8 ret_value = _TRUE;
  469. u8 Band = BAND_ON_5G, BandToSW = BAND_ON_5G;
  470. PHAL_DATA_TYPE hal = GET_HAL_DATA(adapter);
  471. Band = hal->current_band_type;
  472. /* Use current swich channel to judge Band Type and switch Band if need */
  473. if (channelToSW > 14)
  474. BandToSW = BAND_ON_5G;
  475. else
  476. BandToSW = BAND_ON_2_4G;
  477. if (BandToSW != Band) {
  478. /* record current band type for other hal use */
  479. hal->current_band_type = (BAND_TYPE)BandToSW;
  480. ret_value = _TRUE;
  481. } else
  482. ret_value = _FALSE;
  483. return ret_value;
  484. }
  485. static u8 get_pri_ch_id(PADAPTER adapter)
  486. {
  487. u8 pri_ch_idx = 0;
  488. PHAL_DATA_TYPE hal = GET_HAL_DATA(adapter);
  489. if (hal->current_channel_bw == CHANNEL_WIDTH_80) {
  490. /* primary channel is at lower subband of 80MHz & 40MHz */
  491. if ((hal->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) && (hal->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER))
  492. pri_ch_idx = VHT_DATA_SC_20_LOWEST_OF_80MHZ;
  493. /* primary channel is at lower subband of 80MHz & upper subband of 40MHz */
  494. else if ((hal->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) && (hal->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER))
  495. pri_ch_idx = VHT_DATA_SC_20_LOWER_OF_80MHZ;
  496. /* primary channel is at upper subband of 80MHz & lower subband of 40MHz */
  497. else if ((hal->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) && (hal->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER))
  498. pri_ch_idx = VHT_DATA_SC_20_UPPER_OF_80MHZ;
  499. /* primary channel is at upper subband of 80MHz & upper subband of 40MHz */
  500. else if ((hal->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) && (hal->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER))
  501. pri_ch_idx = VHT_DATA_SC_20_UPPERST_OF_80MHZ;
  502. else {
  503. if (hal->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER)
  504. pri_ch_idx = VHT_DATA_SC_40_LOWER_OF_80MHZ;
  505. else if (hal->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER)
  506. pri_ch_idx = VHT_DATA_SC_40_UPPER_OF_80MHZ;
  507. else
  508. RTW_INFO("SCMapping: DONOT CARE Mode Setting\n");
  509. }
  510. } else if (hal->current_channel_bw == CHANNEL_WIDTH_40) {
  511. /* primary channel is at upper subband of 40MHz */
  512. if (hal->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER)
  513. pri_ch_idx = VHT_DATA_SC_20_UPPER_OF_80MHZ;
  514. /* primary channel is at lower subband of 40MHz */
  515. else if (hal->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER)
  516. pri_ch_idx = VHT_DATA_SC_20_LOWER_OF_80MHZ;
  517. else
  518. RTW_INFO("SCMapping: DONOT CARE Mode Setting\n");
  519. }
  520. return pri_ch_idx;
  521. }
  522. static void mac_switch_bandwidth(PADAPTER adapter, u8 pri_ch_idx)
  523. {
  524. u8 channel = 0, bw = 0;
  525. PHAL_DATA_TYPE hal = GET_HAL_DATA(adapter);
  526. int err;
  527. channel = hal->current_channel;
  528. bw = hal->current_channel_bw;
  529. err = rtw_halmac_set_bandwidth(adapter_to_dvobj(adapter), channel, pri_ch_idx, bw);
  530. if (err) {
  531. RTW_INFO(FUNC_ADPT_FMT ": (channel=%d, pri_ch_idx=%d, bw=%d) fail\n",
  532. FUNC_ADPT_ARG(adapter), channel, pri_ch_idx, bw);
  533. }
  534. }
  535. u32 phy_get_tx_bbswing_8812c(_adapter *adapter, BAND_TYPE band, u8 rf_path)
  536. {
  537. HAL_DATA_TYPE *pHalData = GET_HAL_DATA(adapter);
  538. struct PHY_DM_STRUCT *pDM_Odm = &pHalData->odmpriv;
  539. struct odm_rf_calibration_structure *pRFCalibrateInfo = &(pDM_Odm->rf_calibrate_info);
  540. s8 bbSwing_2G = -1 * GetRegTxBBSwing_2G(adapter);
  541. s8 bbSwing_5G = -1 * GetRegTxBBSwing_5G(adapter);
  542. u32 out = 0x200;
  543. const s8 AUTO = -1;
  544. if (pHalData->bautoload_fail_flag) {
  545. if (band == BAND_ON_2_4G) {
  546. pRFCalibrateInfo->bb_swing_diff_2g = bbSwing_2G;
  547. if (bbSwing_2G == 0)
  548. out = 0x200; /* 0 dB */
  549. else if (bbSwing_2G == -3)
  550. out = 0x16A; /* -3 dB */
  551. else if (bbSwing_2G == -6)
  552. out = 0x101; /* -6 dB */
  553. else if (bbSwing_2G == -9)
  554. out = 0x0B6; /* -9 dB */
  555. else {
  556. if (pHalData->ExternalPA_2G) {
  557. pRFCalibrateInfo->bb_swing_diff_2g = -3;
  558. out = 0x16A;
  559. } else {
  560. pRFCalibrateInfo->bb_swing_diff_2g = 0;
  561. out = 0x200;
  562. }
  563. }
  564. } else if (band == BAND_ON_5G) {
  565. pRFCalibrateInfo->bb_swing_diff_5g = bbSwing_5G;
  566. if (bbSwing_5G == 0)
  567. out = 0x200; /* 0 dB */
  568. else if (bbSwing_5G == -3)
  569. out = 0x16A; /* -3 dB */
  570. else if (bbSwing_5G == -6)
  571. out = 0x101; /* -6 dB */
  572. else if (bbSwing_5G == -9)
  573. out = 0x0B6; /* -9 dB */
  574. else {
  575. if (pHalData->external_pa_5g) {
  576. pRFCalibrateInfo->bb_swing_diff_5g = -3;
  577. out = 0x16A;
  578. } else {
  579. pRFCalibrateInfo->bb_swing_diff_5g = 0;
  580. out = 0x200;
  581. }
  582. }
  583. } else {
  584. pRFCalibrateInfo->bb_swing_diff_2g = -3;
  585. pRFCalibrateInfo->bb_swing_diff_5g = -3;
  586. out = 0x16A; /* -3 dB */
  587. }
  588. } else {
  589. u32 swing = 0, onePathSwing = 0;
  590. if (band == BAND_ON_2_4G) {
  591. if (GetRegTxBBSwing_2G(adapter) == AUTO)
  592. swing = pHalData->tx_bbswing_24G;
  593. else if (bbSwing_2G == 0)
  594. swing = 0x00; /* 0 dB */
  595. else if (bbSwing_2G == -3)
  596. swing = 0x55; /* -3 dB */
  597. else if (bbSwing_2G == -6)
  598. swing = 0xAA; /* -6 dB */
  599. else if (bbSwing_2G == -9)
  600. swing = 0xFF; /* -9 dB */
  601. else
  602. swing = 0x00;
  603. } else {
  604. if (GetRegTxBBSwing_5G(adapter) == AUTO)
  605. swing = pHalData->tx_bbswing_5G;
  606. else if (bbSwing_5G == 0)
  607. swing = 0x00; /* 0 dB */
  608. else if (bbSwing_5G == -3)
  609. swing = 0x55; /* -3 dB */
  610. else if (bbSwing_5G == -6)
  611. swing = 0xAA; /* -6 dB */
  612. else if (bbSwing_5G == -9)
  613. swing = 0xFF; /* -9 dB */
  614. else
  615. swing = 0x00;
  616. }
  617. if (rf_path == ODM_RF_PATH_A)
  618. onePathSwing = (swing & 0x3) >> 0; /* 0xC6/C7[1:0] */
  619. if (onePathSwing == 0x0) {
  620. if (band == BAND_ON_2_4G)
  621. pRFCalibrateInfo->bb_swing_diff_2g = 0;
  622. else
  623. pRFCalibrateInfo->bb_swing_diff_5g = 0;
  624. out = 0x200; /* 0 dB */
  625. } else if (onePathSwing == 0x1) {
  626. if (band == BAND_ON_2_4G)
  627. pRFCalibrateInfo->bb_swing_diff_2g = -3;
  628. else
  629. pRFCalibrateInfo->bb_swing_diff_5g = -3;
  630. out = 0x16A; /* -3 dB */
  631. } else if (onePathSwing == 0x2) {
  632. if (band == BAND_ON_2_4G)
  633. pRFCalibrateInfo->bb_swing_diff_2g = -6;
  634. else
  635. pRFCalibrateInfo->bb_swing_diff_5g = -6;
  636. out = 0x101; /* -6 dB */
  637. } else if (onePathSwing == 0x3) {
  638. if (band == BAND_ON_2_4G)
  639. pRFCalibrateInfo->bb_swing_diff_2g = -9;
  640. else
  641. pRFCalibrateInfo->bb_swing_diff_5g = -9;
  642. out = 0x0B6; /* -9 dB */
  643. }
  644. }
  645. /* RTW_INFO("<=== PHY_GetTxBBSwing_8812C, out = 0x%X\n", out); */
  646. return out;
  647. }
  648. void phy_set_bb_swing_by_band_8812c(_adapter *adapter, u8 band, u8 previous_band)
  649. {
  650. HAL_DATA_TYPE *pHalData = GET_HAL_DATA(adapter);
  651. s8 BBDiffBetweenBand = 0;
  652. struct PHY_DM_STRUCT *pDM_Odm = &pHalData->odmpriv;
  653. struct odm_rf_calibration_structure *pRFCalibrateInfo = &(pDM_Odm->rf_calibrate_info);
  654. phy_set_bb_reg(adapter, rA_TxScale_Jaguar, 0xFFE00000,
  655. phy_get_tx_bbswing_8812c(adapter, (BAND_TYPE)band, ODM_RF_PATH_A)); /* 0xC1C[31:21] */
  656. /* When TxPowerTrack is ON, we should take care of the change of BB swing. */
  657. /* That is, reset all info to trigger Tx power tracking. */
  658. {
  659. if (band != previous_band) {
  660. BBDiffBetweenBand = (pRFCalibrateInfo->bb_swing_diff_2g - pRFCalibrateInfo->bb_swing_diff_5g);
  661. BBDiffBetweenBand = (band == BAND_ON_2_4G) ? BBDiffBetweenBand : (-1 * BBDiffBetweenBand);
  662. pRFCalibrateInfo->default_ofdm_index += BBDiffBetweenBand * 2;
  663. }
  664. odm_clear_txpowertracking_state(pDM_Odm);
  665. }
  666. }
  667. void phy_switch_wireless_band_8821c(_adapter *adapter)
  668. {
  669. u8 ret = 0;
  670. PHAL_DATA_TYPE hal_data = GET_HAL_DATA(adapter);
  671. struct PHY_DM_STRUCT *pDM_Odm = &hal_data->odmpriv;
  672. u8 current_band = hal_data->current_band_type;
  673. if (need_switch_band(adapter, hal_data->current_channel) == _TRUE) {
  674. #ifdef CONFIG_BT_COEXIST
  675. if (hal_data->EEPROMBluetoothCoexist) {
  676. struct mlme_ext_priv *mlmeext;
  677. /* switch band under site survey or not, must notify to BT COEX */
  678. mlmeext = &adapter->mlmeextpriv;
  679. if (mlmeext_scan_state(mlmeext) != SCAN_DISABLE)
  680. rtw_btcoex_switchband_notify(_TRUE, hal_data->current_band_type);
  681. else
  682. rtw_btcoex_switchband_notify(_FALSE, hal_data->current_band_type);
  683. } else
  684. rtw_btcoex_wifionly_switchband_notify(adapter);
  685. #else /* !CONFIG_BT_COEXIST */
  686. rtw_btcoex_wifionly_switchband_notify(adapter);
  687. #endif /* CONFIG_BT_COEXIST */
  688. /* hal->current_channel is center channel of pmlmeext->cur_channel(primary channel) */
  689. ret = config_phydm_switch_band_8821c(pDM_Odm, hal_data->current_channel);
  690. if (!ret) {
  691. RTW_ERR("%s: config_phydm_switch_band_8821c fail\n", __func__);
  692. rtw_warn_on(1);
  693. return;
  694. }
  695. phy_set_bb_swing_by_band_8812c(adapter, hal_data->current_band_type, current_band);
  696. }
  697. }
  698. /*
  699. * Description:
  700. * Set channel & bandwidth & offset
  701. */
  702. void rtl8821c_switch_chnl_and_set_bw(PADAPTER adapter)
  703. {
  704. PHAL_DATA_TYPE hal = GET_HAL_DATA(adapter);
  705. struct PHY_DM_STRUCT *pDM_Odm = &hal->odmpriv;
  706. u8 center_ch = 0, ret = 0;
  707. if (adapter->bNotifyChannelChange) {
  708. RTW_INFO("[%s] bSwChnl=%d, ch=%d, bSetChnlBW=%d, bw=%d\n",
  709. __FUNCTION__,
  710. hal->bSwChnl,
  711. hal->current_channel,
  712. hal->bSetChnlBW,
  713. hal->current_channel_bw);
  714. }
  715. if (RTW_CANNOT_RUN(adapter)) {
  716. hal->bSwChnlAndSetBWInProgress = _FALSE;
  717. return;
  718. }
  719. /* set channel & Bandwidth register */
  720. /* 1. set switch band register if need to switch band */
  721. phy_switch_wireless_band_8821c(adapter);
  722. /* 2. set channel register */
  723. if (hal->bSwChnl) {
  724. ret = config_phydm_switch_channel_8821c(pDM_Odm, hal->current_channel);
  725. hal->bSwChnl = _FALSE;
  726. if (!ret) {
  727. RTW_INFO("%s: config_phydm_switch_channel_8821c fail\n", __FUNCTION__);
  728. rtw_warn_on(1);
  729. return;
  730. }
  731. }
  732. phydm_config_kfree(pDM_Odm, hal->current_channel);
  733. /* 3. set Bandwidth register */
  734. if (hal->bSetChnlBW) {
  735. /* get primary channel index */
  736. u8 pri_ch_idx = get_pri_ch_id(adapter);
  737. /* 3.1 set MAC register */
  738. mac_switch_bandwidth(adapter, pri_ch_idx);
  739. /* 3.2 set BB/RF registet */
  740. ret = config_phydm_switch_bandwidth_8821c(pDM_Odm, pri_ch_idx, hal->current_channel_bw);
  741. hal->bSetChnlBW = _FALSE;
  742. if (!ret) {
  743. RTW_INFO("%s: config_phydm_switch_bandwidth_8821c fail\n", __FUNCTION__);
  744. rtw_warn_on(1);
  745. return;
  746. }
  747. }
  748. /* TX Power Setting */
  749. /* odm_clear_txpowertracking_state(pDM_Odm); */
  750. rtw_hal_set_tx_power_level(adapter, hal->current_channel);
  751. /* IQK */
  752. if ((hal->bNeedIQK == _TRUE)
  753. || (adapter->registrypriv.mp_mode == 1)) {
  754. #ifdef CONFIG_IQK_MONITOR
  755. u32 iqk_start_time = rtw_get_current_time();
  756. #endif
  757. phy_iq_calibrate_8821c(pDM_Odm, _FALSE);
  758. #ifdef CONFIG_IQK_MONITOR
  759. RTW_INFO(ADPT_FMT" switch CH(%d) DO IQK : %d ms\n",
  760. ADPT_ARG(adapter), hal->current_channel, rtw_get_passing_time_ms(iqk_start_time));
  761. #endif
  762. hal->bNeedIQK = _FALSE;
  763. }
  764. }
  765. /*
  766. * Description:
  767. * Store channel setting to hal date
  768. * Parameters:
  769. * bSwitchChannel swith channel or not
  770. * bSetBandWidth set band or not
  771. * ChannelNum center channel
  772. * ChnlWidth bandwidth
  773. * ChnlOffsetOf40MHz channel offset for 40MHz Bandwidth
  774. * ChnlOffsetOf80MHz channel offset for 80MHz Bandwidth
  775. * CenterFrequencyIndex1 center channel index
  776. */
  777. void rtl8821c_handle_sw_chnl_and_set_bw(
  778. PADAPTER Adapter, u8 bSwitchChannel, u8 bSetBandWidth,
  779. u8 ChannelNum, CHANNEL_WIDTH ChnlWidth, u8 ChnlOffsetOf40MHz,
  780. u8 ChnlOffsetOf80MHz, u8 CenterFrequencyIndex1)
  781. {
  782. PHAL_DATA_TYPE hal = GET_HAL_DATA(Adapter);
  783. u8 tmpChannel = hal->current_channel;
  784. CHANNEL_WIDTH tmpBW = hal->current_channel_bw;
  785. u8 tmpnCur40MhzPrimeSC = hal->nCur40MhzPrimeSC;
  786. u8 tmpnCur80MhzPrimeSC = hal->nCur80MhzPrimeSC;
  787. u8 tmpCenterFrequencyIndex1 = hal->CurrentCenterFrequencyIndex1;
  788. struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv;
  789. /* check swchnl or setbw */
  790. if (!bSwitchChannel && !bSetBandWidth) {
  791. RTW_INFO("%s: not switch channel and not set bandwidth\n", __FUNCTION__);
  792. return;
  793. }
  794. /* skip switch channel operation for current channel & ChannelNum(will be switch) are the same */
  795. if (bSwitchChannel) {
  796. if (hal->current_channel != ChannelNum) {
  797. if (HAL_IsLegalChannel(Adapter, ChannelNum))
  798. hal->bSwChnl = _TRUE;
  799. else
  800. return;
  801. }
  802. }
  803. /* check set BandWidth */
  804. if (bSetBandWidth) {
  805. /* initial channel bw setting */
  806. if (hal->bChnlBWInitialized == _FALSE) {
  807. hal->bChnlBWInitialized = _TRUE;
  808. hal->bSetChnlBW = _TRUE;
  809. } else if ((hal->current_channel_bw != ChnlWidth) || /* check whether need set band or not */
  810. (hal->nCur40MhzPrimeSC != ChnlOffsetOf40MHz) ||
  811. (hal->nCur80MhzPrimeSC != ChnlOffsetOf80MHz) ||
  812. (hal->CurrentCenterFrequencyIndex1 != CenterFrequencyIndex1))
  813. hal->bSetChnlBW = _TRUE;
  814. }
  815. /* return if not need set bandwidth nor channel after check*/
  816. if (!hal->bSetChnlBW && !hal->bSwChnl && hal->bNeedIQK != _TRUE)
  817. return;
  818. /* set channel number to hal data */
  819. if (hal->bSwChnl) {
  820. hal->current_channel = ChannelNum;
  821. hal->CurrentCenterFrequencyIndex1 = ChannelNum;
  822. }
  823. /* set bandwidth info to hal data */
  824. if (hal->bSetChnlBW) {
  825. hal->current_channel_bw = ChnlWidth;
  826. hal->nCur40MhzPrimeSC = ChnlOffsetOf40MHz;
  827. hal->nCur80MhzPrimeSC = ChnlOffsetOf80MHz;
  828. hal->CurrentCenterFrequencyIndex1 = CenterFrequencyIndex1;
  829. }
  830. /* switch channel & bandwidth */
  831. if (!RTW_CANNOT_RUN(Adapter))
  832. rtl8821c_switch_chnl_and_set_bw(Adapter);
  833. else {
  834. if (hal->bSwChnl) {
  835. hal->current_channel = tmpChannel;
  836. hal->CurrentCenterFrequencyIndex1 = tmpChannel;
  837. }
  838. if (hal->bSetChnlBW) {
  839. hal->current_channel_bw = tmpBW;
  840. hal->nCur40MhzPrimeSC = tmpnCur40MhzPrimeSC;
  841. hal->nCur80MhzPrimeSC = tmpnCur80MhzPrimeSC;
  842. hal->CurrentCenterFrequencyIndex1 = tmpCenterFrequencyIndex1;
  843. }
  844. }
  845. }
  846. /*
  847. * Description:
  848. * Change channel, bandwidth & offset
  849. * Parameters:
  850. * center_ch center channel
  851. * bw bandwidth
  852. * offset40 channel offset for 40MHz Bandwidth
  853. * offset80 channel offset for 80MHz Bandwidth
  854. */
  855. void rtl8821c_set_channel_bw(PADAPTER adapter, u8 center_ch, CHANNEL_WIDTH bw, u8 offset40, u8 offset80)
  856. {
  857. rtl8821c_handle_sw_chnl_and_set_bw(adapter, _TRUE, _TRUE, center_ch, bw, offset40, offset80, center_ch);
  858. }
  859. void rtl8821c_notch_filter_switch(PADAPTER adapter, bool enable)
  860. {
  861. if (enable)
  862. RTW_INFO("%s: Enable notch filter\n", __FUNCTION__);
  863. else
  864. RTW_INFO("%s: Disable notch filter\n", __FUNCTION__);
  865. }
  866. #ifdef CONFIG_MP_INCLUDED
  867. /*
  868. * Description:
  869. * Config RF path
  870. *
  871. * Parameters:
  872. * adapter pointer of struct _ADAPTER
  873. */
  874. void rtl8821c_mp_config_rfpath(PADAPTER adapter)
  875. {
  876. PHAL_DATA_TYPE hal;
  877. PMPT_CONTEXT mpt;
  878. ANTENNA_PATH anttx, antrx;
  879. enum odm_rf_path_e rxant;
  880. hal = GET_HAL_DATA(adapter);
  881. mpt = &adapter->mppriv.mpt_ctx;
  882. anttx = hal->antenna_tx_path;
  883. antrx = hal->AntennaRxPath;
  884. RTW_INFO("+Config RF Path, tx=0x%x rx=0x%x\n", anttx, antrx);
  885. #if 0 /* phydm not ready */
  886. switch (anttx) {
  887. case ANTENNA_A:
  888. mpt->mpt_rf_path = ODM_RF_A;
  889. break;
  890. case ANTENNA_B:
  891. mpt->mpt_rf_path = ODM_RF_B;
  892. break;
  893. case ANTENNA_AB:
  894. default:
  895. mpt->mpt_rf_path = ODM_RF_A | ODM_RF_B;
  896. break;
  897. }
  898. switch (antrx) {
  899. case ANTENNA_A:
  900. rxant = ODM_RF_A;
  901. break;
  902. case ANTENNA_B:
  903. rxant = ODM_RF_B;
  904. break;
  905. case ANTENNA_AB:
  906. default:
  907. rxant = ODM_RF_A | ODM_RF_B;
  908. break;
  909. }
  910. config_phydm_trx_mode_8821c(GET_PDM_ODM(adapter), mpt->mpt_rf_path, rxant, FALSE);
  911. #endif
  912. RTW_INFO("-Config RF Path Finish\n");
  913. }
  914. #endif /* CONFIG_MP_INCLUDED */