rtl8812a_rf6052.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2007 - 2011 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 _RTL8812A_RF6052_C_
  21. //#include <drv_types.h>
  22. #include <rtl8812a_hal.h>
  23. /*-----------------------------------------------------------------------------
  24. * Function: PHY_RF6052SetBandwidth()
  25. *
  26. * Overview: This function is called by SetBWModeCallback8190Pci() only
  27. *
  28. * Input: PADAPTER Adapter
  29. * WIRELESS_BANDWIDTH_E Bandwidth //20M or 40M
  30. *
  31. * Output: NONE
  32. *
  33. * Return: NONE
  34. *
  35. * Note: For RF type 0222D
  36. *---------------------------------------------------------------------------*/
  37. VOID
  38. PHY_RF6052SetBandwidth8812(
  39. IN PADAPTER Adapter,
  40. IN CHANNEL_WIDTH Bandwidth) //20M or 40M
  41. {
  42. HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
  43. switch(Bandwidth)
  44. {
  45. case CHANNEL_WIDTH_20:
  46. //DBG_871X("PHY_RF6052SetBandwidth8812(), set 20MHz, pHalData->RfRegChnlVal[0] = 0x%x \n", pHalData->RfRegChnlVal[0]);
  47. PHY_SetRFReg(Adapter, RF_PATH_A, RF_CHNLBW_Jaguar, BIT11|BIT10, 3);
  48. PHY_SetRFReg(Adapter, RF_PATH_B, RF_CHNLBW_Jaguar, BIT11|BIT10, 3);
  49. break;
  50. case CHANNEL_WIDTH_40:
  51. //DBG_871X("PHY_RF6052SetBandwidth8812(), set 40MHz, pHalData->RfRegChnlVal[0] = 0x%x \n", pHalData->RfRegChnlVal[0]);
  52. PHY_SetRFReg(Adapter, RF_PATH_A, RF_CHNLBW_Jaguar, BIT11|BIT10, 1);
  53. PHY_SetRFReg(Adapter, RF_PATH_B, RF_CHNLBW_Jaguar, BIT11|BIT10, 1);
  54. break;
  55. case CHANNEL_WIDTH_80:
  56. //DBG_871X("PHY_RF6052SetBandwidth8812(), set 80MHz, pHalData->RfRegChnlVal[0] = 0x%x \n", pHalData->RfRegChnlVal[0]);
  57. PHY_SetRFReg(Adapter, RF_PATH_A, RF_CHNLBW_Jaguar, BIT11|BIT10, 0);
  58. PHY_SetRFReg(Adapter, RF_PATH_B, RF_CHNLBW_Jaguar, BIT11|BIT10, 0);
  59. break;
  60. default:
  61. DBG_871X("PHY_RF6052SetBandwidth8812(): unknown Bandwidth: %#X\n",Bandwidth );
  62. break;
  63. }
  64. }
  65. //
  66. // powerbase0 for OFDM rates
  67. // powerbase1 for HT MCS rates
  68. //
  69. void getPowerBase8812(
  70. IN PADAPTER Adapter,
  71. IN u8* pPowerLevelOFDM,
  72. IN u8* pPowerLevelBW20,
  73. IN u8* pPowerLevelBW40,
  74. IN u8 Channel,
  75. IN OUT u32* OfdmBase,
  76. IN OUT u32* MCSBase
  77. )
  78. {
  79. HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
  80. u32 powerBase0, powerBase1;
  81. u8 i, powerlevel[2];
  82. for(i=0; i<2; i++)
  83. {
  84. powerBase0 = pPowerLevelOFDM[i];
  85. powerBase0 = (powerBase0<<24) | (powerBase0<<16) |(powerBase0<<8) |powerBase0;
  86. *(OfdmBase+i) = powerBase0;
  87. //DBG_871X(" [OFDM power base index rf(%c) = 0x%x]\n", ((i==0)?'A':'B'), *(OfdmBase+i));
  88. }
  89. for(i=0; i<pHalData->NumTotalRFPath; i++)
  90. {
  91. //Check HT20 to HT40 diff
  92. if(pHalData->CurrentChannelBW == CHANNEL_WIDTH_20)
  93. {
  94. powerlevel[i] = pPowerLevelBW20[i];
  95. }
  96. else
  97. {
  98. powerlevel[i] = pPowerLevelBW40[i];
  99. }
  100. powerBase1 = powerlevel[i];
  101. powerBase1 = (powerBase1<<24) | (powerBase1<<16) |(powerBase1<<8) |powerBase1;
  102. *(MCSBase+i) = powerBase1;
  103. //DBG_871X(" [MCS power base index rf(%c) = 0x%x]\n", ((i==0)?'A':'B'), *(MCSBase+i));
  104. }
  105. }
  106. void getTxPowerWriteValByRegulatory8812(
  107. IN PADAPTER Adapter,
  108. IN u8 Channel,
  109. IN u8 index,
  110. IN u32* powerBase0,
  111. IN u32* powerBase1,
  112. OUT u32* pOutWriteVal
  113. )
  114. {
  115. HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
  116. struct dm_priv *pdmpriv = &pHalData->dmpriv;
  117. u8 i, chnlGroup=0, pwr_diff_limit[4], customer_pwr_limit;
  118. s8 pwr_diff=0;
  119. u32 writeVal, customer_limit, rf;
  120. u8 Regulatory = pHalData->EEPROMRegulatory;
  121. //
  122. // Index 0 & 1= legacy OFDM, 2-5=HT_MCS rate
  123. //
  124. #if 0 // (INTEL_PROXIMITY_SUPPORT == 1)
  125. if(pMgntInfo->IntelProximityModeInfo.PowerOutput > 0)
  126. Regulatory = 2;
  127. #endif
  128. for(rf=0; rf<2; rf++)
  129. {
  130. switch(Regulatory)
  131. {
  132. case 0: // Realtek better performance
  133. // increase power diff defined by Realtek for large power
  134. chnlGroup = 0;
  135. //RTPRINT(FPHY, PHY_TXPWR, ("MCSTxPowerLevelOriginalOffset[%d][%d] = 0x%x\n",
  136. // chnlGroup, index, pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index+(rf?8:0)]));
  137. writeVal = pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index+(rf?8:0)] +
  138. ((index<2)?powerBase0[rf]:powerBase1[rf]);
  139. //RTPRINT(FPHY, PHY_TXPWR, ("RTK better performance, writeVal(%c) = 0x%x\n", ((rf==0)?'A':'B'), writeVal));
  140. break;
  141. case 1: // Realtek regulatory
  142. // increase power diff defined by Realtek for regulatory
  143. {
  144. if(pHalData->pwrGroupCnt == 1)
  145. chnlGroup = 0;
  146. //if(pHalData->pwrGroupCnt >= pHalData->PGMaxGroup)
  147. {
  148. if (Channel < 3) // Chanel 1-2
  149. chnlGroup = 0;
  150. else if (Channel < 6) // Channel 3-5
  151. chnlGroup = 1;
  152. else if(Channel <9) // Channel 6-8
  153. chnlGroup = 2;
  154. else if(Channel <12) // Channel 9-11
  155. chnlGroup = 3;
  156. else if(Channel <14) // Channel 12-13
  157. chnlGroup = 4;
  158. else if(Channel ==14) // Channel 14
  159. chnlGroup = 5;
  160. /*
  161. if(Channel <= 3)
  162. chnlGroup = 0;
  163. else if(Channel >= 4 && Channel <= 9)
  164. chnlGroup = 1;
  165. else if(Channel > 9)
  166. chnlGroup = 2;
  167. if(pHalData->CurrentChannelBW == CHANNEL_WIDTH_20)
  168. chnlGroup++;
  169. else
  170. chnlGroup+=4;
  171. */
  172. }
  173. //RTPRINT(FPHY, PHY_TXPWR, ("MCSTxPowerLevelOriginalOffset[%d][%d] = 0x%x\n",
  174. //chnlGroup, index, pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index+(rf?8:0)]));
  175. writeVal = pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index+(rf?8:0)] +
  176. ((index<2)?powerBase0[rf]:powerBase1[rf]);
  177. //RTPRINT(FPHY, PHY_TXPWR, ("Realtek regulatory, 20MHz, writeVal(%c) = 0x%x\n", ((rf==0)?'A':'B'), writeVal));
  178. }
  179. break;
  180. case 2: // Better regulatory
  181. // don't increase any power diff
  182. writeVal = ((index<2)?powerBase0[rf]:powerBase1[rf]);
  183. //RTPRINT(FPHY, PHY_TXPWR, ("Better regulatory, writeVal(%c) = 0x%x\n", ((rf==0)?'A':'B'), writeVal));
  184. break;
  185. case 3: // Customer defined power diff.
  186. // increase power diff defined by customer.
  187. chnlGroup = 0;
  188. //RTPRINT(FPHY, PHY_TXPWR, ("MCSTxPowerLevelOriginalOffset[%d][%d] = 0x%x\n",
  189. // chnlGroup, index, pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index+(rf?8:0)]));
  190. /*
  191. if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_40)
  192. {
  193. RTPRINT(FPHY, PHY_TXPWR, ("customer's limit, 40MHz rf(%c) = 0x%x\n",
  194. ((rf==0)?'A':'B'), pHalData->PwrGroupHT40[rf][Channel-1]));
  195. }
  196. else
  197. {
  198. RTPRINT(FPHY, PHY_TXPWR, ("customer's limit, 20MHz rf(%c) = 0x%x\n",
  199. ((rf==0)?'A':'B'), pHalData->PwrGroupHT20[rf][Channel-1]));
  200. }*/
  201. if(index < 2)
  202. pwr_diff = pHalData->TxPwrLegacyHtDiff[rf][Channel-1];
  203. else if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_20)
  204. pwr_diff = pHalData->TxPwrHt20Diff[rf][Channel-1];
  205. //RTPRINT(FPHY, PHY_TXPWR, ("power diff rf(%c) = 0x%x\n", ((rf==0)?'A':'B'), pwr_diff));
  206. if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_40)
  207. customer_pwr_limit = pHalData->PwrGroupHT40[rf][Channel-1];
  208. else
  209. customer_pwr_limit = pHalData->PwrGroupHT20[rf][Channel-1];
  210. //RTPRINT(FPHY, PHY_TXPWR, ("customer pwr limit rf(%c) = 0x%x\n", ((rf==0)?'A':'B'), customer_pwr_limit));
  211. if(pwr_diff >= customer_pwr_limit)
  212. pwr_diff = 0;
  213. else
  214. pwr_diff = customer_pwr_limit - pwr_diff;
  215. for (i=0; i<4; i++)
  216. {
  217. pwr_diff_limit[i] = (u1Byte)((pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index+(rf?8:0)]&(0x7f<<(i*8)))>>(i*8));
  218. if(pwr_diff_limit[i] > pwr_diff)
  219. pwr_diff_limit[i] = pwr_diff;
  220. }
  221. customer_limit = (pwr_diff_limit[3]<<24) | (pwr_diff_limit[2]<<16) |
  222. (pwr_diff_limit[1]<<8) | (pwr_diff_limit[0]);
  223. //RTPRINT(FPHY, PHY_TXPWR, ("Customer's limit rf(%c) = 0x%x\n", ((rf==0)?'A':'B'), customer_limit));
  224. writeVal = customer_limit + ((index<2)?powerBase0[rf]:powerBase1[rf]);
  225. //RTPRINT(FPHY, PHY_TXPWR, ("Customer, writeVal rf(%c)= 0x%x\n", ((rf==0)?'A':'B'), writeVal));
  226. break;
  227. default:
  228. chnlGroup = 0;
  229. writeVal = pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index+(rf?8:0)] +
  230. ((index<2)?powerBase0[rf]:powerBase1[rf]);
  231. //RTPRINT(FPHY, PHY_TXPWR, ("RTK better performance, writeVal rf(%c) = 0x%x\n", ((rf==0)?'A':'B'), writeVal));
  232. break;
  233. }
  234. // 20100427 Joseph: Driver dynamic Tx power shall not affect Tx power. It shall be determined by power training mechanism.
  235. // Currently, we cannot fully disable driver dynamic tx power mechanism because it is referenced by BT coexist mechanism.
  236. // In the future, two mechanism shall be separated from each other and maintained independantly. Thanks for Lanhsin's reminder.
  237. //92d do not need this
  238. if(pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level1)
  239. writeVal = 0x14141414;
  240. else if(pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level2)
  241. writeVal = 0x00000000;
  242. // 20100628 Joseph: High power mode for BT-Coexist mechanism.
  243. // This mechanism is only applied when Driver-Highpower-Mechanism is OFF.
  244. if(pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_BT1)
  245. {
  246. //RTPRINT(FBT, BT_TRACE, ("Tx Power (-6)\n"));
  247. writeVal = writeVal - 0x06060606;
  248. }
  249. else if(pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_BT2)
  250. {
  251. //RTPRINT(FBT, BT_TRACE, ("Tx Power (-0)\n"));
  252. writeVal = writeVal ;
  253. }
  254. /*
  255. if(pMgntInfo->bDisableTXPowerByRate)
  256. {
  257. // add for OID_RT_11N_TX_POWER_BY_RATE ,disable tx powre change by rate
  258. writeVal = 0x2c2c2c2c;
  259. }
  260. */
  261. *(pOutWriteVal+rf) = writeVal;
  262. }
  263. }
  264. static void writeOFDMPowerReg8812(
  265. IN PADAPTER Adapter,
  266. IN u8 index,
  267. IN u32* pValue
  268. )
  269. {
  270. HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
  271. u2Byte RegOffset_A[6] = {
  272. rTxAGC_A_Ofdm18_Ofdm6_JAguar,
  273. rTxAGC_A_Ofdm54_Ofdm24_JAguar,
  274. rTxAGC_A_MCS3_MCS0_JAguar,
  275. rTxAGC_A_MCS7_MCS4_JAguar,
  276. rTxAGC_A_MCS11_MCS8_JAguar,
  277. rTxAGC_A_MCS15_MCS12_JAguar
  278. };
  279. u2Byte RegOffset_B[6] = {
  280. rTxAGC_B_Ofdm18_Ofdm6_JAguar,
  281. rTxAGC_B_Ofdm54_Ofdm24_JAguar,
  282. rTxAGC_B_MCS3_MCS0_JAguar,
  283. rTxAGC_B_MCS7_MCS4_JAguar,
  284. rTxAGC_B_MCS11_MCS8_JAguar,
  285. rTxAGC_B_MCS15_MCS12_JAguar
  286. };
  287. u8 i, rf, pwr_val[4];
  288. u32 writeVal;
  289. u16 RegOffset;
  290. for(rf=0; rf<2; rf++)
  291. {
  292. writeVal = pValue[rf];
  293. for(i=0; i<RF_PATH_MAX_92C_88E; i++)
  294. {
  295. pwr_val[i] = (u8)((writeVal & (0x7f<<(i*8)))>>(i*8));
  296. if (pwr_val[i] > RF6052_MAX_TX_PWR)
  297. pwr_val[i] = RF6052_MAX_TX_PWR;
  298. }
  299. writeVal = (pwr_val[3]<<24) | (pwr_val[2]<<16) |(pwr_val[1]<<8) |pwr_val[0];
  300. if(rf == 0)
  301. RegOffset = RegOffset_A[index];
  302. else
  303. RegOffset = RegOffset_B[index];
  304. PHY_SetBBReg(Adapter, RegOffset, bMaskDWord, writeVal);
  305. //RTPRINT(FPHY, PHY_TXPWR, ("Set 0x%x = %08x\n", RegOffset, writeVal));
  306. }
  307. }
  308. VOID
  309. PHY_RF6052SetCckTxPower8812(
  310. IN PADAPTER Adapter,
  311. IN u8* pPowerlevel)
  312. {
  313. HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
  314. struct dm_priv *pdmpriv = &pHalData->dmpriv;
  315. struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv;
  316. u32 TxAGC[2]={0, 0}, tmpval=0;
  317. BOOLEAN TurboScanOff = _FALSE;
  318. u8 idx1, idx2;
  319. u8* ptr;
  320. //FOR CE ,must disable turbo scan
  321. TurboScanOff = _TRUE;
  322. if(pmlmeext->sitesurvey_res.state == SCAN_PROCESS)
  323. {
  324. TxAGC[RF_PATH_A] = 0x3f3f3f3f;
  325. TxAGC[RF_PATH_B] = 0x3f3f3f3f;
  326. TurboScanOff = _TRUE;//disable turbo scan
  327. if(TurboScanOff)
  328. {
  329. for(idx1=RF_PATH_A; idx1<=RF_PATH_B; idx1++)
  330. {
  331. TxAGC[idx1] =
  332. pPowerlevel[idx1] | (pPowerlevel[idx1]<<8) |
  333. (pPowerlevel[idx1]<<16) | (pPowerlevel[idx1]<<24);
  334. #if defined(CONFIG_USB_HCI) || defined(CONFIG_SDIO_HCI)
  335. // 2010/10/18 MH For external PA module. We need to limit power index to be less than 0x20.
  336. if (TxAGC[idx1] > 0x20 && pHalData->ExternalPA_5G)
  337. TxAGC[idx1] = 0x20;
  338. #endif
  339. }
  340. }
  341. }
  342. else
  343. {
  344. // 20100427 Joseph: Driver dynamic Tx power shall not affect Tx power. It shall be determined by power training mechanism.
  345. // Currently, we cannot fully disable driver dynamic tx power mechanism because it is referenced by BT coexist mechanism.
  346. // In the future, two mechanism shall be separated from each other and maintained independantly. Thanks for Lanhsin's reminder.
  347. if(pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level1)
  348. {
  349. TxAGC[RF_PATH_A] = 0x10101010;
  350. TxAGC[RF_PATH_B] = 0x10101010;
  351. }
  352. else if(pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level2)
  353. {
  354. TxAGC[RF_PATH_A] = 0x00000000;
  355. TxAGC[RF_PATH_B] = 0x00000000;
  356. }
  357. else
  358. {
  359. for(idx1=RF_PATH_A; idx1<=RF_PATH_B; idx1++)
  360. {
  361. TxAGC[idx1] =
  362. pPowerlevel[idx1] | (pPowerlevel[idx1]<<8) |
  363. (pPowerlevel[idx1]<<16) | (pPowerlevel[idx1]<<24);
  364. }
  365. if(pHalData->EEPROMRegulatory==0)
  366. {
  367. tmpval = (pHalData->MCSTxPowerLevelOriginalOffset[0][6]) +
  368. (pHalData->MCSTxPowerLevelOriginalOffset[0][7]<<8);
  369. TxAGC[RF_PATH_A] += tmpval;
  370. tmpval = (pHalData->MCSTxPowerLevelOriginalOffset[0][14]) +
  371. (pHalData->MCSTxPowerLevelOriginalOffset[0][15]<<24);
  372. TxAGC[RF_PATH_B] += tmpval;
  373. }
  374. }
  375. }
  376. for(idx1=RF_PATH_A; idx1<=RF_PATH_B; idx1++)
  377. {
  378. ptr = (u8*)(&(TxAGC[idx1]));
  379. for(idx2=0; idx2<4; idx2++)
  380. {
  381. if(*ptr > RF6052_MAX_TX_PWR)
  382. *ptr = RF6052_MAX_TX_PWR;
  383. ptr++;
  384. }
  385. }
  386. // rf-A cck tx power
  387. tmpval = TxAGC[RF_PATH_A]&0xff;
  388. PHY_SetBBReg(Adapter, rTxAGC_A_CCK11_CCK1_JAguar, bMaskByte1, tmpval);
  389. //RT_DISP(FPHY, PHY_TXPWR, ("CCK PWR 1M (rf-A) = 0x%x (reg 0x%x)\n", tmpval, rTxAGC_A_CCK1_Mcs32));
  390. tmpval = TxAGC[RF_PATH_A]>>8;
  391. PHY_SetBBReg(Adapter, rTxAGC_A_CCK11_CCK1_JAguar, 0xffffff00, tmpval);
  392. //RT_DISP(FPHY, PHY_TXPWR, ("CCK PWR 2~11M (rf-A) = 0x%x (reg 0x%x)\n", tmpval, rTxAGC_B_CCK11_A_CCK2_11));
  393. // rf-B cck tx power
  394. tmpval = TxAGC[RF_PATH_B]>>24;
  395. PHY_SetBBReg(Adapter, rTxAGC_B_CCK11_CCK1_JAguar, bMaskByte0, tmpval);
  396. //RT_DISP(FPHY, PHY_TXPWR, ("CCK PWR 11M (rf-B) = 0x%x (reg 0x%x)\n", tmpval, rTxAGC_B_CCK11_A_CCK2_11));
  397. tmpval = TxAGC[RF_PATH_B]&0x00ffffff;
  398. PHY_SetBBReg(Adapter, rTxAGC_B_CCK11_CCK1_JAguar, 0xffffff00, tmpval);
  399. //RT_DISP(FPHY, PHY_TXPWR, ("CCK PWR 1~5.5M (rf-B) = 0x%x (reg 0x%x)\n", tmpval, rTxAGC_B_CCK1_55_Mcs32));
  400. } /* PHY_RF6052SetCckTxPower */
  401. VOID
  402. PHY_RF6052SetOFDMTxPower8812(
  403. IN PADAPTER Adapter,
  404. IN u8* pPowerLevelOFDM,
  405. IN u8* pPowerLevelBW20,
  406. IN u8* pPowerLevelBW40,
  407. IN u8 Channel)
  408. {
  409. u32 writeVal[2], powerBase0[2], powerBase1[2], pwrtrac_value;
  410. u8 index = 0;
  411. //DBG_871X("PHY_RF6052SetOFDMTxPower, channel(%d) \n", Channel);
  412. getPowerBase8812(Adapter, pPowerLevelOFDM,pPowerLevelBW20,pPowerLevelBW40, Channel, &powerBase0[0], &powerBase1[0]);
  413. for(index=0; index<6; index++)
  414. {
  415. getTxPowerWriteValByRegulatory8812(Adapter, Channel, index,
  416. &powerBase0[0], &powerBase1[0], &writeVal[0]);
  417. writeOFDMPowerReg8812(Adapter, index, &writeVal[0]);
  418. }
  419. }
  420. static int
  421. phy_RF6052_Config_ParaFile_8812(
  422. IN PADAPTER Adapter
  423. )
  424. {
  425. u8 eRFPath;
  426. int rtStatus = _SUCCESS;
  427. HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
  428. static char sz8812RadioAFile[] = RTL8812_PHY_RADIO_A;
  429. static char sz8812RadioBFile[] = RTL8812_PHY_RADIO_B;
  430. static char sz8812TxPwrTrack[] = RTL8812_TXPWR_TRACK;
  431. static char sz8821RadioAFile[] = RTL8821_PHY_RADIO_A;
  432. static char sz8821RadioBFile[] = RTL8821_PHY_RADIO_B;
  433. static char sz8821TxPwrTrack[] = RTL8821_TXPWR_TRACK;
  434. char *pszRadioAFile = NULL, *pszRadioBFile = NULL, *pszTxPwrTrack = NULL;
  435. if(IS_HARDWARE_TYPE_8812(Adapter))
  436. {
  437. pszRadioAFile = sz8812RadioAFile;
  438. pszRadioBFile = sz8812RadioBFile;
  439. pszTxPwrTrack = sz8812TxPwrTrack;
  440. }
  441. else
  442. {
  443. pszRadioAFile = sz8821RadioAFile;
  444. pszRadioBFile = sz8821RadioBFile;
  445. pszTxPwrTrack = sz8821TxPwrTrack;
  446. }
  447. //3//-----------------------------------------------------------------
  448. //3// <2> Initialize RF
  449. //3//-----------------------------------------------------------------
  450. //for(eRFPath = RF_PATH_A; eRFPath <pHalData->NumTotalRFPath; eRFPath++)
  451. for(eRFPath = 0; eRFPath <pHalData->NumTotalRFPath; eRFPath++)
  452. {
  453. /*----Initialize RF fom connfiguration file----*/
  454. switch(eRFPath)
  455. {
  456. case RF_PATH_A:
  457. #ifdef CONFIG_EMBEDDED_FWIMG
  458. if(HAL_STATUS_FAILURE ==ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv,CONFIG_RF_RADIO, (ODM_RF_RADIO_PATH_E)eRFPath))
  459. rtStatus= _FAIL;
  460. #else
  461. rtStatus = PHY_ConfigRFWithParaFile(Adapter, pszRadioAFile, eRFPath);
  462. #endif//#ifdef CONFIG_EMBEDDED_FWIMG
  463. break;
  464. case RF_PATH_B:
  465. #ifdef CONFIG_EMBEDDED_FWIMG
  466. if(HAL_STATUS_FAILURE ==ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv,CONFIG_RF_RADIO, (ODM_RF_RADIO_PATH_E)eRFPath))
  467. rtStatus= _FAIL;
  468. #else
  469. rtStatus =PHY_ConfigRFWithParaFile(Adapter, pszRadioBFile, eRFPath);
  470. #endif
  471. break;
  472. default:
  473. break;
  474. }
  475. if(rtStatus != _SUCCESS){
  476. DBG_871X("%s():Radio[%d] Fail!!", __FUNCTION__, eRFPath);
  477. goto phy_RF6052_Config_ParaFile_Fail;
  478. }
  479. }
  480. //3 -----------------------------------------------------------------
  481. //3 Configuration of Tx Power Tracking
  482. //3 -----------------------------------------------------------------
  483. #ifdef CONFIG_EMBEDDED_FWIMG
  484. ODM_ConfigRFWithTxPwrTrackHeaderFile(&pHalData->odmpriv);
  485. #else
  486. PHY_ConfigRFWithTxPwrTrackParaFile(Adapter, pszTxPwrTrack);
  487. #endif
  488. //RT_TRACE(COMP_INIT, DBG_LOUD, ("<---phy_RF6052_Config_ParaFile_8812()\n"));
  489. phy_RF6052_Config_ParaFile_Fail:
  490. return rtStatus;
  491. }
  492. int
  493. PHY_RF6052_Config_8812(
  494. IN PADAPTER Adapter)
  495. {
  496. HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
  497. int rtStatus = _SUCCESS;
  498. // Initialize general global value
  499. if(pHalData->rf_type == RF_1T1R)
  500. pHalData->NumTotalRFPath = 1;
  501. else
  502. pHalData->NumTotalRFPath = 2;
  503. //
  504. // Config BB and RF
  505. //
  506. rtStatus = phy_RF6052_Config_ParaFile_8812(Adapter);
  507. return rtStatus;
  508. }
  509. /* End of HalRf6052.c */