1 /******************************************************************************
\r
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
\r
5 * This program is free software; you can redistribute it and/or modify it
\r
6 * under the terms of version 2 of the GNU General Public License as
\r
7 * published by the Free Software Foundation.
\r
9 * This program is distributed in the hope that it will be useful, but WITHOUT
\r
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
\r
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
\r
14 * You should have received a copy of the GNU General Public License along with
\r
15 * this program; if not, write to the Free Software Foundation, Inc.,
\r
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
\r
19 ******************************************************************************/
\r
20 /******************************************************************************
\r
23 * Module: rtl8192c_rf6052.c ( Source C File)
\r
25 * Note: Provide RF 6052 series relative API.
\r
36 * 09/25/2008 MHC Create initial version.
\r
37 * 11/05/2008 MHC Add API for tw power setting.
\r
40 ******************************************************************************/
\r
42 #include <rtl8723b_hal.h>
\r
44 /*---------------------------Define Local Constant---------------------------*/
\r
45 /*---------------------------Define Local Constant---------------------------*/
\r
48 /*------------------------Define global variable-----------------------------*/
\r
49 /*------------------------Define global variable-----------------------------*/
\r
52 /*------------------------Define local variable------------------------------*/
\r
53 // 2008/11/20 MH For Debug only, RF
\r
54 //static RF_SHADOW_T RF_Shadow[RF6052_MAX_PATH][RF6052_MAX_REG] = {0};
\r
55 static RF_SHADOW_T RF_Shadow[RF6052_MAX_PATH][RF6052_MAX_REG];
\r
56 /*------------------------Define local variable------------------------------*/
\r
58 /*-----------------------------------------------------------------------------
\r
59 * Function: PHY_RF6052SetBandwidth()
\r
61 * Overview: This function is called by SetBWModeCallback8190Pci() only
\r
63 * Input: PADAPTER Adapter
\r
64 * WIRELESS_BANDWIDTH_E Bandwidth //20M or 40M
\r
70 * Note: For RF type 0222D
\r
71 *---------------------------------------------------------------------------*/
\r
73 PHY_RF6052SetBandwidth8723B(
\r
74 IN PADAPTER Adapter,
\r
75 IN CHANNEL_WIDTH Bandwidth) //20M or 40M
\r
77 HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
\r
81 case CHANNEL_WIDTH_20:
\r
82 pHalData->RfRegChnlVal[0] = ((pHalData->RfRegChnlVal[0] & 0xfffff3ff) | BIT10 | BIT11 );
\r
83 PHY_SetRFReg(Adapter, ODM_RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal[0]);
\r
84 PHY_SetRFReg(Adapter, ODM_RF_PATH_B, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal[0]);
\r
87 case CHANNEL_WIDTH_40:
\r
88 pHalData->RfRegChnlVal[0] = ((pHalData->RfRegChnlVal[0] & 0xfffff3ff) | BIT10 );
\r
89 PHY_SetRFReg(Adapter, ODM_RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal[0]);
\r
90 PHY_SetRFReg(Adapter, ODM_RF_PATH_B, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal[0]);
\r
94 //RT_TRACE(COMP_DBG, DBG_LOUD, ("PHY_SetRF8225Bandwidth(): unknown Bandwidth: %#X\n",Bandwidth ));
\r
101 phy_RF6052_Config_HardCode(
\r
102 IN PADAPTER Adapter
\r
106 // Set Default Bandwidth to 20M
\r
107 //Adapter->HalFunc .SetBWModeHandler(Adapter, CHANNEL_WIDTH_20);
\r
109 // TODO: Set Default Channel to channel one for RTL8225
\r
114 phy_RF6052_Config_ParaFile(
\r
115 IN PADAPTER Adapter
\r
120 BB_REGISTER_DEFINITION_T *pPhyReg;
\r
122 int rtStatus = _SUCCESS;
\r
123 HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
\r
125 static char sz8723RadioAFile[] = RTL8723B_PHY_RADIO_A;
\r
126 static char sz8723RadioBFile[] = RTL8723B_PHY_RADIO_B;
\r
127 static s1Byte sz8723BTxPwrTrackFile[] = RTL8723B_TXPWR_TRACK;
\r
128 char *pszRadioAFile, *pszRadioBFile, *pszTxPwrTrackFile;
\r
130 pszRadioAFile = sz8723RadioAFile;
\r
131 pszRadioBFile = sz8723RadioBFile;
\r
132 pszTxPwrTrackFile = sz8723BTxPwrTrackFile;
\r
134 //3//-----------------------------------------------------------------
\r
135 //3// <2> Initialize RF
\r
136 //3//-----------------------------------------------------------------
\r
137 //for(eRFPath = RF_PATH_A; eRFPath <pHalData->NumTotalRFPath; eRFPath++)
\r
138 for(eRFPath = 0; eRFPath <pHalData->NumTotalRFPath; eRFPath++)
\r
141 pPhyReg = &pHalData->PHYRegDef[eRFPath];
\r
143 /*----Store original RFENV control type----*/
\r
148 u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV);
\r
152 u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV<<16);
\r
156 /*----Set RF_ENV enable----*/
\r
157 PHY_SetBBReg(Adapter, pPhyReg->rfintfe, bRFSI_RFENV<<16, 0x1);
\r
158 rtw_udelay_os(1);//PlatformStallExecution(1);
\r
160 /*----Set RF_ENV output high----*/
\r
161 PHY_SetBBReg(Adapter, pPhyReg->rfintfo, bRFSI_RFENV, 0x1);
\r
162 rtw_udelay_os(1);//PlatformStallExecution(1);
\r
164 /* Set bit number of Address and Data for RF register */
\r
165 PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, b3WireAddressLength, 0x0); // Set 1 to 4 bits for 8255
\r
166 rtw_udelay_os(1);//PlatformStallExecution(1);
\r
168 PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, b3WireDataLength, 0x0); // Set 0 to 12 bits for 8255
\r
169 rtw_udelay_os(1);//PlatformStallExecution(1);
\r
171 /*----Initialize RF fom connfiguration file----*/
\r
175 #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE
\r
176 if (PHY_ConfigRFWithParaFile(Adapter, pszRadioAFile, eRFPath) == _FAIL)
\r
179 #ifdef CONFIG_EMBEDDED_FWIMG
\r
180 if(HAL_STATUS_FAILURE ==ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv,CONFIG_RF_RADIO, (ODM_RF_RADIO_PATH_E)eRFPath))
\r
186 #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE
\r
187 if (PHY_ConfigRFWithParaFile(Adapter, pszRadioBFile, eRFPath) == _FAIL)
\r
190 #ifdef CONFIG_EMBEDDED_FWIMG
\r
191 if(HAL_STATUS_FAILURE ==ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv,CONFIG_RF_RADIO, (ODM_RF_RADIO_PATH_E)eRFPath))
\r
202 /*----Restore RFENV control type----*/;
\r
207 PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV, u4RegValue);
\r
211 PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV<<16, u4RegValue);
\r
215 if(rtStatus != _SUCCESS){
\r
216 //RT_TRACE(COMP_FPGA, DBG_LOUD, ("phy_RF6052_Config_ParaFile():Radio[%d] Fail!!", eRFPath));
\r
217 goto phy_RF6052_Config_ParaFile_Fail;
\r
222 //3 -----------------------------------------------------------------
\r
223 //3 Configuration of Tx Power Tracking
\r
224 //3 -----------------------------------------------------------------
\r
226 #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE
\r
227 if (PHY_ConfigRFWithTxPwrTrackParaFile(Adapter, pszTxPwrTrackFile) == _FAIL)
\r
230 #ifdef CONFIG_EMBEDDED_FWIMG
\r
231 ODM_ConfigRFWithTxPwrTrackHeaderFile(&pHalData->odmpriv);
\r
235 //RT_TRACE(COMP_INIT, DBG_LOUD, ("<---phy_RF6052_Config_ParaFile()\n"));
\r
238 phy_RF6052_Config_ParaFile_Fail:
\r
244 PHY_RF6052_Config8723B(
\r
245 IN PADAPTER Adapter)
\r
247 HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
\r
248 int rtStatus = _SUCCESS;
\r
251 // Initialize general global value
\r
253 // TODO: Extend RF_PATH_C and RF_PATH_D in the future
\r
254 if(pHalData->rf_type == RF_1T1R)
\r
255 pHalData->NumTotalRFPath = 1;
\r
257 pHalData->NumTotalRFPath = 2;
\r
260 // Config BB and RF
\r
262 rtStatus = phy_RF6052_Config_ParaFile(Adapter);
\r
267 /* End of HalRf6052.c */
\r