1 /******************************************************************************
3 * Copyright(c) 2009-2012 Realtek Corporation.
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.
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
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18 * The full GNU General Public License is included in this distribution in the
19 * file called LICENSE.
21 * Contact Information:
22 * wlanfae <wlanfae@realtek.com>
23 * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
24 * Hsinchu 300, Taiwan.
26 * Larry Finger <Larry.Finger@lwfinger.net>
28 *****************************************************************************/
40 #include "../rtl8192c/fw_common.h"
47 static void _rtl92ce_set_bcn_ctrl_reg(struct ieee80211_hw
*hw
,
48 u8 set_bits
, u8 clear_bits
)
50 struct rtl_pci
*rtlpci
= rtl_pcidev(rtl_pcipriv(hw
));
51 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
53 rtlpci
->reg_bcn_ctrl_val
|= set_bits
;
54 rtlpci
->reg_bcn_ctrl_val
&= ~clear_bits
;
56 rtl_write_byte(rtlpriv
, REG_BCN_CTRL
, (u8
) rtlpci
->reg_bcn_ctrl_val
);
59 static void _rtl92ce_stop_tx_beacon(struct ieee80211_hw
*hw
)
61 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
64 tmp1byte
= rtl_read_byte(rtlpriv
, REG_FWHW_TXQ_CTRL
+ 2);
65 rtl_write_byte(rtlpriv
, REG_FWHW_TXQ_CTRL
+ 2, tmp1byte
& (~BIT(6)));
66 rtl_write_byte(rtlpriv
, REG_TBTT_PROHIBIT
+ 1, 0x64);
67 tmp1byte
= rtl_read_byte(rtlpriv
, REG_TBTT_PROHIBIT
+ 2);
68 tmp1byte
&= ~(BIT(0));
69 rtl_write_byte(rtlpriv
, REG_TBTT_PROHIBIT
+ 2, tmp1byte
);
72 static void _rtl92ce_resume_tx_beacon(struct ieee80211_hw
*hw
)
74 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
77 tmp1byte
= rtl_read_byte(rtlpriv
, REG_FWHW_TXQ_CTRL
+ 2);
78 rtl_write_byte(rtlpriv
, REG_FWHW_TXQ_CTRL
+ 2, tmp1byte
| BIT(6));
79 rtl_write_byte(rtlpriv
, REG_TBTT_PROHIBIT
+ 1, 0xff);
80 tmp1byte
= rtl_read_byte(rtlpriv
, REG_TBTT_PROHIBIT
+ 2);
82 rtl_write_byte(rtlpriv
, REG_TBTT_PROHIBIT
+ 2, tmp1byte
);
85 static void _rtl92ce_enable_bcn_sub_func(struct ieee80211_hw
*hw
)
87 _rtl92ce_set_bcn_ctrl_reg(hw
, 0, BIT(1));
90 static void _rtl92ce_disable_bcn_sub_func(struct ieee80211_hw
*hw
)
92 _rtl92ce_set_bcn_ctrl_reg(hw
, BIT(1), 0);
95 void rtl92ce_get_hw_reg(struct ieee80211_hw
*hw
, u8 variable
, u8
*val
)
97 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
98 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
99 struct rtl_pci
*rtlpci
= rtl_pcidev(rtl_pcipriv(hw
));
103 *((u32
*) (val
)) = rtlpci
->receive_config
;
105 case HW_VAR_RF_STATE
:
106 *((enum rf_pwrstate
*)(val
)) = ppsc
->rfpwr_state
;
108 case HW_VAR_FWLPS_RF_ON
:{
109 enum rf_pwrstate rfState
;
112 rtlpriv
->cfg
->ops
->get_hw_reg(hw
,
115 if (rfState
== ERFOFF
) {
116 *((bool *) (val
)) = true;
118 val_rcr
= rtl_read_dword(rtlpriv
, REG_RCR
);
119 val_rcr
&= 0x00070000;
121 *((bool *) (val
)) = false;
123 *((bool *) (val
)) = true;
127 case HW_VAR_FW_PSMODE_STATUS
:
128 *((bool *) (val
)) = ppsc
->fw_current_inpsmode
;
130 case HW_VAR_CORRECT_TSF
:{
132 u32
*ptsf_low
= (u32
*)&tsf
;
133 u32
*ptsf_high
= ((u32
*)&tsf
) + 1;
135 *ptsf_high
= rtl_read_dword(rtlpriv
, (REG_TSFTR
+ 4));
136 *ptsf_low
= rtl_read_dword(rtlpriv
, REG_TSFTR
);
138 *((u64
*) (val
)) = tsf
;
143 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
144 "switch case not processed\n");
149 void rtl92ce_set_hw_reg(struct ieee80211_hw
*hw
, u8 variable
, u8
*val
)
151 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
152 struct rtl_pci_priv
*rtlpcipriv
= rtl_pcipriv(hw
);
153 struct rtl_pci
*rtlpci
= rtl_pcidev(rtl_pcipriv(hw
));
154 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
155 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
156 struct rtl_efuse
*rtlefuse
= rtl_efuse(rtl_priv(hw
));
157 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
161 case HW_VAR_ETHER_ADDR
:{
162 for (idx
= 0; idx
< ETH_ALEN
; idx
++) {
163 rtl_write_byte(rtlpriv
, (REG_MACID
+ idx
),
168 case HW_VAR_BASIC_RATE
:{
169 u16 rate_cfg
= ((u16
*) val
)[0];
173 rtl_write_byte(rtlpriv
, REG_RRSR
, rate_cfg
& 0xff);
174 rtl_write_byte(rtlpriv
, REG_RRSR
+ 1,
175 (rate_cfg
>> 8) & 0xff);
176 while (rate_cfg
> 0x1) {
177 rate_cfg
= (rate_cfg
>> 1);
180 rtl_write_byte(rtlpriv
, REG_INIRTS_RATE_SEL
,
185 for (idx
= 0; idx
< ETH_ALEN
; idx
++) {
186 rtl_write_byte(rtlpriv
, (REG_BSSID
+ idx
),
192 rtl_write_byte(rtlpriv
, REG_SIFS_CTX
+ 1, val
[0]);
193 rtl_write_byte(rtlpriv
, REG_SIFS_TRX
+ 1, val
[1]);
195 rtl_write_byte(rtlpriv
, REG_SPEC_SIFS
+ 1, val
[0]);
196 rtl_write_byte(rtlpriv
, REG_MAC_SPEC_SIFS
+ 1, val
[0]);
199 rtl_write_word(rtlpriv
, REG_RESP_SIFS_OFDM
,
202 rtl_write_word(rtlpriv
, REG_RESP_SIFS_OFDM
,
206 case HW_VAR_SLOT_TIME
:{
209 RT_TRACE(rtlpriv
, COMP_MLME
, DBG_LOUD
,
210 "HW_VAR_SLOT_TIME %x\n", val
[0]);
212 rtl_write_byte(rtlpriv
, REG_SLOT
, val
[0]);
214 for (e_aci
= 0; e_aci
< AC_MAX
; e_aci
++) {
215 rtlpriv
->cfg
->ops
->set_hw_reg(hw
,
221 case HW_VAR_ACK_PREAMBLE
:{
223 u8 short_preamble
= (bool)*val
;
224 reg_tmp
= (mac
->cur_40_prime_sc
) << 5;
228 rtl_write_byte(rtlpriv
, REG_RRSR
+ 2, reg_tmp
);
231 case HW_VAR_AMPDU_MIN_SPACE
:{
232 u8 min_spacing_to_set
;
235 min_spacing_to_set
= *val
;
236 if (min_spacing_to_set
<= 7) {
239 if (min_spacing_to_set
< sec_min_space
)
240 min_spacing_to_set
= sec_min_space
;
242 mac
->min_space_cfg
= ((mac
->min_space_cfg
&
246 *val
= min_spacing_to_set
;
248 RT_TRACE(rtlpriv
, COMP_MLME
, DBG_LOUD
,
249 "Set HW_VAR_AMPDU_MIN_SPACE: %#x\n",
252 rtl_write_byte(rtlpriv
, REG_AMPDU_MIN_SPACE
,
257 case HW_VAR_SHORTGI_DENSITY
:{
260 density_to_set
= *val
;
261 mac
->min_space_cfg
|= (density_to_set
<< 3);
263 RT_TRACE(rtlpriv
, COMP_MLME
, DBG_LOUD
,
264 "Set HW_VAR_SHORTGI_DENSITY: %#x\n",
267 rtl_write_byte(rtlpriv
, REG_AMPDU_MIN_SPACE
,
272 case HW_VAR_AMPDU_FACTOR
:{
273 u8 regtoset_normal
[4] = {0x41, 0xa8, 0x72, 0xb9};
274 u8 regtoset_bt
[4] = {0x31, 0x74, 0x42, 0x97};
277 u8
*p_regtoset
= NULL
;
280 if ((rtlpcipriv
->bt_coexist
.bt_coexistence
) &&
281 (rtlpcipriv
->bt_coexist
.bt_coexist_type
==
283 p_regtoset
= regtoset_bt
;
285 p_regtoset
= regtoset_normal
;
287 factor_toset
= *(val
);
288 if (factor_toset
<= 3) {
289 factor_toset
= (1 << (factor_toset
+ 2));
290 if (factor_toset
> 0xf)
293 for (index
= 0; index
< 4; index
++) {
294 if ((p_regtoset
[index
] & 0xf0) >
297 (p_regtoset
[index
] & 0x0f) |
300 if ((p_regtoset
[index
] & 0x0f) >
303 (p_regtoset
[index
] & 0xf0) |
306 rtl_write_byte(rtlpriv
,
307 (REG_AGGLEN_LMT
+ index
),
312 RT_TRACE(rtlpriv
, COMP_MLME
, DBG_LOUD
,
313 "Set HW_VAR_AMPDU_FACTOR: %#x\n",
318 case HW_VAR_AC_PARAM
:{
320 rtl92c_dm_init_edca_turbo(hw
);
322 if (rtlpci
->acm_method
!= eAcmWay2_SW
)
323 rtlpriv
->cfg
->ops
->set_hw_reg(hw
,
328 case HW_VAR_ACM_CTRL
:{
330 union aci_aifsn
*p_aci_aifsn
=
331 (union aci_aifsn
*)(&(mac
->ac
[0].aifs
));
332 u8 acm
= p_aci_aifsn
->f
.acm
;
333 u8 acm_ctrl
= rtl_read_byte(rtlpriv
, REG_ACMHWCTRL
);
336 acm_ctrl
| ((rtlpci
->acm_method
== 2) ? 0x0 : 0x1);
341 acm_ctrl
|= AcmHw_BeqEn
;
344 acm_ctrl
|= AcmHw_ViqEn
;
347 acm_ctrl
|= AcmHw_VoqEn
;
350 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_WARNING
,
351 "HW_VAR_ACM_CTRL acm set failed: eACI is %d\n",
358 acm_ctrl
&= (~AcmHw_BeqEn
);
361 acm_ctrl
&= (~AcmHw_ViqEn
);
364 acm_ctrl
&= (~AcmHw_BeqEn
);
367 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
368 "switch case not processed\n");
373 RT_TRACE(rtlpriv
, COMP_QOS
, DBG_TRACE
,
374 "SetHwReg8190pci(): [HW_VAR_ACM_CTRL] Write 0x%X\n",
376 rtl_write_byte(rtlpriv
, REG_ACMHWCTRL
, acm_ctrl
);
380 rtl_write_dword(rtlpriv
, REG_RCR
, ((u32
*) (val
))[0]);
381 rtlpci
->receive_config
= ((u32
*) (val
))[0];
384 case HW_VAR_RETRY_LIMIT
:{
385 u8 retry_limit
= val
[0];
387 rtl_write_word(rtlpriv
, REG_RL
,
388 retry_limit
<< RETRY_LIMIT_SHORT_SHIFT
|
389 retry_limit
<< RETRY_LIMIT_LONG_SHIFT
);
392 case HW_VAR_DUAL_TSF_RST
:
393 rtl_write_byte(rtlpriv
, REG_DUAL_TSF_RST
, (BIT(0) | BIT(1)));
395 case HW_VAR_EFUSE_BYTES
:
396 rtlefuse
->efuse_usedbytes
= *((u16
*) val
);
398 case HW_VAR_EFUSE_USAGE
:
399 rtlefuse
->efuse_usedpercentage
= *val
;
402 rtl92c_phy_set_io_cmd(hw
, (*(enum io_type
*)val
));
404 case HW_VAR_WPA_CONFIG
:
405 rtl_write_byte(rtlpriv
, REG_SECCFG
, *val
);
407 case HW_VAR_SET_RPWM
:{
410 rpwm_val
= rtl_read_byte(rtlpriv
, REG_PCIE_HRPWM
);
413 if (rpwm_val
& BIT(7)) {
414 rtl_write_byte(rtlpriv
, REG_PCIE_HRPWM
, *val
);
416 rtl_write_byte(rtlpriv
, REG_PCIE_HRPWM
,
422 case HW_VAR_H2C_FW_PWRMODE
:{
425 if ((psmode
!= FW_PS_ACTIVE_MODE
) &&
426 (!IS_92C_SERIAL(rtlhal
->version
))) {
427 rtl92c_dm_rf_saving(hw
, true);
430 rtl92c_set_fw_pwrmode_cmd(hw
, *val
);
433 case HW_VAR_FW_PSMODE_STATUS
:
434 ppsc
->fw_current_inpsmode
= *((bool *) val
);
436 case HW_VAR_H2C_FW_JOINBSSRPT
:{
438 u8 tmp_regcr
, tmp_reg422
;
439 bool recover
= false;
441 if (mstatus
== RT_MEDIA_CONNECT
) {
442 rtlpriv
->cfg
->ops
->set_hw_reg(hw
, HW_VAR_AID
,
445 tmp_regcr
= rtl_read_byte(rtlpriv
, REG_CR
+ 1);
446 rtl_write_byte(rtlpriv
, REG_CR
+ 1,
447 (tmp_regcr
| BIT(0)));
449 _rtl92ce_set_bcn_ctrl_reg(hw
, 0, BIT(3));
450 _rtl92ce_set_bcn_ctrl_reg(hw
, BIT(4), 0);
453 rtl_read_byte(rtlpriv
,
454 REG_FWHW_TXQ_CTRL
+ 2);
455 if (tmp_reg422
& BIT(6))
457 rtl_write_byte(rtlpriv
, REG_FWHW_TXQ_CTRL
+ 2,
458 tmp_reg422
& (~BIT(6)));
460 rtl92c_set_fw_rsvdpagepkt(hw
, 0);
462 _rtl92ce_set_bcn_ctrl_reg(hw
, BIT(3), 0);
463 _rtl92ce_set_bcn_ctrl_reg(hw
, 0, BIT(4));
466 rtl_write_byte(rtlpriv
,
467 REG_FWHW_TXQ_CTRL
+ 2,
471 rtl_write_byte(rtlpriv
, REG_CR
+ 1,
472 (tmp_regcr
& ~(BIT(0))));
474 rtl92c_set_fw_joinbss_report_cmd(hw
, *val
);
478 case HW_VAR_H2C_FW_P2P_PS_OFFLOAD
:
479 rtl92c_set_p2p_ps_offload_cmd(hw
, (*(u8
*)val
));
483 u2btmp
= rtl_read_word(rtlpriv
, REG_BCN_PSR_RPT
);
485 rtl_write_word(rtlpriv
, REG_BCN_PSR_RPT
, (u2btmp
|
490 case HW_VAR_CORRECT_TSF
:{
491 u8 btype_ibss
= val
[0];
494 _rtl92ce_stop_tx_beacon(hw
);
496 _rtl92ce_set_bcn_ctrl_reg(hw
, 0, BIT(3));
498 rtl_write_dword(rtlpriv
, REG_TSFTR
,
499 (u32
) (mac
->tsf
& 0xffffffff));
500 rtl_write_dword(rtlpriv
, REG_TSFTR
+ 4,
501 (u32
) ((mac
->tsf
>> 32) & 0xffffffff));
503 _rtl92ce_set_bcn_ctrl_reg(hw
, BIT(3), 0);
506 _rtl92ce_resume_tx_beacon(hw
);
511 case HW_VAR_FW_LPS_ACTION
: {
512 bool enter_fwlps
= *((bool *)val
);
513 u8 rpwm_val
, fw_pwrmode
;
514 bool fw_current_inps
;
517 rpwm_val
= 0x02; /* RF off */
518 fw_current_inps
= true;
519 rtlpriv
->cfg
->ops
->set_hw_reg(hw
,
520 HW_VAR_FW_PSMODE_STATUS
,
521 (u8
*)(&fw_current_inps
));
522 rtlpriv
->cfg
->ops
->set_hw_reg(hw
,
523 HW_VAR_H2C_FW_PWRMODE
,
524 (u8
*)(&ppsc
->fwctrl_psmode
));
526 rtlpriv
->cfg
->ops
->set_hw_reg(hw
,
530 rpwm_val
= 0x0C; /* RF on */
531 fw_pwrmode
= FW_PS_ACTIVE_MODE
;
532 fw_current_inps
= false;
533 rtlpriv
->cfg
->ops
->set_hw_reg(hw
,
536 rtlpriv
->cfg
->ops
->set_hw_reg(hw
,
537 HW_VAR_H2C_FW_PWRMODE
,
538 (u8
*)(&fw_pwrmode
));
540 rtlpriv
->cfg
->ops
->set_hw_reg(hw
,
541 HW_VAR_FW_PSMODE_STATUS
,
542 (u8
*)(&fw_current_inps
));
546 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
547 "switch case not processed\n");
552 static bool _rtl92ce_llt_write(struct ieee80211_hw
*hw
, u32 address
, u32 data
)
554 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
557 u32 value
= _LLT_INIT_ADDR(address
) |
558 _LLT_INIT_DATA(data
) | _LLT_OP(_LLT_WRITE_ACCESS
);
560 rtl_write_dword(rtlpriv
, REG_LLT_INIT
, value
);
563 value
= rtl_read_dword(rtlpriv
, REG_LLT_INIT
);
564 if (_LLT_NO_ACTIVE
== _LLT_OP_VALUE(value
))
567 if (count
> POLLING_LLT_THRESHOLD
) {
568 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
569 "Failed to polling write LLT done at address %d!\n",
579 static bool _rtl92ce_llt_table_init(struct ieee80211_hw
*hw
)
581 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
590 #elif LLT_CONFIG == 2
593 #elif LLT_CONFIG == 3
596 #elif LLT_CONFIG == 4
599 #elif LLT_CONFIG == 5
605 rtl_write_byte(rtlpriv
, REG_RQPN_NPQ
, 0x1c);
606 rtl_write_dword(rtlpriv
, REG_RQPN
, 0x80a71c1c);
607 #elif LLT_CONFIG == 2
608 rtl_write_dword(rtlpriv
, REG_RQPN
, 0x845B1010);
609 #elif LLT_CONFIG == 3
610 rtl_write_dword(rtlpriv
, REG_RQPN
, 0x84838484);
611 #elif LLT_CONFIG == 4
612 rtl_write_dword(rtlpriv
, REG_RQPN
, 0x80bd1c1c);
613 #elif LLT_CONFIG == 5
614 rtl_write_word(rtlpriv
, REG_RQPN_NPQ
, 0x0000);
616 rtl_write_dword(rtlpriv
, REG_RQPN
, 0x80b01c29);
619 rtl_write_dword(rtlpriv
, REG_TRXFF_BNDY
, (0x27FF0000 | txpktbuf_bndy
));
620 rtl_write_byte(rtlpriv
, REG_TDECTRL
+ 1, txpktbuf_bndy
);
622 rtl_write_byte(rtlpriv
, REG_TXPKTBUF_BCNQ_BDNY
, txpktbuf_bndy
);
623 rtl_write_byte(rtlpriv
, REG_TXPKTBUF_MGQ_BDNY
, txpktbuf_bndy
);
625 rtl_write_byte(rtlpriv
, 0x45D, txpktbuf_bndy
);
626 rtl_write_byte(rtlpriv
, REG_PBP
, 0x11);
627 rtl_write_byte(rtlpriv
, REG_RX_DRVINFO_SZ
, 0x4);
629 for (i
= 0; i
< (txpktbuf_bndy
- 1); i
++) {
630 status
= _rtl92ce_llt_write(hw
, i
, i
+ 1);
635 status
= _rtl92ce_llt_write(hw
, (txpktbuf_bndy
- 1), 0xFF);
639 for (i
= txpktbuf_bndy
; i
< maxPage
; i
++) {
640 status
= _rtl92ce_llt_write(hw
, i
, (i
+ 1));
645 status
= _rtl92ce_llt_write(hw
, maxPage
, txpktbuf_bndy
);
652 static void _rtl92ce_gen_refresh_led_state(struct ieee80211_hw
*hw
)
654 struct rtl_pci_priv
*pcipriv
= rtl_pcipriv(hw
);
655 struct rtl_pci
*rtlpci
= rtl_pcidev(rtl_pcipriv(hw
));
656 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
657 struct rtl_led
*pLed0
= &(pcipriv
->ledctl
.sw_led0
);
659 if (rtlpci
->up_first_time
)
662 if (ppsc
->rfoff_reason
== RF_CHANGE_BY_IPS
)
663 rtl92ce_sw_led_on(hw
, pLed0
);
664 else if (ppsc
->rfoff_reason
== RF_CHANGE_BY_INIT
)
665 rtl92ce_sw_led_on(hw
, pLed0
);
667 rtl92ce_sw_led_off(hw
, pLed0
);
670 static bool _rtl92ce_init_mac(struct ieee80211_hw
*hw
)
672 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
673 struct rtl_pci_priv
*rtlpcipriv
= rtl_pcipriv(hw
);
674 struct rtl_pci
*rtlpci
= rtl_pcidev(rtl_pcipriv(hw
));
675 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
677 unsigned char bytetmp
;
678 unsigned short wordtmp
;
681 rtl_write_byte(rtlpriv
, REG_RSV_CTRL
, 0x00);
682 if (rtlpcipriv
->bt_coexist
.bt_coexistence
) {
684 value32
= rtl_read_dword(rtlpriv
, REG_APS_FSMCO
);
685 value32
|= (SOP_ABG
| SOP_AMB
| XOP_BTCK
);
686 rtl_write_dword(rtlpriv
, REG_APS_FSMCO
, value32
);
688 rtl_write_byte(rtlpriv
, REG_SPS0_CTRL
, 0x2b);
689 rtl_write_byte(rtlpriv
, REG_AFE_XTAL_CTRL
, 0x0F);
691 if (rtlpcipriv
->bt_coexist
.bt_coexistence
) {
692 u32 u4b_tmp
= rtl_read_dword(rtlpriv
, REG_AFE_XTAL_CTRL
);
694 u4b_tmp
&= (~0x00024800);
695 rtl_write_dword(rtlpriv
, REG_AFE_XTAL_CTRL
, u4b_tmp
);
698 bytetmp
= rtl_read_byte(rtlpriv
, REG_APS_FSMCO
+ 1) | BIT(0);
701 rtl_write_byte(rtlpriv
, REG_APS_FSMCO
+ 1, bytetmp
);
704 bytetmp
= rtl_read_byte(rtlpriv
, REG_APS_FSMCO
+ 1);
708 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_LOUD
, "reg0xec:%x:%x\n",
709 rtl_read_dword(rtlpriv
, 0xEC), bytetmp
);
711 while ((bytetmp
& BIT(0)) && retry
< 1000) {
714 bytetmp
= rtl_read_byte(rtlpriv
, REG_APS_FSMCO
+ 1);
715 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_LOUD
, "reg0xec:%x:%x\n",
716 rtl_read_dword(rtlpriv
, 0xEC), bytetmp
);
720 rtl_write_word(rtlpriv
, REG_APS_FSMCO
, 0x1012);
722 rtl_write_byte(rtlpriv
, REG_SYS_ISO_CTRL
+ 1, 0x82);
725 if (rtlpcipriv
->bt_coexist
.bt_coexistence
) {
726 bytetmp
= rtl_read_byte(rtlpriv
, REG_AFE_XTAL_CTRL
+2) & 0xfd;
727 rtl_write_byte(rtlpriv
, REG_AFE_XTAL_CTRL
+2, bytetmp
);
730 rtl_write_word(rtlpriv
, REG_CR
, 0x2ff);
732 if (!_rtl92ce_llt_table_init(hw
))
735 rtl_write_dword(rtlpriv
, REG_HISR
, 0xffffffff);
736 rtl_write_byte(rtlpriv
, REG_HISRE
, 0xff);
738 rtl_write_word(rtlpriv
, REG_TRXFF_BNDY
+ 2, 0x27ff);
740 wordtmp
= rtl_read_word(rtlpriv
, REG_TRXDMA_CTRL
);
743 rtl_write_word(rtlpriv
, REG_TRXDMA_CTRL
, wordtmp
);
745 rtl_write_byte(rtlpriv
, REG_FWHW_TXQ_CTRL
+ 1, 0x1F);
746 rtl_write_dword(rtlpriv
, REG_RCR
, rtlpci
->receive_config
);
747 rtl_write_dword(rtlpriv
, REG_TCR
, rtlpci
->transmit_config
);
749 rtl_write_byte(rtlpriv
, 0x4d0, 0x0);
751 rtl_write_dword(rtlpriv
, REG_BCNQ_DESA
,
752 ((u64
) rtlpci
->tx_ring
[BEACON_QUEUE
].dma
) &
754 rtl_write_dword(rtlpriv
, REG_MGQ_DESA
,
755 (u64
) rtlpci
->tx_ring
[MGNT_QUEUE
].dma
&
757 rtl_write_dword(rtlpriv
, REG_VOQ_DESA
,
758 (u64
) rtlpci
->tx_ring
[VO_QUEUE
].dma
& DMA_BIT_MASK(32));
759 rtl_write_dword(rtlpriv
, REG_VIQ_DESA
,
760 (u64
) rtlpci
->tx_ring
[VI_QUEUE
].dma
& DMA_BIT_MASK(32));
761 rtl_write_dword(rtlpriv
, REG_BEQ_DESA
,
762 (u64
) rtlpci
->tx_ring
[BE_QUEUE
].dma
& DMA_BIT_MASK(32));
763 rtl_write_dword(rtlpriv
, REG_BKQ_DESA
,
764 (u64
) rtlpci
->tx_ring
[BK_QUEUE
].dma
& DMA_BIT_MASK(32));
765 rtl_write_dword(rtlpriv
, REG_HQ_DESA
,
766 (u64
) rtlpci
->tx_ring
[HIGH_QUEUE
].dma
&
768 rtl_write_dword(rtlpriv
, REG_RX_DESA
,
769 (u64
) rtlpci
->rx_ring
[RX_MPDU_QUEUE
].dma
&
772 if (IS_92C_SERIAL(rtlhal
->version
))
773 rtl_write_byte(rtlpriv
, REG_PCIE_CTRL_REG
+ 3, 0x77);
775 rtl_write_byte(rtlpriv
, REG_PCIE_CTRL_REG
+ 3, 0x22);
777 rtl_write_dword(rtlpriv
, REG_INT_MIG
, 0);
779 bytetmp
= rtl_read_byte(rtlpriv
, REG_APSD_CTRL
);
780 rtl_write_byte(rtlpriv
, REG_APSD_CTRL
, bytetmp
& ~BIT(6));
783 bytetmp
= rtl_read_byte(rtlpriv
, REG_APSD_CTRL
);
784 } while ((retry
< 200) && (bytetmp
& BIT(7)));
786 _rtl92ce_gen_refresh_led_state(hw
);
788 rtl_write_dword(rtlpriv
, REG_MCUTST_1
, 0x0);
793 static void _rtl92ce_hw_configure(struct ieee80211_hw
*hw
)
795 struct rtl_pci
*rtlpci
= rtl_pcidev(rtl_pcipriv(hw
));
796 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
797 struct rtl_pci_priv
*rtlpcipriv
= rtl_pcipriv(hw
);
801 reg_bw_opmode
= BW_OPMODE_20MHZ
;
802 reg_prsr
= RATE_ALL_CCK
| RATE_ALL_OFDM_AG
;
804 rtl_write_byte(rtlpriv
, REG_INIRTS_RATE_SEL
, 0x8);
806 rtl_write_byte(rtlpriv
, REG_BWOPMODE
, reg_bw_opmode
);
808 rtl_write_dword(rtlpriv
, REG_RRSR
, reg_prsr
);
810 rtl_write_byte(rtlpriv
, REG_SLOT
, 0x09);
812 rtl_write_byte(rtlpriv
, REG_AMPDU_MIN_SPACE
, 0x0);
814 rtl_write_word(rtlpriv
, REG_FWHW_TXQ_CTRL
, 0x1F80);
816 rtl_write_word(rtlpriv
, REG_RL
, 0x0707);
818 rtl_write_dword(rtlpriv
, REG_BAR_MODE_CTRL
, 0x02012802);
820 rtl_write_byte(rtlpriv
, REG_HWSEQ_CTRL
, 0xFF);
822 rtl_write_dword(rtlpriv
, REG_DARFRC
, 0x01000000);
823 rtl_write_dword(rtlpriv
, REG_DARFRC
+ 4, 0x07060504);
824 rtl_write_dword(rtlpriv
, REG_RARFRC
, 0x01000000);
825 rtl_write_dword(rtlpriv
, REG_RARFRC
+ 4, 0x07060504);
827 if ((rtlpcipriv
->bt_coexist
.bt_coexistence
) &&
828 (rtlpcipriv
->bt_coexist
.bt_coexist_type
== BT_CSR_BC4
))
829 rtl_write_dword(rtlpriv
, REG_AGGLEN_LMT
, 0x97427431);
831 rtl_write_dword(rtlpriv
, REG_AGGLEN_LMT
, 0xb972a841);
833 rtl_write_byte(rtlpriv
, REG_ATIMWND
, 0x2);
835 rtl_write_byte(rtlpriv
, REG_BCN_MAX_ERR
, 0xff);
837 rtlpci
->reg_bcn_ctrl_val
= 0x1f;
838 rtl_write_byte(rtlpriv
, REG_BCN_CTRL
, rtlpci
->reg_bcn_ctrl_val
);
840 rtl_write_byte(rtlpriv
, REG_TBTT_PROHIBIT
+ 1, 0xff);
842 rtl_write_byte(rtlpriv
, REG_TBTT_PROHIBIT
+ 1, 0xff);
844 rtl_write_byte(rtlpriv
, REG_PIFS
, 0x1C);
845 rtl_write_byte(rtlpriv
, REG_AGGR_BREAK_TIME
, 0x16);
847 if ((rtlpcipriv
->bt_coexist
.bt_coexistence
) &&
848 (rtlpcipriv
->bt_coexist
.bt_coexist_type
== BT_CSR_BC4
)) {
849 rtl_write_word(rtlpriv
, REG_NAV_PROT_LEN
, 0x0020);
850 rtl_write_word(rtlpriv
, REG_PROT_MODE_CTRL
, 0x0402);
852 rtl_write_word(rtlpriv
, REG_NAV_PROT_LEN
, 0x0020);
853 rtl_write_word(rtlpriv
, REG_NAV_PROT_LEN
, 0x0020);
856 if ((rtlpcipriv
->bt_coexist
.bt_coexistence
) &&
857 (rtlpcipriv
->bt_coexist
.bt_coexist_type
== BT_CSR_BC4
))
858 rtl_write_dword(rtlpriv
, REG_FAST_EDCA_CTRL
, 0x03086666);
860 rtl_write_dword(rtlpriv
, REG_FAST_EDCA_CTRL
, 0x086666);
862 rtl_write_byte(rtlpriv
, REG_ACKTO
, 0x40);
864 rtl_write_word(rtlpriv
, REG_SPEC_SIFS
, 0x1010);
865 rtl_write_word(rtlpriv
, REG_MAC_SPEC_SIFS
, 0x1010);
867 rtl_write_word(rtlpriv
, REG_SIFS_CTX
, 0x1010);
869 rtl_write_word(rtlpriv
, REG_SIFS_TRX
, 0x1010);
871 rtl_write_dword(rtlpriv
, REG_MAR
, 0xffffffff);
872 rtl_write_dword(rtlpriv
, REG_MAR
+ 4, 0xffffffff);
876 static void _rtl92ce_enable_aspm_back_door(struct ieee80211_hw
*hw
)
878 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
879 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
881 rtl_write_byte(rtlpriv
, 0x34b, 0x93);
882 rtl_write_word(rtlpriv
, 0x350, 0x870c);
883 rtl_write_byte(rtlpriv
, 0x352, 0x1);
885 if (ppsc
->support_backdoor
)
886 rtl_write_byte(rtlpriv
, 0x349, 0x1b);
888 rtl_write_byte(rtlpriv
, 0x349, 0x03);
890 rtl_write_word(rtlpriv
, 0x350, 0x2718);
891 rtl_write_byte(rtlpriv
, 0x352, 0x1);
894 void rtl92ce_enable_hw_security_config(struct ieee80211_hw
*hw
)
896 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
899 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_LOUD
,
900 "PairwiseEncAlgorithm = %d GroupEncAlgorithm = %d\n",
901 rtlpriv
->sec
.pairwise_enc_algorithm
,
902 rtlpriv
->sec
.group_enc_algorithm
);
904 if (rtlpriv
->cfg
->mod_params
->sw_crypto
|| rtlpriv
->sec
.use_sw_sec
) {
905 RT_TRACE(rtlpriv
, COMP_SEC
, DBG_DMESG
,
906 "not open hw encryption\n");
910 sec_reg_value
= SCR_TxEncEnable
| SCR_RxDecEnable
;
912 if (rtlpriv
->sec
.use_defaultkey
) {
913 sec_reg_value
|= SCR_TxUseDK
;
914 sec_reg_value
|= SCR_RxUseDK
;
917 sec_reg_value
|= (SCR_RXBCUSEDK
| SCR_TXBCUSEDK
);
919 rtl_write_byte(rtlpriv
, REG_CR
+ 1, 0x02);
921 RT_TRACE(rtlpriv
, COMP_SEC
, DBG_LOUD
,
922 "The SECR-value %x\n", sec_reg_value
);
924 rtlpriv
->cfg
->ops
->set_hw_reg(hw
, HW_VAR_WPA_CONFIG
, &sec_reg_value
);
928 int rtl92ce_hw_init(struct ieee80211_hw
*hw
)
930 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
931 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
932 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
933 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
934 struct rtl_pci
*rtlpci
= rtl_pcidev(rtl_pcipriv(hw
));
935 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
936 bool rtstatus
= true;
941 rtlpci
->being_init_adapter
= true;
942 rtlpriv
->intf_ops
->disable_aspm(hw
);
943 rtstatus
= _rtl92ce_init_mac(hw
);
945 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
, "Init MAC failed\n");
950 err
= rtl92c_download_fw(hw
);
952 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_WARNING
,
953 "Failed to download FW. Init HW without FW now..\n");
958 rtlhal
->last_hmeboxnum
= 0;
959 rtl92c_phy_mac_config(hw
);
960 /* because last function modify RCR, so we update
961 * rcr var here, or TP will unstable for receive_config
962 * is wrong, RX RCR_ACRC32 will cause TP unstabel & Rx
963 * RCR_APP_ICV will cause mac80211 unassoc for cisco 1252*/
964 rtlpci
->receive_config
= rtl_read_dword(rtlpriv
, REG_RCR
);
965 rtlpci
->receive_config
&= ~(RCR_ACRC32
| RCR_AICV
);
966 rtl_write_dword(rtlpriv
, REG_RCR
, rtlpci
->receive_config
);
967 rtl92c_phy_bb_config(hw
);
968 rtlphy
->rf_mode
= RF_OP_BY_SW_3WIRE
;
969 rtl92c_phy_rf_config(hw
);
970 if (IS_VENDOR_UMC_A_CUT(rtlhal
->version
) &&
971 !IS_92C_SERIAL(rtlhal
->version
)) {
972 rtl_set_rfreg(hw
, RF90_PATH_A
, RF_RX_G1
, MASKDWORD
, 0x30255);
973 rtl_set_rfreg(hw
, RF90_PATH_A
, RF_RX_G2
, MASKDWORD
, 0x50a00);
974 } else if (IS_81xxC_VENDOR_UMC_B_CUT(rtlhal
->version
)) {
975 rtl_set_rfreg(hw
, RF90_PATH_A
, 0x0C, MASKDWORD
, 0x894AE);
976 rtl_set_rfreg(hw
, RF90_PATH_A
, 0x0A, MASKDWORD
, 0x1AF31);
977 rtl_set_rfreg(hw
, RF90_PATH_A
, RF_IPA
, MASKDWORD
, 0x8F425);
978 rtl_set_rfreg(hw
, RF90_PATH_A
, RF_SYN_G2
, MASKDWORD
, 0x4F200);
979 rtl_set_rfreg(hw
, RF90_PATH_A
, RF_RCK1
, MASKDWORD
, 0x44053);
980 rtl_set_rfreg(hw
, RF90_PATH_A
, RF_RCK2
, MASKDWORD
, 0x80201);
982 rtlphy
->rfreg_chnlval
[0] = rtl_get_rfreg(hw
, (enum radio_path
)0,
983 RF_CHNLBW
, RFREG_OFFSET_MASK
);
984 rtlphy
->rfreg_chnlval
[1] = rtl_get_rfreg(hw
, (enum radio_path
)1,
985 RF_CHNLBW
, RFREG_OFFSET_MASK
);
986 rtl_set_bbreg(hw
, RFPGA0_RFMOD
, BCCKEN
, 0x1);
987 rtl_set_bbreg(hw
, RFPGA0_RFMOD
, BOFDMEN
, 0x1);
988 rtl_set_bbreg(hw
, RFPGA0_ANALOGPARAMETER2
, BIT(10), 1);
989 _rtl92ce_hw_configure(hw
);
990 rtl_cam_reset_all_entry(hw
);
991 rtl92ce_enable_hw_security_config(hw
);
993 ppsc
->rfpwr_state
= ERFON
;
995 rtlpriv
->cfg
->ops
->set_hw_reg(hw
, HW_VAR_ETHER_ADDR
, mac
->mac_addr
);
996 _rtl92ce_enable_aspm_back_door(hw
);
997 rtlpriv
->intf_ops
->enable_aspm(hw
);
999 rtl8192ce_bt_hw_init(hw
);
1001 if (ppsc
->rfpwr_state
== ERFON
) {
1002 rtl92c_phy_set_rfpath_switch(hw
, 1);
1003 if (rtlphy
->iqk_initialized
) {
1004 rtl92c_phy_iq_calibrate(hw
, true);
1006 rtl92c_phy_iq_calibrate(hw
, false);
1007 rtlphy
->iqk_initialized
= true;
1010 rtl92c_dm_check_txpower_tracking(hw
);
1011 rtl92c_phy_lc_calibrate(hw
);
1014 is92c
= IS_92C_SERIAL(rtlhal
->version
);
1015 tmp_u1b
= efuse_read_1byte(hw
, 0x1FA);
1016 if (!(tmp_u1b
& BIT(0))) {
1017 rtl_set_rfreg(hw
, RF90_PATH_A
, 0x15, 0x0F, 0x05);
1018 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
, "PA BIAS path A\n");
1021 if (!(tmp_u1b
& BIT(1)) && is92c
) {
1022 rtl_set_rfreg(hw
, RF90_PATH_B
, 0x15, 0x0F, 0x05);
1023 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
, "PA BIAS path B\n");
1026 if (!(tmp_u1b
& BIT(4))) {
1027 tmp_u1b
= rtl_read_byte(rtlpriv
, 0x16);
1029 rtl_write_byte(rtlpriv
, 0x16, tmp_u1b
| 0x80);
1031 rtl_write_byte(rtlpriv
, 0x16, tmp_u1b
| 0x90);
1032 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
, "under 1.5V\n");
1035 rtlpci
->being_init_adapter
= false;
1039 static enum version_8192c
_rtl92ce_read_chip_version(struct ieee80211_hw
*hw
)
1041 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1042 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
1043 enum version_8192c version
= VERSION_UNKNOWN
;
1045 const char *versionid
;
1047 value32
= rtl_read_dword(rtlpriv
, REG_SYS_CFG
);
1048 if (value32
& TRP_VAUX_EN
) {
1049 version
= (value32
& TYPE_ID
) ? VERSION_A_CHIP_92C
:
1052 version
= (enum version_8192c
) (CHIP_VER_B
|
1053 ((value32
& TYPE_ID
) ? CHIP_92C_BITMASK
: 0) |
1054 ((value32
& VENDOR_ID
) ? CHIP_VENDOR_UMC
: 0));
1055 if ((!IS_CHIP_VENDOR_UMC(version
)) && (value32
&
1056 CHIP_VER_RTL_MASK
)) {
1057 version
= (enum version_8192c
)(version
|
1058 ((((value32
& CHIP_VER_RTL_MASK
) == BIT(12))
1059 ? CHIP_VENDOR_UMC_B_CUT
: CHIP_UNKNOWN
) |
1062 if (IS_92C_SERIAL(version
)) {
1063 value32
= rtl_read_dword(rtlpriv
, REG_HPON_FSM
);
1064 version
= (enum version_8192c
)(version
|
1065 ((CHIP_BONDING_IDENTIFIER(value32
)
1066 == CHIP_BONDING_92C_1T2R
) ?
1072 case VERSION_B_CHIP_92C
:
1073 versionid
= "B_CHIP_92C";
1075 case VERSION_B_CHIP_88C
:
1076 versionid
= "B_CHIP_88C";
1078 case VERSION_A_CHIP_92C
:
1079 versionid
= "A_CHIP_92C";
1081 case VERSION_A_CHIP_88C
:
1082 versionid
= "A_CHIP_88C";
1084 case VERSION_NORMAL_UMC_CHIP_92C_1T2R_A_CUT
:
1085 versionid
= "A_CUT_92C_1T2R";
1087 case VERSION_NORMAL_UMC_CHIP_92C_A_CUT
:
1088 versionid
= "A_CUT_92C";
1090 case VERSION_NORMAL_UMC_CHIP_88C_A_CUT
:
1091 versionid
= "A_CUT_88C";
1093 case VERSION_NORMAL_UMC_CHIP_92C_1T2R_B_CUT
:
1094 versionid
= "B_CUT_92C_1T2R";
1096 case VERSION_NORMAL_UMC_CHIP_92C_B_CUT
:
1097 versionid
= "B_CUT_92C";
1099 case VERSION_NORMAL_UMC_CHIP_88C_B_CUT
:
1100 versionid
= "B_CUT_88C";
1103 versionid
= "Unknown. Bug?";
1107 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_EMERG
,
1108 "Chip Version ID: %s\n", versionid
);
1110 switch (version
& 0x3) {
1112 rtlphy
->rf_type
= RF_1T1R
;
1115 rtlphy
->rf_type
= RF_2T2R
;
1118 rtlphy
->rf_type
= RF_1T2R
;
1121 rtlphy
->rf_type
= RF_1T1R
;
1122 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
1123 "ERROR RF_Type is set!!\n");
1127 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_LOUD
, "Chip RF Type: %s\n",
1128 rtlphy
->rf_type
== RF_2T2R
? "RF_2T2R" : "RF_1T1R");
1133 static int _rtl92ce_set_media_status(struct ieee80211_hw
*hw
,
1134 enum nl80211_iftype type
)
1136 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1137 u8 bt_msr
= rtl_read_byte(rtlpriv
, MSR
);
1138 enum led_ctl_mode ledaction
= LED_CTL_NO_LINK
;
1141 if (type
== NL80211_IFTYPE_UNSPECIFIED
||
1142 type
== NL80211_IFTYPE_STATION
) {
1143 _rtl92ce_stop_tx_beacon(hw
);
1144 _rtl92ce_enable_bcn_sub_func(hw
);
1145 } else if (type
== NL80211_IFTYPE_ADHOC
|| type
== NL80211_IFTYPE_AP
||
1146 type
== NL80211_IFTYPE_MESH_POINT
) {
1147 _rtl92ce_resume_tx_beacon(hw
);
1148 _rtl92ce_disable_bcn_sub_func(hw
);
1150 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_WARNING
,
1151 "Set HW_VAR_MEDIA_STATUS: No such media status(%x)\n",
1156 case NL80211_IFTYPE_UNSPECIFIED
:
1157 bt_msr
|= MSR_NOLINK
;
1158 ledaction
= LED_CTL_LINK
;
1159 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
1160 "Set Network type to NO LINK!\n");
1162 case NL80211_IFTYPE_ADHOC
:
1163 bt_msr
|= MSR_ADHOC
;
1164 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
1165 "Set Network type to Ad Hoc!\n");
1167 case NL80211_IFTYPE_STATION
:
1168 bt_msr
|= MSR_INFRA
;
1169 ledaction
= LED_CTL_LINK
;
1170 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
1171 "Set Network type to STA!\n");
1173 case NL80211_IFTYPE_AP
:
1175 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
1176 "Set Network type to AP!\n");
1178 case NL80211_IFTYPE_MESH_POINT
:
1179 bt_msr
|= MSR_ADHOC
;
1180 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
1181 "Set Network type to Mesh Point!\n");
1184 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
1185 "Network type %d not supported!\n", type
);
1191 rtl_write_byte(rtlpriv
, (MSR
), bt_msr
);
1192 rtlpriv
->cfg
->ops
->led_control(hw
, ledaction
);
1193 if ((bt_msr
& 0xfc) == MSR_AP
)
1194 rtl_write_byte(rtlpriv
, REG_BCNTCFG
+ 1, 0x00);
1196 rtl_write_byte(rtlpriv
, REG_BCNTCFG
+ 1, 0x66);
1200 void rtl92ce_set_check_bssid(struct ieee80211_hw
*hw
, bool check_bssid
)
1202 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1203 u32 reg_rcr
= rtl_read_dword(rtlpriv
, REG_RCR
);
1205 if (rtlpriv
->psc
.rfpwr_state
!= ERFON
)
1209 reg_rcr
|= (RCR_CBSSID_DATA
| RCR_CBSSID_BCN
);
1210 rtlpriv
->cfg
->ops
->set_hw_reg(hw
, HW_VAR_RCR
,
1212 _rtl92ce_set_bcn_ctrl_reg(hw
, 0, BIT(4));
1213 } else if (!check_bssid
) {
1214 reg_rcr
&= (~(RCR_CBSSID_DATA
| RCR_CBSSID_BCN
));
1215 _rtl92ce_set_bcn_ctrl_reg(hw
, BIT(4), 0);
1216 rtlpriv
->cfg
->ops
->set_hw_reg(hw
,
1217 HW_VAR_RCR
, (u8
*) (®_rcr
));
1222 int rtl92ce_set_network_type(struct ieee80211_hw
*hw
, enum nl80211_iftype type
)
1224 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1226 if (_rtl92ce_set_media_status(hw
, type
))
1229 if (rtlpriv
->mac80211
.link_state
== MAC80211_LINKED
) {
1230 if (type
!= NL80211_IFTYPE_AP
&&
1231 type
!= NL80211_IFTYPE_MESH_POINT
)
1232 rtl92ce_set_check_bssid(hw
, true);
1234 rtl92ce_set_check_bssid(hw
, false);
1240 /* don't set REG_EDCA_BE_PARAM here because mac80211 will send pkt when scan */
1241 void rtl92ce_set_qos(struct ieee80211_hw
*hw
, int aci
)
1243 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1244 rtl92c_dm_init_edca_turbo(hw
);
1247 rtl_write_dword(rtlpriv
, REG_EDCA_BK_PARAM
, 0xa44f);
1250 /* rtl_write_dword(rtlpriv, REG_EDCA_BE_PARAM, u4b_ac_param); */
1253 rtl_write_dword(rtlpriv
, REG_EDCA_VI_PARAM
, 0x5e4322);
1256 rtl_write_dword(rtlpriv
, REG_EDCA_VO_PARAM
, 0x2f3222);
1259 RT_ASSERT(false, "invalid aci: %d !\n", aci
);
1264 void rtl92ce_enable_interrupt(struct ieee80211_hw
*hw
)
1266 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1267 struct rtl_pci
*rtlpci
= rtl_pcidev(rtl_pcipriv(hw
));
1269 rtl_write_dword(rtlpriv
, REG_HIMR
, rtlpci
->irq_mask
[0] & 0xFFFFFFFF);
1270 rtl_write_dword(rtlpriv
, REG_HIMRE
, rtlpci
->irq_mask
[1] & 0xFFFFFFFF);
1273 void rtl92ce_disable_interrupt(struct ieee80211_hw
*hw
)
1275 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1276 struct rtl_pci
*rtlpci
= rtl_pcidev(rtl_pcipriv(hw
));
1278 rtl_write_dword(rtlpriv
, REG_HIMR
, IMR8190_DISABLED
);
1279 rtl_write_dword(rtlpriv
, REG_HIMRE
, IMR8190_DISABLED
);
1280 synchronize_irq(rtlpci
->pdev
->irq
);
1283 static void _rtl92ce_poweroff_adapter(struct ieee80211_hw
*hw
)
1285 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1286 struct rtl_pci_priv
*rtlpcipriv
= rtl_pcipriv(hw
);
1287 struct rtl_hal
*rtlhal
= rtl_hal(rtlpriv
);
1291 rtlpriv
->intf_ops
->enable_aspm(hw
);
1292 rtl_write_byte(rtlpriv
, REG_TXPAUSE
, 0xFF);
1293 rtl_set_rfreg(hw
, RF90_PATH_A
, 0x00, RFREG_OFFSET_MASK
, 0x00);
1294 rtl_write_byte(rtlpriv
, REG_RF_CTRL
, 0x00);
1295 rtl_write_byte(rtlpriv
, REG_APSD_CTRL
, 0x40);
1296 rtl_write_byte(rtlpriv
, REG_SYS_FUNC_EN
, 0xE2);
1297 rtl_write_byte(rtlpriv
, REG_SYS_FUNC_EN
, 0xE0);
1298 if (rtl_read_byte(rtlpriv
, REG_MCUFWDL
) & BIT(7))
1299 rtl92c_firmware_selfreset(hw
);
1300 rtl_write_byte(rtlpriv
, REG_SYS_FUNC_EN
+ 1, 0x51);
1301 rtl_write_byte(rtlpriv
, REG_MCUFWDL
, 0x00);
1302 rtl_write_dword(rtlpriv
, REG_GPIO_PIN_CTRL
, 0x00000000);
1303 u1b_tmp
= rtl_read_byte(rtlpriv
, REG_GPIO_PIN_CTRL
);
1304 if ((rtlpcipriv
->bt_coexist
.bt_coexistence
) &&
1305 ((rtlpcipriv
->bt_coexist
.bt_coexist_type
== BT_CSR_BC4
) ||
1306 (rtlpcipriv
->bt_coexist
.bt_coexist_type
== BT_CSR_BC8
))) {
1307 rtl_write_dword(rtlpriv
, REG_GPIO_PIN_CTRL
, 0x00F30000 |
1310 rtl_write_dword(rtlpriv
, REG_GPIO_PIN_CTRL
, 0x00FF0000 |
1313 rtl_write_word(rtlpriv
, REG_GPIO_IO_SEL
, 0x0790);
1314 rtl_write_word(rtlpriv
, REG_LEDCFG0
, 0x8080);
1315 rtl_write_byte(rtlpriv
, REG_AFE_PLL_CTRL
, 0x80);
1316 if (!IS_81xxC_VENDOR_UMC_B_CUT(rtlhal
->version
))
1317 rtl_write_byte(rtlpriv
, REG_SPS0_CTRL
, 0x23);
1318 if (rtlpcipriv
->bt_coexist
.bt_coexistence
) {
1319 u4b_tmp
= rtl_read_dword(rtlpriv
, REG_AFE_XTAL_CTRL
);
1320 u4b_tmp
|= 0x03824800;
1321 rtl_write_dword(rtlpriv
, REG_AFE_XTAL_CTRL
, u4b_tmp
);
1323 rtl_write_dword(rtlpriv
, REG_AFE_XTAL_CTRL
, 0x0e);
1326 rtl_write_byte(rtlpriv
, REG_RSV_CTRL
, 0x0e);
1327 rtl_write_byte(rtlpriv
, REG_APS_FSMCO
+ 1, 0x10);
1330 void rtl92ce_card_disable(struct ieee80211_hw
*hw
)
1332 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1333 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
1334 struct rtl_pci
*rtlpci
= rtl_pcidev(rtl_pcipriv(hw
));
1335 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
1336 enum nl80211_iftype opmode
;
1338 mac
->link_state
= MAC80211_NOLINK
;
1339 opmode
= NL80211_IFTYPE_UNSPECIFIED
;
1340 _rtl92ce_set_media_status(hw
, opmode
);
1341 if (rtlpci
->driver_is_goingto_unload
||
1342 ppsc
->rfoff_reason
> RF_CHANGE_BY_PS
)
1343 rtlpriv
->cfg
->ops
->led_control(hw
, LED_CTL_POWER_OFF
);
1344 RT_SET_PS_LEVEL(ppsc
, RT_RF_OFF_LEVL_HALT_NIC
);
1345 _rtl92ce_poweroff_adapter(hw
);
1347 /* after power off we should do iqk again */
1348 rtlpriv
->phy
.iqk_initialized
= false;
1351 void rtl92ce_interrupt_recognized(struct ieee80211_hw
*hw
,
1352 u32
*p_inta
, u32
*p_intb
)
1354 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1355 struct rtl_pci
*rtlpci
= rtl_pcidev(rtl_pcipriv(hw
));
1357 *p_inta
= rtl_read_dword(rtlpriv
, ISR
) & rtlpci
->irq_mask
[0];
1358 rtl_write_dword(rtlpriv
, ISR
, *p_inta
);
1361 * *p_intb = rtl_read_dword(rtlpriv, REG_HISRE) & rtlpci->irq_mask[1];
1362 * rtl_write_dword(rtlpriv, ISR + 4, *p_intb);
1366 void rtl92ce_set_beacon_related_registers(struct ieee80211_hw
*hw
)
1369 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1370 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
1371 u16 bcn_interval
, atim_window
;
1373 bcn_interval
= mac
->beacon_interval
;
1374 atim_window
= 2; /*FIX MERGE */
1375 rtl92ce_disable_interrupt(hw
);
1376 rtl_write_word(rtlpriv
, REG_ATIMWND
, atim_window
);
1377 rtl_write_word(rtlpriv
, REG_BCN_INTERVAL
, bcn_interval
);
1378 rtl_write_word(rtlpriv
, REG_BCNTCFG
, 0x660f);
1379 rtl_write_byte(rtlpriv
, REG_RXTSF_OFFSET_CCK
, 0x18);
1380 rtl_write_byte(rtlpriv
, REG_RXTSF_OFFSET_OFDM
, 0x18);
1381 rtl_write_byte(rtlpriv
, 0x606, 0x30);
1382 rtl92ce_enable_interrupt(hw
);
1385 void rtl92ce_set_beacon_interval(struct ieee80211_hw
*hw
)
1387 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1388 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
1389 u16 bcn_interval
= mac
->beacon_interval
;
1391 RT_TRACE(rtlpriv
, COMP_BEACON
, DBG_DMESG
,
1392 "beacon_interval:%d\n", bcn_interval
);
1393 rtl92ce_disable_interrupt(hw
);
1394 rtl_write_word(rtlpriv
, REG_BCN_INTERVAL
, bcn_interval
);
1395 rtl92ce_enable_interrupt(hw
);
1398 void rtl92ce_update_interrupt_mask(struct ieee80211_hw
*hw
,
1399 u32 add_msr
, u32 rm_msr
)
1401 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1402 struct rtl_pci
*rtlpci
= rtl_pcidev(rtl_pcipriv(hw
));
1404 RT_TRACE(rtlpriv
, COMP_INTR
, DBG_LOUD
, "add_msr:%x, rm_msr:%x\n",
1408 rtlpci
->irq_mask
[0] |= add_msr
;
1410 rtlpci
->irq_mask
[0] &= (~rm_msr
);
1411 rtl92ce_disable_interrupt(hw
);
1412 rtl92ce_enable_interrupt(hw
);
1415 static void _rtl92ce_read_txpower_info_from_hwpg(struct ieee80211_hw
*hw
,
1419 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1420 struct rtl_efuse
*rtlefuse
= rtl_efuse(rtl_priv(hw
));
1421 u8 rf_path
, index
, tempval
;
1424 for (rf_path
= 0; rf_path
< 2; rf_path
++) {
1425 for (i
= 0; i
< 3; i
++) {
1426 if (!autoload_fail
) {
1428 eeprom_chnlarea_txpwr_cck
[rf_path
][i
] =
1429 hwinfo
[EEPROM_TXPOWERCCK
+ rf_path
* 3 + i
];
1431 eeprom_chnlarea_txpwr_ht40_1s
[rf_path
][i
] =
1432 hwinfo
[EEPROM_TXPOWERHT40_1S
+ rf_path
* 3 +
1436 eeprom_chnlarea_txpwr_cck
[rf_path
][i
] =
1437 EEPROM_DEFAULT_TXPOWERLEVEL
;
1439 eeprom_chnlarea_txpwr_ht40_1s
[rf_path
][i
] =
1440 EEPROM_DEFAULT_TXPOWERLEVEL
;
1445 for (i
= 0; i
< 3; i
++) {
1447 tempval
= hwinfo
[EEPROM_TXPOWERHT40_2SDIFF
+ i
];
1449 tempval
= EEPROM_DEFAULT_HT40_2SDIFF
;
1450 rtlefuse
->eprom_chnl_txpwr_ht40_2sdf
[RF90_PATH_A
][i
] =
1452 rtlefuse
->eprom_chnl_txpwr_ht40_2sdf
[RF90_PATH_B
][i
] =
1453 ((tempval
& 0xf0) >> 4);
1456 for (rf_path
= 0; rf_path
< 2; rf_path
++)
1457 for (i
= 0; i
< 3; i
++)
1458 RTPRINT(rtlpriv
, FINIT
, INIT_EEPROM
,
1459 "RF(%d) EEPROM CCK Area(%d) = 0x%x\n",
1462 eeprom_chnlarea_txpwr_cck
[rf_path
][i
]);
1463 for (rf_path
= 0; rf_path
< 2; rf_path
++)
1464 for (i
= 0; i
< 3; i
++)
1465 RTPRINT(rtlpriv
, FINIT
, INIT_EEPROM
,
1466 "RF(%d) EEPROM HT40 1S Area(%d) = 0x%x\n",
1469 eeprom_chnlarea_txpwr_ht40_1s
[rf_path
][i
]);
1470 for (rf_path
= 0; rf_path
< 2; rf_path
++)
1471 for (i
= 0; i
< 3; i
++)
1472 RTPRINT(rtlpriv
, FINIT
, INIT_EEPROM
,
1473 "RF(%d) EEPROM HT40 2S Diff Area(%d) = 0x%x\n",
1476 eprom_chnl_txpwr_ht40_2sdf
[rf_path
][i
]);
1478 for (rf_path
= 0; rf_path
< 2; rf_path
++) {
1479 for (i
= 0; i
< 14; i
++) {
1480 index
= _rtl92c_get_chnl_group((u8
) i
);
1482 rtlefuse
->txpwrlevel_cck
[rf_path
][i
] =
1483 rtlefuse
->eeprom_chnlarea_txpwr_cck
[rf_path
][index
];
1484 rtlefuse
->txpwrlevel_ht40_1s
[rf_path
][i
] =
1486 eeprom_chnlarea_txpwr_ht40_1s
[rf_path
][index
];
1489 eeprom_chnlarea_txpwr_ht40_1s
[rf_path
][index
] -
1491 eprom_chnl_txpwr_ht40_2sdf
[rf_path
][index
])
1493 rtlefuse
->txpwrlevel_ht40_2s
[rf_path
][i
] =
1495 eeprom_chnlarea_txpwr_ht40_1s
[rf_path
]
1498 eprom_chnl_txpwr_ht40_2sdf
[rf_path
]
1501 rtlefuse
->txpwrlevel_ht40_2s
[rf_path
][i
] = 0;
1505 for (i
= 0; i
< 14; i
++) {
1506 RTPRINT(rtlpriv
, FINIT
, INIT_TXPOWER
,
1507 "RF(%d)-Ch(%d) [CCK / HT40_1S / HT40_2S] = [0x%x / 0x%x / 0x%x]\n",
1509 rtlefuse
->txpwrlevel_cck
[rf_path
][i
],
1510 rtlefuse
->txpwrlevel_ht40_1s
[rf_path
][i
],
1511 rtlefuse
->txpwrlevel_ht40_2s
[rf_path
][i
]);
1515 for (i
= 0; i
< 3; i
++) {
1516 if (!autoload_fail
) {
1517 rtlefuse
->eeprom_pwrlimit_ht40
[i
] =
1518 hwinfo
[EEPROM_TXPWR_GROUP
+ i
];
1519 rtlefuse
->eeprom_pwrlimit_ht20
[i
] =
1520 hwinfo
[EEPROM_TXPWR_GROUP
+ 3 + i
];
1522 rtlefuse
->eeprom_pwrlimit_ht40
[i
] = 0;
1523 rtlefuse
->eeprom_pwrlimit_ht20
[i
] = 0;
1527 for (rf_path
= 0; rf_path
< 2; rf_path
++) {
1528 for (i
= 0; i
< 14; i
++) {
1529 index
= _rtl92c_get_chnl_group((u8
) i
);
1531 if (rf_path
== RF90_PATH_A
) {
1532 rtlefuse
->pwrgroup_ht20
[rf_path
][i
] =
1533 (rtlefuse
->eeprom_pwrlimit_ht20
[index
]
1535 rtlefuse
->pwrgroup_ht40
[rf_path
][i
] =
1536 (rtlefuse
->eeprom_pwrlimit_ht40
[index
]
1538 } else if (rf_path
== RF90_PATH_B
) {
1539 rtlefuse
->pwrgroup_ht20
[rf_path
][i
] =
1540 ((rtlefuse
->eeprom_pwrlimit_ht20
[index
]
1542 rtlefuse
->pwrgroup_ht40
[rf_path
][i
] =
1543 ((rtlefuse
->eeprom_pwrlimit_ht40
[index
]
1547 RTPRINT(rtlpriv
, FINIT
, INIT_TXPOWER
,
1548 "RF-%d pwrgroup_ht20[%d] = 0x%x\n",
1550 rtlefuse
->pwrgroup_ht20
[rf_path
][i
]);
1551 RTPRINT(rtlpriv
, FINIT
, INIT_TXPOWER
,
1552 "RF-%d pwrgroup_ht40[%d] = 0x%x\n",
1554 rtlefuse
->pwrgroup_ht40
[rf_path
][i
]);
1558 for (i
= 0; i
< 14; i
++) {
1559 index
= _rtl92c_get_chnl_group((u8
) i
);
1562 tempval
= hwinfo
[EEPROM_TXPOWERHT20DIFF
+ index
];
1564 tempval
= EEPROM_DEFAULT_HT20_DIFF
;
1566 rtlefuse
->txpwr_ht20diff
[RF90_PATH_A
][i
] = (tempval
& 0xF);
1567 rtlefuse
->txpwr_ht20diff
[RF90_PATH_B
][i
] =
1568 ((tempval
>> 4) & 0xF);
1570 if (rtlefuse
->txpwr_ht20diff
[RF90_PATH_A
][i
] & BIT(3))
1571 rtlefuse
->txpwr_ht20diff
[RF90_PATH_A
][i
] |= 0xF0;
1573 if (rtlefuse
->txpwr_ht20diff
[RF90_PATH_B
][i
] & BIT(3))
1574 rtlefuse
->txpwr_ht20diff
[RF90_PATH_B
][i
] |= 0xF0;
1576 index
= _rtl92c_get_chnl_group((u8
) i
);
1579 tempval
= hwinfo
[EEPROM_TXPOWER_OFDMDIFF
+ index
];
1581 tempval
= EEPROM_DEFAULT_LEGACYHTTXPOWERDIFF
;
1583 rtlefuse
->txpwr_legacyhtdiff
[RF90_PATH_A
][i
] = (tempval
& 0xF);
1584 rtlefuse
->txpwr_legacyhtdiff
[RF90_PATH_B
][i
] =
1585 ((tempval
>> 4) & 0xF);
1588 rtlefuse
->legacy_ht_txpowerdiff
=
1589 rtlefuse
->txpwr_legacyhtdiff
[RF90_PATH_A
][7];
1591 for (i
= 0; i
< 14; i
++)
1592 RTPRINT(rtlpriv
, FINIT
, INIT_TXPOWER
,
1593 "RF-A Ht20 to HT40 Diff[%d] = 0x%x\n",
1594 i
, rtlefuse
->txpwr_ht20diff
[RF90_PATH_A
][i
]);
1595 for (i
= 0; i
< 14; i
++)
1596 RTPRINT(rtlpriv
, FINIT
, INIT_TXPOWER
,
1597 "RF-A Legacy to Ht40 Diff[%d] = 0x%x\n",
1598 i
, rtlefuse
->txpwr_legacyhtdiff
[RF90_PATH_A
][i
]);
1599 for (i
= 0; i
< 14; i
++)
1600 RTPRINT(rtlpriv
, FINIT
, INIT_TXPOWER
,
1601 "RF-B Ht20 to HT40 Diff[%d] = 0x%x\n",
1602 i
, rtlefuse
->txpwr_ht20diff
[RF90_PATH_B
][i
]);
1603 for (i
= 0; i
< 14; i
++)
1604 RTPRINT(rtlpriv
, FINIT
, INIT_TXPOWER
,
1605 "RF-B Legacy to HT40 Diff[%d] = 0x%x\n",
1606 i
, rtlefuse
->txpwr_legacyhtdiff
[RF90_PATH_B
][i
]);
1609 rtlefuse
->eeprom_regulatory
= (hwinfo
[RF_OPTION1
] & 0x7);
1611 rtlefuse
->eeprom_regulatory
= 0;
1612 RTPRINT(rtlpriv
, FINIT
, INIT_TXPOWER
,
1613 "eeprom_regulatory = 0x%x\n", rtlefuse
->eeprom_regulatory
);
1615 if (!autoload_fail
) {
1616 rtlefuse
->eeprom_tssi
[RF90_PATH_A
] = hwinfo
[EEPROM_TSSI_A
];
1617 rtlefuse
->eeprom_tssi
[RF90_PATH_B
] = hwinfo
[EEPROM_TSSI_B
];
1619 rtlefuse
->eeprom_tssi
[RF90_PATH_A
] = EEPROM_DEFAULT_TSSI
;
1620 rtlefuse
->eeprom_tssi
[RF90_PATH_B
] = EEPROM_DEFAULT_TSSI
;
1622 RTPRINT(rtlpriv
, FINIT
, INIT_TXPOWER
, "TSSI_A = 0x%x, TSSI_B = 0x%x\n",
1623 rtlefuse
->eeprom_tssi
[RF90_PATH_A
],
1624 rtlefuse
->eeprom_tssi
[RF90_PATH_B
]);
1627 tempval
= hwinfo
[EEPROM_THERMAL_METER
];
1629 tempval
= EEPROM_DEFAULT_THERMALMETER
;
1630 rtlefuse
->eeprom_thermalmeter
= (tempval
& 0x1f);
1632 if (rtlefuse
->eeprom_thermalmeter
== 0x1f || autoload_fail
)
1633 rtlefuse
->apk_thermalmeterignore
= true;
1635 rtlefuse
->thermalmeter
[0] = rtlefuse
->eeprom_thermalmeter
;
1636 RTPRINT(rtlpriv
, FINIT
, INIT_TXPOWER
,
1637 "thermalmeter = 0x%x\n", rtlefuse
->eeprom_thermalmeter
);
1640 static void _rtl92ce_read_adapter_info(struct ieee80211_hw
*hw
)
1642 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1643 struct rtl_efuse
*rtlefuse
= rtl_efuse(rtl_priv(hw
));
1644 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
1646 u8 hwinfo
[HWSET_MAX_SIZE
];
1649 if (rtlefuse
->epromtype
== EEPROM_BOOT_EFUSE
) {
1650 rtl_efuse_shadow_map_update(hw
);
1652 memcpy((void *)hwinfo
,
1653 (void *)&rtlefuse
->efuse_map
[EFUSE_INIT_MAP
][0],
1655 } else if (rtlefuse
->epromtype
== EEPROM_93C46
) {
1656 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
1657 "RTL819X Not boot from eeprom, check it !!");
1660 RT_PRINT_DATA(rtlpriv
, COMP_INIT
, DBG_DMESG
, "MAP",
1661 hwinfo
, HWSET_MAX_SIZE
);
1663 eeprom_id
= *((u16
*)&hwinfo
[0]);
1664 if (eeprom_id
!= RTL8190_EEPROM_ID
) {
1665 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_WARNING
,
1666 "EEPROM ID(%#x) is invalid!!\n", eeprom_id
);
1667 rtlefuse
->autoload_failflag
= true;
1669 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_LOUD
, "Autoload OK\n");
1670 rtlefuse
->autoload_failflag
= false;
1673 if (rtlefuse
->autoload_failflag
)
1676 rtlefuse
->eeprom_vid
= *(u16
*)&hwinfo
[EEPROM_VID
];
1677 rtlefuse
->eeprom_did
= *(u16
*)&hwinfo
[EEPROM_DID
];
1678 rtlefuse
->eeprom_svid
= *(u16
*)&hwinfo
[EEPROM_SVID
];
1679 rtlefuse
->eeprom_smid
= *(u16
*)&hwinfo
[EEPROM_SMID
];
1680 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_LOUD
,
1681 "EEPROMId = 0x%4x\n", eeprom_id
);
1682 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_LOUD
,
1683 "EEPROM VID = 0x%4x\n", rtlefuse
->eeprom_vid
);
1684 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_LOUD
,
1685 "EEPROM DID = 0x%4x\n", rtlefuse
->eeprom_did
);
1686 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_LOUD
,
1687 "EEPROM SVID = 0x%4x\n", rtlefuse
->eeprom_svid
);
1688 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_LOUD
,
1689 "EEPROM SMID = 0x%4x\n", rtlefuse
->eeprom_smid
);
1691 for (i
= 0; i
< 6; i
+= 2) {
1692 usvalue
= *(u16
*)&hwinfo
[EEPROM_MAC_ADDR
+ i
];
1693 *((u16
*) (&rtlefuse
->dev_addr
[i
])) = usvalue
;
1696 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
, "%pM\n", rtlefuse
->dev_addr
);
1698 _rtl92ce_read_txpower_info_from_hwpg(hw
,
1699 rtlefuse
->autoload_failflag
,
1702 rtl8192ce_read_bt_coexist_info_from_hwpg(hw
,
1703 rtlefuse
->autoload_failflag
,
1706 rtlefuse
->eeprom_channelplan
= *&hwinfo
[EEPROM_CHANNELPLAN
];
1707 rtlefuse
->eeprom_version
= *(u16
*)&hwinfo
[EEPROM_VERSION
];
1708 rtlefuse
->txpwr_fromeprom
= true;
1709 rtlefuse
->eeprom_oemid
= *&hwinfo
[EEPROM_CUSTOMER_ID
];
1711 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_LOUD
,
1712 "EEPROM Customer ID: 0x%2x\n", rtlefuse
->eeprom_oemid
);
1714 /* set channel paln to world wide 13 */
1715 rtlefuse
->channel_plan
= COUNTRY_CODE_WORLD_WIDE_13
;
1717 if (rtlhal
->oem_id
== RT_CID_DEFAULT
) {
1718 switch (rtlefuse
->eeprom_oemid
) {
1719 case EEPROM_CID_DEFAULT
:
1720 if (rtlefuse
->eeprom_did
== 0x8176) {
1721 if ((rtlefuse
->eeprom_svid
== 0x103C &&
1722 rtlefuse
->eeprom_smid
== 0x1629))
1723 rtlhal
->oem_id
= RT_CID_819x_HP
;
1725 rtlhal
->oem_id
= RT_CID_DEFAULT
;
1727 rtlhal
->oem_id
= RT_CID_DEFAULT
;
1730 case EEPROM_CID_TOSHIBA
:
1731 rtlhal
->oem_id
= RT_CID_TOSHIBA
;
1733 case EEPROM_CID_QMI
:
1734 rtlhal
->oem_id
= RT_CID_819x_QMI
;
1736 case EEPROM_CID_WHQL
:
1738 rtlhal
->oem_id
= RT_CID_DEFAULT
;
1746 static void _rtl92ce_hal_customized_behavior(struct ieee80211_hw
*hw
)
1748 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1749 struct rtl_pci_priv
*pcipriv
= rtl_pcipriv(hw
);
1750 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
1752 switch (rtlhal
->oem_id
) {
1753 case RT_CID_819x_HP
:
1754 pcipriv
->ledctl
.led_opendrain
= true;
1756 case RT_CID_819x_Lenovo
:
1757 case RT_CID_DEFAULT
:
1758 case RT_CID_TOSHIBA
:
1760 case RT_CID_819x_Acer
:
1765 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
,
1766 "RT Customized ID: 0x%02X\n", rtlhal
->oem_id
);
1769 void rtl92ce_read_eeprom_info(struct ieee80211_hw
*hw
)
1771 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1772 struct rtl_efuse
*rtlefuse
= rtl_efuse(rtl_priv(hw
));
1773 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
1774 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
1777 rtlhal
->version
= _rtl92ce_read_chip_version(hw
);
1778 if (get_rf_type(rtlphy
) == RF_1T1R
)
1779 rtlpriv
->dm
.rfpath_rxenable
[0] = true;
1781 rtlpriv
->dm
.rfpath_rxenable
[0] =
1782 rtlpriv
->dm
.rfpath_rxenable
[1] = true;
1783 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_LOUD
, "VersionID = 0x%4x\n",
1785 tmp_u1b
= rtl_read_byte(rtlpriv
, REG_9346CR
);
1786 if (tmp_u1b
& BIT(4)) {
1787 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
, "Boot from EEPROM\n");
1788 rtlefuse
->epromtype
= EEPROM_93C46
;
1790 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
, "Boot from EFUSE\n");
1791 rtlefuse
->epromtype
= EEPROM_BOOT_EFUSE
;
1793 if (tmp_u1b
& BIT(5)) {
1794 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_LOUD
, "Autoload OK\n");
1795 rtlefuse
->autoload_failflag
= false;
1796 _rtl92ce_read_adapter_info(hw
);
1798 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
, "Autoload ERR!!\n");
1800 _rtl92ce_hal_customized_behavior(hw
);
1803 static void rtl92ce_update_hal_rate_table(struct ieee80211_hw
*hw
,
1804 struct ieee80211_sta
*sta
)
1806 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1807 struct rtl_pci_priv
*rtlpcipriv
= rtl_pcipriv(hw
);
1808 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
1809 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
1810 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
1813 u8 nmode
= mac
->ht_enable
;
1814 u8 mimo_ps
= IEEE80211_SMPS_OFF
;
1817 u8 curtxbw_40mhz
= mac
->bw_40
;
1818 u8 curshortgi_40mhz
= (sta
->ht_cap
.cap
& IEEE80211_HT_CAP_SGI_40
) ?
1820 u8 curshortgi_20mhz
= (sta
->ht_cap
.cap
& IEEE80211_HT_CAP_SGI_20
) ?
1822 enum wireless_mode wirelessmode
= mac
->mode
;
1824 if (rtlhal
->current_bandtype
== BAND_ON_5G
)
1825 ratr_value
= sta
->supp_rates
[1] << 4;
1827 ratr_value
= sta
->supp_rates
[0];
1828 if (mac
->opmode
== NL80211_IFTYPE_ADHOC
)
1831 ratr_value
|= (sta
->ht_cap
.mcs
.rx_mask
[1] << 20 |
1832 sta
->ht_cap
.mcs
.rx_mask
[0] << 12);
1833 switch (wirelessmode
) {
1834 case WIRELESS_MODE_B
:
1835 if (ratr_value
& 0x0000000c)
1836 ratr_value
&= 0x0000000d;
1838 ratr_value
&= 0x0000000f;
1840 case WIRELESS_MODE_G
:
1841 ratr_value
&= 0x00000FF5;
1843 case WIRELESS_MODE_N_24G
:
1844 case WIRELESS_MODE_N_5G
:
1846 if (mimo_ps
== IEEE80211_SMPS_STATIC
) {
1847 ratr_value
&= 0x0007F005;
1851 if (get_rf_type(rtlphy
) == RF_1T2R
||
1852 get_rf_type(rtlphy
) == RF_1T1R
)
1853 ratr_mask
= 0x000ff005;
1855 ratr_mask
= 0x0f0ff005;
1857 ratr_value
&= ratr_mask
;
1861 if (rtlphy
->rf_type
== RF_1T2R
)
1862 ratr_value
&= 0x000ff0ff;
1864 ratr_value
&= 0x0f0ff0ff;
1869 if ((rtlpcipriv
->bt_coexist
.bt_coexistence
) &&
1870 (rtlpcipriv
->bt_coexist
.bt_coexist_type
== BT_CSR_BC4
) &&
1871 (rtlpcipriv
->bt_coexist
.bt_cur_state
) &&
1872 (rtlpcipriv
->bt_coexist
.bt_ant_isolation
) &&
1873 ((rtlpcipriv
->bt_coexist
.bt_service
== BT_SCO
) ||
1874 (rtlpcipriv
->bt_coexist
.bt_service
== BT_BUSY
)))
1875 ratr_value
&= 0x0fffcfc0;
1877 ratr_value
&= 0x0FFFFFFF;
1879 if (nmode
&& ((curtxbw_40mhz
&&
1880 curshortgi_40mhz
) || (!curtxbw_40mhz
&&
1881 curshortgi_20mhz
))) {
1883 ratr_value
|= 0x10000000;
1884 tmp_ratr_value
= (ratr_value
>> 12);
1886 for (shortgi_rate
= 15; shortgi_rate
> 0; shortgi_rate
--) {
1887 if ((1 << shortgi_rate
) & tmp_ratr_value
)
1891 shortgi_rate
= (shortgi_rate
<< 12) | (shortgi_rate
<< 8) |
1892 (shortgi_rate
<< 4) | (shortgi_rate
);
1895 rtl_write_dword(rtlpriv
, REG_ARFR0
+ ratr_index
* 4, ratr_value
);
1897 RT_TRACE(rtlpriv
, COMP_RATR
, DBG_DMESG
, "%x\n",
1898 rtl_read_dword(rtlpriv
, REG_ARFR0
));
1901 static void rtl92ce_update_hal_rate_mask(struct ieee80211_hw
*hw
,
1902 struct ieee80211_sta
*sta
, u8 rssi_level
)
1904 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1905 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
1906 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
1907 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
1908 struct rtl_sta_info
*sta_entry
= NULL
;
1911 u8 curtxbw_40mhz
= (sta
->bandwidth
>= IEEE80211_STA_RX_BW_40
) ? 1 : 0;
1912 u8 curshortgi_40mhz
= curtxbw_40mhz
&&
1913 (sta
->ht_cap
.cap
& IEEE80211_HT_CAP_SGI_40
) ?
1915 u8 curshortgi_20mhz
= (sta
->ht_cap
.cap
& IEEE80211_HT_CAP_SGI_20
) ?
1917 enum wireless_mode wirelessmode
= 0;
1918 bool shortgi
= false;
1921 u8 mimo_ps
= IEEE80211_SMPS_OFF
;
1923 sta_entry
= (struct rtl_sta_info
*) sta
->drv_priv
;
1924 wirelessmode
= sta_entry
->wireless_mode
;
1925 if (mac
->opmode
== NL80211_IFTYPE_STATION
||
1926 mac
->opmode
== NL80211_IFTYPE_MESH_POINT
)
1927 curtxbw_40mhz
= mac
->bw_40
;
1928 else if (mac
->opmode
== NL80211_IFTYPE_AP
||
1929 mac
->opmode
== NL80211_IFTYPE_ADHOC
)
1930 macid
= sta
->aid
+ 1;
1932 if (rtlhal
->current_bandtype
== BAND_ON_5G
)
1933 ratr_bitmap
= sta
->supp_rates
[1] << 4;
1935 ratr_bitmap
= sta
->supp_rates
[0];
1936 if (mac
->opmode
== NL80211_IFTYPE_ADHOC
)
1937 ratr_bitmap
= 0xfff;
1938 ratr_bitmap
|= (sta
->ht_cap
.mcs
.rx_mask
[1] << 20 |
1939 sta
->ht_cap
.mcs
.rx_mask
[0] << 12);
1940 switch (wirelessmode
) {
1941 case WIRELESS_MODE_B
:
1942 ratr_index
= RATR_INX_WIRELESS_B
;
1943 if (ratr_bitmap
& 0x0000000c)
1944 ratr_bitmap
&= 0x0000000d;
1946 ratr_bitmap
&= 0x0000000f;
1948 case WIRELESS_MODE_G
:
1949 ratr_index
= RATR_INX_WIRELESS_GB
;
1951 if (rssi_level
== 1)
1952 ratr_bitmap
&= 0x00000f00;
1953 else if (rssi_level
== 2)
1954 ratr_bitmap
&= 0x00000ff0;
1956 ratr_bitmap
&= 0x00000ff5;
1958 case WIRELESS_MODE_A
:
1959 ratr_index
= RATR_INX_WIRELESS_A
;
1960 ratr_bitmap
&= 0x00000ff0;
1962 case WIRELESS_MODE_N_24G
:
1963 case WIRELESS_MODE_N_5G
:
1964 ratr_index
= RATR_INX_WIRELESS_NGB
;
1966 if (mimo_ps
== IEEE80211_SMPS_STATIC
) {
1967 if (rssi_level
== 1)
1968 ratr_bitmap
&= 0x00070000;
1969 else if (rssi_level
== 2)
1970 ratr_bitmap
&= 0x0007f000;
1972 ratr_bitmap
&= 0x0007f005;
1974 if (rtlphy
->rf_type
== RF_1T2R
||
1975 rtlphy
->rf_type
== RF_1T1R
) {
1976 if (curtxbw_40mhz
) {
1977 if (rssi_level
== 1)
1978 ratr_bitmap
&= 0x000f0000;
1979 else if (rssi_level
== 2)
1980 ratr_bitmap
&= 0x000ff000;
1982 ratr_bitmap
&= 0x000ff015;
1984 if (rssi_level
== 1)
1985 ratr_bitmap
&= 0x000f0000;
1986 else if (rssi_level
== 2)
1987 ratr_bitmap
&= 0x000ff000;
1989 ratr_bitmap
&= 0x000ff005;
1992 if (curtxbw_40mhz
) {
1993 if (rssi_level
== 1)
1994 ratr_bitmap
&= 0x0f0f0000;
1995 else if (rssi_level
== 2)
1996 ratr_bitmap
&= 0x0f0ff000;
1998 ratr_bitmap
&= 0x0f0ff015;
2000 if (rssi_level
== 1)
2001 ratr_bitmap
&= 0x0f0f0000;
2002 else if (rssi_level
== 2)
2003 ratr_bitmap
&= 0x0f0ff000;
2005 ratr_bitmap
&= 0x0f0ff005;
2010 if ((curtxbw_40mhz
&& curshortgi_40mhz
) ||
2011 (!curtxbw_40mhz
&& curshortgi_20mhz
)) {
2015 else if (macid
== 1)
2020 ratr_index
= RATR_INX_WIRELESS_NGB
;
2022 if (rtlphy
->rf_type
== RF_1T2R
)
2023 ratr_bitmap
&= 0x000ff0ff;
2025 ratr_bitmap
&= 0x0f0ff0ff;
2028 sta_entry
->ratr_index
= ratr_index
;
2030 RT_TRACE(rtlpriv
, COMP_RATR
, DBG_DMESG
,
2031 "ratr_bitmap :%x\n", ratr_bitmap
);
2032 *(u32
*)&rate_mask
= (ratr_bitmap
& 0x0fffffff) |
2034 rate_mask
[4] = macid
| (shortgi
? 0x20 : 0x00) | 0x80;
2035 RT_TRACE(rtlpriv
, COMP_RATR
, DBG_DMESG
,
2036 "Rate_index:%x, ratr_val:%x, %5phC\n",
2037 ratr_index
, ratr_bitmap
, rate_mask
);
2038 rtl92c_fill_h2c_cmd(hw
, H2C_RA_MASK
, 5, rate_mask
);
2041 sta_entry
->ratr_index
= ratr_index
;
2044 void rtl92ce_update_hal_rate_tbl(struct ieee80211_hw
*hw
,
2045 struct ieee80211_sta
*sta
, u8 rssi_level
)
2047 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
2049 if (rtlpriv
->dm
.useramask
)
2050 rtl92ce_update_hal_rate_mask(hw
, sta
, rssi_level
);
2052 rtl92ce_update_hal_rate_table(hw
, sta
);
2055 void rtl92ce_update_channel_access_setting(struct ieee80211_hw
*hw
)
2057 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
2058 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
2061 rtlpriv
->cfg
->ops
->set_hw_reg(hw
, HW_VAR_SLOT_TIME
,
2063 if (!mac
->ht_enable
)
2064 sifs_timer
= 0x0a0a;
2066 sifs_timer
= 0x1010;
2067 rtlpriv
->cfg
->ops
->set_hw_reg(hw
, HW_VAR_SIFS
, (u8
*)&sifs_timer
);
2070 bool rtl92ce_gpio_radio_on_off_checking(struct ieee80211_hw
*hw
, u8
*valid
)
2072 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
2073 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
2074 struct rtl_pci
*rtlpci
= rtl_pcidev(rtl_pcipriv(hw
));
2075 enum rf_pwrstate e_rfpowerstate_toset
;
2077 bool actuallyset
= false;
2080 if (rtlpci
->being_init_adapter
)
2083 if (ppsc
->swrf_processing
)
2086 spin_lock_irqsave(&rtlpriv
->locks
.rf_ps_lock
, flag
);
2087 if (ppsc
->rfchange_inprogress
) {
2088 spin_unlock_irqrestore(&rtlpriv
->locks
.rf_ps_lock
, flag
);
2091 ppsc
->rfchange_inprogress
= true;
2092 spin_unlock_irqrestore(&rtlpriv
->locks
.rf_ps_lock
, flag
);
2095 rtl_write_byte(rtlpriv
, REG_MAC_PINMUX_CFG
, rtl_read_byte(rtlpriv
,
2096 REG_MAC_PINMUX_CFG
)&~(BIT(3)));
2098 u1tmp
= rtl_read_byte(rtlpriv
, REG_GPIO_IO_SEL
);
2099 e_rfpowerstate_toset
= (u1tmp
& BIT(3)) ? ERFON
: ERFOFF
;
2101 if ((ppsc
->hwradiooff
) && (e_rfpowerstate_toset
== ERFON
)) {
2102 RT_TRACE(rtlpriv
, COMP_RF
, DBG_DMESG
,
2103 "GPIOChangeRF - HW Radio ON, RF ON\n");
2105 e_rfpowerstate_toset
= ERFON
;
2106 ppsc
->hwradiooff
= false;
2108 } else if (!ppsc
->hwradiooff
&& (e_rfpowerstate_toset
== ERFOFF
)) {
2109 RT_TRACE(rtlpriv
, COMP_RF
, DBG_DMESG
,
2110 "GPIOChangeRF - HW Radio OFF, RF OFF\n");
2112 e_rfpowerstate_toset
= ERFOFF
;
2113 ppsc
->hwradiooff
= true;
2118 spin_lock_irqsave(&rtlpriv
->locks
.rf_ps_lock
, flag
);
2119 ppsc
->rfchange_inprogress
= false;
2120 spin_unlock_irqrestore(&rtlpriv
->locks
.rf_ps_lock
, flag
);
2122 if (ppsc
->reg_rfps_level
& RT_RF_OFF_LEVL_HALT_NIC
)
2123 RT_SET_PS_LEVEL(ppsc
, RT_RF_OFF_LEVL_HALT_NIC
);
2125 spin_lock_irqsave(&rtlpriv
->locks
.rf_ps_lock
, flag
);
2126 ppsc
->rfchange_inprogress
= false;
2127 spin_unlock_irqrestore(&rtlpriv
->locks
.rf_ps_lock
, flag
);
2131 return !ppsc
->hwradiooff
;
2135 void rtl92ce_set_key(struct ieee80211_hw
*hw
, u32 key_index
,
2136 u8
*p_macaddr
, bool is_group
, u8 enc_algo
,
2137 bool is_wepkey
, bool clear_all
)
2139 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
2140 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
2141 struct rtl_efuse
*rtlefuse
= rtl_efuse(rtl_priv(hw
));
2142 u8
*macaddr
= p_macaddr
;
2144 bool is_pairwise
= false;
2146 static u8 cam_const_addr
[4][6] = {
2147 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
2148 {0x00, 0x00, 0x00, 0x00, 0x00, 0x01},
2149 {0x00, 0x00, 0x00, 0x00, 0x00, 0x02},
2150 {0x00, 0x00, 0x00, 0x00, 0x00, 0x03}
2152 static u8 cam_const_broad
[] = {
2153 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
2159 u8 clear_number
= 5;
2161 RT_TRACE(rtlpriv
, COMP_SEC
, DBG_DMESG
, "clear_all\n");
2163 for (idx
= 0; idx
< clear_number
; idx
++) {
2164 rtl_cam_mark_invalid(hw
, cam_offset
+ idx
);
2165 rtl_cam_empty_entry(hw
, cam_offset
+ idx
);
2168 memset(rtlpriv
->sec
.key_buf
[idx
], 0,
2170 rtlpriv
->sec
.key_len
[idx
] = 0;
2176 case WEP40_ENCRYPTION
:
2177 enc_algo
= CAM_WEP40
;
2179 case WEP104_ENCRYPTION
:
2180 enc_algo
= CAM_WEP104
;
2182 case TKIP_ENCRYPTION
:
2183 enc_algo
= CAM_TKIP
;
2185 case AESCCMP_ENCRYPTION
:
2189 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
2190 "switch case not processed\n");
2191 enc_algo
= CAM_TKIP
;
2195 if (is_wepkey
|| rtlpriv
->sec
.use_defaultkey
) {
2196 macaddr
= cam_const_addr
[key_index
];
2197 entry_id
= key_index
;
2200 macaddr
= cam_const_broad
;
2201 entry_id
= key_index
;
2203 if (mac
->opmode
== NL80211_IFTYPE_AP
||
2204 mac
->opmode
== NL80211_IFTYPE_MESH_POINT
) {
2205 entry_id
= rtl_cam_get_free_entry(hw
,
2207 if (entry_id
>= TOTAL_CAM_ENTRY
) {
2208 RT_TRACE(rtlpriv
, COMP_SEC
,
2210 "Can not find free hw security cam entry\n");
2214 entry_id
= CAM_PAIRWISE_KEY_POSITION
;
2217 key_index
= PAIRWISE_KEYIDX
;
2222 if (rtlpriv
->sec
.key_len
[key_index
] == 0) {
2223 RT_TRACE(rtlpriv
, COMP_SEC
, DBG_DMESG
,
2224 "delete one entry, entry_id is %d\n",
2226 if (mac
->opmode
== NL80211_IFTYPE_AP
||
2227 mac
->opmode
== NL80211_IFTYPE_MESH_POINT
)
2228 rtl_cam_del_entry(hw
, p_macaddr
);
2229 rtl_cam_delete_one_entry(hw
, p_macaddr
, entry_id
);
2231 RT_TRACE(rtlpriv
, COMP_SEC
, DBG_LOUD
,
2232 "The insert KEY length is %d\n",
2233 rtlpriv
->sec
.key_len
[PAIRWISE_KEYIDX
]);
2234 RT_TRACE(rtlpriv
, COMP_SEC
, DBG_LOUD
,
2235 "The insert KEY is %x %x\n",
2236 rtlpriv
->sec
.key_buf
[0][0],
2237 rtlpriv
->sec
.key_buf
[0][1]);
2239 RT_TRACE(rtlpriv
, COMP_SEC
, DBG_DMESG
,
2242 RT_PRINT_DATA(rtlpriv
, COMP_SEC
, DBG_LOUD
,
2243 "Pairwise Key content",
2244 rtlpriv
->sec
.pairwise_key
,
2246 key_len
[PAIRWISE_KEYIDX
]);
2248 RT_TRACE(rtlpriv
, COMP_SEC
, DBG_DMESG
,
2249 "set Pairwise key\n");
2251 rtl_cam_add_one_entry(hw
, macaddr
, key_index
,
2253 CAM_CONFIG_NO_USEDK
,
2255 key_buf
[key_index
]);
2257 RT_TRACE(rtlpriv
, COMP_SEC
, DBG_DMESG
,
2260 if (mac
->opmode
== NL80211_IFTYPE_ADHOC
) {
2261 rtl_cam_add_one_entry(hw
,
2264 CAM_PAIRWISE_KEY_POSITION
,
2266 CAM_CONFIG_NO_USEDK
,
2267 rtlpriv
->sec
.key_buf
2271 rtl_cam_add_one_entry(hw
, macaddr
, key_index
,
2273 CAM_CONFIG_NO_USEDK
,
2274 rtlpriv
->sec
.key_buf
[entry_id
]);
2281 static void rtl8192ce_bt_var_init(struct ieee80211_hw
*hw
)
2283 struct rtl_pci_priv
*rtlpcipriv
= rtl_pcipriv(hw
);
2285 rtlpcipriv
->bt_coexist
.bt_coexistence
=
2286 rtlpcipriv
->bt_coexist
.eeprom_bt_coexist
;
2287 rtlpcipriv
->bt_coexist
.bt_ant_num
=
2288 rtlpcipriv
->bt_coexist
.eeprom_bt_ant_num
;
2289 rtlpcipriv
->bt_coexist
.bt_coexist_type
=
2290 rtlpcipriv
->bt_coexist
.eeprom_bt_type
;
2292 if (rtlpcipriv
->bt_coexist
.reg_bt_iso
== 2)
2293 rtlpcipriv
->bt_coexist
.bt_ant_isolation
=
2294 rtlpcipriv
->bt_coexist
.eeprom_bt_ant_isol
;
2296 rtlpcipriv
->bt_coexist
.bt_ant_isolation
=
2297 rtlpcipriv
->bt_coexist
.reg_bt_iso
;
2299 rtlpcipriv
->bt_coexist
.bt_radio_shared_type
=
2300 rtlpcipriv
->bt_coexist
.eeprom_bt_radio_shared
;
2302 if (rtlpcipriv
->bt_coexist
.bt_coexistence
) {
2304 if (rtlpcipriv
->bt_coexist
.reg_bt_sco
== 1)
2305 rtlpcipriv
->bt_coexist
.bt_service
= BT_OTHER_ACTION
;
2306 else if (rtlpcipriv
->bt_coexist
.reg_bt_sco
== 2)
2307 rtlpcipriv
->bt_coexist
.bt_service
= BT_SCO
;
2308 else if (rtlpcipriv
->bt_coexist
.reg_bt_sco
== 4)
2309 rtlpcipriv
->bt_coexist
.bt_service
= BT_BUSY
;
2310 else if (rtlpcipriv
->bt_coexist
.reg_bt_sco
== 5)
2311 rtlpcipriv
->bt_coexist
.bt_service
= BT_OTHERBUSY
;
2313 rtlpcipriv
->bt_coexist
.bt_service
= BT_IDLE
;
2315 rtlpcipriv
->bt_coexist
.bt_edca_ul
= 0;
2316 rtlpcipriv
->bt_coexist
.bt_edca_dl
= 0;
2317 rtlpcipriv
->bt_coexist
.bt_rssi_state
= 0xff;
2321 void rtl8192ce_read_bt_coexist_info_from_hwpg(struct ieee80211_hw
*hw
,
2322 bool auto_load_fail
, u8
*hwinfo
)
2324 struct rtl_pci_priv
*rtlpcipriv
= rtl_pcipriv(hw
);
2327 if (!auto_load_fail
) {
2328 rtlpcipriv
->bt_coexist
.eeprom_bt_coexist
=
2329 ((hwinfo
[RF_OPTION1
] & 0xe0) >> 5);
2330 val
= hwinfo
[RF_OPTION4
];
2331 rtlpcipriv
->bt_coexist
.eeprom_bt_type
= ((val
& 0xe) >> 1);
2332 rtlpcipriv
->bt_coexist
.eeprom_bt_ant_num
= (val
& 0x1);
2333 rtlpcipriv
->bt_coexist
.eeprom_bt_ant_isol
= ((val
& 0x10) >> 4);
2334 rtlpcipriv
->bt_coexist
.eeprom_bt_radio_shared
=
2335 ((val
& 0x20) >> 5);
2337 rtlpcipriv
->bt_coexist
.eeprom_bt_coexist
= 0;
2338 rtlpcipriv
->bt_coexist
.eeprom_bt_type
= BT_2WIRE
;
2339 rtlpcipriv
->bt_coexist
.eeprom_bt_ant_num
= ANT_X2
;
2340 rtlpcipriv
->bt_coexist
.eeprom_bt_ant_isol
= 0;
2341 rtlpcipriv
->bt_coexist
.eeprom_bt_radio_shared
= BT_RADIO_SHARED
;
2344 rtl8192ce_bt_var_init(hw
);
2347 void rtl8192ce_bt_reg_init(struct ieee80211_hw
*hw
)
2349 struct rtl_pci_priv
*rtlpcipriv
= rtl_pcipriv(hw
);
2351 /* 0:Low, 1:High, 2:From Efuse. */
2352 rtlpcipriv
->bt_coexist
.reg_bt_iso
= 2;
2353 /* 0:Idle, 1:None-SCO, 2:SCO, 3:From Counter. */
2354 rtlpcipriv
->bt_coexist
.reg_bt_sco
= 3;
2355 /* 0:Disable BT control A-MPDU, 1:Enable BT control A-MPDU. */
2356 rtlpcipriv
->bt_coexist
.reg_bt_sco
= 0;
2360 void rtl8192ce_bt_hw_init(struct ieee80211_hw
*hw
)
2362 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
2363 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
2364 struct rtl_pci_priv
*rtlpcipriv
= rtl_pcipriv(hw
);
2368 if (rtlpcipriv
->bt_coexist
.bt_coexistence
&&
2369 ((rtlpcipriv
->bt_coexist
.bt_coexist_type
== BT_CSR_BC4
) ||
2370 rtlpcipriv
->bt_coexist
.bt_coexist_type
== BT_CSR_BC8
)) {
2372 if (rtlpcipriv
->bt_coexist
.bt_ant_isolation
)
2373 rtl_write_byte(rtlpriv
, REG_GPIO_MUXCFG
, 0xa0);
2375 u1_tmp
= rtl_read_byte(rtlpriv
, 0x4fd) &
2376 BIT_OFFSET_LEN_MASK_32(0, 1);
2378 ((rtlpcipriv
->bt_coexist
.bt_ant_isolation
== 1) ?
2379 0 : BIT_OFFSET_LEN_MASK_32(1, 1)) |
2380 ((rtlpcipriv
->bt_coexist
.bt_service
== BT_SCO
) ?
2381 0 : BIT_OFFSET_LEN_MASK_32(2, 1));
2382 rtl_write_byte(rtlpriv
, 0x4fd, u1_tmp
);
2384 rtl_write_dword(rtlpriv
, REG_BT_COEX_TABLE
+4, 0xaaaa9aaa);
2385 rtl_write_dword(rtlpriv
, REG_BT_COEX_TABLE
+8, 0xffbd0040);
2386 rtl_write_dword(rtlpriv
, REG_BT_COEX_TABLE
+0xc, 0x40000010);
2388 /* Config to 1T1R. */
2389 if (rtlphy
->rf_type
== RF_1T1R
) {
2390 u1_tmp
= rtl_read_byte(rtlpriv
, ROFDM0_TRXPATHENABLE
);
2391 u1_tmp
&= ~(BIT_OFFSET_LEN_MASK_32(1, 1));
2392 rtl_write_byte(rtlpriv
, ROFDM0_TRXPATHENABLE
, u1_tmp
);
2394 u1_tmp
= rtl_read_byte(rtlpriv
, ROFDM1_TRXPATHENABLE
);
2395 u1_tmp
&= ~(BIT_OFFSET_LEN_MASK_32(1, 1));
2396 rtl_write_byte(rtlpriv
, ROFDM1_TRXPATHENABLE
, u1_tmp
);
2401 void rtl92ce_suspend(struct ieee80211_hw
*hw
)
2405 void rtl92ce_resume(struct ieee80211_hw
*hw
)
2409 /* Turn on AAP (RCR:bit 0) for promicuous mode. */
2410 void rtl92ce_allow_all_destaddr(struct ieee80211_hw
*hw
,
2411 bool allow_all_da
, bool write_into_reg
)
2413 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
2414 struct rtl_pci
*rtlpci
= rtl_pcidev(rtl_pcipriv(hw
));
2416 if (allow_all_da
) {/* Set BIT0 */
2417 rtlpci
->receive_config
|= RCR_AAP
;
2418 } else {/* Clear BIT0 */
2419 rtlpci
->receive_config
&= ~RCR_AAP
;
2423 rtl_write_dword(rtlpriv
, REG_RCR
, rtlpci
->receive_config
);
2425 RT_TRACE(rtlpriv
, COMP_TURBO
| COMP_INIT
, DBG_LOUD
,
2426 "receive_config=0x%08X, write_into_reg=%d\n",
2427 rtlpci
->receive_config
, write_into_reg
);