rtl8812a_mp.c 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108
  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_MP_C_
  21. #ifdef CONFIG_MP_INCLUDED
  22. //#include <drv_types.h>
  23. #include <rtl8812a_hal.h>
  24. s32 Hal_SetPowerTracking(PADAPTER padapter, u8 enable)
  25. {
  26. BOOLEAN bResult = TRUE;
  27. PMPT_CONTEXT pMptCtx = &(padapter->mppriv.MptCtx);
  28. HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
  29. pHalData->TxPowerTrackControl = (u1Byte)enable;
  30. if(pHalData->TxPowerTrackControl > 1)
  31. pHalData->TxPowerTrackControl = 0;
  32. return bResult;
  33. return _SUCCESS;
  34. }
  35. void Hal_GetPowerTracking(PADAPTER padapter, u8 *enable)
  36. {
  37. HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
  38. struct dm_priv *pdmpriv = &pHalData->dmpriv;
  39. PDM_ODM_T pDM_Odm = &(pHalData->odmpriv);
  40. *enable = pDM_Odm->RFCalibrateInfo.TxPowerTrackControl;
  41. }
  42. static void Hal_disable_dm(PADAPTER padapter)
  43. {
  44. u8 v8;
  45. HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
  46. struct dm_priv *pdmpriv = &pHalData->dmpriv;
  47. PDM_ODM_T pDM_Odm = &(pHalData->odmpriv);
  48. //3 1. disable firmware dynamic mechanism
  49. // disable Power Training, Rate Adaptive
  50. v8 = rtw_read8(padapter, REG_BCN_CTRL);
  51. v8 &= ~EN_BCN_FUNCTION;
  52. rtw_write8(padapter, REG_BCN_CTRL, v8);
  53. //3 2. disable driver dynamic mechanism
  54. // disable Dynamic Initial Gain
  55. // disable High Power
  56. // disable Power Tracking
  57. Switch_DM_Func(padapter, DYNAMIC_FUNC_DISABLE, _FALSE);
  58. // enable APK, LCK and IQK but disable power tracking
  59. pDM_Odm->RFCalibrateInfo.TxPowerTrackControl = _FALSE;
  60. Switch_DM_Func(padapter, DYNAMIC_FUNC_DISABLE, _TRUE);
  61. }
  62. /*-----------------------------------------------------------------------------
  63. * Function: mpt_SwitchRfSetting
  64. *
  65. * Overview: Change RF Setting when we siwthc channel/rate/BW for MP.
  66. *
  67. * Input: IN PADAPTER pAdapter
  68. *
  69. * Output: NONE
  70. *
  71. * Return: NONE
  72. *
  73. * Revised History:
  74. * When Who Remark
  75. * 01/08/2009 MHC Suggestion from SD3 Willis for 92S series.
  76. * 01/09/2009 MHC Add CCK modification for 40MHZ. Suggestion from SD3.
  77. *
  78. *---------------------------------------------------------------------------*/
  79. void Hal_mpt_SwitchRfSetting(PADAPTER pAdapter)
  80. {
  81. //HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
  82. struct mp_priv *pmp = &pAdapter->mppriv;
  83. u1Byte ChannelToSw = pmp->channel;
  84. ULONG ulRateIdx = pmp->rateidx;
  85. ULONG ulbandwidth = pmp->bandwidth;
  86. HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
  87. // <20120525, Kordan> Dynamic mechanism for APK, asked by Dennis.
  88. pmp->MptCtx.backup0x52_RF_A = (u1Byte)PHY_QueryRFReg(pAdapter, RF_PATH_A, RF_0x52, 0x000F0);
  89. pmp->MptCtx.backup0x52_RF_B = (u1Byte)PHY_QueryRFReg(pAdapter, RF_PATH_B, RF_0x52, 0x000F0);
  90. PHY_SetRFReg(pAdapter, RF_PATH_A, RF_0x52, 0x000F0, 0xD);
  91. PHY_SetRFReg(pAdapter, RF_PATH_B, RF_0x52, 0x000F0, 0xD);
  92. return ;
  93. }
  94. /*---------------------------hal\rtl8192c\MPT_Phy.c---------------------------*/
  95. /*---------------------------hal\rtl8192c\MPT_HelperFunc.c---------------------------*/
  96. void Hal_MPT_CCKTxPowerAdjust(PADAPTER Adapter, BOOLEAN bInCH14)
  97. {
  98. u32 TempVal = 0, TempVal2 = 0, TempVal3 = 0;
  99. u32 CurrCCKSwingVal = 0, CCKSwingIndex = 12;
  100. u8 i;
  101. HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
  102. // get current cck swing value and check 0xa22 & 0xa23 later to match the table.
  103. CurrCCKSwingVal = read_bbreg(Adapter, rCCK0_TxFilter1, bMaskHWord);
  104. if (!bInCH14)
  105. {
  106. // Readback the current bb cck swing value and compare with the table to
  107. // get the current swing index
  108. for (i = 0; i < CCK_TABLE_SIZE; i++)
  109. {
  110. if (((CurrCCKSwingVal&0xff) == (u32)CCKSwingTable_Ch1_Ch13[i][0]) &&
  111. (((CurrCCKSwingVal&0xff00)>>8) == (u32)CCKSwingTable_Ch1_Ch13[i][1]))
  112. {
  113. CCKSwingIndex = i;
  114. // RT_TRACE(COMP_INIT, DBG_LOUD,("Ch1~13, Current reg0x%x = 0x%lx, CCKSwingIndex=0x%x\n",
  115. // (rCCK0_TxFilter1+2), CurrCCKSwingVal, CCKSwingIndex));
  116. break;
  117. }
  118. }
  119. //Write 0xa22 0xa23
  120. TempVal = CCKSwingTable_Ch1_Ch13[CCKSwingIndex][0] +
  121. (CCKSwingTable_Ch1_Ch13[CCKSwingIndex][1]<<8) ;
  122. //Write 0xa24 ~ 0xa27
  123. TempVal2 = 0;
  124. TempVal2 = CCKSwingTable_Ch1_Ch13[CCKSwingIndex][2] +
  125. (CCKSwingTable_Ch1_Ch13[CCKSwingIndex][3]<<8) +
  126. (CCKSwingTable_Ch1_Ch13[CCKSwingIndex][4]<<16 )+
  127. (CCKSwingTable_Ch1_Ch13[CCKSwingIndex][5]<<24);
  128. //Write 0xa28 0xa29
  129. TempVal3 = 0;
  130. TempVal3 = CCKSwingTable_Ch1_Ch13[CCKSwingIndex][6] +
  131. (CCKSwingTable_Ch1_Ch13[CCKSwingIndex][7]<<8) ;
  132. }
  133. else
  134. {
  135. for (i = 0; i < CCK_TABLE_SIZE; i++)
  136. {
  137. if (((CurrCCKSwingVal&0xff) == (u32)CCKSwingTable_Ch14[i][0]) &&
  138. (((CurrCCKSwingVal&0xff00)>>8) == (u32)CCKSwingTable_Ch14[i][1]))
  139. {
  140. CCKSwingIndex = i;
  141. // RT_TRACE(COMP_INIT, DBG_LOUD,("Ch14, Current reg0x%x = 0x%lx, CCKSwingIndex=0x%x\n",
  142. // (rCCK0_TxFilter1+2), CurrCCKSwingVal, CCKSwingIndex));
  143. break;
  144. }
  145. }
  146. //Write 0xa22 0xa23
  147. TempVal = CCKSwingTable_Ch14[CCKSwingIndex][0] +
  148. (CCKSwingTable_Ch14[CCKSwingIndex][1]<<8) ;
  149. //Write 0xa24 ~ 0xa27
  150. TempVal2 = 0;
  151. TempVal2 = CCKSwingTable_Ch14[CCKSwingIndex][2] +
  152. (CCKSwingTable_Ch14[CCKSwingIndex][3]<<8) +
  153. (CCKSwingTable_Ch14[CCKSwingIndex][4]<<16 )+
  154. (CCKSwingTable_Ch14[CCKSwingIndex][5]<<24);
  155. //Write 0xa28 0xa29
  156. TempVal3 = 0;
  157. TempVal3 = CCKSwingTable_Ch14[CCKSwingIndex][6] +
  158. (CCKSwingTable_Ch14[CCKSwingIndex][7]<<8) ;
  159. }
  160. write_bbreg(Adapter, rCCK0_TxFilter1, bMaskHWord, TempVal);
  161. write_bbreg(Adapter, rCCK0_TxFilter2, bMaskDWord, TempVal2);
  162. write_bbreg(Adapter, rCCK0_DebugPort, bMaskLWord, TempVal3);
  163. }
  164. void Hal_MPT_CCKTxPowerAdjustbyIndex(PADAPTER pAdapter, BOOLEAN beven)
  165. {
  166. s32 TempCCk;
  167. u8 CCK_index, CCK_index_old;
  168. u8 Action = 0; //0: no action, 1: even->odd, 2:odd->even
  169. u8 TimeOut = 100;
  170. s32 i = 0;
  171. HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
  172. PMPT_CONTEXT pMptCtx = &pAdapter->mppriv.MptCtx;
  173. struct dm_priv *pdmpriv = &pHalData->dmpriv;
  174. PDM_ODM_T pDM_Odm = &(pHalData->odmpriv);
  175. if (!IS_92C_SERIAL(pHalData->VersionID))
  176. return;
  177. #if 0
  178. while(PlatformAtomicExchange(&Adapter->IntrCCKRefCount, TRUE) == TRUE)
  179. {
  180. PlatformSleepUs(100);
  181. TimeOut--;
  182. if(TimeOut <= 0)
  183. {
  184. RTPRINT(FINIT, INIT_TxPower,
  185. ("!!!MPT_CCKTxPowerAdjustbyIndex Wait for check CCK gain index too long!!!\n" ));
  186. break;
  187. }
  188. }
  189. #endif
  190. if (beven && !pMptCtx->bMptIndexEven) //odd->even
  191. {
  192. Action = 2;
  193. pMptCtx->bMptIndexEven = _TRUE;
  194. }
  195. else if (!beven && pMptCtx->bMptIndexEven) //even->odd
  196. {
  197. Action = 1;
  198. pMptCtx->bMptIndexEven = _FALSE;
  199. }
  200. if (Action != 0)
  201. {
  202. //Query CCK default setting From 0xa24
  203. TempCCk = read_bbreg(pAdapter, rCCK0_TxFilter2, bMaskDWord) & bMaskCCK;
  204. for (i = 0; i < CCK_TABLE_SIZE; i++)
  205. {
  206. if (pDM_Odm->RFCalibrateInfo.bCCKinCH14)
  207. {
  208. if (_rtw_memcmp((void*)&TempCCk, (void*)&CCKSwingTable_Ch14[i][2], 4) == _TRUE)
  209. {
  210. CCK_index_old = (u8) i;
  211. // RTPRINT(FINIT, INIT_TxPower,("MPT_CCKTxPowerAdjustbyIndex: Initial reg0x%x = 0x%lx, CCK_index=0x%x, ch 14 %d\n",
  212. // rCCK0_TxFilter2, TempCCk, CCK_index_old, pHalData->bCCKinCH14));
  213. break;
  214. }
  215. }
  216. else
  217. {
  218. if (_rtw_memcmp((void*)&TempCCk, (void*)&CCKSwingTable_Ch1_Ch13[i][2], 4) == _TRUE)
  219. {
  220. CCK_index_old = (u8) i;
  221. // RTPRINT(FINIT, INIT_TxPower,("MPT_CCKTxPowerAdjustbyIndex: Initial reg0x%x = 0x%lx, CCK_index=0x%x, ch14 %d\n",
  222. // rCCK0_TxFilter2, TempCCk, CCK_index_old, pHalData->bCCKinCH14));
  223. break;
  224. }
  225. }
  226. }
  227. if (Action == 1)
  228. CCK_index = CCK_index_old - 1;
  229. else
  230. CCK_index = CCK_index_old + 1;
  231. // RTPRINT(FINIT, INIT_TxPower,("MPT_CCKTxPowerAdjustbyIndex: new CCK_index=0x%x\n",
  232. // CCK_index));
  233. //Adjust CCK according to gain index
  234. if (!pDM_Odm->RFCalibrateInfo.bCCKinCH14) {
  235. rtw_write8(pAdapter, 0xa22, CCKSwingTable_Ch1_Ch13[CCK_index][0]);
  236. rtw_write8(pAdapter, 0xa23, CCKSwingTable_Ch1_Ch13[CCK_index][1]);
  237. rtw_write8(pAdapter, 0xa24, CCKSwingTable_Ch1_Ch13[CCK_index][2]);
  238. rtw_write8(pAdapter, 0xa25, CCKSwingTable_Ch1_Ch13[CCK_index][3]);
  239. rtw_write8(pAdapter, 0xa26, CCKSwingTable_Ch1_Ch13[CCK_index][4]);
  240. rtw_write8(pAdapter, 0xa27, CCKSwingTable_Ch1_Ch13[CCK_index][5]);
  241. rtw_write8(pAdapter, 0xa28, CCKSwingTable_Ch1_Ch13[CCK_index][6]);
  242. rtw_write8(pAdapter, 0xa29, CCKSwingTable_Ch1_Ch13[CCK_index][7]);
  243. } else {
  244. rtw_write8(pAdapter, 0xa22, CCKSwingTable_Ch14[CCK_index][0]);
  245. rtw_write8(pAdapter, 0xa23, CCKSwingTable_Ch14[CCK_index][1]);
  246. rtw_write8(pAdapter, 0xa24, CCKSwingTable_Ch14[CCK_index][2]);
  247. rtw_write8(pAdapter, 0xa25, CCKSwingTable_Ch14[CCK_index][3]);
  248. rtw_write8(pAdapter, 0xa26, CCKSwingTable_Ch14[CCK_index][4]);
  249. rtw_write8(pAdapter, 0xa27, CCKSwingTable_Ch14[CCK_index][5]);
  250. rtw_write8(pAdapter, 0xa28, CCKSwingTable_Ch14[CCK_index][6]);
  251. rtw_write8(pAdapter, 0xa29, CCKSwingTable_Ch14[CCK_index][7]);
  252. }
  253. }
  254. #if 0
  255. RTPRINT(FINIT, INIT_TxPower,
  256. ("MPT_CCKTxPowerAdjustbyIndex 0xa20=%x\n", PlatformEFIORead4Byte(Adapter, 0xa20)));
  257. PlatformAtomicExchange(&Adapter->IntrCCKRefCount, FALSE);
  258. #endif
  259. }
  260. /*---------------------------hal\rtl8192c\MPT_HelperFunc.c---------------------------*/
  261. /*
  262. * SetChannel
  263. * Description
  264. * Use H2C command to change channel,
  265. * not only modify rf register, but also other setting need to be done.
  266. */
  267. void Hal_SetChannel(PADAPTER pAdapter)
  268. {
  269. #if 0
  270. struct mp_priv *pmp = &pAdapter->mppriv;
  271. // SelectChannel(pAdapter, pmp->channel);
  272. set_channel_bwmode(pAdapter, pmp->channel, pmp->channel_offset, pmp->bandwidth);
  273. #else
  274. u8 eRFPath;
  275. HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
  276. struct mp_priv *pmp = &pAdapter->mppriv;
  277. struct dm_priv *pdmpriv = &pHalData->dmpriv;
  278. PDM_ODM_T pDM_Odm = &(pHalData->odmpriv);
  279. u8 channel = pmp->channel;
  280. u8 bandwidth = pmp->bandwidth;
  281. u8 rate = pmp->rateidx;
  282. // set RF channel register
  283. for (eRFPath = 0; eRFPath < pHalData->NumTotalRFPath; eRFPath++)
  284. {
  285. if(IS_HARDWARE_TYPE_8192D(pAdapter))
  286. _write_rfreg(pAdapter, eRFPath, ODM_CHANNEL, 0xFF, channel);
  287. else
  288. _write_rfreg(pAdapter, eRFPath, ODM_CHANNEL, 0x3FF, channel);
  289. }
  290. //Hal_mpt_SwitchRfSetting(pAdapter);
  291. SelectChannel(pAdapter, channel);
  292. if (pHalData->CurrentChannel == 14 && !pDM_Odm->RFCalibrateInfo.bCCKinCH14) {
  293. pDM_Odm->RFCalibrateInfo.bCCKinCH14 = _TRUE;
  294. Hal_MPT_CCKTxPowerAdjust(pAdapter, pDM_Odm->RFCalibrateInfo.bCCKinCH14);
  295. }
  296. else if (pHalData->CurrentChannel != 14 && pDM_Odm->RFCalibrateInfo.bCCKinCH14) {
  297. pDM_Odm->RFCalibrateInfo.bCCKinCH14 = _FALSE;
  298. Hal_MPT_CCKTxPowerAdjust(pAdapter, pDM_Odm->RFCalibrateInfo.bCCKinCH14);
  299. }
  300. #endif
  301. }
  302. /*
  303. * Notice
  304. * Switch bandwitdth may change center frequency(channel)
  305. */
  306. void Hal_SetBandwidth(PADAPTER pAdapter)
  307. {
  308. struct mp_priv *pmp = &pAdapter->mppriv;
  309. SetBWMode(pAdapter, pmp->bandwidth, pmp->prime_channel_offset);
  310. Hal_mpt_SwitchRfSetting(pAdapter);
  311. }
  312. void Hal_SetCCKTxPower(PADAPTER pAdapter, u8 *TxPower)
  313. {
  314. u32 tmpval = 0;
  315. // rf-A cck tx power
  316. write_bbreg(pAdapter, rTxAGC_A_CCK1_Mcs32, bMaskByte1, TxPower[RF_PATH_A]);
  317. tmpval = (TxPower[RF_PATH_A]<<16) | (TxPower[RF_PATH_A]<<8) | TxPower[RF_PATH_A];
  318. write_bbreg(pAdapter, rTxAGC_B_CCK11_A_CCK2_11, 0xffffff00, tmpval);
  319. // rf-B cck tx power
  320. write_bbreg(pAdapter, rTxAGC_B_CCK11_A_CCK2_11, bMaskByte0, TxPower[RF_PATH_B]);
  321. tmpval = (TxPower[RF_PATH_B]<<16) | (TxPower[RF_PATH_B]<<8) | TxPower[RF_PATH_B];
  322. write_bbreg(pAdapter, rTxAGC_B_CCK1_55_Mcs32, 0xffffff00, tmpval);
  323. RT_TRACE(_module_mp_, _drv_notice_,
  324. ("-SetCCKTxPower: A[0x%02x] B[0x%02x]\n",
  325. TxPower[RF_PATH_A], TxPower[RF_PATH_B]));
  326. }
  327. void Hal_SetOFDMTxPower(PADAPTER pAdapter, u8 *TxPower)
  328. {
  329. u32 TxAGC = 0;
  330. u8 tmpval = 0;
  331. PMPT_CONTEXT pMptCtx = &pAdapter->mppriv.MptCtx;
  332. HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
  333. // HT Tx-rf(A)
  334. tmpval = TxPower[RF_PATH_A];
  335. TxAGC = (tmpval<<24) | (tmpval<<16) | (tmpval<<8) | tmpval;
  336. write_bbreg(pAdapter, rTxAGC_A_Rate18_06, bMaskDWord, TxAGC);
  337. write_bbreg(pAdapter, rTxAGC_A_Rate54_24, bMaskDWord, TxAGC);
  338. write_bbreg(pAdapter, rTxAGC_A_Mcs03_Mcs00, bMaskDWord, TxAGC);
  339. write_bbreg(pAdapter, rTxAGC_A_Mcs07_Mcs04, bMaskDWord, TxAGC);
  340. write_bbreg(pAdapter, rTxAGC_A_Mcs11_Mcs08, bMaskDWord, TxAGC);
  341. write_bbreg(pAdapter, rTxAGC_A_Mcs15_Mcs12, bMaskDWord, TxAGC);
  342. // HT Tx-rf(B)
  343. tmpval = TxPower[RF_PATH_B];
  344. TxAGC = (tmpval<<24) | (tmpval<<16) | (tmpval<<8) | tmpval;
  345. write_bbreg(pAdapter, rTxAGC_B_Rate18_06, bMaskDWord, TxAGC);
  346. write_bbreg(pAdapter, rTxAGC_B_Rate54_24, bMaskDWord, TxAGC);
  347. write_bbreg(pAdapter, rTxAGC_B_Mcs03_Mcs00, bMaskDWord, TxAGC);
  348. write_bbreg(pAdapter, rTxAGC_B_Mcs07_Mcs04, bMaskDWord, TxAGC);
  349. write_bbreg(pAdapter, rTxAGC_B_Mcs11_Mcs08, bMaskDWord, TxAGC);
  350. write_bbreg(pAdapter, rTxAGC_B_Mcs15_Mcs12, bMaskDWord, TxAGC);
  351. }
  352. void Hal_SetAntennaPathPower(PADAPTER pAdapter)
  353. {
  354. HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
  355. u8 TxPowerLevel[MAX_RF_PATH];
  356. u8 rfPath;
  357. TxPowerLevel[RF_PATH_A] = pAdapter->mppriv.txpoweridx;
  358. TxPowerLevel[RF_PATH_B] = pAdapter->mppriv.txpoweridx_b;
  359. switch (pAdapter->mppriv.antenna_tx)
  360. {
  361. case ANTENNA_A:
  362. default:
  363. rfPath = RF_PATH_A;
  364. break;
  365. case ANTENNA_B:
  366. rfPath = RF_PATH_B;
  367. break;
  368. case ANTENNA_C:
  369. rfPath = RF_PATH_C;
  370. break;
  371. }
  372. switch (pHalData->rf_chip)
  373. {
  374. case RF_8225:
  375. case RF_8256:
  376. case RF_6052:
  377. Hal_SetCCKTxPower(pAdapter, TxPowerLevel);
  378. if (pAdapter->mppriv.rateidx < MPT_RATE_6M) // CCK rate
  379. Hal_MPT_CCKTxPowerAdjustbyIndex(pAdapter, TxPowerLevel[rfPath]%2 == 0);
  380. Hal_SetOFDMTxPower(pAdapter, TxPowerLevel);
  381. break;
  382. default:
  383. break;
  384. }
  385. }
  386. typedef enum _MPT_TXPWR_DEF{
  387. MPT_CCK,
  388. MPT_OFDM, // L and HT OFDM
  389. MPT_VHT_OFDM
  390. }MPT_TXPWR_DEF;
  391. void
  392. mpt_SetTxPower_8812(
  393. PADAPTER pAdapter,
  394. MPT_TXPWR_DEF Rate,
  395. pu1Byte pTxPower
  396. )
  397. {
  398. u1Byte path = 0;
  399. switch (Rate)
  400. {
  401. case MPT_CCK:
  402. {
  403. for (path = ODM_RF_PATH_A; path <= ODM_RF_PATH_B; path++)
  404. {
  405. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_1M );
  406. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_2M );
  407. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_5_5M);
  408. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_11M );
  409. }
  410. }
  411. break;
  412. case MPT_OFDM:
  413. {
  414. for (path = ODM_RF_PATH_A; path <= ODM_RF_PATH_B; path++)
  415. {
  416. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_1M );
  417. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_2M );
  418. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_5_5M);
  419. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_11M );
  420. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_6M );
  421. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_9M );
  422. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_12M);
  423. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_18M);
  424. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_24M);
  425. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_36M);
  426. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_48M);
  427. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_54M);
  428. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_MCS0 );
  429. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_MCS1 );
  430. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_MCS2 );
  431. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_MCS3 );
  432. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_MCS4 );
  433. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_MCS5 );
  434. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_MCS6 );
  435. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_MCS7 );
  436. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_MCS8 );
  437. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_MCS9 );
  438. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_MCS10);
  439. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_MCS11);
  440. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_MCS12);
  441. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_MCS13);
  442. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_MCS14);
  443. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_MCS15);
  444. }
  445. } break;
  446. case MPT_VHT_OFDM:
  447. {
  448. for (path = ODM_RF_PATH_A; path <= ODM_RF_PATH_B; path++)
  449. {
  450. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_VHT1SS_MCS0);
  451. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_VHT1SS_MCS1);
  452. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_VHT1SS_MCS2);
  453. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_VHT1SS_MCS3);
  454. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_VHT1SS_MCS4);
  455. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_VHT1SS_MCS5);
  456. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_VHT1SS_MCS6);
  457. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_VHT1SS_MCS7);
  458. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_VHT1SS_MCS8);
  459. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_VHT1SS_MCS9);
  460. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_VHT2SS_MCS0);
  461. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_VHT2SS_MCS1);
  462. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_VHT2SS_MCS2);
  463. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_VHT2SS_MCS3);
  464. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_VHT2SS_MCS4);
  465. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_VHT2SS_MCS5);
  466. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_VHT2SS_MCS6);
  467. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_VHT2SS_MCS7);
  468. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_VHT2SS_MCS8);
  469. PHY_SetTxPowerIndex_8812A(pAdapter, pTxPower[path], path, MGN_VHT2SS_MCS9);
  470. }
  471. } break;
  472. default:
  473. DBG_871X("<===mpt_SetTxPower_8812: Illegal channel!!\n");
  474. break;
  475. }
  476. }
  477. void Hal_SetTxPower(PADAPTER pAdapter)
  478. {
  479. HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
  480. PMPT_CONTEXT pMptCtx = &(pAdapter->mppriv.MptCtx);
  481. u1Byte path;
  482. PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
  483. path = ( pAdapter->mppriv.antenna_tx == ANTENNA_A) ? (ODM_RF_PATH_A) : (ODM_RF_PATH_B);
  484. if (IS_HARDWARE_TYPE_JAGUAR(pAdapter))
  485. {
  486. DBG_871X("===> MPT_ProSetTxPower: Jaguar\n");
  487. mpt_SetTxPower_8812(pAdapter, MPT_CCK, pMptCtx->TxPwrLevel);
  488. mpt_SetTxPower_8812(pAdapter, MPT_OFDM, pMptCtx->TxPwrLevel);
  489. mpt_SetTxPower_8812(pAdapter, MPT_VHT_OFDM, pMptCtx->TxPwrLevel);
  490. }
  491. ODM_ClearTxPowerTrackingState(pDM_Odm);
  492. }
  493. void Hal_SetTxAGCOffset(PADAPTER pAdapter, u32 ulTxAGCOffset)
  494. {
  495. u32 TxAGCOffset_B, TxAGCOffset_C, TxAGCOffset_D,tmpAGC;
  496. TxAGCOffset_B = (ulTxAGCOffset&0x000000ff);
  497. TxAGCOffset_C = ((ulTxAGCOffset&0x0000ff00)>>8);
  498. TxAGCOffset_D = ((ulTxAGCOffset&0x00ff0000)>>16);
  499. tmpAGC = (TxAGCOffset_D<<8 | TxAGCOffset_C<<4 | TxAGCOffset_B);
  500. write_bbreg(pAdapter, rFPGA0_TxGainStage,
  501. (bXBTxAGC|bXCTxAGC|bXDTxAGC), tmpAGC);
  502. }
  503. void Hal_SetDataRate(PADAPTER pAdapter)
  504. {
  505. //Hal_mpt_SwitchRfSetting(pAdapter);
  506. }
  507. #define RF_PATH_AB 22
  508. void Hal_SetAntenna(PADAPTER pAdapter)
  509. {
  510. HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
  511. PMPT_CONTEXT pMptCtx = &pAdapter->mppriv.MptCtx;
  512. R_ANTENNA_SELECT_OFDM *p_ofdm_tx; /* OFDM Tx register */
  513. R_ANTENNA_SELECT_CCK *p_cck_txrx;
  514. u8 r_rx_antenna_ofdm = 0, r_ant_select_cck_val = 0;
  515. u8 chgTx = 0, chgRx = 0;
  516. u32 r_ant_sel_cck_val = 0, r_ant_select_ofdm_val = 0, r_ofdm_tx_en_val = 0;
  517. u32 reg0xC50 = 0;
  518. p_ofdm_tx = (R_ANTENNA_SELECT_OFDM *)&r_ant_select_ofdm_val;
  519. p_cck_txrx = (R_ANTENNA_SELECT_CCK *)&r_ant_select_cck_val;
  520. switch (pAdapter->mppriv.antenna_tx)
  521. {
  522. case ANTENNA_A:
  523. pMptCtx->MptRfPath = ODM_RF_PATH_A;
  524. PHY_SetBBReg(pAdapter, rTxPath_Jaguar, bMaskLWord, 0x1111);
  525. if (pHalData->RFEType == 3)
  526. PHY_SetBBReg(pAdapter, r_ANTSEL_SW_Jaguar, bMask_AntselPathFollow_Jaguar, 0x0 );
  527. break;
  528. case ANTENNA_B:
  529. pMptCtx->MptRfPath = ODM_RF_PATH_B;
  530. PHY_SetBBReg(pAdapter, rTxPath_Jaguar, bMaskLWord, 0x2222);
  531. if (pHalData->RFEType == 3)
  532. PHY_SetBBReg(pAdapter, r_ANTSEL_SW_Jaguar, bMask_AntselPathFollow_Jaguar, 0x1 );
  533. break;
  534. break;
  535. case ANTENNA_AB: // For 8192S
  536. pMptCtx->MptRfPath = RF_PATH_AB;
  537. PHY_SetBBReg(pAdapter, rTxPath_Jaguar, bMaskLWord, 0x3333);
  538. if (pHalData->RFEType == 3)
  539. PHY_SetBBReg(pAdapter, r_ANTSEL_SW_Jaguar, bMask_AntselPathFollow_Jaguar, 0x0 );
  540. break;
  541. default:
  542. pMptCtx->MptRfPath = RF_PATH_AB;
  543. DBG_871X("Unknown Tx antenna.\n");
  544. break;
  545. }
  546. switch (pAdapter->mppriv.antenna_rx)
  547. {
  548. case ANTENNA_A:
  549. PHY_SetBBReg(pAdapter, rRxPath_Jaguar, bMaskByte0, 0x11);
  550. PHY_SetRFReg(pAdapter, ODM_RF_PATH_B, RF_AC_Jaguar, 0xF0000, 0x1); // RF_B_0x0[19:16] = 1, Standby mode
  551. PHY_SetBBReg(pAdapter, rCCK_RX_Jaguar, bCCK_RX_Jaguar, 0x0);
  552. PHY_SetRFReg(pAdapter, ODM_RF_PATH_A, RF_AC_Jaguar, BIT19|BIT18|BIT17|BIT16, 0x3);
  553. // <20121101, Kordan> To prevent gain table from not switched, asked by Ynlin.
  554. reg0xC50 = PHY_QueryBBReg(pAdapter, rA_IGI_Jaguar, bMaskByte0);
  555. PHY_SetBBReg(pAdapter, rA_IGI_Jaguar, bMaskByte0, reg0xC50+2);
  556. PHY_SetBBReg(pAdapter, rA_IGI_Jaguar, bMaskByte0, reg0xC50);
  557. break;
  558. case ANTENNA_B:
  559. PHY_SetBBReg(pAdapter, rRxPath_Jaguar, bMaskByte0, 0x22);
  560. PHY_SetRFReg(pAdapter, ODM_RF_PATH_A, RF_AC_Jaguar, 0xF0000, 0x1); // RF_A_0x0[19:16] = 1, Standby mode
  561. PHY_SetBBReg(pAdapter, rCCK_RX_Jaguar, bCCK_RX_Jaguar, 0x1);
  562. PHY_SetRFReg(pAdapter, ODM_RF_PATH_B, RF_AC_Jaguar, BIT19|BIT18|BIT17|BIT16, 0x3);
  563. // <20121101, Kordan> To prevent gain table from not switched, asked by Ynlin.
  564. reg0xC50 = PHY_QueryBBReg(pAdapter, rB_IGI_Jaguar, bMaskByte0);
  565. PHY_SetBBReg(pAdapter, rB_IGI_Jaguar, bMaskByte0, reg0xC50+2);
  566. PHY_SetBBReg(pAdapter, rB_IGI_Jaguar, bMaskByte0, reg0xC50);
  567. break;
  568. case ANTENNA_AB:
  569. PHY_SetBBReg(pAdapter, rRxPath_Jaguar, bMaskByte0, 0x33);
  570. PHY_SetRFReg(pAdapter, ODM_RF_PATH_B, RF_AC_Jaguar, 0xF0000, 0x3); // RF_B_0x0[19:16] = 3, Rx mode
  571. PHY_SetBBReg(pAdapter, rCCK_RX_Jaguar, bCCK_RX_Jaguar, 0x0);
  572. break;
  573. default:
  574. DBG_871X("Unknown Rx antenna.\n");
  575. break;
  576. }
  577. RT_TRACE(_module_mp_, _drv_notice_, ("-SwitchAntenna: finished\n"));
  578. }
  579. s32 Hal_SetThermalMeter(PADAPTER pAdapter, u8 target_ther)
  580. {
  581. HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
  582. if (!netif_running(pAdapter->pnetdev)) {
  583. RT_TRACE(_module_mp_, _drv_warning_, ("SetThermalMeter! Fail: interface not opened!\n"));
  584. return _FAIL;
  585. }
  586. if (check_fwstate(&pAdapter->mlmepriv, WIFI_MP_STATE) == _FALSE) {
  587. RT_TRACE(_module_mp_, _drv_warning_, ("SetThermalMeter: Fail! not in MP mode!\n"));
  588. return _FAIL;
  589. }
  590. target_ther &= 0xff;
  591. if (target_ther < 0x07)
  592. target_ther = 0x07;
  593. else if (target_ther > 0x1d)
  594. target_ther = 0x1d;
  595. pHalData->EEPROMThermalMeter = target_ther;
  596. return _SUCCESS;
  597. }
  598. void Hal_TriggerRFThermalMeter(PADAPTER pAdapter)
  599. {
  600. _write_rfreg( pAdapter, RF_PATH_A , RF_T_METER_8812A , BIT17 |BIT16 , 0x03 );
  601. // RT_TRACE(_module_mp_,_drv_alert_, ("TriggerRFThermalMeter() finished.\n" ));
  602. }
  603. u8 Hal_ReadRFThermalMeter(PADAPTER pAdapter)
  604. {
  605. u32 ThermalValue = 0;
  606. ThermalValue = (u1Byte)PHY_QueryRFReg(pAdapter, ODM_RF_PATH_A, RF_T_METER_8812A, 0xfc00); // 0x42: RF Reg[15:10]
  607. // RT_TRACE(_module_mp_, _drv_alert_, ("ThermalValue = 0x%x\n", ThermalValue));
  608. return (u8)ThermalValue;
  609. }
  610. void Hal_GetThermalMeter(PADAPTER pAdapter, u8 *value)
  611. {
  612. #if 0
  613. fw_cmd(pAdapter, IOCMD_GET_THERMAL_METER);
  614. rtw_msleep_os(1000);
  615. fw_cmd_data(pAdapter, value, 1);
  616. *value &= 0xFF;
  617. #else
  618. Hal_TriggerRFThermalMeter(pAdapter);
  619. rtw_msleep_os(1000);
  620. *value = Hal_ReadRFThermalMeter(pAdapter);
  621. #endif
  622. }
  623. void Hal_SetSingleCarrierTx(PADAPTER pAdapter, u8 bStart)
  624. {
  625. HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
  626. pAdapter->mppriv.MptCtx.bSingleCarrier = bStart;
  627. if (bStart)// Start Single Carrier.
  628. {
  629. RT_TRACE(_module_mp_,_drv_alert_, ("SetSingleCarrierTx: test start\n"));
  630. // 1. if OFDM block on?
  631. if(!read_bbreg(pAdapter, rFPGA0_RFMOD, bOFDMEn))
  632. write_bbreg(pAdapter, rFPGA0_RFMOD, bOFDMEn, bEnable);//set OFDM block on
  633. // 2. set CCK test mode off, set to CCK normal mode
  634. write_bbreg(pAdapter, rCCK0_System, bCCKBBMode, bDisable);
  635. // 3. turn on scramble setting
  636. write_bbreg(pAdapter, rCCK0_System, bCCKScramble, bEnable);
  637. // 4. Turn On Continue Tx and turn off the other test modes.
  638. if (IS_HARDWARE_TYPE_JAGUAR(pAdapter))
  639. PHY_SetBBReg(pAdapter, rSingleTone_ContTx_Jaguar, BIT18|BIT17|BIT16, OFDM_SingleCarrier);
  640. else
  641. PHY_SetBBReg(pAdapter, rOFDM1_LSTF, BIT30|BIT29|BIT28, OFDM_SingleCarrier);
  642. //for dynamic set Power index.
  643. write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000500);
  644. write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000500);
  645. }
  646. else// Stop Single Carrier.
  647. {
  648. RT_TRACE(_module_mp_,_drv_alert_, ("SetSingleCarrierTx: test stop\n"));
  649. //Turn off all test modes.
  650. if (IS_HARDWARE_TYPE_JAGUAR(pAdapter))
  651. PHY_SetBBReg(pAdapter, rSingleTone_ContTx_Jaguar, BIT18|BIT17|BIT16, OFDM_ALL_OFF);
  652. else
  653. PHY_SetBBReg(pAdapter, rOFDM1_LSTF, BIT30|BIT29|BIT28, OFDM_ALL_OFF);
  654. //Delay 10 ms //delay_ms(10);
  655. rtw_msleep_os(10);
  656. //BB Reset
  657. write_bbreg(pAdapter, rPMAC_Reset, bBBResetB, 0x0);
  658. write_bbreg(pAdapter, rPMAC_Reset, bBBResetB, 0x1);
  659. //Stop for dynamic set Power index.
  660. write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000100);
  661. write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000100);
  662. }
  663. }
  664. void Hal_SetSingleToneTx(PADAPTER pAdapter, u8 bStart)
  665. {
  666. HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
  667. PMPT_CONTEXT pMptCtx = &pAdapter->mppriv.MptCtx;
  668. BOOLEAN is92C = IS_92C_SERIAL(pHalData->VersionID);
  669. u8 rfPath;
  670. u32 reg58 = 0x0;
  671. static u4Byte regRF0x0 = 0x0;
  672. static u4Byte reg0xCB0 = 0x0;
  673. static u4Byte reg0xEB0 = 0x0;
  674. static u4Byte reg0xCB4 = 0x0;
  675. static u4Byte reg0xEB4 = 0x0;
  676. switch (pAdapter->mppriv.antenna_tx)
  677. {
  678. case ANTENNA_A:
  679. default:
  680. rfPath = RF_PATH_A;
  681. break;
  682. case ANTENNA_B:
  683. rfPath = RF_PATH_B;
  684. break;
  685. case ANTENNA_C:
  686. rfPath = RF_PATH_C;
  687. break;
  688. }
  689. pAdapter->mppriv.MptCtx.bSingleTone = bStart;
  690. if (bStart)// Start Single Tone.
  691. {
  692. if (IS_HARDWARE_TYPE_JAGUAR(pAdapter))
  693. {
  694. u1Byte p = ODM_RF_PATH_A;
  695. regRF0x0 = PHY_QueryRFReg(pAdapter, ODM_RF_PATH_A, RF_AC_Jaguar, bRFRegOffsetMask);
  696. reg0xCB0 = PHY_QueryBBReg(pAdapter, rA_RFE_Pinmux_Jaguar, bMaskDWord);
  697. reg0xEB0 = PHY_QueryBBReg(pAdapter, rB_RFE_Pinmux_Jaguar, bMaskDWord);
  698. reg0xCB4 = PHY_QueryBBReg(pAdapter, rA_RFE_Pinmux_Jaguar+4, bMaskDWord);
  699. reg0xEB4 = PHY_QueryBBReg(pAdapter, rB_RFE_Pinmux_Jaguar+4, bMaskDWord);
  700. PHY_SetBBReg(pAdapter, rOFDMCCKEN_Jaguar, BIT29|BIT28, 0x0); // Disable CCK and OFDM
  701. if (pMptCtx->MptRfPath == RF_PATH_AB) {
  702. for (p = ODM_RF_PATH_A; p <= ODM_RF_PATH_B; ++p) {
  703. PHY_SetRFReg(pAdapter, p, RF_AC_Jaguar, 0xF0000, 0x2); // Tx mode: RF0x00[19:16]=4'b0010
  704. PHY_SetRFReg(pAdapter, p, RF_AC_Jaguar, 0x1F, 0x0); // Lowest RF gain index: RF_0x0[4:0] = 0
  705. PHY_SetRFReg(pAdapter, p, LNA_Low_Gain_3, BIT1, 0x1); // RF LO enabled
  706. }
  707. } else {
  708. PHY_SetRFReg(pAdapter, pMptCtx->MptRfPath, RF_AC_Jaguar, 0xF0000, 0x2); // Tx mode: RF0x00[19:16]=4'b0010
  709. PHY_SetRFReg(pAdapter, pMptCtx->MptRfPath, RF_AC_Jaguar, 0x1F, 0x0); // Lowest RF gain index: RF_0x0[4:0] = 0
  710. PHY_SetRFReg(pAdapter, pMptCtx->MptRfPath, LNA_Low_Gain_3, BIT1, 0x1); // RF LO enabled
  711. }
  712. PHY_SetBBReg(pAdapter, rA_RFE_Pinmux_Jaguar, 0xFF00F0, 0x77007); // 0xCB0[[23:16, 7:4] = 0x77007
  713. PHY_SetBBReg(pAdapter, rB_RFE_Pinmux_Jaguar, 0xFF00F0, 0x77007); // 0xCB0[[23:16, 7:4] = 0x77007
  714. if (pHalData->ExternalPA_5G) {
  715. PHY_SetBBReg(pAdapter, rA_RFE_Pinmux_Jaguar+4, 0xFF00000, 0x12); // 0xCB4[23:16] = 0x12
  716. PHY_SetBBReg(pAdapter, rB_RFE_Pinmux_Jaguar+4, 0xFF00000, 0x12); // 0xEB4[23:16] = 0x12
  717. } else if (pHalData->ExternalPA_2G) {
  718. PHY_SetBBReg(pAdapter, rA_RFE_Pinmux_Jaguar+4, 0xFF00000, 0x11); // 0xCB4[23:16] = 0x11
  719. PHY_SetBBReg(pAdapter, rB_RFE_Pinmux_Jaguar+4, 0xFF00000, 0x11); // 0xEB4[23:16] = 0x11
  720. }
  721. }
  722. else
  723. {
  724. // Turn On SingleTone and turn off the other test modes.
  725. PHY_SetBBReg(pAdapter, rOFDM1_LSTF, BIT30|BIT29|BIT28, OFDM_SingleTone);
  726. }
  727. //for dynamic set Power index.
  728. write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000500);
  729. write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000500);
  730. }
  731. else// Stop Single Tone.
  732. {
  733. RT_TRACE(_module_mp_,_drv_alert_, ("SetSingleToneTx: test stop\n"));
  734. { // <20120326, Kordan> To amplify the power of tone for Xtal calibration. (asked by Edlu)
  735. // <20120326, Kordan> Only in single tone mode. (asked by Edlu)
  736. if (IS_HARDWARE_TYPE_8188E(pAdapter))
  737. {
  738. reg58 = PHY_QueryRFReg(pAdapter, RF_PATH_A, LNA_Low_Gain_3, bRFRegOffsetMask);
  739. reg58 &= 0xFFFFFFF0;
  740. PHY_SetRFReg(pAdapter, RF_PATH_A, LNA_Low_Gain_3, bRFRegOffsetMask, reg58);
  741. }
  742. write_bbreg(pAdapter, rFPGA0_RFMOD, bCCKEn, 0x1);
  743. write_bbreg(pAdapter, rFPGA0_RFMOD, bOFDMEn, 0x1);
  744. }
  745. if (is92C) {
  746. _write_rfreg(pAdapter, RF_PATH_A, 0x21, BIT19, 0x00);
  747. rtw_usleep_os(100);
  748. write_rfreg(pAdapter, RF_PATH_A, 0x00, 0x32d75); // PAD all on.
  749. write_rfreg(pAdapter, RF_PATH_B, 0x00, 0x32d75); // PAD all on.
  750. rtw_usleep_os(100);
  751. } else {
  752. write_rfreg(pAdapter, rfPath, 0x21, 0x54000);
  753. rtw_usleep_os(100);
  754. write_rfreg(pAdapter, rfPath, 0x00, 0x30000); // PAD all on.
  755. rtw_usleep_os(100);
  756. }
  757. //Stop for dynamic set Power index.
  758. write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000100);
  759. write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000100);
  760. }
  761. }
  762. void Hal_SetCarrierSuppressionTx(PADAPTER pAdapter, u8 bStart)
  763. {
  764. pAdapter->mppriv.MptCtx.bCarrierSuppression = bStart;
  765. if (bStart) // Start Carrier Suppression.
  766. {
  767. RT_TRACE(_module_mp_,_drv_alert_, ("SetCarrierSuppressionTx: test start\n"));
  768. //if(pMgntInfo->dot11CurrentWirelessMode == WIRELESS_MODE_B)
  769. if (pAdapter->mppriv.rateidx <= MPT_RATE_11M)
  770. {
  771. // 1. if CCK block on?
  772. if(!read_bbreg(pAdapter, rFPGA0_RFMOD, bCCKEn))
  773. write_bbreg(pAdapter, rFPGA0_RFMOD, bCCKEn, bEnable);//set CCK block on
  774. //Turn Off All Test Mode
  775. if (IS_HARDWARE_TYPE_JAGUAR(pAdapter))
  776. PHY_SetBBReg(pAdapter, rSingleTone_ContTx_Jaguar, BIT18|BIT17|BIT16, OFDM_ALL_OFF);
  777. else
  778. PHY_SetBBReg(pAdapter, rOFDM1_LSTF, BIT30|BIT29|BIT28, OFDM_ALL_OFF);
  779. PHY_SetBBReg(pAdapter, rCCK0_System, bCCKBBMode, 0x2); //transmit mode
  780. PHY_SetBBReg(pAdapter, rCCK0_System, bCCKScramble, 0x0); //turn off scramble setting
  781. //Set CCK Tx Test Rate
  782. //PHY_SetBBReg(pAdapter, rCCK0_System, bCCKTxRate, pMgntInfo->ForcedDataRate);
  783. PHY_SetBBReg(pAdapter, rCCK0_System, bCCKTxRate, 0x0); //Set FTxRate to 1Mbps
  784. }
  785. //for dynamic set Power index.
  786. write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000500);
  787. write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000500);
  788. }
  789. else// Stop Carrier Suppression.
  790. {
  791. RT_TRACE(_module_mp_,_drv_alert_, ("SetCarrierSuppressionTx: test stop\n"));
  792. //if(pMgntInfo->dot11CurrentWirelessMode == WIRELESS_MODE_B)
  793. if (pAdapter->mppriv.rateidx <= MPT_RATE_11M ) {
  794. PHY_SetBBReg(pAdapter, rCCK0_System, bCCKBBMode, 0x0); //normal mode
  795. PHY_SetBBReg(pAdapter, rCCK0_System, bCCKScramble, 0x1); //turn on scramble setting
  796. //BB Reset
  797. PHY_SetBBReg(pAdapter, rPMAC_Reset, bBBResetB, 0x0);
  798. PHY_SetBBReg(pAdapter, rPMAC_Reset, bBBResetB, 0x1);
  799. }
  800. //Stop for dynamic set Power index.
  801. write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000100);
  802. write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000100);
  803. }
  804. //DbgPrint("\n MPT_ProSetCarrierSupp() is finished. \n");
  805. }
  806. void Hal_SetCCKContinuousTx(PADAPTER pAdapter, u8 bStart)
  807. {
  808. u32 cckrate;
  809. if (bStart)
  810. {
  811. RT_TRACE(_module_mp_, _drv_alert_,
  812. ("SetCCKContinuousTx: test start\n"));
  813. // 1. if CCK block on?
  814. if(!read_bbreg(pAdapter, rFPGA0_RFMOD, bCCKEn))
  815. write_bbreg(pAdapter, rFPGA0_RFMOD, bCCKEn, bEnable);//set CCK block on
  816. //Turn Off All Test Mode
  817. if (IS_HARDWARE_TYPE_JAGUAR(pAdapter))
  818. PHY_SetBBReg(pAdapter, rSingleTone_ContTx_Jaguar, BIT18|BIT17|BIT16, OFDM_ALL_OFF);
  819. else
  820. PHY_SetBBReg(pAdapter, rOFDM1_LSTF, BIT30|BIT29|BIT28, OFDM_ALL_OFF);
  821. //Set CCK Tx Test Rate
  822. #if 0
  823. switch(pAdapter->mppriv.rateidx)
  824. {
  825. case 2:
  826. cckrate = 0;
  827. break;
  828. case 4:
  829. cckrate = 1;
  830. break;
  831. case 11:
  832. cckrate = 2;
  833. break;
  834. case 22:
  835. cckrate = 3;
  836. break;
  837. default:
  838. cckrate = 0;
  839. break;
  840. }
  841. #else
  842. cckrate = pAdapter->mppriv.rateidx;
  843. #endif
  844. PHY_SetBBReg(pAdapter, rCCK0_System, bCCKTxRate, cckrate);
  845. PHY_SetBBReg(pAdapter, rCCK0_System, bCCKBBMode, 0x2); //transmit mode
  846. PHY_SetBBReg(pAdapter, rCCK0_System, bCCKScramble, 0x1); //turn on scramble setting
  847. PHY_SetBBReg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000500);
  848. PHY_SetBBReg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000500);
  849. pAdapter->mppriv.MptCtx.bCckContTx = TRUE;
  850. pAdapter->mppriv.MptCtx.bOfdmContTx = FALSE;
  851. }
  852. else {
  853. RT_TRACE(_module_mp_, _drv_info_,
  854. ("SetCCKContinuousTx: test stop\n"));
  855. pAdapter->mppriv.MptCtx.bCckContTx = FALSE;
  856. pAdapter->mppriv.MptCtx.bOfdmContTx = FALSE;
  857. PHY_SetBBReg(pAdapter, rCCK0_System, bCCKBBMode, 0x0); //normal mode
  858. PHY_SetBBReg(pAdapter, rCCK0_System, bCCKScramble, 0x1); //turn on scramble setting
  859. //BB Reset
  860. PHY_SetBBReg(pAdapter, rPMAC_Reset, bBBResetB, 0x0);
  861. PHY_SetBBReg(pAdapter, rPMAC_Reset, bBBResetB, 0x1);
  862. PHY_SetBBReg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000100);
  863. PHY_SetBBReg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000100);
  864. }
  865. }/* mpt_StartCckContTx */
  866. void Hal_SetOFDMContinuousTx(PADAPTER pAdapter, u8 bStart)
  867. {
  868. HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
  869. if (bStart) {
  870. RT_TRACE(_module_mp_, _drv_info_, ("SetOFDMContinuousTx: test start\n"));
  871. // 1. if OFDM block on?
  872. if(!read_bbreg(pAdapter, rFPGA0_RFMOD, bOFDMEn))
  873. write_bbreg(pAdapter, rFPGA0_RFMOD, bOFDMEn, bEnable);//set OFDM block on
  874. // 2. set CCK test mode off, set to CCK normal mode
  875. write_bbreg(pAdapter, rCCK0_System, bCCKBBMode, bDisable);
  876. // 3. turn on scramble setting
  877. write_bbreg(pAdapter, rCCK0_System, bCCKScramble, bEnable);
  878. // 4. Turn On Continue Tx and turn off the other test modes.
  879. if (IS_HARDWARE_TYPE_JAGUAR(pAdapter))
  880. PHY_SetBBReg(pAdapter, rSingleTone_ContTx_Jaguar, BIT18|BIT17|BIT16, OFDM_ContinuousTx);
  881. else
  882. PHY_SetBBReg(pAdapter, rOFDM1_LSTF, BIT30|BIT29|BIT28, OFDM_ContinuousTx);
  883. //for dynamic set Power index.
  884. write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000500);
  885. write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000500);
  886. } else {
  887. RT_TRACE(_module_mp_,_drv_info_, ("SetOFDMContinuousTx: test stop\n"));
  888. if (IS_HARDWARE_TYPE_JAGUAR(pAdapter))
  889. PHY_SetBBReg(pAdapter, rSingleTone_ContTx_Jaguar, BIT18|BIT17|BIT16, OFDM_ALL_OFF);
  890. else
  891. PHY_SetBBReg(pAdapter, rOFDM1_LSTF, BIT30|BIT29|BIT28, OFDM_ALL_OFF);
  892. rtw_msleep_os(10);
  893. //BB Reset
  894. write_bbreg(pAdapter, rPMAC_Reset, bBBResetB, 0x0);
  895. write_bbreg(pAdapter, rPMAC_Reset, bBBResetB, 0x1);
  896. //Stop for dynamic set Power index.
  897. write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000100);
  898. write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000100);
  899. }
  900. pAdapter->mppriv.MptCtx.bCckContTx = _FALSE;
  901. pAdapter->mppriv.MptCtx.bOfdmContTx = bStart;
  902. }/* mpt_StartOfdmContTx */
  903. void Hal_SetContinuousTx(PADAPTER pAdapter, u8 bStart)
  904. {
  905. #if 0
  906. // ADC turn off [bit24-21] adc port0 ~ port1
  907. if (bStart) {
  908. write_bbreg(pAdapter, rRx_Wait_CCCA, read_bbreg(pAdapter, rRx_Wait_CCCA) & 0xFE1FFFFF);
  909. rtw_usleep_os(100);
  910. }
  911. #endif
  912. RT_TRACE(_module_mp_, _drv_info_,
  913. ("SetContinuousTx: rate:%d\n", pAdapter->mppriv.rateidx));
  914. pAdapter->mppriv.MptCtx.bStartContTx = bStart;
  915. if (pAdapter->mppriv.rateidx <= MPT_RATE_11M)
  916. {
  917. Hal_SetCCKContinuousTx(pAdapter, bStart);
  918. }
  919. else if ((pAdapter->mppriv.rateidx >= MPT_RATE_6M) &&
  920. (pAdapter->mppriv.rateidx <= MPT_RATE_MCS15))
  921. {
  922. Hal_SetOFDMContinuousTx(pAdapter, bStart);
  923. }
  924. #if 0
  925. // ADC turn on [bit24-21] adc port0 ~ port1
  926. if (!bStart) {
  927. write_bbreg(pAdapter, rRx_Wait_CCCA, read_bbreg(pAdapter, rRx_Wait_CCCA) | 0x01E00000);
  928. }
  929. #endif
  930. }
  931. #endif // CONFIG_MP_INCLUDE