1 // SPDX-License-Identifier: GPL-2.0
2 /******************************************************************************
4 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
6 ******************************************************************************/
7 /******************************************************************************
10 * Module: rtl8192c_rf6052.c (Source C File)
12 * Note: Provide RF 6052 series relative API.
23 * 09/25/2008 MHC Create initial version.
24 * 11/05/2008 MHC Add API for tw power setting.
27 ******************************************************************************/
29 #include <rtl8723b_hal.h>
31 /*---------------------------Define Local Constant---------------------------*/
32 /*---------------------------Define Local Constant---------------------------*/
35 /*------------------------Define global variable-----------------------------*/
36 /*------------------------Define global variable-----------------------------*/
39 /*------------------------Define local variable------------------------------*/
40 /* 2008/11/20 MH For Debug only, RF */
41 /*------------------------Define local variable------------------------------*/
43 /*-----------------------------------------------------------------------------
44 * Function: PHY_RF6052SetBandwidth()
46 * Overview: This function is called by SetBWModeCallback8190Pci() only
48 * Input: struct adapter * Adapter
49 * WIRELESS_BANDWIDTH_E Bandwidth 20M or 40M
55 * Note: For RF type 0222D
56 *---------------------------------------------------------------------------*/
57 void PHY_RF6052SetBandwidth8723B(
58 struct adapter *Adapter, enum channel_width Bandwidth
61 struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
64 case CHANNEL_WIDTH_20:
65 pHalData->RfRegChnlVal[0] = ((pHalData->RfRegChnlVal[0] & 0xfffff3ff) | BIT10 | BIT11);
66 PHY_SetRFReg(Adapter, RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal[0]);
67 PHY_SetRFReg(Adapter, RF_PATH_B, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal[0]);
70 case CHANNEL_WIDTH_40:
71 pHalData->RfRegChnlVal[0] = ((pHalData->RfRegChnlVal[0] & 0xfffff3ff) | BIT10);
72 PHY_SetRFReg(Adapter, RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal[0]);
73 PHY_SetRFReg(Adapter, RF_PATH_B, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal[0]);
82 static int phy_RF6052_Config_ParaFile(struct adapter *Adapter)
86 struct bb_register_def *pPhyReg;
87 struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
89 /* 3----------------------------------------------------------------- */
90 /* 3 <2> Initialize RF */
91 /* 3----------------------------------------------------------------- */
92 /* for (eRFPath = RF_PATH_A; eRFPath <pHalData->NumTotalRFPath; eRFPath++) */
93 for (eRFPath = 0; eRFPath < pHalData->NumTotalRFPath; eRFPath++) {
95 pPhyReg = &pHalData->PHYRegDef[eRFPath];
97 /*----Store original RFENV control type----*/
100 u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV);
103 u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV << 16);
107 /*----Set RF_ENV enable----*/
108 PHY_SetBBReg(Adapter, pPhyReg->rfintfe, bRFSI_RFENV << 16, 0x1);
109 udelay(1);/* PlatformStallExecution(1); */
111 /*----Set RF_ENV output high----*/
112 PHY_SetBBReg(Adapter, pPhyReg->rfintfo, bRFSI_RFENV, 0x1);
113 udelay(1);/* PlatformStallExecution(1); */
115 /* Set bit number of Address and Data for RF register */
116 PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, b3WireAddressLength, 0x0); /* Set 1 to 4 bits for 8255 */
117 udelay(1);/* PlatformStallExecution(1); */
119 PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, b3WireDataLength, 0x0); /* Set 0 to 12 bits for 8255 */
120 udelay(1);/* PlatformStallExecution(1); */
122 /*----Initialize RF fom connfiguration file----*/
126 ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv,
127 CONFIG_RF_RADIO, eRFPath);
131 /*----Restore RFENV control type----*/
134 PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV, u4RegValue);
137 PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV << 16, u4RegValue);
142 /* 3 ----------------------------------------------------------------- */
143 /* 3 Configuration of Tx Power Tracking */
144 /* 3 ----------------------------------------------------------------- */
146 ODM_ConfigRFWithTxPwrTrackHeaderFile(&pHalData->odmpriv);
152 int PHY_RF6052_Config8723B(struct adapter *Adapter)
154 struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
157 /* Initialize general global value */
159 pHalData->NumTotalRFPath = 1;
162 /* Config BB and RF */
164 return phy_RF6052_Config_ParaFile(Adapter);
168 /* End of HalRf6052.c */