1 /******************************************************************************
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
19 ******************************************************************************/
20 /*****************************************************************************
22 * Module: __INC_HAL8192DPHYCFG_H
28 * Export: Constants, macro, functions(API), global variables(None).
34 * 08/07/2007 MHC 1. Porting from 9x series PHYCFG.h.
35 * 2. Reorganize code architecture.
37 *****************************************************************************/
38 /* Check to see if the file has been included already. */
39 #ifndef __INC_HAL8192DPHYCFG_H
40 #define __INC_HAL8192DPHYCFG_H
43 /*--------------------------Define Parameters-------------------------------*/
45 #define MAX_STALL_TIME 50 //us
46 #define AntennaDiversityValue 0x80 //(Adapter->bSoftwareAntennaDiversity ? 0x00:0x80)
47 #define MAX_TXPWR_IDX_NMODE_92S 63
48 #define Reset_Cnt_Limit 3
52 #define SET_RTL8192SE_RF_SLEEP(_pAdapter) \
55 u1bTmp = PlatformEFIORead1Byte(_pAdapter, REG_LDOV12D_CTRL); \
57 PlatformEFIOWrite1Byte(_pAdapter, REG_LDOV12D_CTRL, u1bTmp); \
58 PlatformEFIOWrite1Byte(_pAdapter, REG_SPS_OCP_CFG, 0x0); \
59 PlatformEFIOWrite1Byte(_pAdapter, TXPAUSE, 0xFF); \
60 PlatformEFIOWrite2Byte(_pAdapter, CMDR, 0x57FC); \
62 PlatformEFIOWrite2Byte(_pAdapter, CMDR, 0x77FC); \
63 PlatformEFIOWrite1Byte(_pAdapter, PHY_CCA, 0x0); \
65 PlatformEFIOWrite2Byte(_pAdapter, CMDR, 0x37FC); \
67 PlatformEFIOWrite2Byte(_pAdapter, CMDR, 0x77FC); \
69 PlatformEFIOWrite2Byte(_pAdapter, CMDR, 0x57FC); \
74 /*--------------------------Define Parameters-------------------------------*/
77 /*------------------------------Define structure----------------------------*/
78 typedef enum _SwChnlCmdID{
80 CmdID_SetTxPowerLevel,
83 CmdID_WritePortUshort,
89 /* 1. Switch channel related */
90 typedef struct _SwChnlCmd{
97 typedef enum _HW90_BLOCK{
102 HW90_BLOCK_MAXIMUM = 4, // Never use this
103 }HW90_BLOCK_E, *PHW90_BLOCK_E;
105 //vivi added this for read parameter from header, 20100908
106 typedef enum _RF_CONTENT{
113 typedef enum _RF_RADIO_PATH{
114 RF_PATH_A = 0, //Radio Path A
115 RF_PATH_B = 1, //Radio Path B
116 RF_PATH_C = 2, //Radio Path C
117 RF_PATH_D = 3, //Radio Path D
118 //RF_PATH_MAX //Max RF number 90 support
119 }RF_RADIO_PATH_E, *PRF_RADIO_PATH_E;
121 #define RF_PATH_MAX 2
124 typedef enum _WIRELESS_MODE {
125 WIRELESS_MODE_UNKNOWN = 0x00,
126 WIRELESS_MODE_A = 0x01,
127 WIRELESS_MODE_B = 0x02,
128 WIRELESS_MODE_G = 0x04,
129 WIRELESS_MODE_AUTO = 0x08,
130 WIRELESS_MODE_N_24G = 0x10,
131 WIRELESS_MODE_N_5G = 0x20
135 #if(TX_POWER_FOR_5G_BAND == 1)
136 #define CHANNEL_MAX_NUMBER 14+24+21 // 14 is the max channel number
137 #define CHANNEL_GROUP_MAX 3+9 // ch1~3, ch4~9, ch10~14 total three groups
138 #define MAX_PG_GROUP 13
140 #define CHANNEL_MAX_NUMBER 14 // 14 is the max channel number
141 #define CHANNEL_GROUP_MAX 3 // ch1~3, ch4~9, ch10~14 total three groups
142 #define MAX_PG_GROUP 7
144 #define CHANNEL_GROUP_MAX_2G 3
145 #define CHANNEL_GROUP_IDX_5GL 3
146 #define CHANNEL_GROUP_IDX_5GM 6
147 #define CHANNEL_GROUP_IDX_5GH 9
148 #define CHANNEL_GROUP_MAX_5G 9
149 #define CHANNEL_MAX_NUMBER_2G 14
151 #if (RTL8192D_DUAL_MAC_MODE_SWITCH == 1)
152 typedef enum _BaseBand_Config_Type{
153 BaseBand_Config_PHY_REG = 0,
154 BaseBand_Config_AGC_TAB = 1,
155 BaseBand_Config_AGC_TAB_2G = 2,
156 BaseBand_Config_AGC_TAB_5G = 3,
157 }BaseBand_Config_Type, *PBaseBand_Config_Type;
159 typedef enum _BaseBand_Config_Type{
160 BaseBand_Config_PHY_REG = 0, //Radio Path A
161 BaseBand_Config_AGC_TAB = 1, //Radio Path B
162 }BaseBand_Config_Type, *PBaseBand_Config_Type;
166 typedef enum _MACPHY_MODE_8192D{
167 SINGLEMAC_SINGLEPHY, //SMSP
168 DUALMAC_DUALPHY, //DMDP
169 DUALMAC_SINGLEPHY, //DMSP
170 }MACPHY_MODE_8192D,*PMACPHY_MODE_8192D;
172 typedef enum _MACPHY_MODE_CHANGE_ACTION{
180 }MACPHY_MODE_CHANGE_ACTION,*PMACPHY_MODE_CHANGE_ACTION;
182 typedef enum _BAND_TYPE{
187 }BAND_TYPE,*PBAND_TYPE;
189 typedef enum _PHY_Rate_Tx_Power_Offset_Area{
190 RA_OFFSET_LEGACY_OFDM1,
191 RA_OFFSET_LEGACY_OFDM2,
197 }RA_OFFSET_AREA,*PRA_OFFSET_AREA;
201 typedef enum _RF_TYPE_8190P{
203 RF_8225=1, // 1 11b/g RF for verification only
204 RF_8256=2, // 2 11b/g/n
205 RF_8258=3, // 3 11a/b/g/n RF
206 RF_6052=4, // 4 11b/g/n RF
207 //RF_6052=5, // 4 11b/g/n RF
208 // TODO: We sholud remove this psudo PHY RF after we get new RF.
209 RF_PSEUDO_11N=5, // 5, It is a temporality RF.
210 }RF_TYPE_8190P_E,*PRF_TYPE_8190P_E;
214 typedef struct _BB_REGISTER_DEFINITION{
215 u32 rfintfs; // set software control:
216 // 0x870~0x877[8 bytes]
218 u32 rfintfi; // readback data:
219 // 0x8e0~0x8e7[8 bytes]
221 u32 rfintfo; // output data:
222 // 0x860~0x86f [16 bytes]
224 u32 rfintfe; // output enable:
225 // 0x860~0x86f [16 bytes]
227 u32 rf3wireOffset; // LSSI data:
228 // 0x840~0x84f [16 bytes]
230 u32 rfLSSI_Select; // BB Band Select:
231 // 0x878~0x87f [8 bytes]
233 u32 rfTxGainStage; // Tx gain stage:
234 // 0x80c~0x80f [4 bytes]
236 u32 rfHSSIPara1; // wire parameter control1 :
237 // 0x820~0x823,0x828~0x82b, 0x830~0x833, 0x838~0x83b [16 bytes]
239 u32 rfHSSIPara2; // wire parameter control2 :
240 // 0x824~0x827,0x82c~0x82f, 0x834~0x837, 0x83c~0x83f [16 bytes]
242 u32 rfSwitchControl; //Tx Rx antenna control :
243 // 0x858~0x85f [16 bytes]
245 u32 rfAGCControl1; //AGC parameter control1 :
246 // 0xc50~0xc53,0xc58~0xc5b, 0xc60~0xc63, 0xc68~0xc6b [16 bytes]
248 u32 rfAGCControl2; //AGC parameter control2 :
249 // 0xc54~0xc57,0xc5c~0xc5f, 0xc64~0xc67, 0xc6c~0xc6f [16 bytes]
251 u32 rfRxIQImbalance; //OFDM Rx IQ imbalance matrix :
252 // 0xc14~0xc17,0xc1c~0xc1f, 0xc24~0xc27, 0xc2c~0xc2f [16 bytes]
254 u32 rfRxAFE; //Rx IQ DC ofset and Rx digital filter, Rx DC notch filter :
255 // 0xc10~0xc13,0xc18~0xc1b, 0xc20~0xc23, 0xc28~0xc2b [16 bytes]
257 u32 rfTxIQImbalance; //OFDM Tx IQ imbalance matrix
258 // 0xc80~0xc83,0xc88~0xc8b, 0xc90~0xc93, 0xc98~0xc9b [16 bytes]
260 u32 rfTxAFE; //Tx IQ DC Offset and Tx DFIR type
261 // 0xc84~0xc87,0xc8c~0xc8f, 0xc94~0xc97, 0xc9c~0xc9f [16 bytes]
263 u32 rfLSSIReadBack; //LSSI RF readback data SI mode
264 // 0x8a0~0x8af [16 bytes]
266 u32 rfLSSIReadBackPi; //LSSI RF readback data PI mode 0x8b8-8bc for Path A and B
268 }BB_REGISTER_DEFINITION_T, *PBB_REGISTER_DEFINITION_T;
271 typedef struct _R_ANTENNA_SELECT_OFDM{
278 u32 r_ant_non_ht_s1:4;
281 }R_ANTENNA_SELECT_OFDM;
283 typedef struct _R_ANTENNA_SELECT_CCK{
284 u8 r_cckrx_enable_2:2;
287 }R_ANTENNA_SELECT_CCK;
289 /*------------------------------Define structure----------------------------*/
292 /*------------------------Export global variable----------------------------*/
293 /*------------------------Export global variable----------------------------*/
296 /*------------------------Export Marco Definition---------------------------*/
298 /*--------------------------Exported Function prototype---------------------*/
300 // BB and RF register read/write
302 void rtl8192d_PHY_SetBBReg1Byte( IN PADAPTER Adapter,
306 u32 rtl8192d_PHY_QueryBBReg( IN PADAPTER Adapter,
309 void rtl8192d_PHY_SetBBReg( IN PADAPTER Adapter,
313 u32 rtl8192d_PHY_QueryRFReg( IN PADAPTER Adapter,
314 IN RF_RADIO_PATH_E eRFPath,
317 void rtl8192d_PHY_SetRFReg( IN PADAPTER Adapter,
318 IN RF_RADIO_PATH_E eRFPath,
324 // Initialization related function
326 /* MAC/BB/RF HAL config */
327 extern int PHY_MACConfig8192D( IN PADAPTER Adapter );
328 extern int PHY_BBConfig8192D( IN PADAPTER Adapter );
329 extern int PHY_RFConfig8192D( IN PADAPTER Adapter );
331 int rtl8192d_PHY_ConfigRFWithParaFile( IN PADAPTER Adapter,
333 IN RF_RADIO_PATH_E eRFPath);
334 int rtl8192d_PHY_ConfigRFWithHeaderFile( IN PADAPTER Adapter,
335 IN RF_CONTENT Content,
336 IN RF_RADIO_PATH_E eRFPath);
337 /* BB/RF readback check for making sure init OK */
338 int rtl8192d_PHY_CheckBBAndRFOK( IN PADAPTER Adapter,
339 IN HW90_BLOCK_E CheckBlock,
340 IN RF_RADIO_PATH_E eRFPath );
341 /* Read initi reg value for tx power setting. */
342 void rtl8192d_PHY_GetHWRegOriginalValue( IN PADAPTER Adapter );
347 //extern BOOLEAN PHY_SetRFPowerState(IN PADAPTER Adapter,
348 // IN RT_RF_POWER_STATE eRFPowerState);
353 void PHY_GetTxPowerLevel8192D( IN PADAPTER Adapter,
354 OUT u32* powerlevel );
355 void PHY_SetTxPowerLevel8192D( IN PADAPTER Adapter,
357 BOOLEAN PHY_UpdateTxPowerDbm8192D( IN PADAPTER Adapter,
362 PHY_ScanOperationBackup8192D(IN PADAPTER Adapter,
366 // Switch bandwidth for 8192S
368 //void PHY_SetBWModeCallback8192C( IN PRT_TIMER pTimer );
369 void PHY_SetBWMode8192D( IN PADAPTER pAdapter,
370 IN HT_CHANNEL_WIDTH ChnlWidth,
371 IN unsigned char Offset );
374 // Set FW CMD IO for 8192S.
376 //extern BOOLEAN HalSetIO8192C( IN PADAPTER Adapter,
377 // IN IO_TYPE IOType);
380 // Set A2 entry to fw for 8192S
382 extern void FillA2Entry8192C( IN PADAPTER Adapter,
388 // channel switch related funciton
390 //extern void PHY_SwChnlCallback8192C( IN PRT_TIMER pTimer );
391 void PHY_SwChnl8192D( IN PADAPTER pAdapter,
393 // Call after initialization
394 void PHY_SwChnlPhy8192D( IN PADAPTER pAdapter,
397 extern void ChkFwCmdIoDone( IN PADAPTER Adapter);
401 // BB/MAC/RF other monitor API
403 void PHY_SetMonitorMode8192D(IN PADAPTER pAdapter,
404 IN BOOLEAN bEnableMonitorMode );
406 BOOLEAN PHY_CheckIsLegalRfPath8192D(IN PADAPTER pAdapter,
411 // Modify the value of the hw register when beacon interval be changed.
414 rtl8192d_PHY_SetBeaconHwReg( IN PADAPTER Adapter,
415 IN u16 BeaconInterval );
419 PHY_SwitchEphyParameter(
424 PHY_EnableHostClkReq(
435 PHY_UpdateBBRFConfiguration8192D(
437 IN BOOLEAN bisBandSwitch
440 VOID PHY_ReadMacPhyMode92D(
442 IN BOOLEAN AutoloadFail
445 VOID PHY_ConfigMacPhyMode92D(
449 VOID PHY_ConfigMacPhyModeInfo92D(
453 VOID PHY_ConfigMacCoexist_RFPage92D(
458 rtl8192d_PHY_InitRxSetting(
464 rtl8192d_PHY_SetRFPathSwitch(IN PADAPTER pAdapter, IN BOOLEAN bMain);
467 HalChangeCCKStatus8192D(
469 IN BOOLEAN bCCKDisable
473 PHY_InitPABias92D(IN PADAPTER Adapter);
475 /*--------------------------Exported Function prototype---------------------*/
477 #define PHY_SetBBReg1Byte(Adapter, RegAddr, BitMask, Data) rtl8192d_PHY_SetBBReg1Byte((Adapter), (RegAddr), (BitMask), (Data))
478 #define PHY_QueryBBReg(Adapter, RegAddr, BitMask) rtl8192d_PHY_QueryBBReg((Adapter), (RegAddr), (BitMask))
479 #define PHY_SetBBReg(Adapter, RegAddr, BitMask, Data) rtl8192d_PHY_SetBBReg((Adapter), (RegAddr), (BitMask), (Data))
480 #define PHY_QueryRFReg(Adapter, eRFPath, RegAddr, BitMask) rtl8192d_PHY_QueryRFReg((Adapter), (eRFPath), (RegAddr), (BitMask))
481 #define PHY_SetRFReg(Adapter, eRFPath, RegAddr, BitMask, Data) rtl8192d_PHY_SetRFReg((Adapter), (eRFPath), (RegAddr), (BitMask), (Data))
483 #define PHY_SetMacReg PHY_SetBBReg
484 #define PHY_QueryMacReg PHY_QueryBBReg
486 #endif // __INC_HAL8192SPHYCFG_H