rtl8821c_phy.c 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2016 - 2017 Realtek Corporation.
  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. *****************************************************************************/
  15. #define _RTL8821C_PHY_C_
  16. #include <hal_data.h> /* HAL_DATA_TYPE */
  17. #include "../hal_halmac.h" /* REG_CCK_CHECK_8821C */
  18. #include "rtl8821c.h"
  19. /*
  20. * Description:
  21. * Initialize Register definition offset for Radio Path A/B/C/D
  22. * The initialization value is constant and it should never be changes
  23. */
  24. static void bb_rf_register_definition(PADAPTER adapter)
  25. {
  26. PHAL_DATA_TYPE hal = GET_HAL_DATA(adapter);
  27. /* RF Interface Sowrtware Control */
  28. hal->PHYRegDef[RF_PATH_A].rfintfs = rFPGA0_XAB_RFInterfaceSW;
  29. hal->PHYRegDef[RF_PATH_B].rfintfs = rFPGA0_XAB_RFInterfaceSW;
  30. /* RF Interface Output (and Enable) */
  31. hal->PHYRegDef[RF_PATH_A].rfintfo = rFPGA0_XA_RFInterfaceOE;
  32. hal->PHYRegDef[RF_PATH_B].rfintfo = rFPGA0_XB_RFInterfaceOE;
  33. /* RF Interface (Output and) Enable */
  34. hal->PHYRegDef[RF_PATH_A].rfintfe = rFPGA0_XA_RFInterfaceOE;
  35. hal->PHYRegDef[RF_PATH_B].rfintfe = rFPGA0_XB_RFInterfaceOE;
  36. hal->PHYRegDef[RF_PATH_A].rf3wireOffset = rA_LSSIWrite_Jaguar;
  37. hal->PHYRegDef[RF_PATH_B].rf3wireOffset = rB_LSSIWrite_Jaguar;
  38. hal->PHYRegDef[RF_PATH_A].rfHSSIPara2 = rHSSIRead_Jaguar;
  39. hal->PHYRegDef[RF_PATH_B].rfHSSIPara2 = rHSSIRead_Jaguar;
  40. /* Tranceiver Readback LSSI/HSPI mode */
  41. hal->PHYRegDef[RF_PATH_A].rfLSSIReadBack = rA_SIRead_Jaguar;
  42. hal->PHYRegDef[RF_PATH_B].rfLSSIReadBack = rB_SIRead_Jaguar;
  43. hal->PHYRegDef[RF_PATH_A].rfLSSIReadBackPi = rA_PIRead_Jaguar;
  44. hal->PHYRegDef[RF_PATH_B].rfLSSIReadBackPi = rB_PIRead_Jaguar;
  45. }
  46. static void init_bb_rf(PADAPTER adapter)
  47. {
  48. u8 val8;
  49. u16 val16;
  50. /* Enable BB and RF */
  51. val8 = rtw_read8(adapter, REG_SYS_FUNC_EN_8821C);
  52. if (IS_HARDWARE_TYPE_8821CU(adapter))
  53. val8 |= BIT_FEN_USBA_8821C;
  54. else if (IS_HARDWARE_TYPE_8821CE(adapter))
  55. val8 |= BIT_FEN_PCIEA_8821C;
  56. rtw_write8(adapter, REG_SYS_FUNC_EN_8821C, val8);
  57. /*
  58. * 8821C MP Chip => Reset BB/RF ??
  59. * Need to set BBRSTB and GLB_RSTB = 1->0->1 to generate a postive edge and negtive edge for BB
  60. */
  61. val8 |= BIT_FEN_BB_GLB_RSTN_8821C | BIT_FEN_BBRSTB_8821C;
  62. rtw_write8(adapter, REG_SYS_FUNC_EN_8821C, val8);
  63. val8 &= ~(BIT_FEN_BB_GLB_RSTN_8821C | BIT_FEN_BBRSTB_8821C);
  64. rtw_write8(adapter, REG_SYS_FUNC_EN_8821C, val8);
  65. val8 |= BIT_FEN_BB_GLB_RSTN_8821C | BIT_FEN_BBRSTB_8821C;
  66. rtw_write8(adapter, REG_SYS_FUNC_EN_8821C, val8);
  67. val8 = BIT_RF_EN_8821C | BIT_RF_RSTB_8821C | BIT_RF_SDMRSTB_8821C;
  68. /* 0x1F[7:0] = 0x07 PathA RF Power On */
  69. rtw_write8(adapter, REG_RF_CTRL_8821C, val8);
  70. rtw_usleep_os(10);
  71. /*0xEC [31:24],BIT_WLRF1_CTRL, For WLRF1 control*/
  72. /* 0xEF[7:0] = 0x07 for RFE Type=2,BTG RF Power On*/
  73. rtw_write8(adapter, REG_WLRF1_8821C + 3, val8);
  74. rtw_usleep_os(10);
  75. }
  76. u8 rtl8821c_init_phy_parameter_mac(PADAPTER adapter)
  77. {
  78. u8 ret = _FAIL;
  79. PHAL_DATA_TYPE hal;
  80. hal = GET_HAL_DATA(adapter);
  81. #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE
  82. ret = phy_ConfigMACWithParaFile(adapter, PHY_FILE_MAC_REG);
  83. if (ret == _FAIL)
  84. #endif /* CONFIG_LOAD_PHY_PARA_FROM_FILE */
  85. {
  86. odm_config_mac_with_header_file(&hal->odmpriv);
  87. ret = _SUCCESS;
  88. }
  89. return ret;
  90. }
  91. static u8 _init_phy_parameter_bb(PADAPTER Adapter)
  92. {
  93. PHAL_DATA_TYPE hal = GET_HAL_DATA(Adapter);
  94. u8 ret = _TRUE;
  95. int res;
  96. enum hal_status status;
  97. /*
  98. * 1. Read PHY_REG.TXT BB INIT!!
  99. */
  100. #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE
  101. res = phy_ConfigBBWithParaFile(Adapter, PHY_FILE_PHY_REG, CONFIG_BB_PHY_REG);
  102. if (res == _FAIL)
  103. #endif
  104. {
  105. ret = _FALSE;
  106. status = odm_config_bb_with_header_file(&hal->odmpriv, CONFIG_BB_PHY_REG);
  107. if (HAL_STATUS_SUCCESS == status)
  108. ret = _TRUE;
  109. }
  110. if (ret != _TRUE) {
  111. RTW_INFO("%s: Write BB Reg Fail!!", __FUNCTION__);
  112. goto exit;
  113. }
  114. #ifdef CONFIG_MP_INCLUDED
  115. if (Adapter->registrypriv.mp_mode == 1) {
  116. /*
  117. * 1.1 Read PHY_REG_MP.TXT BB INIT!!
  118. */
  119. #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE
  120. res = phy_ConfigBBWithMpParaFile(Adapter, PHY_FILE_PHY_REG_MP);
  121. if (res == _FAIL)
  122. #endif
  123. {
  124. ret = _FALSE;
  125. status = odm_config_bb_with_header_file(&hal->odmpriv, CONFIG_BB_PHY_REG_MP);
  126. if (HAL_STATUS_SUCCESS == status)
  127. ret = _TRUE;
  128. }
  129. if (ret != _TRUE) {
  130. RTW_INFO("%s : Write BB Reg MP Fail!!", __FUNCTION__);
  131. goto exit;
  132. }
  133. }
  134. #endif /* CONFIG_MP_INCLUDED */
  135. /*
  136. * 2. Read BB AGC table Initialization
  137. */
  138. #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE
  139. res = phy_ConfigBBWithParaFile(Adapter, PHY_FILE_AGC_TAB, CONFIG_BB_AGC_TAB);
  140. if (res == _FAIL)
  141. #endif
  142. {
  143. ret = _FALSE;
  144. status = odm_config_bb_with_header_file(&hal->odmpriv, CONFIG_BB_AGC_TAB);
  145. if (HAL_STATUS_SUCCESS == status)
  146. ret = _TRUE;
  147. }
  148. if (ret != _TRUE) {
  149. RTW_INFO("%s: AGC Table Fail\n", __FUNCTION__);
  150. goto exit;
  151. }
  152. exit:
  153. return ret;
  154. }
  155. static u8 init_bb_reg(PADAPTER adapter)
  156. {
  157. u8 ret = _TRUE;
  158. PHAL_DATA_TYPE hal = GET_HAL_DATA(adapter);
  159. /*
  160. * Config BB and AGC
  161. */
  162. ret = _init_phy_parameter_bb(adapter);
  163. hal_set_crystal_cap(adapter, hal->crystal_cap);
  164. phy_set_bb_reg(adapter, rCCK0_FalseAlarmReport, BIT18 | BIT22, 0);
  165. return ret;
  166. }
  167. static u8 _init_phy_parameter_rf(PADAPTER adapter)
  168. {
  169. u32 val32 = 0;
  170. enum rf_path eRFPath;
  171. PBB_REGISTER_DEFINITION_T pPhyReg;
  172. PHAL_DATA_TYPE hal = GET_HAL_DATA(adapter);
  173. enum hal_status status;
  174. int res;
  175. u8 ret = _TRUE;
  176. /*
  177. * Initialize RF
  178. */
  179. for (eRFPath = RF_PATH_A; eRFPath < hal->NumTotalRFPath; eRFPath++) {
  180. pPhyReg = &hal->PHYRegDef[eRFPath];
  181. /* Initialize RF from configuration file */
  182. switch (eRFPath) {
  183. case RF_PATH_A:
  184. #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE
  185. res = PHY_ConfigRFWithParaFile(adapter, PHY_FILE_RADIO_A, eRFPath);
  186. if (res == _FAIL)
  187. #endif
  188. {
  189. ret = _FALSE;
  190. status = odm_config_rf_with_header_file(&hal->odmpriv, CONFIG_RF_RADIO, eRFPath);
  191. if (HAL_STATUS_SUCCESS == status)
  192. ret = _TRUE;
  193. }
  194. break;
  195. case RF_PATH_B:
  196. #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE
  197. res = PHY_ConfigRFWithParaFile(adapter, PHY_FILE_RADIO_B, eRFPath);
  198. if (res == _FAIL)
  199. #endif
  200. {
  201. ret = _FALSE;
  202. status = odm_config_rf_with_header_file(&hal->odmpriv, CONFIG_RF_RADIO, eRFPath);
  203. if (HAL_STATUS_SUCCESS == status)
  204. ret = _TRUE;
  205. }
  206. break;
  207. default:
  208. RTW_INFO("Unknown RF path!! %d\r\n", eRFPath);
  209. break;
  210. }
  211. if (ret != _TRUE)
  212. goto exit;
  213. }
  214. /*
  215. * Configuration of Tx Power Tracking
  216. */
  217. #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE
  218. res = PHY_ConfigRFWithTxPwrTrackParaFile(adapter, PHY_FILE_TXPWR_TRACK);
  219. if (res == _FAIL)
  220. #endif
  221. {
  222. ret = _FALSE;
  223. status = odm_config_rf_with_tx_pwr_track_header_file(&hal->odmpriv);
  224. if (HAL_STATUS_SUCCESS == status)
  225. ret = _TRUE;
  226. }
  227. if (ret != _TRUE)
  228. goto exit;
  229. exit:
  230. return ret;
  231. }
  232. static u8 init_rf_reg(PADAPTER adapter)
  233. {
  234. u8 ret = _TRUE;
  235. ret = _init_phy_parameter_rf(adapter);
  236. return ret;
  237. }
  238. u8 rtl8821c_phy_init(PADAPTER adapter)
  239. {
  240. PHAL_DATA_TYPE hal = GET_HAL_DATA(adapter);
  241. struct dm_struct *phydm = &hal->odmpriv;
  242. bb_rf_register_definition(adapter);
  243. init_bb_rf(adapter);
  244. if (_FALSE == config_phydm_parameter_init_8821c(phydm, ODM_PRE_SETTING))
  245. return _FALSE;
  246. if (_FALSE == init_bb_reg(adapter))
  247. return _FALSE;
  248. if (_FALSE == init_rf_reg(adapter))
  249. return _FALSE;
  250. #if 0
  251. if (_FALSE = config_phydm_trx_mode_8821c(phydm, ODM_RF_A, ODM_RF_A, FALSE))
  252. return _FALSE;
  253. #endif
  254. if (_FALSE == config_phydm_parameter_init_8821c(phydm, ODM_POST_SETTING))
  255. return _FALSE;
  256. hal->phy_spec.trx_cap = query_phydm_trx_capability(phydm);
  257. hal->phy_spec.stbc_cap = query_phydm_stbc_capability(phydm);
  258. hal->phy_spec.ldpc_cap = query_phydm_ldpc_capability(phydm);
  259. hal->phy_spec.txbf_param = query_phydm_txbf_parameters(phydm);
  260. hal->phy_spec.txbf_cap = query_phydm_txbf_capability(phydm);
  261. /*rtw_dump_phy_cap(RTW_DBGDUMP, adapter);*/
  262. return _TRUE;
  263. }
  264. static u32 phy_calculatebitshift(u32 mask)
  265. {
  266. u32 i;
  267. for (i = 0; i <= 31; i++)
  268. if (mask & BIT(i))
  269. break;
  270. return i;
  271. }
  272. u32 rtl8821c_read_bb_reg(PADAPTER adapter, u32 addr, u32 mask)
  273. {
  274. u32 val = 0, val_org, shift;
  275. #if (DISABLE_BB_RF == 1)
  276. return 0;
  277. #endif
  278. val_org = rtw_read32(adapter, addr);
  279. shift = phy_calculatebitshift(mask);
  280. val = (val_org & mask) >> shift;
  281. return val;
  282. }
  283. void rtl8821c_write_bb_reg(PADAPTER adapter, u32 addr, u32 mask, u32 val)
  284. {
  285. u32 val_org, shift;
  286. #if (DISABLE_BB_RF == 1)
  287. return;
  288. #endif
  289. if (mask != 0xFFFFFFFF) {
  290. /* not "double word" write */
  291. val_org = rtw_read32(adapter, addr);
  292. shift = phy_calculatebitshift(mask);
  293. val = ((val_org & (~mask)) | ((val << shift) & mask));
  294. }
  295. rtw_write32(adapter, addr, val);
  296. }
  297. u32 rtl8821c_read_rf_reg(PADAPTER adapter, enum rf_path path, u32 addr, u32 mask)
  298. {
  299. struct dm_struct *phydm = adapter_to_phydm(adapter);
  300. u32 val = 0;
  301. val = config_phydm_read_rf_reg_8821c(phydm, path, addr, mask);
  302. if (!config_phydm_read_rf_check_8821c(val))
  303. RTW_INFO(FUNC_ADPT_FMT ": read RF reg path=%d addr=0x%x mask=0x%x FAIL!\n",
  304. FUNC_ADPT_ARG(adapter), path, addr, mask);
  305. return val;
  306. }
  307. void rtl8821c_write_rf_reg(PADAPTER adapter, enum rf_path path, u32 addr, u32 mask, u32 val)
  308. {
  309. struct dm_struct *phydm = adapter_to_phydm(adapter);
  310. u8 ret;
  311. ret = config_phydm_write_rf_reg_8821c(phydm, path, addr, mask, val);
  312. if (_FALSE == ret)
  313. RTW_INFO(FUNC_ADPT_FMT ": write RF reg path=%d addr=0x%x mask=0x%x val=0x%x FAIL!\n",
  314. FUNC_ADPT_ARG(adapter), path, addr, mask, val);
  315. }
  316. void rtl8821c_set_tx_power_level(PADAPTER adapter, u8 channel)
  317. {
  318. u8 path = RF_PATH_A;
  319. struct dm_struct *phydm = adapter_to_phydm(adapter);
  320. PHAL_DATA_TYPE hal = GET_HAL_DATA(adapter);
  321. u8 under_survey_ch = phy_check_under_survey_ch(adapter);
  322. u8 under_24g = (hal->current_band_type == BAND_ON_2_4G);
  323. /*((hal->RFEType == 2) || (hal->RFEType == 4) || (hal->RFEType == 7))*/
  324. if ((channel <= 14) && (SWITCH_TO_BTG == query_phydm_default_rf_set_8821c(phydm)))
  325. path = RF_PATH_B;
  326. /*if (adapter->registrypriv.mp_mode == 1)*/
  327. if (under_24g)
  328. phy_set_tx_power_index_by_rate_section(adapter, path, channel, CCK);
  329. phy_set_tx_power_index_by_rate_section(adapter, path, channel, OFDM);
  330. if (!under_survey_ch) {
  331. phy_set_tx_power_index_by_rate_section(adapter, path, channel, HT_MCS0_MCS7);
  332. phy_set_tx_power_index_by_rate_section(adapter, path, channel, VHT_1SSMCS0_1SSMCS9);
  333. }
  334. }
  335. void rtl8821c_get_tx_power_level(PADAPTER adapter, s32 *power)
  336. {
  337. }
  338. /*
  339. * Parameters:
  340. * padatper
  341. * powerindex power index for rate
  342. * rfpath Antenna(RF) path, type "enum rf_path"
  343. * rate data rate, type "enum MGN_RATE"
  344. */
  345. /*#define DBG_SET_TX_POWER_IDX*/
  346. void rtl8821c_set_tx_power_index(PADAPTER adapter, u32 powerindex, enum rf_path rfpath, u8 rate)
  347. {
  348. struct dm_struct *phydm = adapter_to_phydm(adapter);
  349. u8 shift = 0;
  350. u8 hw_rate_idx;
  351. static u32 index = 0;
  352. /*hw_rate_idx = PHY_GetRateIndexOfTxPowerByRate(rate);*/
  353. hw_rate_idx = MRateToHwRate(rate);
  354. if (hw_rate_idx > DESC_RATEVHTSS1MCS9) {
  355. RTW_ERR(FUNC_ADPT_FMT"warn rate(%s)\n", FUNC_ADPT_ARG(adapter), HDATA_RATE(hw_rate_idx));
  356. rtw_warn_on(1);
  357. }
  358. if (rfpath > RF_PATH_A) {
  359. #ifdef DBG_SET_TX_POWER_IDX
  360. RTW_INFO(FUNC_ADPT_FMT" rfpath(%d) power index to RF_PATH_A\n", FUNC_ADPT_ARG(adapter), rfpath);
  361. #endif
  362. rfpath = RF_PATH_A;
  363. }
  364. /*
  365. * For 8821C, phydm api use 4 bytes txagc value
  366. * driver must combine every four 1 byte to one 4 byte and send to phydm api
  367. */
  368. shift = hw_rate_idx % 4;
  369. index |= ((powerindex & 0xff) << (shift * 8));
  370. if (shift == 3) {
  371. hw_rate_idx = hw_rate_idx - 3;
  372. if (!config_phydm_write_txagc_8821c(phydm, index, rfpath, hw_rate_idx)) {
  373. RTW_ERR(FUNC_ADPT_FMT" (power index:0x%02x, rfpath:%d, rate:0x%02x, disable api:%d) wite TX-AGC failed\n",
  374. FUNC_ADPT_ARG(adapter), index, rfpath, hw_rate_idx, phydm->is_disable_phy_api);
  375. rtw_warn_on(1);
  376. }
  377. #ifdef DBG_SET_TX_POWER_IDX
  378. RTW_INFO(FUNC_ADPT_FMT"Rate:%s ,tx_power_idx: 0x%08x\n", FUNC_ADPT_ARG(adapter), HDATA_RATE(hw_rate_idx), index);
  379. #endif
  380. index = 0;
  381. }
  382. if (MGN_VHT1SS_MCS9 == rate) {
  383. if (!config_phydm_write_txagc_8821c(phydm, index, rfpath, MRateToHwRate(MGN_VHT1SS_MCS8))) {
  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(MRateToHwRate(MGN_VHT1SS_MCS8)), index);
  390. #endif
  391. index = 0;
  392. }
  393. }
  394. /*
  395. * Parameters:
  396. * padatper
  397. * rfpath Antenna(RF) path, type "enum rf_path"
  398. * rate data rate, type "enum MGN_RATE"
  399. * bandwidth Bandwidth, type "enum _CHANNEL_WIDTH"
  400. * channel Channel number
  401. *
  402. * Rteurn:
  403. * tx_power power index for rate
  404. */
  405. u8 rtl8821c_get_tx_power_index(PADAPTER adapter, enum rf_path rfpath, u8 rate, u8 bandwidth, u8 channel, struct txpwr_idx_comp *tic)
  406. {
  407. PHAL_DATA_TYPE hal = GET_HAL_DATA(adapter);
  408. struct hal_spec_t *hal_spec = GET_HAL_SPEC(adapter);
  409. s16 power_idx;
  410. u8 base_idx = 0;
  411. s8 by_rate_diff = 0, limit = 0, tpt_offset = 0, extra_bias = 0;
  412. u8 bIn24G = _FALSE;
  413. base_idx = PHY_GetTxPowerIndexBase(adapter, rfpath, rate, RF_1TX, bandwidth, channel, &bIn24G);
  414. by_rate_diff = PHY_GetTxPowerByRate(adapter, (u8)(!bIn24G), rfpath, rate);
  415. limit = PHY_GetTxPowerLimit(adapter, NULL, (BAND_TYPE)(!bIn24G),
  416. hal->current_channel_bw, rfpath, rate, RF_1TX, hal->current_channel);
  417. /* tpt_offset += PHY_GetTxPowerTrackingOffset(adapter, rfpath, rate); */
  418. if (tic) {
  419. tic->ntx_idx = RF_1TX;
  420. tic->base = base_idx;
  421. tic->by_rate = by_rate_diff;
  422. tic->limit = limit;
  423. tic->tpt = tpt_offset;
  424. tic->ebias = extra_bias;
  425. }
  426. by_rate_diff = by_rate_diff > limit ? limit : by_rate_diff;
  427. power_idx = base_idx + by_rate_diff + tpt_offset + extra_bias;
  428. #if 0
  429. #if CCX_SUPPORT
  430. CCX_CellPowerLimit(adapter, channel, rate, (pu1Byte)&power_idx);
  431. #endif
  432. #endif
  433. if (power_idx < 0)
  434. power_idx = 0;
  435. else if (power_idx > hal_spec->txgi_max)
  436. power_idx = hal_spec->txgi_max;
  437. return power_idx;
  438. }
  439. /*
  440. * Description:
  441. * Check need to switch band or not
  442. * Parameters:
  443. * channelToSW channel wiii be switch to
  444. * Return:
  445. * _TRUE need to switch band
  446. * _FALSE not need to switch band
  447. */
  448. static u8 need_switch_band(PADAPTER adapter, u8 channelToSW)
  449. {
  450. u8 u1tmp = 0;
  451. u8 ret_value = _TRUE;
  452. u8 Band = BAND_ON_5G, BandToSW = BAND_ON_5G;
  453. PHAL_DATA_TYPE hal = GET_HAL_DATA(adapter);
  454. Band = hal->current_band_type;
  455. /* Use current swich channel to judge Band Type and switch Band if need */
  456. if (channelToSW > 14)
  457. BandToSW = BAND_ON_5G;
  458. else
  459. BandToSW = BAND_ON_2_4G;
  460. if (BandToSW != Band) {
  461. /* record current band type for other hal use */
  462. hal->current_band_type = (BAND_TYPE)BandToSW;
  463. ret_value = _TRUE;
  464. } else
  465. ret_value = _FALSE;
  466. return ret_value;
  467. }
  468. static u8 get_pri_ch_id(PADAPTER adapter)
  469. {
  470. u8 pri_ch_idx = 0;
  471. PHAL_DATA_TYPE hal = GET_HAL_DATA(adapter);
  472. if (hal->current_channel_bw == CHANNEL_WIDTH_80) {
  473. /* primary channel is at lower subband of 80MHz & 40MHz */
  474. if ((hal->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) && (hal->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER))
  475. pri_ch_idx = VHT_DATA_SC_20_LOWEST_OF_80MHZ;
  476. /* primary channel is at lower subband of 80MHz & upper subband of 40MHz */
  477. else if ((hal->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) && (hal->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER))
  478. pri_ch_idx = VHT_DATA_SC_20_LOWER_OF_80MHZ;
  479. /* primary channel is at upper subband of 80MHz & lower subband of 40MHz */
  480. else if ((hal->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) && (hal->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER))
  481. pri_ch_idx = VHT_DATA_SC_20_UPPER_OF_80MHZ;
  482. /* primary channel is at upper subband of 80MHz & upper subband of 40MHz */
  483. else if ((hal->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) && (hal->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER))
  484. pri_ch_idx = VHT_DATA_SC_20_UPPERST_OF_80MHZ;
  485. else {
  486. if (hal->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER)
  487. pri_ch_idx = VHT_DATA_SC_40_LOWER_OF_80MHZ;
  488. else if (hal->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER)
  489. pri_ch_idx = VHT_DATA_SC_40_UPPER_OF_80MHZ;
  490. else
  491. RTW_INFO("SCMapping: DONOT CARE Mode Setting\n");
  492. }
  493. } else if (hal->current_channel_bw == CHANNEL_WIDTH_40) {
  494. /* primary channel is at upper subband of 40MHz */
  495. if (hal->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER)
  496. pri_ch_idx = VHT_DATA_SC_20_UPPER_OF_80MHZ;
  497. /* primary channel is at lower subband of 40MHz */
  498. else if (hal->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER)
  499. pri_ch_idx = VHT_DATA_SC_20_LOWER_OF_80MHZ;
  500. else
  501. RTW_INFO("SCMapping: DONOT CARE Mode Setting\n");
  502. }
  503. return pri_ch_idx;
  504. }
  505. static void mac_switch_bandwidth(PADAPTER adapter, u8 pri_ch_idx)
  506. {
  507. u8 channel = 0, bw = 0;
  508. PHAL_DATA_TYPE hal = GET_HAL_DATA(adapter);
  509. int err;
  510. channel = hal->current_channel;
  511. bw = hal->current_channel_bw;
  512. err = rtw_halmac_set_bandwidth(adapter_to_dvobj(adapter), channel, pri_ch_idx, bw);
  513. if (err) {
  514. RTW_INFO(FUNC_ADPT_FMT ": (channel=%d, pri_ch_idx=%d, bw=%d) fail\n",
  515. FUNC_ADPT_ARG(adapter), channel, pri_ch_idx, bw);
  516. }
  517. }
  518. u32 phy_get_tx_bbswing_8812c(_adapter *adapter, BAND_TYPE band, u8 rf_path)
  519. {
  520. HAL_DATA_TYPE *pHalData = GET_HAL_DATA(adapter);
  521. struct dm_struct *pDM_Odm = &pHalData->odmpriv;
  522. struct dm_rf_calibration_struct *pRFCalibrateInfo = &(pDM_Odm->rf_calibrate_info);
  523. s8 bbSwing_2G = -1 * GetRegTxBBSwing_2G(adapter);
  524. s8 bbSwing_5G = -1 * GetRegTxBBSwing_5G(adapter);
  525. u32 out = 0x200;
  526. const s8 AUTO = -1;
  527. if (pHalData->bautoload_fail_flag) {
  528. if (band == BAND_ON_2_4G) {
  529. pRFCalibrateInfo->bb_swing_diff_2g = bbSwing_2G;
  530. if (bbSwing_2G == 0)
  531. out = 0x200; /* 0 dB */
  532. else if (bbSwing_2G == -3)
  533. out = 0x16A; /* -3 dB */
  534. else if (bbSwing_2G == -6)
  535. out = 0x101; /* -6 dB */
  536. else if (bbSwing_2G == -9)
  537. out = 0x0B6; /* -9 dB */
  538. else {
  539. if (pHalData->ExternalPA_2G) {
  540. pRFCalibrateInfo->bb_swing_diff_2g = -3;
  541. out = 0x16A;
  542. } else {
  543. pRFCalibrateInfo->bb_swing_diff_2g = 0;
  544. out = 0x200;
  545. }
  546. }
  547. } else if (band == BAND_ON_5G) {
  548. pRFCalibrateInfo->bb_swing_diff_5g = bbSwing_5G;
  549. if (bbSwing_5G == 0)
  550. out = 0x200; /* 0 dB */
  551. else if (bbSwing_5G == -3)
  552. out = 0x16A; /* -3 dB */
  553. else if (bbSwing_5G == -6)
  554. out = 0x101; /* -6 dB */
  555. else if (bbSwing_5G == -9)
  556. out = 0x0B6; /* -9 dB */
  557. else {
  558. if (pHalData->external_pa_5g) {
  559. pRFCalibrateInfo->bb_swing_diff_5g = -3;
  560. out = 0x16A;
  561. } else {
  562. pRFCalibrateInfo->bb_swing_diff_5g = 0;
  563. out = 0x200;
  564. }
  565. }
  566. } else {
  567. pRFCalibrateInfo->bb_swing_diff_2g = -3;
  568. pRFCalibrateInfo->bb_swing_diff_5g = -3;
  569. out = 0x16A; /* -3 dB */
  570. }
  571. } else {
  572. u32 swing = 0, onePathSwing = 0;
  573. if (band == BAND_ON_2_4G) {
  574. if (GetRegTxBBSwing_2G(adapter) == AUTO)
  575. swing = pHalData->tx_bbswing_24G;
  576. else if (bbSwing_2G == 0)
  577. swing = 0x00; /* 0 dB */
  578. else if (bbSwing_2G == -3)
  579. swing = 0x55; /* -3 dB */
  580. else if (bbSwing_2G == -6)
  581. swing = 0xAA; /* -6 dB */
  582. else if (bbSwing_2G == -9)
  583. swing = 0xFF; /* -9 dB */
  584. else
  585. swing = 0x00;
  586. } else {
  587. if (GetRegTxBBSwing_5G(adapter) == AUTO)
  588. swing = pHalData->tx_bbswing_5G;
  589. else if (bbSwing_5G == 0)
  590. swing = 0x00; /* 0 dB */
  591. else if (bbSwing_5G == -3)
  592. swing = 0x55; /* -3 dB */
  593. else if (bbSwing_5G == -6)
  594. swing = 0xAA; /* -6 dB */
  595. else if (bbSwing_5G == -9)
  596. swing = 0xFF; /* -9 dB */
  597. else
  598. swing = 0x00;
  599. }
  600. if (rf_path == RF_PATH_A)
  601. onePathSwing = (swing & 0x3) >> 0; /* 0xC6/C7[1:0] */
  602. if (onePathSwing == 0x0) {
  603. if (band == BAND_ON_2_4G)
  604. pRFCalibrateInfo->bb_swing_diff_2g = 0;
  605. else
  606. pRFCalibrateInfo->bb_swing_diff_5g = 0;
  607. out = 0x200; /* 0 dB */
  608. } else if (onePathSwing == 0x1) {
  609. if (band == BAND_ON_2_4G)
  610. pRFCalibrateInfo->bb_swing_diff_2g = -3;
  611. else
  612. pRFCalibrateInfo->bb_swing_diff_5g = -3;
  613. out = 0x16A; /* -3 dB */
  614. } else if (onePathSwing == 0x2) {
  615. if (band == BAND_ON_2_4G)
  616. pRFCalibrateInfo->bb_swing_diff_2g = -6;
  617. else
  618. pRFCalibrateInfo->bb_swing_diff_5g = -6;
  619. out = 0x101; /* -6 dB */
  620. } else if (onePathSwing == 0x3) {
  621. if (band == BAND_ON_2_4G)
  622. pRFCalibrateInfo->bb_swing_diff_2g = -9;
  623. else
  624. pRFCalibrateInfo->bb_swing_diff_5g = -9;
  625. out = 0x0B6; /* -9 dB */
  626. }
  627. }
  628. /* RTW_INFO("<=== PHY_GetTxBBSwing_8812C, out = 0x%X\n", out); */
  629. return out;
  630. }
  631. void phy_set_bb_swing_by_band_8812c(_adapter *adapter, u8 band, u8 previous_band)
  632. {
  633. s8 BBDiffBetweenBand = 0;
  634. struct dm_struct *pDM_Odm = adapter_to_phydm(adapter);
  635. struct dm_rf_calibration_struct *pRFCalibrateInfo = &(pDM_Odm->rf_calibrate_info);
  636. phy_set_bb_reg(adapter, rA_TxScale_Jaguar, 0xFFE00000,
  637. phy_get_tx_bbswing_8812c(adapter, (BAND_TYPE)band, RF_PATH_A)); /* 0xC1C[31:21] */
  638. /* When TxPowerTrack is ON, we should take care of the change of BB swing. */
  639. /* That is, reset all info to trigger Tx power tracking. */
  640. {
  641. if (band != previous_band) {
  642. BBDiffBetweenBand = (pRFCalibrateInfo->bb_swing_diff_2g - pRFCalibrateInfo->bb_swing_diff_5g);
  643. BBDiffBetweenBand = (band == BAND_ON_2_4G) ? BBDiffBetweenBand : (-1 * BBDiffBetweenBand);
  644. pRFCalibrateInfo->default_ofdm_index += BBDiffBetweenBand * 2;
  645. }
  646. odm_clear_txpowertracking_state(pDM_Odm);
  647. }
  648. }
  649. void phy_switch_wireless_band_8821c(_adapter *adapter)
  650. {
  651. u8 ret = 0;
  652. PHAL_DATA_TYPE hal_data = GET_HAL_DATA(adapter);
  653. struct dm_struct *pDM_Odm = &hal_data->odmpriv;
  654. u8 current_band = hal_data->current_band_type;
  655. if (need_switch_band(adapter, hal_data->current_channel) == _TRUE) {
  656. #ifdef CONFIG_BT_COEXIST
  657. if (hal_data->EEPROMBluetoothCoexist) {
  658. struct mlme_ext_priv *mlmeext;
  659. /* switch band under site survey or not, must notify to BT COEX */
  660. mlmeext = &adapter->mlmeextpriv;
  661. if (mlmeext_scan_state(mlmeext) != SCAN_DISABLE)
  662. rtw_btcoex_switchband_notify(_TRUE, hal_data->current_band_type);
  663. else
  664. rtw_btcoex_switchband_notify(_FALSE, hal_data->current_band_type);
  665. } else
  666. rtw_btcoex_wifionly_switchband_notify(adapter);
  667. #else /* !CONFIG_BT_COEXIST */
  668. rtw_btcoex_wifionly_switchband_notify(adapter);
  669. #endif /* CONFIG_BT_COEXIST */
  670. /* hal->current_channel is center channel of pmlmeext->cur_channel(primary channel) */
  671. ret = config_phydm_switch_band_8821c(pDM_Odm, hal_data->current_channel);
  672. if (!ret) {
  673. RTW_ERR("%s: config_phydm_switch_band_8821c fail\n", __func__);
  674. rtw_warn_on(1);
  675. return;
  676. }
  677. phy_set_bb_swing_by_band_8812c(adapter, hal_data->current_band_type, current_band);
  678. }
  679. }
  680. /*
  681. * Description:
  682. * Set channel & bandwidth & offset
  683. */
  684. void rtl8821c_switch_chnl_and_set_bw(PADAPTER adapter)
  685. {
  686. PHAL_DATA_TYPE hal = GET_HAL_DATA(adapter);
  687. struct dm_struct *pDM_Odm = &hal->odmpriv;
  688. u8 center_ch = 0, ret = 0;
  689. if (adapter->bNotifyChannelChange) {
  690. RTW_INFO("[%s] bSwChnl=%d, ch=%d, bSetChnlBW=%d, bw=%d\n",
  691. __FUNCTION__,
  692. hal->bSwChnl,
  693. hal->current_channel,
  694. hal->bSetChnlBW,
  695. hal->current_channel_bw);
  696. }
  697. if (RTW_CANNOT_RUN(adapter)) {
  698. hal->bSwChnlAndSetBWInProgress = _FALSE;
  699. return;
  700. }
  701. /* set channel & Bandwidth register */
  702. /* 1. set switch band register if need to switch band */
  703. phy_switch_wireless_band_8821c(adapter);
  704. /* 2. set channel register */
  705. if (hal->bSwChnl) {
  706. ret = config_phydm_switch_channel_8821c(pDM_Odm, hal->current_channel);
  707. hal->bSwChnl = _FALSE;
  708. if (!ret) {
  709. RTW_INFO("%s: config_phydm_switch_channel_8821c fail\n", __FUNCTION__);
  710. rtw_warn_on(1);
  711. return;
  712. }
  713. }
  714. phydm_config_kfree(pDM_Odm, hal->current_channel);
  715. /* 3. set Bandwidth register */
  716. if (hal->bSetChnlBW) {
  717. /* get primary channel index */
  718. u8 pri_ch_idx = get_pri_ch_id(adapter);
  719. /* 3.1 set MAC register */
  720. mac_switch_bandwidth(adapter, pri_ch_idx);
  721. /* 3.2 set BB/RF registet */
  722. ret = config_phydm_switch_bandwidth_8821c(pDM_Odm, pri_ch_idx, hal->current_channel_bw);
  723. hal->bSetChnlBW = _FALSE;
  724. if (!ret) {
  725. RTW_INFO("%s: config_phydm_switch_bandwidth_8821c fail\n", __FUNCTION__);
  726. rtw_warn_on(1);
  727. return;
  728. }
  729. }
  730. /* TX Power Setting */
  731. /* odm_clear_txpowertracking_state(pDM_Odm); */
  732. rtw_hal_set_tx_power_level(adapter, hal->current_channel);
  733. /* IQK */
  734. if ((hal->bNeedIQK == _TRUE)
  735. || (adapter->registrypriv.mp_mode == 1)) {
  736. #ifdef CONFIG_IQK_MONITOR
  737. systime iqk_start_time = rtw_get_current_time();
  738. #endif
  739. /*phy_iq_calibrate_8821c(pDM_Odm, _FALSE);*/
  740. rtw_phydm_iqk_trigger(adapter);
  741. #ifdef CONFIG_IQK_MONITOR
  742. RTW_INFO(ADPT_FMT" switch CH(%d) DO IQK : %d ms\n",
  743. ADPT_ARG(adapter), hal->current_channel, rtw_get_passing_time_ms(iqk_start_time));
  744. #endif
  745. hal->bNeedIQK = _FALSE;
  746. }
  747. }
  748. /*
  749. * Description:
  750. * Store channel setting to hal date
  751. * Parameters:
  752. * bSwitchChannel swith channel or not
  753. * bSetBandWidth set band or not
  754. * ChannelNum center channel
  755. * ChnlWidth bandwidth
  756. * ChnlOffsetOf40MHz channel offset for 40MHz Bandwidth
  757. * ChnlOffsetOf80MHz channel offset for 80MHz Bandwidth
  758. * CenterFrequencyIndex1 center channel index
  759. */
  760. void rtl8821c_handle_sw_chnl_and_set_bw(
  761. PADAPTER Adapter, u8 bSwitchChannel, u8 bSetBandWidth,
  762. u8 ChannelNum, enum channel_width ChnlWidth, u8 ChnlOffsetOf40MHz,
  763. u8 ChnlOffsetOf80MHz, u8 CenterFrequencyIndex1)
  764. {
  765. PHAL_DATA_TYPE hal = GET_HAL_DATA(Adapter);
  766. u8 tmpChannel = hal->current_channel;
  767. enum channel_width tmpBW = hal->current_channel_bw;
  768. u8 tmpnCur40MhzPrimeSC = hal->nCur40MhzPrimeSC;
  769. u8 tmpnCur80MhzPrimeSC = hal->nCur80MhzPrimeSC;
  770. u8 tmpCenterFrequencyIndex1 = hal->CurrentCenterFrequencyIndex1;
  771. struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv;
  772. /* check swchnl or setbw */
  773. if (!bSwitchChannel && !bSetBandWidth) {
  774. RTW_INFO("%s: not switch channel and not set bandwidth\n", __FUNCTION__);
  775. return;
  776. }
  777. /* skip switch channel operation for current channel & ChannelNum(will be switch) are the same */
  778. if (bSwitchChannel) {
  779. if (hal->current_channel != ChannelNum) {
  780. if (HAL_IsLegalChannel(Adapter, ChannelNum))
  781. hal->bSwChnl = _TRUE;
  782. else
  783. return;
  784. }
  785. }
  786. /* check set BandWidth */
  787. if (bSetBandWidth) {
  788. /* initial channel bw setting */
  789. if (hal->bChnlBWInitialized == _FALSE) {
  790. hal->bChnlBWInitialized = _TRUE;
  791. hal->bSetChnlBW = _TRUE;
  792. } else if ((hal->current_channel_bw != ChnlWidth) || /* check whether need set band or not */
  793. (hal->nCur40MhzPrimeSC != ChnlOffsetOf40MHz) ||
  794. (hal->nCur80MhzPrimeSC != ChnlOffsetOf80MHz) ||
  795. (hal->CurrentCenterFrequencyIndex1 != CenterFrequencyIndex1))
  796. hal->bSetChnlBW = _TRUE;
  797. }
  798. /* return if not need set bandwidth nor channel after check*/
  799. if (!hal->bSetChnlBW && !hal->bSwChnl && hal->bNeedIQK != _TRUE)
  800. return;
  801. /* set channel number to hal data */
  802. if (hal->bSwChnl) {
  803. hal->current_channel = ChannelNum;
  804. hal->CurrentCenterFrequencyIndex1 = ChannelNum;
  805. }
  806. /* set bandwidth info to hal data */
  807. if (hal->bSetChnlBW) {
  808. hal->current_channel_bw = ChnlWidth;
  809. hal->nCur40MhzPrimeSC = ChnlOffsetOf40MHz;
  810. hal->nCur80MhzPrimeSC = ChnlOffsetOf80MHz;
  811. hal->CurrentCenterFrequencyIndex1 = CenterFrequencyIndex1;
  812. }
  813. /* switch channel & bandwidth */
  814. if (!RTW_CANNOT_RUN(Adapter))
  815. rtl8821c_switch_chnl_and_set_bw(Adapter);
  816. else {
  817. if (hal->bSwChnl) {
  818. hal->current_channel = tmpChannel;
  819. hal->CurrentCenterFrequencyIndex1 = tmpChannel;
  820. }
  821. if (hal->bSetChnlBW) {
  822. hal->current_channel_bw = tmpBW;
  823. hal->nCur40MhzPrimeSC = tmpnCur40MhzPrimeSC;
  824. hal->nCur80MhzPrimeSC = tmpnCur80MhzPrimeSC;
  825. hal->CurrentCenterFrequencyIndex1 = tmpCenterFrequencyIndex1;
  826. }
  827. }
  828. }
  829. /*
  830. * Description:
  831. * Change channel, bandwidth & offset
  832. * Parameters:
  833. * center_ch center channel
  834. * bw bandwidth
  835. * offset40 channel offset for 40MHz Bandwidth
  836. * offset80 channel offset for 80MHz Bandwidth
  837. */
  838. void rtl8821c_set_channel_bw(PADAPTER adapter, u8 center_ch, enum channel_width bw, u8 offset40, u8 offset80)
  839. {
  840. rtl8821c_handle_sw_chnl_and_set_bw(adapter, _TRUE, _TRUE, center_ch, bw, offset40, offset80, center_ch);
  841. }
  842. void rtl8821c_notch_filter_switch(PADAPTER adapter, bool enable)
  843. {
  844. if (enable)
  845. RTW_INFO("%s: Enable notch filter\n", __FUNCTION__);
  846. else
  847. RTW_INFO("%s: Disable notch filter\n", __FUNCTION__);
  848. }
  849. #ifdef CONFIG_BEAMFORMING
  850. #ifdef RTW_BEAMFORMING_VERSION_2
  851. /* REG_TXBF_CTRL (Offset 0x42C) */
  852. #define BITS_R_TXBF1_AID_8821C (BIT_MASK_R_TXBF1_AID_8821C << BIT_SHIFT_R_TXBF1_AID_8821C)
  853. #define BIT_CLEAR_R_TXBF1_AID_8821C(x) ((x) & (~BITS_R_TXBF1_AID_8821C))
  854. #define BIT_SET_R_TXBF1_AID_8821C(x, v) (BIT_CLEAR_R_TXBF1_AID_8821C(x) | BIT_R_TXBF1_AID_8821C(v))
  855. #define BITS_R_TXBF0_AID_8821C (BIT_MASK_R_TXBF0_AID_8821C << BIT_SHIFT_R_TXBF0_AID_8821C)
  856. #define BIT_CLEAR_R_TXBF0_AID_8821C(x) ((x) & (~BITS_R_TXBF0_AID_8821C))
  857. #define BIT_SET_R_TXBF0_AID_8821C(x, v) (BIT_CLEAR_R_TXBF0_AID_8821C(x) | BIT_R_TXBF0_AID_8821C(v))
  858. /* REG_NDPA_OPT_CTRL (Offset 0x45F) */
  859. #define BITS_R_NDPA_BW_8821C (BIT_MASK_R_NDPA_BW_8821C << BIT_SHIFT_R_NDPA_BW_8821C)
  860. #define BIT_CLEAR_R_NDPA_BW_8821C(x) ((x) & (~BITS_R_NDPA_BW_8821C))
  861. #define BIT_SET_R_NDPA_BW_8821C(x, v) (BIT_CLEAR_R_NDPA_BW_8821C(x) | BIT_R_NDPA_BW_8821C(v))
  862. /* REG_ASSOCIATED_BFMEE_SEL (Offset 0x714) */
  863. #define BITS_AID1_8821C (BIT_MASK_AID1_8821C << BIT_SHIFT_AID1_8821C)
  864. #define BIT_CLEAR_AID1_8821C(x) ((x) & (~BITS_AID1_8821C))
  865. #define BIT_SET_AID1_8821C(x, v) (BIT_CLEAR_AID1_8821C(x) | BIT_AID1_8821C(v))
  866. #define BITS_AID0_8821C (BIT_MASK_AID0_8821C << BIT_SHIFT_AID0_8821C)
  867. #define BIT_CLEAR_AID0_8821C(x) ((x) & (~BITS_AID0_8821C))
  868. #define BIT_SET_AID0_8821C(x, v) (BIT_CLEAR_AID0_8821C(x) | BIT_AID0_8821C(v))
  869. /* REG_MU_TX_CTL (Offset 0x14C0) */
  870. #define BIT_R_MU_P1_WAIT_STATE_EN_8821C BIT(16)
  871. #define BIT_SHIFT_R_MU_RL_8821C 12
  872. #define BITS_R_MU_RL_8821C (BIT_MASK_R_MU_RL_8821C << BIT_SHIFT_R_MU_RL_8821C)
  873. #define BIT_R_MU_RL_8821C(x) (((x) & BIT_MASK_R_MU_RL_8821C) << BIT_SHIFT_R_MU_RL_8821C)
  874. #define BIT_CLEAR_R_MU_RL_8821C(x) ((x) & (~BITS_R_MU_RL_8821C))
  875. #define BIT_SET_R_MU_RL_8821C(x, v) (BIT_CLEAR_R_MU_RL_8821C(x) | BIT_R_MU_RL_8821C(v))
  876. #define BIT_SHIFT_R_MU_TAB_SEL_8821C 8
  877. #define BIT_MASK_R_MU_TAB_SEL_8821C 0x7
  878. #define BITS_R_MU_TAB_SEL_8821C (BIT_MASK_R_MU_TAB_SEL_8821C << BIT_SHIFT_R_MU_TAB_SEL_8821C)
  879. #define BIT_R_MU_TAB_SEL_8821C(x) (((x) & BIT_MASK_R_MU_TAB_SEL_8821C) << BIT_SHIFT_R_MU_TAB_SEL_8821C)
  880. #define BIT_CLEAR_R_MU_TAB_SEL_8821C(x) ((x) & (~BITS_R_MU_TAB_SEL_8821C))
  881. #define BIT_SET_R_MU_TAB_SEL_8821C(x, v) (BIT_CLEAR_R_MU_TAB_SEL_8821C(x) | BIT_R_MU_TAB_SEL_8821C(v))
  882. #define BIT_R_EN_MU_MIMO_8821C BIT(7)
  883. #define BITS_R_MU_TABLE_VALID_8821C (BIT_MASK_R_MU_TABLE_VALID_8821C << BIT_SHIFT_R_MU_TABLE_VALID_8821C)
  884. #define BIT_CLEAR_R_MU_TABLE_VALID_8821C(x) ((x) & (~BITS_R_MU_TABLE_VALID_8821C))
  885. #define BIT_SET_R_MU_TABLE_VALID_8821C(x, v) (BIT_CLEAR_R_MU_TABLE_VALID_8821C(x) | BIT_R_MU_TABLE_VALID_8821C(v))
  886. /* REG_WMAC_MU_BF_CTL (Offset 0x1680) */
  887. #define BITS_WMAC_MU_BFRPTSEG_SEL_8821C (BIT_MASK_WMAC_MU_BFRPTSEG_SEL_8821C << BIT_SHIFT_WMAC_MU_BFRPTSEG_SEL_8821C)
  888. #define BIT_CLEAR_WMAC_MU_BFRPTSEG_SEL_8821C(x) ((x) & (~BITS_WMAC_MU_BFRPTSEG_SEL_8821C))
  889. #define BIT_SET_WMAC_MU_BFRPTSEG_SEL_8821C(x, v) (BIT_CLEAR_WMAC_MU_BFRPTSEG_SEL_8821C(x) | BIT_WMAC_MU_BFRPTSEG_SEL_8821C(v))
  890. #define BITS_WMAC_MU_BF_MYAID_8821C (BIT_MASK_WMAC_MU_BF_MYAID_8821C << BIT_SHIFT_WMAC_MU_BF_MYAID_8821C)
  891. #define BIT_CLEAR_WMAC_MU_BF_MYAID_8821C(x) ((x) & (~BITS_WMAC_MU_BF_MYAID_8821C))
  892. #define BIT_SET_WMAC_MU_BF_MYAID_8821C(x, v) (BIT_CLEAR_WMAC_MU_BF_MYAID_8821C(x) | BIT_WMAC_MU_BF_MYAID_8821C(v))
  893. /* REG_WMAC_ASSOCIATED_MU_BFMEE7 (Offset 0x168E) */
  894. #define BIT_STATUS_BFEE7_8821C BIT(10)
  895. static u8 _bf_get_nrx(PADAPTER adapter)
  896. {
  897. u8 rf;
  898. u8 nrx = 0;
  899. rtw_hal_get_hwreg(adapter, HW_VAR_RF_TYPE, &rf);
  900. switch (rf) {
  901. case RF_1T1R:
  902. nrx = 0;
  903. break;
  904. default:
  905. case RF_1T2R:
  906. case RF_2T2R:
  907. nrx = 1;
  908. break;
  909. }
  910. return nrx;
  911. }
  912. static void _config_beamformer_su(PADAPTER adapter, struct beamformer_entry *bfer)
  913. {
  914. /* Beamforming */
  915. u8 nc_index = 0, nr_index = 0;
  916. u8 grouping = 0, codebookinfo = 0, coefficientsize = 0;
  917. u32 addr_bfer_info, addr_csi_rpt;
  918. u32 csi_param;
  919. /* Misc */
  920. u8 i;
  921. RTW_INFO("%s: Config SU BFer entry HW setting\n", __FUNCTION__);
  922. if (bfer->su_reg_index == 0) {
  923. addr_bfer_info = REG_ASSOCIATED_BFMER0_INFO_8821C;
  924. addr_csi_rpt = REG_TX_CSI_RPT_PARAM_BW20_8821C;
  925. } else {
  926. addr_bfer_info = REG_ASSOCIATED_BFMER1_INFO_8821C;
  927. addr_csi_rpt = REG_TX_CSI_RPT_PARAM_BW20_8821C + 2;
  928. }
  929. /* Sounding protocol control */
  930. rtw_write8(adapter, REG_SND_PTCL_CTRL_8821C, 0xDB);
  931. /* MAC address/Partial AID of Beamformer */
  932. for (i = 0; i < ETH_ALEN; i++)
  933. rtw_write8(adapter, addr_bfer_info+i, bfer->mac_addr[i]);
  934. /* CSI report parameters of Beamformer */
  935. nc_index = _bf_get_nrx(adapter);
  936. /*
  937. * 0x718[7] = 1 use Nsts
  938. * 0x718[7] = 0 use reg setting
  939. * As Bfee, we use Nsts, so nr_index don't care
  940. */
  941. nr_index = bfer->NumofSoundingDim;
  942. grouping = 0;
  943. /* for ac = 1, for n = 3 */
  944. if (TEST_FLAG(bfer->cap, BEAMFORMER_CAP_VHT_SU))
  945. codebookinfo = 1;
  946. else if (TEST_FLAG(bfer->cap, BEAMFORMER_CAP_HT_EXPLICIT))
  947. codebookinfo = 3;
  948. coefficientsize = 3;
  949. csi_param = (u16)((coefficientsize<<10)|(codebookinfo<<8)|(grouping<<6)|(nr_index<<3)|(nc_index));
  950. rtw_write16(adapter, addr_csi_rpt, csi_param);
  951. RTW_INFO("%s: nc=%d nr=%d group=%d codebookinfo=%d coefficientsize=%d\n",
  952. __FUNCTION__, nc_index, nr_index, grouping, codebookinfo, coefficientsize);
  953. RTW_INFO("%s: csi=0x%04x\n", __FUNCTION__, csi_param);
  954. /* ndp_rx_standby_timer */
  955. rtw_write8(adapter, REG_SND_PTCL_CTRL_8821C+3, 0x70);
  956. }
  957. static void _config_beamformer_mu(PADAPTER adapter, struct beamformer_entry *bfer)
  958. {
  959. /* General */
  960. PHAL_DATA_TYPE hal;
  961. /* Beamforming */
  962. struct beamforming_info *bf_info;
  963. u8 nc_index = 0, nr_index = 0;
  964. u8 grouping = 0, codebookinfo = 0, coefficientsize = 0;
  965. u32 csi_param;
  966. /* Misc */
  967. u8 i, val8;
  968. u16 val16;
  969. RTW_INFO("%s: Config MU BFer entry HW setting\n", __FUNCTION__);
  970. hal = GET_HAL_DATA(adapter);
  971. bf_info = GET_BEAMFORM_INFO(adapter);
  972. /* Reset GID table */
  973. for (i = 0; i < 8; i++)
  974. bfer->gid_valid[i] = 0;
  975. for (i = 0; i < 16; i++)
  976. bfer->user_position[i] = 0;
  977. /* CSI report parameters of Beamformer */
  978. nc_index = _bf_get_nrx(adapter);
  979. nr_index = 1; /* 0x718[7] = 1 use Nsts, 0x718[7] = 0 use reg setting. as Bfee, we use Nsts, so Nr_index don't care */
  980. grouping = 0; /* no grouping */
  981. codebookinfo = 1; /* 7 bit for psi, 9 bit for phi */
  982. coefficientsize = 0; /* This is nothing really matter */
  983. csi_param = (u16)((coefficientsize<<10)|(codebookinfo<<8)|
  984. (grouping<<6)|(nr_index<<3)|(nc_index));
  985. RTW_INFO("%s: nc=%d nr=%d group=%d codebookinfo=%d coefficientsize=%d\n",
  986. __func__, nc_index, nr_index, grouping, codebookinfo,
  987. coefficientsize);
  988. RTW_INFO("%s: csi=0x%04x\n", __func__, csi_param);
  989. rtw_halmac_bf_add_mu_bfer(adapter_to_dvobj(adapter), bfer->p_aid,
  990. csi_param, bfer->aid & 0xfff, HAL_CSI_SEG_4K,
  991. bfer->mac_addr);
  992. bf_info->cur_csi_rpt_rate = HALMAC_OFDM6;
  993. rtw_halmac_bf_cfg_sounding(adapter_to_dvobj(adapter), HAL_BFEE,
  994. bf_info->cur_csi_rpt_rate);
  995. /* Set 0x6A0[14] = 1 to accept action_no_ack */
  996. val8 = rtw_read8(adapter, REG_RXFLTMAP0_8821C+1);
  997. val8 |= (BIT_MGTFLT14EN_8821C >> 8);
  998. rtw_write8(adapter, REG_RXFLTMAP0_8821C+1, val8);
  999. /* Set 0x6A2[5:4] = 1 to NDPA and BF report poll */
  1000. val8 = rtw_read8(adapter, REG_RXFLTMAP1_8821C);
  1001. val8 |= BIT_CTRLFLT4EN_8821C | BIT_CTRLFLT5EN_8821C;
  1002. rtw_write8(adapter, REG_RXFLTMAP1_8821C, val8);
  1003. /* for B-Cut */
  1004. if (IS_B_CUT(hal->version_id)) {
  1005. phy_set_bb_reg(adapter, REG_RXFLTMAP0_8821C, BIT(20), 0);
  1006. phy_set_bb_reg(adapter, REG_RXFLTMAP3_8821C, BIT(20), 0);
  1007. }
  1008. }
  1009. static void _reset_beamformer_su(PADAPTER adapter, struct beamformer_entry *bfer)
  1010. {
  1011. /* Beamforming */
  1012. struct beamforming_info *info;
  1013. u8 idx;
  1014. info = GET_BEAMFORM_INFO(adapter);
  1015. /* SU BFer */
  1016. idx = bfer->su_reg_index;
  1017. if (idx == 0) {
  1018. rtw_write32(adapter, REG_ASSOCIATED_BFMER0_INFO_8821C, 0);
  1019. rtw_write16(adapter, REG_ASSOCIATED_BFMER0_INFO_8821C+4, 0);
  1020. rtw_write16(adapter, REG_TX_CSI_RPT_PARAM_BW20_8821C, 0);
  1021. } else {
  1022. rtw_write32(adapter, REG_ASSOCIATED_BFMER1_INFO_8821C, 0);
  1023. rtw_write16(adapter, REG_ASSOCIATED_BFMER1_INFO_8821C+4, 0);
  1024. rtw_write16(adapter, REG_TX_CSI_RPT_PARAM_BW20_8821C+2, 0);
  1025. }
  1026. info->beamformer_su_reg_maping &= ~BIT(idx);
  1027. bfer->su_reg_index = 0xFF;
  1028. RTW_INFO("%s: Clear SU BFer entry(%d) HW setting\n", __FUNCTION__, idx);
  1029. }
  1030. static void _reset_beamformer_mu(PADAPTER adapter, struct beamformer_entry *bfer)
  1031. {
  1032. struct beamforming_info *bf_info;
  1033. bf_info = GET_BEAMFORM_INFO(adapter);
  1034. rtw_halmac_bf_del_mu_bfer(adapter_to_dvobj(adapter));
  1035. if (bf_info->beamformer_su_cnt == 0 &&
  1036. bf_info->beamformer_mu_cnt == 0)
  1037. rtw_halmac_bf_del_sounding(adapter_to_dvobj(adapter), HAL_BFEE);
  1038. RTW_INFO("%s: Clear MU BFer entry HW setting\n", __FUNCTION__);
  1039. }
  1040. void rtl8821c_phy_bf_init(PADAPTER adapter)
  1041. {
  1042. u8 v8;
  1043. u32 v32;
  1044. v32 = rtw_read32(adapter, REG_MU_TX_CTL_8821C);
  1045. /* Enable P1 aggr new packet according to P0 transfer time */
  1046. v32 |= BIT_R_MU_P1_WAIT_STATE_EN_8821C;
  1047. /* MU Retry Limit */
  1048. v32 = BIT_SET_R_MU_RL_8821C(v32, 0xA);
  1049. /* Disable Tx MU-MIMO until sounding done */
  1050. v32 &= ~BIT_R_EN_MU_MIMO_8821C;
  1051. /* Clear validity of MU STAs */
  1052. v32 = BIT_SET_R_MU_TABLE_VALID_8821C(v32, 0);
  1053. rtw_write32(adapter, REG_MU_TX_CTL_8821C, v32);
  1054. /* MU-MIMO Option as default value */
  1055. v8 = BIT_WMAC_TXMU_ACKPOLICY_8821C(3);
  1056. v8 |= BIT_WMAC_TXMU_ACKPOLICY_EN_8821C;
  1057. rtw_write8(adapter, REG_MU_BF_OPTION_8821C, v8);
  1058. /* MU-MIMO Control as default value */
  1059. rtw_write16(adapter, REG_WMAC_MU_BF_CTL_8821C, 0);
  1060. /* Set MU NDPA rate & BW source */
  1061. /* 0x42C[30] = 1 (0: from Tx desc, 1: from 0x45F) */
  1062. v8 = rtw_read8(adapter, REG_TXBF_CTRL_8821C+3);
  1063. v8 |= (BIT_USE_NDPA_PARAMETER_8821C >> 24);
  1064. rtw_write8(adapter, REG_TXBF_CTRL_8821C+3, v8);
  1065. /* 0x45F[7:0] = 0x10 (Rate=OFDM_6M, BW20) */
  1066. rtw_write8(adapter, REG_NDPA_OPT_CTRL_8821C, 0x10);
  1067. /* Temp Settings */
  1068. /* STA2's CSI rate is fixed at 6M */
  1069. v8 = rtw_read8(adapter, 0x6DF);
  1070. v8 = (v8 & 0xC0) | 0x4;
  1071. rtw_write8(adapter, 0x6DF, v8);
  1072. /* Grouping bitmap parameters */
  1073. rtw_write32(adapter, 0x1C94, 0xAFFFAFFF);
  1074. }
  1075. void rtl8821c_phy_bf_enter(PADAPTER adapter, struct sta_info *sta)
  1076. {
  1077. struct beamforming_info *info;
  1078. struct beamformer_entry *bfer;
  1079. RTW_INFO("+%s: " MAC_FMT "\n", __FUNCTION__, MAC_ARG(sta->cmn.mac_addr));
  1080. info = GET_BEAMFORM_INFO(adapter);
  1081. bfer = rtw_bf_bfer_get_entry_by_addr(adapter, sta->cmn.mac_addr);
  1082. info->bSetBFHwConfigInProgess = _TRUE;
  1083. if (bfer) {
  1084. bfer->state = BEAMFORM_ENTRY_HW_STATE_ADDING;
  1085. if (TEST_FLAG(bfer->cap, BEAMFORMER_CAP_VHT_MU))
  1086. _config_beamformer_mu(adapter, bfer);
  1087. else if (TEST_FLAG(bfer->cap, BEAMFORMER_CAP_VHT_SU|BEAMFORMER_CAP_HT_EXPLICIT))
  1088. _config_beamformer_su(adapter, bfer);
  1089. bfer->state = BEAMFORM_ENTRY_HW_STATE_ADDED;
  1090. }
  1091. info->bSetBFHwConfigInProgess = _FALSE;
  1092. RTW_INFO("-%s\n", __FUNCTION__);
  1093. }
  1094. void rtl8821c_phy_bf_leave(PADAPTER adapter, u8 *addr)
  1095. {
  1096. struct beamforming_info *info;
  1097. struct beamformer_entry *bfer;
  1098. RTW_INFO("+%s: " MAC_FMT "\n", __FUNCTION__, MAC_ARG(addr));
  1099. info = GET_BEAMFORM_INFO(adapter);
  1100. bfer = rtw_bf_bfer_get_entry_by_addr(adapter, addr);
  1101. /* Clear P_AID of Beamformee */
  1102. /* Clear MAC address of Beamformer */
  1103. /* Clear Associated Bfmee Sel */
  1104. if (bfer) {
  1105. bfer->state = BEAMFORM_ENTRY_HW_STATE_DELETING;
  1106. rtw_write8(adapter, REG_SND_PTCL_CTRL_8821C, 0xD8);
  1107. if (TEST_FLAG(bfer->cap, BEAMFORMER_CAP_VHT_MU))
  1108. _reset_beamformer_mu(adapter, bfer);
  1109. else if (TEST_FLAG(bfer->cap, BEAMFORMER_CAP_VHT_SU|BEAMFORMER_CAP_HT_EXPLICIT))
  1110. _reset_beamformer_su(adapter, bfer);
  1111. bfer->state = BEAMFORM_ENTRY_HW_STATE_NONE;
  1112. bfer->cap = BEAMFORMING_CAP_NONE;
  1113. bfer->used = _FALSE;
  1114. }
  1115. RTW_INFO("-%s\n", __FUNCTION__);
  1116. }
  1117. void rtl8821c_phy_bf_set_gid_table(PADAPTER adapter,
  1118. struct beamformer_entry *bfer_info)
  1119. {
  1120. struct beamformer_entry *bfer;
  1121. struct beamforming_info *info;
  1122. u32 gid_valid[2] = {0};
  1123. u32 user_position[4] = {0};
  1124. int i;
  1125. /* update bfer info */
  1126. bfer = rtw_bf_bfer_get_entry_by_addr(adapter, bfer_info->mac_addr);
  1127. if (!bfer) {
  1128. RTW_INFO("%s: Cannot find BFer entry!!\n", __func__);
  1129. return;
  1130. }
  1131. _rtw_memcpy(bfer->gid_valid, bfer_info->gid_valid, 8);
  1132. _rtw_memcpy(bfer->user_position, bfer_info->user_position, 16);
  1133. info = GET_BEAMFORM_INFO(adapter);
  1134. info->bSetBFHwConfigInProgess = _TRUE;
  1135. /* For GID 0~31 */
  1136. for (i = 0; i < 4; i++)
  1137. gid_valid[0] |= (bfer->gid_valid[i] << (i << 3));
  1138. for (i = 0; i < 8; i++) {
  1139. if (i < 4)
  1140. user_position[0] |= (bfer->user_position[i] << (i << 3));
  1141. else
  1142. user_position[1] |= (bfer->user_position[i] << ((i - 4) << 3));
  1143. }
  1144. RTW_INFO("%s: STA0: gid_valid=0x%x, user_position_l=0x%x, user_position_h=0x%x\n",
  1145. __func__, gid_valid[0], user_position[0], user_position[1]);
  1146. /* For GID 32~64 */
  1147. for (i = 4; i < 8; i++)
  1148. gid_valid[1] |= (bfer->gid_valid[i] << ((i - 4) << 3));
  1149. for (i = 8; i < 16; i++) {
  1150. if (i < 12)
  1151. user_position[2] |= (bfer->user_position[i] << ((i - 8) << 3));
  1152. else
  1153. user_position[3] |= (bfer->user_position[i] << ((i - 12) << 3));
  1154. }
  1155. RTW_INFO("%s: STA1: gid_valid=0x%x, user_position_l=0x%x, user_position_h=0x%x\n",
  1156. __func__, gid_valid[1], user_position[2], user_position[3]);
  1157. rtw_halmac_bf_cfg_mu_bfee(adapter_to_dvobj(adapter), gid_valid, user_position);
  1158. info->bSetBFHwConfigInProgess = _FALSE;
  1159. }
  1160. #endif /* RTW_BEAMFORMING_VERSION_2 */
  1161. #endif /* CONFIG_BEAMFORMING */
  1162. #ifdef CONFIG_MP_INCLUDED
  1163. /*
  1164. * Description:
  1165. * Config RF path
  1166. *
  1167. * Parameters:
  1168. * adapter pointer of struct _ADAPTER
  1169. */
  1170. void rtl8821c_mp_config_rfpath(PADAPTER adapter)
  1171. {
  1172. PHAL_DATA_TYPE hal;
  1173. PMPT_CONTEXT mpt;
  1174. ANTENNA_PATH anttx, antrx;
  1175. enum rf_path rxant;
  1176. hal = GET_HAL_DATA(adapter);
  1177. mpt = &adapter->mppriv.mpt_ctx;
  1178. anttx = hal->antenna_tx_path;
  1179. antrx = hal->AntennaRxPath;
  1180. RTW_INFO("+Config RF Path, tx=0x%x rx=0x%x\n", anttx, antrx);
  1181. #if 0 /* phydm not ready */
  1182. switch (anttx) {
  1183. case ANTENNA_A:
  1184. mpt->mpt_rf_path = ODM_RF_A;
  1185. break;
  1186. case ANTENNA_B:
  1187. mpt->mpt_rf_path = ODM_RF_B;
  1188. break;
  1189. case ANTENNA_AB:
  1190. default:
  1191. mpt->mpt_rf_path = ODM_RF_A | ODM_RF_B;
  1192. break;
  1193. }
  1194. switch (antrx) {
  1195. case ANTENNA_A:
  1196. rxant = ODM_RF_A;
  1197. break;
  1198. case ANTENNA_B:
  1199. rxant = ODM_RF_B;
  1200. break;
  1201. case ANTENNA_AB:
  1202. default:
  1203. rxant = ODM_RF_A | ODM_RF_B;
  1204. break;
  1205. }
  1206. config_phydm_trx_mode_8821c(GET_PDM_ODM(adapter), mpt->mpt_rf_path, rxant, FALSE);
  1207. #endif
  1208. RTW_INFO("-Config RF Path Finish\n");
  1209. }
  1210. #endif /* CONFIG_MP_INCLUDED */