From 9c3c9ddc8cfedd6dc0c41f74320fca0fcd100d92 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 8 Aug 2013 00:41:21 -0500 Subject: [PATCH] rtl8188eu: Fix checkpatch errors for hal/rtl8188e_hal_init.c and hal/rtl8188e_dm.c Signed-off-by: Larry Finger --- hal/rtl8188e_dm.c | 292 +++--- hal/rtl8188e_hal_init.c | 2102 ++++++++++++++------------------------- 2 files changed, 884 insertions(+), 1510 deletions(-) diff --git a/hal/rtl8188e_dm.c b/hal/rtl8188e_dm.c index afabb02..2016db2 100644 --- a/hal/rtl8188e_dm.c +++ b/hal/rtl8188e_dm.c @@ -26,30 +26,16 @@ /* */ #define _RTL8188E_DM_C_ -/* */ -/* include files */ -/* */ #include #include #include -/* */ -/* Global var */ -/* */ - - -static void -dm_CheckProtection( - struct adapter * Adapter - ) +static void dm_CheckProtection(struct adapter *Adapter) { } -static void -dm_CheckStatistics( - struct adapter * Adapter - ) +static void dm_CheckStatistics(struct adapter *Adapter) { } @@ -72,24 +58,22 @@ static void dm_CheckPbcGPIO(struct adapter *padapter) tmp1byte &= ~(HAL_8192C_HW_GPIO_WPS_BIT); rtw_write8(padapter, GPIO_IO_SEL, tmp1byte); /* enable GPIO[2] as input mode */ - tmp1byte =rtw_read8(padapter, GPIO_IN); + tmp1byte = rtw_read8(padapter, GPIO_IN); if (tmp1byte == 0xff) - return ; + return; if (tmp1byte&HAL_8192C_HW_GPIO_WPS_BIT) - { bPbcPressed = true; - } - if ( true == bPbcPressed) - { + if (bPbcPressed) { /* Here we only set bPbcPressed to true */ /* After trigger PBC, the variable will be set to false */ DBG_88E("CheckPbcGPIO - PBC is pressed\n"); - if ( padapter->pid[0] == 0 ) - { /* 0 is the default value and it means the application monitors the HW PBC doesn't privde its pid to driver. */ + if (padapter->pid[0] == 0) { + /* 0 is the default value and it means the application + * monitors the HW PBC doesn't privde its pid to driver. */ return; } @@ -100,13 +84,9 @@ static void dm_CheckPbcGPIO(struct adapter *padapter) /* */ /* Initialize GPIO setting registers */ /* */ -static void -dm_InitGPIOSetting( - struct adapter * Adapter - ) +static void dm_InitGPIOSetting(struct adapter *Adapter) { - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - + struct hal_data_8188e *hal_data = GET_HAL_DATA(Adapter); u8 tmp1byte; tmp1byte = rtw_read8(Adapter, REG_GPIO_MUXCFG); @@ -114,238 +94,204 @@ dm_InitGPIOSetting( #ifdef CONFIG_BT_COEXIST /* UMB-B cut bug. We need to support the modification. */ - if (IS_81xxC_VENDOR_UMC_B_CUT(pHalData->VersionID) && - pHalData->bt_coexist.BT_Coexist) - { - tmp1byte |= (BIT5); - } + if (IS_81xxC_VENDOR_UMC_B_CUT(hal_data->VersionID) && + hal_data->bt_coexist.BT_Coexist) + tmp1byte |= BIT5; #endif rtw_write8(Adapter, REG_GPIO_MUXCFG, tmp1byte); - } /* */ /* functions */ /* */ -static void Init_ODM_ComInfo_88E(struct adapter * Adapter) +static void Init_ODM_ComInfo_88E(struct adapter *Adapter) { + struct hal_data_8188e *hal_data = GET_HAL_DATA(Adapter); + struct dm_priv *pdmpriv = &hal_data->dmpriv; + struct odm_dm_struct *dm_odm = &(hal_data->odmpriv); + u8 cut_ver, fab_ver; - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - struct dm_priv *pdmpriv = &pHalData->dmpriv; - struct odm_dm_struct * pDM_Odm = &(pHalData->odmpriv); - u8 cut_ver,fab_ver; - - /* */ /* Init Value */ - /* */ - _rtw_memset(pDM_Odm,0,sizeof(pDM_Odm)); + _rtw_memset(dm_odm, 0, sizeof(dm_odm)); - pDM_Odm->Adapter = Adapter; + dm_odm->Adapter = Adapter; - ODM_CmnInfoInit(pDM_Odm,ODM_CMNINFO_PLATFORM,ODM_CE); + ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_PLATFORM, ODM_CE); - if (Adapter->interface_type == RTW_GSPI ) - ODM_CmnInfoInit(pDM_Odm,ODM_CMNINFO_INTERFACE,ODM_ITRF_SDIO); + if (Adapter->interface_type == RTW_GSPI) + ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_INTERFACE, ODM_ITRF_SDIO); else - ODM_CmnInfoInit(pDM_Odm,ODM_CMNINFO_INTERFACE,Adapter->interface_type);/* RTL871X_HCI_TYPE */ + ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_INTERFACE, Adapter->interface_type);/* RTL871X_HCI_TYPE */ - ODM_CmnInfoInit(pDM_Odm,ODM_CMNINFO_IC_TYPE,ODM_RTL8188E); + ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_IC_TYPE, ODM_RTL8188E); fab_ver = ODM_TSMC; cut_ver = ODM_CUT_A; - ODM_CmnInfoInit(pDM_Odm,ODM_CMNINFO_FAB_VER,fab_ver); - ODM_CmnInfoInit(pDM_Odm,ODM_CMNINFO_CUT_VER,cut_ver); + ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_FAB_VER, fab_ver); + ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_CUT_VER, cut_ver); - ODM_CmnInfoInit(pDM_Odm, ODM_CMNINFO_MP_TEST_CHIP,IS_NORMAL_CHIP(pHalData->VersionID)); + ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_MP_TEST_CHIP, IS_NORMAL_CHIP(hal_data->VersionID)); - ODM_CmnInfoInit(pDM_Odm,ODM_CMNINFO_PATCH_ID,pHalData->CustomerID); - ODM_CmnInfoInit(pDM_Odm,ODM_CMNINFO_BWIFI_TEST,Adapter->registrypriv.wifi_spec); + ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_PATCH_ID, hal_data->CustomerID); + ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_BWIFI_TEST, Adapter->registrypriv.wifi_spec); - if (pHalData->rf_type == RF_1T1R){ - ODM_CmnInfoUpdate(pDM_Odm,ODM_CMNINFO_RF_TYPE,ODM_1T1R); - } - else if (pHalData->rf_type == RF_2T2R){ - ODM_CmnInfoUpdate(pDM_Odm,ODM_CMNINFO_RF_TYPE,ODM_2T2R); - } - else if (pHalData->rf_type == RF_1T2R){ - ODM_CmnInfoUpdate(pDM_Odm,ODM_CMNINFO_RF_TYPE,ODM_1T2R); - } + if (hal_data->rf_type == RF_1T1R) + ODM_CmnInfoUpdate(dm_odm, ODM_CMNINFO_RF_TYPE, ODM_1T1R); + else if (hal_data->rf_type == RF_2T2R) + ODM_CmnInfoUpdate(dm_odm, ODM_CMNINFO_RF_TYPE, ODM_2T2R); + else if (hal_data->rf_type == RF_1T2R) + ODM_CmnInfoUpdate(dm_odm, ODM_CMNINFO_RF_TYPE, ODM_1T2R); - ODM_CmnInfoInit(pDM_Odm, ODM_CMNINFO_RF_ANTENNA_TYPE, pHalData->TRxAntDivType); + ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_RF_ANTENNA_TYPE, hal_data->TRxAntDivType); pdmpriv->InitODMFlag = ODM_RF_CALIBRATION | ODM_RF_TX_PWR_TRACK; - ODM_CmnInfoUpdate(pDM_Odm,ODM_CMNINFO_ABILITY,pdmpriv->InitODMFlag); - + ODM_CmnInfoUpdate(dm_odm, ODM_CMNINFO_ABILITY, pdmpriv->InitODMFlag); } -static void Update_ODM_ComInfo_88E(struct adapter * Adapter) + +static void Update_ODM_ComInfo_88E(struct adapter *Adapter) { struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; struct mlme_priv *pmlmepriv = &Adapter->mlmepriv; struct pwrctrl_priv *pwrctrlpriv = &Adapter->pwrctrlpriv; - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - struct odm_dm_struct * pDM_Odm = &(pHalData->odmpriv); - struct dm_priv *pdmpriv = &pHalData->dmpriv; + struct hal_data_8188e *hal_data = GET_HAL_DATA(Adapter); + struct odm_dm_struct *dm_odm = &(hal_data->odmpriv); + struct dm_priv *pdmpriv = &hal_data->dmpriv; int i; - pdmpriv->InitODMFlag = ODM_BB_DIG | - ODM_BB_RA_MASK | - ODM_BB_DYNAMIC_TXPWR | - ODM_BB_FA_CNT | - ODM_BB_RSSI_MONITOR | - ODM_BB_CCK_PD | - ODM_BB_PWR_SAVE | - ODM_MAC_EDCA_TURBO | - ODM_RF_CALIBRATION | - ODM_RF_TX_PWR_TRACK ; - if (pHalData->AntDivCfg) + pdmpriv->InitODMFlag = ODM_BB_DIG | + ODM_BB_RA_MASK | + ODM_BB_DYNAMIC_TXPWR | + ODM_BB_FA_CNT | + ODM_BB_RSSI_MONITOR | + ODM_BB_CCK_PD | + ODM_BB_PWR_SAVE | + ODM_MAC_EDCA_TURBO | + ODM_RF_CALIBRATION | + ODM_RF_TX_PWR_TRACK; + if (hal_data->AntDivCfg) pdmpriv->InitODMFlag |= ODM_BB_ANT_DIV; if (Adapter->registrypriv.mp_mode == 1) { - pdmpriv->InitODMFlag = ODM_RF_CALIBRATION | + pdmpriv->InitODMFlag = ODM_RF_CALIBRATION | ODM_RF_TX_PWR_TRACK; } - ODM_CmnInfoUpdate(pDM_Odm,ODM_CMNINFO_ABILITY,pdmpriv->InitODMFlag); + ODM_CmnInfoUpdate(dm_odm, ODM_CMNINFO_ABILITY, pdmpriv->InitODMFlag); - ODM_CmnInfoHook(pDM_Odm,ODM_CMNINFO_TX_UNI,&(Adapter->xmitpriv.tx_bytes)); - ODM_CmnInfoHook(pDM_Odm,ODM_CMNINFO_RX_UNI,&(Adapter->recvpriv.rx_bytes)); - ODM_CmnInfoHook(pDM_Odm,ODM_CMNINFO_WM_MODE,&(pmlmeext->cur_wireless_mode)); - ODM_CmnInfoHook(pDM_Odm,ODM_CMNINFO_SEC_CHNL_OFFSET,&(pHalData->nCur40MhzPrimeSC)); - ODM_CmnInfoHook(pDM_Odm,ODM_CMNINFO_SEC_MODE,&(Adapter->securitypriv.dot11PrivacyAlgrthm)); - ODM_CmnInfoHook(pDM_Odm,ODM_CMNINFO_BW,&(pHalData->CurrentChannelBW )); - ODM_CmnInfoHook(pDM_Odm,ODM_CMNINFO_CHNL,&( pHalData->CurrentChannel)); - ODM_CmnInfoHook(pDM_Odm,ODM_CMNINFO_NET_CLOSED,&( Adapter->net_closed)); - ODM_CmnInfoHook(pDM_Odm,ODM_CMNINFO_MP_MODE,&(Adapter->registrypriv.mp_mode)); - ODM_CmnInfoHook(pDM_Odm,ODM_CMNINFO_SCAN,&(pmlmepriv->bScanInProcess)); - ODM_CmnInfoHook(pDM_Odm,ODM_CMNINFO_POWER_SAVING,&(pwrctrlpriv->bpower_saving)); - ODM_CmnInfoInit(pDM_Odm, ODM_CMNINFO_RF_ANTENNA_TYPE, pHalData->TRxAntDivType); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_TX_UNI, &(Adapter->xmitpriv.tx_bytes)); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_RX_UNI, &(Adapter->recvpriv.rx_bytes)); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_WM_MODE, &(pmlmeext->cur_wireless_mode)); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_SEC_CHNL_OFFSET, &(hal_data->nCur40MhzPrimeSC)); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_SEC_MODE, &(Adapter->securitypriv.dot11PrivacyAlgrthm)); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_BW, &(hal_data->CurrentChannelBW)); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_CHNL, &(hal_data->CurrentChannel)); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_NET_CLOSED, &(Adapter->net_closed)); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_MP_MODE, &(Adapter->registrypriv.mp_mode)); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_SCAN, &(pmlmepriv->bScanInProcess)); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_POWER_SAVING, &(pwrctrlpriv->bpower_saving)); + ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_RF_ANTENNA_TYPE, hal_data->TRxAntDivType); - for (i=0; i< NUM_STA; i++) - ODM_CmnInfoPtrArrayHook(pDM_Odm, ODM_CMNINFO_STA_STATUS,i,NULL); + for (i = 0; i < NUM_STA; i++) + ODM_CmnInfoPtrArrayHook(dm_odm, ODM_CMNINFO_STA_STATUS, i, NULL); } -void -rtl8188e_InitHalDm( - struct adapter * Adapter - ) +void rtl8188e_InitHalDm(struct adapter *Adapter) { - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - struct dm_priv *pdmpriv = &pHalData->dmpriv; - struct odm_dm_struct * pDM_Odm = &(pHalData->odmpriv); + struct hal_data_8188e *hal_data = GET_HAL_DATA(Adapter); + struct dm_priv *pdmpriv = &hal_data->dmpriv; + struct odm_dm_struct *dm_odm = &(hal_data->odmpriv); u8 i; dm_InitGPIOSetting(Adapter); - pdmpriv->DM_Type = DM_Type_ByDriver; pdmpriv->DMFlag = DYNAMIC_FUNC_DISABLE; - Update_ODM_ComInfo_88E(Adapter); - ODM_DMInit(pDM_Odm); - + ODM_DMInit(dm_odm); Adapter->fix_rate = 0xFF; - } - -void -rtl8188e_HalDmWatchDog( - struct adapter * Adapter - ) +void rtl8188e_HalDmWatchDog(struct adapter *Adapter) { - bool bFwCurrentInPSMode = false; - bool bFwPSAwake = true; + bool fw_cur_in_ps = false; + bool fw_ps_awake = true; u8 hw_init_completed = false; - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - struct dm_priv *pdmpriv = &pHalData->dmpriv; - struct odm_dm_struct * pDM_Odm = &(pHalData->odmpriv); + struct hal_data_8188e *hal_data = GET_HAL_DATA(Adapter); + struct dm_priv *pdmpriv = &hal_data->dmpriv; + struct odm_dm_struct *dm_odm = &(hal_data->odmpriv); _func_enter_; - hw_init_completed = Adapter->hw_init_completed; - if (hw_init_completed == false) + if (!hw_init_completed) goto skip_dm; - bFwCurrentInPSMode = Adapter->pwrctrlpriv.bFwCurrentInPSMode; - rtw_hal_get_hwreg(Adapter, HW_VAR_FWLPS_RF_ON, (u8 *)(&bFwPSAwake)); + fw_cur_in_ps = Adapter->pwrctrlpriv.bFwCurrentInPSMode; + rtw_hal_get_hwreg(Adapter, HW_VAR_FWLPS_RF_ON, (u8 *)(&fw_ps_awake)); /* Fw is under p2p powersaving mode, driver should stop dynamic mechanism. */ /* modifed by thomas. 2011.06.11. */ if (Adapter->wdinfo.p2p_ps_mode) - bFwPSAwake = false; + fw_ps_awake = false; - if ( (hw_init_completed == true) - && ((!bFwCurrentInPSMode) && bFwPSAwake)) - { - /* */ + if (hw_init_completed && ((!fw_cur_in_ps) && fw_ps_awake)) { /* Calculate Tx/Rx statistics. */ - /* */ dm_CheckStatistics(Adapter); _record_initrate: _func_exit_; } - /* ODM */ - if (hw_init_completed == true) { - struct mlme_priv *pmlmepriv = &Adapter->mlmepriv; - u8 bLinked=false; + if (hw_init_completed) { + struct mlme_priv *pmlmepriv = &Adapter->mlmepriv; + u8 bLinked = false; - if ( (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE) == true)) - { + if ((check_fwstate(pmlmepriv, WIFI_AP_STATE)) || + (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE))) { if (Adapter->stapriv.asoc_sta_count > 2) bLinked = true; - } - else{/* Station mode */ - if (check_fwstate(pmlmepriv, _FW_LINKED)== true) + } else {/* Station mode */ + if (check_fwstate(pmlmepriv, _FW_LINKED)) bLinked = true; } - ODM_CmnInfoUpdate(&pHalData->odmpriv ,ODM_CMNINFO_LINK, bLinked); - ODM_DMWatchdog(&pHalData->odmpriv); - + ODM_CmnInfoUpdate(&hal_data->odmpriv, ODM_CMNINFO_LINK, bLinked); + ODM_DMWatchdog(&hal_data->odmpriv); } - skip_dm: - /* Check GPIO to determine current RF on/off and Pbc status. */ /* Check Hardware Radio ON/OFF or not */ return; } -void rtl8188e_init_dm_priv(struct adapter * Adapter) +void rtl8188e_init_dm_priv(struct adapter *Adapter) { - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - struct dm_priv *pdmpriv = &pHalData->dmpriv; - struct odm_dm_struct * podmpriv = &pHalData->odmpriv; + struct hal_data_8188e *hal_data = GET_HAL_DATA(Adapter); + struct dm_priv *pdmpriv = &hal_data->dmpriv; + struct odm_dm_struct *podmpriv = &hal_data->odmpriv; + _rtw_memset(pdmpriv, 0, sizeof(struct dm_priv)); Init_ODM_ComInfo_88E(Adapter); ODM_InitDebugSetting(podmpriv); } -void rtl8188e_deinit_dm_priv(struct adapter * Adapter) +void rtl8188e_deinit_dm_priv(struct adapter *Adapter) { - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - struct dm_priv *pdmpriv = &pHalData->dmpriv; - struct odm_dm_struct * podmpriv = &pHalData->odmpriv; } /* Add new function to reset the state of antenna diversity before link. */ -/* */ /* Compare RSSI for deciding antenna */ -void AntDivCompare8188E(struct adapter * Adapter, struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src) +void AntDivCompare8188E(struct adapter *Adapter, struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src) { - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - if (0 != pHalData->AntDivCfg) { + struct hal_data_8188e *hal_data = GET_HAL_DATA(Adapter); + + if (0 != hal_data->AntDivCfg) { /* select optimum_antenna for before linked =>For antenna diversity */ - if (dst->Rssi >= src->Rssi )/* keep org parameter */ - { + if (dst->Rssi >= src->Rssi) {/* keep org parameter */ src->Rssi = dst->Rssi; src->PhyInfo.Optimum_antenna = dst->PhyInfo.Optimum_antenna; } @@ -353,31 +299,29 @@ void AntDivCompare8188E(struct adapter * Adapter, struct wlan_bssid_ex *dst, str } /* Add new function to reset the state of antenna diversity before link. */ -u8 AntDivBeforeLink8188E(struct adapter * Adapter ) +u8 AntDivBeforeLink8188E(struct adapter *Adapter) { - - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - struct odm_dm_struct *pDM_Odm =&pHalData->odmpriv; - struct sw_ant_switch *pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table; - struct mlme_priv *pmlmepriv = &(Adapter->mlmepriv); + struct hal_data_8188e *hal_data = GET_HAL_DATA(Adapter); + struct odm_dm_struct *dm_odm = &hal_data->odmpriv; + struct sw_ant_switch *dm_swat_tbl = &dm_odm->DM_SWAT_Table; + struct mlme_priv *pmlmepriv = &(Adapter->mlmepriv); /* Condition that does not need to use antenna diversity. */ - if (pHalData->AntDivCfg==0) + if (hal_data->AntDivCfg == 0) return false; - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) + if (check_fwstate(pmlmepriv, _FW_LINKED)) return false; - if (pDM_SWAT_Table->SWAS_NoLink_State == 0){ + if (dm_swat_tbl->SWAS_NoLink_State == 0) { /* switch channel */ - pDM_SWAT_Table->SWAS_NoLink_State = 1; - pDM_SWAT_Table->CurAntenna = (pDM_SWAT_Table->CurAntenna==Antenna_A)?Antenna_B:Antenna_A; + dm_swat_tbl->SWAS_NoLink_State = 1; + dm_swat_tbl->CurAntenna = (dm_swat_tbl->CurAntenna == Antenna_A) ? Antenna_B : Antenna_A; - rtw_antenna_select_cmd(Adapter, pDM_SWAT_Table->CurAntenna, false); + rtw_antenna_select_cmd(Adapter, dm_swat_tbl->CurAntenna, false); return true; } else { - pDM_SWAT_Table->SWAS_NoLink_State = 0; + dm_swat_tbl->SWAS_NoLink_State = 0; return false; } - } diff --git a/hal/rtl8188e_hal_init.c b/hal/rtl8188e_hal_init.c index 0b2de96..e4f56a8 100644 --- a/hal/rtl8188e_hal_init.c +++ b/hal/rtl8188e_hal_init.c @@ -28,17 +28,16 @@ #include -static void iol_mode_enable(struct adapter * padapter, u8 enable) +static void iol_mode_enable(struct adapter *padapter, u8 enable) { u8 reg_0xf0 = 0; - if (enable) - { + if (enable) { /* Enable initial offload */ reg_0xf0 = rtw_read8(padapter, REG_SYS_CFG); rtw_write8(padapter, REG_SYS_CFG, reg_0xf0|SW_OFFLOAD_EN); - if (padapter->bFWReady == false) { + if (!padapter->bFWReady) { DBG_88E("bFWReady == false call reset 8051...\n"); _8051Reset88E(padapter); } @@ -50,10 +49,10 @@ static void iol_mode_enable(struct adapter * padapter, u8 enable) } } -static s32 iol_execute(struct adapter * padapter, u8 control) +static s32 iol_execute(struct adapter *padapter, u8 control) { s32 status = _FAIL; - u8 reg_0x88 = 0,reg_1c7=0; + u8 reg_0x88 = 0, reg_1c7 = 0; u32 start = 0, passing_time = 0; control = control&0x0f; @@ -61,21 +60,19 @@ static s32 iol_execute(struct adapter * padapter, u8 control) rtw_write8(padapter, REG_HMEBOX_E0, reg_0x88|control); start = rtw_get_current_time(); - while ((reg_0x88=rtw_read8(padapter, REG_HMEBOX_E0)) & control && - (passing_time=rtw_get_passing_time_ms(start))<1000) { + while ((reg_0x88 = rtw_read8(padapter, REG_HMEBOX_E0)) & control && + (passing_time = rtw_get_passing_time_ms(start)) < 1000) { + ; } reg_0x88 = rtw_read8(padapter, REG_HMEBOX_E0); - status = (reg_0x88 & control)?_FAIL:_SUCCESS; + status = (reg_0x88 & control) ? _FAIL : _SUCCESS; if (reg_0x88 & control<<4) status = _FAIL; return status; } -static s32 iol_InitLLTTable( - struct adapter * padapter, - u8 txpktbuf_bndy - ) +static s32 iol_InitLLTTable(struct adapter *padapter, u8 txpktbuf_bndy) { s32 rst = _SUCCESS; iol_mode_enable(padapter, 1); @@ -86,24 +83,24 @@ static s32 iol_InitLLTTable( } static void -efuse_phymap_to_logical(u8 * phymap, u16 _offset, u16 _size_byte, u8 *pbuf) +efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8 *pbuf) { - u8 *efuseTbl = NULL; - u8 rtemp8; + u8 *efuseTbl = NULL; + u8 rtemp8; u16 eFuse_Addr = 0; - u8 offset, wren; + u8 offset, wren; u16 i, j; u16 **eFuseWord = NULL; u16 efuse_utilized = 0; - u8 u1temp = 0; + u8 u1temp = 0; - efuseTbl = (u8*)rtw_zmalloc(EFUSE_MAP_LEN_88E); + efuseTbl = (u8 *)rtw_zmalloc(EFUSE_MAP_LEN_88E); if (efuseTbl == NULL) { DBG_88E("%s: alloc efuseTbl fail!\n", __func__); goto exit; } - eFuseWord= (u16 **)rtw_malloc2d(EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16)); + eFuseWord = (u16 **)rtw_malloc2d(EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16)); if (eFuseWord == NULL) { DBG_88E("%s: alloc eFuseWord fail!\n", __func__); goto exit; @@ -123,7 +120,7 @@ efuse_phymap_to_logical(u8 * phymap, u16 _offset, u16 _size_byte, u8 *pbuf) efuse_utilized++; eFuse_Addr++; } else { - DBG_88E("EFUSE is empty efuse_Addr-%d efuse_data=%x\n", eFuse_Addr, rtemp8); + DBG_88E("EFUSE is empty efuse_Addr-%d efuse_data =%x\n", eFuse_Addr, rtemp8); goto exit; } @@ -132,8 +129,8 @@ efuse_phymap_to_logical(u8 * phymap, u16 _offset, u16 _size_byte, u8 *pbuf) /* */ while ((rtemp8 != 0xFF) && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) { /* Check PG header for section num. */ - if ((rtemp8 & 0x1F ) == 0x0F) { /* extended header */ - u1temp =( (rtemp8 & 0xE0) >> 5); + if ((rtemp8 & 0x1F) == 0x0F) { /* extended header */ + u1temp = ((rtemp8 & 0xE0) >> 5); rtemp8 = *(phymap+eFuse_Addr); if ((rtemp8 & 0x0F) == 0x0F) { eFuse_Addr++; @@ -154,7 +151,7 @@ efuse_phymap_to_logical(u8 * phymap, u16 _offset, u16 _size_byte, u8 *pbuf) if (offset < EFUSE_MAX_SECTION_88E) { /* Get word enable value from PG header */ - for (i=0; i> 8) & 0xff); + for (i = 0; i < EFUSE_MAX_SECTION_88E; i++) { + for (j = 0; j < EFUSE_MAX_WORD_UNIT; j++) { + efuseTbl[(i*8)+(j*2)] = (eFuseWord[i][j] & 0xff); + efuseTbl[(i*8)+((j*2)+1)] = ((eFuseWord[i][j] >> 8) & 0xff); } } /* */ /* 4. Copy from Efuse map to output pointer memory!!! */ /* */ - for (i=0; i<_size_byte; i++) + for (i = 0; i < _size_byte; i++) pbuf[i] = efuseTbl[_offset+i]; /* */ @@ -229,7 +226,7 @@ static void efuse_read_phymap_from_txpktbuf( u8 *pos = content; - if (bcnhead<0) /* if not valid */ + if (bcnhead < 0) /* if not valid */ bcnhead = rtw_read8(adapter, REG_TDECTRL+1); DBG_88E("%s bcnhead:%d\n", __func__, bcnhead); @@ -243,8 +240,8 @@ static void efuse_read_phymap_from_txpktbuf( rtw_write8(adapter, REG_TXPKTBUF_DBG, 0); start = rtw_get_current_time(); - while (!(reg_0x143=rtw_read8(adapter, REG_TXPKTBUF_DBG)) && - (passing_time=rtw_get_passing_time_ms(start))<1000) { + while (!(reg_0x143 = rtw_read8(adapter, REG_TXPKTBUF_DBG)) && + (passing_time = rtw_get_passing_time_ms(start)) < 1000) { DBG_88E("%s polling reg_0x143:0x%02x, reg_0x106:0x%02x\n", __func__, reg_0x143, rtw_read8(adapter, 0x106)); rtw_usleep_os(100); } @@ -252,7 +249,7 @@ static void efuse_read_phymap_from_txpktbuf( lo32 = rtw_read32(adapter, REG_PKTBUF_DBG_DATA_L); hi32 = rtw_read32(adapter, REG_PKTBUF_DBG_DATA_H); - if (i==0) { + if (i == 0) { u8 lenc[2]; u16 lenbak, aaabak; u16 aaa; @@ -264,27 +261,27 @@ static void efuse_read_phymap_from_txpktbuf( aaa = le16_to_cpup((__le16 *)&lo32); len = le16_to_cpu(*((__le16 *)&lo32)); - limit = (len-2=count+2)?2:limit-count); - count+= (limit>=count+2)?2:limit-count; - pos=content+count; + _rtw_memcpy(pos, ((u8 *)&lo32)+2, (limit >= count+2) ? 2 : limit-count); + count += (limit >= count+2) ? 2 : limit-count; + pos = content+count; } else { - _rtw_memcpy(pos, ((u8*)&lo32), (limit>=count+4)?4:limit-count); - count+=(limit>=count+4)?4:limit-count; - pos=content+count; + _rtw_memcpy(pos, ((u8 *)&lo32), (limit >= count+4) ? 4 : limit-count); + count += (limit >= count+4) ? 4 : limit-count; + pos = content+count; } - if (limit>count && len-2>count) { - _rtw_memcpy(pos, (u8*)&hi32, (limit>=count+4)?4:limit-count); - count+=(limit>=count+4)?4:limit-count; - pos=content+count; + if (limit > count && len-2 > count) { + _rtw_memcpy(pos, (u8 *)&hi32, (limit >= count+4) ? 4 : limit-count); + count += (limit >= count+4) ? 4 : limit-count; + pos = content+count; } - if (limit<=count || len-2<=count) + if (limit <= count || len-2 <= count) break; i++; } @@ -293,13 +290,7 @@ static void efuse_read_phymap_from_txpktbuf( *size = count; } -static s32 iol_read_efuse( - struct adapter * padapter, - u8 txpktbuf_bndy, - u16 offset, - u16 size_byte, - u8 *logical_map - ) +static s32 iol_read_efuse(struct adapter *padapter, u8 txpktbuf_bndy, u16 offset, u16 size_byte, u8 *logical_map) { s32 status = _FAIL; u8 reg_0x106 = 0; @@ -317,12 +308,12 @@ static s32 iol_read_efuse( return status; } -s32 rtl8188e_iol_efuse_patch(struct adapter * padapter) +s32 rtl8188e_iol_efuse_patch(struct adapter *padapter) { s32 result = _SUCCESS; - DBG_88E("==> %s\n",__func__); - if (rtw_IOL_applied(padapter)){ + DBG_88E("==> %s\n", __func__); + if (rtw_IOL_applied(padapter)) { iol_mode_enable(padapter, 1); result = iol_execute(padapter, CMD_READ_EFUSE_MAP); if (result == _SUCCESS) @@ -333,45 +324,38 @@ s32 rtl8188e_iol_efuse_patch(struct adapter * padapter) return result; } -static s32 iol_ioconfig( - struct adapter * padapter, - u8 iocfg_bndy - ) +static s32 iol_ioconfig(struct adapter *padapter, u8 iocfg_bndy) { s32 rst = _SUCCESS; rtw_write8(padapter, REG_TDECTRL+1, iocfg_bndy); rst = iol_execute(padapter, CMD_IOCONFIG); - return rst; } -static int rtl8188e_IOL_exec_cmds_sync(struct adapter *adapter, struct xmit_frame *xmit_frame, u32 max_wating_ms,u32 bndy_cnt) +static int rtl8188e_IOL_exec_cmds_sync(struct adapter *adapter, struct xmit_frame *xmit_frame, u32 max_wating_ms, u32 bndy_cnt) { - u32 start_time = rtw_get_current_time(); u32 passing_time_ms; - u8 polling_ret,i; + u8 polling_ret, i; int ret = _FAIL; + struct pkt_attrib *pattrib = &xmit_frame->attrib; if (rtw_IOL_append_END_cmd(xmit_frame) != _SUCCESS) goto exit; - { - struct pkt_attrib *pattrib = &xmit_frame->attrib; - if (rtw_usb_bulk_size_boundary(adapter,TXDESC_SIZE+pattrib->last_txcmdsz)) - { - if (rtw_IOL_append_END_cmd(xmit_frame) != _SUCCESS) - goto exit; - } + if (rtw_usb_bulk_size_boundary(adapter, TXDESC_SIZE+pattrib->last_txcmdsz)) { + if (rtw_IOL_append_END_cmd(xmit_frame) != _SUCCESS) + goto exit; } dump_mgntframe_and_wait(adapter, xmit_frame, max_wating_ms); iol_mode_enable(adapter, 1); - for (i=0;i _8051Reset88E(): 8051 reset success .\n"); } -static s32 _FWFreeToGo(struct adapter * padapter) +static s32 _FWFreeToGo(struct adapter *padapter) { u32 counter = 0; u32 value32; - u8 value8; + u8 value8; /* polling CheckSum report */ do { value32 = rtw_read32(padapter, REG_MCUFWDL); - if (value32 & FWDL_ChkSum_rpt) break; + if (value32 & FWDL_ChkSum_rpt) + break; } while (counter++ < POLLING_READY_TIMEOUT_COUNT); if (counter >= POLLING_READY_TIMEOUT_COUNT) { @@ -615,7 +599,7 @@ static s32 _FWFreeToGo(struct adapter * padapter) rtw_udelay_os(5); } while (counter++ < POLLING_READY_TIMEOUT_COUNT); - DBG_88E ("%s: Polling FW ready fail!! REG_MCUFWDL:0x%08x\n", __func__, value32); + DBG_88E("%s: Polling FW ready fail!! REG_MCUFWDL:0x%08x\n", __func__, value32); return _FAIL; } @@ -623,13 +607,13 @@ static s32 _FWFreeToGo(struct adapter * padapter) #ifdef CONFIG_WOWLAN /* */ -/* Description: */ -/* Download 8192C firmware code. */ +/* Description: */ +/* Download 8192C firmware code. */ /* */ /* */ -s32 rtl8188e_FirmwareDownload(struct adapter * padapter, bool bUsedWoWLANFw) +s32 rtl8188e_FirmwareDownload(struct adapter *padapter, bool bUsedWoWLANFw) #else -s32 rtl8188e_FirmwareDownload(struct adapter * padapter) +s32 rtl8188e_FirmwareDownload(struct adapter *padapter) #endif { s32 rtStatus = _SUCCESS; @@ -637,59 +621,55 @@ s32 rtl8188e_FirmwareDownload(struct adapter * padapter) u32 fwdl_start_time; struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); - u8 *FwImage; + u8 *FwImage; u32 FwImageLen; - u8 *pFwImageFileName; + u8 *pFwImageFileName; #ifdef CONFIG_WOWLAN - u8 *FwImageWoWLAN; + u8 *FwImageWoWLAN; u32 FwImageWoWLANLen; #endif - u8 *pucMappedFile = NULL; + u8 *pucMappedFile = NULL; struct rt_firmware *pFirmware = NULL; struct rt_firmware_hdr *pFwHdr = NULL; - u8 *pFirmwareBuf; + u8 *pFirmwareBuf; u32 FirmwareLen; - RT_TRACE(_module_hal_init_c_, _drv_info_, ("+%s\n", __func__)); pFirmware = (struct rt_firmware *)rtw_zmalloc(sizeof(struct rt_firmware)); - if (!pFirmware) - { - + if (!pFirmware) { rtStatus = _FAIL; goto Exit; } - FwImage = (u8*)Rtl8188E_FwImageArray; + FwImage = (u8 *)Rtl8188E_FwImageArray; FwImageLen = Rtl8188E_FWImgArrayLength; #ifdef CONFIG_WOWLAN - FwImageWoWLAN = (u8*)Rtl8188E_FwWoWImageArray; + FwImageWoWLAN = (u8 *)Rtl8188E_FwWoWImageArray; FwImageWoWLANLen = Rtl8188E_FwWoWImgArrayLength; #endif /* CONFIG_WOWLAN */ - pFirmware->eFWSource = FW_SOURCE_HEADER_FILE; switch (pFirmware->eFWSource) { - case FW_SOURCE_IMG_FILE: - break; - case FW_SOURCE_HEADER_FILE: - if (FwImageLen > FW_8188E_SIZE) { - rtStatus = _FAIL; - RT_TRACE(_module_hal_init_c_, _drv_err_, ("Firmware size exceed 0x%X. Check it.\n", FW_8188E_SIZE) ); - goto Exit; - } + case FW_SOURCE_IMG_FILE: + break; + case FW_SOURCE_HEADER_FILE: + if (FwImageLen > FW_8188E_SIZE) { + rtStatus = _FAIL; + RT_TRACE(_module_hal_init_c_, _drv_err_, ("Firmware size exceed 0x%X. Check it.\n", FW_8188E_SIZE)); + goto Exit; + } - pFirmware->szFwBuffer = FwImage; - pFirmware->ulFwLength = FwImageLen; + pFirmware->szFwBuffer = FwImage; + pFirmware->ulFwLength = FwImageLen; #ifdef CONFIG_WOWLAN - if (bUsedWoWLANFw){ - pFirmware->szWoWLANFwBuffer = FwImageWoWLAN; - pFirmware->ulWoWLANFwLength = FwImageWoWLANLen; - } + if (bUsedWoWLANFw) { + pFirmware->szWoWLANFwBuffer = FwImageWoWLAN; + pFirmware->ulWoWLANFwLength = FwImageWoWLANLen; + } #endif /* CONFIG_WOWLAN */ - break; + break; } #ifdef CONFIG_WOWLAN if (bUsedWoWLANFw) { @@ -711,11 +691,10 @@ s32 rtl8188e_FirmwareDownload(struct adapter * padapter) pHalData->FirmwareSubVersion = pFwHdr->Subversion; pHalData->FirmwareSignature = le16_to_cpu(pFwHdr->Signature); - DBG_88E ("%s: fw_ver=%d fw_subver=%d sig=0x%x\n", - __func__, pHalData->FirmwareVersion, pHalData->FirmwareSubVersion, pHalData->FirmwareSignature); + DBG_88E("%s: fw_ver =%d fw_subver =%d sig = 0x%x\n", + __func__, pHalData->FirmwareVersion, pHalData->FirmwareSubVersion, pHalData->FirmwareSignature); - if (IS_FW_HEADER_EXIST(pFwHdr)) - { + if (IS_FW_HEADER_EXIST(pFwHdr)) { /* Shift 32 bytes for FW header */ pFirmwareBuf = pFirmwareBuf + 32; FirmwareLen = FirmwareLen - 32; @@ -723,8 +702,7 @@ s32 rtl8188e_FirmwareDownload(struct adapter * padapter) /* Suggested by Filen. If 8051 is running in RAM code, driver should inform Fw to reset by itself, */ /* or it will cause download Fw fail. 2010.02.01. by tynli. */ - if (rtw_read8(padapter, REG_MCUFWDL) & RAM_DL_SEL) /* 8051 RAM code */ - { + if (rtw_read8(padapter, REG_MCUFWDL) & RAM_DL_SEL) { /* 8051 RAM code */ rtw_write8(padapter, REG_MCUFWDL, 0x00); _8051Reset88E(padapter); } @@ -733,22 +711,20 @@ s32 rtl8188e_FirmwareDownload(struct adapter * padapter) fwdl_start_time = rtw_get_current_time(); while (1) { /* reset the FWDL chksum */ - rtw_write8(padapter, REG_MCUFWDL, rtw_read8(padapter, REG_MCUFWDL)|FWDL_ChkSum_rpt); + rtw_write8(padapter, REG_MCUFWDL, rtw_read8(padapter, REG_MCUFWDL) | FWDL_ChkSum_rpt); rtStatus = _WriteFW(padapter, pFirmwareBuf, FirmwareLen); - if (rtStatus == _SUCCESS - ||(rtw_get_passing_time_ms(fwdl_start_time) > 500 && writeFW_retry++ >= 3) - ) + if (rtStatus == _SUCCESS || + (rtw_get_passing_time_ms(fwdl_start_time) > 500 && writeFW_retry++ >= 3)) break; - DBG_88E("%s writeFW_retry:%u, time after fwdl_start_time:%ums\n", __func__ - , writeFW_retry - , rtw_get_passing_time_ms(fwdl_start_time) + DBG_88E("%s writeFW_retry:%u, time after fwdl_start_time:%ums\n", + __func__, writeFW_retry, rtw_get_passing_time_ms(fwdl_start_time) ); } _FWDownloadEnable(padapter, false); - if (_SUCCESS != rtStatus){ + if (_SUCCESS != rtStatus) { DBG_88E("DL Firmware failed!\n"); goto Exit; } @@ -763,22 +739,22 @@ s32 rtl8188e_FirmwareDownload(struct adapter * padapter) Exit: if (pFirmware) - rtw_mfree((u8*)pFirmware, sizeof(struct rt_firmware)); + rtw_mfree((u8 *)pFirmware, sizeof(struct rt_firmware)); #ifdef CONFIG_WOWLAN if (padapter->pwrctrlpriv.wowlan_mode) rtl8188e_InitializeFirmwareVars(padapter); else DBG_88E_LEVEL(_drv_always_, "%s: wowland_mode:%d wowlan_wake_reason:%d\n", - __func__, padapter->pwrctrlpriv.wowlan_mode, - padapter->pwrctrlpriv.wowlan_wake_reason); + __func__, padapter->pwrctrlpriv.wowlan_mode, + padapter->pwrctrlpriv.wowlan_wake_reason); #endif return rtStatus; } #ifdef CONFIG_WOWLAN -void rtl8188e_InitializeFirmwareVars(struct adapter * padapter) +void rtl8188e_InitializeFirmwareVars(struct adapter *padapter) { struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); struct pwrctrl_priv *pwrpriv; @@ -794,21 +770,21 @@ void rtl8188e_InitializeFirmwareVars(struct adapter * padapter) /* */ /* Description: Prepare some information to Fw for WoWLAN. */ -/* (1) Download wowlan Fw. */ -/* (2) Download RSVD page packets. */ -/* (3) Enable AP offload if needed. */ +/* (1) Download wowlan Fw. */ +/* (2) Download RSVD page packets. */ +/* (3) Enable AP offload if needed. */ /* */ /* 2011.04.12 by tynli. */ /* */ void SetFwRelatedForWoWLAN8188ES( - struct adapter * padapter, - u8 bHostIsGoingtoSleep + struct adapter *padapter, + u8 bHostIsGoingtoSleep ) { - int status=_FAIL; + int status = _FAIL; struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); - u8 bRecover = false; + u8 bRecover = false; /* */ /* 1. Before WoWLAN we need to re-download WoWLAN Fw. */ /* */ @@ -825,7 +801,7 @@ SetFwRelatedForWoWLAN8188ES( rtl8188e_InitializeFirmwareVars(padapter); } #else -void rtl8188e_InitializeFirmwareVars(struct adapter * padapter) +void rtl8188e_InitializeFirmwareVars(struct adapter *padapter) { struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); @@ -837,7 +813,7 @@ void rtl8188e_InitializeFirmwareVars(struct adapter * padapter) } #endif /* CONFIG_WOWLAN */ -static void rtl8188e_free_hal_data(struct adapter * padapter) +static void rtl8188e_free_hal_data(struct adapter *padapter) { _func_enter_; if (padapter->HalData) { @@ -848,7 +824,7 @@ _func_exit_; } /* */ -/* Efuse related code */ +/* Efuse related code */ /* */ enum{ VOLTAGE_V25 = 0x03, @@ -857,73 +833,69 @@ enum{ static bool hal_EfusePgPacketWrite2ByteHeader( - struct adapter * pAdapter, - u8 efuseType, + struct adapter *pAdapter, + u8 efuseType, u16 *pAddr, struct pgpkt *pTargetPkt, - bool bPseudoTest); + bool bPseudoTest); static bool hal_EfusePgPacketWrite1ByteHeader( - struct adapter * pAdapter, - u8 efuseType, + struct adapter *pAdapter, + u8 efuseType, u16 *pAddr, struct pgpkt *pTargetPkt, - bool bPseudoTest); + bool bPseudoTest); static bool hal_EfusePgPacketWriteData( - struct adapter * pAdapter, - u8 efuseType, + struct adapter *pAdapter, + u8 efuseType, u16 *pAddr, struct pgpkt *pTargetPkt, - bool bPseudoTest); + bool bPseudoTest); static void hal_EfusePowerSwitch_RTL8188E( - struct adapter * pAdapter, - u8 bWrite, - u8 PwrState) + struct adapter *pAdapter, + u8 bWrite, + u8 PwrState) { - u8 tempval; + u8 tempval; u16 tmpV16; - if (PwrState == true) - { + if (PwrState) { rtw_write8(pAdapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_ON); /* 1.2V Power: From VDDON with Power Cut(0x0000h[15]), defualt valid */ - tmpV16 = rtw_read16(pAdapter,REG_SYS_ISO_CTRL); - if ( ! (tmpV16 & PWC_EV12V ) ){ - tmpV16 |= PWC_EV12V ; - rtw_write16(pAdapter,REG_SYS_ISO_CTRL,tmpV16); + tmpV16 = rtw_read16(pAdapter, REG_SYS_ISO_CTRL); + if (!(tmpV16 & PWC_EV12V)) { + tmpV16 |= PWC_EV12V; + rtw_write16(pAdapter, REG_SYS_ISO_CTRL, tmpV16); } /* Reset: 0x0000h[28], default valid */ - tmpV16 = rtw_read16(pAdapter,REG_SYS_FUNC_EN); - if ( !(tmpV16 & FEN_ELDR) ){ - tmpV16 |= FEN_ELDR ; - rtw_write16(pAdapter,REG_SYS_FUNC_EN,tmpV16); + tmpV16 = rtw_read16(pAdapter, REG_SYS_FUNC_EN); + if (!(tmpV16 & FEN_ELDR)) { + tmpV16 |= FEN_ELDR; + rtw_write16(pAdapter, REG_SYS_FUNC_EN, tmpV16); } /* Clock: Gated(0x0008h[5]) 8M(0x0008h[1]) clock from ANA, default valid */ - tmpV16 = rtw_read16(pAdapter,REG_SYS_CLKR); - if ( (!(tmpV16 & LOADER_CLK_EN) ) ||(!(tmpV16 & ANA8M) ) ){ - tmpV16 |= (LOADER_CLK_EN |ANA8M ) ; - rtw_write16(pAdapter,REG_SYS_CLKR,tmpV16); + tmpV16 = rtw_read16(pAdapter, REG_SYS_CLKR); + if ((!(tmpV16 & LOADER_CLK_EN)) || (!(tmpV16 & ANA8M))) { + tmpV16 |= (LOADER_CLK_EN | ANA8M); + rtw_write16(pAdapter, REG_SYS_CLKR, tmpV16); } - if (bWrite == true) - { + if (bWrite) { /* Enable LDO 2.5V before read/write action */ tempval = rtw_read8(pAdapter, EFUSE_TEST+3); tempval &= 0x0F; tempval |= (VOLTAGE_V25 << 4); rtw_write8(pAdapter, EFUSE_TEST+3, (tempval | 0x80)); } - } - else - { + } else { rtw_write8(pAdapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_OFF); - if (bWrite == true){ + if (bWrite) { /* Disable LDO 2.5V after read/write action */ tempval = rtw_read8(pAdapter, EFUSE_TEST+3); rtw_write8(pAdapter, EFUSE_TEST+3, (tempval & 0x7F)); @@ -933,18 +905,17 @@ hal_EfusePowerSwitch_RTL8188E( static void rtl8188e_EfusePowerSwitch( - struct adapter * pAdapter, - u8 bWrite, - u8 PwrState) + struct adapter *pAdapter, + u8 bWrite, + u8 PwrState) { hal_EfusePowerSwitch_RTL8188E(pAdapter, bWrite, PwrState); } - static bool efuse_read_phymap( - struct adapter * Adapter, - u8 *pbuf, /* buffer to store efuse physical map */ + struct adapter *Adapter, + u8 *pbuf, /* buffer to store efuse physical map */ u16 *size /* the max byte to read. will update to byte read */ ) { @@ -958,68 +929,57 @@ static bool efuse_read_phymap( /* */ _rtw_memset(pbuf, 0xFF, limit); - /* */ /* Read physical efuse content. */ /* */ - while (addr < limit) - { + while (addr < limit) { ReadEFuseByte(Adapter, addr, pos, false); - if (*pos != 0xFF) - { + if (*pos != 0xFF) { pos++; addr++; - } - else - { + } else { reach_end = true; break; } } - *size = addr; - return reach_end; - } static void Hal_EfuseReadEFuse88E( - struct adapter * Adapter, + struct adapter *Adapter, u16 _offset, u16 _size_byte, - u8 *pbuf, - bool bPseudoTest + u8 *pbuf, + bool bPseudoTest ) { - u8 *efuseTbl = NULL; - u8 rtemp8[1]; + u8 *efuseTbl = NULL; + u8 rtemp8[1]; u16 eFuse_Addr = 0; - u8 offset, wren; + u8 offset, wren; u16 i, j; u16 **eFuseWord = NULL; u16 efuse_utilized = 0; - u8 u1temp = 0; + u8 u1temp = 0; /* */ /* Do NOT excess total size of EFuse table. Added by Roger, 2008.11.10. */ /* */ - if ((_offset + _size_byte)>EFUSE_MAP_LEN_88E) - {/* total E-Fuse table is 512bytes */ - DBG_88E("Hal_EfuseReadEFuse88E(): Invalid offset(%#x) with read bytes(%#x)!!\n",_offset, _size_byte); + if ((_offset + _size_byte) > EFUSE_MAP_LEN_88E) {/* total E-Fuse table is 512bytes */ + DBG_88E("Hal_EfuseReadEFuse88E(): Invalid offset(%#x) with read bytes(%#x)!!\n", _offset, _size_byte); goto exit; } - efuseTbl = (u8*)rtw_zmalloc(EFUSE_MAP_LEN_88E); - if (efuseTbl == NULL) - { + efuseTbl = (u8 *)rtw_zmalloc(EFUSE_MAP_LEN_88E); + if (efuseTbl == NULL) { DBG_88E("%s: alloc efuseTbl fail!\n", __func__); goto exit; } - eFuseWord= (u16 **)rtw_malloc2d(EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16)); - if (eFuseWord == NULL) - { + eFuseWord = (u16 **)rtw_malloc2d(EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16)); + if (eFuseWord == NULL) { DBG_88E("%s: alloc eFuseWord fail!\n", __func__); goto exit; } @@ -1034,124 +994,86 @@ Hal_EfuseReadEFuse88E( /* */ /* */ ReadEFuseByte(Adapter, eFuse_Addr, rtemp8, bPseudoTest); - if (*rtemp8 != 0xFF) - { + if (*rtemp8 != 0xFF) { efuse_utilized++; eFuse_Addr++; - } - else - { - DBG_88E("EFUSE is empty efuse_Addr-%d efuse_data=%x\n", eFuse_Addr, *rtemp8); + } else { + DBG_88E("EFUSE is empty efuse_Addr-%d efuse_data =%x\n", eFuse_Addr, *rtemp8); goto exit; } - /* */ /* 2. Read real efuse content. Filter PG header and every section data. */ /* */ - while ((*rtemp8 != 0xFF) && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) - { - + while ((*rtemp8 != 0xFF) && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) { /* Check PG header for section num. */ - if ((*rtemp8 & 0x1F ) == 0x0F) /* extended header */ - { - u1temp =( (*rtemp8 & 0xE0) >> 5); - + if ((*rtemp8 & 0x1F) == 0x0F) { /* extended header */ + u1temp = ((*rtemp8 & 0xE0) >> 5); ReadEFuseByte(Adapter, eFuse_Addr, rtemp8, bPseudoTest); - - if ((*rtemp8 & 0x0F) == 0x0F) - { + if ((*rtemp8 & 0x0F) == 0x0F) { eFuse_Addr++; ReadEFuseByte(Adapter, eFuse_Addr, rtemp8, bPseudoTest); if (*rtemp8 != 0xFF && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) - { eFuse_Addr++; - } continue; - } - else - { + } else { offset = ((*rtemp8 & 0xF0) >> 1) | u1temp; wren = (*rtemp8 & 0x0F); eFuse_Addr++; } - } - else - { + } else { offset = ((*rtemp8 >> 4) & 0x0f); wren = (*rtemp8 & 0x0f); } - if (offset < EFUSE_MAX_SECTION_88E) - { + if (offset < EFUSE_MAX_SECTION_88E) { /* Get word enable value from PG header */ - for (i=0; i= EFUSE_REAL_CONTENT_LEN_88E) break; - ReadEFuseByte(Adapter, eFuse_Addr, rtemp8, bPseudoTest); eFuse_Addr++; - efuse_utilized++; eFuseWord[offset][i] |= (((u2Byte)*rtemp8 << 8) & 0xff00); - if (eFuse_Addr >= EFUSE_REAL_CONTENT_LEN_88E) break; } - wren >>= 1; - } } /* Read next PG header */ ReadEFuseByte(Adapter, eFuse_Addr, rtemp8, bPseudoTest); - if (*rtemp8 != 0xFF && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) - { + if (*rtemp8 != 0xFF && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) { efuse_utilized++; eFuse_Addr++; } } - /* */ /* 3. Collect 16 sections and 4 word unit into Efuse map. */ - /* */ - for (i=0; i> 8) & 0xff); + for (i = 0; i < EFUSE_MAX_SECTION_88E; i++) { + for (j = 0; j < EFUSE_MAX_WORD_UNIT; j++) { + efuseTbl[(i*8)+(j*2)] = (eFuseWord[i][j] & 0xff); + efuseTbl[(i*8)+((j*2)+1)] = ((eFuseWord[i][j] >> 8) & 0xff); } } - - /* */ /* 4. Copy from Efuse map to output pointer memory!!! */ - /* */ - for (i=0; i<_size_byte; i++) - { + for (i = 0; i < _size_byte; i++) pbuf[i] = efuseTbl[_offset+i]; - } - /* */ /* 5. Calculate Efuse utilization. */ - /* */ rtw_hal_set_hwreg(Adapter, HW_VAR_EFUSE_BYTES, (u8 *)&eFuse_Addr); exit: @@ -1162,31 +1084,20 @@ exit: rtw_mfree2d((void *)eFuseWord, EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16)); } - -static bool -Hal_EfuseSwitchToBank( - struct adapter * pAdapter, - u8 bank, - bool bPseudoTest - ) +static bool Hal_EfuseSwitchToBank(struct adapter *pAdapter, u8 bank, bool bPseudoTest) { - bool bRet = false; - u32 value32=0; + bool bRet = false; + u32 value32 = 0; - if (bPseudoTest) - { + if (bPseudoTest) { fakeEfuseBank = bank; bRet = true; - } - else - { + } else { if (IS_HARDWARE_TYPE_8723A(pAdapter) && - INCLUDE_MULTI_FUNC_BT(pAdapter)) - { + INCLUDE_MULTI_FUNC_BT(pAdapter)) { value32 = rtw_read32(pAdapter, EFUSE_TEST); bRet = true; - switch (bank) - { + switch (bank) { case 0: value32 = (value32 & ~EFUSE_SEL_MASK) | EFUSE_SEL(EFUSE_WIFI_SEL_0); break; @@ -1205,22 +1116,18 @@ Hal_EfuseSwitchToBank( break; } rtw_write32(pAdapter, EFUSE_TEST, value32); - } - else + } else { bRet = true; + } } return bRet; } - - -static void ReadEFuseByIC(struct adapter * Adapter, u8 efuseType, u16 _offset, u16 _size_byte, u8 *pbuf, bool bPseudoTest) +static void ReadEFuseByIC(struct adapter *Adapter, u8 efuseType, u16 _offset, u16 _size_byte, u8 *pbuf, bool bPseudoTest) { - if (!bPseudoTest )/* rtw_IOL_applied(Adapter)) */ - { + if (!bPseudoTest) { int ret = _FAIL; - if (rtw_IOL_applied(Adapter)) - { + if (rtw_IOL_applied(Adapter)) { rtw_hal_power_on(Adapter); iol_mode_enable(Adapter, 1); @@ -1237,639 +1144,457 @@ exit: return; } -static void -ReadEFuse_Pseudo ( - struct adapter * Adapter, - u8 efuseType, - u16 _offset, - u16 _size_byte, - u8 *pbuf, - bool bPseudoTest - ) +static void ReadEFuse_Pseudo(struct adapter *Adapter, u8 efuseType, u16 _offset, u16 _size_byte, u8 *pbuf, bool bPseudoTest) { Hal_EfuseReadEFuse88E(Adapter, _offset, _size_byte, pbuf, bPseudoTest); } -static void -rtl8188e_ReadEFuse( - struct adapter * Adapter, - u8 efuseType, - u16 _offset, - u16 _size_byte, - u8 *pbuf, - bool bPseudoTest - ) +static void rtl8188e_ReadEFuse(struct adapter *Adapter, u8 efuseType, + u16 _offset, u16 _size_byte, u8 *pbuf, + bool bPseudoTest) { if (bPseudoTest) - { ReadEFuse_Pseudo (Adapter, efuseType, _offset, _size_byte, pbuf, bPseudoTest); - } else - { ReadEFuseByIC(Adapter, efuseType, _offset, _size_byte, pbuf, bPseudoTest); - } } /* Do not support BT */ -static void -Hal_EFUSEGetEfuseDefinition88E( - struct adapter * pAdapter, - u1Byte efuseType, - u1Byte type, - void * pOut - ) +static void Hal_EFUSEGetEfuseDefinition88E(struct adapter *pAdapter, u1Byte efuseType, u1Byte type, void *pOut) { - switch (type) - { - case TYPE_EFUSE_MAX_SECTION: - { - u8* pMax_section; - pMax_section = (u8*)pOut; - *pMax_section = EFUSE_MAX_SECTION_88E; - } - break; - case TYPE_EFUSE_REAL_CONTENT_LEN: - { - u16* pu2Tmp; - pu2Tmp = (u16*)pOut; - *pu2Tmp = EFUSE_REAL_CONTENT_LEN_88E; - } - break; - case TYPE_EFUSE_CONTENT_LEN_BANK: - { - u16* pu2Tmp; - pu2Tmp = (u16*)pOut; - *pu2Tmp = EFUSE_REAL_CONTENT_LEN_88E; - } - break; - case TYPE_AVAILABLE_EFUSE_BYTES_BANK: - { - u16* pu2Tmp; - pu2Tmp = (u16*)pOut; - *pu2Tmp = (u16)(EFUSE_REAL_CONTENT_LEN_88E-EFUSE_OOB_PROTECT_BYTES_88E); - } - break; - case TYPE_AVAILABLE_EFUSE_BYTES_TOTAL: - { - u16* pu2Tmp; - pu2Tmp = (u16*)pOut; - *pu2Tmp = (u16)(EFUSE_REAL_CONTENT_LEN_88E-EFUSE_OOB_PROTECT_BYTES_88E); - } - break; - case TYPE_EFUSE_MAP_LEN: - { - u16* pu2Tmp; - pu2Tmp = (u16*)pOut; - *pu2Tmp = (u16)EFUSE_MAP_LEN_88E; - } - break; - case TYPE_EFUSE_PROTECT_BYTES_BANK: - { - u8* pu1Tmp; - pu1Tmp = (u8*)pOut; - *pu1Tmp = (u8)(EFUSE_OOB_PROTECT_BYTES_88E); - } - break; - default: - { - u8* pu1Tmp; - pu1Tmp = (u8*)pOut; - *pu1Tmp = 0; - } - break; + switch (type) { + case TYPE_EFUSE_MAX_SECTION: + { + u8 *pMax_section; + pMax_section = (u8 *)pOut; + *pMax_section = EFUSE_MAX_SECTION_88E; + } + break; + case TYPE_EFUSE_REAL_CONTENT_LEN: + { + u16 *pu2Tmp; + pu2Tmp = (u16 *)pOut; + *pu2Tmp = EFUSE_REAL_CONTENT_LEN_88E; + } + break; + case TYPE_EFUSE_CONTENT_LEN_BANK: + { + u16 *pu2Tmp; + pu2Tmp = (u16 *)pOut; + *pu2Tmp = EFUSE_REAL_CONTENT_LEN_88E; + } + break; + case TYPE_AVAILABLE_EFUSE_BYTES_BANK: + { + u16 *pu2Tmp; + pu2Tmp = (u16 *)pOut; + *pu2Tmp = (u16)(EFUSE_REAL_CONTENT_LEN_88E-EFUSE_OOB_PROTECT_BYTES_88E); + } + break; + case TYPE_AVAILABLE_EFUSE_BYTES_TOTAL: + { + u16 *pu2Tmp; + pu2Tmp = (u16 *)pOut; + *pu2Tmp = (u16)(EFUSE_REAL_CONTENT_LEN_88E-EFUSE_OOB_PROTECT_BYTES_88E); + } + break; + case TYPE_EFUSE_MAP_LEN: + { + u16 *pu2Tmp; + pu2Tmp = (u16 *)pOut; + *pu2Tmp = (u16)EFUSE_MAP_LEN_88E; + } + break; + case TYPE_EFUSE_PROTECT_BYTES_BANK: + { + u8 *pu1Tmp; + pu1Tmp = (u8 *)pOut; + *pu1Tmp = (u8)(EFUSE_OOB_PROTECT_BYTES_88E); + } + break; + default: + { + u8 *pu1Tmp; + pu1Tmp = (u8 *)pOut; + *pu1Tmp = 0; + } + break; } } -static void Hal_EFUSEGetEfuseDefinition_Pseudo88E( - struct adapter * pAdapter, - u8 efuseType, - u8 type, - void * pOut - ) +static void Hal_EFUSEGetEfuseDefinition_Pseudo88E(struct adapter *pAdapter, u8 efuseType, u8 type, void *pOut) { - switch (type) - { - case TYPE_EFUSE_MAX_SECTION: - { - u8* pMax_section; - pMax_section = (pu1Byte)pOut; - *pMax_section = EFUSE_MAX_SECTION_88E; - } - break; - case TYPE_EFUSE_REAL_CONTENT_LEN: - { - u16* pu2Tmp; - pu2Tmp = (pu2Byte)pOut; - *pu2Tmp = EFUSE_REAL_CONTENT_LEN_88E; - } - break; - case TYPE_EFUSE_CONTENT_LEN_BANK: - { - u16* pu2Tmp; - pu2Tmp = (pu2Byte)pOut; - *pu2Tmp = EFUSE_REAL_CONTENT_LEN_88E; - } - break; - case TYPE_AVAILABLE_EFUSE_BYTES_BANK: - { - u16* pu2Tmp; - pu2Tmp = (pu2Byte)pOut; - *pu2Tmp = (u2Byte)(EFUSE_REAL_CONTENT_LEN_88E-EFUSE_OOB_PROTECT_BYTES_88E); - } - break; - case TYPE_AVAILABLE_EFUSE_BYTES_TOTAL: - { - u16* pu2Tmp; - pu2Tmp = (pu2Byte)pOut; - *pu2Tmp = (u2Byte)(EFUSE_REAL_CONTENT_LEN_88E-EFUSE_OOB_PROTECT_BYTES_88E); - } - break; - case TYPE_EFUSE_MAP_LEN: - { - u16* pu2Tmp; - pu2Tmp = (pu2Byte)pOut; - *pu2Tmp = (u2Byte)EFUSE_MAP_LEN_88E; - } - break; - case TYPE_EFUSE_PROTECT_BYTES_BANK: - { - u8* pu1Tmp; - pu1Tmp = (u8*)pOut; - *pu1Tmp = (u8)(EFUSE_OOB_PROTECT_BYTES_88E); - } - break; - default: - { - u8* pu1Tmp; - pu1Tmp = (u8*)pOut; - *pu1Tmp = 0; - } - break; + switch (type) { + case TYPE_EFUSE_MAX_SECTION: + { + u8 *pMax_section; + pMax_section = (pu1Byte)pOut; + *pMax_section = EFUSE_MAX_SECTION_88E; + } + break; + case TYPE_EFUSE_REAL_CONTENT_LEN: + { + u16 *pu2Tmp; + pu2Tmp = (pu2Byte)pOut; + *pu2Tmp = EFUSE_REAL_CONTENT_LEN_88E; + } + break; + case TYPE_EFUSE_CONTENT_LEN_BANK: + { + u16 *pu2Tmp; + pu2Tmp = (pu2Byte)pOut; + *pu2Tmp = EFUSE_REAL_CONTENT_LEN_88E; + } + break; + case TYPE_AVAILABLE_EFUSE_BYTES_BANK: + { + u16 *pu2Tmp; + pu2Tmp = (pu2Byte)pOut; + *pu2Tmp = (u2Byte)(EFUSE_REAL_CONTENT_LEN_88E-EFUSE_OOB_PROTECT_BYTES_88E); + } + break; + case TYPE_AVAILABLE_EFUSE_BYTES_TOTAL: + { + u16 *pu2Tmp; + pu2Tmp = (pu2Byte)pOut; + *pu2Tmp = (u2Byte)(EFUSE_REAL_CONTENT_LEN_88E-EFUSE_OOB_PROTECT_BYTES_88E); + } + break; + case TYPE_EFUSE_MAP_LEN: + { + u16 *pu2Tmp; + pu2Tmp = (pu2Byte)pOut; + *pu2Tmp = (u2Byte)EFUSE_MAP_LEN_88E; + } + break; + case TYPE_EFUSE_PROTECT_BYTES_BANK: + { + u8 *pu1Tmp; + pu1Tmp = (u8 *)pOut; + *pu1Tmp = (u8)(EFUSE_OOB_PROTECT_BYTES_88E); + } + break; + default: + { + u8 *pu1Tmp; + pu1Tmp = (u8 *)pOut; + *pu1Tmp = 0; + } + break; } } - -static void -rtl8188e_EFUSE_GetEfuseDefinition( - struct adapter * pAdapter, - u8 efuseType, - u8 type, - void *pOut, - bool bPseudoTest - ) +static void rtl8188e_EFUSE_GetEfuseDefinition(struct adapter *pAdapter, u8 efuseType, u8 type, void *pOut, bool bPseudoTest) { if (bPseudoTest) - { Hal_EFUSEGetEfuseDefinition_Pseudo88E(pAdapter, efuseType, type, pOut); - } else - { Hal_EFUSEGetEfuseDefinition88E(pAdapter, efuseType, type, pOut); - } } -static u8 -Hal_EfuseWordEnableDataWrite( struct adapter * pAdapter, - u16 efuse_addr, - u8 word_en, - u8 *data, - bool bPseudoTest) +static u8 Hal_EfuseWordEnableDataWrite(struct adapter *pAdapter, u16 efuse_addr, u8 word_en, u8 *data, bool bPseudoTest) { u16 tmpaddr = 0; u16 start_addr = efuse_addr; - u8 badworden = 0x0F; - u8 tmpdata[8]; + u8 badworden = 0x0F; + u8 tmpdata[8]; _rtw_memset((void *)tmpdata, 0xff, PGPKT_DATA_SIZE); - if (!(word_en&BIT0)) - { + if (!(word_en&BIT0)) { tmpaddr = start_addr; - efuse_OneByteWrite(pAdapter,start_addr++, data[0], bPseudoTest); - efuse_OneByteWrite(pAdapter,start_addr++, data[1], bPseudoTest); + efuse_OneByteWrite(pAdapter, start_addr++, data[0], bPseudoTest); + efuse_OneByteWrite(pAdapter, start_addr++, data[1], bPseudoTest); - efuse_OneByteRead(pAdapter,tmpaddr, &tmpdata[0], bPseudoTest); - efuse_OneByteRead(pAdapter,tmpaddr+1, &tmpdata[1], bPseudoTest); - if ((data[0]!=tmpdata[0])||(data[1]!=tmpdata[1])){ + efuse_OneByteRead(pAdapter, tmpaddr, &tmpdata[0], bPseudoTest); + efuse_OneByteRead(pAdapter, tmpaddr+1, &tmpdata[1], bPseudoTest); + if ((data[0] != tmpdata[0]) || (data[1] != tmpdata[1])) badworden &= (~BIT0); - } } - if (!(word_en&BIT1)) - { + if (!(word_en&BIT1)) { tmpaddr = start_addr; - efuse_OneByteWrite(pAdapter,start_addr++, data[2], bPseudoTest); - efuse_OneByteWrite(pAdapter,start_addr++, data[3], bPseudoTest); + efuse_OneByteWrite(pAdapter, start_addr++, data[2], bPseudoTest); + efuse_OneByteWrite(pAdapter, start_addr++, data[3], bPseudoTest); - efuse_OneByteRead(pAdapter,tmpaddr , &tmpdata[2], bPseudoTest); - efuse_OneByteRead(pAdapter,tmpaddr+1, &tmpdata[3], bPseudoTest); - if ((data[2]!=tmpdata[2])||(data[3]!=tmpdata[3])){ - badworden &=( ~BIT1); - } + efuse_OneByteRead(pAdapter, tmpaddr , &tmpdata[2], bPseudoTest); + efuse_OneByteRead(pAdapter, tmpaddr+1, &tmpdata[3], bPseudoTest); + if ((data[2] != tmpdata[2]) || (data[3] != tmpdata[3])) + badworden &= (~BIT1); } - if (!(word_en&BIT2)) - { + if (!(word_en&BIT2)) { tmpaddr = start_addr; - efuse_OneByteWrite(pAdapter,start_addr++, data[4], bPseudoTest); - efuse_OneByteWrite(pAdapter,start_addr++, data[5], bPseudoTest); + efuse_OneByteWrite(pAdapter, start_addr++, data[4], bPseudoTest); + efuse_OneByteWrite(pAdapter, start_addr++, data[5], bPseudoTest); - efuse_OneByteRead(pAdapter,tmpaddr, &tmpdata[4], bPseudoTest); - efuse_OneByteRead(pAdapter,tmpaddr+1, &tmpdata[5], bPseudoTest); - if ((data[4]!=tmpdata[4])||(data[5]!=tmpdata[5])){ - badworden &=( ~BIT2); - } + efuse_OneByteRead(pAdapter, tmpaddr, &tmpdata[4], bPseudoTest); + efuse_OneByteRead(pAdapter, tmpaddr+1, &tmpdata[5], bPseudoTest); + if ((data[4] != tmpdata[4]) || (data[5] != tmpdata[5])) + badworden &= (~BIT2); } - if (!(word_en&BIT3)) - { + if (!(word_en&BIT3)) { tmpaddr = start_addr; - efuse_OneByteWrite(pAdapter,start_addr++, data[6], bPseudoTest); - efuse_OneByteWrite(pAdapter,start_addr++, data[7], bPseudoTest); + efuse_OneByteWrite(pAdapter, start_addr++, data[6], bPseudoTest); + efuse_OneByteWrite(pAdapter, start_addr++, data[7], bPseudoTest); - efuse_OneByteRead(pAdapter,tmpaddr, &tmpdata[6], bPseudoTest); - efuse_OneByteRead(pAdapter,tmpaddr+1, &tmpdata[7], bPseudoTest); - if ((data[6]!=tmpdata[6])||(data[7]!=tmpdata[7])){ - badworden &=( ~BIT3); - } + efuse_OneByteRead(pAdapter, tmpaddr, &tmpdata[6], bPseudoTest); + efuse_OneByteRead(pAdapter, tmpaddr+1, &tmpdata[7], bPseudoTest); + if ((data[6] != tmpdata[6]) || (data[7] != tmpdata[7])) + badworden &= (~BIT3); } return badworden; } -static u8 -Hal_EfuseWordEnableDataWrite_Pseudo ( struct adapter * pAdapter, - u16 efuse_addr, - u8 word_en, - u8 *data, - bool bPseudoTest) +static u8 Hal_EfuseWordEnableDataWrite_Pseudo(struct adapter *pAdapter, u16 efuse_addr, u8 word_en, u8 *data, bool bPseudoTest) { - u8 ret=0; + u8 ret; ret = Hal_EfuseWordEnableDataWrite(pAdapter, efuse_addr, word_en, data, bPseudoTest); - return ret; } -static u8 -rtl8188e_Efuse_WordEnableDataWrite( struct adapter * pAdapter, - u16 efuse_addr, - u8 word_en, - u8 *data, - bool bPseudoTest) +static u8 rtl8188e_Efuse_WordEnableDataWrite(struct adapter *pAdapter, u16 efuse_addr, u8 word_en, u8 *data, bool bPseudoTest) { - u8 ret=0; + u8 ret = 0; if (bPseudoTest) - { ret = Hal_EfuseWordEnableDataWrite_Pseudo (pAdapter, efuse_addr, word_en, data, bPseudoTest); - } else - { ret = Hal_EfuseWordEnableDataWrite(pAdapter, efuse_addr, word_en, data, bPseudoTest); - } - return ret; } - -static u16 -hal_EfuseGetCurrentSize_8188e( struct adapter * pAdapter, - bool bPseudoTest) +static u16 hal_EfuseGetCurrentSize_8188e(struct adapter *pAdapter, bool bPseudoTest) { int bContinual = true; - u16 efuse_addr = 0; - u8 hoffset=0,hworden=0; - u8 efuse_data,word_cnts=0; + u8 hoffset = 0, hworden = 0; + u8 efuse_data, word_cnts = 0; if (bPseudoTest) - { efuse_addr = (u16)(fakeEfuseUsedBytes); - } else - { rtw_hal_get_hwreg(pAdapter, HW_VAR_EFUSE_BYTES, (u8 *)&efuse_addr); - } - while ( bContinual && - efuse_OneByteRead(pAdapter, efuse_addr ,&efuse_data, bPseudoTest) && - AVAILABLE_EFUSE_ADDR(efuse_addr)) - { - if (efuse_data!=0xFF) - { - if ((efuse_data&0x1F) == 0x0F) /* extended header */ - { + while (bContinual && + efuse_OneByteRead(pAdapter, efuse_addr, &efuse_data, bPseudoTest) && + AVAILABLE_EFUSE_ADDR(efuse_addr)) { + if (efuse_data != 0xFF) { + if ((efuse_data&0x1F) == 0x0F) { /* extended header */ hoffset = efuse_data; efuse_addr++; - efuse_OneByteRead(pAdapter, efuse_addr ,&efuse_data, bPseudoTest); - if ((efuse_data & 0x0F) == 0x0F) - { + efuse_OneByteRead(pAdapter, efuse_addr, &efuse_data, bPseudoTest); + if ((efuse_data & 0x0F) == 0x0F) { efuse_addr++; continue; - } - else - { + } else { hoffset = ((hoffset & 0xE0) >> 5) | ((efuse_data & 0xF0) >> 1); hworden = efuse_data & 0x0F; } - } - else - { + } else { hoffset = (efuse_data>>4) & 0x0F; hworden = efuse_data & 0x0F; } word_cnts = Efuse_CalculateWordCnts(hworden); /* read next header */ efuse_addr = efuse_addr + (word_cnts*2)+1; - } - else - { - bContinual = false ; + } else { + bContinual = false; } } if (bPseudoTest) - { fakeEfuseUsedBytes = efuse_addr; - } else - { rtw_hal_set_hwreg(pAdapter, HW_VAR_EFUSE_BYTES, (u8 *)&efuse_addr); - } return efuse_addr; } -static u16 -Hal_EfuseGetCurrentSize_Pseudo ( struct adapter * pAdapter, - bool bPseudoTest) +static u16 Hal_EfuseGetCurrentSize_Pseudo(struct adapter *pAdapter, bool bPseudoTest) { - u16 ret=0; + u16 ret = 0; ret = hal_EfuseGetCurrentSize_8188e(pAdapter, bPseudoTest); - return ret; } - -static u16 -rtl8188e_EfuseGetCurrentSize( - struct adapter * pAdapter, - u8 efuseType, - bool bPseudoTest) +static u16 rtl8188e_EfuseGetCurrentSize(struct adapter *pAdapter, u8 efuseType, bool bPseudoTest) { - u16 ret=0; + u16 ret = 0; if (bPseudoTest) - { - ret = Hal_EfuseGetCurrentSize_Pseudo (pAdapter, bPseudoTest); - } + ret = Hal_EfuseGetCurrentSize_Pseudo(pAdapter, bPseudoTest); else - { ret = hal_EfuseGetCurrentSize_8188e(pAdapter, bPseudoTest); - - } - return ret; } - -static int -hal_EfusePgPacketRead_8188e( - struct adapter * pAdapter, - u8 offset, - u8 *data, - bool bPseudoTest) +static int hal_EfusePgPacketRead_8188e(struct adapter *pAdapter, u8 offset, u8 *data, bool bPseudoTest) { - u8 ReadState = PG_STATE_HEADER; - + u8 ReadState = PG_STATE_HEADER; int bContinual = true; - int bDataEmpty = true ; - - u8 efuse_data,word_cnts = 0; + int bDataEmpty = true; + u8 efuse_data, word_cnts = 0; u16 efuse_addr = 0; - u8 hoffset = 0,hworden = 0; - u8 tmpidx = 0; - u8 tmpdata[8]; - u8 max_section = 0; - u8 tmp_header = 0; + u8 hoffset = 0, hworden = 0; + u8 tmpidx = 0; + u8 tmpdata[8]; + u8 max_section = 0; + u8 tmp_header = 0; EFUSE_GetEfuseDefinition(pAdapter, EFUSE_WIFI, TYPE_EFUSE_MAX_SECTION, (void *)&max_section, bPseudoTest); - if (data==NULL) + if (data == NULL) return false; - if (offset>max_section) + if (offset > max_section) return false; _rtw_memset((void *)data, 0xff, sizeof(u8)*PGPKT_DATA_SIZE); _rtw_memset((void *)tmpdata, 0xff, sizeof(u8)*PGPKT_DATA_SIZE); - - /* */ /* Efuse has been pre-programmed dummy 5Bytes at the end of Efuse by CP. */ /* Skip dummy parts to prevent unexpected data read from Efuse. */ /* By pass right now. 2009.02.19. */ - /* */ - while (bContinual && AVAILABLE_EFUSE_ADDR(efuse_addr) ) - { + while (bContinual && AVAILABLE_EFUSE_ADDR(efuse_addr)) { /* Header Read ------------- */ - if (ReadState & PG_STATE_HEADER) - { - if (efuse_OneByteRead(pAdapter, efuse_addr ,&efuse_data, bPseudoTest)&&(efuse_data!=0xFF)) - { - if (EXT_HEADER(efuse_data)) - { + if (ReadState & PG_STATE_HEADER) { + if (efuse_OneByteRead(pAdapter, efuse_addr, &efuse_data, bPseudoTest) && (efuse_data != 0xFF)) { + if (EXT_HEADER(efuse_data)) { tmp_header = efuse_data; efuse_addr++; - efuse_OneByteRead(pAdapter, efuse_addr ,&efuse_data, bPseudoTest); - if (!ALL_WORDS_DISABLED(efuse_data)) - { + efuse_OneByteRead(pAdapter, efuse_addr, &efuse_data, bPseudoTest); + if (!ALL_WORDS_DISABLED(efuse_data)) { hoffset = ((tmp_header & 0xE0) >> 5) | ((efuse_data & 0xF0) >> 1); hworden = efuse_data & 0x0F; - } - else - { + } else { DBG_88E("Error, All words disabled\n"); efuse_addr++; continue; } - } - else - { + } else { hoffset = (efuse_data>>4) & 0x0F; hworden = efuse_data & 0x0F; } word_cnts = Efuse_CalculateWordCnts(hworden); - bDataEmpty = true ; + bDataEmpty = true; - if (hoffset==offset) - { - for (tmpidx = 0;tmpidx< word_cnts*2 ;tmpidx++) - { - if (efuse_OneByteRead(pAdapter, efuse_addr+1+tmpidx ,&efuse_data, bPseudoTest) ) - { + if (hoffset == offset) { + for (tmpidx = 0; tmpidx < word_cnts*2; tmpidx++) { + if (efuse_OneByteRead(pAdapter, efuse_addr+1+tmpidx, &efuse_data, bPseudoTest)) { tmpdata[tmpidx] = efuse_data; - if (efuse_data!=0xff) - { + if (efuse_data != 0xff) bDataEmpty = false; - } } } - if (bDataEmpty==false){ + if (bDataEmpty == false) { ReadState = PG_STATE_DATA; - }else{/* read next header */ + } else {/* read next header */ efuse_addr = efuse_addr + (word_cnts*2)+1; ReadState = PG_STATE_HEADER; } - } - else{/* read next header */ + } else {/* read next header */ efuse_addr = efuse_addr + (word_cnts*2)+1; ReadState = PG_STATE_HEADER; } - + } else { + bContinual = false; } - else{ - bContinual = false ; - } - } + } else if (ReadState & PG_STATE_DATA) { /* Data section Read ------------- */ - else if (ReadState & PG_STATE_DATA) - { - efuse_WordEnableDataRead(hworden,tmpdata,data); + efuse_WordEnableDataRead(hworden, tmpdata, data); efuse_addr = efuse_addr + (word_cnts*2)+1; ReadState = PG_STATE_HEADER; } } - if ( (data[0]==0xff) &&(data[1]==0xff) && (data[2]==0xff) && (data[3]==0xff) && - (data[4]==0xff) &&(data[5]==0xff) && (data[6]==0xff) && (data[7]==0xff)) + if ((data[0] == 0xff) && (data[1] == 0xff) && (data[2] == 0xff) && (data[3] == 0xff) && + (data[4] == 0xff) && (data[5] == 0xff) && (data[6] == 0xff) && (data[7] == 0xff)) return false; else return true; - } -static int -Hal_EfusePgPacketRead( struct adapter * pAdapter, - u8 offset, - u8 *data, - bool bPseudoTest) +static int Hal_EfusePgPacketRead(struct adapter *pAdapter, u8 offset, u8 *data, bool bPseudoTest) { - int ret=0; + int ret; ret = hal_EfusePgPacketRead_8188e(pAdapter, offset, data, bPseudoTest); - - return ret; } -static int -Hal_EfusePgPacketRead_Pseudo ( struct adapter * pAdapter, - u8 offset, - u8 *data, - bool bPseudoTest) +static int Hal_EfusePgPacketRead_Pseudo(struct adapter *pAdapter, u8 offset, u8 *data, bool bPseudoTest) { - int ret=0; + int ret; ret = hal_EfusePgPacketRead_8188e(pAdapter, offset, data, bPseudoTest); - return ret; } -static int -rtl8188e_Efuse_PgPacketRead( struct adapter * pAdapter, - u8 offset, - u8 *data, - bool bPseudoTest) +static int rtl8188e_Efuse_PgPacketRead(struct adapter *pAdapter, u8 offset, u8 *data, bool bPseudoTest) { - int ret=0; + int ret; if (bPseudoTest) - { ret = Hal_EfusePgPacketRead_Pseudo (pAdapter, offset, data, bPseudoTest); - } else - { ret = Hal_EfusePgPacketRead(pAdapter, offset, data, bPseudoTest); - } - return ret; } -static bool -hal_EfuseFixHeaderProcess( - struct adapter * pAdapter, - u8 efuseType, - struct pgpkt *pFixPkt, - u16 *pAddr, - bool bPseudoTest -) +static bool hal_EfuseFixHeaderProcess(struct adapter *pAdapter, u8 efuseType, struct pgpkt *pFixPkt, u16 *pAddr, bool bPseudoTest) { - u8 originaldata[8], badworden=0; - u16 efuse_addr=*pAddr; - u32 PgWriteSuccess=0; + u8 originaldata[8], badworden = 0; + u16 efuse_addr = *pAddr; + u32 PgWriteSuccess = 0; _rtw_memset((void *)originaldata, 0xff, 8); - if (Efuse_PgPacketRead(pAdapter, pFixPkt->offset, originaldata, bPseudoTest)) - { /* check if data exist */ + if (Efuse_PgPacketRead(pAdapter, pFixPkt->offset, originaldata, bPseudoTest)) { + /* check if data exist */ badworden = Efuse_WordEnableDataWrite(pAdapter, efuse_addr+1, pFixPkt->word_en, originaldata, bPseudoTest); - if (badworden != 0xf) /* write fail */ - { + if (badworden != 0xf) { /* write fail */ PgWriteSuccess = Efuse_PgPacketWrite(pAdapter, pFixPkt->offset, badworden, originaldata, bPseudoTest); if (!PgWriteSuccess) return false; else efuse_addr = Efuse_GetCurrentSize(pAdapter, efuseType, bPseudoTest); + } else { + efuse_addr = efuse_addr + (pFixPkt->word_cnts*2) + 1; } - else - { - efuse_addr = efuse_addr + (pFixPkt->word_cnts*2) +1; - } - } - else - { - efuse_addr = efuse_addr + (pFixPkt->word_cnts*2) +1; + } else { + efuse_addr = efuse_addr + (pFixPkt->word_cnts*2) + 1; } *pAddr = efuse_addr; return true; } -static bool -hal_EfusePgPacketWrite2ByteHeader( - struct adapter * pAdapter, - u8 efuseType, - u16 *pAddr, - struct pgpkt *pTargetPkt, - bool bPseudoTest) +static bool hal_EfusePgPacketWrite2ByteHeader(struct adapter *pAdapter, u8 efuseType, u16 *pAddr, struct pgpkt *pTargetPkt, bool bPseudoTest) { - bool bRet=false, bContinual=true; - u16 efuse_addr=*pAddr, efuse_max_available_len=0; - u8 pg_header=0, tmp_header=0, pg_header_temp=0; - u8 repeatcnt=0; + bool bRet = false, bContinual = true; + u16 efuse_addr = *pAddr, efuse_max_available_len = 0; + u8 pg_header = 0, tmp_header = 0, pg_header_temp = 0; + u8 repeatcnt = 0; EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_AVAILABLE_EFUSE_BYTES_BANK, (void *)&efuse_max_available_len, bPseudoTest); - while (efuse_addr < efuse_max_available_len) - { + while (efuse_addr < efuse_max_available_len) { pg_header = ((pTargetPkt->offset & 0x07) << 5) | 0x0F; efuse_OneByteWrite(pAdapter, efuse_addr, pg_header, bPseudoTest); efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header, bPseudoTest); - while (tmp_header == 0xFF) - { + while (tmp_header == 0xFF) { if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) - { return false; - } efuse_OneByteWrite(pAdapter, efuse_addr, pg_header, bPseudoTest); efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header, bPseudoTest); } /* to write ext_header */ - if (tmp_header == pg_header) - { + if (tmp_header == pg_header) { efuse_addr++; pg_header_temp = pg_header; pg_header = ((pTargetPkt->offset & 0x78) << 1) | pTargetPkt->word_en; @@ -1877,47 +1602,34 @@ hal_EfusePgPacketWrite2ByteHeader( efuse_OneByteWrite(pAdapter, efuse_addr, pg_header, bPseudoTest); efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header, bPseudoTest); - while (tmp_header == 0xFF) - { + while (tmp_header == 0xFF) { if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) - { return false; - } efuse_OneByteWrite(pAdapter, efuse_addr, pg_header, bPseudoTest); efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header, bPseudoTest); } - if ((tmp_header & 0x0F) == 0x0F) /* word_en PG fail */ - { - if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) - { + if ((tmp_header & 0x0F) == 0x0F) { /* word_en PG fail */ + if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) { return false; - } - else - { + } else { efuse_addr++; continue; } - } - else if (pg_header != tmp_header) /* offset PG fail */ - { + } else if (pg_header != tmp_header) { /* offset PG fail */ struct pgpkt fixPkt; fixPkt.offset = ((pg_header_temp & 0xE0) >> 5) | ((tmp_header & 0xF0) >> 1); fixPkt.word_en = tmp_header & 0x0F; fixPkt.word_cnts = Efuse_CalculateWordCnts(fixPkt.word_en); if (!hal_EfuseFixHeaderProcess(pAdapter, efuseType, &fixPkt, &efuse_addr, bPseudoTest)) return false; - } - else - { + } else { bRet = true; break; } - } - else if ((tmp_header & 0x1F) == 0x0F) /* wrong extended header */ - { - efuse_addr+=2; + } else if ((tmp_header & 0x1F) == 0x0F) { /* wrong extended header */ + efuse_addr += 2; continue; } } @@ -1926,40 +1638,28 @@ hal_EfusePgPacketWrite2ByteHeader( return bRet; } -static bool -hal_EfusePgPacketWrite1ByteHeader( - struct adapter * pAdapter, - u8 efuseType, - u16 *pAddr, - struct pgpkt *pTargetPkt, - bool bPseudoTest) +static bool hal_EfusePgPacketWrite1ByteHeader(struct adapter *pAdapter, u8 efuseType, u16 *pAddr, struct pgpkt *pTargetPkt, bool bPseudoTest) { - bool bRet=false; - u8 pg_header=0, tmp_header=0; - u16 efuse_addr=*pAddr; - u8 repeatcnt=0; + bool bRet = false; + u8 pg_header = 0, tmp_header = 0; + u16 efuse_addr = *pAddr; + u8 repeatcnt = 0; - pg_header = ((pTargetPkt->offset << 4) & 0xf0) |pTargetPkt->word_en; + pg_header = ((pTargetPkt->offset << 4) & 0xf0) | pTargetPkt->word_en; efuse_OneByteWrite(pAdapter, efuse_addr, pg_header, bPseudoTest); efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header, bPseudoTest); - while (tmp_header == 0xFF) - { + while (tmp_header == 0xFF) { if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) - { return false; - } - efuse_OneByteWrite(pAdapter,efuse_addr, pg_header, bPseudoTest); - efuse_OneByteRead(pAdapter,efuse_addr, &tmp_header, bPseudoTest); + efuse_OneByteWrite(pAdapter, efuse_addr, pg_header, bPseudoTest); + efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header, bPseudoTest); } - if (pg_header == tmp_header) - { + if (pg_header == tmp_header) { bRet = true; - } - else - { + } else { struct pgpkt fixPkt; fixPkt.offset = (tmp_header>>4) & 0x0F; fixPkt.word_en = tmp_header & 0x0F; @@ -1972,59 +1672,43 @@ hal_EfusePgPacketWrite1ByteHeader( return bRet; } -static bool -hal_EfusePgPacketWriteData( - struct adapter * pAdapter, - u8 efuseType, - u16 *pAddr, - struct pgpkt *pTargetPkt, - bool bPseudoTest) +static bool hal_EfusePgPacketWriteData(struct adapter *pAdapter, u8 efuseType, u16 *pAddr, struct pgpkt *pTargetPkt, bool bPseudoTest) { - bool bRet=false; - u16 efuse_addr=*pAddr; - u8 badworden=0; - u32 PgWriteSuccess=0; + bool bRet = false; + u16 efuse_addr = *pAddr; + u8 badworden = 0; + u32 PgWriteSuccess = 0; badworden = 0x0f; badworden = Efuse_WordEnableDataWrite(pAdapter, efuse_addr+1, pTargetPkt->word_en, pTargetPkt->data, bPseudoTest); - if (badworden == 0x0F) - { + if (badworden == 0x0F) { /* write ok */ return true; - } - else - { + } else { /* reorganize other pg packet */ - PgWriteSuccess = Efuse_PgPacketWrite(pAdapter, pTargetPkt->offset, badworden, pTargetPkt->data, bPseudoTest); - if (!PgWriteSuccess) return false; else return true; } - return bRet; } static bool hal_EfusePgPacketWriteHeader( - struct adapter * pAdapter, - u8 efuseType, + struct adapter *pAdapter, + u8 efuseType, u16 *pAddr, struct pgpkt *pTargetPkt, - bool bPseudoTest) + bool bPseudoTest) { - bool bRet=false; + bool bRet = false; if (pTargetPkt->offset >= EFUSE_MAX_SECTION_BASE) - { bRet = hal_EfusePgPacketWrite2ByteHeader(pAdapter, efuseType, pAddr, pTargetPkt, bPseudoTest); - } else - { bRet = hal_EfusePgPacketWrite1ByteHeader(pAdapter, efuseType, pAddr, pTargetPkt, bPseudoTest); - } return bRet; } @@ -2033,33 +1717,25 @@ static bool wordEnMatched( struct pgpkt *pTargetPkt, struct pgpkt *pCurPkt, - u8 *pWden + u8 *pWden ) { - u8 match_word_en = 0x0F; /* default all words are disabled */ - u8 i; + u8 match_word_en = 0x0F; /* default all words are disabled */ + u8 i; /* check if the same words are enabled both target and current PG packet */ - if ( ((pTargetPkt->word_en & BIT0) == 0) && - ((pCurPkt->word_en & BIT0) == 0) ) - { + if (((pTargetPkt->word_en & BIT0) == 0) && + ((pCurPkt->word_en & BIT0) == 0)) match_word_en &= ~BIT0; /* enable word 0 */ - } - if ( ((pTargetPkt->word_en & BIT1) == 0) && - ((pCurPkt->word_en & BIT1) == 0) ) - { + if (((pTargetPkt->word_en & BIT1) == 0) && + ((pCurPkt->word_en & BIT1) == 0)) match_word_en &= ~BIT1; /* enable word 1 */ - } - if ( ((pTargetPkt->word_en & BIT2) == 0) && - ((pCurPkt->word_en & BIT2) == 0) ) - { + if (((pTargetPkt->word_en & BIT2) == 0) && + ((pCurPkt->word_en & BIT2) == 0)) match_word_en &= ~BIT2; /* enable word 2 */ - } - if ( ((pTargetPkt->word_en & BIT3) == 0) && - ((pCurPkt->word_en & BIT3) == 0) ) - { + if (((pTargetPkt->word_en & BIT3) == 0) && + ((pCurPkt->word_en & BIT3) == 0)) match_word_en &= ~BIT3; /* enable word 3 */ - } *pWden = match_word_en; @@ -2069,96 +1745,62 @@ wordEnMatched( return false; } -static bool -hal_EfuseCheckIfDatafollowed( - struct adapter * pAdapter, - u8 word_cnts, - u16 startAddr, - bool bPseudoTest - ) +static bool hal_EfuseCheckIfDatafollowed(struct adapter *pAdapter, u8 word_cnts, u16 startAddr, bool bPseudoTest) { - bool bRet=false; - u8 i, efuse_data; + bool bRet = false; + u8 i, efuse_data; - for (i=0; i<(word_cnts*2) ; i++) - { - if (efuse_OneByteRead(pAdapter, (startAddr+i) ,&efuse_data, bPseudoTest)&&(efuse_data != 0xFF)) + for (i = 0; i < (word_cnts*2); i++) { + if (efuse_OneByteRead(pAdapter, (startAddr+i), &efuse_data, bPseudoTest) && (efuse_data != 0xFF)) bRet = true; } - return bRet; } -static bool -hal_EfusePartialWriteCheck( - struct adapter * pAdapter, - u8 efuseType, - u16 *pAddr, - struct pgpkt *pTargetPkt, - bool bPseudoTest - ) +static bool hal_EfusePartialWriteCheck(struct adapter *pAdapter, u8 efuseType, u16 *pAddr, struct pgpkt *pTargetPkt, bool bPseudoTest) { - bool bRet=false; - u8 i, efuse_data=0, cur_header=0; - u8 new_wden=0, matched_wden=0, badworden=0; - u16 startAddr=0, efuse_max_available_len=0, efuse_max=0; + bool bRet = false; + u8 i, efuse_data = 0, cur_header = 0; + u8 new_wden = 0, matched_wden = 0, badworden = 0; + u16 startAddr = 0, efuse_max_available_len = 0, efuse_max = 0; struct pgpkt curPkt; EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_AVAILABLE_EFUSE_BYTES_BANK, (void *)&efuse_max_available_len, bPseudoTest); EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_EFUSE_REAL_CONTENT_LEN, (void *)&efuse_max, bPseudoTest); - if (efuseType == EFUSE_WIFI) - { - if (bPseudoTest) - { + if (efuseType == EFUSE_WIFI) { + if (bPseudoTest) { startAddr = (u16)(fakeEfuseUsedBytes%EFUSE_REAL_CONTENT_LEN); - } - else - { + } else { rtw_hal_get_hwreg(pAdapter, HW_VAR_EFUSE_BYTES, (u8 *)&startAddr); - startAddr%=EFUSE_REAL_CONTENT_LEN; + startAddr %= EFUSE_REAL_CONTENT_LEN; } - } - else - { + } else { if (bPseudoTest) - { startAddr = (u16)(fakeBTEfuseUsedBytes%EFUSE_REAL_CONTENT_LEN); - } else - { startAddr = (u16)(BTEfuseUsedBytes%EFUSE_REAL_CONTENT_LEN); - } } - while (1) - { - if (startAddr >= efuse_max_available_len) - { + while (1) { + if (startAddr >= efuse_max_available_len) { bRet = false; break; } - if (efuse_OneByteRead(pAdapter, startAddr, &efuse_data, bPseudoTest) && (efuse_data!=0xFF)) - { - if (EXT_HEADER(efuse_data)) - { + if (efuse_OneByteRead(pAdapter, startAddr, &efuse_data, bPseudoTest) && (efuse_data != 0xFF)) { + if (EXT_HEADER(efuse_data)) { cur_header = efuse_data; startAddr++; efuse_OneByteRead(pAdapter, startAddr, &efuse_data, bPseudoTest); - if (ALL_WORDS_DISABLED(efuse_data)) - { + if (ALL_WORDS_DISABLED(efuse_data)) { bRet = false; break; - } - else - { + } else { curPkt.offset = ((cur_header & 0xE0) >> 5) | ((efuse_data & 0xF0) >> 1); curPkt.word_en = efuse_data & 0x0F; } - } - else - { + } else { cur_header = efuse_data; curPkt.offset = (cur_header>>4) & 0x0F; curPkt.word_en = cur_header & 0x0F; @@ -2167,40 +1809,32 @@ hal_EfusePartialWriteCheck( curPkt.word_cnts = Efuse_CalculateWordCnts(curPkt.word_en); /* if same header is found but no data followed */ /* write some part of data followed by the header. */ - if ( (curPkt.offset == pTargetPkt->offset) && - (!hal_EfuseCheckIfDatafollowed(pAdapter, curPkt.word_cnts, startAddr+1, bPseudoTest)) && - wordEnMatched(pTargetPkt, &curPkt, &matched_wden) ) - { + if ((curPkt.offset == pTargetPkt->offset) && + (!hal_EfuseCheckIfDatafollowed(pAdapter, curPkt.word_cnts, startAddr+1, bPseudoTest)) && + wordEnMatched(pTargetPkt, &curPkt, &matched_wden)) { /* Here to write partial data */ badworden = Efuse_WordEnableDataWrite(pAdapter, startAddr+1, matched_wden, pTargetPkt->data, bPseudoTest); - if (badworden != 0x0F) - { - u32 PgWriteSuccess=0; + if (badworden != 0x0F) { + u32 PgWriteSuccess = 0; /* if write fail on some words, write these bad words again */ PgWriteSuccess = Efuse_PgPacketWrite(pAdapter, pTargetPkt->offset, badworden, pTargetPkt->data, bPseudoTest); - if (!PgWriteSuccess) - { + if (!PgWriteSuccess) { bRet = false; /* write fail, return */ break; } } /* partial write ok, update the target packet for later use */ - for (i=0; i<4; i++) - { + for (i = 0; i < 4; i++) { if ((matched_wden & (0x1<word_en |= (0x1<word_cnts = Efuse_CalculateWordCnts(pTargetPkt->word_en); } /* read from next header */ - startAddr = startAddr + (curPkt.word_cnts*2) +1; - } - else - { + startAddr = startAddr + (curPkt.word_cnts*2) + 1; + } else { /* not used header, 0xff */ *pAddr = startAddr; bRet = true; @@ -2212,53 +1846,35 @@ hal_EfusePartialWriteCheck( static bool hal_EfusePgCheckAvailableAddr( - struct adapter * pAdapter, - u8 efuseType, - bool bPseudoTest + struct adapter *pAdapter, + u8 efuseType, + bool bPseudoTest ) { - u16 efuse_max_available_len=0; + u16 efuse_max_available_len = 0; - /* Change to check TYPE_EFUSE_MAP_LEN ,beacuse 8188E raw 256,logic map over 256. */ + /* Change to check TYPE_EFUSE_MAP_LEN , beacuse 8188E raw 256, logic map over 256. */ EFUSE_GetEfuseDefinition(pAdapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (void *)&efuse_max_available_len, false); - if (Efuse_GetCurrentSize(pAdapter, efuseType, bPseudoTest) >= efuse_max_available_len) - { return false; - } return true; } -static void -hal_EfuseConstructPGPkt( - u8 offset, - u8 word_en, - u8 *pData, - struct pgpkt *pTargetPkt - -) +static void hal_EfuseConstructPGPkt(u8 offset, u8 word_en, u8 *pData, struct pgpkt *pTargetPkt) { _rtw_memset((void *)pTargetPkt->data, 0xFF, sizeof(u8)*8); pTargetPkt->offset = offset; - pTargetPkt->word_en= word_en; + pTargetPkt->word_en = word_en; efuse_WordEnableDataRead(word_en, pData, pTargetPkt->data); pTargetPkt->word_cnts = Efuse_CalculateWordCnts(pTargetPkt->word_en); - } -static bool -hal_EfusePgPacketWrite_BT( - struct adapter * pAdapter, - u8 offset, - u8 word_en, - u8 *pData, - bool bPseudoTest - ) +static bool hal_EfusePgPacketWrite_BT(struct adapter *pAdapter, u8 offset, u8 word_en, u8 *pData, bool bPseudoTest) { struct pgpkt targetPkt; - u16 startAddr=0; - u8 efuseType=EFUSE_BT; + u16 startAddr = 0; + u8 efuseType = EFUSE_BT; if (!hal_EfusePgCheckAvailableAddr(pAdapter, efuseType, bPseudoTest)) return false; @@ -2277,18 +1893,11 @@ hal_EfusePgPacketWrite_BT( return true; } -static bool -hal_EfusePgPacketWrite_8188e( - struct adapter * pAdapter, - u8 offset, - u8 word_en, - u8 *pData, - bool bPseudoTest - ) +static bool hal_EfusePgPacketWrite_8188e(struct adapter *pAdapter, u8 offset, u8 word_en, u8 *pData, bool bPseudoTest) { struct pgpkt targetPkt; - u16 startAddr=0; - u8 efuseType=EFUSE_WIFI; + u16 startAddr = 0; + u8 efuseType = EFUSE_WIFI; if (!hal_EfusePgCheckAvailableAddr(pAdapter, efuseType, bPseudoTest)) return false; @@ -2307,62 +1916,39 @@ hal_EfusePgPacketWrite_8188e( return true; } - -static int -Hal_EfusePgPacketWrite_Pseudo ( struct adapter * pAdapter, - u8 offset, - u8 word_en, - u8 *data, - bool bPseudoTest) +static int Hal_EfusePgPacketWrite_Pseudo(struct adapter *pAdapter, u8 offset, u8 word_en, u8 *data, bool bPseudoTest) { int ret; ret = hal_EfusePgPacketWrite_8188e(pAdapter, offset, word_en, data, bPseudoTest); - return ret; } -static int -Hal_EfusePgPacketWrite( struct adapter * pAdapter, - u8 offset, - u8 word_en, - u8 *data, - bool bPseudoTest) +static int Hal_EfusePgPacketWrite(struct adapter *pAdapter, u8 offset, u8 word_en, u8 *data, bool bPseudoTest) { - int ret=0; + int ret = 0; ret = hal_EfusePgPacketWrite_8188e(pAdapter, offset, word_en, data, bPseudoTest); - return ret; } -static int -rtl8188e_Efuse_PgPacketWrite( struct adapter * pAdapter, - u8 offset, - u8 word_en, - u8 *data, - bool bPseudoTest) +static int rtl8188e_Efuse_PgPacketWrite(struct adapter *pAdapter, u8 offset, u8 word_en, u8 *data, bool bPseudoTest) { int ret; if (bPseudoTest) - { ret = Hal_EfusePgPacketWrite_Pseudo (pAdapter, offset, word_en, data, bPseudoTest); - } else - { ret = Hal_EfusePgPacketWrite(pAdapter, offset, word_en, data, bPseudoTest); - } return ret; } -static struct HAL_VERSION ReadChipVersion8188E(struct adapter * padapter) +static struct HAL_VERSION ReadChipVersion8188E(struct adapter *padapter) { u32 value32; struct HAL_VERSION ChipVersion; struct hal_data_8188e *pHalData; - pHalData = GET_HAL_DATA(padapter); value32 = rtw_read32(padapter, REG_SYS_CFG); @@ -2379,16 +1965,14 @@ static struct HAL_VERSION ReadChipVersion8188E(struct adapter * padapter) ChipVersion.ROMVer = 0; /* ROM code version. */ pHalData->MultiFunc = RT_MULTI_FUNC_NONE; - dump_chip_info(ChipVersion); pHalData->VersionID = ChipVersion; - if (IS_1T2R(ChipVersion)){ + if (IS_1T2R(ChipVersion)) { pHalData->rf_type = RF_1T2R; pHalData->NumTotalRFPath = 2; - } - else if (IS_2T2R(ChipVersion)){ + } else if (IS_2T2R(ChipVersion)) { pHalData->rf_type = RF_2T2R; pHalData->NumTotalRFPath = 2; } else{ @@ -2401,61 +1985,53 @@ static struct HAL_VERSION ReadChipVersion8188E(struct adapter * padapter) return ChipVersion; } -static void rtl8188e_read_chip_version(struct adapter * padapter) +static void rtl8188e_read_chip_version(struct adapter *padapter) { ReadChipVersion8188E(padapter); } -static void rtl8188e_GetHalODMVar( - struct adapter * Adapter, - enum hal_odm_variable eVariable, - void * pValue1, - bool bSet) +static void rtl8188e_GetHalODMVar(struct adapter *Adapter, enum hal_odm_variable eVariable, void *pValue1, bool bSet) { struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); struct odm_dm_struct *podmpriv = &pHalData->odmpriv; - switch (eVariable){ - case HAL_ODM_STA_INFO: - break; - default: - break; - } -} -static void rtl8188e_SetHalODMVar( - struct adapter * Adapter, - enum hal_odm_variable eVariable, - void * pValue1, - bool bSet) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - struct odm_dm_struct *podmpriv = &pHalData->odmpriv; - switch (eVariable){ - case HAL_ODM_STA_INFO: - { - struct sta_info *psta = (struct sta_info *)pValue1; - if (bSet){ - DBG_88E("### Set STA_(%d) info\n",psta->mac_id); - ODM_CmnInfoPtrArrayHook(podmpriv, ODM_CMNINFO_STA_STATUS,psta->mac_id,psta); - ODM_RAInfo_Init(podmpriv,psta->mac_id); - } - else{ - DBG_88E("### Clean STA_(%d) info\n",psta->mac_id); - ODM_CmnInfoPtrArrayHook(podmpriv, ODM_CMNINFO_STA_STATUS,psta->mac_id,NULL); - } - } - break; - case HAL_ODM_P2P_STATE: - ODM_CmnInfoUpdate(podmpriv,ODM_CMNINFO_WIFI_DIRECT,bSet); - break; - case HAL_ODM_WIFI_DISPLAY_STATE: - ODM_CmnInfoUpdate(podmpriv,ODM_CMNINFO_WIFI_DISPLAY,bSet); - break; - default: - break; + switch (eVariable) { + case HAL_ODM_STA_INFO: + break; + default: + break; } } -void rtl8188e_clone_haldata(struct adapter* dst_adapter, struct adapter* src_adapter) +static void rtl8188e_SetHalODMVar(struct adapter *Adapter, enum hal_odm_variable eVariable, void *pValue1, bool bSet) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + struct odm_dm_struct *podmpriv = &pHalData->odmpriv; + switch (eVariable) { + case HAL_ODM_STA_INFO: + { + struct sta_info *psta = (struct sta_info *)pValue1; + if (bSet) { + DBG_88E("### Set STA_(%d) info\n", psta->mac_id); + ODM_CmnInfoPtrArrayHook(podmpriv, ODM_CMNINFO_STA_STATUS, psta->mac_id, psta); + ODM_RAInfo_Init(podmpriv, psta->mac_id); + } else { + DBG_88E("### Clean STA_(%d) info\n", psta->mac_id); + ODM_CmnInfoPtrArrayHook(podmpriv, ODM_CMNINFO_STA_STATUS, psta->mac_id, NULL); + } + } + break; + case HAL_ODM_P2P_STATE: + ODM_CmnInfoUpdate(podmpriv, ODM_CMNINFO_WIFI_DIRECT, bSet); + break; + case HAL_ODM_WIFI_DISPLAY_STATE: + ODM_CmnInfoUpdate(podmpriv, ODM_CMNINFO_WIFI_DISPLAY, bSet); + break; + default: + break; + } +} + +void rtl8188e_clone_haldata(struct adapter *dst_adapter, struct adapter *src_adapter) { _rtw_memcpy(dst_adapter->HalData, src_adapter->HalData, dst_adapter->hal_data_sz); } @@ -2493,8 +2069,8 @@ void rtl8188e_set_hal_ops(struct hal_ops *pHalFunc) pHalFunc->hal_dm_watchdog = &rtl8188e_HalDmWatchDog; pHalFunc->Add_RateATid = &rtl8188e_Add_RateATid; - pHalFunc->run_thread= &rtl8188e_start_thread; - pHalFunc->cancel_thread= &rtl8188e_stop_thread; + pHalFunc->run_thread = &rtl8188e_start_thread; + pHalFunc->cancel_thread = &rtl8188e_stop_thread; pHalFunc->AntDivBeforeLinkHandler = &AntDivBeforeLink8188E; pHalFunc->AntDivCompareHandler = &AntDivCompare8188E; @@ -2503,7 +2079,6 @@ void rtl8188e_set_hal_ops(struct hal_ops *pHalFunc) pHalFunc->read_rfreg = &rtl8188e_PHY_QueryRFReg; pHalFunc->write_rfreg = &rtl8188e_PHY_SetRFReg; - /* Efuse related function */ pHalFunc->EfusePowerSwitch = &rtl8188e_EfusePowerSwitch; pHalFunc->ReadEFuse = &rtl8188e_ReadEFuse; @@ -2528,7 +2103,7 @@ void rtl8188e_set_hal_ops(struct hal_ops *pHalFunc) pHalFunc->hal_notch_filter = &hal_notch_filter_8188e; } -u8 GetEEPROMSize8188E(struct adapter * padapter) +u8 GetEEPROMSize8188E(struct adapter *padapter) { u8 size = 0; u32 cr; @@ -2537,7 +2112,7 @@ u8 GetEEPROMSize8188E(struct adapter * padapter) /* 6: EEPROM used is 93C46, 4: boot from E-Fuse. */ size = (cr & BOOT_FROM_EEPROM) ? 6 : 4; - MSG_88E("EEPROM type is %s\n", size==4 ? "E-FUSE" : "93C46"); + MSG_88E("EEPROM type is %s\n", size == 4 ? "E-FUSE" : "93C46"); return size; } @@ -2547,22 +2122,20 @@ u8 GetEEPROMSize8188E(struct adapter * padapter) /* LLT R/W/Init function */ /* */ /* */ -static s32 _LLTWrite(struct adapter * padapter, u32 address, u32 data) +static s32 _LLTWrite(struct adapter *padapter, u32 address, u32 data) { s32 status = _SUCCESS; s32 count = 0; u32 value = _LLT_INIT_ADDR(address) | _LLT_INIT_DATA(data) | _LLT_OP(_LLT_WRITE_ACCESS); u16 LLTReg = REG_LLT_INIT; - rtw_write32(padapter, LLTReg, value); /* polling */ do { value = rtw_read32(padapter, LLTReg); - if (_LLT_NO_ACTIVE == _LLT_OP_VALUE(value)) { + if (_LLT_NO_ACTIVE == _LLT_OP_VALUE(value)) break; - } if (count > POLLING_LLT_THRESHOLD) { RT_TRACE(_module_hal_init_c_, _drv_err_, ("Failed to polling write LLT done at address %d!\n", address)); @@ -2574,7 +2147,7 @@ static s32 _LLTWrite(struct adapter * padapter, u32 address, u32 data) return status; } -s32 InitLLTTable(struct adapter * padapter, u8 txpktbuf_bndy) +s32 InitLLTTable(struct adapter *padapter, u8 txpktbuf_bndy) { s32 status = _FAIL; u32 i; @@ -2586,25 +2159,22 @@ s32 InitLLTTable(struct adapter * padapter, u8 txpktbuf_bndy) } else { for (i = 0; i < (txpktbuf_bndy - 1); i++) { status = _LLTWrite(padapter, i, i + 1); - if (_SUCCESS != status) { + if (_SUCCESS != status) return status; - } } /* end of list */ status = _LLTWrite(padapter, (txpktbuf_bndy - 1), 0xFF); - if (_SUCCESS != status) { + if (_SUCCESS != status) return status; - } /* Make the other pages as ring buffer */ /* This ring buffer is used as beacon buffer if we config this MAC as two MAC transfer. */ /* Otherwise used as local loopback buffer. */ for (i = txpktbuf_bndy; i < Last_Entry_Of_TxPktBuf; i++) { status = _LLTWrite(padapter, i, (i + 1)); - if (_SUCCESS != status) { + if (_SUCCESS != status) return status; - } } /* Let last entry point to the start entry of ring buffer */ @@ -2618,14 +2188,13 @@ s32 InitLLTTable(struct adapter * padapter, u8 txpktbuf_bndy) } void -Hal_InitPGData88E(struct adapter * padapter) +Hal_InitPGData88E(struct adapter *padapter) { struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); u32 i; u16 value16; - if (false == pEEPROM->bautoload_fail_flag) - { /* autoload OK. */ + if (!pEEPROM->bautoload_fail_flag) { /* autoload OK. */ if (!is_boot_from_eeprom(padapter)) { /* Read EFUSE real map to shadow. */ EFUSE_ShadowMapUpdate(padapter, EFUSE_WIFI, false); @@ -2640,177 +2209,141 @@ Hal_InitPGData88E(struct adapter * padapter) void Hal_EfuseParseIDCode88E( - struct adapter * padapter, - u8 *hwinfo + struct adapter *padapter, + u8 *hwinfo ) { struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); u16 EEPROMId; - /* Checl 0x8129 again for making sure autoload status!! */ EEPROMId = le16_to_cpu(*((__le16 *)hwinfo)); - if (EEPROMId != RTL_EEPROM_ID) - { + if (EEPROMId != RTL_EEPROM_ID) { DBG_88E("EEPROM ID(%#x) is invalid!!\n", EEPROMId); pEEPROM->bautoload_fail_flag = true; - } - else - { + } else { pEEPROM->bautoload_fail_flag = false; } - DBG_88E("EEPROM ID=0x%04x\n", EEPROMId); + DBG_88E("EEPROM ID = 0x%04x\n", EEPROMId); } static void Hal_EEValueCheck( - u8 EEType, - void * pInValue, - void * pOutValue + u8 EEType, + void *pInValue, + void *pOutValue ) { - switch (EEType) - { - case EETYPE_TX_PWR: - { - s8 *pIn, *pOut; - pIn = (u8*)pInValue; - pOut = (u8*)pOutValue; - if (*pIn >= 0 && *pIn <= 63) { - *pOut = *pIn; - } else { - RT_TRACE(_module_hci_hal_init_c_, _drv_err_, ("EETYPE_TX_PWR, value=%d is invalid, set to default=0x%x\n", - *pIn, EEPROM_Default_TxPowerLevel)); - *pOut = EEPROM_Default_TxPowerLevel; - } + switch (EEType) { + case EETYPE_TX_PWR: + { + s8 *pIn, *pOut; + pIn = (u8 *)pInValue; + pOut = (u8 *)pOutValue; + if (*pIn >= 0 && *pIn <= 63) { + *pOut = *pIn; + } else { + RT_TRACE(_module_hci_hal_init_c_, _drv_err_, ("EETYPE_TX_PWR, value =%d is invalid, set to default = 0x%x\n", + *pIn, EEPROM_Default_TxPowerLevel)); + *pOut = EEPROM_Default_TxPowerLevel; } - break; - default: - break; + } + break; + default: + break; } } -static void -Hal_ReadPowerValueFromPROM_8188E( - struct txpowerinfo24g *pwrInfo24G, - u8* PROMContent, - bool AutoLoadFail - ) +static void Hal_ReadPowerValueFromPROM_8188E(struct txpowerinfo24g *pwrInfo24G, u8 *PROMContent, bool AutoLoadFail) { - u32 rfPath, eeAddr=EEPROM_TX_PWR_INX_88E, group,TxCount=0; + u32 rfPath, eeAddr = EEPROM_TX_PWR_INX_88E, group, TxCount = 0; _rtw_memset(pwrInfo24G, 0, sizeof(struct txpowerinfo24g)); - if (AutoLoadFail) - { - for (rfPath = 0 ; rfPath < MAX_RF_PATH ; rfPath++) - { + if (AutoLoadFail) { + for (rfPath = 0; rfPath < MAX_RF_PATH; rfPath++) { /* 2.4G default value */ - for (group = 0 ; group < MAX_CHNL_GROUP_24G; group++) - { + for (group = 0; group < MAX_CHNL_GROUP_24G; group++) { pwrInfo24G->IndexCCK_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX; pwrInfo24G->IndexBW40_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX; } - for (TxCount=0;TxCountBW20_Diff[rfPath][0] = EEPROM_DEFAULT_24G_HT20_DIFF; - pwrInfo24G->OFDM_Diff[rfPath][0] = EEPROM_DEFAULT_24G_OFDM_DIFF; - } - else - { - pwrInfo24G->BW20_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; - pwrInfo24G->BW40_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; + for (TxCount = 0; TxCount < MAX_TX_COUNT; TxCount++) { + if (TxCount == 0) { + pwrInfo24G->BW20_Diff[rfPath][0] = EEPROM_DEFAULT_24G_HT20_DIFF; + pwrInfo24G->OFDM_Diff[rfPath][0] = EEPROM_DEFAULT_24G_OFDM_DIFF; + } else { + pwrInfo24G->BW20_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; + pwrInfo24G->BW40_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; pwrInfo24G->CCK_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; - pwrInfo24G->OFDM_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; + pwrInfo24G->OFDM_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; } } - - } - - /* pHalData->bNOPG = true; */ return; } - for (rfPath = 0 ; rfPath < MAX_RF_PATH ; rfPath++) - { + for (rfPath = 0; rfPath < MAX_RF_PATH; rfPath++) { /* 2.4G default value */ - for (group = 0 ; group < MAX_CHNL_GROUP_24G; group++) - { + for (group = 0; group < MAX_CHNL_GROUP_24G; group++) { pwrInfo24G->IndexCCK_Base[rfPath][group] = PROMContent[eeAddr++]; if (pwrInfo24G->IndexCCK_Base[rfPath][group] == 0xFF) - { pwrInfo24G->IndexCCK_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX; - } } - for (group = 0 ; group < MAX_CHNL_GROUP_24G-1; group++) - { + for (group = 0; group < MAX_CHNL_GROUP_24G-1; group++) { pwrInfo24G->IndexBW40_Base[rfPath][group] = PROMContent[eeAddr++]; if (pwrInfo24G->IndexBW40_Base[rfPath][group] == 0xFF) pwrInfo24G->IndexBW40_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX; } - for (TxCount=0;TxCountBW40_Diff[rfPath][TxCount] = 0; - if (PROMContent[eeAddr] == 0xFF) - pwrInfo24G->BW20_Diff[rfPath][TxCount] = EEPROM_DEFAULT_24G_HT20_DIFF; - else - { - pwrInfo24G->BW20_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0xf0)>>4; + if (PROMContent[eeAddr] == 0xFF) { + pwrInfo24G->BW20_Diff[rfPath][TxCount] = EEPROM_DEFAULT_24G_HT20_DIFF; + } else { + pwrInfo24G->BW20_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0xf0)>>4; if (pwrInfo24G->BW20_Diff[rfPath][TxCount] & BIT3) /* 4bit sign number to 8 bit sign number */ pwrInfo24G->BW20_Diff[rfPath][TxCount] |= 0xF0; } - if (PROMContent[eeAddr] == 0xFF) + if (PROMContent[eeAddr] == 0xFF) { pwrInfo24G->OFDM_Diff[rfPath][TxCount] = EEPROM_DEFAULT_24G_OFDM_DIFF; - else - { + } else { pwrInfo24G->OFDM_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0x0f); if (pwrInfo24G->OFDM_Diff[rfPath][TxCount] & BIT3) /* 4bit sign number to 8 bit sign number */ pwrInfo24G->OFDM_Diff[rfPath][TxCount] |= 0xF0; } pwrInfo24G->CCK_Diff[rfPath][TxCount] = 0; eeAddr++; - } - else - { - if (PROMContent[eeAddr] == 0xFF) + } else { + if (PROMContent[eeAddr] == 0xFF) { pwrInfo24G->BW40_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; - else - { + } else { pwrInfo24G->BW40_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0xf0)>>4; if (pwrInfo24G->BW40_Diff[rfPath][TxCount] & BIT3) /* 4bit sign number to 8 bit sign number */ pwrInfo24G->BW40_Diff[rfPath][TxCount] |= 0xF0; } - if (PROMContent[eeAddr] == 0xFF) + if (PROMContent[eeAddr] == 0xFF) { pwrInfo24G->BW20_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; - else - { + } else { pwrInfo24G->BW20_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0x0f); if (pwrInfo24G->BW20_Diff[rfPath][TxCount] & BIT3) /* 4bit sign number to 8 bit sign number */ pwrInfo24G->BW20_Diff[rfPath][TxCount] |= 0xF0; } eeAddr++; - if (PROMContent[eeAddr] == 0xFF) - pwrInfo24G->OFDM_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; - else - { + if (PROMContent[eeAddr] == 0xFF) { + pwrInfo24G->OFDM_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; + } else { pwrInfo24G->OFDM_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0xf0)>>4; if (pwrInfo24G->OFDM_Diff[rfPath][TxCount] & BIT3) /* 4bit sign number to 8 bit sign number */ pwrInfo24G->OFDM_Diff[rfPath][TxCount] |= 0xF0; } - if (PROMContent[eeAddr] == 0xFF) + if (PROMContent[eeAddr] == 0xFF) { pwrInfo24G->CCK_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; - else - { + } else { pwrInfo24G->CCK_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0x0f); if (pwrInfo24G->CCK_Diff[rfPath][TxCount] & BIT3) /* 4bit sign number to 8 bit sign number */ pwrInfo24G->CCK_Diff[rfPath][TxCount] |= 0xF0; @@ -2818,18 +2351,12 @@ Hal_ReadPowerValueFromPROM_8188E( eeAddr++; } } - } - - } -static u8 -Hal_GetChnlGroup( - u8 chnl - ) +static u8 Hal_GetChnlGroup(u8 chnl) { - u8 group=0; + u8 group = 0; if (chnl < 3) /* Cjanel 1-3 */ group = 0; @@ -2842,192 +2369,153 @@ Hal_GetChnlGroup( } static u8 Hal_GetChnlGroup88E(u8 chnl, u8 *pGroup) { - u8 bIn24G=true; + u8 bIn24G = true; - if (chnl<=14) { - bIn24G=true; + if (chnl <= 14) { + bIn24G = true; if (chnl < 3) /* Chanel 1-2 */ *pGroup = 0; else if (chnl < 6) /* Channel 3-5 */ *pGroup = 1; - else if (chnl <9) /* Channel 6-8 */ + else if (chnl < 9) /* Channel 6-8 */ *pGroup = 2; - else if (chnl <12) /* Channel 9-11 */ + else if (chnl < 12) /* Channel 9-11 */ *pGroup = 3; - else if (chnl <14) /* Channel 12-13 */ + else if (chnl < 14) /* Channel 12-13 */ *pGroup = 4; - else if (chnl ==14) /* Channel 14 */ + else if (chnl == 14) /* Channel 14 */ *pGroup = 5; } else { - bIn24G=false; + bIn24G = false; - if (chnl <=40) + if (chnl <= 40) *pGroup = 0; - else if (chnl <=48) + else if (chnl <= 48) *pGroup = 1; - else if (chnl <=56) + else if (chnl <= 56) *pGroup = 2; - else if (chnl <=64) + else if (chnl <= 64) *pGroup = 3; - else if (chnl <=104) + else if (chnl <= 104) *pGroup = 4; - else if (chnl <=112) + else if (chnl <= 112) *pGroup = 5; - else if (chnl <=120) + else if (chnl <= 120) *pGroup = 5; - else if (chnl <=128) + else if (chnl <= 128) *pGroup = 6; - else if (chnl <=136) + else if (chnl <= 136) *pGroup = 7; - else if (chnl <=144) + else if (chnl <= 144) *pGroup = 8; - else if (chnl <=153) + else if (chnl <= 153) *pGroup = 9; - else if (chnl <=161) + else if (chnl <= 161) *pGroup = 10; - else if (chnl <=177) + else if (chnl <= 177) *pGroup = 11; } return bIn24G; } -void Hal_ReadPowerSavingMode88E(struct adapter * padapter, u8 *hwinfo, bool AutoLoadFail) +void Hal_ReadPowerSavingMode88E(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail) { struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; u8 tmpvalue; - if (AutoLoadFail){ + if (AutoLoadFail) { padapter->pwrctrlpriv.bHWPowerdown = false; padapter->pwrctrlpriv.bSupportRemoteWakeup = false; - } - else { - + } else { /* hw power down mode selection , 0:rf-off / 1:power down */ - if (padapter->registrypriv.hwpdn_mode==2) + if (padapter->registrypriv.hwpdn_mode == 2) padapter->pwrctrlpriv.bHWPowerdown = (hwinfo[EEPROM_RF_FEATURE_OPTION_88E] & BIT4); else padapter->pwrctrlpriv.bHWPowerdown = padapter->registrypriv.hwpdn_mode; /* decide hw if support remote wakeup function */ - /* if hw supported, 8051 (SIE) will generate WeakUP signal( D+/D- toggle) when autoresume */ - padapter->pwrctrlpriv.bSupportRemoteWakeup = (hwinfo[EEPROM_USB_OPTIONAL_FUNCTION0] & BIT1)?true :false; + /* if hw supported, 8051 (SIE) will generate WeakUP signal(D+/D- toggle) when autoresume */ + padapter->pwrctrlpriv.bSupportRemoteWakeup = (hwinfo[EEPROM_USB_OPTIONAL_FUNCTION0] & BIT1) ? true : false; - DBG_88E("%s...bHWPwrPindetect(%x)-bHWPowerdown(%x) ,bSupportRemoteWakeup(%x)\n",__func__, - padapter->pwrctrlpriv.bHWPwrPindetect,padapter->pwrctrlpriv.bHWPowerdown ,padapter->pwrctrlpriv.bSupportRemoteWakeup); - - DBG_88E("### PS params=> power_mgnt(%x),usbss_enable(%x) ###\n",padapter->registrypriv.power_mgnt,padapter->registrypriv.usbss_enable); + DBG_88E("%s...bHWPwrPindetect(%x)-bHWPowerdown(%x) , bSupportRemoteWakeup(%x)\n", __func__, + padapter->pwrctrlpriv.bHWPwrPindetect, padapter->pwrctrlpriv.bHWPowerdown , padapter->pwrctrlpriv.bSupportRemoteWakeup); + DBG_88E("### PS params => power_mgnt(%x), usbss_enable(%x) ###\n", padapter->registrypriv.power_mgnt, padapter->registrypriv.usbss_enable); } - } -void -Hal_ReadTxPowerInfo88E( - struct adapter * padapter, - u8* PROMContent, - bool AutoLoadFail - ) +void Hal_ReadTxPowerInfo88E(struct adapter *padapter, u8 *PROMContent, bool AutoLoadFail) { struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); struct txpowerinfo24g pwrInfo24G; - u8 rfPath, ch, group, rfPathMax=1; - u8 pwr, diff,bIn24G,TxCount; + u8 rfPath, ch, group, rfPathMax = 1; + u8 pwr, diff, bIn24G, TxCount; Hal_ReadPowerValueFromPROM_8188E(&pwrInfo24G, PROMContent, AutoLoadFail); if (!AutoLoadFail) pHalData->bTXPowerDataReadFromEEPORM = true; - for (rfPath = 0 ; rfPath < pHalData->NumTotalRFPath ; rfPath++) - { - for (ch = 0 ; ch <= CHANNEL_MAX_NUMBER ; ch++) - { - bIn24G = Hal_GetChnlGroup88E(ch,&group); - if (bIn24G) - { - - pHalData->Index24G_CCK_Base[rfPath][ch]=pwrInfo24G.IndexCCK_Base[rfPath][group]; - - if (ch==14) - pHalData->Index24G_BW40_Base[rfPath][ch]=pwrInfo24G.IndexBW40_Base[rfPath][4]; + for (rfPath = 0; rfPath < pHalData->NumTotalRFPath; rfPath++) { + for (ch = 0; ch <= CHANNEL_MAX_NUMBER; ch++) { + bIn24G = Hal_GetChnlGroup88E(ch, &group); + if (bIn24G) { + pHalData->Index24G_CCK_Base[rfPath][ch] = pwrInfo24G.IndexCCK_Base[rfPath][group]; + if (ch == 14) + pHalData->Index24G_BW40_Base[rfPath][ch] = pwrInfo24G.IndexBW40_Base[rfPath][4]; else - pHalData->Index24G_BW40_Base[rfPath][ch]=pwrInfo24G.IndexBW40_Base[rfPath][group]; + pHalData->Index24G_BW40_Base[rfPath][ch] = pwrInfo24G.IndexBW40_Base[rfPath][group]; } - - if (bIn24G) - { - DBG_88E("======= Path %d, Channel %d =======\n",rfPath,ch ); - DBG_88E("Index24G_CCK_Base[%d][%d] = 0x%x\n",rfPath,ch ,pHalData->Index24G_CCK_Base[rfPath][ch]); - DBG_88E("Index24G_BW40_Base[%d][%d] = 0x%x\n",rfPath,ch ,pHalData->Index24G_BW40_Base[rfPath][ch]); + if (bIn24G) { + DBG_88E("======= Path %d, Channel %d =======\n", rfPath, ch); + DBG_88E("Index24G_CCK_Base[%d][%d] = 0x%x\n", rfPath, ch , pHalData->Index24G_CCK_Base[rfPath][ch]); + DBG_88E("Index24G_BW40_Base[%d][%d] = 0x%x\n", rfPath, ch , pHalData->Index24G_BW40_Base[rfPath][ch]); } } - - for (TxCount=0;TxCountCCK_24G_Diff[rfPath][TxCount]=pwrInfo24G.CCK_Diff[rfPath][TxCount]; - pHalData->OFDM_24G_Diff[rfPath][TxCount]=pwrInfo24G.OFDM_Diff[rfPath][TxCount]; - pHalData->BW20_24G_Diff[rfPath][TxCount]=pwrInfo24G.BW20_Diff[rfPath][TxCount]; - pHalData->BW40_24G_Diff[rfPath][TxCount]=pwrInfo24G.BW40_Diff[rfPath][TxCount]; -#if DBG - DBG_88E("======= TxCount %d =======\n",TxCount ); - DBG_88E("CCK_24G_Diff[%d][%d]= %d\n",rfPath,TxCount,pHalData->CCK_24G_Diff[rfPath][TxCount]); - DBG_88E("OFDM_24G_Diff[%d][%d]= %d\n",rfPath,TxCount,pHalData->OFDM_24G_Diff[rfPath][TxCount]); - DBG_88E("BW20_24G_Diff[%d][%d]= %d\n",rfPath,TxCount,pHalData->BW20_24G_Diff[rfPath][TxCount]); - DBG_88E("BW40_24G_Diff[%d][%d]= %d\n",rfPath,TxCount,pHalData->BW40_24G_Diff[rfPath][TxCount]); -#endif + for (TxCount = 0; TxCount < MAX_TX_COUNT; TxCount++) { + pHalData->CCK_24G_Diff[rfPath][TxCount] = pwrInfo24G.CCK_Diff[rfPath][TxCount]; + pHalData->OFDM_24G_Diff[rfPath][TxCount] = pwrInfo24G.OFDM_Diff[rfPath][TxCount]; + pHalData->BW20_24G_Diff[rfPath][TxCount] = pwrInfo24G.BW20_Diff[rfPath][TxCount]; + pHalData->BW40_24G_Diff[rfPath][TxCount] = pwrInfo24G.BW40_Diff[rfPath][TxCount]; + DBG_88E("======= TxCount %d =======\n", TxCount); + DBG_88E("CCK_24G_Diff[%d][%d] = %d\n", rfPath, TxCount, pHalData->CCK_24G_Diff[rfPath][TxCount]); + DBG_88E("OFDM_24G_Diff[%d][%d] = %d\n", rfPath, TxCount, pHalData->OFDM_24G_Diff[rfPath][TxCount]); + DBG_88E("BW20_24G_Diff[%d][%d] = %d\n", rfPath, TxCount, pHalData->BW20_24G_Diff[rfPath][TxCount]); + DBG_88E("BW40_24G_Diff[%d][%d] = %d\n", rfPath, TxCount, pHalData->BW40_24G_Diff[rfPath][TxCount]); } } - /* 2010/10/19 MH Add Regulator recognize for CU. */ - if (!AutoLoadFail) - { + if (!AutoLoadFail) { pHalData->EEPROMRegulatory = (PROMContent[EEPROM_RF_BOARD_OPTION_88E]&0x7); /* bit0~2 */ if (PROMContent[EEPROM_RF_BOARD_OPTION_88E] == 0xFF) pHalData->EEPROMRegulatory = (EEPROM_DEFAULT_BOARD_OPTION&0x7); /* bit0~2 */ - } - else - { + } else { pHalData->EEPROMRegulatory = 0; } DBG_88E("EEPROMRegulatory = 0x%x\n", pHalData->EEPROMRegulatory); - } - -void -Hal_EfuseParseXtal_8188E( - struct adapter * pAdapter, - u8* hwinfo, - bool AutoLoadFail - ) +void Hal_EfuseParseXtal_8188E(struct adapter *pAdapter, u8 *hwinfo, bool AutoLoadFail) { struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); - if (!AutoLoadFail) - { + if (!AutoLoadFail) { pHalData->CrystalCap = hwinfo[EEPROM_XTAL_88E]; if (pHalData->CrystalCap == 0xFF) pHalData->CrystalCap = EEPROM_Default_CrystalCap_88E; - } - else - { + } else { pHalData->CrystalCap = EEPROM_Default_CrystalCap_88E; } DBG_88E("CrystalCap: 0x%2x\n", pHalData->CrystalCap); } -void -Hal_EfuseParseBoardType88E( - struct adapter * pAdapter, - u8* hwinfo, - bool AutoLoadFail - ) +void Hal_EfuseParseBoardType88E(struct adapter *pAdapter, u8 *hwinfo, bool AutoLoadFail) { - struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); + struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); if (!AutoLoadFail) pHalData->BoardType = ((hwinfo[EEPROM_RF_BOARD_OPTION_88E]&0xE0)>>5); @@ -3036,152 +2524,102 @@ Hal_EfuseParseBoardType88E( DBG_88E("Board Type: 0x%2x\n", pHalData->BoardType); } -void -Hal_EfuseParseEEPROMVer88E( - struct adapter * padapter, - u8* hwinfo, - bool AutoLoadFail - ) +void Hal_EfuseParseEEPROMVer88E(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail) { - struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); + struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); - if (!AutoLoadFail){ + if (!AutoLoadFail) { pHalData->EEPROMVersion = hwinfo[EEPROM_VERSION_88E]; if (pHalData->EEPROMVersion == 0xFF) pHalData->EEPROMVersion = EEPROM_Default_Version; - } - else{ + } else { pHalData->EEPROMVersion = 1; } - RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("Hal_EfuseParseEEPROMVer(), EEVer = %d\n", - pHalData->EEPROMVersion)); + RT_TRACE(_module_hci_hal_init_c_, _drv_info_, + ("Hal_EfuseParseEEPROMVer(), EEVer = %d\n", + pHalData->EEPROMVersion)); } -void -rtl8188e_EfuseParseChnlPlan( - struct adapter * padapter, - u8* hwinfo, - bool AutoLoadFail - ) +void rtl8188e_EfuseParseChnlPlan(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail) { - padapter->mlmepriv.ChannelPlan = hal_com_get_channel_plan( - padapter - , hwinfo?hwinfo[EEPROM_ChannelPlan_88E]:0xFF - , padapter->registrypriv.channel_plan - , RT_CHANNEL_DOMAIN_WORLD_WIDE_13 - , AutoLoadFail - ); + padapter->mlmepriv.ChannelPlan = + hal_com_get_channel_plan(padapter, + hwinfo ? hwinfo[EEPROM_ChannelPlan_88E] : 0xFF, + padapter->registrypriv.channel_plan, + RT_CHANNEL_DOMAIN_WORLD_WIDE_13, AutoLoadFail); DBG_88E("mlmepriv.ChannelPlan = 0x%02x\n", padapter->mlmepriv.ChannelPlan); } -void -Hal_EfuseParseCustomerID88E( - struct adapter * padapter, - u8* hwinfo, - bool AutoLoadFail - ) +void Hal_EfuseParseCustomerID88E(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail) { struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); - if (!AutoLoadFail) - { + if (!AutoLoadFail) { pHalData->EEPROMCustomerID = hwinfo[EEPROM_CUSTOMERID_88E]; - } - else - { + } else { pHalData->EEPROMCustomerID = 0; pHalData->EEPROMSubCustomerID = 0; } DBG_88E("EEPROM Customer ID: 0x%2x\n", pHalData->EEPROMCustomerID); } - -void -Hal_ReadAntennaDiversity88E( - struct adapter * pAdapter, - u8* PROMContent, - bool AutoLoadFail - ) +void Hal_ReadAntennaDiversity88E(struct adapter *pAdapter, u8 *PROMContent, bool AutoLoadFail) { struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); struct registry_priv *registry_par = &pAdapter->registrypriv; - if (!AutoLoadFail) - { + if (!AutoLoadFail) { /* Antenna Diversity setting. */ - if (registry_par->antdiv_cfg == 2)/* 2:By EFUSE */ - { + if (registry_par->antdiv_cfg == 2) { /* 2:By EFUSE */ pHalData->AntDivCfg = (PROMContent[EEPROM_RF_BOARD_OPTION_88E]&0x18)>>3; if (PROMContent[EEPROM_RF_BOARD_OPTION_88E] == 0xFF) pHalData->AntDivCfg = (EEPROM_DEFAULT_BOARD_OPTION&0x18)>>3;; - } - else - { - pHalData->AntDivCfg = registry_par->antdiv_cfg ; /* 0:OFF , 1:ON, 2:By EFUSE */ + } else { + pHalData->AntDivCfg = registry_par->antdiv_cfg; /* 0:OFF , 1:ON, 2:By EFUSE */ } - if (registry_par->antdiv_type == 0)/* If TRxAntDivType is AUTO in advanced setting, use EFUSE value instead. */ - { + if (registry_par->antdiv_type == 0) { + /* If TRxAntDivType is AUTO in advanced setting, use EFUSE value instead. */ pHalData->TRxAntDivType = PROMContent[EEPROM_RF_ANTENNA_OPT_88E]; if (pHalData->TRxAntDivType == 0xFF) pHalData->TRxAntDivType = CG_TRX_HW_ANTDIV; /* For 88EE, 1Tx and 1RxCG are fixed.(1Ant, Tx and RxCG are both on aux port) */ - } - else{ - pHalData->TRxAntDivType = registry_par->antdiv_type ; + } else { + pHalData->TRxAntDivType = registry_par->antdiv_type; } if (pHalData->TRxAntDivType == CG_TRX_HW_ANTDIV || pHalData->TRxAntDivType == CGCS_RX_HW_ANTDIV) pHalData->AntDivCfg = 1; /* 0xC1[3] is ignored. */ - } - else - { + } else { pHalData->AntDivCfg = 0; pHalData->TRxAntDivType = pHalData->TRxAntDivType; /* The value in the driver setting of device manager. */ } - - DBG_88E("EEPROM : AntDivCfg = %x, TRxAntDivType = %x\n",pHalData->AntDivCfg, pHalData->TRxAntDivType); - - + DBG_88E("EEPROM : AntDivCfg = %x, TRxAntDivType = %x\n", pHalData->AntDivCfg, pHalData->TRxAntDivType); } -void -Hal_ReadThermalMeter_88E( - struct adapter * Adapter, - u8* PROMContent, - bool AutoloadFail - ) +void Hal_ReadThermalMeter_88E(struct adapter *Adapter, u8 *PROMContent, bool AutoloadFail) { struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); u1Byte tempval; - /* */ /* ThermalMeter from EEPROM */ - /* */ if (!AutoloadFail) pHalData->EEPROMThermalMeter = PROMContent[EEPROM_THERMAL_METER_88E]; else pHalData->EEPROMThermalMeter = EEPROM_Default_ThermalMeter_88E; - if (pHalData->EEPROMThermalMeter == 0xff || AutoloadFail) - { + if (pHalData->EEPROMThermalMeter == 0xff || AutoloadFail) { pHalData->bAPKThermalMeterIgnore = true; pHalData->EEPROMThermalMeter = EEPROM_Default_ThermalMeter_88E; } - DBG_88E("ThermalMeter = 0x%x\n", pHalData->EEPROMThermalMeter); - } - -void -Hal_InitChannelPlan( - struct adapter * padapter - ) +void Hal_InitChannelPlan(struct adapter *padapter) { } -bool HalDetectPwrDownMode88E(struct adapter * Adapter) +bool HalDetectPwrDownMode88E(struct adapter *Adapter) { u8 tmpvalue = 0; struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); @@ -3191,21 +2629,17 @@ bool HalDetectPwrDownMode88E(struct adapter * Adapter) /* 2010/08/25 MH INF priority > PDN Efuse value. */ if (tmpvalue & BIT(4) && pwrctrlpriv->reg_pdnmode) - { pHalData->pwrdown = true; - } else - { pHalData->pwrdown = false; - } - DBG_88E("HalDetectPwrDownMode(): PDN=%d\n", pHalData->pwrdown); + DBG_88E("HalDetectPwrDownMode(): PDN =%d\n", pHalData->pwrdown); return pHalData->pwrdown; } /* HalDetectPwrDownMode */ #ifdef CONFIG_WOWLAN -void Hal_DetectWoWMode(struct adapter * pAdapter) +void Hal_DetectWoWMode(struct adapter *pAdapter) { pAdapter->pwrctrlpriv.bSupportRemoteWakeup = true; DBG_88E("%s\n", __func__); @@ -3218,14 +2652,10 @@ void Hal_DetectWoWMode(struct adapter * pAdapter) /* This prevents from race condition when setting this register. */ /* The value of pHalData->RegBcnCtrlVal is initialized in HwConfigureRTL8192CE() function. */ -void SetBcnCtrlReg( - struct adapter * padapter, - u8 SetBits, - u8 ClearBits) +void SetBcnCtrlReg(struct adapter *padapter, u8 SetBits, u8 ClearBits) { struct hal_data_8188e *pHalData; - pHalData = GET_HAL_DATA(padapter); pHalData->RegBcnCtrlVal |= SetBits;