2014-12-19 06:59:46 +00:00
/******************************************************************************
*
* Copyright ( c ) 2007 - 2011 Realtek Corporation . All rights reserved .
*
* This program is free software ; you can redistribute it and / or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation .
*
* This program is distributed in the hope that it will be useful , but WITHOUT
* ANY WARRANTY ; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE . See the GNU General Public License for
* more details .
*
* You should have received a copy of the GNU General Public License along with
* this program ; if not , write to the Free Software Foundation , Inc . ,
* 51 Franklin Street , Fifth Floor , Boston , MA 02110 , USA
*
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# include "odm_precomp.h"
/*---------------------------Define Local Constant---------------------------*/
2015-02-20 00:51:33 +00:00
/* 2010/04/25 MH Define the max tx power tracking tx agc power. */
2014-12-19 06:59:46 +00:00
# define ODM_TXPWRTRACK_MAX_IDX_88E 6
# define CALCULATE_SWINGTALBE_OFFSET(_offset, _direction, _size, _deltaThermal) \
do { \
2015-08-15 18:06:32 +00:00
for ( _offset = 0 ; _offset < _size ; _offset + + ) \
2014-12-19 06:59:46 +00:00
{ \
2015-08-15 18:02:34 +00:00
if ( _deltaThermal < thermalThreshold [ _direction ] [ _offset ] ) \
2014-12-19 06:59:46 +00:00
{ \
2015-08-15 18:02:34 +00:00
if ( _offset ! = 0 ) \
2014-12-19 06:59:46 +00:00
_offset - - ; \
break ; \
} \
} \
2015-08-15 18:02:34 +00:00
if ( _offset > = _size ) \
2014-12-19 06:59:46 +00:00
_offset = _size - 1 ; \
2015-08-15 18:04:12 +00:00
} while ( 0 )
2014-12-19 06:59:46 +00:00
2015-02-20 00:51:33 +00:00
/* 3============================================================ */
/* 3 Tx Power Tracking */
/* 3============================================================ */
2015-01-29 21:27:28 +00:00
static void setIqkMatrix (
2014-12-19 06:59:46 +00:00
PDM_ODM_T pDM_Odm ,
2014-12-30 23:50:44 +00:00
u8 OFDM_index ,
u8 RFPath ,
2014-12-30 23:58:53 +00:00
s32 IqkResult_X ,
s32 IqkResult_Y
2014-12-19 06:59:46 +00:00
)
{
2014-12-30 23:58:53 +00:00
s32 ele_A = 0 , ele_D , ele_C = 0 , TempCCk , value32 ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:00:19 +00:00
/* printk("%s==> OFDM_index:%d\n",__FUNCTION__,OFDM_index); */
2014-12-19 06:59:46 +00:00
2015-08-15 18:02:34 +00:00
/* if (OFDM_index> OFDM_TABLE_SIZE_92D) */
2015-02-20 00:51:33 +00:00
/* */
/* printk("%s==> OFDM_index> 43\n",__FUNCTION__); */
/* */
2014-12-19 06:59:46 +00:00
ele_D = ( OFDMSwingTable [ OFDM_index ] & 0xFFC00000 ) > > 22 ;
2015-02-20 00:51:33 +00:00
/* new element A = element D x X */
2015-08-15 18:02:34 +00:00
if ( ( IqkResult_X ! = 0 ) & & ( * ( pDM_Odm - > pBandType ) = = ODM_BAND_2_4G ) )
2014-12-19 06:59:46 +00:00
{
2015-02-20 00:51:33 +00:00
if ( ( IqkResult_X & 0x00000200 ) ! = 0 ) /* consider minus */
2014-12-19 06:59:46 +00:00
IqkResult_X = IqkResult_X | 0xFFFFFC00 ;
ele_A = ( ( IqkResult_X * ele_D ) > > 8 ) & 0x000003FF ;
2015-02-20 00:51:33 +00:00
/* new element C = element D x Y */
2014-12-19 06:59:46 +00:00
if ( ( IqkResult_Y & 0x00000200 ) ! = 0 )
IqkResult_Y = IqkResult_Y | 0xFFFFFC00 ;
ele_C = ( ( IqkResult_Y * ele_D ) > > 8 ) & 0x000003FF ;
if ( RFPath = = RF_PATH_A )
2015-03-10 16:18:03 +00:00
switch ( RFPath ) {
case RF_PATH_A :
/* wirte new elements A, C, D to regC80 and regC94, element B is always 0 */
value32 = ( ele_D < < 22 ) | ( ( ele_C & 0x3F ) < < 16 ) | ele_A ;
ODM_SetBBReg ( pDM_Odm , rOFDM0_XATxIQImbalance , bMaskDWord , value32 ) ;
2014-12-19 06:59:46 +00:00
2015-03-10 16:18:03 +00:00
value32 = ( ele_C & 0x000003C0 ) > > 6 ;
ODM_SetBBReg ( pDM_Odm , rOFDM0_XCTxAFE , bMaskH4Bits , value32 ) ;
2014-12-19 06:59:46 +00:00
2015-03-10 16:18:03 +00:00
value32 = ( ( IqkResult_X * ele_D ) > > 7 ) & 0x01 ;
ODM_SetBBReg ( pDM_Odm , rOFDM0_ECCAThreshold , BIT24 , value32 ) ;
break ;
case RF_PATH_B :
/* wirte new elements A, C, D to regC88 and regC9C, element B is always 0 */
value32 = ( ele_D < < 22 ) | ( ( ele_C & 0x3F ) < < 16 ) | ele_A ;
ODM_SetBBReg ( pDM_Odm , rOFDM0_XBTxIQImbalance , bMaskDWord , value32 ) ;
2014-12-19 06:59:46 +00:00
2015-03-10 16:18:03 +00:00
value32 = ( ele_C & 0x000003C0 ) > > 6 ;
ODM_SetBBReg ( pDM_Odm , rOFDM0_XDTxAFE , bMaskH4Bits , value32 ) ;
2014-12-19 06:59:46 +00:00
2015-03-10 16:18:03 +00:00
value32 = ( ( IqkResult_X * ele_D ) > > 7 ) & 0x01 ;
ODM_SetBBReg ( pDM_Odm , rOFDM0_ECCAThreshold , BIT28 , value32 ) ;
2014-12-19 06:59:46 +00:00
2015-03-10 16:18:03 +00:00
break ;
default :
break ;
}
} else {
switch ( RFPath ) {
2014-12-19 06:59:46 +00:00
case RF_PATH_A :
ODM_SetBBReg ( pDM_Odm , rOFDM0_XATxIQImbalance , bMaskDWord , OFDMSwingTable [ OFDM_index ] ) ;
ODM_SetBBReg ( pDM_Odm , rOFDM0_XCTxAFE , bMaskH4Bits , 0x00 ) ;
ODM_SetBBReg ( pDM_Odm , rOFDM0_ECCAThreshold , BIT24 , 0x00 ) ;
break ;
case RF_PATH_B :
ODM_SetBBReg ( pDM_Odm , rOFDM0_XBTxIQImbalance , bMaskDWord , OFDMSwingTable [ OFDM_index ] ) ;
ODM_SetBBReg ( pDM_Odm , rOFDM0_XDTxAFE , bMaskH4Bits , 0x00 ) ;
ODM_SetBBReg ( pDM_Odm , rOFDM0_ECCAThreshold , BIT28 , 0x00 ) ;
break ;
default :
break ;
}
}
2015-03-10 16:18:03 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_TX_PWR_TRACK , ODM_DBG_LOUD ,
( " TxPwrTracking path B: X = 0x%x, Y = 0x%x ele_A = 0x%x ele_C = 0x%x ele_D = 0x%x 0xeb4 = 0x%x 0xebc = 0x%x \n " ,
( u32 ) IqkResult_X , ( u32 ) IqkResult_Y , ( u32 ) ele_A , ( u32 ) ele_C , ( u32 ) ele_D , ( u32 ) IqkResult_X , ( u32 ) IqkResult_Y ) ) ;
2014-12-19 06:59:46 +00:00
}
2015-01-29 21:27:28 +00:00
static void doIQK (
2014-12-19 06:59:46 +00:00
PDM_ODM_T pDM_Odm ,
2014-12-30 23:50:44 +00:00
u8 DeltaThermalIndex ,
u8 ThermalValue ,
u8 Threshold
2014-12-19 06:59:46 +00:00
)
{
struct adapter * Adapter = pDM_Odm - > Adapter ;
HAL_DATA_TYPE * pHalData = GET_HAL_DATA ( Adapter ) ;
ODM_ResetIQKResult ( pDM_Odm ) ;
pDM_Odm - > RFCalibrateInfo . ThermalValue_IQK = ThermalValue ;
2015-03-02 23:25:27 +00:00
PHY_IQCalibrate_8188E ( Adapter , false ) ;
2014-12-19 06:59:46 +00:00
}
/*-----------------------------------------------------------------------------
* Function : ODM_TxPwrTrackAdjust88E ( )
*
* Overview : 88 E we can not write 0xc80 / c94 / c4c / 0xa2 x . Instead of write TX agc .
* No matter OFDM & CCK use the same method .
*
* Input : NONE
*
* Output : NONE
*
* Return : NONE
*
* Revised History :
* When Who Remark
* 04 / 23 / 2012 MHC Create Version 0.
* 04 / 23 / 2012 MHC Adjust TX agc directly not throughput BB digital .
*
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
2014-12-29 02:06:17 +00:00
void
2014-12-19 06:59:46 +00:00
ODM_TxPwrTrackAdjust88E (
PDM_ODM_T pDM_Odm ,
2015-02-20 00:51:33 +00:00
u8 Type , /* 0 = OFDM, 1 = CCK */
u8 * pDirection , /* 1 = +(increase) 2 = -(decrease) */
u32 * pOutWriteVal /* Tx tracking CCK/OFDM BB swing index adjust */
2014-12-19 06:59:46 +00:00
)
{
2014-12-30 23:50:44 +00:00
u8 pwr_value = 0 ;
2015-02-20 00:51:33 +00:00
/* */
/* Tx power tracking BB swing table. */
/* The base index = 12. +((12-n)/2)dB 13~?? = decrease tx pwr by -((n-12)/2)dB */
/* */
if ( Type = = 0 ) /* For OFDM afjust */
2014-12-19 06:59:46 +00:00
{
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_TX_PWR_TRACK , ODM_DBG_LOUD ,
( " BbSwingIdxOfdm = %d BbSwingFlagOfdm=%d \n " , pDM_Odm - > BbSwingIdxOfdm , pDM_Odm - > BbSwingFlagOfdm ) ) ;
2015-02-20 00:51:33 +00:00
/* printk("BbSwingIdxOfdm = %d BbSwingFlagOfdm=%d\n", pDM_Odm->BbSwingIdxOfdm, pDM_Odm->BbSwingFlagOfdm); */
2014-12-19 06:59:46 +00:00
if ( pDM_Odm - > BbSwingIdxOfdm < = pDM_Odm - > BbSwingIdxOfdmBase )
{
* pDirection = 1 ;
pwr_value = ( pDM_Odm - > BbSwingIdxOfdmBase - pDM_Odm - > BbSwingIdxOfdm ) ;
}
else
{
* pDirection = 2 ;
pwr_value = ( pDM_Odm - > BbSwingIdxOfdm - pDM_Odm - > BbSwingIdxOfdmBase ) ;
}
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_TX_PWR_TRACK , ODM_DBG_LOUD ,
( " BbSwingIdxOfdm = %d BbSwingIdxOfdmBase=%d \n " , pDM_Odm - > BbSwingIdxOfdm , pDM_Odm - > BbSwingIdxOfdmBase ) ) ;
2015-02-20 00:51:33 +00:00
/* printk("BbSwingIdxOfdm = %d BbSwingIdxOfdmBase=%d pwr_value=%d\n", pDM_Odm->BbSwingIdxOfdm, pDM_Odm->BbSwingIdxOfdmBase,pwr_value); */
2014-12-19 06:59:46 +00:00
}
2015-02-20 00:51:33 +00:00
else if ( Type = = 1 ) /* For CCK adjust. */
2014-12-19 06:59:46 +00:00
{
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_TX_PWR_TRACK , ODM_DBG_LOUD ,
( " pDM_Odm->BbSwingIdxCck = %d pDM_Odm->BbSwingIdxCckBase = %d \n " , pDM_Odm - > BbSwingIdxCck , pDM_Odm - > BbSwingIdxCckBase ) ) ;
2015-02-20 00:51:33 +00:00
/* printk("pDM_Odm->BbSwingIdxCck = %d pDM_Odm->BbSwingIdxCckBase = %d\n", pDM_Odm->BbSwingIdxCck, pDM_Odm->BbSwingIdxCckBase); */
2014-12-19 06:59:46 +00:00
if ( pDM_Odm - > BbSwingIdxCck < = pDM_Odm - > BbSwingIdxCckBase )
{
* pDirection = 1 ;
pwr_value = ( pDM_Odm - > BbSwingIdxCckBase - pDM_Odm - > BbSwingIdxCck ) ;
}
else
{
* pDirection = 2 ;
pwr_value = ( pDM_Odm - > BbSwingIdxCck - pDM_Odm - > BbSwingIdxCckBase ) ;
}
2015-02-20 00:51:33 +00:00
/* printk("pDM_Odm->BbSwingIdxCck = %d pDM_Odm->BbSwingIdxCckBase = %d pwr_value:%d\n", pDM_Odm->BbSwingIdxCck, pDM_Odm->BbSwingIdxCckBase,pwr_value); */
2014-12-19 06:59:46 +00:00
}
2015-02-20 00:51:33 +00:00
/* */
/* 2012/04/25 MH According to Ed/Luke.Lees estimate for EVM the max tx power tracking */
/* need to be less than 6 power index for 88E. */
/* */
2014-12-19 06:59:46 +00:00
if ( pwr_value > = ODM_TXPWRTRACK_MAX_IDX_88E & & * pDirection = = 1 )
pwr_value = ODM_TXPWRTRACK_MAX_IDX_88E ;
* pOutWriteVal = pwr_value | ( pwr_value < < 8 ) | ( pwr_value < < 16 ) | ( pwr_value < < 24 ) ;
2015-02-20 00:51:33 +00:00
} /* ODM_TxPwrTrackAdjust88E */
2014-12-19 06:59:46 +00:00
/*-----------------------------------------------------------------------------
* Function : odm_TxPwrTrackSetPwr88E ( )
*
* Overview : 88 E change all channel tx power accordign to flag .
* OFDM & CCK are all different .
*
* Input : NONE
*
* Output : NONE
*
* Return : NONE
*
* Revised History :
* When Who Remark
* 04 / 23 / 2012 MHC Create Version 0.
*
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
2015-01-29 21:27:28 +00:00
static void
2014-12-19 06:59:46 +00:00
odm_TxPwrTrackSetPwr88E (
PDM_ODM_T pDM_Odm ,
PWRTRACK_METHOD Method ,
2014-12-30 23:50:44 +00:00
u8 RFPath ,
u8 ChannelMappedIndex
2014-12-19 06:59:46 +00:00
)
{
2014-12-30 19:48:00 +00:00
if ( Method = = TXAGC ) {
2014-12-30 23:50:44 +00:00
u8 cckPowerLevel [ MAX_TX_COUNT ] , ofdmPowerLevel [ MAX_TX_COUNT ] ;
u8 BW20PowerLevel [ MAX_TX_COUNT ] , BW40PowerLevel [ MAX_TX_COUNT ] ;
u8 rf = 0 ;
2014-12-30 22:55:10 +00:00
u32 pwr = 0 , TxAGC = 0 ;
2014-12-19 06:59:46 +00:00
struct adapter * Adapter = pDM_Odm - > Adapter ;
2015-08-15 18:00:19 +00:00
/* printk("odm_TxPwrTrackSetPwr88E CH=%d, modify TXAGC\n", *(pDM_Odm->pChannel)); */
2014-12-19 06:59:46 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_TX_PWR_TRACK , ODM_DBG_LOUD , ( " odm_TxPwrTrackSetPwr88E CH=%d \n " , * ( pDM_Odm - > pChannel ) ) ) ;
2015-02-20 00:51:33 +00:00
/* if (MP_DRIVER != 1) */
2015-08-15 18:24:16 +00:00
if ( * ( pDM_Odm - > mp_mode ) ! = 1 ) {
2014-12-19 06:59:46 +00:00
PHY_SetTxPowerLevel8188E ( pDM_Odm - > Adapter , * pDM_Odm - > pChannel ) ;
}
else
{
pwr = PHY_QueryBBReg ( Adapter , rTxAGC_A_Rate18_06 , 0xFF ) ;
pwr + = ( pDM_Odm - > BbSwingIdxCck - pDM_Odm - > BbSwingIdxCckBase ) ;
PHY_SetBBReg ( Adapter , rTxAGC_A_CCK1_Mcs32 , bMaskByte1 , pwr ) ;
TxAGC = ( pwr < < 16 ) | ( pwr < < 8 ) | ( pwr ) ;
PHY_SetBBReg ( Adapter , rTxAGC_B_CCK11_A_CCK2_11 , 0xffffff00 , TxAGC ) ;
2015-08-15 21:38:30 +00:00
DBG_88E ( " ODM_TxPwrTrackSetPwr88E: CCK Tx-rf(A) Power = 0x%x \n " , TxAGC ) ;
2014-12-19 06:59:46 +00:00
pwr = PHY_QueryBBReg ( Adapter , rTxAGC_A_Rate18_06 , 0xFF ) ;
pwr + = ( pDM_Odm - > BbSwingIdxOfdm - pDM_Odm - > BbSwingIdxOfdmBase ) ;
TxAGC | = ( ( pwr < < 24 ) | ( pwr < < 16 ) | ( pwr < < 8 ) | pwr ) ;
PHY_SetBBReg ( Adapter , rTxAGC_A_Rate18_06 , bMaskDWord , TxAGC ) ;
PHY_SetBBReg ( Adapter , rTxAGC_A_Rate54_24 , bMaskDWord , TxAGC ) ;
PHY_SetBBReg ( Adapter , rTxAGC_A_Mcs03_Mcs00 , bMaskDWord , TxAGC ) ;
PHY_SetBBReg ( Adapter , rTxAGC_A_Mcs07_Mcs04 , bMaskDWord , TxAGC ) ;
PHY_SetBBReg ( Adapter , rTxAGC_A_Mcs11_Mcs08 , bMaskDWord , TxAGC ) ;
PHY_SetBBReg ( Adapter , rTxAGC_A_Mcs15_Mcs12 , bMaskDWord , TxAGC ) ;
2015-08-15 21:38:30 +00:00
DBG_88E ( " ODM_TxPwrTrackSetPwr88E: OFDM Tx-rf(A) Power = 0x%x \n " , TxAGC ) ;
2014-12-19 06:59:46 +00:00
}
}
else if ( Method = = BBSWING )
{
2015-08-15 18:02:34 +00:00
if ( * ( pDM_Odm - > pChannel ) < 14 )
2014-12-19 06:59:46 +00:00
{
ODM_Write1Byte ( pDM_Odm , 0xa22 , CCKSwingTable_Ch1_Ch13 [ pDM_Odm - > BbSwingIdxCck ] [ 0 ] ) ;
ODM_Write1Byte ( pDM_Odm , 0xa23 , CCKSwingTable_Ch1_Ch13 [ pDM_Odm - > BbSwingIdxCck ] [ 1 ] ) ;
ODM_Write1Byte ( pDM_Odm , 0xa24 , CCKSwingTable_Ch1_Ch13 [ pDM_Odm - > BbSwingIdxCck ] [ 2 ] ) ;
ODM_Write1Byte ( pDM_Odm , 0xa25 , CCKSwingTable_Ch1_Ch13 [ pDM_Odm - > BbSwingIdxCck ] [ 3 ] ) ;
ODM_Write1Byte ( pDM_Odm , 0xa26 , CCKSwingTable_Ch1_Ch13 [ pDM_Odm - > BbSwingIdxCck ] [ 4 ] ) ;
ODM_Write1Byte ( pDM_Odm , 0xa27 , CCKSwingTable_Ch1_Ch13 [ pDM_Odm - > BbSwingIdxCck ] [ 5 ] ) ;
ODM_Write1Byte ( pDM_Odm , 0xa28 , CCKSwingTable_Ch1_Ch13 [ pDM_Odm - > BbSwingIdxCck ] [ 6 ] ) ;
ODM_Write1Byte ( pDM_Odm , 0xa29 , CCKSwingTable_Ch1_Ch13 [ pDM_Odm - > BbSwingIdxCck ] [ 7 ] ) ;
}
else
{
ODM_Write1Byte ( pDM_Odm , 0xa22 , CCKSwingTable_Ch14 [ pDM_Odm - > BbSwingIdxCck ] [ 0 ] ) ;
ODM_Write1Byte ( pDM_Odm , 0xa23 , CCKSwingTable_Ch14 [ pDM_Odm - > BbSwingIdxCck ] [ 1 ] ) ;
ODM_Write1Byte ( pDM_Odm , 0xa24 , CCKSwingTable_Ch14 [ pDM_Odm - > BbSwingIdxCck ] [ 2 ] ) ;
ODM_Write1Byte ( pDM_Odm , 0xa25 , CCKSwingTable_Ch14 [ pDM_Odm - > BbSwingIdxCck ] [ 3 ] ) ;
ODM_Write1Byte ( pDM_Odm , 0xa26 , CCKSwingTable_Ch14 [ pDM_Odm - > BbSwingIdxCck ] [ 4 ] ) ;
ODM_Write1Byte ( pDM_Odm , 0xa27 , CCKSwingTable_Ch14 [ pDM_Odm - > BbSwingIdxCck ] [ 5 ] ) ;
ODM_Write1Byte ( pDM_Odm , 0xa28 , CCKSwingTable_Ch14 [ pDM_Odm - > BbSwingIdxCck ] [ 6 ] ) ;
ODM_Write1Byte ( pDM_Odm , 0xa29 , CCKSwingTable_Ch14 [ pDM_Odm - > BbSwingIdxCck ] [ 7 ] ) ;
}
2015-02-20 00:51:33 +00:00
/* Adjust BB swing by OFDM IQ matrix */
2014-12-19 06:59:46 +00:00
if ( RFPath = = RF_PATH_A )
{
setIqkMatrix ( pDM_Odm , pDM_Odm - > BbSwingIdxOfdm , RF_PATH_A ,
pDM_Odm - > RFCalibrateInfo . IQKMatrixRegSetting [ ChannelMappedIndex ] . Value [ 0 ] [ 0 ] ,
pDM_Odm - > RFCalibrateInfo . IQKMatrixRegSetting [ ChannelMappedIndex ] . Value [ 0 ] [ 1 ] ) ;
}
/*
else if ( RFPath = = RF_PATH_B )
{
setIqkMatrix ( pDM_Odm , pDM_Odm - > BbSwingIdxOfdm [ RF_PATH_B ] , RF_PATH_B ,
pDM_Odm - > RFCalibrateInfo . IQKMatrixRegSetting [ ChannelMappedIndex ] . Value [ 0 ] [ 4 ] ,
pDM_Odm - > RFCalibrateInfo . IQKMatrixRegSetting [ ChannelMappedIndex ] . Value [ 0 ] [ 5 ] ) ;
} */
}
else
{
return ;
}
2015-02-20 00:51:33 +00:00
} /* odm_TxPwrTrackSetPwr88E */
2014-12-19 06:59:46 +00:00
2014-12-29 02:06:17 +00:00
void
2014-12-19 06:59:46 +00:00
odm_TXPowerTrackingCallback_ThermalMeter_8188E (
2015-03-13 17:06:38 +00:00
struct adapter * Adapter
2014-12-19 06:59:46 +00:00
)
{
HAL_DATA_TYPE * pHalData = GET_HAL_DATA ( Adapter ) ;
2014-12-30 23:50:44 +00:00
u8 ThermalValue = 0 , delta , delta_LCK , delta_IQK , offset ;
u8 ThermalValue_AVG_count = 0 ;
2014-12-30 22:55:10 +00:00
u32 ThermalValue_AVG = 0 ;
2014-12-30 23:58:53 +00:00
s32 ele_A = 0 , ele_D , TempCCk , X , value32 ;
s32 Y , ele_C = 0 ;
s8 OFDM_index [ 2 ] , CCK_index = 0 , OFDM_index_old [ 2 ] = { 0 , 0 } , CCK_index_old = 0 , index ;
s8 deltaPowerIndex = 0 ;
2014-12-30 22:55:10 +00:00
u32 i = 0 , j = 0 ;
2015-03-02 23:25:27 +00:00
bool is2T = false ;
bool bInteralPA = false ;
2014-12-19 06:59:46 +00:00
2015-02-20 00:51:33 +00:00
u8 OFDM_min_index = 6 , rf = ( is2T ) ? 2 : 1 ; /* OFDM BB Swing should be less than +3.0dB, which is required by Arthur */
2014-12-30 23:50:44 +00:00
u8 Indexforchannel = 0 ; /*GetRightChnlPlaceforIQK(pHalData->CurrentChannel)*/
2015-03-10 16:18:03 +00:00
enum _POWER_DEC_INC { POWER_DEC , POWER_INC } ;
2014-12-19 06:59:46 +00:00
PDM_ODM_T pDM_Odm = & pHalData - > odmpriv ;
struct dm_priv * pdmpriv = & pHalData - > dmpriv ;
2015-02-20 00:51:33 +00:00
/* 4 0.1 The following TWO tables decide the final index of OFDM/CCK swing table. */
2014-12-30 23:58:53 +00:00
s8 deltaSwingTableIdx [ 2 ] [ index_mapping_NUM_88E ] = {
2015-02-20 00:51:33 +00:00
/* {{Power decreasing(lower temperature)}, {Power increasing(higher temperature)}} */
2014-12-19 06:59:46 +00:00
{ 0 , 0 , 2 , 3 , 4 , 4 , 5 , 6 , 7 , 7 , 8 , 9 , 10 , 10 , 11 } , { 0 , 0 , - 1 , - 2 , - 3 , - 4 , - 4 , - 4 , - 4 , - 5 , - 7 , - 8 , - 9 , - 9 , - 10 }
} ;
2014-12-30 23:50:44 +00:00
u8 thermalThreshold [ 2 ] [ index_mapping_NUM_88E ] = {
2015-02-20 00:51:33 +00:00
/* {{Power decreasing(lower temperature)}, {Power increasing(higher temperature)}} */
2014-12-19 06:59:46 +00:00
{ 0 , 2 , 4 , 6 , 8 , 10 , 12 , 14 , 16 , 18 , 20 , 22 , 24 , 26 , 27 } , { 0 , 2 , 4 , 6 , 8 , 10 , 12 , 14 , 16 , 18 , 20 , 22 , 25 , 25 , 25 }
} ;
2015-02-20 00:51:33 +00:00
/* 4 0.1 Initilization ( 7 steps in total ) */
2014-12-19 06:59:46 +00:00
2015-02-20 00:51:33 +00:00
pDM_Odm - > RFCalibrateInfo . TXPowerTrackingCallbackCnt + + ; /* cosa add for debug */
2015-03-02 23:25:27 +00:00
pDM_Odm - > RFCalibrateInfo . bTXPowerTrackingInit = true ;
2014-12-19 06:59:46 +00:00
# if (MP_DRIVER == 1)
2015-02-20 00:51:33 +00:00
/* <Kordan> RFCalibrateInfo.RegA24 will be initialized when ODM HW configuring, but MP configures with para files. */
2014-12-19 06:59:46 +00:00
pDM_Odm - > RFCalibrateInfo . RegA24 = 0x090e1317 ;
# endif
2015-08-15 18:00:19 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_TX_PWR_TRACK , ODM_DBG_LOUD , ( " ===>odm_TXPowerTrackingCallback_ThermalMeter_8188E, pDM_Odm->BbSwingIdxCckBase: %d, pDM_Odm->BbSwingIdxOfdmBase: %d \n " , pDM_Odm - > BbSwingIdxCckBase , pDM_Odm - > BbSwingIdxOfdmBase ) ) ;
2015-02-20 00:51:33 +00:00
ThermalValue = ( u8 ) ODM_GetRFReg ( pDM_Odm , RF_PATH_A , RF_T_METER_88E , 0xfc00 ) ; /* 0x42: RF Reg[15:10] 88E */
2015-03-10 16:18:03 +00:00
if ( ! ThermalValue | | ! pDM_Odm - > RFCalibrateInfo . TxPowerTrackControl )
return ;
2014-12-19 06:59:46 +00:00
2015-02-20 00:51:33 +00:00
/* 4 3. Initialize ThermalValues of RFCalibrateInfo */
2014-12-19 06:59:46 +00:00
2015-08-15 18:02:34 +00:00
if ( ! pDM_Odm - > RFCalibrateInfo . ThermalValue )
2014-12-19 06:59:46 +00:00
{
pDM_Odm - > RFCalibrateInfo . ThermalValue_LCK = ThermalValue ;
pDM_Odm - > RFCalibrateInfo . ThermalValue_IQK = ThermalValue ;
}
2015-08-15 18:02:34 +00:00
if ( pDM_Odm - > RFCalibrateInfo . bReloadtxpowerindex )
2014-12-19 06:59:46 +00:00
{
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_TX_PWR_TRACK , ODM_DBG_LOUD , ( " reload ofdm index for band switch \n " ) ) ;
}
2015-02-20 00:51:33 +00:00
/* 4 4. Calculate average thermal meter */
2014-12-19 06:59:46 +00:00
pDM_Odm - > RFCalibrateInfo . ThermalValue_AVG [ pDM_Odm - > RFCalibrateInfo . ThermalValue_AVG_index ] = ThermalValue ;
pDM_Odm - > RFCalibrateInfo . ThermalValue_AVG_index + + ;
2015-08-15 18:02:34 +00:00
if ( pDM_Odm - > RFCalibrateInfo . ThermalValue_AVG_index = = AVG_THERMAL_NUM_88E )
2014-12-19 06:59:46 +00:00
pDM_Odm - > RFCalibrateInfo . ThermalValue_AVG_index = 0 ;
2015-08-15 18:06:32 +00:00
for ( i = 0 ; i < AVG_THERMAL_NUM_88E ; i + + )
2014-12-19 06:59:46 +00:00
{
2015-08-15 18:02:34 +00:00
if ( pDM_Odm - > RFCalibrateInfo . ThermalValue_AVG [ i ] )
2014-12-19 06:59:46 +00:00
{
ThermalValue_AVG + = pDM_Odm - > RFCalibrateInfo . ThermalValue_AVG [ i ] ;
ThermalValue_AVG_count + + ;
}
}
2015-08-15 18:02:34 +00:00
if ( ThermalValue_AVG_count )
2014-12-19 06:59:46 +00:00
{
2014-12-30 23:50:44 +00:00
ThermalValue = ( u8 ) ( ThermalValue_AVG / ThermalValue_AVG_count ) ;
2015-08-15 18:00:19 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_TX_PWR_TRACK , ODM_DBG_LOUD , ( " AVG Thermal Meter = 0x%x \n " , ThermalValue ) ) ;
2014-12-19 06:59:46 +00:00
}
2015-02-20 00:51:33 +00:00
/* 4 5. Calculate delta, delta_LCK, delta_IQK. */
2014-12-19 06:59:46 +00:00
delta = ( ThermalValue > pDM_Odm - > RFCalibrateInfo . ThermalValue ) ? ( ThermalValue - pDM_Odm - > RFCalibrateInfo . ThermalValue ) : ( pDM_Odm - > RFCalibrateInfo . ThermalValue - ThermalValue ) ;
delta_LCK = ( ThermalValue > pDM_Odm - > RFCalibrateInfo . ThermalValue_LCK ) ? ( ThermalValue - pDM_Odm - > RFCalibrateInfo . ThermalValue_LCK ) : ( pDM_Odm - > RFCalibrateInfo . ThermalValue_LCK - ThermalValue ) ;
delta_IQK = ( ThermalValue > pDM_Odm - > RFCalibrateInfo . ThermalValue_IQK ) ? ( ThermalValue - pDM_Odm - > RFCalibrateInfo . ThermalValue_IQK ) : ( pDM_Odm - > RFCalibrateInfo . ThermalValue_IQK - ThermalValue ) ;
2015-02-20 00:51:33 +00:00
/* 4 6. If necessary, do LCK. */
2014-12-19 06:59:46 +00:00
2015-08-15 18:02:34 +00:00
/* if ((delta_LCK > pHalData->Delta_LCK) && (pHalData->Delta_LCK != 0)) */
2015-02-20 00:51:33 +00:00
if ( ( delta_LCK > = 8 ) ) /* Delta temperature is equal to or larger than 20 centigrade. */
2014-12-19 06:59:46 +00:00
{
pDM_Odm - > RFCalibrateInfo . ThermalValue_LCK = ThermalValue ;
PHY_LCCalibrate_8188E ( Adapter ) ;
}
2015-02-20 00:51:33 +00:00
/* 3 7. If necessary, move the index of swing table to adjust Tx power. */
2014-12-19 06:59:46 +00:00
if ( delta > 0 & & pDM_Odm - > RFCalibrateInfo . TxPowerTrackControl )
{
2014-12-30 19:48:00 +00:00
delta = ThermalValue > pHalData - > EEPROMThermalMeter ? ( ThermalValue - pHalData - > EEPROMThermalMeter ) : ( pHalData - > EEPROMThermalMeter - ThermalValue ) ;
2014-12-19 06:59:46 +00:00
2015-02-20 00:51:33 +00:00
/* 4 7.1 The Final Power Index = BaseIndex + PowerIndexOffset */
2014-12-19 06:59:46 +00:00
2015-08-15 18:02:34 +00:00
if ( ThermalValue > pHalData - > EEPROMThermalMeter ) {
2014-12-19 06:59:46 +00:00
CALCULATE_SWINGTALBE_OFFSET ( offset , POWER_INC , index_mapping_NUM_88E , delta ) ;
pDM_Odm - > RFCalibrateInfo . DeltaPowerIndexLast = pDM_Odm - > RFCalibrateInfo . DeltaPowerIndex ;
pDM_Odm - > RFCalibrateInfo . DeltaPowerIndex = - 1 * deltaSwingTableIdx [ POWER_INC ] [ offset ] ;
} else {
CALCULATE_SWINGTALBE_OFFSET ( offset , POWER_DEC , index_mapping_NUM_88E , delta ) ;
pDM_Odm - > RFCalibrateInfo . DeltaPowerIndexLast = pDM_Odm - > RFCalibrateInfo . DeltaPowerIndex ;
pDM_Odm - > RFCalibrateInfo . DeltaPowerIndex = - 1 * deltaSwingTableIdx [ POWER_DEC ] [ offset ] ;
}
if ( pDM_Odm - > RFCalibrateInfo . DeltaPowerIndex = = pDM_Odm - > RFCalibrateInfo . DeltaPowerIndexLast )
pDM_Odm - > RFCalibrateInfo . PowerIndexOffset = 0 ;
else
pDM_Odm - > RFCalibrateInfo . PowerIndexOffset = pDM_Odm - > RFCalibrateInfo . DeltaPowerIndex - pDM_Odm - > RFCalibrateInfo . DeltaPowerIndexLast ;
2015-08-15 18:06:32 +00:00
for ( i = 0 ; i < rf ; i + + )
2015-03-10 16:18:03 +00:00
pDM_Odm - > RFCalibrateInfo . OFDM_index [ i ] = pDM_Odm - > BbSwingIdxOfdmBase + pDM_Odm - > RFCalibrateInfo . PowerIndexOffset ;
2014-12-19 06:59:46 +00:00
pDM_Odm - > RFCalibrateInfo . CCK_index = pDM_Odm - > BbSwingIdxCckBase + pDM_Odm - > RFCalibrateInfo . PowerIndexOffset ;
pDM_Odm - > BbSwingIdxCck = pDM_Odm - > RFCalibrateInfo . CCK_index ;
pDM_Odm - > BbSwingIdxOfdm = pDM_Odm - > RFCalibrateInfo . OFDM_index [ RF_PATH_A ] ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_TX_PWR_TRACK , ODM_DBG_LOUD , ( " The 'CCK' final index(%d) = BaseIndex(%d) + PowerIndexOffset(%d) \n " , pDM_Odm - > BbSwingIdxCck , pDM_Odm - > BbSwingIdxCckBase , pDM_Odm - > RFCalibrateInfo . PowerIndexOffset ) ) ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_TX_PWR_TRACK , ODM_DBG_LOUD , ( " The 'OFDM' final index(%d) = BaseIndex(%d) + PowerIndexOffset(%d) \n " , pDM_Odm - > BbSwingIdxOfdm , pDM_Odm - > BbSwingIdxOfdmBase , pDM_Odm - > RFCalibrateInfo . PowerIndexOffset ) ) ;
2015-02-20 00:51:33 +00:00
/* 4 7.1 Handle boundary conditions of index. */
2014-12-19 06:59:46 +00:00
2015-08-15 18:06:32 +00:00
for ( i = 0 ; i < rf ; i + + ) {
2015-08-15 18:02:34 +00:00
if ( pDM_Odm - > RFCalibrateInfo . OFDM_index [ i ] > OFDM_TABLE_SIZE_92D - 1 )
2014-12-19 06:59:46 +00:00
{
pDM_Odm - > RFCalibrateInfo . OFDM_index [ i ] = OFDM_TABLE_SIZE_92D - 1 ;
}
else if ( pDM_Odm - > RFCalibrateInfo . OFDM_index [ i ] < OFDM_min_index )
{
pDM_Odm - > RFCalibrateInfo . OFDM_index [ i ] = OFDM_min_index ;
}
}
2015-08-15 18:02:34 +00:00
if ( pDM_Odm - > RFCalibrateInfo . CCK_index > CCK_TABLE_SIZE - 1 )
2014-12-19 06:59:46 +00:00
pDM_Odm - > RFCalibrateInfo . CCK_index = CCK_TABLE_SIZE - 1 ;
2015-03-10 16:18:03 +00:00
} else {
2014-12-19 06:59:46 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_TX_PWR_TRACK , ODM_DBG_LOUD ,
( " The thermal meter is unchanged or TxPowerTracking OFF: ThermalValue: %d , pDM_Odm->RFCalibrateInfo.ThermalValue: %d) \n " , ThermalValue , pDM_Odm - > RFCalibrateInfo . ThermalValue ) ) ;
pDM_Odm - > RFCalibrateInfo . PowerIndexOffset = 0 ;
}
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_TX_PWR_TRACK , ODM_DBG_LOUD ,
( " TxPowerTracking: [CCK] Swing Current Index: %d, Swing Base Index: %d \n " , pDM_Odm - > RFCalibrateInfo . CCK_index , pDM_Odm - > BbSwingIdxCckBase ) ) ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_TX_PWR_TRACK , ODM_DBG_LOUD ,
( " TxPowerTracking: [OFDM] Swing Current Index: %d, Swing Base Index: %d \n " , pDM_Odm - > RFCalibrateInfo . OFDM_index [ RF_PATH_A ] , pDM_Odm - > BbSwingIdxOfdmBase ) ) ;
if ( pDM_Odm - > RFCalibrateInfo . PowerIndexOffset ! = 0 & & pDM_Odm - > RFCalibrateInfo . TxPowerTrackControl )
{
2015-02-20 00:51:33 +00:00
/* 4 7.2 Configure the Swing Table to adjust Tx Power. */
2015-03-02 23:25:27 +00:00
pDM_Odm - > RFCalibrateInfo . bTxPowerChanged = true ; /* Always true after Tx Power is adjusted by power tracking. */
2015-02-20 00:51:33 +00:00
/* */
/* 2012/04/23 MH According to Luke's suggestion, we can not write BB digital */
/* to increase TX power. Otherwise, EVM will be bad. */
/* */
/* 2012/04/25 MH Add for tx power tracking to set tx power in tx agc for 88E. */
2014-12-19 06:59:46 +00:00
if ( ThermalValue > pDM_Odm - > RFCalibrateInfo . ThermalValue )
{
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_TX_PWR_TRACK , ODM_DBG_LOUD ,
( " Temperature Increasing: delta_pi: %d , delta_t: %d, Now_t: %d, EFUSE_t: %d, Last_t: %d \n " ,
pDM_Odm - > RFCalibrateInfo . PowerIndexOffset , delta , ThermalValue , pHalData - > EEPROMThermalMeter , pDM_Odm - > RFCalibrateInfo . ThermalValue ) ) ;
}
2015-02-20 00:51:33 +00:00
else if ( ThermalValue < pDM_Odm - > RFCalibrateInfo . ThermalValue ) /* Low temperature */
2014-12-19 06:59:46 +00:00
{
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_TX_PWR_TRACK , ODM_DBG_LOUD ,
( " Temperature Decreasing: delta_pi: %d , delta_t: %d, Now_t: %d, EFUSE_t: %d, Last_t: %d \n " ,
pDM_Odm - > RFCalibrateInfo . PowerIndexOffset , delta , ThermalValue , pHalData - > EEPROMThermalMeter , pDM_Odm - > RFCalibrateInfo . ThermalValue ) ) ;
}
if ( ThermalValue > pHalData - > EEPROMThermalMeter )
{
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_TX_PWR_TRACK , ODM_DBG_LOUD , ( " Temperature(%d) hugher than PG value(%d), increases the power by TxAGC \n " , ThermalValue , pHalData - > EEPROMThermalMeter ) ) ;
odm_TxPwrTrackSetPwr88E ( pDM_Odm , TXAGC , 0 , 0 ) ;
}
else
{
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_TX_PWR_TRACK , ODM_DBG_LOUD , ( " Temperature(%d) lower than PG value(%d), increases the power by TxAGC \n " , ThermalValue , pHalData - > EEPROMThermalMeter ) ) ;
odm_TxPwrTrackSetPwr88E ( pDM_Odm , BBSWING , RF_PATH_A , Indexforchannel ) ;
2015-08-15 18:02:34 +00:00
/* if (is2T) */
2015-02-20 00:51:33 +00:00
/* odm_TxPwrTrackSetPwr88E(pDM_Odm, BBSWING, RF_PATH_B, Indexforchannel); */
2014-12-19 06:59:46 +00:00
}
pDM_Odm - > BbSwingIdxCckBase = pDM_Odm - > BbSwingIdxCck ;
pDM_Odm - > BbSwingIdxOfdmBase = pDM_Odm - > BbSwingIdxOfdm ;
pDM_Odm - > RFCalibrateInfo . ThermalValue = ThermalValue ;
}
2015-08-15 18:02:34 +00:00
/* if ((delta_IQK > pHalData->Delta_IQK) && (pHalData->Delta_IQK != 0)) */
2015-08-15 18:24:16 +00:00
if ( ( delta_IQK > = 8 ) ) { /* Delta temperature is equal to or larger than 20 centigrade. */
2015-02-20 00:51:33 +00:00
/* printk("delta_IQK(%d) >=8 do_IQK\n",delta_IQK); */
2014-12-19 06:59:46 +00:00
doIQK ( pDM_Odm , delta_IQK , ThermalValue , 8 ) ;
}
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_TX_PWR_TRACK , ODM_DBG_LOUD , ( " <===dm_TXPowerTrackingCallback_ThermalMeter_8188E \n " ) ) ;
pDM_Odm - > RFCalibrateInfo . TXPowercount = 0 ;
}
2015-02-20 00:51:33 +00:00
/* 1 7. IQK */
2014-12-19 06:59:46 +00:00
# define MAX_TOLERANCE 5
2015-02-20 00:51:33 +00:00
# define IQK_DELAY_TIME 1 /* ms */
2014-12-19 06:59:46 +00:00
2015-02-20 00:51:33 +00:00
static u8 /* bit0 = 1 => Tx OK, bit1 = 1 => Rx OK */
2014-12-19 06:59:46 +00:00
phy_PathA_IQK_8188E (
2015-03-13 17:06:38 +00:00
struct adapter * pAdapter ,
bool configPathB
2014-12-19 06:59:46 +00:00
)
{
2014-12-30 22:55:10 +00:00
u32 regEAC , regE94 , regE9C , regEA4 ;
2014-12-30 23:50:44 +00:00
u8 result = 0x00 ;
2014-12-19 06:59:46 +00:00
HAL_DATA_TYPE * pHalData = GET_HAL_DATA ( pAdapter ) ;
PDM_ODM_T pDM_Odm = & pHalData - > odmpriv ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " Path A IQK! \n " ) ) ;
2015-02-20 00:51:33 +00:00
/* 1 Tx IQK */
/* path-A IQK setting */
2014-12-19 06:59:46 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " Path-A IQK setting! \n " ) ) ;
ODM_SetBBReg ( pDM_Odm , rTx_IQK_Tone_A , bMaskDWord , 0x10008c1c ) ;
ODM_SetBBReg ( pDM_Odm , rRx_IQK_Tone_A , bMaskDWord , 0x30008c1c ) ;
ODM_SetBBReg ( pDM_Odm , rTx_IQK_PI_A , bMaskDWord , 0x8214032a ) ;
ODM_SetBBReg ( pDM_Odm , rRx_IQK_PI_A , bMaskDWord , 0x28160000 ) ;
2015-02-20 00:51:33 +00:00
/* LO calibration setting */
2014-12-19 06:59:46 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " LO calibration setting! \n " ) ) ;
ODM_SetBBReg ( pDM_Odm , rIQK_AGC_Rsp , bMaskDWord , 0x00462911 ) ;
2015-02-20 00:51:33 +00:00
/* One shot, path A LOK & IQK */
2014-12-19 06:59:46 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " One shot, path A LOK & IQK! \n " ) ) ;
ODM_SetBBReg ( pDM_Odm , rIQK_AGC_Pts , bMaskDWord , 0xf9000000 ) ;
ODM_SetBBReg ( pDM_Odm , rIQK_AGC_Pts , bMaskDWord , 0xf8000000 ) ;
2015-02-20 00:51:33 +00:00
/* delay x ms */
2014-12-19 06:59:46 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " Delay %d ms for One shot, path A LOK & IQK. \n " , IQK_DELAY_TIME_88E ) ) ;
2015-02-20 00:51:33 +00:00
/* PlatformStallExecution(IQK_DELAY_TIME_88E*1000); */
2014-12-19 06:59:46 +00:00
ODM_delay_ms ( IQK_DELAY_TIME_88E ) ;
2015-02-20 00:51:33 +00:00
/* Check failed */
2014-12-19 06:59:46 +00:00
regEAC = ODM_GetBBReg ( pDM_Odm , rRx_Power_After_IQK_A_2 , bMaskDWord ) ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " 0xeac = 0x%x \n " , regEAC ) ) ;
regE94 = ODM_GetBBReg ( pDM_Odm , rTx_Power_Before_IQK_A , bMaskDWord ) ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " 0xe94 = 0x%x \n " , regE94 ) ) ;
regE9C = ODM_GetBBReg ( pDM_Odm , rTx_Power_After_IQK_A , bMaskDWord ) ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " 0xe9c = 0x%x \n " , regE9C ) ) ;
regEA4 = ODM_GetBBReg ( pDM_Odm , rRx_Power_Before_IQK_A_2 , bMaskDWord ) ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " 0xea4 = 0x%x \n " , regEA4 ) ) ;
2015-08-15 18:02:34 +00:00
if ( ! ( regEAC & BIT28 ) & &
2014-12-19 06:59:46 +00:00
( ( ( regE94 & 0x03FF0000 ) > > 16 ) ! = 0x142 ) & &
( ( ( regE9C & 0x03FF0000 ) > > 16 ) ! = 0x42 ) )
result | = 0x01 ;
2015-02-20 00:51:33 +00:00
else /* if Tx not OK, ignore Rx */
2014-12-19 06:59:46 +00:00
return result ;
return result ;
2014-12-29 02:00:11 +00:00
}
2014-12-19 06:59:46 +00:00
2015-02-20 00:51:33 +00:00
static u8 /* bit0 = 1 => Tx OK, bit1 = 1 => Rx OK */
2014-12-19 06:59:46 +00:00
phy_PathA_RxIQK (
2015-03-13 17:06:38 +00:00
struct adapter * pAdapter ,
bool configPathB
2014-12-19 06:59:46 +00:00
)
{
2014-12-30 22:55:10 +00:00
u32 regEAC , regE94 , regE9C , regEA4 , u4tmp ;
2014-12-30 23:50:44 +00:00
u8 result = 0x00 ;
2014-12-19 06:59:46 +00:00
HAL_DATA_TYPE * pHalData = GET_HAL_DATA ( pAdapter ) ;
PDM_ODM_T pDM_Odm = & pHalData - > odmpriv ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " Path A Rx IQK! \n " ) ) ;
2015-02-20 00:51:33 +00:00
/* 1 Get TXIMR setting */
/* modify RXIQK mode table */
2014-12-19 06:59:46 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " Path-A Rx IQK modify RXIQK mode table! \n " ) ) ;
ODM_SetBBReg ( pDM_Odm , rFPGA0_IQK , bMaskDWord , 0x00000000 ) ;
ODM_SetRFReg ( pDM_Odm , RF_PATH_A , RF_WE_LUT , bRFRegOffsetMask , 0x800a0 ) ;
ODM_SetRFReg ( pDM_Odm , RF_PATH_A , RF_RCK_OS , bRFRegOffsetMask , 0x30000 ) ;
ODM_SetRFReg ( pDM_Odm , RF_PATH_A , RF_TXPA_G1 , bRFRegOffsetMask , 0x0000f ) ;
ODM_SetRFReg ( pDM_Odm , RF_PATH_A , RF_TXPA_G2 , bRFRegOffsetMask , 0xf117B ) ;
2015-02-20 00:51:33 +00:00
/* PA,PAD off */
2014-12-19 06:59:46 +00:00
ODM_SetRFReg ( pDM_Odm , RF_PATH_A , 0xdf , bRFRegOffsetMask , 0x980 ) ;
ODM_SetRFReg ( pDM_Odm , RF_PATH_A , 0x56 , bRFRegOffsetMask , 0x51000 ) ;
ODM_SetBBReg ( pDM_Odm , rFPGA0_IQK , bMaskDWord , 0x80800000 ) ;
2015-02-20 00:51:33 +00:00
/* IQK setting */
2014-12-19 06:59:46 +00:00
ODM_SetBBReg ( pDM_Odm , rTx_IQK , bMaskDWord , 0x01007c00 ) ;
ODM_SetBBReg ( pDM_Odm , rRx_IQK , bMaskDWord , 0x81004800 ) ;
2015-02-20 00:51:33 +00:00
/* path-A IQK setting */
2014-12-19 06:59:46 +00:00
ODM_SetBBReg ( pDM_Odm , rTx_IQK_Tone_A , bMaskDWord , 0x10008c1c ) ;
ODM_SetBBReg ( pDM_Odm , rRx_IQK_Tone_A , bMaskDWord , 0x30008c1c ) ;
ODM_SetBBReg ( pDM_Odm , rTx_IQK_PI_A , bMaskDWord , 0x82160c1f ) ;
ODM_SetBBReg ( pDM_Odm , rRx_IQK_PI_A , bMaskDWord , 0x28160000 ) ;
2015-02-20 00:51:33 +00:00
/* LO calibration setting */
2014-12-19 06:59:46 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " LO calibration setting! \n " ) ) ;
ODM_SetBBReg ( pDM_Odm , rIQK_AGC_Rsp , bMaskDWord , 0x0046a911 ) ;
2015-02-20 00:51:33 +00:00
/* One shot, path A LOK & IQK */
2014-12-19 06:59:46 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " One shot, path A LOK & IQK! \n " ) ) ;
ODM_SetBBReg ( pDM_Odm , rIQK_AGC_Pts , bMaskDWord , 0xf9000000 ) ;
ODM_SetBBReg ( pDM_Odm , rIQK_AGC_Pts , bMaskDWord , 0xf8000000 ) ;
2015-02-20 00:51:33 +00:00
/* delay x ms */
2014-12-19 06:59:46 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " Delay %d ms for One shot, path A LOK & IQK. \n " , IQK_DELAY_TIME_88E ) ) ;
2015-02-20 00:51:33 +00:00
/* PlatformStallExecution(IQK_DELAY_TIME_88E*1000); */
2014-12-19 06:59:46 +00:00
ODM_delay_ms ( IQK_DELAY_TIME_88E ) ;
2015-02-20 00:51:33 +00:00
/* Check failed */
2014-12-19 06:59:46 +00:00
regEAC = ODM_GetBBReg ( pDM_Odm , rRx_Power_After_IQK_A_2 , bMaskDWord ) ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " 0xeac = 0x%x \n " , regEAC ) ) ;
regE94 = ODM_GetBBReg ( pDM_Odm , rTx_Power_Before_IQK_A , bMaskDWord ) ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " 0xe94 = 0x%x \n " , regE94 ) ) ;
regE9C = ODM_GetBBReg ( pDM_Odm , rTx_Power_After_IQK_A , bMaskDWord ) ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " 0xe9c = 0x%x \n " , regE9C ) ) ;
2015-08-15 18:02:34 +00:00
if ( ! ( regEAC & BIT28 ) & &
2014-12-19 06:59:46 +00:00
( ( ( regE94 & 0x03FF0000 ) > > 16 ) ! = 0x142 ) & &
( ( ( regE9C & 0x03FF0000 ) > > 16 ) ! = 0x42 ) )
{
result | = 0x01 ;
}
else
{
2015-02-20 00:51:33 +00:00
/* reload RF 0xdf */
2014-12-19 06:59:46 +00:00
ODM_SetBBReg ( pDM_Odm , rFPGA0_IQK , bMaskDWord , 0x00000000 ) ;
2015-02-20 00:51:33 +00:00
ODM_SetRFReg ( pDM_Odm , RF_PATH_A , 0xdf , bRFRegOffsetMask , 0x180 ) ; /* if Tx not OK, ignore Rx */
2014-12-19 06:59:46 +00:00
return result ;
}
u4tmp = 0x80007C00 | ( regE94 & 0x3FF0000 ) | ( ( regE9C & 0x3FF0000 ) > > 16 ) ;
ODM_SetBBReg ( pDM_Odm , rTx_IQK , bMaskDWord , u4tmp ) ;
2015-08-15 18:00:19 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " 0xe40 = 0x%x u4tmp = 0x%x \n " , ODM_GetBBReg ( pDM_Odm , rTx_IQK , bMaskDWord ) , u4tmp ) ) ;
2014-12-19 06:59:46 +00:00
2015-02-20 00:51:33 +00:00
/* 1 RX IQK */
/* modify RXIQK mode table */
2014-12-19 06:59:46 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " Path-A Rx IQK modify RXIQK mode table 2! \n " ) ) ;
ODM_SetBBReg ( pDM_Odm , rFPGA0_IQK , bMaskDWord , 0x00000000 ) ;
ODM_SetRFReg ( pDM_Odm , RF_PATH_A , RF_WE_LUT , bRFRegOffsetMask , 0x800a0 ) ;
ODM_SetRFReg ( pDM_Odm , RF_PATH_A , RF_RCK_OS , bRFRegOffsetMask , 0x30000 ) ;
ODM_SetRFReg ( pDM_Odm , RF_PATH_A , RF_TXPA_G1 , bRFRegOffsetMask , 0x0000f ) ;
ODM_SetRFReg ( pDM_Odm , RF_PATH_A , RF_TXPA_G2 , bRFRegOffsetMask , 0xf7ffa ) ;
ODM_SetBBReg ( pDM_Odm , rFPGA0_IQK , bMaskDWord , 0x80800000 ) ;
2015-02-20 00:51:33 +00:00
/* IQK setting */
2014-12-19 06:59:46 +00:00
ODM_SetBBReg ( pDM_Odm , rRx_IQK , bMaskDWord , 0x01004800 ) ;
2015-02-20 00:51:33 +00:00
/* path-A IQK setting */
2014-12-19 06:59:46 +00:00
ODM_SetBBReg ( pDM_Odm , rTx_IQK_Tone_A , bMaskDWord , 0x38008c1c ) ;
ODM_SetBBReg ( pDM_Odm , rRx_IQK_Tone_A , bMaskDWord , 0x18008c1c ) ;
ODM_SetBBReg ( pDM_Odm , rTx_IQK_PI_A , bMaskDWord , 0x82160c05 ) ;
ODM_SetBBReg ( pDM_Odm , rRx_IQK_PI_A , bMaskDWord , 0x28160c1f ) ;
2015-02-20 00:51:33 +00:00
/* LO calibration setting */
2014-12-19 06:59:46 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " LO calibration setting! \n " ) ) ;
ODM_SetBBReg ( pDM_Odm , rIQK_AGC_Rsp , bMaskDWord , 0x0046a911 ) ;
2015-02-20 00:51:33 +00:00
/* One shot, path A LOK & IQK */
2014-12-19 06:59:46 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " One shot, path A LOK & IQK! \n " ) ) ;
ODM_SetBBReg ( pDM_Odm , rIQK_AGC_Pts , bMaskDWord , 0xf9000000 ) ;
ODM_SetBBReg ( pDM_Odm , rIQK_AGC_Pts , bMaskDWord , 0xf8000000 ) ;
2015-02-20 00:51:33 +00:00
/* delay x ms */
2014-12-19 06:59:46 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " Delay %d ms for One shot, path A LOK & IQK. \n " , IQK_DELAY_TIME_88E ) ) ;
2015-02-20 00:51:33 +00:00
/* PlatformStallExecution(IQK_DELAY_TIME_88E*1000); */
2014-12-19 06:59:46 +00:00
ODM_delay_ms ( IQK_DELAY_TIME_88E ) ;
2015-02-20 00:51:33 +00:00
/* Check failed */
2014-12-19 06:59:46 +00:00
regEAC = ODM_GetBBReg ( pDM_Odm , rRx_Power_After_IQK_A_2 , bMaskDWord ) ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " 0xeac = 0x%x \n " , regEAC ) ) ;
regE94 = ODM_GetBBReg ( pDM_Odm , rTx_Power_Before_IQK_A , bMaskDWord ) ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " 0xe94 = 0x%x \n " , regE94 ) ) ;
regE9C = ODM_GetBBReg ( pDM_Odm , rTx_Power_After_IQK_A , bMaskDWord ) ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " 0xe9c = 0x%x \n " , regE9C ) ) ;
regEA4 = ODM_GetBBReg ( pDM_Odm , rRx_Power_Before_IQK_A_2 , bMaskDWord ) ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " 0xea4 = 0x%x \n " , regEA4 ) ) ;
2015-02-20 00:51:33 +00:00
/* reload RF 0xdf */
2014-12-19 06:59:46 +00:00
ODM_SetBBReg ( pDM_Odm , rFPGA0_IQK , bMaskDWord , 0x00000000 ) ;
ODM_SetRFReg ( pDM_Odm , RF_PATH_A , 0xdf , bRFRegOffsetMask , 0x180 ) ;
2015-08-15 18:02:34 +00:00
if ( ! ( regEAC & BIT27 ) & & /* if Tx is OK, check whether Rx is OK */
2014-12-19 06:59:46 +00:00
( ( ( regEA4 & 0x03FF0000 ) > > 16 ) ! = 0x132 ) & &
( ( ( regEAC & 0x03FF0000 ) > > 16 ) ! = 0x36 ) )
result | = 0x02 ;
else
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " Path A Rx IQK fail!! \n " ) ) ;
return result ;
}
2015-02-20 00:51:33 +00:00
static u8 /* bit0 = 1 => Tx OK, bit1 = 1 => Rx OK */
2014-12-19 06:59:46 +00:00
phy_PathB_IQK_8188E (
2015-03-13 17:06:38 +00:00
struct adapter * pAdapter
2014-12-19 06:59:46 +00:00
)
{
2014-12-30 22:55:10 +00:00
u32 regEAC , regEB4 , regEBC , regEC4 , regECC ;
2014-12-30 23:50:44 +00:00
u8 result = 0x00 ;
2014-12-19 06:59:46 +00:00
HAL_DATA_TYPE * pHalData = GET_HAL_DATA ( pAdapter ) ;
PDM_ODM_T pDM_Odm = & pHalData - > odmpriv ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " Path B IQK! \n " ) ) ;
2015-02-20 00:51:33 +00:00
/* One shot, path B LOK & IQK */
2014-12-19 06:59:46 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " One shot, path A LOK & IQK! \n " ) ) ;
ODM_SetBBReg ( pDM_Odm , rIQK_AGC_Cont , bMaskDWord , 0x00000002 ) ;
ODM_SetBBReg ( pDM_Odm , rIQK_AGC_Cont , bMaskDWord , 0x00000000 ) ;
2015-02-20 00:51:33 +00:00
/* delay x ms */
2014-12-19 06:59:46 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " Delay %d ms for One shot, path B LOK & IQK. \n " , IQK_DELAY_TIME_88E ) ) ;
2015-02-20 00:51:33 +00:00
/* PlatformStallExecution(IQK_DELAY_TIME_88E*1000); */
2014-12-19 06:59:46 +00:00
ODM_delay_ms ( IQK_DELAY_TIME_88E ) ;
2015-02-20 00:51:33 +00:00
/* Check failed */
2014-12-19 06:59:46 +00:00
regEAC = ODM_GetBBReg ( pDM_Odm , rRx_Power_After_IQK_A_2 , bMaskDWord ) ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " 0xeac = 0x%x \n " , regEAC ) ) ;
regEB4 = ODM_GetBBReg ( pDM_Odm , rTx_Power_Before_IQK_B , bMaskDWord ) ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " 0xeb4 = 0x%x \n " , regEB4 ) ) ;
regEBC = ODM_GetBBReg ( pDM_Odm , rTx_Power_After_IQK_B , bMaskDWord ) ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " 0xebc = 0x%x \n " , regEBC ) ) ;
regEC4 = ODM_GetBBReg ( pDM_Odm , rRx_Power_Before_IQK_B_2 , bMaskDWord ) ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " 0xec4 = 0x%x \n " , regEC4 ) ) ;
regECC = ODM_GetBBReg ( pDM_Odm , rRx_Power_After_IQK_B_2 , bMaskDWord ) ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " 0xecc = 0x%x \n " , regECC ) ) ;
2015-08-15 18:02:34 +00:00
if ( ! ( regEAC & BIT31 ) & &
2014-12-19 06:59:46 +00:00
( ( ( regEB4 & 0x03FF0000 ) > > 16 ) ! = 0x142 ) & &
( ( ( regEBC & 0x03FF0000 ) > > 16 ) ! = 0x42 ) )
result | = 0x01 ;
else
return result ;
2015-08-15 18:02:34 +00:00
if ( ! ( regEAC & BIT30 ) & &
2014-12-19 06:59:46 +00:00
( ( ( regEC4 & 0x03FF0000 ) > > 16 ) ! = 0x132 ) & &
( ( ( regECC & 0x03FF0000 ) > > 16 ) ! = 0x36 ) )
result | = 0x02 ;
else
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " Path B Rx IQK fail!! \n " ) ) ;
return result ;
}
2015-01-29 21:27:28 +00:00
static void
2014-12-19 06:59:46 +00:00
_PHY_PathAFillIQKMatrix (
2015-03-13 17:06:38 +00:00
struct adapter * pAdapter ,
bool bIQKOK ,
s32 result [ ] [ 8 ] ,
u8 final_candidate ,
bool bTxOnly
2014-12-19 06:59:46 +00:00
)
{
2014-12-30 22:55:10 +00:00
u32 Oldval_0 , X , TX0_A , reg ;
2014-12-30 23:58:53 +00:00
s32 Y , TX0_C ;
2014-12-19 06:59:46 +00:00
HAL_DATA_TYPE * pHalData = GET_HAL_DATA ( pAdapter ) ;
PDM_ODM_T pDM_Odm = & pHalData - > odmpriv ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " Path A IQ Calibration %s ! \n " , ( bIQKOK ) ? " Success " : " Failed " ) ) ;
2015-08-15 18:02:34 +00:00
if ( final_candidate = = 0xFF )
2014-12-19 06:59:46 +00:00
return ;
2015-08-15 18:02:34 +00:00
else if ( bIQKOK )
2014-12-19 06:59:46 +00:00
{
Oldval_0 = ( ODM_GetBBReg ( pDM_Odm , rOFDM0_XATxIQImbalance , bMaskDWord ) > > 22 ) & 0x3FF ;
X = result [ final_candidate ] [ 0 ] ;
if ( ( X & 0x00000200 ) ! = 0 )
X = X | 0xFFFFFC00 ;
TX0_A = ( X * Oldval_0 ) > > 8 ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " X = 0x%x, TX0_A = 0x%x, Oldval_0 0x%x \n " , X , TX0_A , Oldval_0 ) ) ;
ODM_SetBBReg ( pDM_Odm , rOFDM0_XATxIQImbalance , 0x3FF , TX0_A ) ;
ODM_SetBBReg ( pDM_Odm , rOFDM0_ECCAThreshold , BIT ( 31 ) , ( ( X * Oldval_0 > > 7 ) & 0x1 ) ) ;
Y = result [ final_candidate ] [ 1 ] ;
if ( ( Y & 0x00000200 ) ! = 0 )
Y = Y | 0xFFFFFC00 ;
TX0_C = ( Y * Oldval_0 ) > > 8 ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " Y = 0x%x, TX = 0x%x \n " , Y , TX0_C ) ) ;
ODM_SetBBReg ( pDM_Odm , rOFDM0_XCTxAFE , 0xF0000000 , ( ( TX0_C & 0x3C0 ) > > 6 ) ) ;
ODM_SetBBReg ( pDM_Odm , rOFDM0_XATxIQImbalance , 0x003F0000 , ( TX0_C & 0x3F ) ) ;
ODM_SetBBReg ( pDM_Odm , rOFDM0_ECCAThreshold , BIT ( 29 ) , ( ( Y * Oldval_0 > > 7 ) & 0x1 ) ) ;
2015-08-15 18:02:34 +00:00
if ( bTxOnly )
2014-12-19 06:59:46 +00:00
{
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " _PHY_PathAFillIQKMatrix only Tx OK \n " ) ) ;
return ;
}
reg = result [ final_candidate ] [ 2 ] ;
ODM_SetBBReg ( pDM_Odm , rOFDM0_XARxIQImbalance , 0x3FF , reg ) ;
reg = result [ final_candidate ] [ 3 ] & 0x3F ;
ODM_SetBBReg ( pDM_Odm , rOFDM0_XARxIQImbalance , 0xFC00 , reg ) ;
reg = ( result [ final_candidate ] [ 3 ] > > 6 ) & 0xF ;
ODM_SetBBReg ( pDM_Odm , rOFDM0_RxIQExtAnta , 0xF0000000 , reg ) ;
}
}
2015-01-29 21:27:28 +00:00
static void
2014-12-19 06:59:46 +00:00
_PHY_PathBFillIQKMatrix (
2015-03-13 17:06:38 +00:00
struct adapter * pAdapter ,
bool bIQKOK ,
s32 result [ ] [ 8 ] ,
u8 final_candidate ,
bool bTxOnly /* do Tx only */
2014-12-19 06:59:46 +00:00
)
{
2014-12-30 22:55:10 +00:00
u32 Oldval_1 , X , TX1_A , reg ;
2014-12-30 23:58:53 +00:00
s32 Y , TX1_C ;
2014-12-19 06:59:46 +00:00
HAL_DATA_TYPE * pHalData = GET_HAL_DATA ( pAdapter ) ;
PDM_ODM_T pDM_Odm = & pHalData - > odmpriv ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " Path B IQ Calibration %s ! \n " , ( bIQKOK ) ? " Success " : " Failed " ) ) ;
2015-08-15 18:02:34 +00:00
if ( final_candidate = = 0xFF )
2014-12-19 06:59:46 +00:00
return ;
2015-08-15 18:02:34 +00:00
else if ( bIQKOK )
2014-12-19 06:59:46 +00:00
{
Oldval_1 = ( ODM_GetBBReg ( pDM_Odm , rOFDM0_XBTxIQImbalance , bMaskDWord ) > > 22 ) & 0x3FF ;
X = result [ final_candidate ] [ 4 ] ;
if ( ( X & 0x00000200 ) ! = 0 )
X = X | 0xFFFFFC00 ;
TX1_A = ( X * Oldval_1 ) > > 8 ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " X = 0x%x, TX1_A = 0x%x \n " , X , TX1_A ) ) ;
ODM_SetBBReg ( pDM_Odm , rOFDM0_XBTxIQImbalance , 0x3FF , TX1_A ) ;
ODM_SetBBReg ( pDM_Odm , rOFDM0_ECCAThreshold , BIT ( 27 ) , ( ( X * Oldval_1 > > 7 ) & 0x1 ) ) ;
Y = result [ final_candidate ] [ 5 ] ;
if ( ( Y & 0x00000200 ) ! = 0 )
Y = Y | 0xFFFFFC00 ;
TX1_C = ( Y * Oldval_1 ) > > 8 ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " Y = 0x%x, TX1_C = 0x%x \n " , Y , TX1_C ) ) ;
ODM_SetBBReg ( pDM_Odm , rOFDM0_XDTxAFE , 0xF0000000 , ( ( TX1_C & 0x3C0 ) > > 6 ) ) ;
ODM_SetBBReg ( pDM_Odm , rOFDM0_XBTxIQImbalance , 0x003F0000 , ( TX1_C & 0x3F ) ) ;
ODM_SetBBReg ( pDM_Odm , rOFDM0_ECCAThreshold , BIT ( 25 ) , ( ( Y * Oldval_1 > > 7 ) & 0x1 ) ) ;
2015-08-15 18:02:34 +00:00
if ( bTxOnly )
2014-12-19 06:59:46 +00:00
return ;
reg = result [ final_candidate ] [ 6 ] ;
ODM_SetBBReg ( pDM_Odm , rOFDM0_XBRxIQImbalance , 0x3FF , reg ) ;
reg = result [ final_candidate ] [ 7 ] & 0x3F ;
ODM_SetBBReg ( pDM_Odm , rOFDM0_XBRxIQImbalance , 0xFC00 , reg ) ;
reg = ( result [ final_candidate ] [ 7 ] > > 6 ) & 0xF ;
ODM_SetBBReg ( pDM_Odm , rOFDM0_AGCRSSITable , 0x0000F000 , reg ) ;
}
}
2015-02-20 00:51:33 +00:00
/* */
/* 2011/07/26 MH Add an API for testing IQK fail case. */
/* */
/* MP Already declare in odm.c */
2015-03-02 23:21:23 +00:00
static bool
2014-12-19 06:59:46 +00:00
ODM_CheckPowerStatus (
2015-03-13 17:06:38 +00:00
struct adapter * Adapter )
2014-12-19 06:59:46 +00:00
{
2015-03-02 23:25:27 +00:00
return true ;
2014-12-19 06:59:46 +00:00
}
2014-12-29 02:06:17 +00:00
void
2014-12-19 06:59:46 +00:00
_PHY_SaveADDARegisters (
2015-03-13 17:06:38 +00:00
struct adapter * pAdapter ,
u32 * ADDAReg ,
u32 * ADDABackup ,
u32 RegisterNum
2014-12-19 06:59:46 +00:00
)
{
2014-12-30 22:55:10 +00:00
u32 i ;
2014-12-19 06:59:46 +00:00
HAL_DATA_TYPE * pHalData = GET_HAL_DATA ( pAdapter ) ;
PDM_ODM_T pDM_Odm = & pHalData - > odmpriv ;
2015-03-02 23:25:27 +00:00
if ( ODM_CheckPowerStatus ( pAdapter ) = = false )
2014-12-19 06:59:46 +00:00
return ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " Save ADDA parameters. \n " ) ) ;
2015-08-15 18:24:16 +00:00
for ( i = 0 ; i < RegisterNum ; i + + ) {
2014-12-19 06:59:46 +00:00
ADDABackup [ i ] = ODM_GetBBReg ( pDM_Odm , ADDAReg [ i ] , bMaskDWord ) ;
}
}
2015-01-29 21:27:28 +00:00
static void
2014-12-19 06:59:46 +00:00
_PHY_SaveMACRegisters (
2015-03-13 17:06:38 +00:00
struct adapter * pAdapter ,
u32 * MACReg ,
u32 * MACBackup
2014-12-19 06:59:46 +00:00
)
{
2014-12-30 22:55:10 +00:00
u32 i ;
2014-12-19 06:59:46 +00:00
HAL_DATA_TYPE * pHalData = GET_HAL_DATA ( pAdapter ) ;
PDM_ODM_T pDM_Odm = & pHalData - > odmpriv ;
2014-12-30 19:48:00 +00:00
2014-12-19 06:59:46 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " Save MAC parameters. \n " ) ) ;
2015-08-15 18:24:16 +00:00
for ( i = 0 ; i < ( IQK_MAC_REG_NUM - 1 ) ; i + + ) {
2014-12-19 06:59:46 +00:00
MACBackup [ i ] = ODM_Read1Byte ( pDM_Odm , MACReg [ i ] ) ;
}
MACBackup [ i ] = ODM_Read4Byte ( pDM_Odm , MACReg [ i ] ) ;
}
2015-01-29 21:27:28 +00:00
static void
2014-12-19 06:59:46 +00:00
_PHY_ReloadADDARegisters (
2015-03-13 17:06:38 +00:00
struct adapter * pAdapter ,
u32 * ADDAReg ,
u32 * ADDABackup ,
u32 RegiesterNum
2014-12-19 06:59:46 +00:00
)
{
2014-12-30 22:55:10 +00:00
u32 i ;
2014-12-19 06:59:46 +00:00
HAL_DATA_TYPE * pHalData = GET_HAL_DATA ( pAdapter ) ;
PDM_ODM_T pDM_Odm = & pHalData - > odmpriv ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " Reload ADDA power saving parameters ! \n " ) ) ;
2015-08-15 18:06:32 +00:00
for ( i = 0 ; i < RegiesterNum ; i + + )
2014-12-19 06:59:46 +00:00
{
ODM_SetBBReg ( pDM_Odm , ADDAReg [ i ] , bMaskDWord , ADDABackup [ i ] ) ;
}
}
2015-01-29 21:27:28 +00:00
static void
2014-12-19 06:59:46 +00:00
_PHY_ReloadMACRegisters (
2015-03-13 17:06:38 +00:00
struct adapter * pAdapter ,
u32 * MACReg ,
u32 * MACBackup
2014-12-19 06:59:46 +00:00
)
{
2014-12-30 22:55:10 +00:00
u32 i ;
2014-12-19 06:59:46 +00:00
HAL_DATA_TYPE * pHalData = GET_HAL_DATA ( pAdapter ) ;
PDM_ODM_T pDM_Odm = & pHalData - > odmpriv ;
2014-12-30 19:48:00 +00:00
2014-12-19 06:59:46 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " Reload MAC parameters ! \n " ) ) ;
2015-08-15 18:24:16 +00:00
for ( i = 0 ; i < ( IQK_MAC_REG_NUM - 1 ) ; i + + ) {
2014-12-30 23:50:44 +00:00
ODM_Write1Byte ( pDM_Odm , MACReg [ i ] , ( u8 ) MACBackup [ i ] ) ;
2014-12-19 06:59:46 +00:00
}
ODM_Write4Byte ( pDM_Odm , MACReg [ i ] , MACBackup [ i ] ) ;
}
2014-12-29 02:06:17 +00:00
void
2014-12-19 06:59:46 +00:00
_PHY_PathADDAOn (
2015-03-13 17:06:38 +00:00
struct adapter * pAdapter ,
u32 * ADDAReg ,
bool isPathAOn ,
bool is2T
2014-12-19 06:59:46 +00:00
)
{
2014-12-30 22:55:10 +00:00
u32 pathOn ;
u32 i ;
2014-12-19 06:59:46 +00:00
HAL_DATA_TYPE * pHalData = GET_HAL_DATA ( pAdapter ) ;
PDM_ODM_T pDM_Odm = & pHalData - > odmpriv ;
2014-12-30 19:48:00 +00:00
2014-12-19 06:59:46 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " ADDA ON. \n " ) ) ;
pathOn = isPathAOn ? 0x04db25a4 : 0x0b1b25a4 ;
2015-08-15 18:24:16 +00:00
if ( false = = is2T ) {
2014-12-19 06:59:46 +00:00
pathOn = 0x0bdb25a0 ;
ODM_SetBBReg ( pDM_Odm , ADDAReg [ 0 ] , bMaskDWord , 0x0b1b25a0 ) ;
}
2015-08-15 18:27:00 +00:00
else {
2014-12-19 06:59:46 +00:00
ODM_SetBBReg ( pDM_Odm , ADDAReg [ 0 ] , bMaskDWord , pathOn ) ;
}
2015-08-15 18:24:16 +00:00
for ( i = 1 ; i < IQK_ADDA_REG_NUM ; i + + ) {
2014-12-19 06:59:46 +00:00
ODM_SetBBReg ( pDM_Odm , ADDAReg [ i ] , bMaskDWord , pathOn ) ;
}
}
2014-12-29 02:06:17 +00:00
void
2014-12-19 06:59:46 +00:00
_PHY_MACSettingCalibration (
2015-03-13 17:06:38 +00:00
struct adapter * pAdapter ,
u32 * MACReg ,
u32 * MACBackup
2014-12-19 06:59:46 +00:00
)
{
2014-12-30 22:55:10 +00:00
u32 i = 0 ;
2014-12-19 06:59:46 +00:00
HAL_DATA_TYPE * pHalData = GET_HAL_DATA ( pAdapter ) ;
PDM_ODM_T pDM_Odm = & pHalData - > odmpriv ;
2014-12-30 19:48:00 +00:00
2014-12-19 06:59:46 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " MAC settings for Calibration. \n " ) ) ;
ODM_Write1Byte ( pDM_Odm , MACReg [ i ] , 0x3F ) ;
2015-08-15 18:24:16 +00:00
for ( i = 1 ; i < ( IQK_MAC_REG_NUM - 1 ) ; i + + ) {
2014-12-30 23:50:44 +00:00
ODM_Write1Byte ( pDM_Odm , MACReg [ i ] , ( u8 ) ( MACBackup [ i ] & ( ~ BIT3 ) ) ) ;
2014-12-19 06:59:46 +00:00
}
2014-12-30 23:50:44 +00:00
ODM_Write1Byte ( pDM_Odm , MACReg [ i ] , ( u8 ) ( MACBackup [ i ] & ( ~ BIT5 ) ) ) ;
2014-12-19 06:59:46 +00:00
}
2014-12-29 02:06:17 +00:00
void
2014-12-19 06:59:46 +00:00
_PHY_PathAStandBy (
2015-03-13 17:06:38 +00:00
struct adapter * pAdapter
2014-12-19 06:59:46 +00:00
)
{
HAL_DATA_TYPE * pHalData = GET_HAL_DATA ( pAdapter ) ;
PDM_ODM_T pDM_Odm = & pHalData - > odmpriv ;
2014-12-30 19:48:00 +00:00
2014-12-19 06:59:46 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " Path-A standby mode! \n " ) ) ;
ODM_SetBBReg ( pDM_Odm , rFPGA0_IQK , bMaskDWord , 0x0 ) ;
ODM_SetBBReg ( pDM_Odm , 0x840 , bMaskDWord , 0x00010000 ) ;
ODM_SetBBReg ( pDM_Odm , rFPGA0_IQK , bMaskDWord , 0x80800000 ) ;
}
2015-01-29 21:27:28 +00:00
static void
2014-12-19 06:59:46 +00:00
_PHY_PIModeSwitch (
2015-03-13 17:06:38 +00:00
struct adapter * pAdapter ,
bool PIMode
2014-12-19 06:59:46 +00:00
)
{
2014-12-30 22:55:10 +00:00
u32 mode ;
2014-12-19 06:59:46 +00:00
HAL_DATA_TYPE * pHalData = GET_HAL_DATA ( pAdapter ) ;
PDM_ODM_T pDM_Odm = & pHalData - > odmpriv ;
2014-12-30 19:48:00 +00:00
2014-12-19 06:59:46 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " BB Switch to %s mode! \n " , ( PIMode ? " PI " : " SI " ) ) ) ;
mode = PIMode ? 0x01000100 : 0x01000000 ;
ODM_SetBBReg ( pDM_Odm , rFPGA0_XA_HSSIParameter1 , bMaskDWord , mode ) ;
ODM_SetBBReg ( pDM_Odm , rFPGA0_XB_HSSIParameter1 , bMaskDWord , mode ) ;
}
2015-03-02 23:21:23 +00:00
static bool
2014-12-19 06:59:46 +00:00
phy_SimularityCompare_8188E (
2015-03-13 17:06:38 +00:00
struct adapter * pAdapter ,
s32 result [ ] [ 8 ] ,
u8 c1 ,
u8 c2
2014-12-19 06:59:46 +00:00
)
{
2014-12-30 22:55:10 +00:00
u32 i , j , diff , SimularityBitMap , bound = 0 ;
2014-12-19 06:59:46 +00:00
HAL_DATA_TYPE * pHalData = GET_HAL_DATA ( pAdapter ) ;
PDM_ODM_T pDM_Odm = & pHalData - > odmpriv ;
2015-02-20 00:51:33 +00:00
u8 final_candidate [ 2 ] = { 0xFF , 0xFF } ; /* for path A and path B */
2015-03-02 23:25:27 +00:00
bool bResult = true ;
2015-03-02 23:21:23 +00:00
bool is2T ;
2014-12-30 23:58:53 +00:00
s32 tmp1 = 0 , tmp2 = 0 ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:02:34 +00:00
if ( ( pDM_Odm - > RFType = = ODM_2T2R ) | | ( pDM_Odm - > RFType = = ODM_2T3R ) | | ( pDM_Odm - > RFType = = ODM_2T4R ) )
2015-03-02 23:25:27 +00:00
is2T = true ;
2014-12-19 06:59:46 +00:00
else
2015-03-02 23:25:27 +00:00
is2T = false ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:02:34 +00:00
if ( is2T )
2014-12-19 06:59:46 +00:00
bound = 8 ;
else
bound = 4 ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " ===> IQK:phy_SimularityCompare_8188E c1 %d c2 %d!!! \n " , c1 , c2 ) ) ;
SimularityBitMap = 0 ;
2015-08-15 18:06:32 +00:00
for ( i = 0 ; i < bound ; i + + )
2014-12-19 06:59:46 +00:00
{
2015-02-20 00:51:33 +00:00
/* diff = (result[c1][i] > result[c2][i]) ? (result[c1][i] - result[c2][i]) : (result[c2][i] - result[c1][i]); */
2015-08-15 18:02:34 +00:00
if ( ( i = = 1 ) | | ( i = = 3 ) | | ( i = = 5 ) | | ( i = = 7 ) )
2014-12-19 06:59:46 +00:00
{
2015-08-15 18:02:34 +00:00
if ( ( result [ c1 ] [ i ] & 0x00000200 ) ! = 0 )
2014-12-19 06:59:46 +00:00
tmp1 = result [ c1 ] [ i ] | 0xFFFFFC00 ;
else
tmp1 = result [ c1 ] [ i ] ;
2015-08-15 18:02:34 +00:00
if ( ( result [ c2 ] [ i ] & 0x00000200 ) ! = 0 )
2014-12-19 06:59:46 +00:00
tmp2 = result [ c2 ] [ i ] | 0xFFFFFC00 ;
else
tmp2 = result [ c2 ] [ i ] ;
}
else
{
tmp1 = result [ c1 ] [ i ] ;
tmp2 = result [ c2 ] [ i ] ;
}
diff = ( tmp1 > tmp2 ) ? ( tmp1 - tmp2 ) : ( tmp2 - tmp1 ) ;
if ( diff > MAX_TOLERANCE )
{
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " IQK:phy_SimularityCompare_8188E differnece overflow index %d compare1 0x%x compare2 0x%x!!! \n " , i , result [ c1 ] [ i ] , result [ c2 ] [ i ] ) ) ;
2015-08-15 18:02:34 +00:00
if ( ( i = = 2 | | i = = 6 ) & & ! SimularityBitMap )
2014-12-19 06:59:46 +00:00
{
2015-08-15 18:02:34 +00:00
if ( result [ c1 ] [ i ] + result [ c1 ] [ i + 1 ] = = 0 )
2014-12-19 06:59:46 +00:00
final_candidate [ ( i / 4 ) ] = c2 ;
else if ( result [ c2 ] [ i ] + result [ c2 ] [ i + 1 ] = = 0 )
final_candidate [ ( i / 4 ) ] = c1 ;
else
SimularityBitMap = SimularityBitMap | ( 1 < < i ) ;
}
else
SimularityBitMap = SimularityBitMap | ( 1 < < i ) ;
}
}
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " IQK:phy_SimularityCompare_8188E SimularityBitMap %d !!! \n " , SimularityBitMap ) ) ;
if ( SimularityBitMap = = 0 )
{
2015-08-15 18:06:32 +00:00
for ( i = 0 ; i < ( bound / 4 ) ; i + + )
2014-12-19 06:59:46 +00:00
{
2015-08-15 18:02:34 +00:00
if ( final_candidate [ i ] ! = 0xFF )
2014-12-19 06:59:46 +00:00
{
2015-08-15 18:06:32 +00:00
for ( j = i * 4 ; j < ( i + 1 ) * 4 - 2 ; j + + )
2014-12-19 06:59:46 +00:00
result [ 3 ] [ j ] = result [ final_candidate [ i ] ] [ j ] ;
2015-03-02 23:25:27 +00:00
bResult = false ;
2014-12-19 06:59:46 +00:00
}
}
return bResult ;
}
else
{
2015-03-10 16:18:03 +00:00
if ( ! ( SimularityBitMap & 0x03 ) ) /* path A TX OK */
{
2015-08-15 18:06:32 +00:00
for ( i = 0 ; i < 2 ; i + + )
2015-03-10 16:18:03 +00:00
result [ 3 ] [ i ] = result [ c1 ] [ i ] ;
}
2014-12-19 06:59:46 +00:00
2015-03-10 16:18:03 +00:00
if ( ! ( SimularityBitMap & 0x0c ) ) /* path A RX OK */
{
2015-08-15 18:06:32 +00:00
for ( i = 2 ; i < 4 ; i + + )
2015-03-10 16:18:03 +00:00
result [ 3 ] [ i ] = result [ c1 ] [ i ] ;
}
2014-12-19 06:59:46 +00:00
2015-03-10 16:18:03 +00:00
if ( ! ( SimularityBitMap & 0x30 ) ) /* path B TX OK */
{
2015-08-15 18:06:32 +00:00
for ( i = 4 ; i < 6 ; i + + )
2015-03-10 16:18:03 +00:00
result [ 3 ] [ i ] = result [ c1 ] [ i ] ;
}
2014-12-19 06:59:46 +00:00
2015-03-10 16:18:03 +00:00
if ( ! ( SimularityBitMap & 0xc0 ) ) /* path B RX OK */
{
2015-08-15 18:06:32 +00:00
for ( i = 6 ; i < 8 ; i + + )
2015-03-10 16:18:03 +00:00
result [ 3 ] [ i ] = result [ c1 ] [ i ] ;
}
2014-12-19 06:59:46 +00:00
2015-03-10 16:18:03 +00:00
return false ;
2014-12-19 06:59:46 +00:00
}
}
2015-01-29 21:27:28 +00:00
static void
2014-12-19 06:59:46 +00:00
phy_IQCalibrate_8188E (
2015-03-13 17:06:38 +00:00
struct adapter * pAdapter ,
s32 result [ ] [ 8 ] ,
u8 t ,
bool is2T
2014-12-19 06:59:46 +00:00
)
{
HAL_DATA_TYPE * pHalData = GET_HAL_DATA ( pAdapter ) ;
PDM_ODM_T pDM_Odm = & pHalData - > odmpriv ;
2014-12-30 22:55:10 +00:00
u32 i ;
2014-12-30 23:50:44 +00:00
u8 PathAOK , PathBOK ;
2014-12-30 22:55:10 +00:00
u32 ADDA_REG [ IQK_ADDA_REG_NUM ] = {
2014-12-19 06:59:46 +00:00
rFPGA0_XCD_SwitchControl , rBlue_Tooth ,
rRx_Wait_CCA , rTx_CCK_RFON ,
rTx_CCK_BBON , rTx_OFDM_RFON ,
rTx_OFDM_BBON , rTx_To_Rx ,
rTx_To_Tx , rRx_CCK ,
rRx_OFDM , rRx_Wait_RIFS ,
rRx_TO_Rx , rStandby ,
rSleep , rPMPD_ANAEN } ;
2014-12-30 22:55:10 +00:00
u32 IQK_MAC_REG [ IQK_MAC_REG_NUM ] = {
2014-12-19 06:59:46 +00:00
REG_TXPAUSE , REG_BCN_CTRL ,
REG_BCN_CTRL_1 , REG_GPIO_MUXCFG } ;
2015-02-20 00:51:33 +00:00
/* since 92C & 92D have the different define in IQK_BB_REG */
2014-12-30 22:55:10 +00:00
u32 IQK_BB_REG_92C [ IQK_BB_REG_NUM ] = {
2014-12-19 06:59:46 +00:00
rOFDM0_TRxPathEnable , rOFDM0_TRMuxPar ,
rFPGA0_XCD_RFInterfaceSW , rConfig_AntA , rConfig_AntB ,
rFPGA0_XAB_RFInterfaceSW , rFPGA0_XA_RFInterfaceOE ,
rFPGA0_XB_RFInterfaceOE , rFPGA0_RFMOD
} ;
# if MP_DRIVER
2014-12-30 22:55:10 +00:00
u32 retryCount = 9 ;
2014-12-19 06:59:46 +00:00
# else
2014-12-30 22:55:10 +00:00
u32 retryCount = 2 ;
2014-12-19 06:59:46 +00:00
# endif
2015-03-10 16:18:03 +00:00
if ( * ( pDM_Odm - > mp_mode ) = = 1 )
retryCount = 9 ;
2018-02-27 13:58:15 +00:00
else
2014-12-19 06:59:46 +00:00
retryCount = 2 ;
2015-02-20 00:51:33 +00:00
/* Note: IQ calibration must be performed after loading */
/* PHY_REG.txt , and radio_a, radio_b.txt */
2014-12-19 06:59:46 +00:00
2015-08-15 18:22:58 +00:00
if ( t = = 0 ) {
2014-12-30 19:48:00 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " IQ Calibration for %s for %d times \n " , ( is2T ? " 2T2R " : " 1T1R " ) , t ) ) ;
2014-12-19 06:59:46 +00:00
2015-02-20 00:51:33 +00:00
/* Save ADDA parameters, turn Path A ADDA on */
2014-12-19 06:59:46 +00:00
_PHY_SaveADDARegisters ( pAdapter , ADDA_REG , pDM_Odm - > RFCalibrateInfo . ADDA_backup , IQK_ADDA_REG_NUM ) ;
_PHY_SaveMACRegisters ( pAdapter , IQK_MAC_REG , pDM_Odm - > RFCalibrateInfo . IQK_MAC_backup ) ;
_PHY_SaveADDARegisters ( pAdapter , IQK_BB_REG_92C , pDM_Odm - > RFCalibrateInfo . IQK_BB_backup , IQK_BB_REG_NUM ) ;
}
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " IQ Calibration for %s for %d times \n " , ( is2T ? " 2T2R " : " 1T1R " ) , t ) ) ;
2015-03-02 23:25:27 +00:00
_PHY_PathADDAOn ( pAdapter , ADDA_REG , true , is2T ) ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:22:58 +00:00
if ( t = = 0 ) {
2014-12-30 23:50:44 +00:00
pDM_Odm - > RFCalibrateInfo . bRfPiEnable = ( u8 ) ODM_GetBBReg ( pDM_Odm , rFPGA0_XA_HSSIParameter1 , BIT ( 8 ) ) ;
2014-12-19 06:59:46 +00:00
}
2015-08-15 18:24:16 +00:00
if ( ! pDM_Odm - > RFCalibrateInfo . bRfPiEnable ) {
2015-02-20 00:51:33 +00:00
/* Switch BB to PI mode to do IQ Calibration. */
2015-03-02 23:25:27 +00:00
_PHY_PIModeSwitch ( pAdapter , true ) ;
2014-12-19 06:59:46 +00:00
}
2015-02-20 00:51:33 +00:00
/* BB setting */
2014-12-19 06:59:46 +00:00
ODM_SetBBReg ( pDM_Odm , rFPGA0_RFMOD , BIT24 , 0x00 ) ;
ODM_SetBBReg ( pDM_Odm , rOFDM0_TRxPathEnable , bMaskDWord , 0x03a05600 ) ;
ODM_SetBBReg ( pDM_Odm , rOFDM0_TRMuxPar , bMaskDWord , 0x000800e4 ) ;
ODM_SetBBReg ( pDM_Odm , rFPGA0_XCD_RFInterfaceSW , bMaskDWord , 0x22204000 ) ;
ODM_SetBBReg ( pDM_Odm , rFPGA0_XAB_RFInterfaceSW , BIT10 , 0x01 ) ;
ODM_SetBBReg ( pDM_Odm , rFPGA0_XAB_RFInterfaceSW , BIT26 , 0x01 ) ;
ODM_SetBBReg ( pDM_Odm , rFPGA0_XA_RFInterfaceOE , BIT10 , 0x00 ) ;
ODM_SetBBReg ( pDM_Odm , rFPGA0_XB_RFInterfaceOE , BIT10 , 0x00 ) ;
2015-08-15 18:02:34 +00:00
if ( is2T )
2014-12-19 06:59:46 +00:00
{
ODM_SetBBReg ( pDM_Odm , rFPGA0_XA_LSSIParameter , bMaskDWord , 0x00010000 ) ;
ODM_SetBBReg ( pDM_Odm , rFPGA0_XB_LSSIParameter , bMaskDWord , 0x00010000 ) ;
}
2015-02-20 00:51:33 +00:00
/* MAC settings */
2014-12-19 06:59:46 +00:00
_PHY_MACSettingCalibration ( pAdapter , IQK_MAC_REG , pDM_Odm - > RFCalibrateInfo . IQK_MAC_backup ) ;
2015-02-20 00:51:33 +00:00
/* Page B init */
/* AP or IQK */
2014-12-19 06:59:46 +00:00
ODM_SetBBReg ( pDM_Odm , rConfig_AntA , bMaskDWord , 0x0f600000 ) ;
2015-08-15 18:02:34 +00:00
if ( is2T )
2014-12-19 06:59:46 +00:00
{
ODM_SetBBReg ( pDM_Odm , rConfig_AntB , bMaskDWord , 0x0f600000 ) ;
}
2015-02-20 00:51:33 +00:00
/* IQ calibration setting */
2014-12-19 06:59:46 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " IQK setting! \n " ) ) ;
ODM_SetBBReg ( pDM_Odm , rFPGA0_IQK , bMaskDWord , 0x80800000 ) ;
ODM_SetBBReg ( pDM_Odm , rTx_IQK , bMaskDWord , 0x01007c00 ) ;
ODM_SetBBReg ( pDM_Odm , rRx_IQK , bMaskDWord , 0x81004800 ) ;
2015-08-15 18:24:16 +00:00
for ( i = 0 ; i < retryCount ; i + + ) {
2014-12-19 06:59:46 +00:00
PathAOK = phy_PathA_IQK_8188E ( pAdapter , is2T ) ;
2015-08-15 18:24:16 +00:00
if ( PathAOK = = 0x01 ) {
2014-12-19 06:59:46 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " Path A Tx IQK Success!! \n " ) ) ;
result [ t ] [ 0 ] = ( ODM_GetBBReg ( pDM_Odm , rTx_Power_Before_IQK_A , bMaskDWord ) & 0x3FF0000 ) > > 16 ;
result [ t ] [ 1 ] = ( ODM_GetBBReg ( pDM_Odm , rTx_Power_After_IQK_A , bMaskDWord ) & 0x3FF0000 ) > > 16 ;
break ;
}
}
2015-08-15 18:24:16 +00:00
for ( i = 0 ; i < retryCount ; i + + ) {
2014-12-19 06:59:46 +00:00
PathAOK = phy_PathA_RxIQK ( pAdapter , is2T ) ;
2015-08-15 18:24:16 +00:00
if ( PathAOK = = 0x03 ) {
2014-12-19 06:59:46 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " Path A Rx IQK Success!! \n " ) ) ;
2014-12-30 19:48:00 +00:00
result [ t ] [ 2 ] = ( ODM_GetBBReg ( pDM_Odm , rRx_Power_Before_IQK_A_2 , bMaskDWord ) & 0x3FF0000 ) > > 16 ;
result [ t ] [ 3 ] = ( ODM_GetBBReg ( pDM_Odm , rRx_Power_After_IQK_A_2 , bMaskDWord ) & 0x3FF0000 ) > > 16 ;
2014-12-19 06:59:46 +00:00
break ;
2014-12-30 19:48:00 +00:00
} else {
2014-12-19 06:59:46 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " Path A Rx IQK Fail!! \n " ) ) ;
}
}
2015-08-15 18:24:16 +00:00
if ( 0x00 = = PathAOK ) {
2014-12-19 06:59:46 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " Path A IQK failed!! \n " ) ) ;
}
2015-08-15 18:24:16 +00:00
if ( is2T ) {
2014-12-19 06:59:46 +00:00
_PHY_PathAStandBy ( pAdapter ) ;
2015-02-20 00:51:33 +00:00
/* Turn Path B ADDA on */
2015-03-02 23:25:27 +00:00
_PHY_PathADDAOn ( pAdapter , ADDA_REG , false , is2T ) ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:24:16 +00:00
for ( i = 0 ; i < retryCount ; i + + ) {
2014-12-19 06:59:46 +00:00
PathBOK = phy_PathB_IQK_8188E ( pAdapter ) ;
2015-08-15 18:24:16 +00:00
if ( PathBOK = = 0x03 ) {
2014-12-19 06:59:46 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " Path B IQK Success!! \n " ) ) ;
result [ t ] [ 4 ] = ( ODM_GetBBReg ( pDM_Odm , rTx_Power_Before_IQK_B , bMaskDWord ) & 0x3FF0000 ) > > 16 ;
result [ t ] [ 5 ] = ( ODM_GetBBReg ( pDM_Odm , rTx_Power_After_IQK_B , bMaskDWord ) & 0x3FF0000 ) > > 16 ;
result [ t ] [ 6 ] = ( ODM_GetBBReg ( pDM_Odm , rRx_Power_Before_IQK_B_2 , bMaskDWord ) & 0x3FF0000 ) > > 16 ;
result [ t ] [ 7 ] = ( ODM_GetBBReg ( pDM_Odm , rRx_Power_After_IQK_B_2 , bMaskDWord ) & 0x3FF0000 ) > > 16 ;
break ;
}
2015-02-20 00:51:33 +00:00
else if ( i = = ( retryCount - 1 ) & & PathBOK = = 0x01 ) /* Tx IQK OK */
2014-12-19 06:59:46 +00:00
{
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " Path B Only Tx IQK Success!! \n " ) ) ;
result [ t ] [ 4 ] = ( ODM_GetBBReg ( pDM_Odm , rTx_Power_Before_IQK_B , bMaskDWord ) & 0x3FF0000 ) > > 16 ;
result [ t ] [ 5 ] = ( ODM_GetBBReg ( pDM_Odm , rTx_Power_After_IQK_B , bMaskDWord ) & 0x3FF0000 ) > > 16 ;
}
}
2015-08-15 18:24:16 +00:00
if ( 0x00 = = PathBOK ) {
2014-12-19 06:59:46 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " Path B IQK failed!! \n " ) ) ;
}
}
2015-02-20 00:51:33 +00:00
/* Back to BB mode, load original value */
2014-12-19 06:59:46 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " IQK:Back to BB mode, load original value! \n " ) ) ;
ODM_SetBBReg ( pDM_Odm , rFPGA0_IQK , bMaskDWord , 0 ) ;
2015-08-15 18:02:34 +00:00
if ( t ! = 0 ) {
2015-08-15 18:24:16 +00:00
if ( ! pDM_Odm - > RFCalibrateInfo . bRfPiEnable ) {
2015-02-20 00:51:33 +00:00
/* Switch back BB to SI mode after finish IQ Calibration. */
2015-03-02 23:25:27 +00:00
_PHY_PIModeSwitch ( pAdapter , false ) ;
2014-12-19 06:59:46 +00:00
}
2015-02-20 00:51:33 +00:00
/* Reload ADDA power saving parameters */
2014-12-19 06:59:46 +00:00
_PHY_ReloadADDARegisters ( pAdapter , ADDA_REG , pDM_Odm - > RFCalibrateInfo . ADDA_backup , IQK_ADDA_REG_NUM ) ;
2015-02-20 00:51:33 +00:00
/* Reload MAC parameters */
2014-12-19 06:59:46 +00:00
_PHY_ReloadMACRegisters ( pAdapter , IQK_MAC_REG , pDM_Odm - > RFCalibrateInfo . IQK_MAC_backup ) ;
_PHY_ReloadADDARegisters ( pAdapter , IQK_BB_REG_92C , pDM_Odm - > RFCalibrateInfo . IQK_BB_backup , IQK_BB_REG_NUM ) ;
2015-02-20 00:51:33 +00:00
/* Restore RX initial gain */
2014-12-30 19:48:00 +00:00
ODM_SetBBReg ( pDM_Odm , rFPGA0_XA_LSSIParameter , bMaskDWord , 0x00032ed3 ) ;
2015-08-15 18:24:16 +00:00
if ( is2T ) {
2014-12-30 19:48:00 +00:00
ODM_SetBBReg ( pDM_Odm , rFPGA0_XB_LSSIParameter , bMaskDWord , 0x00032ed3 ) ;
}
2014-12-19 06:59:46 +00:00
2015-02-20 00:51:33 +00:00
/* load 0xe30 IQC default value */
2014-12-19 06:59:46 +00:00
ODM_SetBBReg ( pDM_Odm , rTx_IQK_Tone_A , bMaskDWord , 0x01008c00 ) ;
ODM_SetBBReg ( pDM_Odm , rRx_IQK_Tone_A , bMaskDWord , 0x01008c00 ) ;
}
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " phy_IQCalibrate_8188E() <== \n " ) ) ;
}
2015-01-29 21:27:28 +00:00
static void
2014-12-19 06:59:46 +00:00
phy_LCCalibrate_8188E (
2015-03-13 17:06:38 +00:00
struct adapter * pAdapter ,
bool is2T
2014-12-19 06:59:46 +00:00
)
{
2014-12-30 23:50:44 +00:00
u8 tmpReg ;
2014-12-30 22:55:10 +00:00
u32 RF_Amode = 0 , RF_Bmode = 0 , LC_Cal ;
2014-12-19 06:59:46 +00:00
HAL_DATA_TYPE * pHalData = GET_HAL_DATA ( pAdapter ) ;
PDM_ODM_T pDM_Odm = & pHalData - > odmpriv ;
2014-12-30 19:48:00 +00:00
2015-02-20 00:51:33 +00:00
/* Check continuous TX and Packet TX */
2014-12-19 06:59:46 +00:00
tmpReg = ODM_Read1Byte ( pDM_Odm , 0xd03 ) ;
2015-08-15 18:02:34 +00:00
if ( ( tmpReg & 0x70 ) ! = 0 ) /* Deal with contisuous TX case */
2015-02-20 00:51:33 +00:00
ODM_Write1Byte ( pDM_Odm , 0xd03 , tmpReg & 0x8F ) ; /* disable all continuous TX */
else /* Deal with Packet TX case */
ODM_Write1Byte ( pDM_Odm , REG_TXPAUSE , 0xFF ) ; /* block all queues */
2014-12-19 06:59:46 +00:00
2015-08-15 18:02:34 +00:00
if ( ( tmpReg & 0x70 ) ! = 0 )
2014-12-19 06:59:46 +00:00
{
2015-02-20 00:51:33 +00:00
/* 1. Read original RF mode */
/* Path-A */
2014-12-19 06:59:46 +00:00
RF_Amode = PHY_QueryRFReg ( pAdapter , RF_PATH_A , RF_AC , bMask12Bits ) ;
2015-02-20 00:51:33 +00:00
/* Path-B */
2015-08-15 18:02:34 +00:00
if ( is2T )
2014-12-19 06:59:46 +00:00
RF_Bmode = PHY_QueryRFReg ( pAdapter , RF_PATH_B , RF_AC , bMask12Bits ) ;
2015-02-20 00:51:33 +00:00
/* 2. Set RF mode = standby mode */
/* Path-A */
2014-12-19 06:59:46 +00:00
ODM_SetRFReg ( pDM_Odm , RF_PATH_A , RF_AC , bMask12Bits , ( RF_Amode & 0x8FFFF ) | 0x10000 ) ;
2015-02-20 00:51:33 +00:00
/* Path-B */
2015-08-15 18:02:34 +00:00
if ( is2T )
2014-12-19 06:59:46 +00:00
ODM_SetRFReg ( pDM_Odm , RF_PATH_B , RF_AC , bMask12Bits , ( RF_Bmode & 0x8FFFF ) | 0x10000 ) ;
}
2015-02-20 00:51:33 +00:00
/* 3. Read RF reg18 */
2014-12-19 06:59:46 +00:00
LC_Cal = PHY_QueryRFReg ( pAdapter , RF_PATH_A , RF_CHNLBW , bMask12Bits ) ;
2015-02-20 00:51:33 +00:00
/* 4. Set LC calibration begin bit15 */
2014-12-19 06:59:46 +00:00
ODM_SetRFReg ( pDM_Odm , RF_PATH_A , RF_CHNLBW , bMask12Bits , LC_Cal | 0x08000 ) ;
ODM_sleep_ms ( 100 ) ;
2015-02-20 00:51:33 +00:00
/* Restore original situation */
2015-08-15 18:02:34 +00:00
if ( ( tmpReg & 0x70 ) ! = 0 ) /* Deal with contisuous TX case */
2014-12-19 06:59:46 +00:00
{
2015-02-20 00:51:33 +00:00
/* Path-A */
2014-12-19 06:59:46 +00:00
ODM_Write1Byte ( pDM_Odm , 0xd03 , tmpReg ) ;
ODM_SetRFReg ( pDM_Odm , RF_PATH_A , RF_AC , bMask12Bits , RF_Amode ) ;
2015-02-20 00:51:33 +00:00
/* Path-B */
2015-08-15 18:02:34 +00:00
if ( is2T )
2014-12-19 06:59:46 +00:00
ODM_SetRFReg ( pDM_Odm , RF_PATH_B , RF_AC , bMask12Bits , RF_Bmode ) ;
}
2015-02-20 00:51:33 +00:00
else /* Deal with Packet TX case */
2014-12-19 06:59:46 +00:00
{
ODM_Write1Byte ( pDM_Odm , REG_TXPAUSE , 0x00 ) ;
}
}
2015-02-20 00:51:33 +00:00
/* Analog Pre-distortion calibration */
2014-12-19 06:59:46 +00:00
# define APK_BB_REG_NUM 8
# define APK_CURVE_REG_NUM 4
# define PATH_NUM 2
2015-01-29 21:27:28 +00:00
static void
2014-12-19 06:59:46 +00:00
phy_APCalibrate_8188E (
2015-03-13 17:06:38 +00:00
struct adapter * pAdapter ,
s8 delta ,
bool is2T
2014-12-19 06:59:46 +00:00
)
{
HAL_DATA_TYPE * pHalData = GET_HAL_DATA ( pAdapter ) ;
PDM_ODM_T pDM_Odm = & pHalData - > odmpriv ;
2014-12-30 22:55:10 +00:00
u32 regD [ PATH_NUM ] ;
u32 tmpReg , index , offset , apkbound ;
2014-12-30 23:50:44 +00:00
u8 path , i , pathbound = PATH_NUM ;
2014-12-30 22:55:10 +00:00
u32 BB_backup [ APK_BB_REG_NUM ] ;
u32 BB_REG [ APK_BB_REG_NUM ] = {
2014-12-19 06:59:46 +00:00
rFPGA1_TxBlock , rOFDM0_TRxPathEnable ,
rFPGA0_RFMOD , rOFDM0_TRMuxPar ,
rFPGA0_XCD_RFInterfaceSW , rFPGA0_XAB_RFInterfaceSW ,
rFPGA0_XA_RFInterfaceOE , rFPGA0_XB_RFInterfaceOE } ;
2014-12-30 22:55:10 +00:00
u32 BB_AP_MODE [ APK_BB_REG_NUM ] = {
2014-12-19 06:59:46 +00:00
0x00000020 , 0x00a05430 , 0x02040000 ,
0x000800e4 , 0x00204000 } ;
2014-12-30 22:55:10 +00:00
u32 BB_normal_AP_MODE [ APK_BB_REG_NUM ] = {
2014-12-19 06:59:46 +00:00
0x00000020 , 0x00a05430 , 0x02040000 ,
0x000800e4 , 0x22204000 } ;
2014-12-30 22:55:10 +00:00
u32 AFE_backup [ IQK_ADDA_REG_NUM ] ;
u32 AFE_REG [ IQK_ADDA_REG_NUM ] = {
2014-12-19 06:59:46 +00:00
rFPGA0_XCD_SwitchControl , rBlue_Tooth ,
rRx_Wait_CCA , rTx_CCK_RFON ,
rTx_CCK_BBON , rTx_OFDM_RFON ,
rTx_OFDM_BBON , rTx_To_Rx ,
rTx_To_Tx , rRx_CCK ,
rRx_OFDM , rRx_Wait_RIFS ,
rRx_TO_Rx , rStandby ,
rSleep , rPMPD_ANAEN } ;
2014-12-30 22:55:10 +00:00
u32 MAC_backup [ IQK_MAC_REG_NUM ] ;
u32 MAC_REG [ IQK_MAC_REG_NUM ] = {
2014-12-19 06:59:46 +00:00
REG_TXPAUSE , REG_BCN_CTRL ,
REG_BCN_CTRL_1 , REG_GPIO_MUXCFG } ;
2014-12-30 22:55:10 +00:00
u32 APK_RF_init_value [ PATH_NUM ] [ APK_BB_REG_NUM ] = {
2014-12-19 06:59:46 +00:00
{ 0x0852c , 0x1852c , 0x5852c , 0x1852c , 0x5852c } ,
{ 0x2852e , 0x0852e , 0x3852e , 0x0852e , 0x0852e }
} ;
2014-12-30 22:55:10 +00:00
u32 APK_normal_RF_init_value [ PATH_NUM ] [ APK_BB_REG_NUM ] = {
2015-02-20 00:51:33 +00:00
{ 0x0852c , 0x0a52c , 0x3a52c , 0x5a52c , 0x5a52c } , /* path settings equal to path b settings */
2014-12-19 06:59:46 +00:00
{ 0x0852c , 0x0a52c , 0x5a52c , 0x5a52c , 0x5a52c }
} ;
2014-12-30 22:55:10 +00:00
u32 APK_RF_value_0 [ PATH_NUM ] [ APK_BB_REG_NUM ] = {
2014-12-19 06:59:46 +00:00
{ 0x52019 , 0x52014 , 0x52013 , 0x5200f , 0x5208d } ,
{ 0x5201a , 0x52019 , 0x52016 , 0x52033 , 0x52050 }
} ;
2014-12-30 22:55:10 +00:00
u32 APK_normal_RF_value_0 [ PATH_NUM ] [ APK_BB_REG_NUM ] = {
2015-02-20 00:51:33 +00:00
{ 0x52019 , 0x52017 , 0x52010 , 0x5200d , 0x5206a } , /* path settings equal to path b settings */
2014-12-19 06:59:46 +00:00
{ 0x52019 , 0x52017 , 0x52010 , 0x5200d , 0x5206a }
} ;
2014-12-30 22:55:10 +00:00
u32 AFE_on_off [ PATH_NUM ] = {
2015-02-20 00:51:33 +00:00
0x04db25a4 , 0x0b1b25a4 } ; /* path A on path B off / path A off path B on */
2014-12-19 06:59:46 +00:00
2014-12-30 22:55:10 +00:00
u32 APK_offset [ PATH_NUM ] = {
2014-12-19 06:59:46 +00:00
rConfig_AntA , rConfig_AntB } ;
2014-12-30 22:55:10 +00:00
u32 APK_normal_offset [ PATH_NUM ] = {
2014-12-19 06:59:46 +00:00
rConfig_Pmpd_AntA , rConfig_Pmpd_AntB } ;
2014-12-30 22:55:10 +00:00
u32 APK_value [ PATH_NUM ] = {
2014-12-19 06:59:46 +00:00
0x92fc0000 , 0x12fc0000 } ;
2014-12-30 22:55:10 +00:00
u32 APK_normal_value [ PATH_NUM ] = {
2014-12-19 06:59:46 +00:00
0x92680000 , 0x12680000 } ;
2014-12-30 23:58:53 +00:00
s8 APK_delta_mapping [ APK_BB_REG_NUM ] [ 13 ] = {
2014-12-19 06:59:46 +00:00
{ - 4 , - 3 , - 2 , - 2 , - 1 , - 1 , 0 , 1 , 2 , 3 , 4 , 5 , 6 } ,
{ - 4 , - 3 , - 2 , - 2 , - 1 , - 1 , 0 , 1 , 2 , 3 , 4 , 5 , 6 } ,
{ - 6 , - 4 , - 2 , - 2 , - 1 , - 1 , 0 , 1 , 2 , 3 , 4 , 5 , 6 } ,
{ - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , 0 , 1 , 2 , 3 , 4 , 5 , 6 } ,
{ - 11 , - 9 , - 7 , - 5 , - 3 , - 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }
} ;
2014-12-30 22:55:10 +00:00
u32 APK_normal_setting_value_1 [ 13 ] = {
2014-12-19 06:59:46 +00:00
0x01017018 , 0xf7ed8f84 , 0x1b1a1816 , 0x2522201e , 0x322e2b28 ,
0x433f3a36 , 0x5b544e49 , 0x7b726a62 , 0xa69a8f84 , 0xdfcfc0b3 ,
0x12680000 , 0x00880000 , 0x00880000
} ;
2014-12-30 22:55:10 +00:00
u32 APK_normal_setting_value_2 [ 16 ] = {
2014-12-19 06:59:46 +00:00
0x01c7021d , 0x01670183 , 0x01000123 , 0x00bf00e2 , 0x008d00a3 ,
0x0068007b , 0x004d0059 , 0x003a0042 , 0x002b0031 , 0x001f0025 ,
0x0017001b , 0x00110014 , 0x000c000f , 0x0009000b , 0x00070008 ,
0x00050006
} ;
2015-02-20 00:51:33 +00:00
u32 APK_result [ PATH_NUM ] [ APK_BB_REG_NUM ] ; /* val_1_1a, val_1_2a, val_2a, val_3a, val_4a */
/* u32 AP_curve[PATH_NUM][APK_CURVE_REG_NUM]; */
2014-12-19 06:59:46 +00:00
2014-12-30 23:58:53 +00:00
s32 BB_offset , delta_V , delta_offset ;
2014-12-19 06:59:46 +00:00
# if MP_DRIVER == 1
if ( * ( pDM_Odm - > mp_mode ) = = 1 )
{
2015-03-17 01:14:52 +00:00
struct mpt_context * pMptCtx = & ( pAdapter - > mppriv . MptCtx ) ;
2014-12-19 06:59:46 +00:00
pMptCtx - > APK_bound [ 0 ] = 45 ;
pMptCtx - > APK_bound [ 1 ] = 52 ;
}
# endif
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " ==>phy_APCalibrate_8188E() delta %d \n " , delta ) ) ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " AP Calibration for %s \n " , ( is2T ? " 2T2R " : " 1T1R " ) ) ) ;
2015-08-15 18:02:34 +00:00
if ( ! is2T )
2014-12-19 06:59:46 +00:00
pathbound = 1 ;
2015-02-20 00:51:33 +00:00
/* 2 FOR NORMAL CHIP SETTINGS */
2014-12-19 06:59:46 +00:00
2015-02-20 00:51:33 +00:00
/* Temporarily do not allow normal driver to do the following settings because these offset */
/* and value will cause RF internal PA to be unpredictably disabled by HW, such that RF Tx signal */
/* will disappear after disable/enable card many times on 88CU. RF SD and DD have not find the */
/* root cause, so we remove these actions temporarily. Added by tynli and SD3 Allen. 2010.05.31. */
2015-03-10 16:18:03 +00:00
if ( * ( pDM_Odm - > mp_mode ) ! = 1 )
return ;
2015-02-20 00:51:33 +00:00
/* settings adjust for normal chip */
2015-08-15 18:06:32 +00:00
for ( index = 0 ; index < PATH_NUM ; index + + ) {
2014-12-19 06:59:46 +00:00
APK_offset [ index ] = APK_normal_offset [ index ] ;
APK_value [ index ] = APK_normal_value [ index ] ;
AFE_on_off [ index ] = 0x6fdb25a4 ;
}
2015-08-15 18:06:32 +00:00
for ( index = 0 ; index < APK_BB_REG_NUM ; index + + ) {
for ( path = 0 ; path < pathbound ; path + + ) {
2014-12-19 06:59:46 +00:00
APK_RF_init_value [ path ] [ index ] = APK_normal_RF_init_value [ path ] [ index ] ;
APK_RF_value_0 [ path ] [ index ] = APK_normal_RF_value_0 [ path ] [ index ] ;
}
BB_AP_MODE [ index ] = BB_normal_AP_MODE [ index ] ;
}
apkbound = 6 ;
2015-02-20 00:51:33 +00:00
/* save BB default value */
2015-08-15 18:06:32 +00:00
for ( index = 0 ; index < APK_BB_REG_NUM ; index + + ) {
2015-08-15 18:02:34 +00:00
if ( index = = 0 ) /* skip */
2014-12-19 06:59:46 +00:00
continue ;
BB_backup [ index ] = ODM_GetBBReg ( pDM_Odm , BB_REG [ index ] , bMaskDWord ) ;
}
2015-02-20 00:51:33 +00:00
/* save MAC default value */
2014-12-19 06:59:46 +00:00
_PHY_SaveMACRegisters ( pAdapter , MAC_REG , MAC_backup ) ;
2015-02-20 00:51:33 +00:00
/* save AFE default value */
2014-12-19 06:59:46 +00:00
_PHY_SaveADDARegisters ( pAdapter , AFE_REG , AFE_backup , IQK_ADDA_REG_NUM ) ;
2015-08-15 18:06:32 +00:00
for ( path = 0 ; path < pathbound ; path + + )
2014-12-19 06:59:46 +00:00
{
2015-08-15 18:02:34 +00:00
if ( path = = RF_PATH_A )
2014-12-19 06:59:46 +00:00
{
2015-02-20 00:51:33 +00:00
/* path A APK */
/* load APK setting */
/* path-A */
2014-12-19 06:59:46 +00:00
offset = rPdp_AntA ;
2015-08-15 18:06:32 +00:00
for ( index = 0 ; index < 11 ; index + + )
2014-12-19 06:59:46 +00:00
{
ODM_SetBBReg ( pDM_Odm , offset , bMaskDWord , APK_normal_setting_value_1 [ index ] ) ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " phy_APCalibrate_8188E() offset 0x%x value 0x%x \n " , offset , ODM_GetBBReg ( pDM_Odm , offset , bMaskDWord ) ) ) ;
offset + = 0x04 ;
}
ODM_SetBBReg ( pDM_Odm , rConfig_Pmpd_AntB , bMaskDWord , 0x12680000 ) ;
offset = rConfig_AntA ;
2015-08-15 18:06:32 +00:00
for ( ; index < 13 ; index + + )
2014-12-19 06:59:46 +00:00
{
ODM_SetBBReg ( pDM_Odm , offset , bMaskDWord , APK_normal_setting_value_1 [ index ] ) ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " phy_APCalibrate_8188E() offset 0x%x value 0x%x \n " , offset , ODM_GetBBReg ( pDM_Odm , offset , bMaskDWord ) ) ) ;
offset + = 0x04 ;
}
2015-02-20 00:51:33 +00:00
/* page-B1 */
2014-12-19 06:59:46 +00:00
ODM_SetBBReg ( pDM_Odm , rFPGA0_IQK , bMaskDWord , 0x40000000 ) ;
2015-02-20 00:51:33 +00:00
/* path A */
2014-12-19 06:59:46 +00:00
offset = rPdp_AntA ;
2015-08-15 18:06:32 +00:00
for ( index = 0 ; index < 16 ; index + + )
2014-12-19 06:59:46 +00:00
{
ODM_SetBBReg ( pDM_Odm , offset , bMaskDWord , APK_normal_setting_value_2 [ index ] ) ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " phy_APCalibrate_8188E() offset 0x%x value 0x%x \n " , offset , ODM_GetBBReg ( pDM_Odm , offset , bMaskDWord ) ) ) ;
offset + = 0x04 ;
}
ODM_SetBBReg ( pDM_Odm , rFPGA0_IQK , bMaskDWord , 0x00000000 ) ;
}
2015-08-15 18:02:34 +00:00
else if ( path = = RF_PATH_B )
2014-12-19 06:59:46 +00:00
{
2015-02-20 00:51:33 +00:00
/* path B APK */
/* load APK setting */
/* path-B */
2014-12-19 06:59:46 +00:00
offset = rPdp_AntB ;
2015-08-15 18:06:32 +00:00
for ( index = 0 ; index < 10 ; index + + )
2014-12-19 06:59:46 +00:00
{
ODM_SetBBReg ( pDM_Odm , offset , bMaskDWord , APK_normal_setting_value_1 [ index ] ) ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " phy_APCalibrate_8188E() offset 0x%x value 0x%x \n " , offset , ODM_GetBBReg ( pDM_Odm , offset , bMaskDWord ) ) ) ;
offset + = 0x04 ;
}
ODM_SetBBReg ( pDM_Odm , rConfig_Pmpd_AntA , bMaskDWord , 0x12680000 ) ;
PHY_SetBBReg ( pAdapter , rConfig_Pmpd_AntB , bMaskDWord , 0x12680000 ) ;
offset = rConfig_AntA ;
index = 11 ;
2015-08-15 18:06:32 +00:00
for ( ; index < 13 ; index + + ) /* offset 0xb68, 0xb6c */
2014-12-19 06:59:46 +00:00
{
ODM_SetBBReg ( pDM_Odm , offset , bMaskDWord , APK_normal_setting_value_1 [ index ] ) ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " phy_APCalibrate_8188E() offset 0x%x value 0x%x \n " , offset , ODM_GetBBReg ( pDM_Odm , offset , bMaskDWord ) ) ) ;
offset + = 0x04 ;
}
2015-02-20 00:51:33 +00:00
/* page-B1 */
2014-12-19 06:59:46 +00:00
ODM_SetBBReg ( pDM_Odm , rFPGA0_IQK , bMaskDWord , 0x40000000 ) ;
2015-02-20 00:51:33 +00:00
/* path B */
2014-12-19 06:59:46 +00:00
offset = 0xb60 ;
2015-08-15 18:06:32 +00:00
for ( index = 0 ; index < 16 ; index + + )
2014-12-19 06:59:46 +00:00
{
ODM_SetBBReg ( pDM_Odm , offset , bMaskDWord , APK_normal_setting_value_2 [ index ] ) ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " phy_APCalibrate_8188E() offset 0x%x value 0x%x \n " , offset , ODM_GetBBReg ( pDM_Odm , offset , bMaskDWord ) ) ) ;
offset + = 0x04 ;
}
ODM_SetBBReg ( pDM_Odm , rFPGA0_IQK , bMaskDWord , 0 ) ;
}
2015-02-20 00:51:33 +00:00
/* save RF default value */
2014-12-19 06:59:46 +00:00
regD [ path ] = PHY_QueryRFReg ( pAdapter , path , RF_TXBIAS_A , bMaskDWord ) ;
2015-02-20 00:51:33 +00:00
/* Path A AFE all on, path B AFE All off or vise versa */
2015-08-15 18:06:32 +00:00
for ( index = 0 ; index < IQK_ADDA_REG_NUM ; index + + )
2014-12-19 06:59:46 +00:00
ODM_SetBBReg ( pDM_Odm , AFE_REG [ index ] , bMaskDWord , AFE_on_off [ path ] ) ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " phy_APCalibrate_8188E() offset 0xe70 %x \n " , ODM_GetBBReg ( pDM_Odm , rRx_Wait_CCA , bMaskDWord ) ) ) ;
2015-02-20 00:51:33 +00:00
/* BB to AP mode */
2015-08-15 18:02:34 +00:00
if ( path = = 0 )
2014-12-19 06:59:46 +00:00
{
2015-08-15 18:06:32 +00:00
for ( index = 0 ; index < APK_BB_REG_NUM ; index + + )
2014-12-19 06:59:46 +00:00
{
2015-08-15 18:02:34 +00:00
if ( index = = 0 ) /* skip */
2014-12-19 06:59:46 +00:00
continue ;
else if ( index < 5 )
ODM_SetBBReg ( pDM_Odm , BB_REG [ index ] , bMaskDWord , BB_AP_MODE [ index ] ) ;
else if ( BB_REG [ index ] = = 0x870 )
ODM_SetBBReg ( pDM_Odm , BB_REG [ index ] , bMaskDWord , BB_backup [ index ] | BIT10 | BIT26 ) ;
else
ODM_SetBBReg ( pDM_Odm , BB_REG [ index ] , BIT10 , 0x0 ) ;
}
ODM_SetBBReg ( pDM_Odm , rTx_IQK_Tone_A , bMaskDWord , 0x01008c00 ) ;
ODM_SetBBReg ( pDM_Odm , rRx_IQK_Tone_A , bMaskDWord , 0x01008c00 ) ;
}
2015-02-20 00:51:33 +00:00
else /* path B */
2014-12-19 06:59:46 +00:00
{
ODM_SetBBReg ( pDM_Odm , rTx_IQK_Tone_B , bMaskDWord , 0x01008c00 ) ;
ODM_SetBBReg ( pDM_Odm , rRx_IQK_Tone_B , bMaskDWord , 0x01008c00 ) ;
}
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " phy_APCalibrate_8188E() offset 0x800 %x \n " , ODM_GetBBReg ( pDM_Odm , 0x800 , bMaskDWord ) ) ) ;
2015-02-20 00:51:33 +00:00
/* MAC settings */
2014-12-19 06:59:46 +00:00
_PHY_MACSettingCalibration ( pAdapter , MAC_REG , MAC_backup ) ;
2015-08-15 18:02:34 +00:00
if ( path = = RF_PATH_A ) /* Path B to standby mode */
2014-12-19 06:59:46 +00:00
{
ODM_SetRFReg ( pDM_Odm , RF_PATH_B , RF_AC , bMaskDWord , 0x10000 ) ;
}
2015-02-20 00:51:33 +00:00
else /* Path A to standby mode */
2014-12-19 06:59:46 +00:00
{
ODM_SetRFReg ( pDM_Odm , RF_PATH_A , RF_AC , bMaskDWord , 0x10000 ) ;
ODM_SetRFReg ( pDM_Odm , RF_PATH_A , RF_MODE1 , bMaskDWord , 0x1000f ) ;
ODM_SetRFReg ( pDM_Odm , RF_PATH_A , RF_MODE2 , bMaskDWord , 0x20103 ) ;
}
delta_offset = ( ( delta + 14 ) / 2 ) ;
2015-08-15 18:02:34 +00:00
if ( delta_offset < 0 )
2014-12-19 06:59:46 +00:00
delta_offset = 0 ;
else if ( delta_offset > 12 )
delta_offset = 12 ;
2015-02-20 00:51:33 +00:00
/* AP calibration */
2015-08-15 18:06:32 +00:00
for ( index = 0 ; index < APK_BB_REG_NUM ; index + + )
2014-12-19 06:59:46 +00:00
{
2015-08-15 18:02:34 +00:00
if ( index ! = 1 ) /* only DO PA11+PAD01001, AP RF setting */
2014-12-19 06:59:46 +00:00
continue ;
tmpReg = APK_RF_init_value [ path ] [ index ] ;
2015-08-15 18:02:34 +00:00
if ( ! pDM_Odm - > RFCalibrateInfo . bAPKThermalMeterIgnore )
2014-12-19 06:59:46 +00:00
{
BB_offset = ( tmpReg & 0xF0000 ) > > 16 ;
2015-08-15 18:02:34 +00:00
if ( ! ( tmpReg & BIT15 ) ) /* sign bit 0 */
2014-12-19 06:59:46 +00:00
{
BB_offset = - BB_offset ;
}
delta_V = APK_delta_mapping [ index ] [ delta_offset ] ;
BB_offset + = delta_V ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " phy_APCalibrate_8188E() APK index %d tmpReg 0x%x delta_V %d delta_offset %d \n " , index , tmpReg , delta_V , delta_offset ) ) ;
2015-08-15 18:02:34 +00:00
if ( BB_offset < 0 )
2014-12-19 06:59:46 +00:00
{
tmpReg = tmpReg & ( ~ BIT15 ) ;
BB_offset = - BB_offset ;
}
else
{
tmpReg = tmpReg | BIT15 ;
}
tmpReg = ( tmpReg & 0xFFF0FFFF ) | ( BB_offset < < 16 ) ;
}
ODM_SetRFReg ( pDM_Odm , path , RF_IPA_A , bMaskDWord , 0x8992e ) ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " phy_APCalibrate_8188E() offset 0xc %x \n " , PHY_QueryRFReg ( pAdapter , path , RF_IPA_A , bMaskDWord ) ) ) ;
ODM_SetRFReg ( pDM_Odm , path , RF_AC , bMaskDWord , APK_RF_value_0 [ path ] [ index ] ) ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " phy_APCalibrate_8188E() offset 0x0 %x \n " , PHY_QueryRFReg ( pAdapter , path , RF_AC , bMaskDWord ) ) ) ;
ODM_SetRFReg ( pDM_Odm , path , RF_TXBIAS_A , bMaskDWord , tmpReg ) ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " phy_APCalibrate_8188E() offset 0xd %x \n " , PHY_QueryRFReg ( pAdapter , path , RF_TXBIAS_A , bMaskDWord ) ) ) ;
2015-02-20 00:51:33 +00:00
/* PA11+PAD01111, one shot */
2014-12-19 06:59:46 +00:00
i = 0 ;
do
{
ODM_SetBBReg ( pDM_Odm , rFPGA0_IQK , bMaskDWord , 0x80000000 ) ;
{
ODM_SetBBReg ( pDM_Odm , APK_offset [ path ] , bMaskDWord , APK_value [ 0 ] ) ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " phy_APCalibrate_8188E() offset 0x%x value 0x%x \n " , APK_offset [ path ] , ODM_GetBBReg ( pDM_Odm , APK_offset [ path ] , bMaskDWord ) ) ) ;
ODM_delay_ms ( 3 ) ;
ODM_SetBBReg ( pDM_Odm , APK_offset [ path ] , bMaskDWord , APK_value [ 1 ] ) ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " phy_APCalibrate_8188E() offset 0x%x value 0x%x \n " , APK_offset [ path ] , ODM_GetBBReg ( pDM_Odm , APK_offset [ path ] , bMaskDWord ) ) ) ;
ODM_delay_ms ( 20 ) ;
}
ODM_SetBBReg ( pDM_Odm , rFPGA0_IQK , bMaskDWord , 0x00000000 ) ;
2015-08-15 18:02:34 +00:00
if ( path = = RF_PATH_A )
2014-12-19 06:59:46 +00:00
tmpReg = ODM_GetBBReg ( pDM_Odm , rAPK , 0x03E00000 ) ;
else
tmpReg = ODM_GetBBReg ( pDM_Odm , rAPK , 0xF8000000 ) ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " phy_APCalibrate_8188E() offset 0xbd8[25:21] %x \n " , tmpReg ) ) ;
i + + ;
}
2015-08-15 18:04:12 +00:00
while ( tmpReg > apkbound & & i < 4 ) ;
2014-12-19 06:59:46 +00:00
APK_result [ path ] [ index ] = tmpReg ;
}
}
2015-02-20 00:51:33 +00:00
/* reload MAC default value */
2014-12-19 06:59:46 +00:00
_PHY_ReloadMACRegisters ( pAdapter , MAC_REG , MAC_backup ) ;
2015-02-20 00:51:33 +00:00
/* reload BB default value */
2015-08-15 18:06:32 +00:00
for ( index = 0 ; index < APK_BB_REG_NUM ; index + + )
2014-12-19 06:59:46 +00:00
{
2015-08-15 18:02:34 +00:00
if ( index = = 0 ) /* skip */
2014-12-19 06:59:46 +00:00
continue ;
ODM_SetBBReg ( pDM_Odm , BB_REG [ index ] , bMaskDWord , BB_backup [ index ] ) ;
}
2015-02-20 00:51:33 +00:00
/* reload AFE default value */
2014-12-19 06:59:46 +00:00
_PHY_ReloadADDARegisters ( pAdapter , AFE_REG , AFE_backup , IQK_ADDA_REG_NUM ) ;
2015-02-20 00:51:33 +00:00
/* reload RF path default value */
2015-08-15 18:06:32 +00:00
for ( path = 0 ; path < pathbound ; path + + )
2014-12-19 06:59:46 +00:00
{
ODM_SetRFReg ( pDM_Odm , path , 0xd , bMaskDWord , regD [ path ] ) ;
2015-08-15 18:02:34 +00:00
if ( path = = RF_PATH_B )
2014-12-19 06:59:46 +00:00
{
ODM_SetRFReg ( pDM_Odm , RF_PATH_A , RF_MODE1 , bMaskDWord , 0x1000f ) ;
ODM_SetRFReg ( pDM_Odm , RF_PATH_A , RF_MODE2 , bMaskDWord , 0x20101 ) ;
}
2015-02-20 00:51:33 +00:00
/* note no index == 0 */
2014-12-19 06:59:46 +00:00
if ( APK_result [ path ] [ 1 ] > 6 )
APK_result [ path ] [ 1 ] = 6 ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " apk path %d result %d 0x%x \t " , path , 1 , APK_result [ path ] [ 1 ] ) ) ;
}
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " \n " ) ) ;
2015-08-15 18:06:32 +00:00
for ( path = 0 ; path < pathbound ; path + + )
2014-12-19 06:59:46 +00:00
{
ODM_SetRFReg ( pDM_Odm , path , 0x3 , bMaskDWord ,
( ( APK_result [ path ] [ 1 ] < < 15 ) | ( APK_result [ path ] [ 1 ] < < 10 ) | ( APK_result [ path ] [ 1 ] < < 5 ) | APK_result [ path ] [ 1 ] ) ) ;
2015-08-15 18:02:34 +00:00
if ( path = = RF_PATH_A )
2014-12-19 06:59:46 +00:00
ODM_SetRFReg ( pDM_Odm , path , 0x4 , bMaskDWord ,
( ( APK_result [ path ] [ 1 ] < < 15 ) | ( APK_result [ path ] [ 1 ] < < 10 ) | ( 0x00 < < 5 ) | 0x05 ) ) ;
else
ODM_SetRFReg ( pDM_Odm , path , 0x4 , bMaskDWord ,
( ( APK_result [ path ] [ 1 ] < < 15 ) | ( APK_result [ path ] [ 1 ] < < 10 ) | ( 0x02 < < 5 ) | 0x05 ) ) ;
2015-08-15 18:02:34 +00:00
if ( ! IS_HARDWARE_TYPE_8723A ( pAdapter ) )
2014-12-19 06:59:46 +00:00
ODM_SetRFReg ( pDM_Odm , path , RF_BS_PA_APSET_G9_G11 , bMaskDWord ,
( ( 0x08 < < 15 ) | ( 0x08 < < 10 ) | ( 0x08 < < 5 ) | 0x08 ) ) ;
}
2015-03-02 23:25:27 +00:00
pDM_Odm - > RFCalibrateInfo . bAPKdone = true ;
2014-12-19 06:59:46 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " <==phy_APCalibrate_8188E() \n " ) ) ;
}
# define DP_BB_REG_NUM 7
# define DP_RF_REG_NUM 1
# define DP_RETRY_LIMIT 10
# define DP_PATH_NUM 2
# define DP_DPK_NUM 3
# define DP_DPK_VALUE_NUM 2
2014-12-29 02:06:17 +00:00
void
2014-12-19 06:59:46 +00:00
PHY_IQCalibrate_8188E (
2015-03-13 17:06:38 +00:00
struct adapter * pAdapter ,
bool bReCovery
2014-12-19 06:59:46 +00:00
)
{
HAL_DATA_TYPE * pHalData = GET_HAL_DATA ( pAdapter ) ;
PDM_ODM_T pDM_Odm = & pHalData - > odmpriv ;
# if (MP_DRIVER == 1)
2015-03-17 01:14:52 +00:00
struct mpt_context * pMptCtx = & ( pAdapter - > mppriv . MptCtx ) ;
2015-02-20 00:51:33 +00:00
# endif /* MP_DRIVER == 1) */
2014-12-19 06:59:46 +00:00
2015-02-20 00:51:33 +00:00
s32 result [ 4 ] [ 8 ] ; /* last is final result */
2014-12-30 23:50:44 +00:00
u8 i , final_candidate , Indexforchannel ;
u8 channelToIQK = 7 ;
2015-03-02 23:21:23 +00:00
bool bPathAOK , bPathBOK ;
2014-12-30 23:58:53 +00:00
s32 RegE94 , RegE9C , RegEA4 , RegEAC , RegEB4 , RegEBC , RegEC4 , RegECC , RegTmp = 0 ;
2015-03-02 23:21:23 +00:00
bool is12simular , is13simular , is23simular ;
2015-03-02 23:25:27 +00:00
bool bStartContTx = false , bSingleTone = false , bCarrierSuppression = false ;
2014-12-30 22:55:10 +00:00
u32 IQK_BB_REG_92C [ IQK_BB_REG_NUM ] = {
2014-12-19 06:59:46 +00:00
rOFDM0_XARxIQImbalance , rOFDM0_XBRxIQImbalance ,
rOFDM0_ECCAThreshold , rOFDM0_AGCRSSITable ,
rOFDM0_XATxIQImbalance , rOFDM0_XBTxIQImbalance ,
rOFDM0_XCTxAFE , rOFDM0_XDTxAFE ,
rOFDM0_RxIQExtAnta } ;
2015-03-02 23:21:23 +00:00
bool is2T ;
2014-12-19 06:59:46 +00:00
2015-03-02 23:25:27 +00:00
is2T = ( pDM_Odm - > RFType = = ODM_2T2R ) ? true : false ;
if ( ODM_CheckPowerStatus ( pAdapter ) = = false )
2014-12-19 06:59:46 +00:00
return ;
2015-08-15 18:02:34 +00:00
if ( ! ( pDM_Odm - > SupportAbility & ODM_RF_CALIBRATION ) )
2014-12-19 06:59:46 +00:00
{
return ;
}
# if MP_DRIVER == 1
if ( * ( pDM_Odm - > mp_mode ) = = 1 )
{
bStartContTx = pMptCtx - > bStartContTx ;
bSingleTone = pMptCtx - > bSingleTone ;
bCarrierSuppression = pMptCtx - > bCarrierSuppression ;
}
# endif
2015-02-20 00:51:33 +00:00
/* 20120213<Kordan> Turn on when continuous Tx to pass lab testing. (required by Edlu) */
2015-08-15 18:02:34 +00:00
if ( bSingleTone | | bCarrierSuppression )
2014-12-19 06:59:46 +00:00
return ;
# if DISABLE_BB_RF
return ;
# endif
2015-08-15 18:02:34 +00:00
if ( bReCovery )
2014-12-19 06:59:46 +00:00
{
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_INIT , ODM_DBG_LOUD , ( " PHY_IQCalibrate_8188E: Return due to bReCovery! \n " ) ) ;
_PHY_ReloadADDARegisters ( pAdapter , IQK_BB_REG_92C , pDM_Odm - > RFCalibrateInfo . IQK_BB_backup_recover , 9 ) ;
return ;
}
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " IQK:Start!!! \n " ) ) ;
2015-08-15 18:06:32 +00:00
for ( i = 0 ; i < 8 ; i + + ) {
2014-12-19 06:59:46 +00:00
result [ 0 ] [ i ] = 0 ;
result [ 1 ] [ i ] = 0 ;
result [ 2 ] [ i ] = 0 ;
2015-08-15 18:22:58 +00:00
if ( ( i = = 0 ) | | ( i = = 2 ) | | ( i = = 4 ) | | ( i = = 6 ) )
2014-12-19 06:59:46 +00:00
result [ 3 ] [ i ] = 0x100 ;
else
result [ 3 ] [ i ] = 0 ;
}
final_candidate = 0xff ;
2015-03-02 23:25:27 +00:00
bPathAOK = false ;
bPathBOK = false ;
is12simular = false ;
is23simular = false ;
is13simular = false ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:00:19 +00:00
/* ODM_RT_TRACE(pDM_Odm,ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK !!!interface %d currentband %d ishardwareD %d\n", pDM_Odm->interfaceIndex, pHalData->CurrentBandType92D, IS_HARDWARE_TYPE_8192D(pAdapter))); */
/* RT_TRACE(COMP_INIT,DBG_LOUD,("Acquire Mutex in IQCalibrate\n")); */
2014-12-19 06:59:46 +00:00
for ( i = 0 ; i < 3 ; i + + )
{
phy_IQCalibrate_8188E ( pAdapter , result , i , is2T ) ;
2015-08-15 18:02:34 +00:00
if ( i = = 1 ) {
2014-12-19 06:59:46 +00:00
is12simular = phy_SimularityCompare_8188E ( pAdapter , result , 0 , 1 ) ;
2015-08-15 18:02:34 +00:00
if ( is12simular ) {
2014-12-19 06:59:46 +00:00
final_candidate = 0 ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " IQK: is12simular final_candidate is %x \n " , final_candidate ) ) ;
break ;
}
}
2015-08-15 18:02:34 +00:00
if ( i = = 2 )
2014-12-19 06:59:46 +00:00
{
is13simular = phy_SimularityCompare_8188E ( pAdapter , result , 0 , 2 ) ;
2015-08-15 18:02:34 +00:00
if ( is13simular ) {
2014-12-19 06:59:46 +00:00
final_candidate = 0 ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " IQK: is13simular final_candidate is %x \n " , final_candidate ) ) ;
break ;
}
is23simular = phy_SimularityCompare_8188E ( pAdapter , result , 1 , 2 ) ;
2015-08-15 18:02:34 +00:00
if ( is23simular ) {
2014-12-19 06:59:46 +00:00
final_candidate = 1 ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " IQK: is23simular final_candidate is %x \n " , final_candidate ) ) ;
}
else
{
/*
2015-08-15 18:06:32 +00:00
for ( i = 0 ; i < 8 ; i + + )
2014-12-19 06:59:46 +00:00
RegTmp + = result [ 3 ] [ i ] ;
2015-08-15 18:02:34 +00:00
if ( RegTmp ! = 0 )
2014-12-19 06:59:46 +00:00
final_candidate = 3 ;
else
final_candidate = 0xFF ;
*/
final_candidate = 3 ;
}
}
}
2015-08-15 18:00:19 +00:00
/* RT_TRACE(COMP_INIT,DBG_LOUD,("Release Mutex in IQCalibrate\n")); */
2014-12-19 06:59:46 +00:00
for ( i = 0 ; i < 4 ; i + + )
{
RegE94 = result [ i ] [ 0 ] ;
RegE9C = result [ i ] [ 1 ] ;
RegEA4 = result [ i ] [ 2 ] ;
RegEAC = result [ i ] [ 3 ] ;
RegEB4 = result [ i ] [ 4 ] ;
RegEBC = result [ i ] [ 5 ] ;
RegEC4 = result [ i ] [ 6 ] ;
RegECC = result [ i ] [ 7 ] ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " IQK: RegE94=%x RegE9C=%x RegEA4=%x RegEAC=%x RegEB4=%x RegEBC=%x RegEC4=%x RegECC=%x \n " , RegE94 , RegE9C , RegEA4 , RegEAC , RegEB4 , RegEBC , RegEC4 , RegECC ) ) ;
}
2015-08-15 18:02:34 +00:00
if ( final_candidate ! = 0xff )
2014-12-19 06:59:46 +00:00
{
pDM_Odm - > RFCalibrateInfo . RegE94 = RegE94 = result [ final_candidate ] [ 0 ] ;
pDM_Odm - > RFCalibrateInfo . RegE9C = RegE9C = result [ final_candidate ] [ 1 ] ;
RegEA4 = result [ final_candidate ] [ 2 ] ;
RegEAC = result [ final_candidate ] [ 3 ] ;
pDM_Odm - > RFCalibrateInfo . RegEB4 = RegEB4 = result [ final_candidate ] [ 4 ] ;
pDM_Odm - > RFCalibrateInfo . RegEBC = RegEBC = result [ final_candidate ] [ 5 ] ;
RegEC4 = result [ final_candidate ] [ 6 ] ;
RegECC = result [ final_candidate ] [ 7 ] ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " IQK: final_candidate is %x \n " , final_candidate ) ) ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " IQK: RegE94=%x RegE9C=%x RegEA4=%x RegEAC=%x RegEB4=%x RegEBC=%x RegEC4=%x RegECC=%x \n " , RegE94 , RegE9C , RegEA4 , RegEAC , RegEB4 , RegEBC , RegEC4 , RegECC ) ) ;
2015-03-02 23:25:27 +00:00
bPathAOK = bPathBOK = true ;
2014-12-30 19:48:00 +00:00
} else {
2014-12-19 06:59:46 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " IQK: FAIL use default value \n " ) ) ;
2015-02-20 00:51:33 +00:00
pDM_Odm - > RFCalibrateInfo . RegE94 = pDM_Odm - > RFCalibrateInfo . RegEB4 = 0x100 ; /* X default value */
pDM_Odm - > RFCalibrateInfo . RegE9C = pDM_Odm - > RFCalibrateInfo . RegEBC = 0x0 ; /* Y default value */
2014-12-19 06:59:46 +00:00
}
2015-08-15 18:02:34 +00:00
if ( ( RegE94 ! = 0 ) /*&&(RegEA4 != 0)*/ )
2014-12-19 06:59:46 +00:00
_PHY_PathAFillIQKMatrix ( pAdapter , bPathAOK , result , final_candidate , ( RegEA4 = = 0 ) ) ;
2014-12-30 19:48:00 +00:00
if ( is2T ) {
2015-08-15 18:02:34 +00:00
if ( ( RegEB4 ! = 0 ) /*&&(RegEC4 != 0)*/ )
2014-12-19 06:59:46 +00:00
_PHY_PathBFillIQKMatrix ( pAdapter , bPathBOK , result , final_candidate , ( RegEC4 = = 0 ) ) ;
}
2015-03-10 16:18:03 +00:00
Indexforchannel = ODM_GetRightChnlPlaceforIQK ( pHalData - > CurrentChannel ) ;
2014-12-19 06:59:46 +00:00
2015-02-20 00:51:33 +00:00
/* To Fix BSOD when final_candidate is 0xff */
/* by sherry 20120321 */
2015-08-15 18:02:34 +00:00
if ( final_candidate < 4 )
2014-12-19 06:59:46 +00:00
{
2015-08-15 18:06:32 +00:00
for ( i = 0 ; i < IQK_Matrix_REG_NUM ; i + + )
2014-12-19 06:59:46 +00:00
pDM_Odm - > RFCalibrateInfo . IQKMatrixRegSetting [ Indexforchannel ] . Value [ 0 ] [ i ] = result [ final_candidate ] [ i ] ;
2015-03-02 23:25:27 +00:00
pDM_Odm - > RFCalibrateInfo . IQKMatrixRegSetting [ Indexforchannel ] . bIQKDone = true ;
2014-12-19 06:59:46 +00:00
}
2015-02-20 00:51:33 +00:00
/* RTPRINT(FINIT, INIT_IQK, ("\nIQK OK Indexforchannel %d.\n", Indexforchannel)); */
2014-12-19 06:59:46 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " \n IQK OK Indexforchannel %d. \n " , Indexforchannel ) ) ;
_PHY_SaveADDARegisters ( pAdapter , IQK_BB_REG_92C , pDM_Odm - > RFCalibrateInfo . IQK_BB_backup_recover , 9 ) ;
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " IQK finished \n " ) ) ;
}
2014-12-29 02:06:17 +00:00
void
2014-12-19 06:59:46 +00:00
PHY_LCCalibrate_8188E (
2015-03-13 17:06:38 +00:00
struct adapter * pAdapter
2014-12-19 06:59:46 +00:00
)
{
2015-03-02 23:25:27 +00:00
bool bStartContTx = false , bSingleTone = false , bCarrierSuppression = false ;
2014-12-30 22:55:10 +00:00
u32 timeout = 2000 , timecount = 0 ;
2014-12-19 06:59:46 +00:00
HAL_DATA_TYPE * pHalData = GET_HAL_DATA ( pAdapter ) ;
PDM_ODM_T pDM_Odm = & pHalData - > odmpriv ;
# if (MP_DRIVER == 1)
2015-03-17 01:14:52 +00:00
struct mpt_context * pMptCtx = & ( pAdapter - > mppriv . MptCtx ) ;
2015-02-20 00:51:33 +00:00
# endif /* MP_DRIVER == 1) */
2014-12-19 06:59:46 +00:00
# if MP_DRIVER == 1
if ( * ( pDM_Odm - > mp_mode ) = = 1 )
{
bStartContTx = pMptCtx - > bStartContTx ;
bSingleTone = pMptCtx - > bSingleTone ;
bCarrierSuppression = pMptCtx - > bCarrierSuppression ;
}
# endif
# if DISABLE_BB_RF
return ;
# endif
2015-08-15 18:02:34 +00:00
if ( ! ( pDM_Odm - > SupportAbility & ODM_RF_CALIBRATION ) )
2014-12-19 06:59:46 +00:00
{
return ;
}
2015-02-20 00:51:33 +00:00
/* 20120213<Kordan> Turn on when continuous Tx to pass lab testing. (required by Edlu) */
2015-08-15 18:02:34 +00:00
if ( bSingleTone | | bCarrierSuppression )
2014-12-19 06:59:46 +00:00
return ;
2015-08-15 18:04:12 +00:00
while ( * ( pDM_Odm - > pbScanInProcess ) & & timecount < timeout )
2014-12-19 06:59:46 +00:00
{
ODM_delay_ms ( 50 ) ;
timecount + = 50 ;
}
2015-03-02 23:25:27 +00:00
pDM_Odm - > RFCalibrateInfo . bLCKInProgress = true ;
2014-12-19 06:59:46 +00:00
2015-02-20 00:51:33 +00:00
/* ODM_RT_TRACE(pDM_Odm,ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("LCK:Start!!!interface %d currentband %x delay %d ms\n", pDM_Odm->interfaceIndex, pHalData->CurrentBandType92D, timecount)); */
2014-12-19 06:59:46 +00:00
2015-08-15 18:02:34 +00:00
if ( pDM_Odm - > RFType = = ODM_2T2R )
2014-12-19 06:59:46 +00:00
{
2015-03-02 23:25:27 +00:00
phy_LCCalibrate_8188E ( pAdapter , true ) ;
2014-12-19 06:59:46 +00:00
}
else
{
2015-02-20 00:51:33 +00:00
/* For 88C 1T1R */
2015-03-02 23:25:27 +00:00
phy_LCCalibrate_8188E ( pAdapter , false ) ;
2014-12-19 06:59:46 +00:00
}
2015-03-02 23:25:27 +00:00
pDM_Odm - > RFCalibrateInfo . bLCKInProgress = false ;
2014-12-19 06:59:46 +00:00
ODM_RT_TRACE ( pDM_Odm , ODM_COMP_CALIBRATION , ODM_DBG_LOUD , ( " LCK:Finish!!!interface %d \n " , pDM_Odm - > InterfaceIndex ) ) ;
}
2014-12-29 02:06:17 +00:00
void
2014-12-19 06:59:46 +00:00
PHY_APCalibrate_8188E (
2015-03-13 17:06:38 +00:00
struct adapter * pAdapter ,
s8 delta
2014-12-19 06:59:46 +00:00
)
{
}
2015-01-29 21:27:28 +00:00
static void phy_SetRFPathSwitch_8188E (
2015-03-13 17:06:38 +00:00
struct adapter * pAdapter ,
bool bMain ,
bool is2T
2014-12-19 06:59:46 +00:00
)
{
HAL_DATA_TYPE * pHalData = GET_HAL_DATA ( pAdapter ) ;
PDM_ODM_T pDM_Odm = & pHalData - > odmpriv ;
2015-08-15 18:02:34 +00:00
if ( pAdapter - > hw_init_completed = = false )
2014-12-19 06:59:46 +00:00
{
2014-12-30 23:50:44 +00:00
u8 u1bTmp ;
2014-12-19 06:59:46 +00:00
u1bTmp = ODM_Read1Byte ( pDM_Odm , REG_LEDCFG2 ) | BIT7 ;
ODM_Write1Byte ( pDM_Odm , REG_LEDCFG2 , u1bTmp ) ;
2015-02-20 00:51:33 +00:00
/* ODM_SetBBReg(pDM_Odm, REG_LEDCFG0, BIT23, 0x01); */
2014-12-19 06:59:46 +00:00
ODM_SetBBReg ( pDM_Odm , rFPGA0_XAB_RFParameter , BIT13 , 0x01 ) ;
}
2015-08-15 18:02:34 +00:00
if ( is2T ) /* 92C */
2014-12-19 06:59:46 +00:00
{
2015-08-15 18:02:34 +00:00
if ( bMain )
2015-02-20 00:51:33 +00:00
ODM_SetBBReg ( pDM_Odm , rFPGA0_XB_RFInterfaceOE , BIT5 | BIT6 , 0x1 ) ; /* 92C_Path_A */
2014-12-19 06:59:46 +00:00
else
2015-02-20 00:51:33 +00:00
ODM_SetBBReg ( pDM_Odm , rFPGA0_XB_RFInterfaceOE , BIT5 | BIT6 , 0x2 ) ; /* BT */
2014-12-19 06:59:46 +00:00
}
2015-02-20 00:51:33 +00:00
else /* 88C */
2014-12-19 06:59:46 +00:00
{
2015-08-15 18:02:34 +00:00
if ( bMain )
2015-02-20 00:51:33 +00:00
ODM_SetBBReg ( pDM_Odm , rFPGA0_XA_RFInterfaceOE , BIT8 | BIT9 , 0x2 ) ; /* Main */
2014-12-19 06:59:46 +00:00
else
2015-02-20 00:51:33 +00:00
ODM_SetBBReg ( pDM_Odm , rFPGA0_XA_RFInterfaceOE , BIT8 | BIT9 , 0x1 ) ; /* Aux */
2014-12-19 06:59:46 +00:00
}
}
2014-12-29 02:06:17 +00:00
void PHY_SetRFPathSwitch_8188E (
2015-03-13 17:06:38 +00:00
struct adapter * pAdapter ,
bool bMain
2014-12-19 06:59:46 +00:00
)
{
HAL_DATA_TYPE * pHalData = GET_HAL_DATA ( pAdapter ) ;
PDM_ODM_T pDM_Odm = & pHalData - > odmpriv ;
# if DISABLE_BB_RF
return ;
# endif
2015-08-15 18:02:34 +00:00
if ( pDM_Odm - > RFType = = ODM_2T2R )
2014-12-19 06:59:46 +00:00
{
2015-03-02 23:25:27 +00:00
phy_SetRFPathSwitch_8188E ( pAdapter , bMain , true ) ;
2014-12-19 06:59:46 +00:00
}
else
{
2015-02-20 00:51:33 +00:00
/* For 88C 1T1R */
2015-03-02 23:25:27 +00:00
phy_SetRFPathSwitch_8188E ( pAdapter , bMain , false ) ;
2014-12-19 06:59:46 +00:00
}
}