linux/drivers/staging/rtl8723bs/hal/odm_DynamicBBPowerSaving.c
<<
>>
Prefs
   1// SPDX-License-Identifier: GPL-2.0
   2/******************************************************************************
   3 *
   4 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
   5 *
   6 ******************************************************************************/
   7
   8#include "odm_precomp.h"
   9
  10void odm_DynamicBBPowerSavingInit(void *pDM_VOID)
  11{
  12        PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
  13        pPS_T pDM_PSTable = &pDM_Odm->DM_PSTable;
  14
  15        pDM_PSTable->PreCCAState = CCA_MAX;
  16        pDM_PSTable->CurCCAState = CCA_MAX;
  17        pDM_PSTable->PreRFState = RF_MAX;
  18        pDM_PSTable->CurRFState = RF_MAX;
  19        pDM_PSTable->Rssi_val_min = 0;
  20        pDM_PSTable->initialize = 0;
  21}
  22
  23void ODM_RF_Saving(void *pDM_VOID, u8 bForceInNormal)
  24{
  25        PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
  26        pPS_T pDM_PSTable = &pDM_Odm->DM_PSTable;
  27        u8 Rssi_Up_bound = 30;
  28        u8 Rssi_Low_bound = 25;
  29
  30        if (pDM_Odm->PatchID == 40) { /* RT_CID_819x_FUNAI_TV */
  31                Rssi_Up_bound = 50;
  32                Rssi_Low_bound = 45;
  33        }
  34
  35        if (pDM_PSTable->initialize == 0) {
  36
  37                pDM_PSTable->Reg874 = (PHY_QueryBBReg(pDM_Odm->Adapter, 0x874, bMaskDWord)&0x1CC000)>>14;
  38                pDM_PSTable->RegC70 = (PHY_QueryBBReg(pDM_Odm->Adapter, 0xc70, bMaskDWord)&BIT3)>>3;
  39                pDM_PSTable->Reg85C = (PHY_QueryBBReg(pDM_Odm->Adapter, 0x85c, bMaskDWord)&0xFF000000)>>24;
  40                pDM_PSTable->RegA74 = (PHY_QueryBBReg(pDM_Odm->Adapter, 0xa74, bMaskDWord)&0xF000)>>12;
  41                /* Reg818 = PHY_QueryBBReg(padapter, 0x818, bMaskDWord); */
  42                pDM_PSTable->initialize = 1;
  43        }
  44
  45        if (!bForceInNormal) {
  46                if (pDM_Odm->RSSI_Min != 0xFF) {
  47                        if (pDM_PSTable->PreRFState == RF_Normal) {
  48                                if (pDM_Odm->RSSI_Min >= Rssi_Up_bound)
  49                                        pDM_PSTable->CurRFState = RF_Save;
  50                                else
  51                                        pDM_PSTable->CurRFState = RF_Normal;
  52                        } else {
  53                                if (pDM_Odm->RSSI_Min <= Rssi_Low_bound)
  54                                        pDM_PSTable->CurRFState = RF_Normal;
  55                                else
  56                                        pDM_PSTable->CurRFState = RF_Save;
  57                        }
  58                } else
  59                        pDM_PSTable->CurRFState = RF_MAX;
  60        } else
  61                pDM_PSTable->CurRFState = RF_Normal;
  62
  63        if (pDM_PSTable->PreRFState != pDM_PSTable->CurRFState) {
  64                if (pDM_PSTable->CurRFState == RF_Save) {
  65                        PHY_SetBBReg(pDM_Odm->Adapter, 0x874, 0x1C0000, 0x2); /* Reg874[20:18]=3'b010 */
  66                        PHY_SetBBReg(pDM_Odm->Adapter, 0xc70, BIT3, 0); /* RegC70[3]= 1'b0 */
  67                        PHY_SetBBReg(pDM_Odm->Adapter, 0x85c, 0xFF000000, 0x63); /* Reg85C[31:24]= 0x63 */
  68                        PHY_SetBBReg(pDM_Odm->Adapter, 0x874, 0xC000, 0x2); /* Reg874[15:14]=2'b10 */
  69                        PHY_SetBBReg(pDM_Odm->Adapter, 0xa74, 0xF000, 0x3); /* RegA75[7:4]= 0x3 */
  70                        PHY_SetBBReg(pDM_Odm->Adapter, 0x818, BIT28, 0x0); /* Reg818[28]= 1'b0 */
  71                        PHY_SetBBReg(pDM_Odm->Adapter, 0x818, BIT28, 0x1); /* Reg818[28]= 1'b1 */
  72                } else {
  73                        PHY_SetBBReg(pDM_Odm->Adapter, 0x874, 0x1CC000, pDM_PSTable->Reg874);
  74                        PHY_SetBBReg(pDM_Odm->Adapter, 0xc70, BIT3, pDM_PSTable->RegC70);
  75                        PHY_SetBBReg(pDM_Odm->Adapter, 0x85c, 0xFF000000, pDM_PSTable->Reg85C);
  76                        PHY_SetBBReg(pDM_Odm->Adapter, 0xa74, 0xF000, pDM_PSTable->RegA74);
  77                        PHY_SetBBReg(pDM_Odm->Adapter, 0x818, BIT28, 0x0);
  78                }
  79                pDM_PSTable->PreRFState = pDM_PSTable->CurRFState;
  80        }
  81}
  82