1 /****************************************************************************** 2 * 3 * Copyright(c) 2009-2013 Realtek Corporation. 4 * 5 * This program is free software; you can redistribute it and/or modify it 6 * under the terms of version 2 of the GNU General Public License as 7 * published by the Free Software Foundation. 8 * 9 * This program is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 * more details. 13 * 14 * The full GNU General Public License is included in this distribution in the 15 * file called LICENSE. 16 * 17 * Contact Information: 18 * wlanfae <wlanfae@realtek.com> 19 * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, 20 * Hsinchu 300, Taiwan. 21 * 22 * Larry Finger <Larry.Finger@lwfinger.net> 23 * 24 *****************************************************************************/ 25 26 #include "../wifi.h" 27 #include "../efuse.h" 28 #include "../base.h" 29 #include "../regd.h" 30 #include "../cam.h" 31 #include "../ps.h" 32 #include "../pci.h" 33 #include "../pwrseqcmd.h" 34 #include "reg.h" 35 #include "def.h" 36 #include "phy.h" 37 #include "dm.h" 38 #include "fw.h" 39 #include "led.h" 40 #include "hw.h" 41 #include "pwrseq.h" 42 43 #define LLT_CONFIG 5 44 45 static void _rtl88ee_set_bcn_ctrl_reg(struct ieee80211_hw *hw, 46 u8 set_bits, u8 clear_bits) 47 { 48 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 49 struct rtl_priv *rtlpriv = rtl_priv(hw); 50 51 rtlpci->reg_bcn_ctrl_val |= set_bits; 52 rtlpci->reg_bcn_ctrl_val &= ~clear_bits; 53 54 rtl_write_byte(rtlpriv, REG_BCN_CTRL, (u8) rtlpci->reg_bcn_ctrl_val); 55 } 56 57 static void _rtl88ee_stop_tx_beacon(struct ieee80211_hw *hw) 58 { 59 struct rtl_priv *rtlpriv = rtl_priv(hw); 60 u8 tmp1byte; 61 62 tmp1byte = rtl_read_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2); 63 rtl_write_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2, tmp1byte & (~BIT(6))); 64 rtl_write_byte(rtlpriv, REG_TBTT_PROHIBIT + 1, 0x64); 65 tmp1byte = rtl_read_byte(rtlpriv, REG_TBTT_PROHIBIT + 2); 66 tmp1byte &= ~(BIT(0)); 67 rtl_write_byte(rtlpriv, REG_TBTT_PROHIBIT + 2, tmp1byte); 68 } 69 70 static void _rtl88ee_resume_tx_beacon(struct ieee80211_hw *hw) 71 { 72 struct rtl_priv *rtlpriv = rtl_priv(hw); 73 u8 tmp1byte; 74 75 tmp1byte = rtl_read_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2); 76 rtl_write_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2, tmp1byte | BIT(6)); 77 rtl_write_byte(rtlpriv, REG_TBTT_PROHIBIT + 1, 0xff); 78 tmp1byte = rtl_read_byte(rtlpriv, REG_TBTT_PROHIBIT + 2); 79 tmp1byte |= BIT(0); 80 rtl_write_byte(rtlpriv, REG_TBTT_PROHIBIT + 2, tmp1byte); 81 } 82 83 static void _rtl88ee_enable_bcn_sub_func(struct ieee80211_hw *hw) 84 { 85 _rtl88ee_set_bcn_ctrl_reg(hw, 0, BIT(1)); 86 } 87 88 static void _rtl88ee_return_beacon_queue_skb(struct ieee80211_hw *hw) 89 { 90 struct rtl_priv *rtlpriv = rtl_priv(hw); 91 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 92 struct rtl8192_tx_ring *ring = &rtlpci->tx_ring[BEACON_QUEUE]; 93 unsigned long flags; 94 95 spin_lock_irqsave(&rtlpriv->locks.irq_th_lock, flags); 96 while (skb_queue_len(&ring->queue)) { 97 struct rtl_tx_desc *entry = &ring->desc[ring->idx]; 98 struct sk_buff *skb = __skb_dequeue(&ring->queue); 99 100 pci_unmap_single(rtlpci->pdev, 101 rtlpriv->cfg->ops->get_desc( 102 hw, 103 (u8 *)entry, true, HW_DESC_TXBUFF_ADDR), 104 skb->len, PCI_DMA_TODEVICE); 105 kfree_skb(skb); 106 ring->idx = (ring->idx + 1) % ring->entries; 107 } 108 spin_unlock_irqrestore(&rtlpriv->locks.irq_th_lock, flags); 109 } 110 111 static void _rtl88ee_disable_bcn_sub_func(struct ieee80211_hw *hw) 112 { 113 _rtl88ee_set_bcn_ctrl_reg(hw, BIT(1), 0); 114 } 115 116 static void _rtl88ee_set_fw_clock_on(struct ieee80211_hw *hw, 117 u8 rpwm_val, bool b_need_turn_off_ckk) 118 { 119 struct rtl_priv *rtlpriv = rtl_priv(hw); 120 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 121 bool b_support_remote_wake_up; 122 u32 count = 0, isr_regaddr, content; 123 bool schedule_timer = b_need_turn_off_ckk; 124 rtlpriv->cfg->ops->get_hw_reg(hw, HAL_DEF_WOWLAN, 125 (u8 *)(&b_support_remote_wake_up)); 126 127 if (!rtlhal->fw_ready) 128 return; 129 if (!rtlpriv->psc.fw_current_inpsmode) 130 return; 131 132 while (1) { 133 spin_lock_bh(&rtlpriv->locks.fw_ps_lock); 134 if (rtlhal->fw_clk_change_in_progress) { 135 while (rtlhal->fw_clk_change_in_progress) { 136 spin_unlock_bh(&rtlpriv->locks.fw_ps_lock); 137 count++; 138 udelay(100); 139 if (count > 1000) 140 return; 141 spin_lock_bh(&rtlpriv->locks.fw_ps_lock); 142 } 143 spin_unlock_bh(&rtlpriv->locks.fw_ps_lock); 144 } else { 145 rtlhal->fw_clk_change_in_progress = false; 146 spin_unlock_bh(&rtlpriv->locks.fw_ps_lock); 147 break; 148 } 149 } 150 151 if (IS_IN_LOW_POWER_STATE_88E(rtlhal->fw_ps_state)) { 152 rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_SET_RPWM, &rpwm_val); 153 if (FW_PS_IS_ACK(rpwm_val)) { 154 isr_regaddr = REG_HISR; 155 content = rtl_read_dword(rtlpriv, isr_regaddr); 156 while (!(content & IMR_CPWM) && (count < 500)) { 157 udelay(50); 158 count++; 159 content = rtl_read_dword(rtlpriv, isr_regaddr); 160 } 161 162 if (content & IMR_CPWM) { 163 rtl_write_word(rtlpriv, isr_regaddr, 0x0100); 164 rtlhal->fw_ps_state = FW_PS_STATE_RF_ON_88E; 165 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 166 "Receive CPWM INT!!! Set pHalData->FwPSState = %X\n", 167 rtlhal->fw_ps_state); 168 } 169 } 170 171 spin_lock_bh(&rtlpriv->locks.fw_ps_lock); 172 rtlhal->fw_clk_change_in_progress = false; 173 spin_unlock_bh(&rtlpriv->locks.fw_ps_lock); 174 if (schedule_timer) { 175 mod_timer(&rtlpriv->works.fw_clockoff_timer, 176 jiffies + MSECS(10)); 177 } 178 179 } else { 180 spin_lock_bh(&rtlpriv->locks.fw_ps_lock); 181 rtlhal->fw_clk_change_in_progress = false; 182 spin_unlock_bh(&rtlpriv->locks.fw_ps_lock); 183 } 184 } 185 186 static void _rtl88ee_set_fw_clock_off(struct ieee80211_hw *hw, 187 u8 rpwm_val) 188 { 189 struct rtl_priv *rtlpriv = rtl_priv(hw); 190 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 191 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 192 struct rtl8192_tx_ring *ring; 193 enum rf_pwrstate rtstate; 194 bool schedule_timer = false; 195 u8 queue; 196 197 if (!rtlhal->fw_ready) 198 return; 199 if (!rtlpriv->psc.fw_current_inpsmode) 200 return; 201 if (!rtlhal->allow_sw_to_change_hwclc) 202 return; 203 rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_RF_STATE, (u8 *)(&rtstate)); 204 if (rtstate == ERFOFF || rtlpriv->psc.inactive_pwrstate == ERFOFF) 205 return; 206 207 for (queue = 0; queue < RTL_PCI_MAX_TX_QUEUE_COUNT; queue++) { 208 ring = &rtlpci->tx_ring[queue]; 209 if (skb_queue_len(&ring->queue)) { 210 schedule_timer = true; 211 break; 212 } 213 } 214 215 if (schedule_timer) { 216 mod_timer(&rtlpriv->works.fw_clockoff_timer, 217 jiffies + MSECS(10)); 218 return; 219 } 220 221 if (FW_PS_STATE(rtlhal->fw_ps_state) != 222 FW_PS_STATE_RF_OFF_LOW_PWR_88E) { 223 spin_lock_bh(&rtlpriv->locks.fw_ps_lock); 224 if (!rtlhal->fw_clk_change_in_progress) { 225 rtlhal->fw_clk_change_in_progress = true; 226 spin_unlock_bh(&rtlpriv->locks.fw_ps_lock); 227 rtlhal->fw_ps_state = FW_PS_STATE(rpwm_val); 228 rtl_write_word(rtlpriv, REG_HISR, 0x0100); 229 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SET_RPWM, 230 &rpwm_val); 231 spin_lock_bh(&rtlpriv->locks.fw_ps_lock); 232 rtlhal->fw_clk_change_in_progress = false; 233 spin_unlock_bh(&rtlpriv->locks.fw_ps_lock); 234 } else { 235 spin_unlock_bh(&rtlpriv->locks.fw_ps_lock); 236 mod_timer(&rtlpriv->works.fw_clockoff_timer, 237 jiffies + MSECS(10)); 238 } 239 } 240 } 241 242 static void _rtl88ee_set_fw_ps_rf_on(struct ieee80211_hw *hw) 243 { 244 u8 rpwm_val = 0; 245 246 rpwm_val |= (FW_PS_STATE_RF_OFF_88E | FW_PS_ACK); 247 _rtl88ee_set_fw_clock_on(hw, rpwm_val, true); 248 } 249 250 static void _rtl88ee_set_fw_ps_rf_off_low_power(struct ieee80211_hw *hw) 251 { 252 u8 rpwm_val = 0; 253 rpwm_val |= FW_PS_STATE_RF_OFF_LOW_PWR_88E; 254 _rtl88ee_set_fw_clock_off(hw, rpwm_val); 255 } 256 257 void rtl88ee_fw_clk_off_timer_callback(struct timer_list *t) 258 { 259 struct rtl_priv *rtlpriv = from_timer(rtlpriv, t, 260 works.fw_clockoff_timer); 261 struct ieee80211_hw *hw = rtlpriv->hw; 262 263 _rtl88ee_set_fw_ps_rf_off_low_power(hw); 264 } 265 266 static void _rtl88ee_fwlps_leave(struct ieee80211_hw *hw) 267 { 268 struct rtl_priv *rtlpriv = rtl_priv(hw); 269 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); 270 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 271 bool fw_current_inps = false; 272 u8 rpwm_val = 0, fw_pwrmode = FW_PS_ACTIVE_MODE; 273 274 if (ppsc->low_power_enable) { 275 rpwm_val = (FW_PS_STATE_ALL_ON_88E|FW_PS_ACK);/* RF on */ 276 _rtl88ee_set_fw_clock_on(hw, rpwm_val, false); 277 rtlhal->allow_sw_to_change_hwclc = false; 278 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_H2C_FW_PWRMODE, 279 &fw_pwrmode); 280 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_FW_PSMODE_STATUS, 281 (u8 *)(&fw_current_inps)); 282 } else { 283 rpwm_val = FW_PS_STATE_ALL_ON_88E; /* RF on */ 284 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SET_RPWM, &rpwm_val); 285 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_H2C_FW_PWRMODE, 286 &fw_pwrmode); 287 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_FW_PSMODE_STATUS, 288 (u8 *)(&fw_current_inps)); 289 } 290 } 291 292 static void _rtl88ee_fwlps_enter(struct ieee80211_hw *hw) 293 { 294 struct rtl_priv *rtlpriv = rtl_priv(hw); 295 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); 296 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 297 bool fw_current_inps = true; 298 u8 rpwm_val; 299 300 if (ppsc->low_power_enable) { 301 rpwm_val = FW_PS_STATE_RF_OFF_LOW_PWR_88E; /* RF off */ 302 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_FW_PSMODE_STATUS, 303 (u8 *)(&fw_current_inps)); 304 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_H2C_FW_PWRMODE, 305 &ppsc->fwctrl_psmode); 306 rtlhal->allow_sw_to_change_hwclc = true; 307 _rtl88ee_set_fw_clock_off(hw, rpwm_val); 308 } else { 309 rpwm_val = FW_PS_STATE_RF_OFF_88E; /* RF off */ 310 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_FW_PSMODE_STATUS, 311 (u8 *)(&fw_current_inps)); 312 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_H2C_FW_PWRMODE, 313 &ppsc->fwctrl_psmode); 314 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SET_RPWM, &rpwm_val); 315 } 316 } 317 318 void rtl88ee_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) 319 { 320 struct rtl_priv *rtlpriv = rtl_priv(hw); 321 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); 322 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 323 324 switch (variable) { 325 case HW_VAR_RCR: 326 *((u32 *)(val)) = rtlpci->receive_config; 327 break; 328 case HW_VAR_RF_STATE: 329 *((enum rf_pwrstate *)(val)) = ppsc->rfpwr_state; 330 break; 331 case HW_VAR_FWLPS_RF_ON:{ 332 enum rf_pwrstate rfstate; 333 u32 val_rcr; 334 335 rtlpriv->cfg->ops->get_hw_reg(hw, 336 HW_VAR_RF_STATE, 337 (u8 *)(&rfstate)); 338 if (rfstate == ERFOFF) { 339 *((bool *)(val)) = true; 340 } else { 341 val_rcr = rtl_read_dword(rtlpriv, REG_RCR); 342 val_rcr &= 0x00070000; 343 if (val_rcr) 344 *((bool *)(val)) = false; 345 else 346 *((bool *)(val)) = true; 347 } 348 break; } 349 case HW_VAR_FW_PSMODE_STATUS: 350 *((bool *)(val)) = ppsc->fw_current_inpsmode; 351 break; 352 case HW_VAR_CORRECT_TSF:{ 353 u64 tsf; 354 u32 *ptsf_low = (u32 *)&tsf; 355 u32 *ptsf_high = ((u32 *)&tsf) + 1; 356 357 *ptsf_high = rtl_read_dword(rtlpriv, (REG_TSFTR + 4)); 358 *ptsf_low = rtl_read_dword(rtlpriv, REG_TSFTR); 359 360 *((u64 *)(val)) = tsf; 361 break; } 362 case HAL_DEF_WOWLAN: 363 break; 364 default: 365 pr_err("switch case %#x not processed\n", variable); 366 break; 367 } 368 } 369 370 void rtl88ee_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) 371 { 372 struct rtl_priv *rtlpriv = rtl_priv(hw); 373 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 374 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 375 struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); 376 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); 377 u8 idx; 378 379 switch (variable) { 380 case HW_VAR_ETHER_ADDR: 381 for (idx = 0; idx < ETH_ALEN; idx++) { 382 rtl_write_byte(rtlpriv, (REG_MACID + idx), 383 val[idx]); 384 } 385 break; 386 case HW_VAR_BASIC_RATE:{ 387 u16 b_rate_cfg = ((u16 *)val)[0]; 388 u8 rate_index = 0; 389 b_rate_cfg = b_rate_cfg & 0x15f; 390 b_rate_cfg |= 0x01; 391 rtl_write_byte(rtlpriv, REG_RRSR, b_rate_cfg & 0xff); 392 rtl_write_byte(rtlpriv, REG_RRSR + 1, 393 (b_rate_cfg >> 8) & 0xff); 394 while (b_rate_cfg > 0x1) { 395 b_rate_cfg = (b_rate_cfg >> 1); 396 rate_index++; 397 } 398 rtl_write_byte(rtlpriv, REG_INIRTS_RATE_SEL, 399 rate_index); 400 break; 401 } 402 case HW_VAR_BSSID: 403 for (idx = 0; idx < ETH_ALEN; idx++) { 404 rtl_write_byte(rtlpriv, (REG_BSSID + idx), 405 val[idx]); 406 } 407 break; 408 case HW_VAR_SIFS: 409 rtl_write_byte(rtlpriv, REG_SIFS_CTX + 1, val[0]); 410 rtl_write_byte(rtlpriv, REG_SIFS_TRX + 1, val[1]); 411 412 rtl_write_byte(rtlpriv, REG_SPEC_SIFS + 1, val[0]); 413 rtl_write_byte(rtlpriv, REG_MAC_SPEC_SIFS + 1, val[0]); 414 415 if (!mac->ht_enable) 416 rtl_write_word(rtlpriv, REG_RESP_SIFS_OFDM, 417 0x0e0e); 418 else 419 rtl_write_word(rtlpriv, REG_RESP_SIFS_OFDM, 420 *((u16 *)val)); 421 break; 422 case HW_VAR_SLOT_TIME:{ 423 u8 e_aci; 424 425 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, 426 "HW_VAR_SLOT_TIME %x\n", val[0]); 427 428 rtl_write_byte(rtlpriv, REG_SLOT, val[0]); 429 430 for (e_aci = 0; e_aci < AC_MAX; e_aci++) { 431 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_AC_PARAM, 432 &e_aci); 433 } 434 break; 435 } 436 case HW_VAR_ACK_PREAMBLE:{ 437 u8 reg_tmp; 438 u8 short_preamble = (bool)*val; 439 reg_tmp = rtl_read_byte(rtlpriv, REG_TRXPTCL_CTL+2); 440 if (short_preamble) { 441 reg_tmp |= 0x02; 442 rtl_write_byte(rtlpriv, REG_TRXPTCL_CTL + 443 2, reg_tmp); 444 } else { 445 reg_tmp |= 0xFD; 446 rtl_write_byte(rtlpriv, REG_TRXPTCL_CTL + 447 2, reg_tmp); 448 } 449 break; } 450 case HW_VAR_WPA_CONFIG: 451 rtl_write_byte(rtlpriv, REG_SECCFG, *val); 452 break; 453 case HW_VAR_AMPDU_MIN_SPACE:{ 454 u8 min_spacing_to_set; 455 u8 sec_min_space; 456 457 min_spacing_to_set = *val; 458 if (min_spacing_to_set <= 7) { 459 sec_min_space = 0; 460 461 if (min_spacing_to_set < sec_min_space) 462 min_spacing_to_set = sec_min_space; 463 464 mac->min_space_cfg = ((mac->min_space_cfg & 465 0xf8) | 466 min_spacing_to_set); 467 468 *val = min_spacing_to_set; 469 470 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, 471 "Set HW_VAR_AMPDU_MIN_SPACE: %#x\n", 472 mac->min_space_cfg); 473 474 rtl_write_byte(rtlpriv, REG_AMPDU_MIN_SPACE, 475 mac->min_space_cfg); 476 } 477 break; } 478 case HW_VAR_SHORTGI_DENSITY:{ 479 u8 density_to_set; 480 481 density_to_set = *val; 482 mac->min_space_cfg |= (density_to_set << 3); 483 484 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, 485 "Set HW_VAR_SHORTGI_DENSITY: %#x\n", 486 mac->min_space_cfg); 487 488 rtl_write_byte(rtlpriv, REG_AMPDU_MIN_SPACE, 489 mac->min_space_cfg); 490 break; 491 } 492 case HW_VAR_AMPDU_FACTOR:{ 493 u8 regtoset_normal[4] = { 0x41, 0xa8, 0x72, 0xb9 }; 494 u8 factor_toset; 495 u8 *p_regtoset = NULL; 496 u8 index = 0; 497 498 p_regtoset = regtoset_normal; 499 500 factor_toset = *val; 501 if (factor_toset <= 3) { 502 factor_toset = (1 << (factor_toset + 2)); 503 if (factor_toset > 0xf) 504 factor_toset = 0xf; 505 506 for (index = 0; index < 4; index++) { 507 if ((p_regtoset[index] & 0xf0) > 508 (factor_toset << 4)) 509 p_regtoset[index] = 510 (p_regtoset[index] & 0x0f) | 511 (factor_toset << 4); 512 513 if ((p_regtoset[index] & 0x0f) > 514 factor_toset) 515 p_regtoset[index] = 516 (p_regtoset[index] & 0xf0) | 517 (factor_toset); 518 519 rtl_write_byte(rtlpriv, 520 (REG_AGGLEN_LMT + index), 521 p_regtoset[index]); 522 523 } 524 525 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, 526 "Set HW_VAR_AMPDU_FACTOR: %#x\n", 527 factor_toset); 528 } 529 break; } 530 case HW_VAR_AC_PARAM:{ 531 u8 e_aci = *val; 532 rtl88e_dm_init_edca_turbo(hw); 533 534 if (rtlpci->acm_method != EACMWAY2_SW) 535 rtlpriv->cfg->ops->set_hw_reg(hw, 536 HW_VAR_ACM_CTRL, 537 &e_aci); 538 break; } 539 case HW_VAR_ACM_CTRL:{ 540 u8 e_aci = *val; 541 union aci_aifsn *p_aci_aifsn = 542 (union aci_aifsn *)(&(mac->ac[0].aifs)); 543 u8 acm = p_aci_aifsn->f.acm; 544 u8 acm_ctrl = rtl_read_byte(rtlpriv, REG_ACMHWCTRL); 545 546 acm_ctrl = acm_ctrl | 547 ((rtlpci->acm_method == 2) ? 0x0 : 0x1); 548 549 if (acm) { 550 switch (e_aci) { 551 case AC0_BE: 552 acm_ctrl |= ACMHW_BEQEN; 553 break; 554 case AC2_VI: 555 acm_ctrl |= ACMHW_VIQEN; 556 break; 557 case AC3_VO: 558 acm_ctrl |= ACMHW_VOQEN; 559 break; 560 default: 561 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 562 "HW_VAR_ACM_CTRL acm set failed: eACI is %d\n", 563 acm); 564 break; 565 } 566 } else { 567 switch (e_aci) { 568 case AC0_BE: 569 acm_ctrl &= (~ACMHW_BEQEN); 570 break; 571 case AC2_VI: 572 acm_ctrl &= (~ACMHW_VIQEN); 573 break; 574 case AC3_VO: 575 acm_ctrl &= (~ACMHW_VOQEN); 576 break; 577 default: 578 pr_err("switch case %#x not processed\n", 579 e_aci); 580 break; 581 } 582 } 583 584 RT_TRACE(rtlpriv, COMP_QOS, DBG_TRACE, 585 "SetHwReg8190pci(): [HW_VAR_ACM_CTRL] Write 0x%X\n", 586 acm_ctrl); 587 rtl_write_byte(rtlpriv, REG_ACMHWCTRL, acm_ctrl); 588 break; } 589 case HW_VAR_RCR: 590 rtl_write_dword(rtlpriv, REG_RCR, ((u32 *)(val))[0]); 591 rtlpci->receive_config = ((u32 *)(val))[0]; 592 break; 593 case HW_VAR_RETRY_LIMIT:{ 594 u8 retry_limit = *val; 595 596 rtl_write_word(rtlpriv, REG_RL, 597 retry_limit << RETRY_LIMIT_SHORT_SHIFT | 598 retry_limit << RETRY_LIMIT_LONG_SHIFT); 599 break; } 600 case HW_VAR_DUAL_TSF_RST: 601 rtl_write_byte(rtlpriv, REG_DUAL_TSF_RST, (BIT(0) | BIT(1))); 602 break; 603 case HW_VAR_EFUSE_BYTES: 604 rtlefuse->efuse_usedbytes = *((u16 *)val); 605 break; 606 case HW_VAR_EFUSE_USAGE: 607 rtlefuse->efuse_usedpercentage = *val; 608 break; 609 case HW_VAR_IO_CMD: 610 rtl88e_phy_set_io_cmd(hw, (*(enum io_type *)val)); 611 break; 612 case HW_VAR_SET_RPWM:{ 613 u8 rpwm_val; 614 615 rpwm_val = rtl_read_byte(rtlpriv, REG_PCIE_HRPWM); 616 udelay(1); 617 618 if (rpwm_val & BIT(7)) { 619 rtl_write_byte(rtlpriv, REG_PCIE_HRPWM, *val); 620 } else { 621 rtl_write_byte(rtlpriv, REG_PCIE_HRPWM, *val | BIT(7)); 622 } 623 break; } 624 case HW_VAR_H2C_FW_PWRMODE: 625 rtl88e_set_fw_pwrmode_cmd(hw, *val); 626 break; 627 case HW_VAR_FW_PSMODE_STATUS: 628 ppsc->fw_current_inpsmode = *((bool *)val); 629 break; 630 case HW_VAR_RESUME_CLK_ON: 631 _rtl88ee_set_fw_ps_rf_on(hw); 632 break; 633 case HW_VAR_FW_LPS_ACTION:{ 634 bool enter_fwlps = *((bool *)val); 635 636 if (enter_fwlps) 637 _rtl88ee_fwlps_enter(hw); 638 else 639 _rtl88ee_fwlps_leave(hw); 640 641 break; } 642 case HW_VAR_H2C_FW_JOINBSSRPT:{ 643 u8 mstatus = *val; 644 u8 tmp_regcr, tmp_reg422, bcnvalid_reg; 645 u8 count = 0, dlbcn_count = 0; 646 bool b_recover = false; 647 648 if (mstatus == RT_MEDIA_CONNECT) { 649 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_AID, 650 NULL); 651 652 tmp_regcr = rtl_read_byte(rtlpriv, REG_CR + 1); 653 rtl_write_byte(rtlpriv, REG_CR + 1, 654 (tmp_regcr | BIT(0))); 655 656 _rtl88ee_set_bcn_ctrl_reg(hw, 0, BIT(3)); 657 _rtl88ee_set_bcn_ctrl_reg(hw, BIT(4), 0); 658 659 tmp_reg422 = 660 rtl_read_byte(rtlpriv, 661 REG_FWHW_TXQ_CTRL + 2); 662 rtl_write_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2, 663 tmp_reg422 & (~BIT(6))); 664 if (tmp_reg422 & BIT(6)) 665 b_recover = true; 666 667 do { 668 bcnvalid_reg = rtl_read_byte(rtlpriv, 669 REG_TDECTRL+2); 670 rtl_write_byte(rtlpriv, REG_TDECTRL+2, 671 (bcnvalid_reg | BIT(0))); 672 _rtl88ee_return_beacon_queue_skb(hw); 673 674 rtl88e_set_fw_rsvdpagepkt(hw, 0); 675 bcnvalid_reg = rtl_read_byte(rtlpriv, 676 REG_TDECTRL+2); 677 count = 0; 678 while (!(bcnvalid_reg & BIT(0)) && count < 20) { 679 count++; 680 udelay(10); 681 bcnvalid_reg = 682 rtl_read_byte(rtlpriv, REG_TDECTRL+2); 683 } 684 dlbcn_count++; 685 } while (!(bcnvalid_reg & BIT(0)) && dlbcn_count < 5); 686 687 if (bcnvalid_reg & BIT(0)) 688 rtl_write_byte(rtlpriv, REG_TDECTRL+2, BIT(0)); 689 690 _rtl88ee_set_bcn_ctrl_reg(hw, BIT(3), 0); 691 _rtl88ee_set_bcn_ctrl_reg(hw, 0, BIT(4)); 692 693 if (b_recover) { 694 rtl_write_byte(rtlpriv, 695 REG_FWHW_TXQ_CTRL + 2, 696 tmp_reg422); 697 } 698 699 rtl_write_byte(rtlpriv, REG_CR + 1, 700 (tmp_regcr & ~(BIT(0)))); 701 } 702 rtl88e_set_fw_joinbss_report_cmd(hw, (*(u8 *)val)); 703 break; } 704 case HW_VAR_H2C_FW_P2P_PS_OFFLOAD: 705 rtl88e_set_p2p_ps_offload_cmd(hw, *val); 706 break; 707 case HW_VAR_AID:{ 708 u16 u2btmp; 709 710 u2btmp = rtl_read_word(rtlpriv, REG_BCN_PSR_RPT); 711 u2btmp &= 0xC000; 712 rtl_write_word(rtlpriv, REG_BCN_PSR_RPT, (u2btmp | 713 mac->assoc_id)); 714 break; } 715 case HW_VAR_CORRECT_TSF:{ 716 u8 btype_ibss = *val; 717 718 if (btype_ibss) 719 _rtl88ee_stop_tx_beacon(hw); 720 721 _rtl88ee_set_bcn_ctrl_reg(hw, 0, BIT(3)); 722 723 rtl_write_dword(rtlpriv, REG_TSFTR, 724 (u32)(mac->tsf & 0xffffffff)); 725 rtl_write_dword(rtlpriv, REG_TSFTR + 4, 726 (u32)((mac->tsf >> 32) & 0xffffffff)); 727 728 _rtl88ee_set_bcn_ctrl_reg(hw, BIT(3), 0); 729 730 if (btype_ibss) 731 _rtl88ee_resume_tx_beacon(hw); 732 break; } 733 case HW_VAR_KEEP_ALIVE: { 734 u8 array[2]; 735 736 array[0] = 0xff; 737 array[1] = *((u8 *)val); 738 rtl88e_fill_h2c_cmd(hw, H2C_88E_KEEP_ALIVE_CTRL, 739 2, array); 740 break; } 741 default: 742 pr_err("switch case %#x not processed\n", variable); 743 break; 744 } 745 } 746 747 static bool _rtl88ee_llt_write(struct ieee80211_hw *hw, u32 address, u32 data) 748 { 749 struct rtl_priv *rtlpriv = rtl_priv(hw); 750 bool status = true; 751 long count = 0; 752 u32 value = _LLT_INIT_ADDR(address) | _LLT_INIT_DATA(data) | 753 _LLT_OP(_LLT_WRITE_ACCESS); 754 755 rtl_write_dword(rtlpriv, REG_LLT_INIT, value); 756 757 do { 758 value = rtl_read_dword(rtlpriv, REG_LLT_INIT); 759 if (_LLT_NO_ACTIVE == _LLT_OP_VALUE(value)) 760 break; 761 762 if (count > POLLING_LLT_THRESHOLD) { 763 pr_err("Failed to polling write LLT done at address %d!\n", 764 address); 765 status = false; 766 break; 767 } 768 } while (++count); 769 770 return status; 771 } 772 773 static bool _rtl88ee_llt_table_init(struct ieee80211_hw *hw) 774 { 775 struct rtl_priv *rtlpriv = rtl_priv(hw); 776 unsigned short i; 777 u8 txpktbuf_bndy; 778 u8 maxpage; 779 bool status; 780 781 maxpage = 0xAF; 782 txpktbuf_bndy = 0xAB; 783 784 rtl_write_byte(rtlpriv, REG_RQPN_NPQ, 0x01); 785 rtl_write_dword(rtlpriv, REG_RQPN, 0x80730d29); 786 787 /*0x2600 MaxRxBuff=10k-max(TxReportSize(64*8), WOLPattern(16*24)) */ 788 rtl_write_dword(rtlpriv, REG_TRXFF_BNDY, (0x25FF0000 | txpktbuf_bndy)); 789 rtl_write_byte(rtlpriv, REG_TDECTRL + 1, txpktbuf_bndy); 790 791 rtl_write_byte(rtlpriv, REG_TXPKTBUF_BCNQ_BDNY, txpktbuf_bndy); 792 rtl_write_byte(rtlpriv, REG_TXPKTBUF_MGQ_BDNY, txpktbuf_bndy); 793 794 rtl_write_byte(rtlpriv, 0x45D, txpktbuf_bndy); 795 rtl_write_byte(rtlpriv, REG_PBP, 0x11); 796 rtl_write_byte(rtlpriv, REG_RX_DRVINFO_SZ, 0x4); 797 798 for (i = 0; i < (txpktbuf_bndy - 1); i++) { 799 status = _rtl88ee_llt_write(hw, i, i + 1); 800 if (true != status) 801 return status; 802 } 803 804 status = _rtl88ee_llt_write(hw, (txpktbuf_bndy - 1), 0xFF); 805 if (true != status) 806 return status; 807 808 for (i = txpktbuf_bndy; i < maxpage; i++) { 809 status = _rtl88ee_llt_write(hw, i, (i + 1)); 810 if (true != status) 811 return status; 812 } 813 814 status = _rtl88ee_llt_write(hw, maxpage, txpktbuf_bndy); 815 if (true != status) 816 return status; 817 818 return true; 819 } 820 821 static void _rtl88ee_gen_refresh_led_state(struct ieee80211_hw *hw) 822 { 823 struct rtl_priv *rtlpriv = rtl_priv(hw); 824 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); 825 struct rtl_led *pled0 = &rtlpriv->ledctl.sw_led0; 826 827 if (rtlpriv->rtlhal.up_first_time) 828 return; 829 830 if (ppsc->rfoff_reason == RF_CHANGE_BY_IPS) 831 rtl88ee_sw_led_on(hw, pled0); 832 else if (ppsc->rfoff_reason == RF_CHANGE_BY_INIT) 833 rtl88ee_sw_led_on(hw, pled0); 834 else 835 rtl88ee_sw_led_off(hw, pled0); 836 } 837 838 static bool _rtl88ee_init_mac(struct ieee80211_hw *hw) 839 { 840 struct rtl_priv *rtlpriv = rtl_priv(hw); 841 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 842 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 843 844 u8 bytetmp; 845 u16 wordtmp; 846 847 /*Disable XTAL OUTPUT for power saving. YJ,add,111206. */ 848 bytetmp = rtl_read_byte(rtlpriv, REG_XCK_OUT_CTRL) & (~BIT(0)); 849 rtl_write_byte(rtlpriv, REG_XCK_OUT_CTRL, bytetmp); 850 /*Auto Power Down to CHIP-off State*/ 851 bytetmp = rtl_read_byte(rtlpriv, REG_APS_FSMCO + 1) & (~BIT(7)); 852 rtl_write_byte(rtlpriv, REG_APS_FSMCO + 1, bytetmp); 853 854 rtl_write_byte(rtlpriv, REG_RSV_CTRL, 0x00); 855 /* HW Power on sequence */ 856 if (!rtl_hal_pwrseqcmdparsing(rtlpriv, PWR_CUT_ALL_MSK, 857 PWR_FAB_ALL_MSK, PWR_INTF_PCI_MSK, 858 RTL8188EE_NIC_ENABLE_FLOW)) { 859 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 860 "init MAC Fail as rtl_hal_pwrseqcmdparsing\n"); 861 return false; 862 } 863 864 bytetmp = rtl_read_byte(rtlpriv, REG_APS_FSMCO) | BIT(4); 865 rtl_write_byte(rtlpriv, REG_APS_FSMCO, bytetmp); 866 867 bytetmp = rtl_read_byte(rtlpriv, REG_PCIE_CTRL_REG+2); 868 rtl_write_byte(rtlpriv, REG_PCIE_CTRL_REG+2, bytetmp|BIT(2)); 869 870 bytetmp = rtl_read_byte(rtlpriv, REG_WATCH_DOG+1); 871 rtl_write_byte(rtlpriv, REG_WATCH_DOG+1, bytetmp|BIT(7)); 872 873 bytetmp = rtl_read_byte(rtlpriv, REG_AFE_XTAL_CTRL_EXT+1); 874 rtl_write_byte(rtlpriv, REG_AFE_XTAL_CTRL_EXT+1, bytetmp|BIT(1)); 875 876 bytetmp = rtl_read_byte(rtlpriv, REG_TX_RPT_CTRL); 877 rtl_write_byte(rtlpriv, REG_TX_RPT_CTRL, bytetmp|BIT(1)|BIT(0)); 878 rtl_write_byte(rtlpriv, REG_TX_RPT_CTRL+1, 2); 879 rtl_write_word(rtlpriv, REG_TX_RPT_TIME, 0xcdf0); 880 881 /*Add for wake up online*/ 882 bytetmp = rtl_read_byte(rtlpriv, REG_SYS_CLKR); 883 884 rtl_write_byte(rtlpriv, REG_SYS_CLKR, bytetmp|BIT(3)); 885 bytetmp = rtl_read_byte(rtlpriv, REG_GPIO_MUXCFG+1); 886 rtl_write_byte(rtlpriv, REG_GPIO_MUXCFG+1, (bytetmp & (~BIT(4)))); 887 rtl_write_byte(rtlpriv, 0x367, 0x80); 888 889 rtl_write_word(rtlpriv, REG_CR, 0x2ff); 890 rtl_write_byte(rtlpriv, REG_CR+1, 0x06); 891 rtl_write_byte(rtlpriv, MSR, 0x00); 892 893 if (!rtlhal->mac_func_enable) { 894 if (_rtl88ee_llt_table_init(hw) == false) { 895 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 896 "LLT table init fail\n"); 897 return false; 898 } 899 } 900 rtl_write_dword(rtlpriv, REG_HISR, 0xffffffff); 901 rtl_write_dword(rtlpriv, REG_HISRE, 0xffffffff); 902 903 wordtmp = rtl_read_word(rtlpriv, REG_TRXDMA_CTRL); 904 wordtmp &= 0xf; 905 wordtmp |= 0xE771; 906 rtl_write_word(rtlpriv, REG_TRXDMA_CTRL, wordtmp); 907 908 rtl_write_dword(rtlpriv, REG_RCR, rtlpci->receive_config); 909 rtl_write_word(rtlpriv, REG_RXFLTMAP2, 0xffff); 910 rtl_write_dword(rtlpriv, REG_TCR, rtlpci->transmit_config); 911 912 rtl_write_dword(rtlpriv, REG_BCNQ_DESA, 913 ((u64) rtlpci->tx_ring[BEACON_QUEUE].dma) & 914 DMA_BIT_MASK(32)); 915 rtl_write_dword(rtlpriv, REG_MGQ_DESA, 916 (u64) rtlpci->tx_ring[MGNT_QUEUE].dma & 917 DMA_BIT_MASK(32)); 918 rtl_write_dword(rtlpriv, REG_VOQ_DESA, 919 (u64) rtlpci->tx_ring[VO_QUEUE].dma & DMA_BIT_MASK(32)); 920 rtl_write_dword(rtlpriv, REG_VIQ_DESA, 921 (u64) rtlpci->tx_ring[VI_QUEUE].dma & DMA_BIT_MASK(32)); 922 rtl_write_dword(rtlpriv, REG_BEQ_DESA, 923 (u64) rtlpci->tx_ring[BE_QUEUE].dma & DMA_BIT_MASK(32)); 924 rtl_write_dword(rtlpriv, REG_BKQ_DESA, 925 (u64) rtlpci->tx_ring[BK_QUEUE].dma & DMA_BIT_MASK(32)); 926 rtl_write_dword(rtlpriv, REG_HQ_DESA, 927 (u64) rtlpci->tx_ring[HIGH_QUEUE].dma & 928 DMA_BIT_MASK(32)); 929 rtl_write_dword(rtlpriv, REG_RX_DESA, 930 (u64) rtlpci->rx_ring[RX_MPDU_QUEUE].dma & 931 DMA_BIT_MASK(32)); 932 933 /* if we want to support 64 bit DMA, we should set it here, 934 * but now we do not support 64 bit DMA 935 */ 936 rtl_write_dword(rtlpriv, REG_INT_MIG, 0); 937 938 rtl_write_dword(rtlpriv, REG_MCUTST_1, 0x0); 939 rtl_write_byte(rtlpriv, REG_PCIE_CTRL_REG+1, 0);/*Enable RX DMA */ 940 941 if (rtlhal->earlymode_enable) {/*Early mode enable*/ 942 bytetmp = rtl_read_byte(rtlpriv, REG_EARLY_MODE_CONTROL); 943 bytetmp |= 0x1f; 944 rtl_write_byte(rtlpriv, REG_EARLY_MODE_CONTROL, bytetmp); 945 rtl_write_byte(rtlpriv, REG_EARLY_MODE_CONTROL+3, 0x81); 946 } 947 _rtl88ee_gen_refresh_led_state(hw); 948 return true; 949 } 950 951 static void _rtl88ee_hw_configure(struct ieee80211_hw *hw) 952 { 953 struct rtl_priv *rtlpriv = rtl_priv(hw); 954 u32 reg_prsr; 955 956 reg_prsr = RATE_ALL_CCK | RATE_ALL_OFDM_AG; 957 958 rtl_write_dword(rtlpriv, REG_RRSR, reg_prsr); 959 rtl_write_byte(rtlpriv, REG_HWSEQ_CTRL, 0xFF); 960 } 961 962 static void _rtl88ee_enable_aspm_back_door(struct ieee80211_hw *hw) 963 { 964 struct rtl_priv *rtlpriv = rtl_priv(hw); 965 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); 966 u8 tmp1byte = 0; 967 u32 tmp4byte = 0, count = 0; 968 969 rtl_write_word(rtlpriv, 0x354, 0x8104); 970 rtl_write_word(rtlpriv, 0x358, 0x24); 971 972 rtl_write_word(rtlpriv, 0x350, 0x70c); 973 rtl_write_byte(rtlpriv, 0x352, 0x2); 974 tmp1byte = rtl_read_byte(rtlpriv, 0x352); 975 count = 0; 976 while (tmp1byte && count < 20) { 977 udelay(10); 978 tmp1byte = rtl_read_byte(rtlpriv, 0x352); 979 count++; 980 } 981 if (0 == tmp1byte) { 982 tmp4byte = rtl_read_dword(rtlpriv, 0x34c); 983 rtl_write_dword(rtlpriv, 0x348, tmp4byte|BIT(31)); 984 rtl_write_word(rtlpriv, 0x350, 0xf70c); 985 rtl_write_byte(rtlpriv, 0x352, 0x1); 986 } 987 988 tmp1byte = rtl_read_byte(rtlpriv, 0x352); 989 count = 0; 990 while (tmp1byte && count < 20) { 991 udelay(10); 992 tmp1byte = rtl_read_byte(rtlpriv, 0x352); 993 count++; 994 } 995 996 rtl_write_word(rtlpriv, 0x350, 0x718); 997 rtl_write_byte(rtlpriv, 0x352, 0x2); 998 tmp1byte = rtl_read_byte(rtlpriv, 0x352); 999 count = 0; 1000 while (tmp1byte && count < 20) { 1001 udelay(10); 1002 tmp1byte = rtl_read_byte(rtlpriv, 0x352); 1003 count++; 1004 } 1005 1006 if (ppsc->support_backdoor || (0 == tmp1byte)) { 1007 tmp4byte = rtl_read_dword(rtlpriv, 0x34c); 1008 rtl_write_dword(rtlpriv, 0x348, tmp4byte|BIT(11)|BIT(12)); 1009 rtl_write_word(rtlpriv, 0x350, 0xf718); 1010 rtl_write_byte(rtlpriv, 0x352, 0x1); 1011 } 1012 1013 tmp1byte = rtl_read_byte(rtlpriv, 0x352); 1014 count = 0; 1015 while (tmp1byte && count < 20) { 1016 udelay(10); 1017 tmp1byte = rtl_read_byte(rtlpriv, 0x352); 1018 count++; 1019 } 1020 } 1021 1022 void rtl88ee_enable_hw_security_config(struct ieee80211_hw *hw) 1023 { 1024 struct rtl_priv *rtlpriv = rtl_priv(hw); 1025 u8 sec_reg_value; 1026 1027 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 1028 "PairwiseEncAlgorithm = %d GroupEncAlgorithm = %d\n", 1029 rtlpriv->sec.pairwise_enc_algorithm, 1030 rtlpriv->sec.group_enc_algorithm); 1031 1032 if (rtlpriv->cfg->mod_params->sw_crypto || rtlpriv->sec.use_sw_sec) { 1033 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 1034 "not open hw encryption\n"); 1035 return; 1036 } 1037 1038 sec_reg_value = SCR_TXENCENABLE | SCR_RXDECENABLE; 1039 1040 if (rtlpriv->sec.use_defaultkey) { 1041 sec_reg_value |= SCR_TXUSEDK; 1042 sec_reg_value |= SCR_RXUSEDK; 1043 } 1044 1045 sec_reg_value |= (SCR_RXBCUSEDK | SCR_TXBCUSEDK); 1046 1047 rtl_write_byte(rtlpriv, REG_CR + 1, 0x02); 1048 1049 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 1050 "The SECR-value %x\n", sec_reg_value); 1051 1052 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_WPA_CONFIG, &sec_reg_value); 1053 } 1054 1055 int rtl88ee_hw_init(struct ieee80211_hw *hw) 1056 { 1057 struct rtl_priv *rtlpriv = rtl_priv(hw); 1058 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 1059 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 1060 struct rtl_phy *rtlphy = &(rtlpriv->phy); 1061 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); 1062 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 1063 struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); 1064 bool rtstatus = true; 1065 int err = 0; 1066 u8 tmp_u1b, u1byte; 1067 unsigned long flags; 1068 1069 rtlpriv->rtlhal.being_init_adapter = true; 1070 /* As this function can take a very long time (up to 350 ms) 1071 * and can be called with irqs disabled, reenable the irqs 1072 * to let the other devices continue being serviced. 1073 * 1074 * It is safe doing so since our own interrupts will only be enabled 1075 * in a subsequent step. 1076 */ 1077 local_save_flags(flags); 1078 local_irq_enable(); 1079 rtlhal->fw_ready = false; 1080 1081 rtlpriv->intf_ops->disable_aspm(hw); 1082 1083 tmp_u1b = rtl_read_byte(rtlpriv, REG_SYS_CLKR+1); 1084 u1byte = rtl_read_byte(rtlpriv, REG_CR); 1085 if ((tmp_u1b & BIT(3)) && (u1byte != 0 && u1byte != 0xEA)) { 1086 rtlhal->mac_func_enable = true; 1087 } else { 1088 rtlhal->mac_func_enable = false; 1089 rtlhal->fw_ps_state = FW_PS_STATE_ALL_ON_88E; 1090 } 1091 1092 rtstatus = _rtl88ee_init_mac(hw); 1093 if (rtstatus != true) { 1094 pr_info("Init MAC failed\n"); 1095 err = 1; 1096 goto exit; 1097 } 1098 1099 err = rtl88e_download_fw(hw, false); 1100 if (err) { 1101 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 1102 "Failed to download FW. Init HW without FW now..\n"); 1103 err = 1; 1104 goto exit; 1105 } 1106 rtlhal->fw_ready = true; 1107 /*fw related variable initialize */ 1108 rtlhal->last_hmeboxnum = 0; 1109 rtlhal->fw_ps_state = FW_PS_STATE_ALL_ON_88E; 1110 rtlhal->fw_clk_change_in_progress = false; 1111 rtlhal->allow_sw_to_change_hwclc = false; 1112 ppsc->fw_current_inpsmode = false; 1113 1114 rtl88e_phy_mac_config(hw); 1115 /* because last function modify RCR, so we update 1116 * rcr var here, or TP will unstable for receive_config 1117 * is wrong, RX RCR_ACRC32 will cause TP unstabel & Rx 1118 * RCR_APP_ICV will cause mac80211 unassoc for cisco 1252 1119 */ 1120 rtlpci->receive_config &= ~(RCR_ACRC32 | RCR_AICV); 1121 rtl_write_dword(rtlpriv, REG_RCR, rtlpci->receive_config); 1122 1123 rtl88e_phy_bb_config(hw); 1124 rtl_set_bbreg(hw, RFPGA0_RFMOD, BCCKEN, 0x1); 1125 rtl_set_bbreg(hw, RFPGA0_RFMOD, BOFDMEN, 0x1); 1126 1127 rtlphy->rf_mode = RF_OP_BY_SW_3WIRE; 1128 rtl88e_phy_rf_config(hw); 1129 1130 rtlphy->rfreg_chnlval[0] = rtl_get_rfreg(hw, (enum radio_path)0, 1131 RF_CHNLBW, RFREG_OFFSET_MASK); 1132 rtlphy->rfreg_chnlval[0] = rtlphy->rfreg_chnlval[0] & 0xfff00fff; 1133 1134 _rtl88ee_hw_configure(hw); 1135 rtl_cam_reset_all_entry(hw); 1136 rtl88ee_enable_hw_security_config(hw); 1137 1138 rtlhal->mac_func_enable = true; 1139 ppsc->rfpwr_state = ERFON; 1140 1141 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ETHER_ADDR, mac->mac_addr); 1142 _rtl88ee_enable_aspm_back_door(hw); 1143 rtlpriv->intf_ops->enable_aspm(hw); 1144 1145 if (ppsc->rfpwr_state == ERFON) { 1146 if ((rtlefuse->antenna_div_type == CGCS_RX_HW_ANTDIV) || 1147 ((rtlefuse->antenna_div_type == CG_TRX_HW_ANTDIV) && 1148 (rtlhal->oem_id == RT_CID_819X_HP))) { 1149 rtl88e_phy_set_rfpath_switch(hw, true); 1150 rtlpriv->dm.fat_table.rx_idle_ant = MAIN_ANT; 1151 } else { 1152 rtl88e_phy_set_rfpath_switch(hw, false); 1153 rtlpriv->dm.fat_table.rx_idle_ant = AUX_ANT; 1154 } 1155 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "rx idle ant %s\n", 1156 (rtlpriv->dm.fat_table.rx_idle_ant == MAIN_ANT) ? 1157 ("MAIN_ANT") : ("AUX_ANT")); 1158 1159 if (rtlphy->iqk_initialized) { 1160 rtl88e_phy_iq_calibrate(hw, true); 1161 } else { 1162 rtl88e_phy_iq_calibrate(hw, false); 1163 rtlphy->iqk_initialized = true; 1164 } 1165 1166 rtl88e_dm_check_txpower_tracking(hw); 1167 rtl88e_phy_lc_calibrate(hw); 1168 } 1169 1170 tmp_u1b = efuse_read_1byte(hw, 0x1FA); 1171 if (!(tmp_u1b & BIT(0))) { 1172 rtl_set_rfreg(hw, RF90_PATH_A, 0x15, 0x0F, 0x05); 1173 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "PA BIAS path A\n"); 1174 } 1175 1176 if (!(tmp_u1b & BIT(4))) { 1177 tmp_u1b = rtl_read_byte(rtlpriv, 0x16); 1178 tmp_u1b &= 0x0F; 1179 rtl_write_byte(rtlpriv, 0x16, tmp_u1b | 0x80); 1180 udelay(10); 1181 rtl_write_byte(rtlpriv, 0x16, tmp_u1b | 0x90); 1182 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "under 1.5V\n"); 1183 } 1184 rtl_write_byte(rtlpriv, REG_NAV_CTRL+2, ((30000+127)/128)); 1185 rtl88e_dm_init(hw); 1186 exit: 1187 local_irq_restore(flags); 1188 rtlpriv->rtlhal.being_init_adapter = false; 1189 return err; 1190 } 1191 1192 static enum version_8188e _rtl88ee_read_chip_version(struct ieee80211_hw *hw) 1193 { 1194 struct rtl_priv *rtlpriv = rtl_priv(hw); 1195 struct rtl_phy *rtlphy = &(rtlpriv->phy); 1196 enum version_8188e version = VERSION_UNKNOWN; 1197 u32 value32; 1198 1199 value32 = rtl_read_dword(rtlpriv, REG_SYS_CFG); 1200 if (value32 & TRP_VAUX_EN) { 1201 version = (enum version_8188e) VERSION_TEST_CHIP_88E; 1202 } else { 1203 version = NORMAL_CHIP; 1204 version = version | ((value32 & TYPE_ID) ? RF_TYPE_2T2R : 0); 1205 version = version | ((value32 & VENDOR_ID) ? 1206 CHIP_VENDOR_UMC : 0); 1207 } 1208 1209 rtlphy->rf_type = RF_1T1R; 1210 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 1211 "Chip RF Type: %s\n", (rtlphy->rf_type == RF_2T2R) ? 1212 "RF_2T2R" : "RF_1T1R"); 1213 1214 return version; 1215 } 1216 1217 static int _rtl88ee_set_media_status(struct ieee80211_hw *hw, 1218 enum nl80211_iftype type) 1219 { 1220 struct rtl_priv *rtlpriv = rtl_priv(hw); 1221 u8 bt_msr = rtl_read_byte(rtlpriv, MSR) & 0xfc; 1222 enum led_ctl_mode ledaction = LED_CTL_NO_LINK; 1223 u8 mode = MSR_NOLINK; 1224 1225 switch (type) { 1226 case NL80211_IFTYPE_UNSPECIFIED: 1227 mode = MSR_NOLINK; 1228 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 1229 "Set Network type to NO LINK!\n"); 1230 break; 1231 case NL80211_IFTYPE_ADHOC: 1232 case NL80211_IFTYPE_MESH_POINT: 1233 mode = MSR_ADHOC; 1234 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 1235 "Set Network type to Ad Hoc!\n"); 1236 break; 1237 case NL80211_IFTYPE_STATION: 1238 mode = MSR_INFRA; 1239 ledaction = LED_CTL_LINK; 1240 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 1241 "Set Network type to STA!\n"); 1242 break; 1243 case NL80211_IFTYPE_AP: 1244 mode = MSR_AP; 1245 ledaction = LED_CTL_LINK; 1246 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 1247 "Set Network type to AP!\n"); 1248 break; 1249 default: 1250 pr_err("Network type %d not support!\n", type); 1251 return 1; 1252 break; 1253 } 1254 1255 /* MSR_INFRA == Link in infrastructure network; 1256 * MSR_ADHOC == Link in ad hoc network; 1257 * Therefore, check link state is necessary. 1258 * 1259 * MSR_AP == AP mode; link state is not cared here. 1260 */ 1261 if (mode != MSR_AP && rtlpriv->mac80211.link_state < MAC80211_LINKED) { 1262 mode = MSR_NOLINK; 1263 ledaction = LED_CTL_NO_LINK; 1264 } 1265 1266 if (mode == MSR_NOLINK || mode == MSR_INFRA) { 1267 _rtl88ee_stop_tx_beacon(hw); 1268 _rtl88ee_enable_bcn_sub_func(hw); 1269 } else if (mode == MSR_ADHOC || mode == MSR_AP) { 1270 _rtl88ee_resume_tx_beacon(hw); 1271 _rtl88ee_disable_bcn_sub_func(hw); 1272 } else { 1273 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 1274 "Set HW_VAR_MEDIA_STATUS: No such media status(%x).\n", 1275 mode); 1276 } 1277 1278 rtl_write_byte(rtlpriv, MSR, bt_msr | mode); 1279 rtlpriv->cfg->ops->led_control(hw, ledaction); 1280 if (mode == MSR_AP) 1281 rtl_write_byte(rtlpriv, REG_BCNTCFG + 1, 0x00); 1282 else 1283 rtl_write_byte(rtlpriv, REG_BCNTCFG + 1, 0x66); 1284 return 0; 1285 } 1286 1287 void rtl88ee_set_check_bssid(struct ieee80211_hw *hw, bool check_bssid) 1288 { 1289 struct rtl_priv *rtlpriv = rtl_priv(hw); 1290 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 1291 u32 reg_rcr = rtlpci->receive_config; 1292 1293 if (rtlpriv->psc.rfpwr_state != ERFON) 1294 return; 1295 1296 if (check_bssid == true) { 1297 reg_rcr |= (RCR_CBSSID_DATA | RCR_CBSSID_BCN); 1298 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RCR, 1299 (u8 *)(®_rcr)); 1300 _rtl88ee_set_bcn_ctrl_reg(hw, 0, BIT(4)); 1301 } else if (check_bssid == false) { 1302 reg_rcr &= (~(RCR_CBSSID_DATA | RCR_CBSSID_BCN)); 1303 _rtl88ee_set_bcn_ctrl_reg(hw, BIT(4), 0); 1304 rtlpriv->cfg->ops->set_hw_reg(hw, 1305 HW_VAR_RCR, (u8 *)(®_rcr)); 1306 } 1307 1308 } 1309 1310 int rtl88ee_set_network_type(struct ieee80211_hw *hw, 1311 enum nl80211_iftype type) 1312 { 1313 struct rtl_priv *rtlpriv = rtl_priv(hw); 1314 1315 if (_rtl88ee_set_media_status(hw, type)) 1316 return -EOPNOTSUPP; 1317 1318 if (rtlpriv->mac80211.link_state == MAC80211_LINKED) { 1319 if (type != NL80211_IFTYPE_AP && 1320 type != NL80211_IFTYPE_MESH_POINT) 1321 rtl88ee_set_check_bssid(hw, true); 1322 } else { 1323 rtl88ee_set_check_bssid(hw, false); 1324 } 1325 1326 return 0; 1327 } 1328 1329 /* don't set REG_EDCA_BE_PARAM here 1330 * because mac80211 will send pkt when scan 1331 */ 1332 void rtl88ee_set_qos(struct ieee80211_hw *hw, int aci) 1333 { 1334 struct rtl_priv *rtlpriv = rtl_priv(hw); 1335 rtl88e_dm_init_edca_turbo(hw); 1336 switch (aci) { 1337 case AC1_BK: 1338 rtl_write_dword(rtlpriv, REG_EDCA_BK_PARAM, 0xa44f); 1339 break; 1340 case AC0_BE: 1341 break; 1342 case AC2_VI: 1343 rtl_write_dword(rtlpriv, REG_EDCA_VI_PARAM, 0x5e4322); 1344 break; 1345 case AC3_VO: 1346 rtl_write_dword(rtlpriv, REG_EDCA_VO_PARAM, 0x2f3222); 1347 break; 1348 default: 1349 WARN_ONCE(true, "rtl8188ee: invalid aci: %d !\n", aci); 1350 break; 1351 } 1352 } 1353 1354 void rtl88ee_enable_interrupt(struct ieee80211_hw *hw) 1355 { 1356 struct rtl_priv *rtlpriv = rtl_priv(hw); 1357 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 1358 1359 rtl_write_dword(rtlpriv, REG_HIMR, 1360 rtlpci->irq_mask[0] & 0xFFFFFFFF); 1361 rtl_write_dword(rtlpriv, REG_HIMRE, 1362 rtlpci->irq_mask[1] & 0xFFFFFFFF); 1363 rtlpci->irq_enabled = true; 1364 /* there are some C2H CMDs have been sent 1365 * before system interrupt is enabled, e.g., C2H, CPWM. 1366 * So we need to clear all C2H events that FW has notified, 1367 * otherwise FW won't schedule any commands anymore. 1368 */ 1369 rtl_write_byte(rtlpriv, REG_C2HEVT_CLEAR, 0); 1370 /*enable system interrupt*/ 1371 rtl_write_dword(rtlpriv, REG_HSIMR, 1372 rtlpci->sys_irq_mask & 0xFFFFFFFF); 1373 } 1374 1375 void rtl88ee_disable_interrupt(struct ieee80211_hw *hw) 1376 { 1377 struct rtl_priv *rtlpriv = rtl_priv(hw); 1378 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 1379 1380 rtl_write_dword(rtlpriv, REG_HIMR, IMR_DISABLED); 1381 rtl_write_dword(rtlpriv, REG_HIMRE, IMR_DISABLED); 1382 rtlpci->irq_enabled = false; 1383 /*synchronize_irq(rtlpci->pdev->irq);*/ 1384 } 1385 1386 static void _rtl88ee_poweroff_adapter(struct ieee80211_hw *hw) 1387 { 1388 struct rtl_priv *rtlpriv = rtl_priv(hw); 1389 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 1390 u8 u1b_tmp; 1391 u32 count = 0; 1392 rtlhal->mac_func_enable = false; 1393 rtlpriv->intf_ops->enable_aspm(hw); 1394 1395 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "POWER OFF adapter\n"); 1396 u1b_tmp = rtl_read_byte(rtlpriv, REG_TX_RPT_CTRL); 1397 rtl_write_byte(rtlpriv, REG_TX_RPT_CTRL, u1b_tmp & (~BIT(1))); 1398 1399 u1b_tmp = rtl_read_byte(rtlpriv, REG_RXDMA_CONTROL); 1400 while (!(u1b_tmp & BIT(1)) && (count++ < 100)) { 1401 udelay(10); 1402 u1b_tmp = rtl_read_byte(rtlpriv, REG_RXDMA_CONTROL); 1403 count++; 1404 } 1405 rtl_write_byte(rtlpriv, REG_PCIE_CTRL_REG+1, 0xFF); 1406 1407 rtl_hal_pwrseqcmdparsing(rtlpriv, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, 1408 PWR_INTF_PCI_MSK, 1409 RTL8188EE_NIC_LPS_ENTER_FLOW); 1410 1411 rtl_write_byte(rtlpriv, REG_RF_CTRL, 0x00); 1412 1413 if ((rtl_read_byte(rtlpriv, REG_MCUFWDL) & BIT(7)) && rtlhal->fw_ready) 1414 rtl88e_firmware_selfreset(hw); 1415 1416 u1b_tmp = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN+1); 1417 rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN + 1, (u1b_tmp & (~BIT(2)))); 1418 rtl_write_byte(rtlpriv, REG_MCUFWDL, 0x00); 1419 1420 u1b_tmp = rtl_read_byte(rtlpriv, REG_32K_CTRL); 1421 rtl_write_byte(rtlpriv, REG_32K_CTRL, (u1b_tmp & (~BIT(0)))); 1422 1423 rtl_hal_pwrseqcmdparsing(rtlpriv, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, 1424 PWR_INTF_PCI_MSK, RTL8188EE_NIC_DISABLE_FLOW); 1425 1426 u1b_tmp = rtl_read_byte(rtlpriv, REG_RSV_CTRL+1); 1427 rtl_write_byte(rtlpriv, REG_RSV_CTRL+1, (u1b_tmp & (~BIT(3)))); 1428 u1b_tmp = rtl_read_byte(rtlpriv, REG_RSV_CTRL+1); 1429 rtl_write_byte(rtlpriv, REG_RSV_CTRL+1, (u1b_tmp | BIT(3))); 1430 1431 rtl_write_byte(rtlpriv, REG_RSV_CTRL, 0x0E); 1432 1433 u1b_tmp = rtl_read_byte(rtlpriv, GPIO_IN); 1434 rtl_write_byte(rtlpriv, GPIO_OUT, u1b_tmp); 1435 rtl_write_byte(rtlpriv, GPIO_IO_SEL, 0x7F); 1436 1437 u1b_tmp = rtl_read_byte(rtlpriv, REG_GPIO_IO_SEL); 1438 rtl_write_byte(rtlpriv, REG_GPIO_IO_SEL, (u1b_tmp << 4) | u1b_tmp); 1439 u1b_tmp = rtl_read_byte(rtlpriv, REG_GPIO_IO_SEL+1); 1440 rtl_write_byte(rtlpriv, REG_GPIO_IO_SEL+1, u1b_tmp | 0x0F); 1441 1442 rtl_write_dword(rtlpriv, REG_GPIO_IO_SEL_2+2, 0x00080808); 1443 } 1444 1445 void rtl88ee_card_disable(struct ieee80211_hw *hw) 1446 { 1447 struct rtl_priv *rtlpriv = rtl_priv(hw); 1448 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); 1449 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 1450 enum nl80211_iftype opmode; 1451 1452 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "RTL8188ee card disable\n"); 1453 1454 mac->link_state = MAC80211_NOLINK; 1455 opmode = NL80211_IFTYPE_UNSPECIFIED; 1456 1457 _rtl88ee_set_media_status(hw, opmode); 1458 1459 if (rtlpriv->rtlhal.driver_is_goingto_unload || 1460 ppsc->rfoff_reason > RF_CHANGE_BY_PS) 1461 rtlpriv->cfg->ops->led_control(hw, LED_CTL_POWER_OFF); 1462 1463 RT_SET_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC); 1464 _rtl88ee_poweroff_adapter(hw); 1465 1466 /* after power off we should do iqk again */ 1467 rtlpriv->phy.iqk_initialized = false; 1468 } 1469 1470 void rtl88ee_interrupt_recognized(struct ieee80211_hw *hw, 1471 struct rtl_int *intvec) 1472 { 1473 struct rtl_priv *rtlpriv = rtl_priv(hw); 1474 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 1475 1476 intvec->inta = rtl_read_dword(rtlpriv, ISR) & rtlpci->irq_mask[0]; 1477 rtl_write_dword(rtlpriv, ISR, intvec->inta); 1478 1479 intvec->intb = rtl_read_dword(rtlpriv, REG_HISRE) & rtlpci->irq_mask[1]; 1480 rtl_write_dword(rtlpriv, REG_HISRE, intvec->intb); 1481 1482 } 1483 1484 void rtl88ee_set_beacon_related_registers(struct ieee80211_hw *hw) 1485 { 1486 struct rtl_priv *rtlpriv = rtl_priv(hw); 1487 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 1488 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 1489 u16 bcn_interval, atim_window; 1490 1491 bcn_interval = mac->beacon_interval; 1492 atim_window = 2; /*FIX MERGE */ 1493 rtl88ee_disable_interrupt(hw); 1494 rtl_write_word(rtlpriv, REG_ATIMWND, atim_window); 1495 rtl_write_word(rtlpriv, REG_BCN_INTERVAL, bcn_interval); 1496 rtl_write_word(rtlpriv, REG_BCNTCFG, 0x660f); 1497 rtl_write_byte(rtlpriv, REG_RXTSF_OFFSET_CCK, 0x18); 1498 rtl_write_byte(rtlpriv, REG_RXTSF_OFFSET_OFDM, 0x18); 1499 rtl_write_byte(rtlpriv, 0x606, 0x30); 1500 rtlpci->reg_bcn_ctrl_val |= BIT(3); 1501 rtl_write_byte(rtlpriv, REG_BCN_CTRL, (u8) rtlpci->reg_bcn_ctrl_val); 1502 /*rtl88ee_enable_interrupt(hw);*/ 1503 } 1504 1505 void rtl88ee_set_beacon_interval(struct ieee80211_hw *hw) 1506 { 1507 struct rtl_priv *rtlpriv = rtl_priv(hw); 1508 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 1509 u16 bcn_interval = mac->beacon_interval; 1510 1511 RT_TRACE(rtlpriv, COMP_BEACON, DBG_DMESG, 1512 "beacon_interval:%d\n", bcn_interval); 1513 /*rtl88ee_disable_interrupt(hw);*/ 1514 rtl_write_word(rtlpriv, REG_BCN_INTERVAL, bcn_interval); 1515 /*rtl88ee_enable_interrupt(hw);*/ 1516 } 1517 1518 void rtl88ee_update_interrupt_mask(struct ieee80211_hw *hw, 1519 u32 add_msr, u32 rm_msr) 1520 { 1521 struct rtl_priv *rtlpriv = rtl_priv(hw); 1522 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 1523 1524 RT_TRACE(rtlpriv, COMP_INTR, DBG_LOUD, 1525 "add_msr:%x, rm_msr:%x\n", add_msr, rm_msr); 1526 1527 if (add_msr) 1528 rtlpci->irq_mask[0] |= add_msr; 1529 if (rm_msr) 1530 rtlpci->irq_mask[0] &= (~rm_msr); 1531 rtl88ee_disable_interrupt(hw); 1532 rtl88ee_enable_interrupt(hw); 1533 } 1534 1535 static u8 _rtl88e_get_chnl_group(u8 chnl) 1536 { 1537 u8 group = 0; 1538 1539 if (chnl < 3) 1540 group = 0; 1541 else if (chnl < 6) 1542 group = 1; 1543 else if (chnl < 9) 1544 group = 2; 1545 else if (chnl < 12) 1546 group = 3; 1547 else if (chnl < 14) 1548 group = 4; 1549 else if (chnl == 14) 1550 group = 5; 1551 1552 return group; 1553 } 1554 1555 static void set_24g_base(struct txpower_info_2g *pwrinfo24g, u32 rfpath) 1556 { 1557 int group, txcnt; 1558 1559 for (group = 0 ; group < MAX_CHNL_GROUP_24G; group++) { 1560 pwrinfo24g->index_cck_base[rfpath][group] = 0x2D; 1561 pwrinfo24g->index_bw40_base[rfpath][group] = 0x2D; 1562 } 1563 for (txcnt = 0; txcnt < MAX_TX_COUNT; txcnt++) { 1564 if (txcnt == 0) { 1565 pwrinfo24g->bw20_diff[rfpath][0] = 0x02; 1566 pwrinfo24g->ofdm_diff[rfpath][0] = 0x04; 1567 } else { 1568 pwrinfo24g->bw20_diff[rfpath][txcnt] = 0xFE; 1569 pwrinfo24g->bw40_diff[rfpath][txcnt] = 0xFE; 1570 pwrinfo24g->cck_diff[rfpath][txcnt] = 0xFE; 1571 pwrinfo24g->ofdm_diff[rfpath][txcnt] = 0xFE; 1572 } 1573 } 1574 } 1575 1576 static void read_power_value_fromprom(struct ieee80211_hw *hw, 1577 struct txpower_info_2g *pwrinfo24g, 1578 struct txpower_info_5g *pwrinfo5g, 1579 bool autoload_fail, u8 *hwinfo) 1580 { 1581 struct rtl_priv *rtlpriv = rtl_priv(hw); 1582 u32 rfpath, eeaddr = EEPROM_TX_PWR_INX, group, txcnt = 0; 1583 1584 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 1585 "hal_ReadPowerValueFromPROM88E():PROMContent[0x%x]=0x%x\n", 1586 (eeaddr+1), hwinfo[eeaddr+1]); 1587 if (0xFF == hwinfo[eeaddr+1]) /*YJ,add,120316*/ 1588 autoload_fail = true; 1589 1590 if (autoload_fail) { 1591 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 1592 "auto load fail : Use Default value!\n"); 1593 for (rfpath = 0 ; rfpath < MAX_RF_PATH ; rfpath++) { 1594 /* 2.4G default value */ 1595 set_24g_base(pwrinfo24g, rfpath); 1596 } 1597 return; 1598 } 1599 1600 for (rfpath = 0 ; rfpath < MAX_RF_PATH ; rfpath++) { 1601 /*2.4G default value*/ 1602 for (group = 0 ; group < MAX_CHNL_GROUP_24G; group++) { 1603 pwrinfo24g->index_cck_base[rfpath][group] = 1604 hwinfo[eeaddr++]; 1605 if (pwrinfo24g->index_cck_base[rfpath][group] == 0xFF) 1606 pwrinfo24g->index_cck_base[rfpath][group] = 1607 0x2D; 1608 } 1609 for (group = 0 ; group < MAX_CHNL_GROUP_24G-1; group++) { 1610 pwrinfo24g->index_bw40_base[rfpath][group] = 1611 hwinfo[eeaddr++]; 1612 if (pwrinfo24g->index_bw40_base[rfpath][group] == 0xFF) 1613 pwrinfo24g->index_bw40_base[rfpath][group] = 1614 0x2D; 1615 } 1616 pwrinfo24g->bw40_diff[rfpath][0] = 0; 1617 if (hwinfo[eeaddr] == 0xFF) { 1618 pwrinfo24g->bw20_diff[rfpath][0] = 0x02; 1619 } else { 1620 pwrinfo24g->bw20_diff[rfpath][0] = 1621 (hwinfo[eeaddr]&0xf0)>>4; 1622 /*bit sign number to 8 bit sign number*/ 1623 if (pwrinfo24g->bw20_diff[rfpath][0] & BIT(3)) 1624 pwrinfo24g->bw20_diff[rfpath][0] |= 0xF0; 1625 } 1626 1627 if (hwinfo[eeaddr] == 0xFF) { 1628 pwrinfo24g->ofdm_diff[rfpath][0] = 0x04; 1629 } else { 1630 pwrinfo24g->ofdm_diff[rfpath][0] = 1631 (hwinfo[eeaddr]&0x0f); 1632 /*bit sign number to 8 bit sign number*/ 1633 if (pwrinfo24g->ofdm_diff[rfpath][0] & BIT(3)) 1634 pwrinfo24g->ofdm_diff[rfpath][0] |= 0xF0; 1635 } 1636 pwrinfo24g->cck_diff[rfpath][0] = 0; 1637 eeaddr++; 1638 for (txcnt = 1; txcnt < MAX_TX_COUNT; txcnt++) { 1639 if (hwinfo[eeaddr] == 0xFF) { 1640 pwrinfo24g->bw40_diff[rfpath][txcnt] = 0xFE; 1641 } else { 1642 pwrinfo24g->bw40_diff[rfpath][txcnt] = 1643 (hwinfo[eeaddr]&0xf0)>>4; 1644 if (pwrinfo24g->bw40_diff[rfpath][txcnt] & 1645 BIT(3)) 1646 pwrinfo24g->bw40_diff[rfpath][txcnt] |= 1647 0xF0; 1648 } 1649 1650 if (hwinfo[eeaddr] == 0xFF) { 1651 pwrinfo24g->bw20_diff[rfpath][txcnt] = 1652 0xFE; 1653 } else { 1654 pwrinfo24g->bw20_diff[rfpath][txcnt] = 1655 (hwinfo[eeaddr]&0x0f); 1656 if (pwrinfo24g->bw20_diff[rfpath][txcnt] & 1657 BIT(3)) 1658 pwrinfo24g->bw20_diff[rfpath][txcnt] |= 1659 0xF0; 1660 } 1661 eeaddr++; 1662 1663 if (hwinfo[eeaddr] == 0xFF) { 1664 pwrinfo24g->ofdm_diff[rfpath][txcnt] = 0xFE; 1665 } else { 1666 pwrinfo24g->ofdm_diff[rfpath][txcnt] = 1667 (hwinfo[eeaddr]&0xf0)>>4; 1668 if (pwrinfo24g->ofdm_diff[rfpath][txcnt] & 1669 BIT(3)) 1670 pwrinfo24g->ofdm_diff[rfpath][txcnt] |= 1671 0xF0; 1672 } 1673 1674 if (hwinfo[eeaddr] == 0xFF) { 1675 pwrinfo24g->cck_diff[rfpath][txcnt] = 0xFE; 1676 } else { 1677 pwrinfo24g->cck_diff[rfpath][txcnt] = 1678 (hwinfo[eeaddr]&0x0f); 1679 if (pwrinfo24g->cck_diff[rfpath][txcnt] & 1680 BIT(3)) 1681 pwrinfo24g->cck_diff[rfpath][txcnt] |= 1682 0xF0; 1683 } 1684 eeaddr++; 1685 } 1686 1687 /*5G default value*/ 1688 for (group = 0 ; group < MAX_CHNL_GROUP_5G; group++) { 1689 pwrinfo5g->index_bw40_base[rfpath][group] = 1690 hwinfo[eeaddr++]; 1691 if (pwrinfo5g->index_bw40_base[rfpath][group] == 0xFF) 1692 pwrinfo5g->index_bw40_base[rfpath][group] = 1693 0xFE; 1694 } 1695 1696 pwrinfo5g->bw40_diff[rfpath][0] = 0; 1697 1698 if (hwinfo[eeaddr] == 0xFF) { 1699 pwrinfo5g->bw20_diff[rfpath][0] = 0; 1700 } else { 1701 pwrinfo5g->bw20_diff[rfpath][0] = 1702 (hwinfo[eeaddr]&0xf0)>>4; 1703 if (pwrinfo5g->bw20_diff[rfpath][0] & BIT(3)) 1704 pwrinfo5g->bw20_diff[rfpath][0] |= 0xF0; 1705 } 1706 1707 if (hwinfo[eeaddr] == 0xFF) { 1708 pwrinfo5g->ofdm_diff[rfpath][0] = 0x04; 1709 } else { 1710 pwrinfo5g->ofdm_diff[rfpath][0] = (hwinfo[eeaddr]&0x0f); 1711 if (pwrinfo5g->ofdm_diff[rfpath][0] & BIT(3)) 1712 pwrinfo5g->ofdm_diff[rfpath][0] |= 0xF0; 1713 } 1714 eeaddr++; 1715 for (txcnt = 1; txcnt < MAX_TX_COUNT; txcnt++) { 1716 if (hwinfo[eeaddr] == 0xFF) { 1717 pwrinfo5g->bw40_diff[rfpath][txcnt] = 0xFE; 1718 } else { 1719 pwrinfo5g->bw40_diff[rfpath][txcnt] = 1720 (hwinfo[eeaddr]&0xf0)>>4; 1721 if (pwrinfo5g->bw40_diff[rfpath][txcnt] & 1722 BIT(3)) 1723 pwrinfo5g->bw40_diff[rfpath][txcnt] |= 1724 0xF0; 1725 } 1726 1727 if (hwinfo[eeaddr] == 0xFF) { 1728 pwrinfo5g->bw20_diff[rfpath][txcnt] = 0xFE; 1729 } else { 1730 pwrinfo5g->bw20_diff[rfpath][txcnt] = 1731 (hwinfo[eeaddr]&0x0f); 1732 if (pwrinfo5g->bw20_diff[rfpath][txcnt] & 1733 BIT(3)) 1734 pwrinfo5g->bw20_diff[rfpath][txcnt] |= 1735 0xF0; 1736 } 1737 eeaddr++; 1738 } 1739 1740 if (hwinfo[eeaddr] == 0xFF) { 1741 pwrinfo5g->ofdm_diff[rfpath][1] = 0xFE; 1742 pwrinfo5g->ofdm_diff[rfpath][2] = 0xFE; 1743 } else { 1744 pwrinfo5g->ofdm_diff[rfpath][1] = 1745 (hwinfo[eeaddr]&0xf0)>>4; 1746 pwrinfo5g->ofdm_diff[rfpath][2] = 1747 (hwinfo[eeaddr]&0x0f); 1748 } 1749 eeaddr++; 1750 1751 if (hwinfo[eeaddr] == 0xFF) 1752 pwrinfo5g->ofdm_diff[rfpath][3] = 0xFE; 1753 else 1754 pwrinfo5g->ofdm_diff[rfpath][3] = (hwinfo[eeaddr]&0x0f); 1755 eeaddr++; 1756 1757 for (txcnt = 1; txcnt < MAX_TX_COUNT; txcnt++) { 1758 if (pwrinfo5g->ofdm_diff[rfpath][txcnt] == 0xFF) 1759 pwrinfo5g->ofdm_diff[rfpath][txcnt] = 0xFE; 1760 else if (pwrinfo5g->ofdm_diff[rfpath][txcnt] & BIT(3)) 1761 pwrinfo5g->ofdm_diff[rfpath][txcnt] |= 0xF0; 1762 } 1763 } 1764 } 1765 1766 static void _rtl88ee_read_txpower_info_from_hwpg(struct ieee80211_hw *hw, 1767 bool autoload_fail, 1768 u8 *hwinfo) 1769 { 1770 struct rtl_priv *rtlpriv = rtl_priv(hw); 1771 struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); 1772 struct txpower_info_2g pwrinfo24g; 1773 struct txpower_info_5g pwrinfo5g; 1774 u8 rf_path, index; 1775 u8 i; 1776 1777 read_power_value_fromprom(hw, &pwrinfo24g, 1778 &pwrinfo5g, autoload_fail, hwinfo); 1779 1780 for (rf_path = 0; rf_path < 2; rf_path++) { 1781 for (i = 0; i < 14; i++) { 1782 index = _rtl88e_get_chnl_group(i+1); 1783 1784 rtlefuse->txpwrlevel_cck[rf_path][i] = 1785 pwrinfo24g.index_cck_base[rf_path][index]; 1786 rtlefuse->txpwrlevel_ht40_1s[rf_path][i] = 1787 pwrinfo24g.index_bw40_base[rf_path][index]; 1788 rtlefuse->txpwr_ht20diff[rf_path][i] = 1789 pwrinfo24g.bw20_diff[rf_path][0]; 1790 rtlefuse->txpwr_legacyhtdiff[rf_path][i] = 1791 pwrinfo24g.ofdm_diff[rf_path][0]; 1792 } 1793 1794 for (i = 0; i < 14; i++) { 1795 RTPRINT(rtlpriv, FINIT, INIT_TXPOWER, 1796 "RF(%d)-Ch(%d) [CCK / HT40_1S ] = [0x%x / 0x%x ]\n", 1797 rf_path, i, 1798 rtlefuse->txpwrlevel_cck[rf_path][i], 1799 rtlefuse->txpwrlevel_ht40_1s[rf_path][i]); 1800 } 1801 } 1802 1803 if (!autoload_fail) 1804 rtlefuse->eeprom_thermalmeter = 1805 hwinfo[EEPROM_THERMAL_METER_88E]; 1806 else 1807 rtlefuse->eeprom_thermalmeter = EEPROM_DEFAULT_THERMALMETER; 1808 1809 if (rtlefuse->eeprom_thermalmeter == 0xff || autoload_fail) { 1810 rtlefuse->apk_thermalmeterignore = true; 1811 rtlefuse->eeprom_thermalmeter = EEPROM_DEFAULT_THERMALMETER; 1812 } 1813 1814 rtlefuse->thermalmeter[0] = rtlefuse->eeprom_thermalmeter; 1815 RTPRINT(rtlpriv, FINIT, INIT_TXPOWER, 1816 "thermalmeter = 0x%x\n", rtlefuse->eeprom_thermalmeter); 1817 1818 if (!autoload_fail) { 1819 rtlefuse->eeprom_regulatory = 1820 hwinfo[EEPROM_RF_BOARD_OPTION_88E] & 0x07;/*bit0~2*/ 1821 if (hwinfo[EEPROM_RF_BOARD_OPTION_88E] == 0xFF) 1822 rtlefuse->eeprom_regulatory = 0; 1823 } else { 1824 rtlefuse->eeprom_regulatory = 0; 1825 } 1826 RTPRINT(rtlpriv, FINIT, INIT_TXPOWER, 1827 "eeprom_regulatory = 0x%x\n", rtlefuse->eeprom_regulatory); 1828 } 1829 1830 static void _rtl88ee_read_adapter_info(struct ieee80211_hw *hw) 1831 { 1832 struct rtl_priv *rtlpriv = rtl_priv(hw); 1833 struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); 1834 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 1835 int params[] = {RTL8188E_EEPROM_ID, EEPROM_VID, EEPROM_DID, 1836 EEPROM_SVID, EEPROM_SMID, EEPROM_MAC_ADDR, 1837 EEPROM_CHANNELPLAN, EEPROM_VERSION, EEPROM_CUSTOMER_ID, 1838 COUNTRY_CODE_WORLD_WIDE_13}; 1839 u8 *hwinfo; 1840 1841 hwinfo = kzalloc(HWSET_MAX_SIZE, GFP_KERNEL); 1842 if (!hwinfo) 1843 return; 1844 1845 if (rtl_get_hwinfo(hw, rtlpriv, HWSET_MAX_SIZE, hwinfo, params)) 1846 goto exit; 1847 1848 if (rtlefuse->eeprom_oemid == 0xFF) 1849 rtlefuse->eeprom_oemid = 0; 1850 1851 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 1852 "EEPROM Customer ID: 0x%2x\n", rtlefuse->eeprom_oemid); 1853 /* set channel plan from efuse */ 1854 rtlefuse->channel_plan = rtlefuse->eeprom_channelplan; 1855 /*tx power*/ 1856 _rtl88ee_read_txpower_info_from_hwpg(hw, 1857 rtlefuse->autoload_failflag, 1858 hwinfo); 1859 rtlefuse->txpwr_fromeprom = true; 1860 1861 rtl8188ee_read_bt_coexist_info_from_hwpg(hw, 1862 rtlefuse->autoload_failflag, 1863 hwinfo); 1864 1865 /*board type*/ 1866 rtlefuse->board_type = 1867 ((hwinfo[EEPROM_RF_BOARD_OPTION_88E] & 0xE0) >> 5); 1868 rtlhal->board_type = rtlefuse->board_type; 1869 /*Wake on wlan*/ 1870 rtlefuse->wowlan_enable = 1871 ((hwinfo[EEPROM_RF_FEATURE_OPTION_88E] & 0x40) >> 6); 1872 /*parse xtal*/ 1873 rtlefuse->crystalcap = hwinfo[EEPROM_XTAL_88E]; 1874 if (hwinfo[EEPROM_XTAL_88E]) 1875 rtlefuse->crystalcap = 0x20; 1876 /*antenna diversity*/ 1877 rtlefuse->antenna_div_cfg = 1878 (hwinfo[EEPROM_RF_BOARD_OPTION_88E] & 0x18) >> 3; 1879 if (hwinfo[EEPROM_RF_BOARD_OPTION_88E] == 0xFF) 1880 rtlefuse->antenna_div_cfg = 0; 1881 if (rtlpriv->btcoexist.eeprom_bt_coexist != 0 && 1882 rtlpriv->btcoexist.eeprom_bt_ant_num == ANT_X1) 1883 rtlefuse->antenna_div_cfg = 0; 1884 1885 rtlefuse->antenna_div_type = hwinfo[EEPROM_RF_ANTENNA_OPT_88E]; 1886 if (rtlefuse->antenna_div_type == 0xFF) 1887 rtlefuse->antenna_div_type = 0x01; 1888 if (rtlefuse->antenna_div_type == CG_TRX_HW_ANTDIV || 1889 rtlefuse->antenna_div_type == CGCS_RX_HW_ANTDIV) 1890 rtlefuse->antenna_div_cfg = 1; 1891 1892 if (rtlhal->oem_id == RT_CID_DEFAULT) { 1893 switch (rtlefuse->eeprom_oemid) { 1894 case EEPROM_CID_DEFAULT: 1895 if (rtlefuse->eeprom_did == 0x8179) { 1896 if (rtlefuse->eeprom_svid == 0x1025) { 1897 rtlhal->oem_id = RT_CID_819X_ACER; 1898 } else if ((rtlefuse->eeprom_svid == 0x10EC && 1899 rtlefuse->eeprom_smid == 0x0179) || 1900 (rtlefuse->eeprom_svid == 0x17AA && 1901 rtlefuse->eeprom_smid == 0x0179)) { 1902 rtlhal->oem_id = RT_CID_819X_LENOVO; 1903 } else if (rtlefuse->eeprom_svid == 0x103c && 1904 rtlefuse->eeprom_smid == 0x197d) { 1905 rtlhal->oem_id = RT_CID_819X_HP; 1906 } else { 1907 rtlhal->oem_id = RT_CID_DEFAULT; 1908 } 1909 } else { 1910 rtlhal->oem_id = RT_CID_DEFAULT; 1911 } 1912 break; 1913 case EEPROM_CID_TOSHIBA: 1914 rtlhal->oem_id = RT_CID_TOSHIBA; 1915 break; 1916 case EEPROM_CID_QMI: 1917 rtlhal->oem_id = RT_CID_819X_QMI; 1918 break; 1919 case EEPROM_CID_WHQL: 1920 default: 1921 rtlhal->oem_id = RT_CID_DEFAULT; 1922 break; 1923 1924 } 1925 } 1926 exit: 1927 kfree(hwinfo); 1928 } 1929 1930 static void _rtl88ee_hal_customized_behavior(struct ieee80211_hw *hw) 1931 { 1932 struct rtl_priv *rtlpriv = rtl_priv(hw); 1933 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 1934 1935 rtlpriv->ledctl.led_opendrain = true; 1936 1937 switch (rtlhal->oem_id) { 1938 case RT_CID_819X_HP: 1939 rtlpriv->ledctl.led_opendrain = true; 1940 break; 1941 case RT_CID_819X_LENOVO: 1942 case RT_CID_DEFAULT: 1943 case RT_CID_TOSHIBA: 1944 case RT_CID_CCX: 1945 case RT_CID_819X_ACER: 1946 case RT_CID_WHQL: 1947 default: 1948 break; 1949 } 1950 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 1951 "RT Customized ID: 0x%02X\n", rtlhal->oem_id); 1952 } 1953 1954 void rtl88ee_read_eeprom_info(struct ieee80211_hw *hw) 1955 { 1956 struct rtl_priv *rtlpriv = rtl_priv(hw); 1957 struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); 1958 struct rtl_phy *rtlphy = &(rtlpriv->phy); 1959 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 1960 u8 tmp_u1b; 1961 1962 rtlhal->version = _rtl88ee_read_chip_version(hw); 1963 if (get_rf_type(rtlphy) == RF_1T1R) 1964 rtlpriv->dm.rfpath_rxenable[0] = true; 1965 else 1966 rtlpriv->dm.rfpath_rxenable[0] = 1967 rtlpriv->dm.rfpath_rxenable[1] = true; 1968 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "VersionID = 0x%4x\n", 1969 rtlhal->version); 1970 tmp_u1b = rtl_read_byte(rtlpriv, REG_9346CR); 1971 if (tmp_u1b & BIT(4)) { 1972 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "Boot from EEPROM\n"); 1973 rtlefuse->epromtype = EEPROM_93C46; 1974 } else { 1975 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "Boot from EFUSE\n"); 1976 rtlefuse->epromtype = EEPROM_BOOT_EFUSE; 1977 } 1978 if (tmp_u1b & BIT(5)) { 1979 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Autoload OK\n"); 1980 rtlefuse->autoload_failflag = false; 1981 _rtl88ee_read_adapter_info(hw); 1982 } else { 1983 pr_err("Autoload ERR!!\n"); 1984 } 1985 _rtl88ee_hal_customized_behavior(hw); 1986 } 1987 1988 static void rtl88ee_update_hal_rate_table(struct ieee80211_hw *hw, 1989 struct ieee80211_sta *sta) 1990 { 1991 struct rtl_priv *rtlpriv = rtl_priv(hw); 1992 struct rtl_phy *rtlphy = &(rtlpriv->phy); 1993 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 1994 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 1995 u32 ratr_value; 1996 u8 ratr_index = 0; 1997 u8 b_nmode = mac->ht_enable; 1998 /*u8 mimo_ps = IEEE80211_SMPS_OFF;*/ 1999 u16 shortgi_rate; 2000 u32 tmp_ratr_value; 2001 u8 curtxbw_40mhz = mac->bw_40; 2002 u8 curshortgi_40mhz = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40) ? 2003 1 : 0; 2004 u8 curshortgi_20mhz = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20) ? 2005 1 : 0; 2006 enum wireless_mode wirelessmode = mac->mode; 2007 u32 ratr_mask; 2008 2009 if (rtlhal->current_bandtype == BAND_ON_5G) 2010 ratr_value = sta->supp_rates[1] << 4; 2011 else 2012 ratr_value = sta->supp_rates[0]; 2013 if (mac->opmode == NL80211_IFTYPE_ADHOC) 2014 ratr_value = 0xfff; 2015 ratr_value |= (sta->ht_cap.mcs.rx_mask[1] << 20 | 2016 sta->ht_cap.mcs.rx_mask[0] << 12); 2017 switch (wirelessmode) { 2018 case WIRELESS_MODE_B: 2019 if (ratr_value & 0x0000000c) 2020 ratr_value &= 0x0000000d; 2021 else 2022 ratr_value &= 0x0000000f; 2023 break; 2024 case WIRELESS_MODE_G: 2025 ratr_value &= 0x00000FF5; 2026 break; 2027 case WIRELESS_MODE_N_24G: 2028 case WIRELESS_MODE_N_5G: 2029 b_nmode = 1; 2030 if (get_rf_type(rtlphy) == RF_1T2R || 2031 get_rf_type(rtlphy) == RF_1T1R) 2032 ratr_mask = 0x000ff005; 2033 else 2034 ratr_mask = 0x0f0ff005; 2035 2036 ratr_value &= ratr_mask; 2037 break; 2038 default: 2039 if (rtlphy->rf_type == RF_1T2R) 2040 ratr_value &= 0x000ff0ff; 2041 else 2042 ratr_value &= 0x0f0ff0ff; 2043 2044 break; 2045 } 2046 2047 if ((rtlpriv->btcoexist.bt_coexistence) && 2048 (rtlpriv->btcoexist.bt_coexist_type == BT_CSR_BC4) && 2049 (rtlpriv->btcoexist.bt_cur_state) && 2050 (rtlpriv->btcoexist.bt_ant_isolation) && 2051 ((rtlpriv->btcoexist.bt_service == BT_SCO) || 2052 (rtlpriv->btcoexist.bt_service == BT_BUSY))) 2053 ratr_value &= 0x0fffcfc0; 2054 else 2055 ratr_value &= 0x0FFFFFFF; 2056 2057 if (b_nmode && 2058 ((curtxbw_40mhz && curshortgi_40mhz) || 2059 (!curtxbw_40mhz && curshortgi_20mhz))) { 2060 ratr_value |= 0x10000000; 2061 tmp_ratr_value = (ratr_value >> 12); 2062 2063 for (shortgi_rate = 15; shortgi_rate > 0; shortgi_rate--) { 2064 if ((1 << shortgi_rate) & tmp_ratr_value) 2065 break; 2066 } 2067 2068 shortgi_rate = (shortgi_rate << 12) | (shortgi_rate << 8) | 2069 (shortgi_rate << 4) | (shortgi_rate); 2070 } 2071 2072 rtl_write_dword(rtlpriv, REG_ARFR0 + ratr_index * 4, ratr_value); 2073 2074 RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, 2075 "%x\n", rtl_read_dword(rtlpriv, REG_ARFR0)); 2076 } 2077 2078 static void rtl88ee_update_hal_rate_mask(struct ieee80211_hw *hw, 2079 struct ieee80211_sta *sta, u8 rssi_level, bool update_bw) 2080 { 2081 struct rtl_priv *rtlpriv = rtl_priv(hw); 2082 struct rtl_phy *rtlphy = &(rtlpriv->phy); 2083 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 2084 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 2085 struct rtl_sta_info *sta_entry = NULL; 2086 u32 ratr_bitmap; 2087 u8 ratr_index; 2088 u8 curtxbw_40mhz = (sta->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) 2089 ? 1 : 0; 2090 u8 curshortgi_40mhz = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40) ? 2091 1 : 0; 2092 u8 curshortgi_20mhz = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20) ? 2093 1 : 0; 2094 enum wireless_mode wirelessmode = 0; 2095 bool b_shortgi = false; 2096 u8 rate_mask[5]; 2097 u8 macid = 0; 2098 /*u8 mimo_ps = IEEE80211_SMPS_OFF;*/ 2099 2100 sta_entry = (struct rtl_sta_info *)sta->drv_priv; 2101 wirelessmode = sta_entry->wireless_mode; 2102 if (mac->opmode == NL80211_IFTYPE_STATION || 2103 mac->opmode == NL80211_IFTYPE_MESH_POINT) 2104 curtxbw_40mhz = mac->bw_40; 2105 else if (mac->opmode == NL80211_IFTYPE_AP || 2106 mac->opmode == NL80211_IFTYPE_ADHOC) 2107 macid = sta->aid + 1; 2108 2109 if (rtlhal->current_bandtype == BAND_ON_5G) 2110 ratr_bitmap = sta->supp_rates[1] << 4; 2111 else 2112 ratr_bitmap = sta->supp_rates[0]; 2113 if (mac->opmode == NL80211_IFTYPE_ADHOC) 2114 ratr_bitmap = 0xfff; 2115 ratr_bitmap |= (sta->ht_cap.mcs.rx_mask[1] << 20 | 2116 sta->ht_cap.mcs.rx_mask[0] << 12); 2117 switch (wirelessmode) { 2118 case WIRELESS_MODE_B: 2119 ratr_index = RATR_INX_WIRELESS_B; 2120 if (ratr_bitmap & 0x0000000c) 2121 ratr_bitmap &= 0x0000000d; 2122 else 2123 ratr_bitmap &= 0x0000000f; 2124 break; 2125 case WIRELESS_MODE_G: 2126 ratr_index = RATR_INX_WIRELESS_GB; 2127 2128 if (rssi_level == 1) 2129 ratr_bitmap &= 0x00000f00; 2130 else if (rssi_level == 2) 2131 ratr_bitmap &= 0x00000ff0; 2132 else 2133 ratr_bitmap &= 0x00000ff5; 2134 break; 2135 case WIRELESS_MODE_N_24G: 2136 case WIRELESS_MODE_N_5G: 2137 ratr_index = RATR_INX_WIRELESS_NGB; 2138 if (rtlphy->rf_type == RF_1T2R || 2139 rtlphy->rf_type == RF_1T1R) { 2140 if (curtxbw_40mhz) { 2141 if (rssi_level == 1) 2142 ratr_bitmap &= 0x000f0000; 2143 else if (rssi_level == 2) 2144 ratr_bitmap &= 0x000ff000; 2145 else 2146 ratr_bitmap &= 0x000ff015; 2147 } else { 2148 if (rssi_level == 1) 2149 ratr_bitmap &= 0x000f0000; 2150 else if (rssi_level == 2) 2151 ratr_bitmap &= 0x000ff000; 2152 else 2153 ratr_bitmap &= 0x000ff005; 2154 } 2155 } else { 2156 if (curtxbw_40mhz) { 2157 if (rssi_level == 1) 2158 ratr_bitmap &= 0x0f8f0000; 2159 else if (rssi_level == 2) 2160 ratr_bitmap &= 0x0f8ff000; 2161 else 2162 ratr_bitmap &= 0x0f8ff015; 2163 } else { 2164 if (rssi_level == 1) 2165 ratr_bitmap &= 0x0f8f0000; 2166 else if (rssi_level == 2) 2167 ratr_bitmap &= 0x0f8ff000; 2168 else 2169 ratr_bitmap &= 0x0f8ff005; 2170 } 2171 } 2172 /*}*/ 2173 2174 if ((curtxbw_40mhz && curshortgi_40mhz) || 2175 (!curtxbw_40mhz && curshortgi_20mhz)) { 2176 2177 if (macid == 0) 2178 b_shortgi = true; 2179 else if (macid == 1) 2180 b_shortgi = false; 2181 } 2182 break; 2183 default: 2184 ratr_index = RATR_INX_WIRELESS_NGB; 2185 2186 if (rtlphy->rf_type == RF_1T2R) 2187 ratr_bitmap &= 0x000ff0ff; 2188 else 2189 ratr_bitmap &= 0x0f0ff0ff; 2190 break; 2191 } 2192 sta_entry->ratr_index = ratr_index; 2193 2194 RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, 2195 "ratr_bitmap :%x\n", ratr_bitmap); 2196 *(u32 *)&rate_mask = (ratr_bitmap & 0x0fffffff) | 2197 (ratr_index << 28); 2198 rate_mask[4] = macid | (b_shortgi ? 0x20 : 0x00) | 0x80; 2199 RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, 2200 "Rate_index:%x, ratr_val:%x, %x:%x:%x:%x:%x\n", 2201 ratr_index, ratr_bitmap, 2202 rate_mask[0], rate_mask[1], 2203 rate_mask[2], rate_mask[3], 2204 rate_mask[4]); 2205 rtl88e_fill_h2c_cmd(hw, H2C_88E_RA_MASK, 5, rate_mask); 2206 _rtl88ee_set_bcn_ctrl_reg(hw, BIT(3), 0); 2207 } 2208 2209 void rtl88ee_update_hal_rate_tbl(struct ieee80211_hw *hw, 2210 struct ieee80211_sta *sta, u8 rssi_level, bool update_bw) 2211 { 2212 struct rtl_priv *rtlpriv = rtl_priv(hw); 2213 2214 if (rtlpriv->dm.useramask) 2215 rtl88ee_update_hal_rate_mask(hw, sta, rssi_level, update_bw); 2216 else 2217 rtl88ee_update_hal_rate_table(hw, sta); 2218 } 2219 2220 void rtl88ee_update_channel_access_setting(struct ieee80211_hw *hw) 2221 { 2222 struct rtl_priv *rtlpriv = rtl_priv(hw); 2223 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 2224 u16 sifs_timer; 2225 2226 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SLOT_TIME, &mac->slot_time); 2227 if (!mac->ht_enable) 2228 sifs_timer = 0x0a0a; 2229 else 2230 sifs_timer = 0x0e0e; 2231 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SIFS, (u8 *)&sifs_timer); 2232 } 2233 2234 bool rtl88ee_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 *valid) 2235 { 2236 struct rtl_priv *rtlpriv = rtl_priv(hw); 2237 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); 2238 enum rf_pwrstate e_rfpowerstate_toset; 2239 u32 u4tmp; 2240 bool b_actuallyset = false; 2241 2242 if (rtlpriv->rtlhal.being_init_adapter) 2243 return false; 2244 2245 if (ppsc->swrf_processing) 2246 return false; 2247 2248 spin_lock(&rtlpriv->locks.rf_ps_lock); 2249 if (ppsc->rfchange_inprogress) { 2250 spin_unlock(&rtlpriv->locks.rf_ps_lock); 2251 return false; 2252 } else { 2253 ppsc->rfchange_inprogress = true; 2254 spin_unlock(&rtlpriv->locks.rf_ps_lock); 2255 } 2256 2257 u4tmp = rtl_read_dword(rtlpriv, REG_GPIO_OUTPUT); 2258 e_rfpowerstate_toset = (u4tmp & BIT(31)) ? ERFON : ERFOFF; 2259 2260 if (ppsc->hwradiooff && (e_rfpowerstate_toset == ERFON)) { 2261 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, 2262 "GPIOChangeRF - HW Radio ON, RF ON\n"); 2263 2264 e_rfpowerstate_toset = ERFON; 2265 ppsc->hwradiooff = false; 2266 b_actuallyset = true; 2267 } else if ((!ppsc->hwradiooff) && 2268 (e_rfpowerstate_toset == ERFOFF)) { 2269 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, 2270 "GPIOChangeRF - HW Radio OFF, RF OFF\n"); 2271 2272 e_rfpowerstate_toset = ERFOFF; 2273 ppsc->hwradiooff = true; 2274 b_actuallyset = true; 2275 } 2276 2277 if (b_actuallyset) { 2278 spin_lock(&rtlpriv->locks.rf_ps_lock); 2279 ppsc->rfchange_inprogress = false; 2280 spin_unlock(&rtlpriv->locks.rf_ps_lock); 2281 } else { 2282 if (ppsc->reg_rfps_level & RT_RF_OFF_LEVL_HALT_NIC) 2283 RT_SET_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC); 2284 2285 spin_lock(&rtlpriv->locks.rf_ps_lock); 2286 ppsc->rfchange_inprogress = false; 2287 spin_unlock(&rtlpriv->locks.rf_ps_lock); 2288 } 2289 2290 *valid = 1; 2291 return !ppsc->hwradiooff; 2292 2293 } 2294 2295 void rtl88ee_set_key(struct ieee80211_hw *hw, u32 key_index, 2296 u8 *p_macaddr, bool is_group, u8 enc_algo, 2297 bool is_wepkey, bool clear_all) 2298 { 2299 struct rtl_priv *rtlpriv = rtl_priv(hw); 2300 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 2301 struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); 2302 u8 *macaddr = p_macaddr; 2303 u32 entry_id = 0; 2304 bool is_pairwise = false; 2305 static u8 cam_const_addr[4][6] = { 2306 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 2307 {0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, 2308 {0x00, 0x00, 0x00, 0x00, 0x00, 0x02}, 2309 {0x00, 0x00, 0x00, 0x00, 0x00, 0x03} 2310 }; 2311 static u8 cam_const_broad[] = { 2312 0xff, 0xff, 0xff, 0xff, 0xff, 0xff 2313 }; 2314 2315 if (clear_all) { 2316 u8 idx = 0; 2317 u8 cam_offset = 0; 2318 u8 clear_number = 5; 2319 2320 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "clear_all\n"); 2321 2322 for (idx = 0; idx < clear_number; idx++) { 2323 rtl_cam_mark_invalid(hw, cam_offset + idx); 2324 rtl_cam_empty_entry(hw, cam_offset + idx); 2325 2326 if (idx < 5) { 2327 memset(rtlpriv->sec.key_buf[idx], 0, 2328 MAX_KEY_LEN); 2329 rtlpriv->sec.key_len[idx] = 0; 2330 } 2331 } 2332 2333 } else { 2334 switch (enc_algo) { 2335 case WEP40_ENCRYPTION: 2336 enc_algo = CAM_WEP40; 2337 break; 2338 case WEP104_ENCRYPTION: 2339 enc_algo = CAM_WEP104; 2340 break; 2341 case TKIP_ENCRYPTION: 2342 enc_algo = CAM_TKIP; 2343 break; 2344 case AESCCMP_ENCRYPTION: 2345 enc_algo = CAM_AES; 2346 break; 2347 default: 2348 pr_err("switch case %#x not processed\n", 2349 enc_algo); 2350 enc_algo = CAM_TKIP; 2351 break; 2352 } 2353 2354 if (is_wepkey || rtlpriv->sec.use_defaultkey) { 2355 macaddr = cam_const_addr[key_index]; 2356 entry_id = key_index; 2357 } else { 2358 if (is_group) { 2359 macaddr = cam_const_broad; 2360 entry_id = key_index; 2361 } else { 2362 if (mac->opmode == NL80211_IFTYPE_AP || 2363 mac->opmode == NL80211_IFTYPE_MESH_POINT) { 2364 entry_id = 2365 rtl_cam_get_free_entry(hw, p_macaddr); 2366 if (entry_id >= TOTAL_CAM_ENTRY) { 2367 pr_err("Can not find free hw security cam entry\n"); 2368 return; 2369 } 2370 } else { 2371 entry_id = CAM_PAIRWISE_KEY_POSITION; 2372 } 2373 key_index = PAIRWISE_KEYIDX; 2374 is_pairwise = true; 2375 } 2376 } 2377 2378 if (rtlpriv->sec.key_len[key_index] == 0) { 2379 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 2380 "delete one entry, entry_id is %d\n", 2381 entry_id); 2382 if (mac->opmode == NL80211_IFTYPE_AP || 2383 mac->opmode == NL80211_IFTYPE_MESH_POINT) 2384 rtl_cam_del_entry(hw, p_macaddr); 2385 rtl_cam_delete_one_entry(hw, p_macaddr, entry_id); 2386 } else { 2387 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 2388 "add one entry\n"); 2389 if (is_pairwise) { 2390 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 2391 "set Pairwise key\n"); 2392 2393 rtl_cam_add_one_entry(hw, macaddr, key_index, 2394 entry_id, enc_algo, 2395 CAM_CONFIG_NO_USEDK, 2396 rtlpriv->sec.key_buf[key_index]); 2397 } else { 2398 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 2399 "set group key\n"); 2400 2401 if (mac->opmode == NL80211_IFTYPE_ADHOC) { 2402 rtl_cam_add_one_entry(hw, 2403 rtlefuse->dev_addr, 2404 PAIRWISE_KEYIDX, 2405 CAM_PAIRWISE_KEY_POSITION, 2406 enc_algo, 2407 CAM_CONFIG_NO_USEDK, 2408 rtlpriv->sec.key_buf 2409 [entry_id]); 2410 } 2411 2412 rtl_cam_add_one_entry(hw, macaddr, key_index, 2413 entry_id, enc_algo, 2414 CAM_CONFIG_NO_USEDK, 2415 rtlpriv->sec.key_buf[entry_id]); 2416 } 2417 2418 } 2419 } 2420 } 2421 2422 static void rtl8188ee_bt_var_init(struct ieee80211_hw *hw) 2423 { 2424 struct rtl_priv *rtlpriv = rtl_priv(hw); 2425 2426 rtlpriv->btcoexist.bt_coexistence = 2427 rtlpriv->btcoexist.eeprom_bt_coexist; 2428 rtlpriv->btcoexist.bt_ant_num = rtlpriv->btcoexist.eeprom_bt_ant_num; 2429 rtlpriv->btcoexist.bt_coexist_type = rtlpriv->btcoexist.eeprom_bt_type; 2430 2431 if (rtlpriv->btcoexist.reg_bt_iso == 2) 2432 rtlpriv->btcoexist.bt_ant_isolation = 2433 rtlpriv->btcoexist.eeprom_bt_ant_isol; 2434 else 2435 rtlpriv->btcoexist.bt_ant_isolation = 2436 rtlpriv->btcoexist.reg_bt_iso; 2437 2438 rtlpriv->btcoexist.bt_radio_shared_type = 2439 rtlpriv->btcoexist.eeprom_bt_radio_shared; 2440 2441 if (rtlpriv->btcoexist.bt_coexistence) { 2442 if (rtlpriv->btcoexist.reg_bt_sco == 1) 2443 rtlpriv->btcoexist.bt_service = BT_OTHER_ACTION; 2444 else if (rtlpriv->btcoexist.reg_bt_sco == 2) 2445 rtlpriv->btcoexist.bt_service = BT_SCO; 2446 else if (rtlpriv->btcoexist.reg_bt_sco == 4) 2447 rtlpriv->btcoexist.bt_service = BT_BUSY; 2448 else if (rtlpriv->btcoexist.reg_bt_sco == 5) 2449 rtlpriv->btcoexist.bt_service = BT_OTHERBUSY; 2450 else 2451 rtlpriv->btcoexist.bt_service = BT_IDLE; 2452 2453 rtlpriv->btcoexist.bt_edca_ul = 0; 2454 rtlpriv->btcoexist.bt_edca_dl = 0; 2455 rtlpriv->btcoexist.bt_rssi_state = 0xff; 2456 } 2457 } 2458 2459 void rtl8188ee_read_bt_coexist_info_from_hwpg(struct ieee80211_hw *hw, 2460 bool auto_load_fail, u8 *hwinfo) 2461 { 2462 struct rtl_priv *rtlpriv = rtl_priv(hw); 2463 u8 value; 2464 2465 if (!auto_load_fail) { 2466 rtlpriv->btcoexist.eeprom_bt_coexist = 2467 ((hwinfo[EEPROM_RF_FEATURE_OPTION_88E] & 0xe0) >> 5); 2468 if (hwinfo[EEPROM_RF_FEATURE_OPTION_88E] == 0xFF) 2469 rtlpriv->btcoexist.eeprom_bt_coexist = 0; 2470 value = hwinfo[EEPROM_RF_BT_SETTING_88E]; 2471 rtlpriv->btcoexist.eeprom_bt_type = ((value & 0xe) >> 1); 2472 rtlpriv->btcoexist.eeprom_bt_ant_num = (value & 0x1); 2473 rtlpriv->btcoexist.eeprom_bt_ant_isol = ((value & 0x10) >> 4); 2474 rtlpriv->btcoexist.eeprom_bt_radio_shared = 2475 ((value & 0x20) >> 5); 2476 } else { 2477 rtlpriv->btcoexist.eeprom_bt_coexist = 0; 2478 rtlpriv->btcoexist.eeprom_bt_type = BT_2WIRE; 2479 rtlpriv->btcoexist.eeprom_bt_ant_num = ANT_X2; 2480 rtlpriv->btcoexist.eeprom_bt_ant_isol = 0; 2481 rtlpriv->btcoexist.eeprom_bt_radio_shared = BT_RADIO_SHARED; 2482 } 2483 2484 rtl8188ee_bt_var_init(hw); 2485 } 2486 2487 void rtl8188ee_bt_reg_init(struct ieee80211_hw *hw) 2488 { 2489 struct rtl_priv *rtlpriv = rtl_priv(hw); 2490 2491 /* 0:Low, 1:High, 2:From Efuse. */ 2492 rtlpriv->btcoexist.reg_bt_iso = 2; 2493 /* 0:Idle, 1:None-SCO, 2:SCO, 3:From Counter. */ 2494 rtlpriv->btcoexist.reg_bt_sco = 3; 2495 /* 0:Disable BT control A-MPDU, 1:Enable BT control A-MPDU. */ 2496 rtlpriv->btcoexist.reg_bt_sco = 0; 2497 } 2498 2499 void rtl8188ee_bt_hw_init(struct ieee80211_hw *hw) 2500 { 2501 struct rtl_priv *rtlpriv = rtl_priv(hw); 2502 struct rtl_phy *rtlphy = &rtlpriv->phy; 2503 u8 u1_tmp; 2504 2505 if (rtlpriv->btcoexist.bt_coexistence && 2506 ((rtlpriv->btcoexist.bt_coexist_type == BT_CSR_BC4) || 2507 rtlpriv->btcoexist.bt_coexist_type == BT_CSR_BC8)) { 2508 if (rtlpriv->btcoexist.bt_ant_isolation) 2509 rtl_write_byte(rtlpriv, REG_GPIO_MUXCFG, 0xa0); 2510 2511 u1_tmp = rtl_read_byte(rtlpriv, 0x4fd) & 2512 BIT_OFFSET_LEN_MASK_32(0, 1); 2513 u1_tmp = u1_tmp | 2514 ((rtlpriv->btcoexist.bt_ant_isolation == 1) ? 2515 0 : BIT_OFFSET_LEN_MASK_32(1, 1)) | 2516 ((rtlpriv->btcoexist.bt_service == BT_SCO) ? 2517 0 : BIT_OFFSET_LEN_MASK_32(2, 1)); 2518 rtl_write_byte(rtlpriv, 0x4fd, u1_tmp); 2519 2520 rtl_write_dword(rtlpriv, REG_BT_COEX_TABLE+4, 0xaaaa9aaa); 2521 rtl_write_dword(rtlpriv, REG_BT_COEX_TABLE+8, 0xffbd0040); 2522 rtl_write_dword(rtlpriv, REG_BT_COEX_TABLE+0xc, 0x40000010); 2523 2524 /* Config to 1T1R. */ 2525 if (rtlphy->rf_type == RF_1T1R) { 2526 u1_tmp = rtl_read_byte(rtlpriv, ROFDM0_TRXPATHENABLE); 2527 u1_tmp &= ~(BIT_OFFSET_LEN_MASK_32(1, 1)); 2528 rtl_write_byte(rtlpriv, ROFDM0_TRXPATHENABLE, u1_tmp); 2529 2530 u1_tmp = rtl_read_byte(rtlpriv, ROFDM1_TRXPATHENABLE); 2531 u1_tmp &= ~(BIT_OFFSET_LEN_MASK_32(1, 1)); 2532 rtl_write_byte(rtlpriv, ROFDM1_TRXPATHENABLE, u1_tmp); 2533 } 2534 } 2535 } 2536 2537 void rtl88ee_suspend(struct ieee80211_hw *hw) 2538 { 2539 } 2540 2541 void rtl88ee_resume(struct ieee80211_hw *hw) 2542 { 2543 } 2544