1
0
mirror of https://github.com/aircrack-ng/rtl8812au.git synced 2025-01-05 21:56:08 +00:00

Cleanup some code in rtl8814au HAL init

This commit is contained in:
kimocoder 2019-08-24 06:10:41 +02:00
parent 0bb520cbfa
commit 6cde25e625

View File

@ -5381,8 +5381,7 @@ static void hw_var_set_mlme_join(PADAPTER Adapter, u8 variable, u8* val)
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
struct mlme_priv *pmlmepriv = &Adapter->mlmepriv;
if(type == 0) // prepare to join
{
if(type == 0) { // prepare to join
if(check_buddy_mlmeinfo_state(Adapter, WIFI_FW_AP_STATE) &&
check_buddy_fwstate(Adapter, _FW_LINKED))
{
@ -5393,17 +5392,13 @@ static void hw_var_set_mlme_join(PADAPTER Adapter, u8 variable, u8* val)
//rtw_write32(padapter, REG_RCR, rtw_read32(padapter, REG_RCR)|RCR_ADF);
rtw_write16(Adapter, REG_RXFLTMAP2,0xFFFF);
if(check_buddy_mlmeinfo_state(Adapter, WIFI_FW_AP_STATE))
{
if (check_buddy_mlmeinfo_state(Adapter, WIFI_FW_AP_STATE)) {
rtw_write32(Adapter, REG_RCR, rtw_read32(Adapter, REG_RCR)|RCR_CBSSID_BCN);
}
else
{
} else {
rtw_write32(Adapter, REG_RCR, rtw_read32(Adapter, REG_RCR)|RCR_CBSSID_DATA|RCR_CBSSID_BCN);
}
if(check_fwstate(pmlmepriv, WIFI_STATION_STATE) == _TRUE)
{
if(check_fwstate(pmlmepriv, WIFI_STATION_STATE) == _TRUE) {
RetryLimit = (pHalData->CustomerID == RT_CID_CCX) ? 7 : 48;
}
else // Ad-hoc Mode
@ -5411,8 +5406,7 @@ static void hw_var_set_mlme_join(PADAPTER Adapter, u8 variable, u8* val)
RetryLimit = 0x7;
}
}
else if(type == 1) //joinbss_event call back when join res < 0
{
else if (type == 1) { //joinbss_event call back when join res < 0
if (check_buddy_mlmeinfo_state(Adapter, _HW_STATE_NOLINK_))
rtw_write16(Adapter, REG_RXFLTMAP2,0x00);
@ -5435,9 +5429,7 @@ static void hw_var_set_mlme_join(PADAPTER Adapter, u8 variable, u8* val)
else
rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)&(~BIT(4)));
if(check_fwstate(pmlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE))
{
if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE)) {
//fixed beacon issue for 8191su...........
rtw_write8(Adapter,0x542 ,0x02);
RetryLimit = 0x7;
@ -5591,13 +5583,10 @@ u8 SetHwReg8814A(PADAPTER padapter, u8 variable, u8 *pval)
input_b = BrateCfg;
/* apply force and allow mask */
if(pHalData->current_band_type == BAND_ON_2_4G)
{
if(pHalData->current_band_type == BAND_ON_2_4G) {
BrateCfg |= rrsr_2g_force_mask;
BrateCfg &= rrsr_2g_allow_mask;
}
else // 5G
{
} else { // 5G
BrateCfg |= rrsr_5g_force_mask;
BrateCfg &= rrsr_5g_allow_mask;
}
@ -5641,8 +5630,7 @@ u8 SetHwReg8814A(PADAPTER padapter, u8 variable, u8 *pval)
//tsf = pmlmeext->TSFValue - ((u32)pmlmeext->TSFValue % (pmlmeinfo->bcn_interval*1024)) -1024; //us
tsf = pmlmeext->TSFValue - rtw_modular64(pmlmeext->TSFValue, (pmlmeinfo->bcn_interval*1024)) -1024; //us
if(((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE))
{
if(((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) {
//pHalData->RegTxPause |= STOP_BCNQ;BIT(6)
//rtw_write8(padapter, REG_TXPAUSE, (rtw_read8(padapter, REG_TXPAUSE)|BIT(6)));
StopTxBeacon(padapter);
@ -5658,9 +5646,7 @@ u8 SetHwReg8814A(PADAPTER padapter, u8 variable, u8 *pval)
//enable related TSF function
rtw_write8(padapter, REG_BCN_CTRL, rtw_read8(padapter, REG_BCN_CTRL)|BIT(3));
if(((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE))
{
if(((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) {
//pHalData->RegTxPause &= (~STOP_BCNQ);
//rtw_write8(padapter, REG_TXPAUSE, (rtw_read8(padapter, REG_TXPAUSE)&(~BIT(6))));
ResumeTxBeacon(padapter);
@ -5712,17 +5698,13 @@ u8 SetHwReg8814A(PADAPTER padapter, u8 variable, u8 *pval)
u8 type = *(u8*)pval;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
if (type == 0) // prepare to join
{
if (type == 0) { // prepare to join
//enable to rx data frame.Accept all data frame
rtw_write16(padapter, REG_RXFLTMAP2, 0xFFFF);
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == _TRUE)
{
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == _TRUE) {
RetryLimit = (pHalData->CustomerID == RT_CID_CCX) ? 7 : 48;
}
else // Ad-hoc Mode
{
} else { // Ad-hoc Mode
RetryLimit = RL_VAL_AP;
}
}
@ -5737,8 +5719,7 @@ u8 SetHwReg8814A(PADAPTER padapter, u8 variable, u8 *pval)
val8 &= ~BIT(4);
rtw_write8(padapter, REG_BCN_CTRL, val8);
if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE))
{
if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE)) {
RetryLimit = RL_VAL_AP;
}
}
@ -5749,8 +5730,7 @@ u8 SetHwReg8814A(PADAPTER padapter, u8 variable, u8 *pval)
#endif // !CONFIG_CONCURRENT_MODE
#ifdef CONFIG_BT_COEXIST
if (_TRUE == pHalData->EEPROMBluetoothCoexist)
{
if (_TRUE == pHalData->EEPROMBluetoothCoexist) {
switch (*pval)
{
case 0:
@ -5770,7 +5750,6 @@ u8 SetHwReg8814A(PADAPTER padapter, u8 variable, u8 *pval)
#endif
break;
case HW_VAR_BEACON_INTERVAL:
rtw_write16(padapter, REG_BCN_INTERVAL, *(u16*)pval);
#ifdef CONFIG_INTERRUPT_BASED_TXBCN_EARLY_INT
@ -5783,8 +5762,7 @@ u8 SetHwReg8814A(PADAPTER padapter, u8 variable, u8 *pval)
pmlmeinfo = &pmlmeext->mlmext_info;
bcn_interval = *((u16*)pval);
if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)
{
if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) {
RTW_INFO("%s==> bcn_interval:%d, eraly_int:%d\n", __FUNCTION__, bcn_interval, bcn_interval>>1);
rtw_write8(padapter, REG_DRVERLYINT, bcn_interval>>1);// 50ms for sdio
}
@ -5826,16 +5804,12 @@ u8 SetHwReg8814A(PADAPTER padapter, u8 variable, u8 *pval)
u32 ulContent = 0;
u32 ulEncAlgo = CAM_AES;
for (i=0; i<CAM_CONTENT_COUNT; i++)
{
for (i=0; i<CAM_CONTENT_COUNT; i++) {
// filled id in CAM config 2 byte
if (i == 0)
{
if (i == 0) {
ulContent |= (ucIndex & 0x03) | ((u16)(ulEncAlgo)<<2);
//ulContent |= CAM_VALID;
}
else
{
} else {
ulContent = 0;
}
// polling bit, and No Write enable, and address
@ -5991,8 +5965,7 @@ u8 SetHwReg8814A(PADAPTER padapter, u8 variable, u8 *pval)
// keep sn
rtw_store_all_sta_hwseq(padapter);
if (pwrpriv->bkeepfwalive != _TRUE)
{
if (pwrpriv->bkeepfwalive != _TRUE) {
// RX DMA stop
val32 = rtw_read32(padapter, REG_RXPKT_NUM);
val32 |= RW_RELEASE_EN;
@ -6003,8 +5976,7 @@ u8 SetHwReg8814A(PADAPTER padapter, u8 variable, u8 *pval)
if (val32)
break;
} while (--trycnt);
if (trycnt == 0)
{
if (trycnt == 0) {
RTW_INFO("[HW_VAR_FIFO_CLEARN_UP] Stop RX DMA failed......\n");
}
@ -6095,8 +6067,7 @@ u8 SetHwReg8814A(PADAPTER padapter, u8 variable, u8 *pval)
{
u32 usNavUpper = *((u32*)pval);
if (usNavUpper > HAL_NAV_UPPER_UNIT * 0xFF)
{
if (usNavUpper > HAL_NAV_UPPER_UNIT * 0xFF) {
RTW_INFO("%s: [HW_VAR_NAV_UPPER] set value(0x%08X us) is larger than (%d * 0xFF)!\n",
__FUNCTION__, usNavUpper, HAL_NAV_UPPER_UNIT);
break;
@ -6111,8 +6082,7 @@ u8 SetHwReg8814A(PADAPTER padapter, u8 variable, u8 *pval)
case HW_VAR_BCN_VALID:
#ifdef CONFIG_CONCURRENT_MODE
if (padapter->iface_type == IFACE_PORT1)
{
if (padapter->iface_type == IFACE_PORT1) {
/* BCN_VALID, BIT31 of REG_FIFOPAGE_CTRL_2_8814A, write 1 to clear, Clear by sw */
val8 = rtw_read8(padapter, REG_FIFOPAGE_CTRL_2_8814A+3);
val8 |= BIT(7);
@ -6131,8 +6101,7 @@ u8 SetHwReg8814A(PADAPTER padapter, u8 variable, u8 *pval)
case HW_VAR_DL_BCN_SEL:
#if 0 /* for MBSSID, so far we don't need this */
#ifdef CONFIG_CONCURRENT_MODE
if (IS_HARDWARE_TYPE_8821(padapter) && padapter->iface_type == IFACE_PORT1)
{
if (IS_HARDWARE_TYPE_8821(padapter) && padapter->iface_type == IFACE_PORT1) {
// SW_BCN_SEL - Port1
val8 = rtw_read8(padapter, REG_AUTO_LLT_8814A);
val8 |= BIT(2);
@ -6202,10 +6171,8 @@ u8 SetHwReg8814A(PADAPTER padapter, u8 variable, u8 *pval)
break;
case HW_VAR_DL_RSVD_PAGE:
#ifdef CONFIG_BT_COEXIST
if (pHalData->EEPROMBluetoothCoexist == 1)
{
if (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) == _TRUE)
{
if (pHalData->EEPROMBluetoothCoexist == 1) {
if (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) == _TRUE) {
rtl8814a_download_BTCoex_AP_mode_rsvd_page(padapter);
}
}
@ -6261,7 +6228,6 @@ u8 SetHwReg8814A(PADAPTER padapter, u8 variable, u8 *pval)
#endif/*#if (BEAMFORMING_SUPPORT == 1) - for PHYDM TxBF*/
#endif/*#ifdef CONFIG_BEAMFORMING*/
#ifdef CONFIG_GPIO_WAKEUP
case HW_SET_GPIO_WL_CTRL:
{
@ -6366,16 +6332,14 @@ void GetHwReg8814A(PADAPTER padapter, u8 variable, u8 *pval)
pHalData = GET_HAL_DATA(padapter);
podmpriv = &pHalData->odmpriv;
switch (variable)
{
switch (variable) {
case HW_VAR_TXPAUSE:
*pval = rtw_read8(padapter, REG_TXPAUSE);
break;
case HW_VAR_BCN_VALID:
#ifdef CONFIG_CONCURRENT_MODE
if (padapter->iface_type == IFACE_PORT1)
{
if (padapter->iface_type == IFACE_PORT1) {
/* BCN_VALID, BIT31 of REG_FIFOPAGE_CTRL_2_8814A, write 1 to clear */
val8 = rtw_read8(padapter, REG_FIFOPAGE_CTRL_2_8814A+3);
*pval = (BIT(7) & val8) ? _TRUE:_FALSE;
@ -6391,22 +6355,20 @@ void GetHwReg8814A(PADAPTER padapter, u8 variable, u8 *pval)
case HW_VAR_FWLPS_RF_ON:
//When we halt NIC, we should check if FW LPS is leave.
if(adapter_to_pwrctl(padapter)->rf_pwrstate == rf_off)
{
if (adapter_to_pwrctl(padapter)->rf_pwrstate == rf_off) {
// If it is in HW/SW Radio OFF or IPS state, we do not check Fw LPS Leave,
// because Fw is unload.
*pval = _TRUE;
}
else
{
} else {
u32 valRCR;
valRCR = rtw_read32(padapter, REG_RCR);
valRCR &= 0x00070000;
if(valRCR)
if (valRCR) {
*pval = _FALSE;
else
} else {
*pval = _TRUE;
}
}
break;
@ -6449,12 +6411,10 @@ u8 SetHalDefVar8814A(PADAPTER padapter, HAL_DEF_VARIABLE variable, void *pval)
PHAL_DATA_TYPE pHalData;
u8 bResult;
pHalData = GET_HAL_DATA(padapter);
bResult = _SUCCESS;
switch (variable)
{
switch (variable) {
case HAL_DEF_EFUSE_BYTES:
pHalData->EfuseUsedBytes = *((u16*)pval);
break;
@ -6478,13 +6438,10 @@ u8 GetHalDefVar8814A(PADAPTER padapter, HAL_DEF_VARIABLE variable, void *pval)
PHAL_DATA_TYPE pHalData;
u8 bResult;
pHalData = GET_HAL_DATA(padapter);
bResult = _SUCCESS;
switch (variable)
{
switch (variable) {
#ifdef CONFIG_ANTENNA_DIVERSITY
case HAL_DEF_IS_SUPPORT_ANT_DIV:
@ -6604,12 +6561,9 @@ u8 GetHalDefVar8814A(PADAPTER padapter, HAL_DEF_VARIABLE variable, void *pval)
break;
case HAL_DEF_TX_PAGE_BOUNDARY:
if (!padapter->registrypriv.wifi_spec)
{
if (!padapter->registrypriv.wifi_spec) {
*(u16*)pval = TX_PAGE_BOUNDARY_8814A;
}
else
{
} else {
*(u16*)pval = WMM_NORMAL_TX_PAGE_BOUNDARY_8814A;
}
break;
@ -6641,7 +6595,6 @@ u8 GetHalDefVar8814A(PADAPTER padapter, HAL_DEF_VARIABLE variable, void *pval)
return bResult;
}
#ifdef CONFIG_BT_COEXIST
void rtl8812a_combo_card_WifiOnlyHwInit(PADAPTER pdapter)
{
@ -6692,7 +6645,6 @@ void rtl8812a_combo_card_WifiOnlyHwInit(PADAPTER pdapter)
rtw_write8(pdapter,0x7, u1Tmp);
}
}
#endif //CONFIG_BT_COEXIST
@ -6731,7 +6683,6 @@ void rtl8814_set_hal_ops(struct hal_ops *pHalFunc)
pHalFunc->read_rfreg = &PHY_QueryRFReg8814A;
pHalFunc->write_rfreg = &PHY_SetRFReg8814A;
// Efuse related function
pHalFunc->EfusePowerSwitch = &rtl8814_EfusePowerSwitch;
pHalFunc->ReadEFuse = &rtl8814_ReadEFuse;
@ -6765,5 +6716,3 @@ void rtl8814_set_hal_ops(struct hal_ops *pHalFunc)
pHalFunc->fw_dl = &FirmwareDownload8814A;
pHalFunc->hal_get_tx_buff_rsvd_page_num = &GetTxBufferRsvdPageNum8814;
}