2016-03-27 17:56:02 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
|
2017-04-07 11:39:45 +00:00
|
|
|
*
|
2016-03-27 17:56:02 +00:00
|
|
|
* 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
|
|
|
|
*
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
#define _HAL_PHY_C_
|
|
|
|
|
|
|
|
#include <drv_types.h>
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/* ********************************************************************************
|
|
|
|
* Constant.
|
|
|
|
* ********************************************************************************
|
|
|
|
* 2008/11/20 MH For Debug only, RF */
|
2016-03-27 17:56:02 +00:00
|
|
|
static RF_SHADOW_T RF_Shadow[RF6052_MAX_PATH][RF6052_MAX_REG];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function: PHY_CalculateBitShift
|
|
|
|
*
|
|
|
|
* OverView: Get shifted position of the BitMask
|
|
|
|
*
|
|
|
|
* Input:
|
2017-04-07 11:39:45 +00:00
|
|
|
* u4Byte BitMask,
|
2016-03-27 17:56:02 +00:00
|
|
|
*
|
|
|
|
* Output: none
|
|
|
|
* Return: u4Byte Return the shift bit bit position of the mask
|
|
|
|
*/
|
|
|
|
u32
|
|
|
|
PHY_CalculateBitShift(
|
|
|
|
u32 BitMask
|
2017-04-07 11:39:45 +00:00
|
|
|
)
|
2016-03-27 17:56:02 +00:00
|
|
|
{
|
|
|
|
u32 i;
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
for (i = 0; i <= 31; i++) {
|
|
|
|
if (((BitMask >> i) & 0x1) == 1)
|
2016-03-27 17:56:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
return i;
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
/*
|
|
|
|
* ==> RF shadow Operation API Code Section!!!
|
|
|
|
*
|
|
|
|
*-----------------------------------------------------------------------------
|
2016-03-27 17:56:02 +00:00
|
|
|
* Function: PHY_RFShadowRead
|
|
|
|
* PHY_RFShadowWrite
|
|
|
|
* PHY_RFShadowCompare
|
|
|
|
* PHY_RFShadowRecorver
|
|
|
|
* PHY_RFShadowCompareAll
|
|
|
|
* PHY_RFShadowRecorverAll
|
|
|
|
* PHY_RFShadowCompareFlagSet
|
|
|
|
* PHY_RFShadowRecorverFlagSet
|
|
|
|
*
|
|
|
|
* Overview: When we set RF register, we must write shadow at first.
|
|
|
|
* When we are running, we must compare shadow abd locate error addr.
|
|
|
|
* Decide to recorver or not.
|
|
|
|
*
|
|
|
|
* Input: NONE
|
|
|
|
*
|
|
|
|
* Output: NONE
|
|
|
|
*
|
|
|
|
* Return: NONE
|
|
|
|
*
|
|
|
|
* Revised History:
|
|
|
|
* When Who Remark
|
2017-04-07 11:39:45 +00:00
|
|
|
* 11/20/2008 MHC Create Version 0.
|
2016-03-27 17:56:02 +00:00
|
|
|
*
|
|
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
u32
|
|
|
|
PHY_RFShadowRead(
|
|
|
|
IN PADAPTER Adapter,
|
|
|
|
IN u8 eRFPath,
|
|
|
|
IN u32 Offset)
|
|
|
|
{
|
|
|
|
return RF_Shadow[eRFPath][Offset].Value;
|
|
|
|
|
|
|
|
} /* PHY_RFShadowRead */
|
|
|
|
|
|
|
|
|
|
|
|
VOID
|
|
|
|
PHY_RFShadowWrite(
|
|
|
|
IN PADAPTER Adapter,
|
|
|
|
IN u8 eRFPath,
|
|
|
|
IN u32 Offset,
|
|
|
|
IN u32 Data)
|
|
|
|
{
|
|
|
|
RF_Shadow[eRFPath][Offset].Value = (Data & bRFRegOffsetMask);
|
|
|
|
RF_Shadow[eRFPath][Offset].Driver_Write = _TRUE;
|
|
|
|
|
|
|
|
} /* PHY_RFShadowWrite */
|
|
|
|
|
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
PHY_RFShadowCompare(
|
|
|
|
IN PADAPTER Adapter,
|
|
|
|
IN u8 eRFPath,
|
|
|
|
IN u32 Offset)
|
|
|
|
{
|
|
|
|
u32 reg;
|
2017-04-07 11:39:45 +00:00
|
|
|
/* Check if we need to check the register */
|
|
|
|
if (RF_Shadow[eRFPath][Offset].Compare == _TRUE) {
|
2016-03-27 17:56:02 +00:00
|
|
|
reg = rtw_hal_read_rfreg(Adapter, eRFPath, Offset, bRFRegOffsetMask);
|
2017-04-07 11:39:45 +00:00
|
|
|
/* Compare shadow and real rf register for 20bits!! */
|
|
|
|
if (RF_Shadow[eRFPath][Offset].Value != reg) {
|
|
|
|
/* Locate error position. */
|
2016-03-27 17:56:02 +00:00
|
|
|
RF_Shadow[eRFPath][Offset].ErrorOrNot = _TRUE;
|
|
|
|
}
|
|
|
|
return RF_Shadow[eRFPath][Offset].ErrorOrNot ;
|
|
|
|
}
|
|
|
|
return _FALSE;
|
|
|
|
} /* PHY_RFShadowCompare */
|
|
|
|
|
|
|
|
|
|
|
|
VOID
|
|
|
|
PHY_RFShadowRecorver(
|
|
|
|
IN PADAPTER Adapter,
|
|
|
|
IN u8 eRFPath,
|
|
|
|
IN u32 Offset)
|
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
/* Check if the address is error */
|
|
|
|
if (RF_Shadow[eRFPath][Offset].ErrorOrNot == _TRUE) {
|
|
|
|
/* Check if we need to recorver the register. */
|
|
|
|
if (RF_Shadow[eRFPath][Offset].Recorver == _TRUE) {
|
2016-03-27 17:56:02 +00:00
|
|
|
rtw_hal_write_rfreg(Adapter, eRFPath, Offset, bRFRegOffsetMask,
|
2017-04-07 11:39:45 +00:00
|
|
|
RF_Shadow[eRFPath][Offset].Value);
|
2016-03-27 17:56:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} /* PHY_RFShadowRecorver */
|
|
|
|
|
|
|
|
|
|
|
|
VOID
|
|
|
|
PHY_RFShadowCompareAll(
|
|
|
|
IN PADAPTER Adapter)
|
|
|
|
{
|
|
|
|
u8 eRFPath = 0 ;
|
2017-04-07 11:39:45 +00:00
|
|
|
u32 Offset = 0, maxReg = GET_RF6052_REAL_MAX_REG(Adapter);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++) {
|
2016-03-27 17:56:02 +00:00
|
|
|
for (Offset = 0; Offset < maxReg; Offset++)
|
|
|
|
PHY_RFShadowCompare(Adapter, eRFPath, Offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
} /* PHY_RFShadowCompareAll */
|
|
|
|
|
|
|
|
|
|
|
|
VOID
|
|
|
|
PHY_RFShadowRecorverAll(
|
|
|
|
IN PADAPTER Adapter)
|
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
u8 eRFPath = 0;
|
|
|
|
u32 Offset = 0, maxReg = GET_RF6052_REAL_MAX_REG(Adapter);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++) {
|
2016-03-27 17:56:02 +00:00
|
|
|
for (Offset = 0; Offset < maxReg; Offset++)
|
|
|
|
PHY_RFShadowRecorver(Adapter, eRFPath, Offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
} /* PHY_RFShadowRecorverAll */
|
|
|
|
|
|
|
|
|
|
|
|
VOID
|
|
|
|
PHY_RFShadowCompareFlagSet(
|
|
|
|
IN PADAPTER Adapter,
|
|
|
|
IN u8 eRFPath,
|
|
|
|
IN u32 Offset,
|
|
|
|
IN u8 Type)
|
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
/* Set True or False!!! */
|
2016-03-27 17:56:02 +00:00
|
|
|
RF_Shadow[eRFPath][Offset].Compare = Type;
|
|
|
|
|
|
|
|
} /* PHY_RFShadowCompareFlagSet */
|
|
|
|
|
|
|
|
|
|
|
|
VOID
|
|
|
|
PHY_RFShadowRecorverFlagSet(
|
|
|
|
IN PADAPTER Adapter,
|
|
|
|
IN u8 eRFPath,
|
|
|
|
IN u32 Offset,
|
|
|
|
IN u8 Type)
|
|
|
|
{
|
2017-04-07 11:39:45 +00:00
|
|
|
/* Set True or False!!! */
|
|
|
|
RF_Shadow[eRFPath][Offset].Recorver = Type;
|
2016-03-27 17:56:02 +00:00
|
|
|
|
|
|
|
} /* PHY_RFShadowRecorverFlagSet */
|
|
|
|
|
|
|
|
|
|
|
|
VOID
|
|
|
|
PHY_RFShadowCompareFlagSetAll(
|
|
|
|
IN PADAPTER Adapter)
|
|
|
|
{
|
|
|
|
u8 eRFPath = 0;
|
2017-04-07 11:39:45 +00:00
|
|
|
u32 Offset = 0, maxReg = GET_RF6052_REAL_MAX_REG(Adapter);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++) {
|
|
|
|
for (Offset = 0; Offset < maxReg; Offset++) {
|
|
|
|
/* 2008/11/20 MH For S3S4 test, we only check reg 26/27 now!!!! */
|
2016-03-27 17:56:02 +00:00
|
|
|
if (Offset != 0x26 && Offset != 0x27)
|
|
|
|
PHY_RFShadowCompareFlagSet(Adapter, eRFPath, Offset, _FALSE);
|
|
|
|
else
|
|
|
|
PHY_RFShadowCompareFlagSet(Adapter, eRFPath, Offset, _TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} /* PHY_RFShadowCompareFlagSetAll */
|
|
|
|
|
|
|
|
|
|
|
|
VOID
|
|
|
|
PHY_RFShadowRecorverFlagSetAll(
|
|
|
|
IN PADAPTER Adapter)
|
|
|
|
{
|
|
|
|
u8 eRFPath = 0;
|
2017-04-07 11:39:45 +00:00
|
|
|
u32 Offset = 0, maxReg = GET_RF6052_REAL_MAX_REG(Adapter);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++) {
|
|
|
|
for (Offset = 0; Offset < maxReg; Offset++) {
|
|
|
|
/* 2008/11/20 MH For S3S4 test, we only check reg 26/27 now!!!! */
|
2016-03-27 17:56:02 +00:00
|
|
|
if (Offset != 0x26 && Offset != 0x27)
|
|
|
|
PHY_RFShadowRecorverFlagSet(Adapter, eRFPath, Offset, _FALSE);
|
|
|
|
else
|
|
|
|
PHY_RFShadowRecorverFlagSet(Adapter, eRFPath, Offset, _TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} /* PHY_RFShadowCompareFlagSetAll */
|
|
|
|
|
|
|
|
VOID
|
|
|
|
PHY_RFShadowRefresh(
|
|
|
|
IN PADAPTER Adapter)
|
|
|
|
{
|
|
|
|
u8 eRFPath = 0;
|
2017-04-07 11:39:45 +00:00
|
|
|
u32 Offset = 0, maxReg = GET_RF6052_REAL_MAX_REG(Adapter);
|
2016-03-27 17:56:02 +00:00
|
|
|
|
2017-04-07 11:39:45 +00:00
|
|
|
for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++) {
|
|
|
|
for (Offset = 0; Offset < maxReg; Offset++) {
|
2016-03-27 17:56:02 +00:00
|
|
|
RF_Shadow[eRFPath][Offset].Value = 0;
|
|
|
|
RF_Shadow[eRFPath][Offset].Compare = _FALSE;
|
|
|
|
RF_Shadow[eRFPath][Offset].Recorver = _FALSE;
|
|
|
|
RF_Shadow[eRFPath][Offset].ErrorOrNot = _FALSE;
|
|
|
|
RF_Shadow[eRFPath][Offset].Driver_Write = _FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} /* PHY_RFShadowRead */
|