• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0
2 /******************************************************************************
3  *
4  * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
5  *
6  ******************************************************************************/
7 /******************************************************************************
8  *
9  *
10  * Module:	rtl8192c_rf6052.c	(Source C File)
11  *
12  * Note:	Provide RF 6052 series relative API.
13  *
14  * Function:
15  *
16  * Export:
17  *
18  * Abbrev:
19  *
20  * History:
21  * Data			Who		Remark
22  *
23  * 09/25/2008	MHC		Create initial version.
24  * 11/05/2008	MHC		Add API for tw power setting.
25  *
26  *
27 ******************************************************************************/
28 
29 #include <rtl8723b_hal.h>
30 
31 /*---------------------------Define Local Constant---------------------------*/
32 /*---------------------------Define Local Constant---------------------------*/
33 
34 
35 /*------------------------Define global variable-----------------------------*/
36 /*------------------------Define global variable-----------------------------*/
37 
38 
39 /*------------------------Define local variable------------------------------*/
40 /*  2008/11/20 MH For Debug only, RF */
41 /*------------------------Define local variable------------------------------*/
42 
43 /*-----------------------------------------------------------------------------
44  * Function:    PHY_RF6052SetBandwidth()
45  *
46  * Overview:    This function is called by SetBWModeCallback8190Pci() only
47  *
48  * Input:       struct adapter *			Adapter
49  *		WIRELESS_BANDWIDTH_E	Bandwidth	20M or 40M
50  *
51  * Output:      NONE
52  *
53  * Return:      NONE
54  *
55  * Note:		For RF type 0222D
56  *---------------------------------------------------------------------------*/
PHY_RF6052SetBandwidth8723B(struct adapter * Adapter,enum channel_width Bandwidth)57 void PHY_RF6052SetBandwidth8723B(
58 	struct adapter *Adapter, enum channel_width Bandwidth
59 ) /* 20M or 40M */
60 {
61 	struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
62 
63 	switch (Bandwidth) {
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]);
68 		break;
69 
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]);
74 		break;
75 
76 	default:
77 		break;
78 	}
79 
80 }
81 
phy_RF6052_Config_ParaFile(struct adapter * Adapter)82 static int phy_RF6052_Config_ParaFile(struct adapter *Adapter)
83 {
84 	u32 u4RegValue = 0;
85 	u8 eRFPath;
86 	struct bb_register_def *pPhyReg;
87 	struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
88 
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++) {
94 
95 		pPhyReg = &pHalData->PHYRegDef[eRFPath];
96 
97 		/*----Store original RFENV control type----*/
98 		switch (eRFPath) {
99 		case RF_PATH_A:
100 			u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV);
101 			break;
102 		case RF_PATH_B:
103 			u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV << 16);
104 			break;
105 		}
106 
107 		/*----Set RF_ENV enable----*/
108 		PHY_SetBBReg(Adapter, pPhyReg->rfintfe, bRFSI_RFENV << 16, 0x1);
109 		udelay(1);/* PlatformStallExecution(1); */
110 
111 		/*----Set RF_ENV output high----*/
112 		PHY_SetBBReg(Adapter, pPhyReg->rfintfo, bRFSI_RFENV, 0x1);
113 		udelay(1);/* PlatformStallExecution(1); */
114 
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); */
118 
119 		PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, b3WireDataLength, 0x0);	/*  Set 0 to 12  bits for 8255 */
120 		udelay(1);/* PlatformStallExecution(1); */
121 
122 		/*----Initialize RF fom connfiguration file----*/
123 		switch (eRFPath) {
124 		case RF_PATH_A:
125 		case RF_PATH_B:
126 			ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv,
127 						   CONFIG_RF_RADIO, eRFPath);
128 			break;
129 		}
130 
131 		/*----Restore RFENV control type----*/
132 		switch (eRFPath) {
133 		case RF_PATH_A:
134 			PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV, u4RegValue);
135 			break;
136 		case RF_PATH_B:
137 			PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV << 16, u4RegValue);
138 			break;
139 		}
140 	}
141 
142 	/* 3 ----------------------------------------------------------------- */
143 	/* 3 Configuration of Tx Power Tracking */
144 	/* 3 ----------------------------------------------------------------- */
145 
146 	ODM_ConfigRFWithTxPwrTrackHeaderFile(&pHalData->odmpriv);
147 
148 	return _SUCCESS;
149 }
150 
151 
PHY_RF6052_Config8723B(struct adapter * Adapter)152 int PHY_RF6052_Config8723B(struct adapter *Adapter)
153 {
154 	struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
155 
156 	/*  */
157 	/*  Initialize general global value */
158 	/*  */
159 	pHalData->NumTotalRFPath = 1;
160 
161 	/*  */
162 	/*  Config BB and RF */
163 	/*  */
164 	return phy_RF6052_Config_ParaFile(Adapter);
165 
166 }
167 
168 /* End of HalRf6052.c */
169