RT-AC56 3.0.0.4.374.37 core
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / drivers / staging / rtl8192su / r8192S_rtl8225.c
blob7a0318bb24bb9f283e3cd6e021ae421efadd73e9
2 #include "r8192U.h"
3 #include "r8192S_hw.h"
4 #include "r8192S_phyreg.h"
5 #include "r8192S_phy.h"
6 #include "r8192S_rtl8225.h"
8 /*---------------------Define local function prototype-----------------------*/
9 void phy_RF8225_Config_HardCode(struct net_device* dev );
10 bool phy_RF8225_Config_ParaFile(struct net_device* dev );
11 /*---------------------Define local function prototype-----------------------*/
12 void PHY_SetRF8225OfdmTxPower(struct net_device* dev ,u8 powerlevel)
19 void PHY_SetRF8225CckTxPower( struct net_device* dev , u8 powerlevel)
25 // TODO: The following RF 022D related function should be removed to HalPhy0222D.c.
26 void PHY_SetRF0222DOfdmTxPower(struct net_device* dev ,u8 powerlevel)
28 //TODO: We should set RF TxPower for RF 0222D here!!
33 void PHY_SetRF0222DCckTxPower(struct net_device* dev ,u8 powerlevel)
35 //TODO: We should set RF TxPower for RF 0222D here!!
39 /*-----------------------------------------------------------------------------
40 * Function: PHY_SetRF0222DBandwidth()
42 * Overview: This function is called by SetBWModeCallback8190Pci() only
44 * Input: PADAPTER Adapter
45 * WIRELESS_BANDWIDTH_E Bandwidth //20M or 40M
47 * Output: NONE
49 * Return: NONE
51 * Note: For RF type 0222D
52 *---------------------------------------------------------------------------*/
53 //just in phy
54 void PHY_SetRF0222DBandwidth(struct net_device* dev , HT_CHANNEL_WIDTH Bandwidth) //20M or 40M
56 u8 eRFPath;
57 struct r8192_priv *priv = ieee80211_priv(dev);
60 //if (IS_HARDWARE_TYPE_8192S(dev))
61 if (1)
63 #ifndef RTL92SE_FPGA_VERIFY
64 switch(Bandwidth)
66 case HT_CHANNEL_WIDTH_20:
67 #ifdef FIB_MODIFICATION
68 write_nic_byte(dev, rFPGA0_AnalogParameter2, 0x58);
69 #endif
70 rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)RF90_PATH_A, RF_CHNLBW, BIT10|BIT11, 0x01);
71 break;
72 case HT_CHANNEL_WIDTH_20_40:
73 #ifdef FIB_MODIFICATION
74 write_nic_byte(dev, rFPGA0_AnalogParameter2, 0x18);
75 #endif
76 rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)RF90_PATH_A, RF_CHNLBW, BIT10|BIT11, 0x00);
77 break;
78 default:
79 ;//RT_TRACE(COMP_DBG, DBG_LOUD, ("PHY_SetRF8225Bandwidth(): unknown Bandwidth: %#X\n",Bandwidth ));
80 break;
82 #endif
84 else
86 for(eRFPath = 0; eRFPath <priv->NumTotalRFPath; eRFPath++)
88 switch(Bandwidth)
90 case HT_CHANNEL_WIDTH_20:
91 //rtl8192_phy_SetRFReg(Adapter, (RF90_RADIO_PATH_E)RF90_PATH_A, RF_CHNLBW, (BIT10|BIT11), 0x01);
92 break;
93 case HT_CHANNEL_WIDTH_20_40:
94 //rtl8192_phy_SetRFReg(Adapter, (RF90_RADIO_PATH_E)RF90_PATH_A, RF_CHNLBW, (BIT10|BIT11), 0x00);
95 break;
96 default:
97 ;//RT_TRACE(COMP_DBG, DBG_LOUD, ("PHY_SetRF8225Bandwidth(): unknown Bandwidth: %#X\n",Bandwidth ));
98 break;
106 // TODO: Aabove RF 022D related function should be removed to HalPhy0222D.c.
108 /*-----------------------------------------------------------------------------
109 * Function: PHY_SetRF8225Bandwidth()
111 * Overview: This function is called by SetBWModeCallback8190Pci() only
113 * Input: PADAPTER Adapter
114 * WIRELESS_BANDWIDTH_E Bandwidth //20M or 40M
116 * Output: NONE
118 * Return: NONE
120 * Note: 8225(zebra1) support 20M only
121 *---------------------------------------------------------------------------*/
122 //just in phy
123 void PHY_SetRF8225Bandwidth(struct net_device* dev ,HT_CHANNEL_WIDTH Bandwidth) //20M or 40M
125 u8 eRFPath;
126 struct r8192_priv *priv = ieee80211_priv(dev);
128 //for(eRFPath = RF90_PATH_A; eRFPath <pHalData->NumTotalRFPath; eRFPath++)
129 for(eRFPath = 0; eRFPath <priv->NumTotalRFPath; eRFPath++)
131 switch(Bandwidth)
133 case HT_CHANNEL_WIDTH_20:
134 // TODO: Update the parameters here
135 break;
136 case HT_CHANNEL_WIDTH_20_40:
137 RT_TRACE(COMP_DBG, "SetChannelBandwidth8190Pci():8225 does not support 40M mode\n");
138 break;
139 default:
140 RT_TRACE(COMP_DBG, "PHY_SetRF8225Bandwidth(): unknown Bandwidth: %#X\n",Bandwidth );
141 break;
148 //just in phy
149 bool PHY_RF8225_Config(struct net_device* dev )
151 struct r8192_priv *priv = ieee80211_priv(dev);
152 bool rtStatus = true;
153 //RF90_RADIO_PATH_E eRFPath;
154 //BB_REGISTER_DEFINITION_T *pPhyReg;
155 //u32 OrgStoreRFIntSW[RF90_PATH_D+1];
158 // Initialize general global value
160 // TODO: Extend RF_PATH_C and RF_PATH_D in the future
161 priv->NumTotalRFPath = 2;
164 // Config BB and RF
166 //switch( Adapter->MgntInfo.bRegHwParaFile )
168 // case 0:
169 // phy_RF8225_Config_HardCode(dev);
170 // break;
172 // case 1:
173 // rtStatus = phy_RF8225_Config_ParaFile(dev);
174 // break;
176 // case 2:
177 // Partial Modify.
178 phy_RF8225_Config_HardCode(dev);
179 phy_RF8225_Config_ParaFile(dev);
180 // break;
182 // default:
183 // phy_RF8225_Config_HardCode(dev);
184 // break;
186 return rtStatus;
190 //just in 8225
191 void phy_RF8225_Config_HardCode(struct net_device* dev)
194 // Set Default Bandwidth to 20M
195 //Adapter->HalFunc .SetBWModeHandler(Adapter, HT_CHANNEL_WIDTH_20);
197 // TODO: Set Default Channel to channel one for RTL8225
201 //just in 8225
202 bool phy_RF8225_Config_ParaFile(struct net_device* dev)
204 u32 u4RegValue = 0;
205 //static char szRadioAFile[] = RTL819X_PHY_RADIO_A;
206 //static char szRadioBFile[] = RTL819X_PHY_RADIO_B;
207 u8 eRFPath;
208 bool rtStatus = true;
209 struct r8192_priv *priv = ieee80211_priv(dev);
210 BB_REGISTER_DEFINITION_T *pPhyReg;
211 //u8 eCheckItem;
213 //3//-----------------------------------------------------------------
214 //3// <2> Initialize RF
215 //3//-----------------------------------------------------------------
216 //for(eRFPath = RF90_PATH_A; eRFPath <pHalData->NumTotalRFPath; eRFPath++)
217 for(eRFPath = 0; eRFPath <priv->NumTotalRFPath; eRFPath++)
220 pPhyReg = &priv->PHYRegDef[eRFPath];
222 /*----Store original RFENV control type----*/
223 switch(eRFPath)
225 case RF90_PATH_A:
226 case RF90_PATH_C:
227 u4RegValue = rtl8192_QueryBBReg(dev, pPhyReg->rfintfs, bRFSI_RFENV);
228 break;
229 case RF90_PATH_B :
230 case RF90_PATH_D:
231 u4RegValue = rtl8192_QueryBBReg(dev, pPhyReg->rfintfs, bRFSI_RFENV<<16);
232 break;
235 /*----Set RF_ENV enable----*/
236 rtl8192_setBBreg(dev, pPhyReg->rfintfe, bRFSI_RFENV<<16, 0x1);
238 /*----Set RF_ENV output high----*/
239 rtl8192_setBBreg(dev, pPhyReg->rfintfo, bRFSI_RFENV, 0x1);
241 /* Set bit number of Address and Data for RF register */
242 rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, b3WireAddressLength, 0x0); // Set 1 to 4 bits for 8255
243 rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, b3WireDataLength, 0x0); // Set 0 to 12 bits for 8255
246 /*----Initialize RF fom connfiguration file----*/
247 switch(eRFPath)
249 case RF90_PATH_A:
250 //rtStatus = PHY_ConfigRFWithParaFile(dev, (char* )&szRadioAFile, (RF90_RADIO_PATH_E)eRFPath);
251 rtStatus = rtl8192_phy_ConfigRFWithHeaderFile(dev,(RF90_RADIO_PATH_E)eRFPath);
252 break;
253 case RF90_PATH_B:
254 //rtStatus = PHY_ConfigRFWithParaFile(dev, (char* )&szRadioBFile, (RF90_RADIO_PATH_E)eRFPath);
255 rtStatus = rtl8192_phy_ConfigRFWithHeaderFile(dev,(RF90_RADIO_PATH_E)eRFPath);
256 break;
257 case RF90_PATH_C:
258 break;
259 case RF90_PATH_D:
260 break;
263 /*----Restore RFENV control type----*/;
264 switch(eRFPath)
266 case RF90_PATH_A:
267 case RF90_PATH_C:
268 rtl8192_setBBreg(dev, pPhyReg->rfintfs, bRFSI_RFENV, u4RegValue);
269 break;
270 case RF90_PATH_B :
271 case RF90_PATH_D:
272 rtl8192_setBBreg(dev, pPhyReg->rfintfs, bRFSI_RFENV<<16, u4RegValue);
273 break;
276 if(rtStatus == false){
277 //RT_TRACE(COMP_FPGA, DBG_LOUD, ("phy_RF8225_Config_ParaFile():Radio[%d] Fail!!", eRFPath));
278 goto phy_RF8225_Config_ParaFile_Fail;
283 //RT_TRACE(COMP_INIT, DBG_LOUD, ("<---phy_RF8225_Config_ParaFile()\n"));
284 return rtStatus;
286 phy_RF8225_Config_ParaFile_Fail:
287 return rtStatus;