static void _FirmwareSelfReset(PADAPTER Adapter) { u8 u1bTmp; u8 Delay = 100; HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); if((pHalData->FirmwareVersion > 0x21) || (pHalData->FirmwareVersion == 0x21 && pHalData->FirmwareSubVersion >= 0x01)) { /* printk("==> %s REG 02(0x%04x),80(0x%08x),130(0x%08x),134(0x%08x),138(0x%08x),13c(0x%08x),\ 1c0(0x%08x),1c4(0x%08x),1c8(0x%08x),1cc(0x%08x),\n", __FUNCTION__,rtw_read16(Adapter,0x02),rtw_read32(Adapter,0x80), rtw_read32(Adapter,0x130), rtw_read32(Adapter,0x134), rtw_read32(Adapter,0x138), rtw_read32(Adapter,0x13c), rtw_read32(Adapter,0x1c0), rtw_read32(Adapter,0x1c4), rtw_read32(Adapter,0x1c8), rtw_read32(Adapter,0x1cc)); */ //0x1cf=0x20. Inform 8051 to reset. 2009.12.25. tynli_test rtw_write8(Adapter, REG_HMETFR+3, 0x20); u1bTmp = rtw_read8(Adapter, REG_SYS_FUNC_EN+1); while(u1bTmp&BIT2) { Delay--; //RT_TRACE(COMP_INIT, DBG_LOUD, ("PowerOffAdapter8192CE(): polling 0x03[2] Delay = %d \n", Delay)); if(Delay == 0) break; //delay_us(50); rtw_udelay_os(50); u1bTmp = rtw_read8(Adapter, REG_SYS_FUNC_EN+1); } if((u1bTmp&BIT2) && (Delay == 0)) { DBG_8192C("FirmwareDownload92C():fw reset by itself Fail!!!!!! 0x03 = %x\n", u1bTmp); //RT_ASSERT(FALSE, ("PowerOffAdapter8192CE(): 0x03 = %x\n", u1bTmp)); rtw_write8(Adapter,REG_SYS_FUNC_EN+1,(rtw_read8(Adapter, REG_SYS_FUNC_EN+1)&~BIT2)); } /* printk("==> %s REG 02(0x%04x),80(0x%08x),130(0x%08x),134(0x%08x),138(0x%08x),13c(0x%08x),\ 1c0(0x%08x),1c4(0x%08x),1c8(0x%08x),1cc(0x%08x),\n", __FUNCTION__,rtw_read16(Adapter,0x02),rtw_read32(Adapter,0x80), rtw_read32(Adapter,0x130), rtw_read32(Adapter,0x134), rtw_read32(Adapter,0x138), rtw_read32(Adapter,0x13c), rtw_read32(Adapter,0x1c0), rtw_read32(Adapter,0x1c4), rtw_read32(Adapter,0x1c8), rtw_read32(Adapter,0x1cc)); */ } }
VOID ODM_delay_us(IN u4Byte us) { #if(DM_ODM_SUPPORT_TYPE & (ODM_AP|ODM_ADSL)) delay_us(us); #elif(DM_ODM_SUPPORT_TYPE & ODM_CE) rtw_udelay_os(us); #elif(DM_ODM_SUPPORT_TYPE & ODM_MP) PlatformStallExecution(us); #endif }
// // ODM Timer relative API. // VOID ODM_StallExecution( IN u4Byte usDelay ) { #if(DM_ODM_SUPPORT_TYPE & (ODM_AP|ODM_ADSL)) #elif(DM_ODM_SUPPORT_TYPE & ODM_CE) rtw_udelay_os(usDelay); #elif(DM_ODM_SUPPORT_TYPE & ODM_WIN) PlatformStallExecution(usDelay); #endif }
// // ODM Timer relative API. // void ODM_StallExecution( u32 usDelay ) { #if(DM_ODM_SUPPORT_TYPE & (ODM_AP|ODM_ADSL)) #elif(DM_ODM_SUPPORT_TYPE & ODM_CE) rtw_udelay_os(usDelay); #elif(DM_ODM_SUPPORT_TYPE & ODM_MP) PlatformStallExecution(usDelay); #endif }
void rtw_hal_write_rfreg(_adapter *padapter, u32 eRFPath, u32 RegAddr, u32 BitMask, u32 Data) { if (padapter->HalFunc.write_rfreg) { if (match_rf_write_sniff_ranges(eRFPath, RegAddr, BitMask)) { DBG_871X("DBG_IO rtw_hal_write_rfreg(%u, 0x%04x, 0x%08x) write:0x%08x(0x%08x)\n" , eRFPath, RegAddr, BitMask, (Data << PHY_CalculateBitShift(BitMask)), Data); } padapter->HalFunc.write_rfreg(padapter, eRFPath, RegAddr, BitMask, Data); #ifdef CONFIG_PCI_HCI if (!IS_HARDWARE_TYPE_JAGUAR_AND_JAGUAR2(padapter)) /*For N-Series IC, suggest by Jenyu*/ rtw_udelay_os(2); #endif } }
/***************************************** * H2C Msg format : *| 31 - 8 |7 | 6 - 0 | *| h2c_msg |Ext_bit |CMD_ID | * ******************************************/ static void _FillH2CCmd92D(_adapter* padapter, u8 ElementID, u32 CmdLen, u8* pCmdBuffer) { HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); u8 BoxNum; u16 BOXReg=0, BOXExtReg=0; u8 BoxContent[4], BoxExtContent[2]; u8 BufIndex=0; u8 U1btmp; //Read 0x1bf u8 bWriteSucess = _FALSE; u8 IsFwRead = _FALSE; u8 WaitH2cLimmit = 100; u8 WaitWriteH2cLimmit = 100; u8 idx=0; _func_enter_; padapter = GET_PRIMARY_ADAPTER(padapter); pHalData = GET_HAL_DATA(padapter); _enter_critical_mutex(&(adapter_to_dvobj(padapter)->h2c_fwcmd_mutex), NULL); //DBG_8192C("FillH2CCmd : ElementID=%d \n",ElementID); while(!bWriteSucess) { WaitWriteH2cLimmit--; if(WaitWriteH2cLimmit == 0) { DBG_8192C("FillH2CCmd92C():Write H2C fail because no trigger for FW INT!!!!!!!!\n"); break; } // 2. Find the last BOX number which has been writen. BoxNum = pHalData->LastHMEBoxNum; switch(BoxNum) { case 0: BOXReg = REG_HMEBOX_0; BOXExtReg = REG_HMEBOX_EXT_0; break; case 1: BOXReg = REG_HMEBOX_1; BOXExtReg = REG_HMEBOX_EXT_1; break; case 2: BOXReg = REG_HMEBOX_2; BOXExtReg = REG_HMEBOX_EXT_2; break; case 3: BOXReg = REG_HMEBOX_3; BOXExtReg = REG_HMEBOX_EXT_3; break; default: break; } // 3. Check if the box content is empty. IsFwRead = CheckFwReadLastH2C(padapter, BoxNum); while(!IsFwRead) { //wait until Fw read WaitH2cLimmit--; if(WaitH2cLimmit == 0) { DBG_8192C("FillH2CCmd92C(): Wating too long for FW read clear HMEBox(%d)!!!\n", BoxNum); break; } rtw_udelay_os(10); //us IsFwRead = CheckFwReadLastH2C(padapter, BoxNum); U1btmp = rtw_read8(padapter, 0x1BF); //DBG_8192C("FillH2CCmd92C(): Wating for FW read clear HMEBox(%d)!!! 0x1BF = %2x\n", BoxNum, U1btmp); } // If Fw has not read the last H2C cmd, break and give up this H2C. if(!IsFwRead) { DBG_8192C("FillH2CCmd92C(): Write H2C register BOX[%d] fail!!!!! Fw do not read. \n", BoxNum); break; } // 4. Fill the H2C cmd into box _rtw_memset(BoxContent, 0, sizeof(BoxContent)); _rtw_memset(BoxExtContent, 0, sizeof(BoxExtContent)); BoxContent[0] = ElementID; // Fill element ID //DBG_8192C("FillH2CCmd92C():Write ElementID BOXReg(%4x) = %2x \n", BOXReg, ElementID); switch(CmdLen) { case 1: { BoxContent[0] &= ~(BIT7); _rtw_memcpy((u8 *)(BoxContent)+1, pCmdBuffer+BufIndex, 1); //PlatformEFIOWrite4Byte(Adapter, BOXReg, *((pu4Byte)BoxContent)); //For Endian Free. for(idx= 0; idx < 4; idx++) { rtw_write8(padapter, BOXReg+idx, BoxContent[idx]); } break; } case 2: { BoxContent[0] &= ~(BIT7); _rtw_memcpy((u8 *)(BoxContent)+1, pCmdBuffer+BufIndex, 2); //PlatformEFIOWrite4Byte(Adapter, BOXReg, *((pu4Byte)BoxContent)); for(idx=0; idx < 4; idx++) { rtw_write8(padapter, BOXReg+idx, BoxContent[idx]); } break; } case 3: { BoxContent[0] &= ~(BIT7); _rtw_memcpy((u8 *)(BoxContent)+1, pCmdBuffer+BufIndex, 3); //PlatformEFIOWrite4Byte(Adapter, BOXReg, *((pu4Byte)BoxContent)); for(idx = 0; idx < 4 ; idx++) { rtw_write8(padapter, BOXReg+idx, BoxContent[idx]); } break; } case 4: { BoxContent[0] |= (BIT7); _rtw_memcpy((u8 *)(BoxExtContent), pCmdBuffer+BufIndex, 2); _rtw_memcpy((u8 *)(BoxContent)+1, pCmdBuffer+BufIndex+2, 2); //PlatformEFIOWrite2Byte(Adapter, BOXExtReg, *((pu2Byte)BoxExtContent)); //PlatformEFIOWrite4Byte(Adapter, BOXReg, *((pu4Byte)BoxContent)); for(idx = 0 ; idx < 2 ; idx ++) { rtw_write8(padapter, BOXExtReg+idx, BoxExtContent[idx]); } for(idx = 0 ; idx < 4 ; idx ++) { rtw_write8(padapter, BOXReg+idx, BoxContent[idx]); } break; } case 5: { BoxContent[0] |= (BIT7); _rtw_memcpy((u8 *)(BoxExtContent), pCmdBuffer+BufIndex, 2); _rtw_memcpy((u8 *)(BoxContent)+1, pCmdBuffer+BufIndex+2, 3); //PlatformEFIOWrite2Byte(Adapter, BOXExtReg, *((pu2Byte)BoxExtContent)); //PlatformEFIOWrite4Byte(Adapter, BOXReg, *((pu4Byte)BoxContent)); for(idx = 0 ; idx < 2 ; idx ++) { rtw_write8(padapter, BOXExtReg+idx, BoxExtContent[idx]); } for(idx = 0 ; idx < 4 ; idx ++) { rtw_write8(padapter, BOXReg+idx, BoxContent[idx]); } break; } default: break; } //DBG_8192C("FillH2CCmd(): BoxExtContent=0x%04x\n", *(u16*)BoxExtContent); //DBG_8192C("FillH2CCmd(): BoxContent=0x%08x\n", *(u32*)BoxContent); // 5. Normal chip does not need to check if the H2C cmd has be written successfully. // 92D test chip does not need to check, bWriteSucess = _TRUE; // Record the next BoxNum pHalData->LastHMEBoxNum = BoxNum+1; if(pHalData->LastHMEBoxNum == 4) // loop to 0 pHalData->LastHMEBoxNum = 0; //DBG_8192C("FillH2CCmd92C():pHalData->LastHMEBoxNum = %d\n", pHalData->LastHMEBoxNum); } _exit_critical_mutex(&(adapter_to_dvobj(padapter)->h2c_fwcmd_mutex), NULL); _func_exit_; }
static int phy_RF6052_Config_ParaFile( IN PADAPTER Adapter ) { u32 u4RegValue; u8 eRFPath; BB_REGISTER_DEFINITION_T *pPhyReg; int rtStatus = _SUCCESS; HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); static char sz88CRadioAFile[] = RTL8188C_PHY_RADIO_A; static char sz88CRadioBFile[] = RTL8188C_PHY_RADIO_B; #ifdef CONFIG_USB_HCI static char sz88CRadioAFile_mCard[] = RTL8188C_PHY_RADIO_A_mCard; static char sz88CRadioBFile_mCard[] = RTL8188C_PHY_RADIO_B_mCard; static char sz88CRadioAFile_HP[] = RTL8188C_PHY_RADIO_A_HP; #endif static char sz92CRadioAFile[] = RTL8192C_PHY_RADIO_A; static char sz92CRadioBFile[] = RTL8192C_PHY_RADIO_B; static char sz8723RadioAFile[] = RTL8723_PHY_RADIO_A; static char sz8723RadioBFile[] = RTL8723_PHY_RADIO_B; char *pszRadioAFile, *pszRadioBFile; if(IS_HARDWARE_TYPE_8192C(Adapter)) { if(IS_92C_SERIAL( pHalData->VersionID))// 88c's IPA is different from 92c's { if(IS_NORMAL_CHIP(pHalData->VersionID)) { pszRadioAFile = sz92CRadioAFile; pszRadioBFile = sz92CRadioBFile; } else { rtStatus = _FAIL; return rtStatus; } } else { if(IS_NORMAL_CHIP(pHalData->VersionID)) { pszRadioAFile = sz88CRadioAFile; pszRadioBFile = sz88CRadioBFile; #ifdef CONFIG_USB_HCI if( BOARD_MINICARD == pHalData->BoardType) { pszRadioAFile = sz88CRadioAFile_mCard; pszRadioBFile = sz88CRadioBFile_mCard; } else if( BOARD_USB_High_PA == pHalData->BoardType) { pszRadioAFile = sz88CRadioAFile_HP; } #endif } else { rtStatus = _FAIL; return rtStatus; } } } else if(IS_HARDWARE_TYPE_8723(Adapter)) { pszRadioAFile = sz8723RadioAFile; pszRadioBFile = sz8723RadioBFile; } //3//----------------------------------------------------------------- //3// <2> Initialize RF //3//----------------------------------------------------------------- //for(eRFPath = RF90_PATH_A; eRFPath <pHalData->NumTotalRFPath; eRFPath++) for(eRFPath = 0; eRFPath <pHalData->NumTotalRFPath; eRFPath++) { pPhyReg = &pHalData->PHYRegDef[eRFPath]; /*----Store original RFENV control type----*/ switch(eRFPath) { case RF90_PATH_A: case RF90_PATH_C: u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV); break; case RF90_PATH_B : case RF90_PATH_D: u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV<<16); break; } /*----Set RF_ENV enable----*/ PHY_SetBBReg(Adapter, pPhyReg->rfintfe, bRFSI_RFENV<<16, 0x1); rtw_udelay_os(1);//PlatformStallExecution(1); /*----Set RF_ENV output high----*/ PHY_SetBBReg(Adapter, pPhyReg->rfintfo, bRFSI_RFENV, 0x1); rtw_udelay_os(1);//PlatformStallExecution(1); /* Set bit number of Address and Data for RF register */ PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, b3WireAddressLength, 0x0); // Set 1 to 4 bits for 8255 rtw_udelay_os(1);//PlatformStallExecution(1); PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, b3WireDataLength, 0x0); // Set 0 to 12 bits for 8255 rtw_udelay_os(1);//PlatformStallExecution(1); /*----Initialize RF fom connfiguration file----*/ switch(eRFPath) { case RF90_PATH_A: #ifdef CONFIG_EMBEDDED_FWIMG rtStatus= rtl8192c_PHY_ConfigRFWithHeaderFile(Adapter,(RF90_RADIO_PATH_E)eRFPath); #else rtStatus = rtl8192c_PHY_ConfigRFWithParaFile(Adapter, pszRadioAFile, (RF90_RADIO_PATH_E)eRFPath); #endif break; case RF90_PATH_B: #ifdef CONFIG_EMBEDDED_FWIMG rtStatus = rtl8192c_PHY_ConfigRFWithHeaderFile(Adapter,(RF90_RADIO_PATH_E)eRFPath); #else rtStatus = rtl8192c_PHY_ConfigRFWithParaFile(Adapter, pszRadioBFile, (RF90_RADIO_PATH_E)eRFPath); #endif break; case RF90_PATH_C: break; case RF90_PATH_D: break; } /*----Restore RFENV control type----*/; switch(eRFPath) { case RF90_PATH_A: case RF90_PATH_C: PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV, u4RegValue); break; case RF90_PATH_B : case RF90_PATH_D: PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV<<16, u4RegValue); break; } if(rtStatus != _SUCCESS){ //RT_TRACE(COMP_FPGA, DBG_LOUD, ("phy_RF6052_Config_ParaFile():Radio[%d] Fail!!", eRFPath)); goto phy_RF6052_Config_ParaFile_Fail; } } //RT_TRACE(COMP_INIT, DBG_LOUD, ("<---phy_RF6052_Config_ParaFile()\n")); return rtStatus; phy_RF6052_Config_ParaFile_Fail: return rtStatus; }
static int phy_RF6052_Config_ParaFile(struct adapter *Adapter) { struct bb_reg_def *pPhyReg; struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); u32 u4RegValue = 0; u8 eRFPath; int rtStatus = _SUCCESS; /* 3----------------------------------------------------------------- */ /* 3 <2> Initialize RF */ /* 3----------------------------------------------------------------- */ for (eRFPath = 0; eRFPath < pHalData->NumTotalRFPath; eRFPath++) { pPhyReg = &pHalData->PHYRegDef[eRFPath]; /*----Store original RFENV control type----*/ switch (eRFPath) { case RF_PATH_A: case RF_PATH_C: u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV); break; case RF_PATH_B: case RF_PATH_D: u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV<<16); break; } /*----Set RF_ENV enable----*/ PHY_SetBBReg(Adapter, pPhyReg->rfintfe, bRFSI_RFENV<<16, 0x1); rtw_udelay_os(1);/* PlatformStallExecution(1); */ /*----Set RF_ENV output high----*/ PHY_SetBBReg(Adapter, pPhyReg->rfintfo, bRFSI_RFENV, 0x1); rtw_udelay_os(1);/* PlatformStallExecution(1); */ /* Set bit number of Address and Data for RF register */ PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, b3WireAddressLength, 0x0); /* Set 1 to 4 bits for 8255 */ rtw_udelay_os(1);/* PlatformStallExecution(1); */ PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, b3WireDataLength, 0x0); /* Set 0 to 12 bits for 8255 */ rtw_udelay_os(1);/* PlatformStallExecution(1); */ /*----Initialize RF fom connfiguration file----*/ switch (eRFPath) { case RF_PATH_A: if (HAL_STATUS_FAILURE == ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv, (enum rf_radio_path)eRFPath, (enum rf_radio_path)eRFPath)) rtStatus = _FAIL; break; case RF_PATH_B: if (HAL_STATUS_FAILURE == ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv, (enum rf_radio_path)eRFPath, (enum rf_radio_path)eRFPath)) rtStatus = _FAIL; break; case RF_PATH_C: break; case RF_PATH_D: break; } /*----Restore RFENV control type----*/; switch (eRFPath) { case RF_PATH_A: case RF_PATH_C: PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV, u4RegValue); break; case RF_PATH_B: case RF_PATH_D: PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV<<16, u4RegValue); break; } if (rtStatus != _SUCCESS) goto phy_RF6052_Config_ParaFile_Fail; } return rtStatus; phy_RF6052_Config_ParaFile_Fail: return rtStatus; }
static int phy_RF6052_Config_ParaFile( IN PADAPTER Adapter ) { u32 u4RegValue = 0; u8 eRFPath; BB_REGISTER_DEFINITION_T *pPhyReg; int rtStatus = _SUCCESS; HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); static char sz8188RadioAFile[] = RTL8188F_PHY_RADIO_A; static char sz8188RadioBFile[] = RTL8188F_PHY_RADIO_B; static s1Byte sz8188FTxPwrTrackFile[] = RTL8188F_TXPWR_TRACK; char *pszRadioAFile, *pszRadioBFile, *pszTxPwrTrackFile; pszRadioAFile = sz8188RadioAFile; pszRadioBFile = sz8188RadioBFile; pszTxPwrTrackFile = sz8188FTxPwrTrackFile; /*3//----------------------------------------------------------------- */ /*3// <2> Initialize RF */ /*3//----------------------------------------------------------------- */ /*for(eRFPath = RF_PATH_A; eRFPath <pHalData->NumTotalRFPath; eRFPath++) */ for (eRFPath = 0; eRFPath < pHalData->NumTotalRFPath; eRFPath++) { pPhyReg = &pHalData->PHYRegDef[eRFPath]; /*----Store original RFENV control type----*/ switch (eRFPath) { case RF_PATH_A: case RF_PATH_C: u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV); break; case RF_PATH_B : case RF_PATH_D: u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV << 16); break; } /*----Set RF_ENV enable----*/ PHY_SetBBReg(Adapter, pPhyReg->rfintfe, bRFSI_RFENV << 16, 0x1); rtw_udelay_os(1);/*PlatformStallExecution(1); */ /*----Set RF_ENV output high----*/ PHY_SetBBReg(Adapter, pPhyReg->rfintfo, bRFSI_RFENV, 0x1); rtw_udelay_os(1);/*PlatformStallExecution(1); */ /* Set bit number of Address and Data for RF register */ PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, b3WireAddressLength, 0x0); /* Set 1 to 4 bits for 8255 */ rtw_udelay_os(1);/*PlatformStallExecution(1); */ PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, b3WireDataLength, 0x0); /* Set 0 to 12 bits for 8255 */ rtw_udelay_os(1);/*PlatformStallExecution(1); */ /*----Initialize RF fom connfiguration file----*/ switch (eRFPath) { case RF_PATH_A: #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE if (PHY_ConfigRFWithParaFile(Adapter, pszRadioAFile, eRFPath) == _FAIL) #endif { #ifdef CONFIG_EMBEDDED_FWIMG if (HAL_STATUS_FAILURE == ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv, CONFIG_RF_RADIO, (ODM_RF_RADIO_PATH_E)eRFPath)) rtStatus = _FAIL; #endif } break; case RF_PATH_B: #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE if (PHY_ConfigRFWithParaFile(Adapter, pszRadioBFile, eRFPath) == _FAIL) #endif { #ifdef CONFIG_EMBEDDED_FWIMG if (HAL_STATUS_FAILURE == ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv, CONFIG_RF_RADIO, (ODM_RF_RADIO_PATH_E)eRFPath)) rtStatus = _FAIL; #endif } break; case RF_PATH_C: break; case RF_PATH_D: break; } /*----Restore RFENV control type----*/; switch (eRFPath) { case RF_PATH_A: case RF_PATH_C: PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV, u4RegValue); break; case RF_PATH_B : case RF_PATH_D: PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV << 16, u4RegValue); break; } if (rtStatus != _SUCCESS) { /*RT_TRACE(COMP_FPGA, DBG_LOUD, ("phy_RF6052_Config_ParaFile():Radio[%d] Fail!!", eRFPath)); */ goto phy_RF6052_Config_ParaFile_Fail; } } /*3 ----------------------------------------------------------------- */ /*3 Configuration of Tx Power Tracking */ /*3 ----------------------------------------------------------------- */ #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE if (PHY_ConfigRFWithTxPwrTrackParaFile(Adapter, pszTxPwrTrackFile) == _FAIL) #endif { #ifdef CONFIG_EMBEDDED_FWIMG ODM_ConfigRFWithTxPwrTrackHeaderFile(&pHalData->odmpriv); #endif } /*RT_TRACE(COMP_INIT, DBG_LOUD, ("<---phy_RF6052_Config_ParaFile()\n")); */ return rtStatus; phy_RF6052_Config_ParaFile_Fail: return rtStatus; }
/* * Description: * This routine deal with the Power Configuration CMDs parsing for RTL8723/RTL8188E Series IC. * * Assumption: * We should follow specific format which was released from HW SD. * * 2011.07.07, added by Roger. * */ u8 HalPwrSeqCmdParsing( PADAPTER padapter, u8 CutVersion, u8 FabVersion, u8 InterfaceType, WLAN_PWR_CFG PwrSeqCmd[]) { WLAN_PWR_CFG PwrCfgCmd = {0}; u8 bPollingBit = _FALSE; u32 AryIdx = 0; u8 value = 0; u32 offset = 0; u32 pollingCount = 0; /* polling autoload done. */ u32 maxPollingCnt = 5000; do { PwrCfgCmd = PwrSeqCmd[AryIdx]; /* 2 Only Handle the command whose FAB, CUT, and Interface are matched */ if ((GET_PWR_CFG_FAB_MASK(PwrCfgCmd) & FabVersion) && (GET_PWR_CFG_CUT_MASK(PwrCfgCmd) & CutVersion) && (GET_PWR_CFG_INTF_MASK(PwrCfgCmd) & InterfaceType)) { switch (GET_PWR_CFG_CMD(PwrCfgCmd)) { case PWR_CMD_READ: break; case PWR_CMD_WRITE: offset = GET_PWR_CFG_OFFSET(PwrCfgCmd); #ifdef CONFIG_SDIO_HCI /* */ /* <Roger_Notes> We should deal with interface specific address mapping for some interfaces, e.g., SDIO interface */ /* 2011.07.07. */ /* */ if (GET_PWR_CFG_BASE(PwrCfgCmd) == PWR_BASEADDR_SDIO) { /* Read Back SDIO Local value */ value = SdioLocalCmd52Read1Byte(padapter, offset); value &= ~(GET_PWR_CFG_MASK(PwrCfgCmd)); value |= (GET_PWR_CFG_VALUE(PwrCfgCmd) & GET_PWR_CFG_MASK(PwrCfgCmd)); /* Write Back SDIO Local value */ SdioLocalCmd52Write1Byte(padapter, offset, value); } else #endif { #ifdef CONFIG_GSPI_HCI if (GET_PWR_CFG_BASE(PwrCfgCmd) == PWR_BASEADDR_SDIO) offset = SPI_LOCAL_OFFSET | offset; #endif /* Read the value from system register */ value = rtw_read8(padapter, offset); value = value & (~(GET_PWR_CFG_MASK(PwrCfgCmd))); value = value | (GET_PWR_CFG_VALUE(PwrCfgCmd) & GET_PWR_CFG_MASK(PwrCfgCmd)); /* Write the value back to sytem register */ rtw_write8(padapter, offset, value); } break; case PWR_CMD_POLLING: bPollingBit = _FALSE; offset = GET_PWR_CFG_OFFSET(PwrCfgCmd); #ifdef CONFIG_GSPI_HCI if (GET_PWR_CFG_BASE(PwrCfgCmd) == PWR_BASEADDR_SDIO) offset = SPI_LOCAL_OFFSET | offset; #endif do { #ifdef CONFIG_SDIO_HCI if (GET_PWR_CFG_BASE(PwrCfgCmd) == PWR_BASEADDR_SDIO) value = SdioLocalCmd52Read1Byte(padapter, offset); else #endif value = rtw_read8(padapter, offset); value = value & GET_PWR_CFG_MASK(PwrCfgCmd); if (value == (GET_PWR_CFG_VALUE(PwrCfgCmd) & GET_PWR_CFG_MASK(PwrCfgCmd))) bPollingBit = _TRUE; else rtw_udelay_os(10); if (pollingCount++ > maxPollingCnt) { RTW_ERR("HalPwrSeqCmdParsing: Fail to polling Offset[%#x]=%02x\n", offset, value); return _FALSE; } } while (!bPollingBit); break; case PWR_CMD_DELAY: if (GET_PWR_CFG_VALUE(PwrCfgCmd) == PWRSEQ_DELAY_US) rtw_udelay_os(GET_PWR_CFG_OFFSET(PwrCfgCmd)); else rtw_udelay_os(GET_PWR_CFG_OFFSET(PwrCfgCmd) * 1000); break; case PWR_CMD_END: /* When this command is parsed, end the process */ return _TRUE; break; default: break; } } AryIdx++;/* Add Array Index */ } while (1); return _TRUE; }
IMAGE2_TEXT_SECTION void delayMicroseconds(uint32_t us) { rtw_udelay_os(us); }
/* This routine deals with the Power Configuration CMDs parsing * for RTL8723/RTL8188E Series IC. * Assumption: * We should follow specific format which was released from HW SD. */ u8 HalPwrSeqCmdParsing(struct adapter *padapter, u8 cut_vers, u8 fab_vers, u8 ifacetype, struct wl_pwr_cfg pwrseqcmd[]) { struct wl_pwr_cfg pwrcfgcmd = {0}; u8 poll_bit = false; u32 aryidx = 0; u8 value = 0; u32 offset = 0; u32 poll_count = 0; /* polling autoload done. */ u32 max_poll_count = 5000; do { pwrcfgcmd = pwrseqcmd[aryidx]; RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: offset(%#x) cut_msk(%#x) fab_msk(%#x) interface_msk(%#x) base(%#x) cmd(%#x) msk(%#x) value(%#x)\n", GET_PWR_CFG_OFFSET(pwrcfgcmd), GET_PWR_CFG_CUT_MASK(pwrcfgcmd), GET_PWR_CFG_FAB_MASK(pwrcfgcmd), GET_PWR_CFG_INTF_MASK(pwrcfgcmd), GET_PWR_CFG_BASE(pwrcfgcmd), GET_PWR_CFG_CMD(pwrcfgcmd), GET_PWR_CFG_MASK(pwrcfgcmd), GET_PWR_CFG_VALUE(pwrcfgcmd))); /* 2 Only Handle the command whose FAB, CUT, and Interface are matched */ if ((GET_PWR_CFG_FAB_MASK(pwrcfgcmd) & fab_vers) && (GET_PWR_CFG_CUT_MASK(pwrcfgcmd) & cut_vers) && (GET_PWR_CFG_INTF_MASK(pwrcfgcmd) & ifacetype)) { switch (GET_PWR_CFG_CMD(pwrcfgcmd)) { case PWR_CMD_READ: RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_READ\n")); break; case PWR_CMD_WRITE: RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_WRITE\n")); offset = GET_PWR_CFG_OFFSET(pwrcfgcmd); /* Read the value from system register */ value = rtw_read8(padapter, offset); value &= ~(GET_PWR_CFG_MASK(pwrcfgcmd)); value |= (GET_PWR_CFG_VALUE(pwrcfgcmd) & GET_PWR_CFG_MASK(pwrcfgcmd)); /* Write the value back to system register */ rtw_write8(padapter, offset, value); break; case PWR_CMD_POLLING: RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_POLLING\n")); poll_bit = false; offset = GET_PWR_CFG_OFFSET(pwrcfgcmd); do { value = rtw_read8(padapter, offset); value &= GET_PWR_CFG_MASK(pwrcfgcmd); if (value == (GET_PWR_CFG_VALUE(pwrcfgcmd) & GET_PWR_CFG_MASK(pwrcfgcmd))) poll_bit = true; else rtw_udelay_os(10); if (poll_count++ > max_poll_count) { DBG_88E("Fail to polling Offset[%#x]\n", offset); return false; } } while (!poll_bit); break; case PWR_CMD_DELAY: RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_DELAY\n")); if (GET_PWR_CFG_VALUE(pwrcfgcmd) == PWRSEQ_DELAY_US) rtw_udelay_os(GET_PWR_CFG_OFFSET(pwrcfgcmd)); else rtw_udelay_os(GET_PWR_CFG_OFFSET(pwrcfgcmd)*1000); break; case PWR_CMD_END: /* When this command is parsed, end the process */ RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_END\n")); return true; break; default: RT_TRACE(_module_hal_init_c_ , _drv_err_, ("HalPwrSeqCmdParsing: Unknown CMD!!\n")); break; } } aryidx++;/* Add Array Index */ } while (1); return true; }
u8 HalPwrSeqCmdParsing( PADAPTER padapter, u8 CutVersion, u8 FabVersion, u8 InterfaceType, WLAN_PWR_CFG PwrSeqCmd[]) { WLAN_PWR_CFG PwrCfgCmd = {0}; u8 bPollingBit = false; u32 AryIdx = 0; u8 value = 0; u32 offset = 0; u32 pollingCount = 0; /* polling autoload done. */ u32 maxPollingCnt = 5000; do { PwrCfgCmd = PwrSeqCmd[AryIdx]; RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: offset(%#x) cut_msk(%#x) fab_msk(%#x) interface_msk(%#x) base(%#x) cmd(%#x) msk(%#x) value(%#x)\n", GET_PWR_CFG_OFFSET(PwrCfgCmd), GET_PWR_CFG_CUT_MASK(PwrCfgCmd), GET_PWR_CFG_FAB_MASK(PwrCfgCmd), GET_PWR_CFG_INTF_MASK(PwrCfgCmd), GET_PWR_CFG_BASE(PwrCfgCmd), GET_PWR_CFG_CMD(PwrCfgCmd), GET_PWR_CFG_MASK(PwrCfgCmd), GET_PWR_CFG_VALUE(PwrCfgCmd))); /* 2 Only Handle the command whose FAB, CUT, and Interface are matched */ if ((GET_PWR_CFG_FAB_MASK(PwrCfgCmd) & FabVersion) && (GET_PWR_CFG_CUT_MASK(PwrCfgCmd) & CutVersion) && (GET_PWR_CFG_INTF_MASK(PwrCfgCmd) & InterfaceType)) { switch (GET_PWR_CFG_CMD(PwrCfgCmd)) { case PWR_CMD_READ: RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_READ\n")); break; case PWR_CMD_WRITE: RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_WRITE\n")); offset = GET_PWR_CFG_OFFSET(PwrCfgCmd); /* Read the value from system register */ value = rtw_read8(padapter, offset); value &= ~(GET_PWR_CFG_MASK(PwrCfgCmd)); value |= (GET_PWR_CFG_VALUE(PwrCfgCmd) & GET_PWR_CFG_MASK(PwrCfgCmd)); /* Write the value back to sytem register */ rtw_write8(padapter, offset, value); break; case PWR_CMD_POLLING: RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_POLLING\n")); bPollingBit = false; offset = GET_PWR_CFG_OFFSET(PwrCfgCmd); do { value = rtw_read8(padapter, offset); value &= GET_PWR_CFG_MASK(PwrCfgCmd); if (value == (GET_PWR_CFG_VALUE(PwrCfgCmd) & GET_PWR_CFG_MASK(PwrCfgCmd))) bPollingBit = true; else rtw_udelay_os(10); if (pollingCount++ > maxPollingCnt) { DBG_88E("Fail to polling Offset[%#x]\n", offset); return false; } } while (!bPollingBit); break; case PWR_CMD_DELAY: RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_DELAY\n")); if (GET_PWR_CFG_VALUE(PwrCfgCmd) == PWRSEQ_DELAY_US) rtw_udelay_os(GET_PWR_CFG_OFFSET(PwrCfgCmd)); else rtw_udelay_os(GET_PWR_CFG_OFFSET(PwrCfgCmd)*1000); break; case PWR_CMD_END: /* When this command is parsed, end the process */ RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_END\n")); return true; break; default: RT_TRACE(_module_hal_init_c_ , _drv_err_, ("HalPwrSeqCmdParsing: Unknown CMD!!\n")); break; } } AryIdx++;/* Add Array Index */ }while (1); return true; }
static int phy_RF6052_Config_ParaFile( IN PADAPTER Adapter ) { u32 u4RegValue=0; u8 eRFPath; BB_REGISTER_DEFINITION_T *pPhyReg; int rtStatus = _SUCCESS; HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); struct dm_priv *pdmpriv = &pHalData->dmpriv; u8 *pszRadioAFile = NULL, *pszRadioBFile = NULL; static s8 sz92DRadioAFile[] = RTL8192D_PHY_RADIO_A; static s8 sz92DRadioBFile[] = RTL8192D_PHY_RADIO_B; static s8 sz92DRadioAintPAFile[] = RTL8192D_PHY_RADIO_A_intPA; static s8 sz92DRadioBintPAFile[] = RTL8192D_PHY_RADIO_B_intPA; BOOLEAN bMac1NeedInitRadioAFirst = _FALSE,bMac0NeedInitRadioBFirst = _FALSE; BOOLEAN bNeedPowerDownRadioA = _FALSE,bNeedPowerDownRadioB = _FALSE; BOOLEAN bTrueBPath = _FALSE;//vivi added this for read parameter from header, 20100908 u32 MaskforPhySet = 0; //For 92d PHY cross access, 88c must set value 0. pszRadioAFile = sz92DRadioAFile; pszRadioBFile = sz92DRadioBFile; if(pHalData->InternalPA5G[0]) pszRadioAFile = sz92DRadioAintPAFile; if(pHalData->InternalPA5G[1]) pszRadioBFile = sz92DRadioBintPAFile; //DMDP,MAC0 on G band,MAC1 on A band. if(pHalData->MacPhyMode92D==DUALMAC_DUALPHY) { if(pHalData->CurrentBandType92D == BAND_ON_2_4G && pHalData->interfaceIndex == 0) { //MAC0 Need PHY1 load radio_b.txt . Driver use DBI to write. if(rtl8192d_PHY_EnableAnotherPHY(Adapter, _TRUE)) { pHalData->NumTotalRFPath = 2; bMac0NeedInitRadioBFirst = _TRUE; } else { // We think if MAC1 is ON,then radio_a.txt and radio_b.txt has been load. return rtStatus; } } else if(pHalData->CurrentBandType92D == BAND_ON_5G && pHalData->interfaceIndex == 1) { //MAC1 Need PHY0 load radio_a.txt . Driver use DBI to write. if(rtl8192d_PHY_EnableAnotherPHY(Adapter, _FALSE)) { pHalData->NumTotalRFPath = 2; bMac1NeedInitRadioAFirst = _TRUE; } else { // We think if MAC0 is ON,then radio_a.txt and radio_b.txt has been load. return rtStatus; } } else if(pHalData->interfaceIndex == 1) { // MAC0 enabled, only init radia B. pszRadioAFile = pszRadioBFile; bTrueBPath = _TRUE; //vivi added this for read parameter from header, 20100909 } } //RT_TRACE(COMP_INIT, DBG_LOUD, (" ===> phy_RF6052_Config_ParaFile() Radio_A:%s\n",pszRadioAFile)); //RT_TRACE(COMP_INIT, DBG_LOUD, (" ===> phy_RF6052_Config_ParaFile() Radio_B:%s\n",pszRadioBFile)); //3//----------------------------------------------------------------- //3// <2> Initialize RF //3//----------------------------------------------------------------- for(eRFPath = RF_PATH_A; eRFPath <pHalData->NumTotalRFPath; eRFPath++) { if (bMac1NeedInitRadioAFirst) //Mac1 use PHY0 write { if (eRFPath == RF_PATH_A) { bNeedPowerDownRadioA = _TRUE; MaskforPhySet = MAC1_ACCESS_PHY0; } else if (eRFPath == RF_PATH_B) { MaskforPhySet = 0; bMac1NeedInitRadioAFirst = _FALSE; eRFPath = RF_PATH_A; bTrueBPath = _TRUE; pszRadioAFile = pszRadioBFile; pHalData->NumTotalRFPath = 1; } } else if (bMac0NeedInitRadioBFirst) //Mac0 use PHY1 write { if (eRFPath == RF_PATH_A) { MaskforPhySet = 0; } if (eRFPath == RF_PATH_B) { MaskforPhySet = MAC0_ACCESS_PHY1; bMac0NeedInitRadioBFirst = _FALSE; bNeedPowerDownRadioB = _TRUE; eRFPath = RF_PATH_A; bTrueBPath = _TRUE; pszRadioAFile = pszRadioBFile; pHalData->NumTotalRFPath = 1; } } pPhyReg = &pHalData->PHYRegDef[eRFPath]; /*----Store original RFENV control type----*/ switch(eRFPath) { case RF_PATH_A: case RF_PATH_C: u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs|MaskforPhySet, bRFSI_RFENV); break; case RF_PATH_B : case RF_PATH_D: u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs|MaskforPhySet, bRFSI_RFENV<<16); break; } /*----Set RF_ENV enable----*/ PHY_SetBBReg(Adapter, pPhyReg->rfintfe|MaskforPhySet, bRFSI_RFENV<<16, 0x1); rtw_udelay_os(1);//PlatformStallExecution(1); /*----Set RF_ENV output high----*/ PHY_SetBBReg(Adapter, pPhyReg->rfintfo|MaskforPhySet, bRFSI_RFENV, 0x1); rtw_udelay_os(1);//PlatformStallExecution(1); /* Set bit number of Address and Data for RF register */ PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2|MaskforPhySet, b3WireAddressLength, 0x0); // Set 1 to 4 bits for 8255 rtw_udelay_os(1);//PlatformStallExecution(1); PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2|MaskforPhySet, b3WireDataLength, 0x0); // Set 0 to 12 bits for 8255 rtw_udelay_os(1);//PlatformStallExecution(1); /*----Initialize RF fom connfiguration file----*/ switch(eRFPath) { case RF_PATH_A: #ifdef CONFIG_EMBEDDED_FWIMG //vivi added this for read parameter from header, 20100908 if(bTrueBPath == _TRUE) rtStatus = rtl8192d_PHY_ConfigRFWithHeaderFile(Adapter,radiob_txt|MaskforPhySet, (RF_RADIO_PATH_E)eRFPath); else rtStatus = rtl8192d_PHY_ConfigRFWithHeaderFile(Adapter,radioa_txt|MaskforPhySet, (RF_RADIO_PATH_E)eRFPath); #else rtStatus = rtl8192d_PHY_ConfigRFWithParaFile(Adapter, pszRadioAFile, (RF_RADIO_PATH_E)eRFPath); #endif break; case RF_PATH_B: #ifdef CONFIG_EMBEDDED_FWIMG rtStatus = rtl8192d_PHY_ConfigRFWithHeaderFile(Adapter,radiob_txt, (RF_RADIO_PATH_E)eRFPath); #else rtStatus = rtl8192d_PHY_ConfigRFWithParaFile(Adapter, pszRadioBFile, (RF_RADIO_PATH_E)eRFPath); #endif break; case RF_PATH_C: break; case RF_PATH_D: break; } /*----Restore RFENV control type----*/; switch(eRFPath) { case RF_PATH_A: case RF_PATH_C: PHY_SetBBReg(Adapter, pPhyReg->rfintfs|MaskforPhySet, bRFSI_RFENV, u4RegValue); break; case RF_PATH_B : case RF_PATH_D: PHY_SetBBReg(Adapter, pPhyReg->rfintfs|MaskforPhySet, bRFSI_RFENV<<16, u4RegValue); break; } if(rtStatus != _SUCCESS){ //RT_TRACE(COMP_FPGA, DBG_LOUD, ("phy_RF6052_Config_ParaFile():Radio[%d] Fail!!", eRFPath)); goto phy_RF6052_Config_ParaFile_Fail; } } if (bNeedPowerDownRadioA) { // check MAC0 enable or not again now, if enabled, not power down radio A. rtl8192d_PHY_PowerDownAnotherPHY(Adapter, _FALSE); } else if (bNeedPowerDownRadioB) { // check MAC1 enable or not again now, if enabled, not power down radio B. rtl8192d_PHY_PowerDownAnotherPHY(Adapter, _TRUE); } for(eRFPath = RF_PATH_A; eRFPath <pHalData->NumTotalRFPath; eRFPath++) { #if MP_DRIVER == 1 PHY_SetRFReg(Adapter, eRFPath, RF_RXRF_A3, bRFRegOffsetMask, 0xff456); #endif pdmpriv->RegRF3C[eRFPath] = PHY_QueryRFReg(Adapter, eRFPath, RF_RXRF_A3, bRFRegOffsetMask); } //RT_TRACE(COMP_INIT, DBG_LOUD, ("<---phy_RF6052_Config_ParaFile()\n")); return rtStatus; phy_RF6052_Config_ParaFile_Fail: return rtStatus; }
static int phy_RF6052_Config_ParaFile_8192E( IN PADAPTER Adapter ) { u8 eRFPath; int rtStatus = _SUCCESS; HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); BB_REGISTER_DEFINITION_T *pPhyReg; static char sz8192ERadioAFile[] = RTL8192E_PHY_RADIO_A; static char sz8192ERadioBFile[] = RTL8192E_PHY_RADIO_B; static char sz8192ETxPwrTrack[] = RTL8192E_TXPWR_TRACK; char *pszRadioAFile = NULL, *pszRadioBFile = NULL, *pszTxPwrTrack = NULL; u32 u4RegValue,MaskforPhySet = 0;; pszRadioAFile = sz8192ERadioAFile; pszRadioBFile = sz8192ERadioBFile; pszTxPwrTrack = sz8192ETxPwrTrack; //3//----------------------------------------------------------------- //3// <2> Initialize RF //3//----------------------------------------------------------------- //for(eRFPath = RF_PATH_A; eRFPath <pHalData->NumTotalRFPath; eRFPath++) for(eRFPath = 0; eRFPath <pHalData->NumTotalRFPath; eRFPath++) { pPhyReg = &pHalData->PHYRegDef[eRFPath]; switch(eRFPath) { case RF_PATH_A: case RF_PATH_C: u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs|MaskforPhySet, bRFSI_RFENV); break; case RF_PATH_B : case RF_PATH_D: u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs|MaskforPhySet, bRFSI_RFENV<<16); break; default: u4RegValue = 0; break; } /*----Set RF_ENV enable----*/ PHY_SetBBReg(Adapter, pPhyReg->rfintfe|MaskforPhySet, bRFSI_RFENV<<16, 0x1); rtw_udelay_os(1);//PlatformStallExecution(1); /*----Set RF_ENV output high----*/ PHY_SetBBReg(Adapter, pPhyReg->rfintfo|MaskforPhySet, bRFSI_RFENV, 0x1); rtw_udelay_os(1);//PlatformStallExecution(1); /* Set bit number of Address and Data for RF register */ PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2|MaskforPhySet, b3WireAddressLength, 0x0); // Set 1 to 4 bits for 8255 rtw_udelay_os(1);//PlatformStallExecution(1); PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2|MaskforPhySet, b3WireDataLength, 0x0); // Set 0 to 12 bits for 8255 rtw_udelay_os(1);//PlatformStallExecution(1); /*----Initialize RF fom connfiguration file----*/ switch(eRFPath) { case RF_PATH_A: #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE if (PHY_ConfigRFWithParaFile(Adapter, pszRadioAFile, eRFPath) == _FAIL) #endif { #ifdef CONFIG_EMBEDDED_FWIMG if(HAL_STATUS_FAILURE ==ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv,CONFIG_RF_RADIO, (ODM_RF_RADIO_PATH_E)eRFPath)) rtStatus = _FAIL; #endif } break; case RF_PATH_B: #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE if (PHY_ConfigRFWithParaFile(Adapter, pszRadioBFile, eRFPath) == _FAIL) #endif { #ifdef CONFIG_EMBEDDED_FWIMG if(HAL_STATUS_FAILURE ==ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv,CONFIG_RF_RADIO, (ODM_RF_RADIO_PATH_E)eRFPath)) rtStatus = _FAIL; #endif } break; default: break; } /*----Restore RFENV control type----*/; switch(eRFPath) { case RF_PATH_A: case RF_PATH_C: PHY_SetBBReg(Adapter, pPhyReg->rfintfs|MaskforPhySet, bRFSI_RFENV, u4RegValue); break; case RF_PATH_B : case RF_PATH_D: PHY_SetBBReg(Adapter, pPhyReg->rfintfs|MaskforPhySet, bRFSI_RFENV<<16, u4RegValue); break; default: break; } if(rtStatus != _SUCCESS){ DBG_871X("%s():Radio[%d] Fail!!", __FUNCTION__, eRFPath); goto phy_RF6052_Config_ParaFile_Fail; } } //3 ----------------------------------------------------------------- //3 Configuration of Tx Power Tracking //3 ----------------------------------------------------------------- #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE if (PHY_ConfigRFWithTxPwrTrackParaFile(Adapter, pszTxPwrTrack) == _FAIL) #endif { #ifdef CONFIG_EMBEDDED_FWIMG ODM_ConfigRFWithTxPwrTrackHeaderFile(&pHalData->odmpriv); #endif } //RT_TRACE(COMP_INIT, DBG_LOUD, ("<---phy_RF6052_Config_ParaFile_8192E()\n")); phy_RF6052_Config_ParaFile_Fail: return rtStatus; }
static int phy_RF6052_Config_ParaFile( IN PADAPTER Adapter ) { u32 u4RegValue; u8 eRFPath; BB_REGISTER_DEFINITION_T *pPhyReg; int rtStatus = _SUCCESS; HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); static char sz88eRadioAFile[] = RTL8188E_PHY_RADIO_A; static char sz88eRadioBFile[] = RTL8188E_PHY_RADIO_B; char *pszRadioAFile, *pszRadioBFile; pszRadioAFile = sz88eRadioAFile; pszRadioBFile = sz88eRadioBFile; //3//----------------------------------------------------------------- //3// <2> Initialize RF //3//----------------------------------------------------------------- //for(eRFPath = RF_PATH_A; eRFPath <pHalData->NumTotalRFPath; eRFPath++) for(eRFPath = 0; eRFPath <pHalData->NumTotalRFPath; eRFPath++) { pPhyReg = &pHalData->PHYRegDef[eRFPath]; /*----Store original RFENV control type----*/ switch(eRFPath) { case RF_PATH_A: case RF_PATH_C: u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV); break; case RF_PATH_B : case RF_PATH_D: u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV<<16); break; } /*----Set RF_ENV enable----*/ PHY_SetBBReg(Adapter, pPhyReg->rfintfe, bRFSI_RFENV<<16, 0x1); rtw_udelay_os(1);//PlatformStallExecution(1); /*----Set RF_ENV output high----*/ PHY_SetBBReg(Adapter, pPhyReg->rfintfo, bRFSI_RFENV, 0x1); rtw_udelay_os(1);//PlatformStallExecution(1); /* Set bit number of Address and Data for RF register */ PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, b3WireAddressLength, 0x0); // Set 1 to 4 bits for 8255 rtw_udelay_os(1);//PlatformStallExecution(1); PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, b3WireDataLength, 0x0); // Set 0 to 12 bits for 8255 rtw_udelay_os(1);//PlatformStallExecution(1); /*----Initialize RF fom connfiguration file----*/ switch(eRFPath) { case RF_PATH_A: #ifdef CONFIG_EMBEDDED_FWIMG #ifdef CONFIG_PHY_SETTING_WITH_ODM if(HAL_STATUS_FAILURE ==ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv,(ODM_RF_RADIO_PATH_E)eRFPath, (ODM_RF_RADIO_PATH_E)eRFPath)) rtStatus= _FAIL; #else rtStatus= rtl8188e_PHY_ConfigRFWithHeaderFile(Adapter,(RF_RADIO_PATH_E)eRFPath); #endif//#ifdef CONFIG_PHY_SETTING_WITH_ODM #else rtStatus = rtl8188e_PHY_ConfigRFWithParaFile(Adapter, pszRadioAFile, (RF_RADIO_PATH_E)eRFPath); #endif//#ifdef CONFIG_EMBEDDED_FWIMG break; case RF_PATH_B: #ifdef CONFIG_EMBEDDED_FWIMG #ifdef CONFIG_PHY_SETTING_WITH_ODM if(HAL_STATUS_FAILURE ==ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv,(ODM_RF_RADIO_PATH_E)eRFPath, (ODM_RF_RADIO_PATH_E)eRFPath)) rtStatus= _FAIL; #else rtStatus = rtl8188e_PHY_ConfigRFWithHeaderFile(Adapter,(RF_RADIO_PATH_E)eRFPath); #endif //#ifdef CONFIG_PHY_SETTING_WITH_ODM #else rtStatus =rtl8188e_PHY_ConfigRFWithParaFile(Adapter, pszRadioBFile, (RF_RADIO_PATH_E)eRFPath); #endif break; case RF_PATH_C: break; case RF_PATH_D: break; } /*----Restore RFENV control type----*/; switch(eRFPath) { case RF_PATH_A: case RF_PATH_C: PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV, u4RegValue); break; case RF_PATH_B : case RF_PATH_D: PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV<<16, u4RegValue); break; } if(rtStatus != _SUCCESS){ //RT_TRACE(COMP_FPGA, DBG_LOUD, ("phy_RF6052_Config_ParaFile():Radio[%d] Fail!!", eRFPath)); goto phy_RF6052_Config_ParaFile_Fail; } } //RT_TRACE(COMP_INIT, DBG_LOUD, ("<---phy_RF6052_Config_ParaFile()\n")); return rtStatus; phy_RF6052_Config_ParaFile_Fail: return rtStatus; }
// // Description: // This routine deal with the Power Configuration CMDs parsing for RTL8723/RTL8188E Series IC. // // Assumption: // We should follow specific format which was released from HW SD. // // 2011.07.07, added by Roger. // u8 HalPwrSeqCmdParsing( PADAPTER padapter, u8 CutVersion, u8 FabVersion, u8 InterfaceType, WLAN_PWR_CFG PwrSeqCmd[]) { WLAN_PWR_CFG PwrCfgCmd = {0}; u8 bPollingBit = _FALSE; u32 AryIdx = 0; u8 value = 0; u32 offset = 0; u32 pollingCount = 0; // polling autoload done. u32 maxPollingCnt = 5000; do { PwrCfgCmd = PwrSeqCmd[AryIdx]; RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: offset(%#x) cut_msk(%#x) fab_msk(%#x) interface_msk(%#x) base(%#x) cmd(%#x) msk(%#x) value(%#x)\n", GET_PWR_CFG_OFFSET(PwrCfgCmd), GET_PWR_CFG_CUT_MASK(PwrCfgCmd), GET_PWR_CFG_FAB_MASK(PwrCfgCmd), GET_PWR_CFG_INTF_MASK(PwrCfgCmd), GET_PWR_CFG_BASE(PwrCfgCmd), GET_PWR_CFG_CMD(PwrCfgCmd), GET_PWR_CFG_MASK(PwrCfgCmd), GET_PWR_CFG_VALUE(PwrCfgCmd))); //2 Only Handle the command whose FAB, CUT, and Interface are matched if ((GET_PWR_CFG_FAB_MASK(PwrCfgCmd) & FabVersion) && (GET_PWR_CFG_CUT_MASK(PwrCfgCmd) & CutVersion) && (GET_PWR_CFG_INTF_MASK(PwrCfgCmd) & InterfaceType)) { switch (GET_PWR_CFG_CMD(PwrCfgCmd)) { case PWR_CMD_READ: RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_READ\n")); break; case PWR_CMD_WRITE: RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_WRITE\n")); offset = GET_PWR_CFG_OFFSET(PwrCfgCmd); #ifdef CONFIG_SDIO_HCI // // <Roger_Notes> We should deal with interface specific address mapping for some interfaces, e.g., SDIO interface // 2011.07.07. // if (GET_PWR_CFG_BASE(PwrCfgCmd) == PWR_BASEADDR_SDIO) { // Read Back SDIO Local value value = SdioLocalCmd52Read1Byte(padapter, offset); value &= ~(GET_PWR_CFG_MASK(PwrCfgCmd)); value |= (GET_PWR_CFG_VALUE(PwrCfgCmd) & GET_PWR_CFG_MASK(PwrCfgCmd)); // Write Back SDIO Local value SdioLocalCmd52Write1Byte(padapter, offset, value); } else #endif { #ifdef CONFIG_GSPI_HCI if (GET_PWR_CFG_BASE(PwrCfgCmd) == PWR_BASEADDR_SDIO) offset = SPI_LOCAL_OFFSET | offset; #endif // Read the value from system register value = rtw_read8(padapter, offset); value=value&(~(GET_PWR_CFG_MASK(PwrCfgCmd))); value=value|(GET_PWR_CFG_VALUE(PwrCfgCmd)&GET_PWR_CFG_MASK(PwrCfgCmd)); // Write the value back to sytem register rtw_write8(padapter, offset, value); } break; case PWR_CMD_POLLING: RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_POLLING\n")); bPollingBit = _FALSE; offset = GET_PWR_CFG_OFFSET(PwrCfgCmd); #ifdef CONFIG_GSPI_HCI if (GET_PWR_CFG_BASE(PwrCfgCmd) == PWR_BASEADDR_SDIO) offset = SPI_LOCAL_OFFSET | offset; #endif do { #ifdef CONFIG_SDIO_HCI if (GET_PWR_CFG_BASE(PwrCfgCmd) == PWR_BASEADDR_SDIO) value = SdioLocalCmd52Read1Byte(padapter, offset); else #endif value = rtw_read8(padapter, offset); value=value&GET_PWR_CFG_MASK(PwrCfgCmd); if (value == (GET_PWR_CFG_VALUE(PwrCfgCmd) & GET_PWR_CFG_MASK(PwrCfgCmd))) bPollingBit = _TRUE; else rtw_udelay_os(10); if (pollingCount++ > maxPollingCnt) { DBG_871X("Fail to polling Offset[%#x]=%02x\n", offset, value); return _FALSE; } } while (!bPollingBit); break; case PWR_CMD_DELAY: RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_DELAY\n")); if (GET_PWR_CFG_VALUE(PwrCfgCmd) == PWRSEQ_DELAY_US) rtw_udelay_os(GET_PWR_CFG_OFFSET(PwrCfgCmd)); else rtw_udelay_os(GET_PWR_CFG_OFFSET(PwrCfgCmd)*1000); break; case PWR_CMD_END: // When this command is parsed, end the process RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_END\n")); return _TRUE; break; default: RT_TRACE(_module_hal_init_c_ , _drv_err_, ("HalPwrSeqCmdParsing: Unknown CMD!!\n")); break; } } AryIdx++;//Add Array Index }while(1); return _TRUE; }