2022-06-08 23:46:35 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
/* Copyright(c) 2007 - 2011 Realtek Corporation. */
|
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Module: rtl8192c_rf6052.c ( Source C File)
|
|
|
|
*
|
|
|
|
* Note: Provide RF 6052 series relative API.
|
|
|
|
*
|
|
|
|
* Function:
|
|
|
|
*
|
|
|
|
* Export:
|
|
|
|
*
|
|
|
|
* Abbrev:
|
|
|
|
*
|
|
|
|
* History:
|
|
|
|
* Data Who Remark
|
|
|
|
*
|
|
|
|
* 09/25/2008 MHC Create initial version.
|
|
|
|
* 11/05/2008 MHC Add API for tw power setting.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
#define _RTL8188E_RF6052_C_
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
#include "../include/osdep_service.h"
|
|
|
|
#include "../include/drv_types.h"
|
|
|
|
#include "../include/rtl8188e_hal.h"
|
2013-05-19 04:28:07 +00:00
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------
|
|
|
|
* Function: PHY_RF6052SetBandwidth()
|
|
|
|
*
|
|
|
|
* Overview: This function is called by SetBWModeCallback8190Pci() only
|
|
|
|
*
|
2013-08-08 14:31:29 +00:00
|
|
|
* Input: struct adapter *Adapter
|
2013-07-10 18:25:07 +00:00
|
|
|
* WIRELESS_BANDWIDTH_E Bandwidth 20M or 40M
|
2013-05-19 04:28:07 +00:00
|
|
|
*
|
|
|
|
* Output: NONE
|
|
|
|
*
|
|
|
|
* Return: NONE
|
|
|
|
*
|
|
|
|
* Note: For RF type 0222D
|
|
|
|
*---------------------------------------------------------------------------*/
|
2013-08-08 14:31:29 +00:00
|
|
|
void rtl8188e_PHY_RF6052SetBandwidth(struct adapter *Adapter,
|
|
|
|
enum ht_channel_width Bandwidth)
|
2013-05-19 04:28:07 +00:00
|
|
|
{
|
2022-06-08 23:46:35 +00:00
|
|
|
struct hal_data_8188e *pHalData = &Adapter->haldata;
|
2013-08-08 14:31:29 +00:00
|
|
|
|
|
|
|
switch (Bandwidth) {
|
|
|
|
case HT_CHANNEL_WIDTH_20:
|
2022-06-08 23:46:35 +00:00
|
|
|
pHalData->RfRegChnlVal = ((pHalData->RfRegChnlVal & 0xfffff3ff) | BIT(10) | BIT(11));
|
|
|
|
rtl8188e_PHY_SetRFReg(Adapter, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal);
|
2013-08-08 14:31:29 +00:00
|
|
|
break;
|
|
|
|
case HT_CHANNEL_WIDTH_40:
|
2022-06-08 23:46:35 +00:00
|
|
|
pHalData->RfRegChnlVal = ((pHalData->RfRegChnlVal & 0xfffff3ff) | BIT(10));
|
|
|
|
rtl8188e_PHY_SetRFReg(Adapter, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal);
|
2013-08-08 14:31:29 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------
|
|
|
|
* Function: PHY_RF6052SetCckTxPower
|
|
|
|
*
|
|
|
|
* Overview:
|
|
|
|
*
|
|
|
|
* Input: NONE
|
|
|
|
*
|
|
|
|
* Output: NONE
|
|
|
|
*
|
|
|
|
* Return: NONE
|
|
|
|
*
|
|
|
|
* Revised History:
|
|
|
|
* When Who Remark
|
|
|
|
* 11/05/2008 MHC Simulate 8192series..
|
|
|
|
*
|
|
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
|
2013-05-19 04:37:45 +00:00
|
|
|
void
|
2013-05-19 04:28:07 +00:00
|
|
|
rtl8188e_PHY_RF6052SetCckTxPower(
|
2013-08-08 14:31:29 +00:00
|
|
|
struct adapter *Adapter,
|
|
|
|
u8 *pPowerlevel)
|
2013-05-19 04:28:07 +00:00
|
|
|
{
|
2022-06-08 23:46:35 +00:00
|
|
|
struct hal_data_8188e *pHalData = &Adapter->haldata;
|
2013-10-19 17:45:47 +00:00
|
|
|
struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv;
|
2013-08-08 14:31:29 +00:00
|
|
|
u32 TxAGC[2] = {0, 0}, tmpval = 0, pwrtrac_value;
|
|
|
|
u8 idx1, idx2;
|
|
|
|
u8 *ptr;
|
|
|
|
u8 direction;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-08 14:31:29 +00:00
|
|
|
if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) {
|
2013-05-19 04:28:07 +00:00
|
|
|
TxAGC[RF_PATH_A] = 0x3f3f3f3f;
|
|
|
|
TxAGC[RF_PATH_B] = 0x3f3f3f3f;
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) {
|
|
|
|
TxAGC[idx1] =
|
|
|
|
pPowerlevel[idx1] | (pPowerlevel[idx1] << 8) |
|
|
|
|
(pPowerlevel[idx1] << 16) | (pPowerlevel[idx1] << 24);
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
2013-08-08 14:31:29 +00:00
|
|
|
} else {
|
2022-06-08 23:46:35 +00:00
|
|
|
for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) {
|
|
|
|
TxAGC[idx1] =
|
|
|
|
pPowerlevel[idx1] | (pPowerlevel[idx1] << 8) |
|
|
|
|
(pPowerlevel[idx1] << 16) | (pPowerlevel[idx1] << 24);
|
|
|
|
}
|
|
|
|
if (pHalData->EEPROMRegulatory == 0) {
|
|
|
|
tmpval = (pHalData->MCSTxPowerLevelOriginalOffset[0][6]) +
|
|
|
|
(pHalData->MCSTxPowerLevelOriginalOffset[0][7] << 8);
|
|
|
|
TxAGC[RF_PATH_A] += tmpval;
|
|
|
|
|
|
|
|
tmpval = (pHalData->MCSTxPowerLevelOriginalOffset[0][14]) +
|
|
|
|
(pHalData->MCSTxPowerLevelOriginalOffset[0][15] << 24);
|
|
|
|
TxAGC[RF_PATH_B] += tmpval;
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
|
|
|
}
|
2013-08-08 14:31:29 +00:00
|
|
|
for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) {
|
2022-06-08 23:46:35 +00:00
|
|
|
ptr = (u8 *)(&TxAGC[idx1]);
|
2013-08-08 14:31:29 +00:00
|
|
|
for (idx2 = 0; idx2 < 4; idx2++) {
|
2013-05-19 04:28:07 +00:00
|
|
|
if (*ptr > RF6052_MAX_TX_PWR)
|
|
|
|
*ptr = RF6052_MAX_TX_PWR;
|
|
|
|
ptr++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ODM_TxPwrTrackAdjust88E(&pHalData->odmpriv, 1, &direction, &pwrtrac_value);
|
|
|
|
|
2013-08-08 14:31:29 +00:00
|
|
|
if (direction == 1) {
|
2013-11-29 22:10:20 +00:00
|
|
|
/* Increase TX power */
|
2013-05-19 04:28:07 +00:00
|
|
|
TxAGC[0] += pwrtrac_value;
|
|
|
|
TxAGC[1] += pwrtrac_value;
|
2013-08-08 14:31:29 +00:00
|
|
|
} else if (direction == 2) {
|
2013-11-29 22:10:20 +00:00
|
|
|
/* Decrease TX power */
|
2013-05-19 04:28:07 +00:00
|
|
|
TxAGC[0] -= pwrtrac_value;
|
|
|
|
TxAGC[1] -= pwrtrac_value;
|
|
|
|
}
|
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* rf-A cck tx power */
|
2022-06-08 23:46:35 +00:00
|
|
|
tmpval = TxAGC[RF_PATH_A] & 0xff;
|
|
|
|
rtl8188e_PHY_SetBBReg(Adapter, rTxAGC_A_CCK1_Mcs32, bMaskByte1, tmpval);
|
|
|
|
tmpval = TxAGC[RF_PATH_A] >> 8;
|
|
|
|
rtl8188e_PHY_SetBBReg(Adapter, rTxAGC_B_CCK11_A_CCK2_11, 0xffffff00, tmpval);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* rf-B cck tx power */
|
2022-06-08 23:46:35 +00:00
|
|
|
tmpval = TxAGC[RF_PATH_B] >> 24;
|
|
|
|
rtl8188e_PHY_SetBBReg(Adapter, rTxAGC_B_CCK11_A_CCK2_11, bMaskByte0, tmpval);
|
|
|
|
tmpval = TxAGC[RF_PATH_B] & 0x00ffffff;
|
|
|
|
rtl8188e_PHY_SetBBReg(Adapter, rTxAGC_B_CCK1_55_Mcs32, 0xffffff00, tmpval);
|
2013-05-19 04:28:07 +00:00
|
|
|
} /* PHY_RF6052SetCckTxPower */
|
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* */
|
|
|
|
/* powerbase0 for OFDM rates */
|
|
|
|
/* powerbase1 for HT MCS rates */
|
|
|
|
/* */
|
2013-08-08 14:31:29 +00:00
|
|
|
static void getpowerbase88e(struct adapter *Adapter, u8 *pPowerLevelOFDM,
|
|
|
|
u8 *pPowerLevelBW20, u8 *pPowerLevelBW40, u8 Channel, u32 *OfdmBase, u32 *MCSBase)
|
2013-05-19 04:28:07 +00:00
|
|
|
{
|
2022-06-08 23:46:35 +00:00
|
|
|
struct hal_data_8188e *pHalData = &Adapter->haldata;
|
2013-08-08 14:31:29 +00:00
|
|
|
u32 powerBase0, powerBase1;
|
2022-06-08 23:46:35 +00:00
|
|
|
u8 i;
|
2013-08-08 14:31:29 +00:00
|
|
|
|
|
|
|
for (i = 0; i < 2; i++) {
|
2013-05-19 04:28:07 +00:00
|
|
|
powerBase0 = pPowerLevelOFDM[i];
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
powerBase0 = (powerBase0 << 24) | (powerBase0 << 16) | (powerBase0 << 8) | powerBase0;
|
|
|
|
*(OfdmBase + i) = powerBase0;
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
2022-06-08 23:46:35 +00:00
|
|
|
|
|
|
|
/* Check HT20 to HT40 diff */
|
|
|
|
if (pHalData->CurrentChannelBW == HT_CHANNEL_WIDTH_20)
|
|
|
|
powerBase1 = pPowerLevelBW20[0];
|
|
|
|
else
|
|
|
|
powerBase1 = pPowerLevelBW40[0];
|
|
|
|
powerBase1 = (powerBase1 << 24) | (powerBase1 << 16) | (powerBase1 << 8) | powerBase1;
|
|
|
|
*MCSBase = powerBase1;
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
2022-06-08 23:46:35 +00:00
|
|
|
|
2013-08-08 14:31:29 +00:00
|
|
|
static void get_rx_power_val_by_reg(struct adapter *Adapter, u8 Channel,
|
|
|
|
u8 index, u32 *powerBase0, u32 *powerBase1,
|
|
|
|
u32 *pOutWriteVal)
|
2013-05-19 04:28:07 +00:00
|
|
|
{
|
2022-06-08 23:46:35 +00:00
|
|
|
struct hal_data_8188e *pHalData = &Adapter->haldata;
|
2013-08-14 17:03:28 +00:00
|
|
|
u8 i, chnlGroup = 0, pwr_diff_limit[4], customer_pwr_limit;
|
|
|
|
s8 pwr_diff = 0;
|
|
|
|
u32 writeVal, customer_limit, rf;
|
|
|
|
u8 Regulatory = pHalData->EEPROMRegulatory;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* Index 0 & 1= legacy OFDM, 2-5=HT_MCS rate */
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-08 14:31:29 +00:00
|
|
|
for (rf = 0; rf < 2; rf++) {
|
|
|
|
switch (Regulatory) {
|
|
|
|
case 0: /* Realtek better performance */
|
|
|
|
/* increase power diff defined by Realtek for large power */
|
|
|
|
chnlGroup = 0;
|
2022-06-08 23:46:35 +00:00
|
|
|
writeVal = pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index + (rf ? 8 : 0)] +
|
2013-08-08 14:31:29 +00:00
|
|
|
((index < 2) ? powerBase0[rf] : powerBase1[rf]);
|
|
|
|
break;
|
|
|
|
case 1: /* Realtek regulatory */
|
|
|
|
/* increase power diff defined by Realtek for regulatory */
|
|
|
|
if (pHalData->pwrGroupCnt == 1)
|
2013-05-19 04:28:07 +00:00
|
|
|
chnlGroup = 0;
|
2022-06-08 23:46:35 +00:00
|
|
|
if (pHalData->pwrGroupCnt >= MAX_PG_GROUP) {
|
2013-11-29 22:10:20 +00:00
|
|
|
if (Channel < 3) /* Channel 1-2 */
|
2013-08-08 14:31:29 +00:00
|
|
|
chnlGroup = 0;
|
|
|
|
else if (Channel < 6) /* Channel 3-5 */
|
|
|
|
chnlGroup = 1;
|
|
|
|
else if (Channel < 9) /* Channel 6-8 */
|
|
|
|
chnlGroup = 2;
|
|
|
|
else if (Channel < 12) /* Channel 9-11 */
|
|
|
|
chnlGroup = 3;
|
|
|
|
else if (Channel < 14) /* Channel 12-13 */
|
|
|
|
chnlGroup = 4;
|
|
|
|
else if (Channel == 14) /* Channel 14 */
|
|
|
|
chnlGroup = 5;
|
|
|
|
}
|
2022-06-08 23:46:35 +00:00
|
|
|
writeVal = pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index + (rf ? 8 : 0)] +
|
2013-08-08 14:31:29 +00:00
|
|
|
((index < 2) ? powerBase0[rf] : powerBase1[rf]);
|
|
|
|
break;
|
|
|
|
case 2: /* Better regulatory */
|
|
|
|
/* don't increase any power diff */
|
|
|
|
writeVal = ((index < 2) ? powerBase0[rf] : powerBase1[rf]);
|
|
|
|
break;
|
|
|
|
case 3: /* Customer defined power diff. */
|
|
|
|
/* increase power diff defined by customer. */
|
|
|
|
chnlGroup = 0;
|
|
|
|
|
|
|
|
if (index < 2)
|
2022-06-08 23:46:35 +00:00
|
|
|
pwr_diff = pHalData->TxPwrLegacyHtDiff[rf][Channel - 1];
|
2013-08-08 14:31:29 +00:00
|
|
|
else if (pHalData->CurrentChannelBW == HT_CHANNEL_WIDTH_20)
|
2022-06-08 23:46:35 +00:00
|
|
|
pwr_diff = pHalData->TxPwrHt20Diff[rf][Channel - 1];
|
2013-08-08 14:31:29 +00:00
|
|
|
|
|
|
|
if (pHalData->CurrentChannelBW == HT_CHANNEL_WIDTH_40)
|
2022-06-08 23:46:35 +00:00
|
|
|
customer_pwr_limit = pHalData->PwrGroupHT40[rf][Channel - 1];
|
2013-08-08 14:31:29 +00:00
|
|
|
else
|
2022-06-08 23:46:35 +00:00
|
|
|
customer_pwr_limit = pHalData->PwrGroupHT20[rf][Channel - 1];
|
2013-08-08 14:31:29 +00:00
|
|
|
|
|
|
|
if (pwr_diff >= customer_pwr_limit)
|
|
|
|
pwr_diff = 0;
|
|
|
|
else
|
|
|
|
pwr_diff = customer_pwr_limit - pwr_diff;
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++) {
|
2022-06-08 23:46:35 +00:00
|
|
|
pwr_diff_limit[i] = (u8)((pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index + (rf ? 8 : 0)] & (0x7f << (i * 8))) >> (i * 8));
|
2013-08-08 14:31:29 +00:00
|
|
|
|
|
|
|
if (pwr_diff_limit[i] > pwr_diff)
|
|
|
|
pwr_diff_limit[i] = pwr_diff;
|
|
|
|
}
|
2022-06-08 23:46:35 +00:00
|
|
|
customer_limit = (pwr_diff_limit[3] << 24) | (pwr_diff_limit[2] << 16) |
|
|
|
|
(pwr_diff_limit[1] << 8) | (pwr_diff_limit[0]);
|
2013-08-08 14:31:29 +00:00
|
|
|
writeVal = customer_limit + ((index < 2) ? powerBase0[rf] : powerBase1[rf]);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
chnlGroup = 0;
|
2022-06-08 23:46:35 +00:00
|
|
|
writeVal = pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index + (rf ? 8 : 0)] +
|
2013-08-08 14:31:29 +00:00
|
|
|
((index < 2) ? powerBase0[rf] : powerBase1[rf]);
|
|
|
|
break;
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
2022-06-08 23:46:35 +00:00
|
|
|
|
|
|
|
*(pOutWriteVal + rf) = writeVal;
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
|
|
|
}
|
2013-08-08 14:31:29 +00:00
|
|
|
static void writeOFDMPowerReg88E(struct adapter *Adapter, u8 index, u32 *pValue)
|
2013-05-19 04:28:07 +00:00
|
|
|
{
|
2013-08-08 14:31:29 +00:00
|
|
|
u16 regoffset_a[6] = {
|
|
|
|
rTxAGC_A_Rate18_06, rTxAGC_A_Rate54_24,
|
|
|
|
rTxAGC_A_Mcs03_Mcs00, rTxAGC_A_Mcs07_Mcs04,
|
|
|
|
rTxAGC_A_Mcs11_Mcs08, rTxAGC_A_Mcs15_Mcs12};
|
|
|
|
u16 regoffset_b[6] = {
|
|
|
|
rTxAGC_B_Rate18_06, rTxAGC_B_Rate54_24,
|
|
|
|
rTxAGC_B_Mcs03_Mcs00, rTxAGC_B_Mcs07_Mcs04,
|
|
|
|
rTxAGC_B_Mcs11_Mcs08, rTxAGC_B_Mcs15_Mcs12};
|
2013-05-19 04:28:07 +00:00
|
|
|
u8 i, rf, pwr_val[4];
|
|
|
|
u32 writeVal;
|
2013-08-08 14:31:29 +00:00
|
|
|
u16 regoffset;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-08 14:31:29 +00:00
|
|
|
for (rf = 0; rf < 2; rf++) {
|
2013-05-19 04:28:07 +00:00
|
|
|
writeVal = pValue[rf];
|
2013-08-08 14:31:29 +00:00
|
|
|
for (i = 0; i < 4; i++) {
|
2022-06-08 23:46:35 +00:00
|
|
|
pwr_val[i] = (u8)((writeVal & (0x7f << (i * 8))) >> (i * 8));
|
2013-05-19 04:28:07 +00:00
|
|
|
if (pwr_val[i] > RF6052_MAX_TX_PWR)
|
|
|
|
pwr_val[i] = RF6052_MAX_TX_PWR;
|
|
|
|
}
|
2022-06-08 23:46:35 +00:00
|
|
|
writeVal = (pwr_val[3] << 24) | (pwr_val[2] << 16) | (pwr_val[1] << 8) | pwr_val[0];
|
2013-05-19 04:28:07 +00:00
|
|
|
|
|
|
|
if (rf == 0)
|
2013-08-08 14:31:29 +00:00
|
|
|
regoffset = regoffset_a[index];
|
2013-05-19 04:28:07 +00:00
|
|
|
else
|
2013-08-08 14:31:29 +00:00
|
|
|
regoffset = regoffset_b[index];
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
rtl8188e_PHY_SetBBReg(Adapter, regoffset, bMaskDWord, writeVal);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* 201005115 Joseph: Set Tx Power diff for Tx power training mechanism. */
|
2022-06-08 23:46:35 +00:00
|
|
|
if (regoffset == rTxAGC_A_Mcs07_Mcs04 || regoffset == rTxAGC_B_Mcs07_Mcs04) {
|
2013-05-19 04:28:07 +00:00
|
|
|
writeVal = pwr_val[3];
|
2013-08-08 14:31:29 +00:00
|
|
|
if (regoffset == rTxAGC_A_Mcs15_Mcs12 || regoffset == rTxAGC_A_Mcs07_Mcs04)
|
|
|
|
regoffset = 0xc90;
|
|
|
|
if (regoffset == rTxAGC_B_Mcs15_Mcs12 || regoffset == rTxAGC_B_Mcs07_Mcs04)
|
|
|
|
regoffset = 0xc98;
|
|
|
|
for (i = 0; i < 3; i++) {
|
|
|
|
if (i != 2)
|
2022-06-08 23:46:35 +00:00
|
|
|
writeVal = (writeVal > 8) ? (writeVal - 8) : 0;
|
2013-05-19 04:28:07 +00:00
|
|
|
else
|
2022-06-08 23:46:35 +00:00
|
|
|
writeVal = (writeVal > 6) ? (writeVal - 6) : 0;
|
|
|
|
rtw_write8(Adapter, (u32)(regoffset + i), (u8)writeVal);
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------
|
|
|
|
* Function: PHY_RF6052SetOFDMTxPower
|
|
|
|
*
|
|
|
|
* Overview: For legacy and HY OFDM, we must read EEPROM TX power index for
|
|
|
|
* different channel and read original value in TX power register area from
|
|
|
|
* 0xe00. We increase offset and original value to be correct tx pwr.
|
|
|
|
*
|
|
|
|
* Input: NONE
|
|
|
|
*
|
|
|
|
* Output: NONE
|
|
|
|
*
|
|
|
|
* Return: NONE
|
|
|
|
*
|
|
|
|
* Revised History:
|
|
|
|
* When Who Remark
|
|
|
|
* 11/05/2008 MHC Simulate 8192 series method.
|
|
|
|
* 01/06/2009 MHC 1. Prevent Path B tx power overflow or underflow dure to
|
|
|
|
* A/B pwr difference or legacy/HT pwr diff.
|
|
|
|
* 2. We concern with path B legacy/HT OFDM difference.
|
|
|
|
* 01/22/2009 MHC Support new EPRO format from SD3.
|
|
|
|
*
|
|
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
|
2013-05-19 04:37:45 +00:00
|
|
|
void
|
2013-05-19 04:28:07 +00:00
|
|
|
rtl8188e_PHY_RF6052SetOFDMTxPower(
|
2013-08-08 14:31:29 +00:00
|
|
|
struct adapter *Adapter,
|
|
|
|
u8 *pPowerLevelOFDM,
|
|
|
|
u8 *pPowerLevelBW20,
|
|
|
|
u8 *pPowerLevelBW40,
|
|
|
|
u8 Channel)
|
2013-05-19 04:28:07 +00:00
|
|
|
{
|
2022-06-08 23:46:35 +00:00
|
|
|
struct hal_data_8188e *pHalData = &Adapter->haldata;
|
2013-05-19 04:28:07 +00:00
|
|
|
u32 writeVal[2], powerBase0[2], powerBase1[2], pwrtrac_value;
|
|
|
|
u8 direction;
|
|
|
|
u8 index = 0;
|
|
|
|
|
2013-08-08 14:31:29 +00:00
|
|
|
getpowerbase88e(Adapter, pPowerLevelOFDM, pPowerLevelBW20, pPowerLevelBW40, Channel, &powerBase0[0], &powerBase1[0]);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* 2012/04/23 MH According to power tracking value, we need to revise OFDM tx power. */
|
|
|
|
/* This is ued to fix unstable power tracking mode. */
|
2013-05-19 04:28:07 +00:00
|
|
|
ODM_TxPwrTrackAdjust88E(&pHalData->odmpriv, 0, &direction, &pwrtrac_value);
|
|
|
|
|
2013-08-08 14:31:29 +00:00
|
|
|
for (index = 0; index < 6; index++) {
|
|
|
|
get_rx_power_val_by_reg(Adapter, Channel, index,
|
|
|
|
&powerBase0[0], &powerBase1[0],
|
|
|
|
&writeVal[0]);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-08 14:31:29 +00:00
|
|
|
if (direction == 1) {
|
2013-05-19 04:28:07 +00:00
|
|
|
writeVal[0] += pwrtrac_value;
|
|
|
|
writeVal[1] += pwrtrac_value;
|
2013-08-08 14:31:29 +00:00
|
|
|
} else if (direction == 2) {
|
2013-05-19 04:28:07 +00:00
|
|
|
writeVal[0] -= pwrtrac_value;
|
|
|
|
writeVal[1] -= pwrtrac_value;
|
|
|
|
}
|
|
|
|
writeOFDMPowerReg88E(Adapter, index, &writeVal[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-08 14:31:29 +00:00
|
|
|
static int phy_RF6052_Config_ParaFile(struct adapter *Adapter)
|
2013-05-19 04:28:07 +00:00
|
|
|
{
|
2013-07-26 18:36:38 +00:00
|
|
|
struct bb_reg_def *pPhyReg;
|
2022-06-08 23:46:35 +00:00
|
|
|
struct hal_data_8188e *pHalData = &Adapter->haldata;
|
2013-10-19 17:45:47 +00:00
|
|
|
u32 u4RegValue = 0;
|
|
|
|
int rtStatus = _SUCCESS;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
/* Initialize RF */
|
|
|
|
|
|
|
|
pPhyReg = &pHalData->PHYRegDef;
|
|
|
|
|
|
|
|
/*----Store original RFENV control type----*/
|
|
|
|
u4RegValue = rtl8188e_PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV);
|
|
|
|
|
|
|
|
/*----Set RF_ENV enable----*/
|
|
|
|
rtl8188e_PHY_SetBBReg(Adapter, pPhyReg->rfintfe, bRFSI_RFENV << 16, 0x1);
|
|
|
|
udelay(1);/* PlatformStallExecution(1); */
|
|
|
|
|
|
|
|
/*----Set RF_ENV output high----*/
|
|
|
|
rtl8188e_PHY_SetBBReg(Adapter, pPhyReg->rfintfo, bRFSI_RFENV, 0x1);
|
|
|
|
udelay(1);/* PlatformStallExecution(1); */
|
|
|
|
|
|
|
|
/* Set bit number of Address and Data for RF register */
|
|
|
|
rtl8188e_PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, b3WireAddressLength, 0x0); /* Set 1 to 4 bits for 8255 */
|
|
|
|
udelay(1);/* PlatformStallExecution(1); */
|
|
|
|
|
|
|
|
rtl8188e_PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, b3WireDataLength, 0x0); /* Set 0 to 12 bits for 8255 */
|
|
|
|
udelay(1);/* PlatformStallExecution(1); */
|
|
|
|
|
|
|
|
/*----Initialize RF fom connfiguration file----*/
|
|
|
|
if (HAL_STATUS_FAILURE == ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv))
|
|
|
|
rtStatus = _FAIL;
|
|
|
|
|
|
|
|
/*----Restore RFENV control type----*/;
|
|
|
|
rtl8188e_PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV, u4RegValue);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
|
|
|
return rtStatus;
|
|
|
|
}
|
|
|
|
|
2013-08-08 14:31:29 +00:00
|
|
|
int PHY_RF6052_Config8188E(struct adapter *Adapter)
|
2013-05-19 04:28:07 +00:00
|
|
|
{
|
2013-08-08 14:31:29 +00:00
|
|
|
int rtStatus = _SUCCESS;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* */
|
|
|
|
/* Config BB and RF */
|
|
|
|
/* */
|
2013-05-19 04:28:07 +00:00
|
|
|
rtStatus = phy_RF6052_Config_ParaFile(Adapter);
|
|
|
|
return rtStatus;
|
|
|
|
}
|