1 /******************************************************************************
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
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.
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
14 ******************************************************************************/
15 /******************************************************************************
18 * Module: rtl8192c_rf6052.c (Source C File)
20 * Note: Provide RF 6052 series relative API.
31 * 09/25/2008 MHC Create initial version.
32 * 11/05/2008 MHC Add API for tw power setting.
35 ******************************************************************************/
37 #include <rtl8723b_hal.h>
39 /*---------------------------Define Local Constant---------------------------*/
40 /*---------------------------Define Local Constant---------------------------*/
43 /*------------------------Define global variable-----------------------------*/
44 /*------------------------Define global variable-----------------------------*/
47 /*------------------------Define local variable------------------------------*/
48 /* 2008/11/20 MH For Debug only, RF */
49 /*------------------------Define local variable------------------------------*/
51 /*-----------------------------------------------------------------------------
52 * Function: PHY_RF6052SetBandwidth()
54 * Overview: This function is called by SetBWModeCallback8190Pci() only
56 * Input: struct adapter * Adapter
57 * WIRELESS_BANDWIDTH_E Bandwidth 20M or 40M
63 * Note: For RF type 0222D
64 *---------------------------------------------------------------------------*/
65 void PHY_RF6052SetBandwidth8723B(
66 struct adapter *Adapter, enum CHANNEL_WIDTH Bandwidth
69 struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
72 case CHANNEL_WIDTH_20:
73 pHalData->RfRegChnlVal[0] = ((pHalData->RfRegChnlVal[0] & 0xfffff3ff) | BIT10 | BIT11);
74 PHY_SetRFReg(Adapter, ODM_RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal[0]);
75 PHY_SetRFReg(Adapter, ODM_RF_PATH_B, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal[0]);
78 case CHANNEL_WIDTH_40:
79 pHalData->RfRegChnlVal[0] = ((pHalData->RfRegChnlVal[0] & 0xfffff3ff) | BIT10);
80 PHY_SetRFReg(Adapter, ODM_RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal[0]);
81 PHY_SetRFReg(Adapter, ODM_RF_PATH_B, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal[0]);
85 /* RT_TRACE(COMP_DBG, DBG_LOUD, ("PHY_SetRF8225Bandwidth(): unknown Bandwidth: %#X\n", Bandwidth)); */
91 static int phy_RF6052_Config_ParaFile(struct adapter *Adapter)
95 struct bb_register_def *pPhyReg;
97 int rtStatus = _SUCCESS;
98 struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
100 static char sz8723RadioAFile[] = RTL8723B_PHY_RADIO_A;
101 static char sz8723RadioBFile[] = RTL8723B_PHY_RADIO_B;
102 static s8 sz8723BTxPwrTrackFile[] = RTL8723B_TXPWR_TRACK;
103 char *pszRadioAFile, *pszRadioBFile, *pszTxPwrTrackFile;
105 pszRadioAFile = sz8723RadioAFile;
106 pszRadioBFile = sz8723RadioBFile;
107 pszTxPwrTrackFile = sz8723BTxPwrTrackFile;
109 /* 3----------------------------------------------------------------- */
110 /* 3 <2> Initialize RF */
111 /* 3----------------------------------------------------------------- */
112 /* for (eRFPath = RF_PATH_A; eRFPath <pHalData->NumTotalRFPath; eRFPath++) */
113 for (eRFPath = 0; eRFPath < pHalData->NumTotalRFPath; eRFPath++) {
115 pPhyReg = &pHalData->PHYRegDef[eRFPath];
117 /*----Store original RFENV control type----*/
121 u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV);
125 u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV<<16);
129 /*----Set RF_ENV enable----*/
130 PHY_SetBBReg(Adapter, pPhyReg->rfintfe, bRFSI_RFENV<<16, 0x1);
131 udelay(1);/* PlatformStallExecution(1); */
133 /*----Set RF_ENV output high----*/
134 PHY_SetBBReg(Adapter, pPhyReg->rfintfo, bRFSI_RFENV, 0x1);
135 udelay(1);/* PlatformStallExecution(1); */
137 /* Set bit number of Address and Data for RF register */
138 PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, b3WireAddressLength, 0x0); /* Set 1 to 4 bits for 8255 */
139 udelay(1);/* PlatformStallExecution(1); */
141 PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, b3WireDataLength, 0x0); /* Set 0 to 12 bits for 8255 */
142 udelay(1);/* PlatformStallExecution(1); */
144 /*----Initialize RF fom connfiguration file----*/
147 if (PHY_ConfigRFWithParaFile(Adapter, pszRadioAFile,
149 if (HAL_STATUS_FAILURE == ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv, CONFIG_RF_RADIO, (ODM_RF_RADIO_PATH_E)eRFPath))
154 if (PHY_ConfigRFWithParaFile(Adapter, pszRadioBFile,
156 if (HAL_STATUS_FAILURE == ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv, CONFIG_RF_RADIO, (ODM_RF_RADIO_PATH_E)eRFPath))
166 /*----Restore RFENV control type----*/;
170 PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV, u4RegValue);
174 PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV<<16, u4RegValue);
178 if (rtStatus != _SUCCESS) {
179 /* RT_TRACE(COMP_FPGA, DBG_LOUD, ("phy_RF6052_Config_ParaFile():Radio[%d] Fail!!", eRFPath)); */
180 goto phy_RF6052_Config_ParaFile_Fail;
185 /* 3 ----------------------------------------------------------------- */
186 /* 3 Configuration of Tx Power Tracking */
187 /* 3 ----------------------------------------------------------------- */
189 if (PHY_ConfigRFWithTxPwrTrackParaFile(Adapter, pszTxPwrTrackFile) ==
191 ODM_ConfigRFWithTxPwrTrackHeaderFile(&pHalData->odmpriv);
194 /* RT_TRACE(COMP_INIT, DBG_LOUD, ("<---phy_RF6052_Config_ParaFile()\n")); */
197 phy_RF6052_Config_ParaFile_Fail:
202 int PHY_RF6052_Config8723B(struct adapter *Adapter)
204 struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
205 int rtStatus = _SUCCESS;
208 /* Initialize general global value */
210 /* TODO: Extend RF_PATH_C and RF_PATH_D in the future */
211 if (pHalData->rf_type == RF_1T1R)
212 pHalData->NumTotalRFPath = 1;
214 pHalData->NumTotalRFPath = 2;
217 /* Config BB and RF */
219 rtStatus = phy_RF6052_Config_ParaFile(Adapter);
224 /* End of HalRf6052.c */