2
This is part of the rtl8192 driver
3
released under the GPL (See file COPYING for details).
5
This files contains programming code for the rtl8256
8
*Many* thanks to Realtek Corp. for their great support!
13
#include "r8192U_hw.h"
14
#include "r819xU_phyreg.h"
15
#include "r819xU_phy.h"
16
#include "r8190_rtl8256.h"
18
/*--------------------------------------------------------------------------
19
* Overview: set RF band width (20M or 40M)
20
* Input: struct net_device* dev
21
* WIRELESS_BANDWIDTH_E Bandwidth //20M or 40M
24
* Note: 8226 support both 20M and 40 MHz
25
*---------------------------------------------------------------------------*/
26
void PHY_SetRF8256Bandwidth(struct net_device* dev , HT_CHANNEL_WIDTH Bandwidth) //20M or 40M
29
struct r8192_priv *priv = ieee80211_priv(dev);
31
//for(eRFPath = RF90_PATH_A; eRFPath <pHalData->NumTotalRFPath; eRFPath++)
32
for(eRFPath = 0; eRFPath <RF90_PATH_MAX; eRFPath++)
34
if (!rtl8192_phy_CheckIsLegalRFPath(dev, eRFPath))
39
case HT_CHANNEL_WIDTH_20:
40
if(priv->card_8192_version == VERSION_819xU_A || priv->card_8192_version == VERSION_819xU_B)// 8256 D-cut, E-cut, xiong: consider it later!
42
rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x0b, bMask12Bits, 0x100); //phy para:1ba
43
rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x2c, bMask12Bits, 0x3d7);
44
rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x0e, bMask12Bits, 0x021);
46
//cosa add for sd3's request 01/23/2008
47
rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x14, bMask12Bits, 0x5ab);
51
RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): unknown hardware version\n");
55
case HT_CHANNEL_WIDTH_20_40:
56
if(priv->card_8192_version == VERSION_819xU_A ||priv->card_8192_version == VERSION_819xU_B)// 8256 D-cut, E-cut, xiong: consider it later!
58
rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x0b, bMask12Bits, 0x300); //phy para:3ba
59
rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x2c, bMask12Bits, 0x3df);
60
rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x0e, bMask12Bits, 0x0a1);
62
//cosa add for sd3's request 01/23/2008
63
if(priv->chan == 3 || priv->chan == 9) //I need to set priv->chan whenever current channel changes
64
rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x14, bMask12Bits, 0x59b);
66
rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x14, bMask12Bits, 0x5ab);
70
RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): unknown hardware version\n");
76
RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): unknown Bandwidth: %#X\n",Bandwidth );
83
/*--------------------------------------------------------------------------
84
* Overview: Interface to config 8256
85
* Input: struct net_device* dev
88
*---------------------------------------------------------------------------*/
89
void PHY_RF8256_Config(struct net_device* dev)
91
struct r8192_priv *priv = ieee80211_priv(dev);
92
// Initialize general global value
94
// TODO: Extend RF_PATH_C and RF_PATH_D in the future
95
priv->NumTotalRFPath = RTL819X_TOTAL_RF_PATH;
97
phy_RF8256_Config_ParaFile(dev);
101
/*--------------------------------------------------------------------------
102
* Overview: Interface to config 8256
103
* Input: struct net_device* dev
106
*---------------------------------------------------------------------------*/
107
void phy_RF8256_Config_ParaFile(struct net_device* dev)
110
//static s1Byte szRadioAFile[] = RTL819X_PHY_RADIO_A;
111
//static s1Byte szRadioBFile[] = RTL819X_PHY_RADIO_B;
112
//static s1Byte szRadioCFile[] = RTL819X_PHY_RADIO_C;
113
//static s1Byte szRadioDFile[] = RTL819X_PHY_RADIO_D;
115
BB_REGISTER_DEFINITION_T *pPhyReg;
116
struct r8192_priv *priv = ieee80211_priv(dev);
117
u32 RegOffSetToBeCheck = 0x3;
118
u32 RegValueToBeCheck = 0x7f1;
119
u32 RF3_Final_Value = 0;
120
u8 ConstRetryTimes = 5, RetryTimes = 5;
122
//3//-----------------------------------------------------------------
123
//3// <2> Initialize RF
124
//3//-----------------------------------------------------------------
125
for(eRFPath = (RF90_RADIO_PATH_E)RF90_PATH_A; eRFPath <priv->NumTotalRFPath; eRFPath++)
127
if (!rtl8192_phy_CheckIsLegalRFPath(dev, eRFPath))
130
pPhyReg = &priv->PHYRegDef[eRFPath];
132
// Joseph test for shorten RF config
133
// pHalData->RfReg0Value[eRFPath] = rtl8192_phy_QueryRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, rGlobalCtrl, bMaskDWord);
135
/*----Store original RFENV control type----*/
140
u4RegValue = rtl8192_QueryBBReg(dev, pPhyReg->rfintfs, bRFSI_RFENV);
144
u4RegValue = rtl8192_QueryBBReg(dev, pPhyReg->rfintfs, bRFSI_RFENV<<16);
148
/*----Set RF_ENV enable----*/
149
rtl8192_setBBreg(dev, pPhyReg->rfintfe, bRFSI_RFENV<<16, 0x1);
151
/*----Set RF_ENV output high----*/
152
rtl8192_setBBreg(dev, pPhyReg->rfintfo, bRFSI_RFENV, 0x1);
154
/* Set bit number of Address and Data for RF register */
155
rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, b3WireAddressLength, 0x0); // Set 0 to 4 bits for Z-serial and set 1 to 6 bits for 8258
156
rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, b3WireDataLength, 0x0); // Set 0 to 12 bits for Z-serial and 8258, and set 1 to 14 bits for ???
158
rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E) eRFPath, 0x0, bMask12Bits, 0xbf);
160
/*----Check RF block (for FPGA platform only)----*/
161
// TODO: this function should be removed on ASIC , Emily 2007.2.2
162
if (rtl8192_phy_checkBBAndRF(dev, HW90_BLOCK_RF, (RF90_RADIO_PATH_E)eRFPath))
164
RT_TRACE(COMP_ERR, "PHY_RF8256_Config():Check Radio[%d] Fail!!\n", eRFPath);
165
goto phy_RF8256_Config_ParaFile_Fail;
168
RetryTimes = ConstRetryTimes;
170
/*----Initialize RF fom connfiguration file----*/
174
while(RF3_Final_Value!=RegValueToBeCheck && RetryTimes!=0)
176
ret = rtl8192_phy_ConfigRFWithHeaderFile(dev,(RF90_RADIO_PATH_E)eRFPath);
177
RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, RegOffSetToBeCheck, bMask12Bits);
178
RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value);
183
while(RF3_Final_Value!=RegValueToBeCheck && RetryTimes!=0)
185
ret = rtl8192_phy_ConfigRFWithHeaderFile(dev,(RF90_RADIO_PATH_E)eRFPath);
186
RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, RegOffSetToBeCheck, bMask12Bits);
187
RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value);
192
while(RF3_Final_Value!=RegValueToBeCheck && RetryTimes!=0)
194
ret = rtl8192_phy_ConfigRFWithHeaderFile(dev,(RF90_RADIO_PATH_E)eRFPath);
195
RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, RegOffSetToBeCheck, bMask12Bits);
196
RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value);
201
while(RF3_Final_Value!=RegValueToBeCheck && RetryTimes!=0)
203
ret = rtl8192_phy_ConfigRFWithHeaderFile(dev,(RF90_RADIO_PATH_E)eRFPath);
204
RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, RegOffSetToBeCheck, bMask12Bits);
205
RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value);
211
/*----Restore RFENV control type----*/;
216
rtl8192_setBBreg(dev, pPhyReg->rfintfs, bRFSI_RFENV, u4RegValue);
220
rtl8192_setBBreg(dev, pPhyReg->rfintfs, bRFSI_RFENV<<16, u4RegValue);
225
RT_TRACE(COMP_ERR, "phy_RF8256_Config_ParaFile():Radio[%d] Fail!!", eRFPath);
226
goto phy_RF8256_Config_ParaFile_Fail;
231
RT_TRACE(COMP_PHY, "PHY Initialization Success\n") ;
234
phy_RF8256_Config_ParaFile_Fail:
235
RT_TRACE(COMP_ERR, "PHY Initialization failed\n") ;
240
void PHY_SetRF8256CCKTxPower(struct net_device* dev, u8 powerlevel)
243
struct r8192_priv *priv = ieee80211_priv(dev);
244
//modified by vivi, 20080109
247
if(priv->bDynamicTxLowPower == TRUE ) //cosa 05/22/2008 for scan
249
if(priv->CustomerID == RT_CID_819x_Netcore)
252
TxAGC += priv->CckPwEnl;
257
rtl8192_setBBreg(dev, rTxAGC_CCK_Mcs32, bTxAGCRateCCK, TxAGC);
261
void PHY_SetRF8256OFDMTxPower(struct net_device* dev, u8 powerlevel)
263
struct r8192_priv *priv = ieee80211_priv(dev);
264
//Joseph TxPower for 8192 testing
265
u32 writeVal, powerBase0, powerBase1, writeVal_tmp;
267
u16 RegOffset[6] = {0xe00, 0xe04, 0xe10, 0xe14, 0xe18, 0xe1c};
268
u8 byte0, byte1, byte2, byte3;
270
powerBase0 = powerlevel + priv->TxPowerDiff; //OFDM rates
271
powerBase0 = (powerBase0<<24) | (powerBase0<<16) |(powerBase0<<8) |powerBase0;
272
powerBase1 = powerlevel; //MCS rates
273
powerBase1 = (powerBase1<<24) | (powerBase1<<16) |(powerBase1<<8) |powerBase1;
275
for(index=0; index<6; index++)
277
writeVal = priv->MCSTxPowerLevelOriginalOffset[index] + ((index<2)?powerBase0:powerBase1);
278
byte0 = (u8)(writeVal & 0x7f);
279
byte1 = (u8)((writeVal & 0x7f00)>>8);
280
byte2 = (u8)((writeVal & 0x7f0000)>>16);
281
byte3 = (u8)((writeVal & 0x7f000000)>>24);
282
if(byte0 > 0x24) // Max power index = 0x24
294
writeVal_tmp = (byte3<<24) | (byte2<<16) |(byte1<<8) |byte0;
295
priv->Pwr_Track = writeVal_tmp;
298
if(priv->bDynamicTxHighPower == TRUE) //Add by Jacken 2008/03/06
300
// Emily, 20080613. Set low tx power for both MCS and legacy OFDM
301
writeVal = 0x03030303;
305
writeVal = (byte3<<24) | (byte2<<16) |(byte1<<8) |byte0;
307
rtl8192_setBBreg(dev, RegOffset[index], 0x7f7f7f7f, writeVal);