1 /******************************************************************************
3 * Copyright(c) 2009-2010 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 process\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) (*(u8
*) 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
= *((u8
*) 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",
250 mac
->min_space_cfg
));
252 rtl_write_byte(rtlpriv
, REG_AMPDU_MIN_SPACE
,
257 case HW_VAR_SHORTGI_DENSITY
:{
260 density_to_set
= *((u8
*) 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",
265 mac
->min_space_cfg
));
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
= *((u8
*) 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
:{
319 u8 e_aci
= *((u8
*) val
);
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
:{
329 u8 e_aci
= *((u8
*) val
);
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 "
352 "failed: eACI is %d\n", acm
));
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 process\n"));
373 RT_TRACE(rtlpriv
, COMP_QOS
, DBG_TRACE
,
374 ("SetHwReg8190pci(): [HW_VAR_ACM_CTRL] "
375 "Write 0x%X\n", acm_ctrl
));
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
= ((u8
*) (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
= *((u8
*) 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
, *((u8
*) 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
,
417 rtl_write_byte(rtlpriv
, REG_PCIE_HRPWM
,
418 ((*(u8
*) val
) | BIT(7)));
423 case HW_VAR_H2C_FW_PWRMODE
:{
424 u8 psmode
= (*(u8
*) val
);
426 if ((psmode
!= FW_PS_ACTIVE_MODE
) &&
427 (!IS_92C_SERIAL(rtlhal
->version
))) {
428 rtl92c_dm_rf_saving(hw
, true);
431 rtl92c_set_fw_pwrmode_cmd(hw
, (*(u8
*) val
));
434 case HW_VAR_FW_PSMODE_STATUS
:
435 ppsc
->fw_current_inpsmode
= *((bool *) val
);
437 case HW_VAR_H2C_FW_JOINBSSRPT
:{
438 u8 mstatus
= (*(u8
*) val
);
439 u8 tmp_regcr
, tmp_reg422
;
440 bool recover
= false;
442 if (mstatus
== RT_MEDIA_CONNECT
) {
443 rtlpriv
->cfg
->ops
->set_hw_reg(hw
, HW_VAR_AID
,
446 tmp_regcr
= rtl_read_byte(rtlpriv
, REG_CR
+ 1);
447 rtl_write_byte(rtlpriv
, REG_CR
+ 1,
448 (tmp_regcr
| BIT(0)));
450 _rtl92ce_set_bcn_ctrl_reg(hw
, 0, BIT(3));
451 _rtl92ce_set_bcn_ctrl_reg(hw
, BIT(4), 0);
454 rtl_read_byte(rtlpriv
,
455 REG_FWHW_TXQ_CTRL
+ 2);
456 if (tmp_reg422
& BIT(6))
458 rtl_write_byte(rtlpriv
, REG_FWHW_TXQ_CTRL
+ 2,
459 tmp_reg422
& (~BIT(6)));
461 rtl92c_set_fw_rsvdpagepkt(hw
, 0);
463 _rtl92ce_set_bcn_ctrl_reg(hw
, BIT(3), 0);
464 _rtl92ce_set_bcn_ctrl_reg(hw
, 0, BIT(4));
467 rtl_write_byte(rtlpriv
,
468 REG_FWHW_TXQ_CTRL
+ 2,
472 rtl_write_byte(rtlpriv
, REG_CR
+ 1,
473 (tmp_regcr
& ~(BIT(0))));
475 rtl92c_set_fw_joinbss_report_cmd(hw
, (*(u8
*) val
));
481 u2btmp
= rtl_read_word(rtlpriv
, REG_BCN_PSR_RPT
);
483 rtl_write_word(rtlpriv
, REG_BCN_PSR_RPT
, (u2btmp
|
488 case HW_VAR_CORRECT_TSF
:{
489 u8 btype_ibss
= ((u8
*) (val
))[0];
492 _rtl92ce_stop_tx_beacon(hw
);
494 _rtl92ce_set_bcn_ctrl_reg(hw
, 0, BIT(3));
496 rtl_write_dword(rtlpriv
, REG_TSFTR
,
497 (u32
) (mac
->tsf
& 0xffffffff));
498 rtl_write_dword(rtlpriv
, REG_TSFTR
+ 4,
499 (u32
) ((mac
->tsf
>> 32) & 0xffffffff));
501 _rtl92ce_set_bcn_ctrl_reg(hw
, BIT(3), 0);
504 _rtl92ce_resume_tx_beacon(hw
);
510 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
, ("switch case "
516 static bool _rtl92ce_llt_write(struct ieee80211_hw
*hw
, u32 address
, u32 data
)
518 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
521 u32 value
= _LLT_INIT_ADDR(address
) |
522 _LLT_INIT_DATA(data
) | _LLT_OP(_LLT_WRITE_ACCESS
);
524 rtl_write_dword(rtlpriv
, REG_LLT_INIT
, value
);
527 value
= rtl_read_dword(rtlpriv
, REG_LLT_INIT
);
528 if (_LLT_NO_ACTIVE
== _LLT_OP_VALUE(value
))
531 if (count
> POLLING_LLT_THRESHOLD
) {
532 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
533 ("Failed to polling write LLT done at "
534 "address %d!\n", address
));
543 static bool _rtl92ce_llt_table_init(struct ieee80211_hw
*hw
)
545 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
554 #elif LLT_CONFIG == 2
557 #elif LLT_CONFIG == 3
560 #elif LLT_CONFIG == 4
563 #elif LLT_CONFIG == 5
569 rtl_write_byte(rtlpriv
, REG_RQPN_NPQ
, 0x1c);
570 rtl_write_dword(rtlpriv
, REG_RQPN
, 0x80a71c1c);
571 #elif LLT_CONFIG == 2
572 rtl_write_dword(rtlpriv
, REG_RQPN
, 0x845B1010);
573 #elif LLT_CONFIG == 3
574 rtl_write_dword(rtlpriv
, REG_RQPN
, 0x84838484);
575 #elif LLT_CONFIG == 4
576 rtl_write_dword(rtlpriv
, REG_RQPN
, 0x80bd1c1c);
577 #elif LLT_CONFIG == 5
578 rtl_write_word(rtlpriv
, REG_RQPN_NPQ
, 0x0000);
580 rtl_write_dword(rtlpriv
, REG_RQPN
, 0x80b01c29);
583 rtl_write_dword(rtlpriv
, REG_TRXFF_BNDY
, (0x27FF0000 | txpktbuf_bndy
));
584 rtl_write_byte(rtlpriv
, REG_TDECTRL
+ 1, txpktbuf_bndy
);
586 rtl_write_byte(rtlpriv
, REG_TXPKTBUF_BCNQ_BDNY
, txpktbuf_bndy
);
587 rtl_write_byte(rtlpriv
, REG_TXPKTBUF_MGQ_BDNY
, txpktbuf_bndy
);
589 rtl_write_byte(rtlpriv
, 0x45D, txpktbuf_bndy
);
590 rtl_write_byte(rtlpriv
, REG_PBP
, 0x11);
591 rtl_write_byte(rtlpriv
, REG_RX_DRVINFO_SZ
, 0x4);
593 for (i
= 0; i
< (txpktbuf_bndy
- 1); i
++) {
594 status
= _rtl92ce_llt_write(hw
, i
, i
+ 1);
599 status
= _rtl92ce_llt_write(hw
, (txpktbuf_bndy
- 1), 0xFF);
603 for (i
= txpktbuf_bndy
; i
< maxPage
; i
++) {
604 status
= _rtl92ce_llt_write(hw
, i
, (i
+ 1));
609 status
= _rtl92ce_llt_write(hw
, maxPage
, txpktbuf_bndy
);
616 static void _rtl92ce_gen_refresh_led_state(struct ieee80211_hw
*hw
)
618 struct rtl_pci_priv
*pcipriv
= rtl_pcipriv(hw
);
619 struct rtl_pci
*rtlpci
= rtl_pcidev(rtl_pcipriv(hw
));
620 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
621 struct rtl_led
*pLed0
= &(pcipriv
->ledctl
.sw_led0
);
623 if (rtlpci
->up_first_time
)
626 if (ppsc
->rfoff_reason
== RF_CHANGE_BY_IPS
)
627 rtl92ce_sw_led_on(hw
, pLed0
);
628 else if (ppsc
->rfoff_reason
== RF_CHANGE_BY_INIT
)
629 rtl92ce_sw_led_on(hw
, pLed0
);
631 rtl92ce_sw_led_off(hw
, pLed0
);
634 static bool _rtl92ce_init_mac(struct ieee80211_hw
*hw
)
636 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
637 struct rtl_pci_priv
*rtlpcipriv
= rtl_pcipriv(hw
);
638 struct rtl_pci
*rtlpci
= rtl_pcidev(rtl_pcipriv(hw
));
639 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
641 unsigned char bytetmp
;
642 unsigned short wordtmp
;
645 rtl_write_byte(rtlpriv
, REG_RSV_CTRL
, 0x00);
646 if (rtlpcipriv
->bt_coexist
.bt_coexistence
) {
648 value32
= rtl_read_dword(rtlpriv
, REG_APS_FSMCO
);
649 value32
|= (SOP_ABG
| SOP_AMB
| XOP_BTCK
);
650 rtl_write_dword(rtlpriv
, REG_APS_FSMCO
, value32
);
652 rtl_write_byte(rtlpriv
, REG_SPS0_CTRL
, 0x2b);
653 rtl_write_byte(rtlpriv
, REG_AFE_XTAL_CTRL
, 0x0F);
655 if (rtlpcipriv
->bt_coexist
.bt_coexistence
) {
656 u32 u4b_tmp
= rtl_read_dword(rtlpriv
, REG_AFE_XTAL_CTRL
);
658 u4b_tmp
&= (~0x00024800);
659 rtl_write_dword(rtlpriv
, REG_AFE_XTAL_CTRL
, u4b_tmp
);
662 bytetmp
= rtl_read_byte(rtlpriv
, REG_APS_FSMCO
+ 1) | BIT(0);
665 rtl_write_byte(rtlpriv
, REG_APS_FSMCO
+ 1, bytetmp
);
668 bytetmp
= rtl_read_byte(rtlpriv
, REG_APS_FSMCO
+ 1);
672 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_LOUD
, ("reg0xec:%x:%x\n",
673 rtl_read_dword(rtlpriv
, 0xEC),
676 while ((bytetmp
& BIT(0)) && retry
< 1000) {
679 bytetmp
= rtl_read_byte(rtlpriv
, REG_APS_FSMCO
+ 1);
680 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_LOUD
, ("reg0xec:%x:%x\n",
681 rtl_read_dword(rtlpriv
,
687 rtl_write_word(rtlpriv
, REG_APS_FSMCO
, 0x1012);
689 rtl_write_byte(rtlpriv
, REG_SYS_ISO_CTRL
+ 1, 0x82);
692 if (rtlpcipriv
->bt_coexist
.bt_coexistence
) {
693 bytetmp
= rtl_read_byte(rtlpriv
, REG_AFE_XTAL_CTRL
+2) & 0xfd;
694 rtl_write_byte(rtlpriv
, REG_AFE_XTAL_CTRL
+2, bytetmp
);
697 rtl_write_word(rtlpriv
, REG_CR
, 0x2ff);
699 if (_rtl92ce_llt_table_init(hw
) == false)
702 rtl_write_dword(rtlpriv
, REG_HISR
, 0xffffffff);
703 rtl_write_byte(rtlpriv
, REG_HISRE
, 0xff);
705 rtl_write_word(rtlpriv
, REG_TRXFF_BNDY
+ 2, 0x27ff);
707 wordtmp
= rtl_read_word(rtlpriv
, REG_TRXDMA_CTRL
);
710 rtl_write_word(rtlpriv
, REG_TRXDMA_CTRL
, wordtmp
);
712 rtl_write_byte(rtlpriv
, REG_FWHW_TXQ_CTRL
+ 1, 0x1F);
713 rtl_write_dword(rtlpriv
, REG_RCR
, rtlpci
->receive_config
);
714 rtl_write_dword(rtlpriv
, REG_TCR
, rtlpci
->transmit_config
);
716 rtl_write_byte(rtlpriv
, 0x4d0, 0x0);
718 rtl_write_dword(rtlpriv
, REG_BCNQ_DESA
,
719 ((u64
) rtlpci
->tx_ring
[BEACON_QUEUE
].dma
) &
721 rtl_write_dword(rtlpriv
, REG_MGQ_DESA
,
722 (u64
) rtlpci
->tx_ring
[MGNT_QUEUE
].dma
&
724 rtl_write_dword(rtlpriv
, REG_VOQ_DESA
,
725 (u64
) rtlpci
->tx_ring
[VO_QUEUE
].dma
& DMA_BIT_MASK(32));
726 rtl_write_dword(rtlpriv
, REG_VIQ_DESA
,
727 (u64
) rtlpci
->tx_ring
[VI_QUEUE
].dma
& DMA_BIT_MASK(32));
728 rtl_write_dword(rtlpriv
, REG_BEQ_DESA
,
729 (u64
) rtlpci
->tx_ring
[BE_QUEUE
].dma
& DMA_BIT_MASK(32));
730 rtl_write_dword(rtlpriv
, REG_BKQ_DESA
,
731 (u64
) rtlpci
->tx_ring
[BK_QUEUE
].dma
& DMA_BIT_MASK(32));
732 rtl_write_dword(rtlpriv
, REG_HQ_DESA
,
733 (u64
) rtlpci
->tx_ring
[HIGH_QUEUE
].dma
&
735 rtl_write_dword(rtlpriv
, REG_RX_DESA
,
736 (u64
) rtlpci
->rx_ring
[RX_MPDU_QUEUE
].dma
&
739 if (IS_92C_SERIAL(rtlhal
->version
))
740 rtl_write_byte(rtlpriv
, REG_PCIE_CTRL_REG
+ 3, 0x77);
742 rtl_write_byte(rtlpriv
, REG_PCIE_CTRL_REG
+ 3, 0x22);
744 rtl_write_dword(rtlpriv
, REG_INT_MIG
, 0);
746 bytetmp
= rtl_read_byte(rtlpriv
, REG_APSD_CTRL
);
747 rtl_write_byte(rtlpriv
, REG_APSD_CTRL
, bytetmp
& ~BIT(6));
750 bytetmp
= rtl_read_byte(rtlpriv
, REG_APSD_CTRL
);
751 } while ((retry
< 200) && (bytetmp
& BIT(7)));
753 _rtl92ce_gen_refresh_led_state(hw
);
755 rtl_write_dword(rtlpriv
, REG_MCUTST_1
, 0x0);
760 static void _rtl92ce_hw_configure(struct ieee80211_hw
*hw
)
762 struct rtl_pci
*rtlpci
= rtl_pcidev(rtl_pcipriv(hw
));
763 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
764 struct rtl_pci_priv
*rtlpcipriv
= rtl_pcipriv(hw
);
768 reg_bw_opmode
= BW_OPMODE_20MHZ
;
769 reg_prsr
= RATE_ALL_CCK
| RATE_ALL_OFDM_AG
;
771 rtl_write_byte(rtlpriv
, REG_INIRTS_RATE_SEL
, 0x8);
773 rtl_write_byte(rtlpriv
, REG_BWOPMODE
, reg_bw_opmode
);
775 rtl_write_dword(rtlpriv
, REG_RRSR
, reg_prsr
);
777 rtl_write_byte(rtlpriv
, REG_SLOT
, 0x09);
779 rtl_write_byte(rtlpriv
, REG_AMPDU_MIN_SPACE
, 0x0);
781 rtl_write_word(rtlpriv
, REG_FWHW_TXQ_CTRL
, 0x1F80);
783 rtl_write_word(rtlpriv
, REG_RL
, 0x0707);
785 rtl_write_dword(rtlpriv
, REG_BAR_MODE_CTRL
, 0x02012802);
787 rtl_write_byte(rtlpriv
, REG_HWSEQ_CTRL
, 0xFF);
789 rtl_write_dword(rtlpriv
, REG_DARFRC
, 0x01000000);
790 rtl_write_dword(rtlpriv
, REG_DARFRC
+ 4, 0x07060504);
791 rtl_write_dword(rtlpriv
, REG_RARFRC
, 0x01000000);
792 rtl_write_dword(rtlpriv
, REG_RARFRC
+ 4, 0x07060504);
794 if ((rtlpcipriv
->bt_coexist
.bt_coexistence
) &&
795 (rtlpcipriv
->bt_coexist
.bt_coexist_type
== BT_CSR_BC4
))
796 rtl_write_dword(rtlpriv
, REG_AGGLEN_LMT
, 0x97427431);
798 rtl_write_dword(rtlpriv
, REG_AGGLEN_LMT
, 0xb972a841);
800 rtl_write_byte(rtlpriv
, REG_ATIMWND
, 0x2);
802 rtl_write_byte(rtlpriv
, REG_BCN_MAX_ERR
, 0xff);
804 rtlpci
->reg_bcn_ctrl_val
= 0x1f;
805 rtl_write_byte(rtlpriv
, REG_BCN_CTRL
, rtlpci
->reg_bcn_ctrl_val
);
807 rtl_write_byte(rtlpriv
, REG_TBTT_PROHIBIT
+ 1, 0xff);
809 rtl_write_byte(rtlpriv
, REG_TBTT_PROHIBIT
+ 1, 0xff);
811 rtl_write_byte(rtlpriv
, REG_PIFS
, 0x1C);
812 rtl_write_byte(rtlpriv
, REG_AGGR_BREAK_TIME
, 0x16);
814 if ((rtlpcipriv
->bt_coexist
.bt_coexistence
) &&
815 (rtlpcipriv
->bt_coexist
.bt_coexist_type
== BT_CSR_BC4
)) {
816 rtl_write_word(rtlpriv
, REG_NAV_PROT_LEN
, 0x0020);
817 rtl_write_word(rtlpriv
, REG_PROT_MODE_CTRL
, 0x0402);
819 rtl_write_word(rtlpriv
, REG_NAV_PROT_LEN
, 0x0020);
820 rtl_write_word(rtlpriv
, REG_NAV_PROT_LEN
, 0x0020);
823 if ((rtlpcipriv
->bt_coexist
.bt_coexistence
) &&
824 (rtlpcipriv
->bt_coexist
.bt_coexist_type
== BT_CSR_BC4
))
825 rtl_write_dword(rtlpriv
, REG_FAST_EDCA_CTRL
, 0x03086666);
827 rtl_write_dword(rtlpriv
, REG_FAST_EDCA_CTRL
, 0x086666);
829 rtl_write_byte(rtlpriv
, REG_ACKTO
, 0x40);
831 rtl_write_word(rtlpriv
, REG_SPEC_SIFS
, 0x1010);
832 rtl_write_word(rtlpriv
, REG_MAC_SPEC_SIFS
, 0x1010);
834 rtl_write_word(rtlpriv
, REG_SIFS_CTX
, 0x1010);
836 rtl_write_word(rtlpriv
, REG_SIFS_TRX
, 0x1010);
838 rtl_write_dword(rtlpriv
, REG_MAR
, 0xffffffff);
839 rtl_write_dword(rtlpriv
, REG_MAR
+ 4, 0xffffffff);
843 static void _rtl92ce_enable_aspm_back_door(struct ieee80211_hw
*hw
)
845 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
846 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
848 rtl_write_byte(rtlpriv
, 0x34b, 0x93);
849 rtl_write_word(rtlpriv
, 0x350, 0x870c);
850 rtl_write_byte(rtlpriv
, 0x352, 0x1);
852 if (ppsc
->support_backdoor
)
853 rtl_write_byte(rtlpriv
, 0x349, 0x1b);
855 rtl_write_byte(rtlpriv
, 0x349, 0x03);
857 rtl_write_word(rtlpriv
, 0x350, 0x2718);
858 rtl_write_byte(rtlpriv
, 0x352, 0x1);
861 void rtl92ce_enable_hw_security_config(struct ieee80211_hw
*hw
)
863 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
866 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_LOUD
,
867 ("PairwiseEncAlgorithm = %d GroupEncAlgorithm = %d\n",
868 rtlpriv
->sec
.pairwise_enc_algorithm
,
869 rtlpriv
->sec
.group_enc_algorithm
));
871 if (rtlpriv
->cfg
->mod_params
->sw_crypto
|| rtlpriv
->sec
.use_sw_sec
) {
872 RT_TRACE(rtlpriv
, COMP_SEC
, DBG_DMESG
, ("not open "
877 sec_reg_value
= SCR_TxEncEnable
| SCR_RxDecEnable
;
879 if (rtlpriv
->sec
.use_defaultkey
) {
880 sec_reg_value
|= SCR_TxUseDK
;
881 sec_reg_value
|= SCR_RxUseDK
;
884 sec_reg_value
|= (SCR_RXBCUSEDK
| SCR_TXBCUSEDK
);
886 rtl_write_byte(rtlpriv
, REG_CR
+ 1, 0x02);
888 RT_TRACE(rtlpriv
, COMP_SEC
, DBG_LOUD
,
889 ("The SECR-value %x\n", sec_reg_value
));
891 rtlpriv
->cfg
->ops
->set_hw_reg(hw
, HW_VAR_WPA_CONFIG
, &sec_reg_value
);
895 int rtl92ce_hw_init(struct ieee80211_hw
*hw
)
897 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
898 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
899 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
900 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
901 struct rtl_pci
*rtlpci
= rtl_pcidev(rtl_pcipriv(hw
));
902 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
903 static bool iqk_initialized
; /* initialized to false */
904 bool rtstatus
= true;
909 rtlpci
->being_init_adapter
= true;
910 rtlpriv
->intf_ops
->disable_aspm(hw
);
911 rtstatus
= _rtl92ce_init_mac(hw
);
912 if (rtstatus
!= true) {
913 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
, ("Init MAC failed\n"));
918 err
= rtl92c_download_fw(hw
);
920 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_WARNING
,
921 ("Failed to download FW. Init HW "
922 "without FW now..\n"));
927 rtlhal
->last_hmeboxnum
= 0;
928 rtl92c_phy_mac_config(hw
);
929 rtl92c_phy_bb_config(hw
);
930 rtlphy
->rf_mode
= RF_OP_BY_SW_3WIRE
;
931 rtl92c_phy_rf_config(hw
);
932 rtlphy
->rfreg_chnlval
[0] = rtl_get_rfreg(hw
, (enum radio_path
)0,
933 RF_CHNLBW
, RFREG_OFFSET_MASK
);
934 rtlphy
->rfreg_chnlval
[1] = rtl_get_rfreg(hw
, (enum radio_path
)1,
935 RF_CHNLBW
, RFREG_OFFSET_MASK
);
936 rtl_set_bbreg(hw
, RFPGA0_RFMOD
, BCCKEN
, 0x1);
937 rtl_set_bbreg(hw
, RFPGA0_RFMOD
, BOFDMEN
, 0x1);
938 rtl_set_bbreg(hw
, RFPGA0_ANALOGPARAMETER2
, BIT(10), 1);
939 _rtl92ce_hw_configure(hw
);
940 rtl_cam_reset_all_entry(hw
);
941 rtl92ce_enable_hw_security_config(hw
);
943 ppsc
->rfpwr_state
= ERFON
;
945 rtlpriv
->cfg
->ops
->set_hw_reg(hw
, HW_VAR_ETHER_ADDR
, mac
->mac_addr
);
946 _rtl92ce_enable_aspm_back_door(hw
);
947 rtlpriv
->intf_ops
->enable_aspm(hw
);
949 rtl8192ce_bt_hw_init(hw
);
951 if (ppsc
->rfpwr_state
== ERFON
) {
952 rtl92c_phy_set_rfpath_switch(hw
, 1);
953 if (iqk_initialized
) {
954 rtl92c_phy_iq_calibrate(hw
, true);
956 rtl92c_phy_iq_calibrate(hw
, false);
957 iqk_initialized
= true;
960 rtl92c_dm_check_txpower_tracking(hw
);
961 rtl92c_phy_lc_calibrate(hw
);
964 is92c
= IS_92C_SERIAL(rtlhal
->version
);
965 tmp_u1b
= efuse_read_1byte(hw
, 0x1FA);
966 if (!(tmp_u1b
& BIT(0))) {
967 rtl_set_rfreg(hw
, RF90_PATH_A
, 0x15, 0x0F, 0x05);
968 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
, ("PA BIAS path A\n"));
971 if (!(tmp_u1b
& BIT(1)) && is92c
) {
972 rtl_set_rfreg(hw
, RF90_PATH_B
, 0x15, 0x0F, 0x05);
973 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
, ("PA BIAS path B\n"));
976 if (!(tmp_u1b
& BIT(4))) {
977 tmp_u1b
= rtl_read_byte(rtlpriv
, 0x16);
979 rtl_write_byte(rtlpriv
, 0x16, tmp_u1b
| 0x80);
981 rtl_write_byte(rtlpriv
, 0x16, tmp_u1b
| 0x90);
982 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
, ("under 1.5V\n"));
985 rtlpci
->being_init_adapter
= false;
989 static enum version_8192c
_rtl92ce_read_chip_version(struct ieee80211_hw
*hw
)
991 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
992 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
993 enum version_8192c version
= VERSION_UNKNOWN
;
996 value32
= rtl_read_dword(rtlpriv
, REG_SYS_CFG
);
997 if (value32
& TRP_VAUX_EN
) {
998 version
= (value32
& TYPE_ID
) ? VERSION_A_CHIP_92C
:
1001 version
= (value32
& TYPE_ID
) ? VERSION_B_CHIP_92C
:
1006 case VERSION_B_CHIP_92C
:
1007 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
1008 ("Chip Version ID: VERSION_B_CHIP_92C.\n"));
1010 case VERSION_B_CHIP_88C
:
1011 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
1012 ("Chip Version ID: VERSION_B_CHIP_88C.\n"));
1014 case VERSION_A_CHIP_92C
:
1015 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
1016 ("Chip Version ID: VERSION_A_CHIP_92C.\n"));
1018 case VERSION_A_CHIP_88C
:
1019 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
1020 ("Chip Version ID: VERSION_A_CHIP_88C.\n"));
1023 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
1024 ("Chip Version ID: Unknown. Bug?\n"));
1028 switch (version
& 0x3) {
1030 rtlphy
->rf_type
= RF_1T1R
;
1033 rtlphy
->rf_type
= RF_2T2R
;
1036 rtlphy
->rf_type
= RF_1T2R
;
1039 rtlphy
->rf_type
= RF_1T1R
;
1040 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
1041 ("ERROR RF_Type is set!!"));
1045 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_LOUD
,
1046 ("Chip RF Type: %s\n", (rtlphy
->rf_type
== RF_2T2R
) ?
1047 "RF_2T2R" : "RF_1T1R"));
1052 static int _rtl92ce_set_media_status(struct ieee80211_hw
*hw
,
1053 enum nl80211_iftype type
)
1055 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1056 u8 bt_msr
= rtl_read_byte(rtlpriv
, MSR
);
1057 enum led_ctl_mode ledaction
= LED_CTL_NO_LINK
;
1060 if (type
== NL80211_IFTYPE_UNSPECIFIED
||
1061 type
== NL80211_IFTYPE_STATION
) {
1062 _rtl92ce_stop_tx_beacon(hw
);
1063 _rtl92ce_enable_bcn_sub_func(hw
);
1064 } else if (type
== NL80211_IFTYPE_ADHOC
|| type
== NL80211_IFTYPE_AP
) {
1065 _rtl92ce_resume_tx_beacon(hw
);
1066 _rtl92ce_disable_bcn_sub_func(hw
);
1068 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_WARNING
,
1069 ("Set HW_VAR_MEDIA_STATUS: "
1070 "No such media status(%x).\n", type
));
1074 case NL80211_IFTYPE_UNSPECIFIED
:
1075 bt_msr
|= MSR_NOLINK
;
1076 ledaction
= LED_CTL_LINK
;
1077 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
1078 ("Set Network type to NO LINK!\n"));
1080 case NL80211_IFTYPE_ADHOC
:
1081 bt_msr
|= MSR_ADHOC
;
1082 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
1083 ("Set Network type to Ad Hoc!\n"));
1085 case NL80211_IFTYPE_STATION
:
1086 bt_msr
|= MSR_INFRA
;
1087 ledaction
= LED_CTL_LINK
;
1088 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
1089 ("Set Network type to STA!\n"));
1091 case NL80211_IFTYPE_AP
:
1093 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
1094 ("Set Network type to AP!\n"));
1097 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
1098 ("Network type %d not support!\n", type
));
1104 rtl_write_byte(rtlpriv
, (MSR
), bt_msr
);
1105 rtlpriv
->cfg
->ops
->led_control(hw
, ledaction
);
1106 if ((bt_msr
& 0xfc) == MSR_AP
)
1107 rtl_write_byte(rtlpriv
, REG_BCNTCFG
+ 1, 0x00);
1109 rtl_write_byte(rtlpriv
, REG_BCNTCFG
+ 1, 0x66);
1113 void rtl92ce_set_check_bssid(struct ieee80211_hw
*hw
, bool check_bssid
)
1115 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1116 u32 reg_rcr
= rtl_read_dword(rtlpriv
, REG_RCR
);
1118 if (rtlpriv
->psc
.rfpwr_state
!= ERFON
)
1122 reg_rcr
|= (RCR_CBSSID_DATA
| RCR_CBSSID_BCN
);
1123 rtlpriv
->cfg
->ops
->set_hw_reg(hw
, HW_VAR_RCR
,
1125 _rtl92ce_set_bcn_ctrl_reg(hw
, 0, BIT(4));
1126 } else if (check_bssid
== false) {
1127 reg_rcr
&= (~(RCR_CBSSID_DATA
| RCR_CBSSID_BCN
));
1128 _rtl92ce_set_bcn_ctrl_reg(hw
, BIT(4), 0);
1129 rtlpriv
->cfg
->ops
->set_hw_reg(hw
,
1130 HW_VAR_RCR
, (u8
*) (®_rcr
));
1135 int rtl92ce_set_network_type(struct ieee80211_hw
*hw
, enum nl80211_iftype type
)
1137 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1139 if (_rtl92ce_set_media_status(hw
, type
))
1142 if (rtlpriv
->mac80211
.link_state
== MAC80211_LINKED
) {
1143 if (type
!= NL80211_IFTYPE_AP
)
1144 rtl92ce_set_check_bssid(hw
, true);
1146 rtl92ce_set_check_bssid(hw
, false);
1152 /* don't set REG_EDCA_BE_PARAM here because mac80211 will send pkt when scan */
1153 void rtl92ce_set_qos(struct ieee80211_hw
*hw
, int aci
)
1155 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1156 rtl92c_dm_init_edca_turbo(hw
);
1159 rtl_write_dword(rtlpriv
, REG_EDCA_BK_PARAM
, 0xa44f);
1162 /* rtl_write_dword(rtlpriv, REG_EDCA_BE_PARAM, u4b_ac_param); */
1165 rtl_write_dword(rtlpriv
, REG_EDCA_VI_PARAM
, 0x5e4322);
1168 rtl_write_dword(rtlpriv
, REG_EDCA_VO_PARAM
, 0x2f3222);
1171 RT_ASSERT(false, ("invalid aci: %d !\n", aci
));
1176 void rtl92ce_enable_interrupt(struct ieee80211_hw
*hw
)
1178 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1179 struct rtl_pci
*rtlpci
= rtl_pcidev(rtl_pcipriv(hw
));
1181 rtl_write_dword(rtlpriv
, REG_HIMR
, rtlpci
->irq_mask
[0] & 0xFFFFFFFF);
1182 rtl_write_dword(rtlpriv
, REG_HIMRE
, rtlpci
->irq_mask
[1] & 0xFFFFFFFF);
1185 void rtl92ce_disable_interrupt(struct ieee80211_hw
*hw
)
1187 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1188 struct rtl_pci
*rtlpci
= rtl_pcidev(rtl_pcipriv(hw
));
1190 rtl_write_dword(rtlpriv
, REG_HIMR
, IMR8190_DISABLED
);
1191 rtl_write_dword(rtlpriv
, REG_HIMRE
, IMR8190_DISABLED
);
1192 synchronize_irq(rtlpci
->pdev
->irq
);
1195 static void _rtl92ce_poweroff_adapter(struct ieee80211_hw
*hw
)
1197 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1198 struct rtl_pci_priv
*rtlpcipriv
= rtl_pcipriv(hw
);
1202 rtlpriv
->intf_ops
->enable_aspm(hw
);
1203 rtl_write_byte(rtlpriv
, REG_TXPAUSE
, 0xFF);
1204 rtl_set_rfreg(hw
, RF90_PATH_A
, 0x00, RFREG_OFFSET_MASK
, 0x00);
1205 rtl_write_byte(rtlpriv
, REG_RF_CTRL
, 0x00);
1206 rtl_write_byte(rtlpriv
, REG_APSD_CTRL
, 0x40);
1207 rtl_write_byte(rtlpriv
, REG_SYS_FUNC_EN
, 0xE2);
1208 rtl_write_byte(rtlpriv
, REG_SYS_FUNC_EN
, 0xE0);
1209 if (rtl_read_byte(rtlpriv
, REG_MCUFWDL
) & BIT(7))
1210 rtl92c_firmware_selfreset(hw
);
1211 rtl_write_byte(rtlpriv
, REG_SYS_FUNC_EN
+ 1, 0x51);
1212 rtl_write_byte(rtlpriv
, REG_MCUFWDL
, 0x00);
1213 rtl_write_dword(rtlpriv
, REG_GPIO_PIN_CTRL
, 0x00000000);
1214 u1b_tmp
= rtl_read_byte(rtlpriv
, REG_GPIO_PIN_CTRL
);
1215 if ((rtlpcipriv
->bt_coexist
.bt_coexistence
) &&
1216 ((rtlpcipriv
->bt_coexist
.bt_coexist_type
== BT_CSR_BC4
) ||
1217 (rtlpcipriv
->bt_coexist
.bt_coexist_type
== BT_CSR_BC8
))) {
1218 rtl_write_dword(rtlpriv
, REG_GPIO_PIN_CTRL
, 0x00F30000 |
1221 rtl_write_dword(rtlpriv
, REG_GPIO_PIN_CTRL
, 0x00FF0000 |
1224 rtl_write_word(rtlpriv
, REG_GPIO_IO_SEL
, 0x0790);
1225 rtl_write_word(rtlpriv
, REG_LEDCFG0
, 0x8080);
1226 rtl_write_byte(rtlpriv
, REG_AFE_PLL_CTRL
, 0x80);
1227 rtl_write_byte(rtlpriv
, REG_SPS0_CTRL
, 0x23);
1228 if (rtlpcipriv
->bt_coexist
.bt_coexistence
) {
1229 u4b_tmp
= rtl_read_dword(rtlpriv
, REG_AFE_XTAL_CTRL
);
1230 u4b_tmp
|= 0x03824800;
1231 rtl_write_dword(rtlpriv
, REG_AFE_XTAL_CTRL
, u4b_tmp
);
1233 rtl_write_dword(rtlpriv
, REG_AFE_XTAL_CTRL
, 0x0e);
1236 rtl_write_byte(rtlpriv
, REG_RSV_CTRL
, 0x0e);
1237 rtl_write_byte(rtlpriv
, REG_APS_FSMCO
+ 1, 0x10);
1240 void rtl92ce_card_disable(struct ieee80211_hw
*hw
)
1242 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1243 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
1244 struct rtl_pci
*rtlpci
= rtl_pcidev(rtl_pcipriv(hw
));
1245 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
1246 enum nl80211_iftype opmode
;
1248 mac
->link_state
= MAC80211_NOLINK
;
1249 opmode
= NL80211_IFTYPE_UNSPECIFIED
;
1250 _rtl92ce_set_media_status(hw
, opmode
);
1251 if (rtlpci
->driver_is_goingto_unload
||
1252 ppsc
->rfoff_reason
> RF_CHANGE_BY_PS
)
1253 rtlpriv
->cfg
->ops
->led_control(hw
, LED_CTL_POWER_OFF
);
1254 RT_SET_PS_LEVEL(ppsc
, RT_RF_OFF_LEVL_HALT_NIC
);
1255 _rtl92ce_poweroff_adapter(hw
);
1258 void rtl92ce_interrupt_recognized(struct ieee80211_hw
*hw
,
1259 u32
*p_inta
, u32
*p_intb
)
1261 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1262 struct rtl_pci
*rtlpci
= rtl_pcidev(rtl_pcipriv(hw
));
1264 *p_inta
= rtl_read_dword(rtlpriv
, ISR
) & rtlpci
->irq_mask
[0];
1265 rtl_write_dword(rtlpriv
, ISR
, *p_inta
);
1268 * *p_intb = rtl_read_dword(rtlpriv, REG_HISRE) & rtlpci->irq_mask[1];
1269 * rtl_write_dword(rtlpriv, ISR + 4, *p_intb);
1273 void rtl92ce_set_beacon_related_registers(struct ieee80211_hw
*hw
)
1276 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1277 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
1278 u16 bcn_interval
, atim_window
;
1280 bcn_interval
= mac
->beacon_interval
;
1281 atim_window
= 2; /*FIX MERGE */
1282 rtl92ce_disable_interrupt(hw
);
1283 rtl_write_word(rtlpriv
, REG_ATIMWND
, atim_window
);
1284 rtl_write_word(rtlpriv
, REG_BCN_INTERVAL
, bcn_interval
);
1285 rtl_write_word(rtlpriv
, REG_BCNTCFG
, 0x660f);
1286 rtl_write_byte(rtlpriv
, REG_RXTSF_OFFSET_CCK
, 0x18);
1287 rtl_write_byte(rtlpriv
, REG_RXTSF_OFFSET_OFDM
, 0x18);
1288 rtl_write_byte(rtlpriv
, 0x606, 0x30);
1289 rtl92ce_enable_interrupt(hw
);
1292 void rtl92ce_set_beacon_interval(struct ieee80211_hw
*hw
)
1294 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1295 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
1296 u16 bcn_interval
= mac
->beacon_interval
;
1298 RT_TRACE(rtlpriv
, COMP_BEACON
, DBG_DMESG
,
1299 ("beacon_interval:%d\n", bcn_interval
));
1300 rtl92ce_disable_interrupt(hw
);
1301 rtl_write_word(rtlpriv
, REG_BCN_INTERVAL
, bcn_interval
);
1302 rtl92ce_enable_interrupt(hw
);
1305 void rtl92ce_update_interrupt_mask(struct ieee80211_hw
*hw
,
1306 u32 add_msr
, u32 rm_msr
)
1308 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1309 struct rtl_pci
*rtlpci
= rtl_pcidev(rtl_pcipriv(hw
));
1311 RT_TRACE(rtlpriv
, COMP_INTR
, DBG_LOUD
,
1312 ("add_msr:%x, rm_msr:%x\n", add_msr
, rm_msr
));
1315 rtlpci
->irq_mask
[0] |= add_msr
;
1317 rtlpci
->irq_mask
[0] &= (~rm_msr
);
1318 rtl92ce_disable_interrupt(hw
);
1319 rtl92ce_enable_interrupt(hw
);
1322 static void _rtl92ce_read_txpower_info_from_hwpg(struct ieee80211_hw
*hw
,
1326 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1327 struct rtl_efuse
*rtlefuse
= rtl_efuse(rtl_priv(hw
));
1328 u8 rf_path
, index
, tempval
;
1331 for (rf_path
= 0; rf_path
< 2; rf_path
++) {
1332 for (i
= 0; i
< 3; i
++) {
1333 if (!autoload_fail
) {
1335 eeprom_chnlarea_txpwr_cck
[rf_path
][i
] =
1336 hwinfo
[EEPROM_TXPOWERCCK
+ rf_path
* 3 + i
];
1338 eeprom_chnlarea_txpwr_ht40_1s
[rf_path
][i
] =
1339 hwinfo
[EEPROM_TXPOWERHT40_1S
+ rf_path
* 3 +
1343 eeprom_chnlarea_txpwr_cck
[rf_path
][i
] =
1344 EEPROM_DEFAULT_TXPOWERLEVEL
;
1346 eeprom_chnlarea_txpwr_ht40_1s
[rf_path
][i
] =
1347 EEPROM_DEFAULT_TXPOWERLEVEL
;
1352 for (i
= 0; i
< 3; i
++) {
1354 tempval
= hwinfo
[EEPROM_TXPOWERHT40_2SDIFF
+ i
];
1356 tempval
= EEPROM_DEFAULT_HT40_2SDIFF
;
1357 rtlefuse
->eeprom_chnlarea_txpwr_ht40_2sdiif
[RF90_PATH_A
][i
] =
1359 rtlefuse
->eeprom_chnlarea_txpwr_ht40_2sdiif
[RF90_PATH_B
][i
] =
1360 ((tempval
& 0xf0) >> 4);
1363 for (rf_path
= 0; rf_path
< 2; rf_path
++)
1364 for (i
= 0; i
< 3; i
++)
1365 RTPRINT(rtlpriv
, FINIT
, INIT_EEPROM
,
1366 ("RF(%d) EEPROM CCK Area(%d) = 0x%x\n", rf_path
,
1369 eeprom_chnlarea_txpwr_cck
[rf_path
][i
]));
1370 for (rf_path
= 0; rf_path
< 2; rf_path
++)
1371 for (i
= 0; i
< 3; i
++)
1372 RTPRINT(rtlpriv
, FINIT
, INIT_EEPROM
,
1373 ("RF(%d) EEPROM HT40 1S Area(%d) = 0x%x\n",
1376 eeprom_chnlarea_txpwr_ht40_1s
[rf_path
][i
]));
1377 for (rf_path
= 0; rf_path
< 2; rf_path
++)
1378 for (i
= 0; i
< 3; i
++)
1379 RTPRINT(rtlpriv
, FINIT
, INIT_EEPROM
,
1380 ("RF(%d) EEPROM HT40 2S Diff Area(%d) = 0x%x\n",
1383 eeprom_chnlarea_txpwr_ht40_2sdiif
[rf_path
]
1386 for (rf_path
= 0; rf_path
< 2; rf_path
++) {
1387 for (i
= 0; i
< 14; i
++) {
1388 index
= _rtl92c_get_chnl_group((u8
) i
);
1390 rtlefuse
->txpwrlevel_cck
[rf_path
][i
] =
1391 rtlefuse
->eeprom_chnlarea_txpwr_cck
[rf_path
][index
];
1392 rtlefuse
->txpwrlevel_ht40_1s
[rf_path
][i
] =
1394 eeprom_chnlarea_txpwr_ht40_1s
[rf_path
][index
];
1397 eeprom_chnlarea_txpwr_ht40_1s
[rf_path
][index
] -
1399 eeprom_chnlarea_txpwr_ht40_2sdiif
[rf_path
][index
])
1401 rtlefuse
->txpwrlevel_ht40_2s
[rf_path
][i
] =
1403 eeprom_chnlarea_txpwr_ht40_1s
[rf_path
]
1406 eeprom_chnlarea_txpwr_ht40_2sdiif
[rf_path
]
1409 rtlefuse
->txpwrlevel_ht40_2s
[rf_path
][i
] = 0;
1413 for (i
= 0; i
< 14; i
++) {
1414 RTPRINT(rtlpriv
, FINIT
, INIT_TxPower
,
1415 ("RF(%d)-Ch(%d) [CCK / HT40_1S / HT40_2S] = "
1416 "[0x%x / 0x%x / 0x%x]\n", rf_path
, i
,
1417 rtlefuse
->txpwrlevel_cck
[rf_path
][i
],
1418 rtlefuse
->txpwrlevel_ht40_1s
[rf_path
][i
],
1419 rtlefuse
->txpwrlevel_ht40_2s
[rf_path
][i
]));
1423 for (i
= 0; i
< 3; i
++) {
1424 if (!autoload_fail
) {
1425 rtlefuse
->eeprom_pwrlimit_ht40
[i
] =
1426 hwinfo
[EEPROM_TXPWR_GROUP
+ i
];
1427 rtlefuse
->eeprom_pwrlimit_ht20
[i
] =
1428 hwinfo
[EEPROM_TXPWR_GROUP
+ 3 + i
];
1430 rtlefuse
->eeprom_pwrlimit_ht40
[i
] = 0;
1431 rtlefuse
->eeprom_pwrlimit_ht20
[i
] = 0;
1435 for (rf_path
= 0; rf_path
< 2; rf_path
++) {
1436 for (i
= 0; i
< 14; i
++) {
1437 index
= _rtl92c_get_chnl_group((u8
) i
);
1439 if (rf_path
== RF90_PATH_A
) {
1440 rtlefuse
->pwrgroup_ht20
[rf_path
][i
] =
1441 (rtlefuse
->eeprom_pwrlimit_ht20
[index
]
1443 rtlefuse
->pwrgroup_ht40
[rf_path
][i
] =
1444 (rtlefuse
->eeprom_pwrlimit_ht40
[index
]
1446 } else if (rf_path
== RF90_PATH_B
) {
1447 rtlefuse
->pwrgroup_ht20
[rf_path
][i
] =
1448 ((rtlefuse
->eeprom_pwrlimit_ht20
[index
]
1450 rtlefuse
->pwrgroup_ht40
[rf_path
][i
] =
1451 ((rtlefuse
->eeprom_pwrlimit_ht40
[index
]
1455 RTPRINT(rtlpriv
, FINIT
, INIT_TxPower
,
1456 ("RF-%d pwrgroup_ht20[%d] = 0x%x\n",
1458 rtlefuse
->pwrgroup_ht20
[rf_path
][i
]));
1459 RTPRINT(rtlpriv
, FINIT
, INIT_TxPower
,
1460 ("RF-%d pwrgroup_ht40[%d] = 0x%x\n",
1462 rtlefuse
->pwrgroup_ht40
[rf_path
][i
]));
1466 for (i
= 0; i
< 14; i
++) {
1467 index
= _rtl92c_get_chnl_group((u8
) i
);
1470 tempval
= hwinfo
[EEPROM_TXPOWERHT20DIFF
+ index
];
1472 tempval
= EEPROM_DEFAULT_HT20_DIFF
;
1474 rtlefuse
->txpwr_ht20diff
[RF90_PATH_A
][i
] = (tempval
& 0xF);
1475 rtlefuse
->txpwr_ht20diff
[RF90_PATH_B
][i
] =
1476 ((tempval
>> 4) & 0xF);
1478 if (rtlefuse
->txpwr_ht20diff
[RF90_PATH_A
][i
] & BIT(3))
1479 rtlefuse
->txpwr_ht20diff
[RF90_PATH_A
][i
] |= 0xF0;
1481 if (rtlefuse
->txpwr_ht20diff
[RF90_PATH_B
][i
] & BIT(3))
1482 rtlefuse
->txpwr_ht20diff
[RF90_PATH_B
][i
] |= 0xF0;
1484 index
= _rtl92c_get_chnl_group((u8
) i
);
1487 tempval
= hwinfo
[EEPROM_TXPOWER_OFDMDIFF
+ index
];
1489 tempval
= EEPROM_DEFAULT_LEGACYHTTXPOWERDIFF
;
1491 rtlefuse
->txpwr_legacyhtdiff
[RF90_PATH_A
][i
] = (tempval
& 0xF);
1492 rtlefuse
->txpwr_legacyhtdiff
[RF90_PATH_B
][i
] =
1493 ((tempval
>> 4) & 0xF);
1496 rtlefuse
->legacy_ht_txpowerdiff
=
1497 rtlefuse
->txpwr_legacyhtdiff
[RF90_PATH_A
][7];
1499 for (i
= 0; i
< 14; i
++)
1500 RTPRINT(rtlpriv
, FINIT
, INIT_TxPower
,
1501 ("RF-A Ht20 to HT40 Diff[%d] = 0x%x\n", i
,
1502 rtlefuse
->txpwr_ht20diff
[RF90_PATH_A
][i
]));
1503 for (i
= 0; i
< 14; i
++)
1504 RTPRINT(rtlpriv
, FINIT
, INIT_TxPower
,
1505 ("RF-A Legacy to Ht40 Diff[%d] = 0x%x\n", i
,
1506 rtlefuse
->txpwr_legacyhtdiff
[RF90_PATH_A
][i
]));
1507 for (i
= 0; i
< 14; i
++)
1508 RTPRINT(rtlpriv
, FINIT
, INIT_TxPower
,
1509 ("RF-B Ht20 to HT40 Diff[%d] = 0x%x\n", i
,
1510 rtlefuse
->txpwr_ht20diff
[RF90_PATH_B
][i
]));
1511 for (i
= 0; i
< 14; i
++)
1512 RTPRINT(rtlpriv
, FINIT
, INIT_TxPower
,
1513 ("RF-B Legacy to HT40 Diff[%d] = 0x%x\n", i
,
1514 rtlefuse
->txpwr_legacyhtdiff
[RF90_PATH_B
][i
]));
1517 rtlefuse
->eeprom_regulatory
= (hwinfo
[RF_OPTION1
] & 0x7);
1519 rtlefuse
->eeprom_regulatory
= 0;
1520 RTPRINT(rtlpriv
, FINIT
, INIT_TxPower
,
1521 ("eeprom_regulatory = 0x%x\n", rtlefuse
->eeprom_regulatory
));
1523 if (!autoload_fail
) {
1524 rtlefuse
->eeprom_tssi
[RF90_PATH_A
] = hwinfo
[EEPROM_TSSI_A
];
1525 rtlefuse
->eeprom_tssi
[RF90_PATH_B
] = hwinfo
[EEPROM_TSSI_B
];
1527 rtlefuse
->eeprom_tssi
[RF90_PATH_A
] = EEPROM_DEFAULT_TSSI
;
1528 rtlefuse
->eeprom_tssi
[RF90_PATH_B
] = EEPROM_DEFAULT_TSSI
;
1530 RTPRINT(rtlpriv
, FINIT
, INIT_TxPower
,
1531 ("TSSI_A = 0x%x, TSSI_B = 0x%x\n",
1532 rtlefuse
->eeprom_tssi
[RF90_PATH_A
],
1533 rtlefuse
->eeprom_tssi
[RF90_PATH_B
]));
1536 tempval
= hwinfo
[EEPROM_THERMAL_METER
];
1538 tempval
= EEPROM_DEFAULT_THERMALMETER
;
1539 rtlefuse
->eeprom_thermalmeter
= (tempval
& 0x1f);
1541 if (rtlefuse
->eeprom_thermalmeter
== 0x1f || autoload_fail
)
1542 rtlefuse
->apk_thermalmeterignore
= true;
1544 rtlefuse
->thermalmeter
[0] = rtlefuse
->eeprom_thermalmeter
;
1545 RTPRINT(rtlpriv
, FINIT
, INIT_TxPower
,
1546 ("thermalmeter = 0x%x\n", rtlefuse
->eeprom_thermalmeter
));
1549 static void _rtl92ce_read_adapter_info(struct ieee80211_hw
*hw
)
1551 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1552 struct rtl_efuse
*rtlefuse
= rtl_efuse(rtl_priv(hw
));
1553 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
1555 u8 hwinfo
[HWSET_MAX_SIZE
];
1558 if (rtlefuse
->epromtype
== EEPROM_BOOT_EFUSE
) {
1559 rtl_efuse_shadow_map_update(hw
);
1561 memcpy((void *)hwinfo
,
1562 (void *)&rtlefuse
->efuse_map
[EFUSE_INIT_MAP
][0],
1564 } else if (rtlefuse
->epromtype
== EEPROM_93C46
) {
1565 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
1566 ("RTL819X Not boot from eeprom, check it !!"));
1569 RT_PRINT_DATA(rtlpriv
, COMP_INIT
, DBG_DMESG
, ("MAP\n"),
1570 hwinfo
, HWSET_MAX_SIZE
);
1572 eeprom_id
= *((u16
*)&hwinfo
[0]);
1573 if (eeprom_id
!= RTL8190_EEPROM_ID
) {
1574 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_WARNING
,
1575 ("EEPROM ID(%#x) is invalid!!\n", eeprom_id
));
1576 rtlefuse
->autoload_failflag
= true;
1578 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_LOUD
, ("Autoload OK\n"));
1579 rtlefuse
->autoload_failflag
= false;
1582 if (rtlefuse
->autoload_failflag
)
1585 for (i
= 0; i
< 6; i
+= 2) {
1586 usvalue
= *(u16
*)&hwinfo
[EEPROM_MAC_ADDR
+ i
];
1587 *((u16
*) (&rtlefuse
->dev_addr
[i
])) = usvalue
;
1590 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
,
1591 ("%pM\n", rtlefuse
->dev_addr
));
1593 _rtl92ce_read_txpower_info_from_hwpg(hw
,
1594 rtlefuse
->autoload_failflag
,
1597 rtl8192ce_read_bt_coexist_info_from_hwpg(hw
,
1598 rtlefuse
->autoload_failflag
,
1601 rtlefuse
->eeprom_channelplan
= *(u8
*)&hwinfo
[EEPROM_CHANNELPLAN
];
1602 rtlefuse
->eeprom_version
= *(u16
*)&hwinfo
[EEPROM_VERSION
];
1603 rtlefuse
->txpwr_fromeprom
= true;
1604 rtlefuse
->eeprom_oemid
= *(u8
*)&hwinfo
[EEPROM_CUSTOMER_ID
];
1606 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_LOUD
,
1607 ("EEPROM Customer ID: 0x%2x\n", rtlefuse
->eeprom_oemid
));
1609 /* set channel paln to world wide 13 */
1610 rtlefuse
->channel_plan
= COUNTRY_CODE_WORLD_WIDE_13
;
1612 if (rtlhal
->oem_id
== RT_CID_DEFAULT
) {
1613 switch (rtlefuse
->eeprom_oemid
) {
1614 case EEPROM_CID_DEFAULT
:
1615 if (rtlefuse
->eeprom_did
== 0x8176) {
1616 if ((rtlefuse
->eeprom_svid
== 0x103C &&
1617 rtlefuse
->eeprom_smid
== 0x1629))
1618 rtlhal
->oem_id
= RT_CID_819x_HP
;
1620 rtlhal
->oem_id
= RT_CID_DEFAULT
;
1622 rtlhal
->oem_id
= RT_CID_DEFAULT
;
1625 case EEPROM_CID_TOSHIBA
:
1626 rtlhal
->oem_id
= RT_CID_TOSHIBA
;
1628 case EEPROM_CID_QMI
:
1629 rtlhal
->oem_id
= RT_CID_819x_QMI
;
1631 case EEPROM_CID_WHQL
:
1633 rtlhal
->oem_id
= RT_CID_DEFAULT
;
1641 static void _rtl92ce_hal_customized_behavior(struct ieee80211_hw
*hw
)
1643 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1644 struct rtl_pci_priv
*pcipriv
= rtl_pcipriv(hw
);
1645 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
1647 switch (rtlhal
->oem_id
) {
1648 case RT_CID_819x_HP
:
1649 pcipriv
->ledctl
.led_opendrain
= true;
1651 case RT_CID_819x_Lenovo
:
1652 case RT_CID_DEFAULT
:
1653 case RT_CID_TOSHIBA
:
1655 case RT_CID_819x_Acer
:
1660 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
,
1661 ("RT Customized ID: 0x%02X\n", rtlhal
->oem_id
));
1664 void rtl92ce_read_eeprom_info(struct ieee80211_hw
*hw
)
1666 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1667 struct rtl_efuse
*rtlefuse
= rtl_efuse(rtl_priv(hw
));
1668 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
1669 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
1672 rtlhal
->version
= _rtl92ce_read_chip_version(hw
);
1673 if (get_rf_type(rtlphy
) == RF_1T1R
)
1674 rtlpriv
->dm
.rfpath_rxenable
[0] = true;
1676 rtlpriv
->dm
.rfpath_rxenable
[0] =
1677 rtlpriv
->dm
.rfpath_rxenable
[1] = true;
1678 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_LOUD
, ("VersionID = 0x%4x\n",
1680 tmp_u1b
= rtl_read_byte(rtlpriv
, REG_9346CR
);
1681 if (tmp_u1b
& BIT(4)) {
1682 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
, ("Boot from EEPROM\n"));
1683 rtlefuse
->epromtype
= EEPROM_93C46
;
1685 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
, ("Boot from EFUSE\n"));
1686 rtlefuse
->epromtype
= EEPROM_BOOT_EFUSE
;
1688 if (tmp_u1b
& BIT(5)) {
1689 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_LOUD
, ("Autoload OK\n"));
1690 rtlefuse
->autoload_failflag
= false;
1691 _rtl92ce_read_adapter_info(hw
);
1693 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
, ("Autoload ERR!!\n"));
1695 _rtl92ce_hal_customized_behavior(hw
);
1698 static void rtl92ce_update_hal_rate_table(struct ieee80211_hw
*hw
,
1699 struct ieee80211_sta
*sta
)
1701 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1702 struct rtl_pci_priv
*rtlpcipriv
= rtl_pcipriv(hw
);
1703 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
1704 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
1705 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
1708 u8 nmode
= mac
->ht_enable
;
1709 u8 mimo_ps
= IEEE80211_SMPS_OFF
;
1712 u8 curtxbw_40mhz
= mac
->bw_40
;
1713 u8 curshortgi_40mhz
= (sta
->ht_cap
.cap
& IEEE80211_HT_CAP_SGI_40
) ?
1715 u8 curshortgi_20mhz
= (sta
->ht_cap
.cap
& IEEE80211_HT_CAP_SGI_20
) ?
1717 enum wireless_mode wirelessmode
= mac
->mode
;
1719 if (rtlhal
->current_bandtype
== BAND_ON_5G
)
1720 ratr_value
= sta
->supp_rates
[1] << 4;
1722 ratr_value
= sta
->supp_rates
[0];
1723 ratr_value
|= (sta
->ht_cap
.mcs
.rx_mask
[1] << 20 |
1724 sta
->ht_cap
.mcs
.rx_mask
[0] << 12);
1725 switch (wirelessmode
) {
1726 case WIRELESS_MODE_B
:
1727 if (ratr_value
& 0x0000000c)
1728 ratr_value
&= 0x0000000d;
1730 ratr_value
&= 0x0000000f;
1732 case WIRELESS_MODE_G
:
1733 ratr_value
&= 0x00000FF5;
1735 case WIRELESS_MODE_N_24G
:
1736 case WIRELESS_MODE_N_5G
:
1738 if (mimo_ps
== IEEE80211_SMPS_STATIC
) {
1739 ratr_value
&= 0x0007F005;
1743 if (get_rf_type(rtlphy
) == RF_1T2R
||
1744 get_rf_type(rtlphy
) == RF_1T1R
)
1745 ratr_mask
= 0x000ff005;
1747 ratr_mask
= 0x0f0ff005;
1749 ratr_value
&= ratr_mask
;
1753 if (rtlphy
->rf_type
== RF_1T2R
)
1754 ratr_value
&= 0x000ff0ff;
1756 ratr_value
&= 0x0f0ff0ff;
1761 if ((rtlpcipriv
->bt_coexist
.bt_coexistence
) &&
1762 (rtlpcipriv
->bt_coexist
.bt_coexist_type
== BT_CSR_BC4
) &&
1763 (rtlpcipriv
->bt_coexist
.bt_cur_state
) &&
1764 (rtlpcipriv
->bt_coexist
.bt_ant_isolation
) &&
1765 ((rtlpcipriv
->bt_coexist
.bt_service
== BT_SCO
) ||
1766 (rtlpcipriv
->bt_coexist
.bt_service
== BT_BUSY
)))
1767 ratr_value
&= 0x0fffcfc0;
1769 ratr_value
&= 0x0FFFFFFF;
1771 if (nmode
&& ((curtxbw_40mhz
&&
1772 curshortgi_40mhz
) || (!curtxbw_40mhz
&&
1773 curshortgi_20mhz
))) {
1775 ratr_value
|= 0x10000000;
1776 tmp_ratr_value
= (ratr_value
>> 12);
1778 for (shortgi_rate
= 15; shortgi_rate
> 0; shortgi_rate
--) {
1779 if ((1 << shortgi_rate
) & tmp_ratr_value
)
1783 shortgi_rate
= (shortgi_rate
<< 12) | (shortgi_rate
<< 8) |
1784 (shortgi_rate
<< 4) | (shortgi_rate
);
1787 rtl_write_dword(rtlpriv
, REG_ARFR0
+ ratr_index
* 4, ratr_value
);
1789 RT_TRACE(rtlpriv
, COMP_RATR
, DBG_DMESG
,
1790 ("%x\n", rtl_read_dword(rtlpriv
, REG_ARFR0
)));
1793 static void rtl92ce_update_hal_rate_mask(struct ieee80211_hw
*hw
,
1794 struct ieee80211_sta
*sta
, u8 rssi_level
)
1796 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1797 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
1798 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
1799 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
1800 struct rtl_sta_info
*sta_entry
= NULL
;
1803 u8 curtxbw_40mhz
= (sta
->ht_cap
.cap
& IEEE80211_HT_CAP_SUP_WIDTH_20_40
)
1805 u8 curshortgi_40mhz
= (sta
->ht_cap
.cap
& IEEE80211_HT_CAP_SGI_40
) ?
1807 u8 curshortgi_20mhz
= (sta
->ht_cap
.cap
& IEEE80211_HT_CAP_SGI_20
) ?
1809 enum wireless_mode wirelessmode
= 0;
1810 bool shortgi
= false;
1813 u8 mimo_ps
= IEEE80211_SMPS_OFF
;
1815 sta_entry
= (struct rtl_sta_info
*) sta
->drv_priv
;
1816 wirelessmode
= sta_entry
->wireless_mode
;
1817 if (mac
->opmode
== NL80211_IFTYPE_STATION
)
1818 curtxbw_40mhz
= mac
->bw_40
;
1819 else if (mac
->opmode
== NL80211_IFTYPE_AP
||
1820 mac
->opmode
== NL80211_IFTYPE_ADHOC
)
1821 macid
= sta
->aid
+ 1;
1823 if (rtlhal
->current_bandtype
== BAND_ON_5G
)
1824 ratr_bitmap
= sta
->supp_rates
[1] << 4;
1826 ratr_bitmap
= sta
->supp_rates
[0];
1827 ratr_bitmap
|= (sta
->ht_cap
.mcs
.rx_mask
[1] << 20 |
1828 sta
->ht_cap
.mcs
.rx_mask
[0] << 12);
1829 switch (wirelessmode
) {
1830 case WIRELESS_MODE_B
:
1831 ratr_index
= RATR_INX_WIRELESS_B
;
1832 if (ratr_bitmap
& 0x0000000c)
1833 ratr_bitmap
&= 0x0000000d;
1835 ratr_bitmap
&= 0x0000000f;
1837 case WIRELESS_MODE_G
:
1838 ratr_index
= RATR_INX_WIRELESS_GB
;
1840 if (rssi_level
== 1)
1841 ratr_bitmap
&= 0x00000f00;
1842 else if (rssi_level
== 2)
1843 ratr_bitmap
&= 0x00000ff0;
1845 ratr_bitmap
&= 0x00000ff5;
1847 case WIRELESS_MODE_A
:
1848 ratr_index
= RATR_INX_WIRELESS_A
;
1849 ratr_bitmap
&= 0x00000ff0;
1851 case WIRELESS_MODE_N_24G
:
1852 case WIRELESS_MODE_N_5G
:
1853 ratr_index
= RATR_INX_WIRELESS_NGB
;
1855 if (mimo_ps
== IEEE80211_SMPS_STATIC
) {
1856 if (rssi_level
== 1)
1857 ratr_bitmap
&= 0x00070000;
1858 else if (rssi_level
== 2)
1859 ratr_bitmap
&= 0x0007f000;
1861 ratr_bitmap
&= 0x0007f005;
1863 if (rtlphy
->rf_type
== RF_1T2R
||
1864 rtlphy
->rf_type
== RF_1T1R
) {
1865 if (curtxbw_40mhz
) {
1866 if (rssi_level
== 1)
1867 ratr_bitmap
&= 0x000f0000;
1868 else if (rssi_level
== 2)
1869 ratr_bitmap
&= 0x000ff000;
1871 ratr_bitmap
&= 0x000ff015;
1873 if (rssi_level
== 1)
1874 ratr_bitmap
&= 0x000f0000;
1875 else if (rssi_level
== 2)
1876 ratr_bitmap
&= 0x000ff000;
1878 ratr_bitmap
&= 0x000ff005;
1881 if (curtxbw_40mhz
) {
1882 if (rssi_level
== 1)
1883 ratr_bitmap
&= 0x0f0f0000;
1884 else if (rssi_level
== 2)
1885 ratr_bitmap
&= 0x0f0ff000;
1887 ratr_bitmap
&= 0x0f0ff015;
1889 if (rssi_level
== 1)
1890 ratr_bitmap
&= 0x0f0f0000;
1891 else if (rssi_level
== 2)
1892 ratr_bitmap
&= 0x0f0ff000;
1894 ratr_bitmap
&= 0x0f0ff005;
1899 if ((curtxbw_40mhz
&& curshortgi_40mhz
) ||
1900 (!curtxbw_40mhz
&& curshortgi_20mhz
)) {
1904 else if (macid
== 1)
1909 ratr_index
= RATR_INX_WIRELESS_NGB
;
1911 if (rtlphy
->rf_type
== RF_1T2R
)
1912 ratr_bitmap
&= 0x000ff0ff;
1914 ratr_bitmap
&= 0x0f0ff0ff;
1917 RT_TRACE(rtlpriv
, COMP_RATR
, DBG_DMESG
,
1918 ("ratr_bitmap :%x\n", ratr_bitmap
));
1919 *(u32
*)&rate_mask
= EF4BYTE((ratr_bitmap
& 0x0fffffff) |
1920 (ratr_index
<< 28));
1921 rate_mask
[4] = macid
| (shortgi
? 0x20 : 0x00) | 0x80;
1922 RT_TRACE(rtlpriv
, COMP_RATR
, DBG_DMESG
, ("Rate_index:%x, "
1923 "ratr_val:%x, %x:%x:%x:%x:%x\n",
1924 ratr_index
, ratr_bitmap
,
1925 rate_mask
[0], rate_mask
[1],
1926 rate_mask
[2], rate_mask
[3],
1928 rtl92c_fill_h2c_cmd(hw
, H2C_RA_MASK
, 5, rate_mask
);
1931 sta_entry
->ratr_index
= ratr_index
;
1934 void rtl92ce_update_hal_rate_tbl(struct ieee80211_hw
*hw
,
1935 struct ieee80211_sta
*sta
, u8 rssi_level
)
1937 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1939 if (rtlpriv
->dm
.useramask
)
1940 rtl92ce_update_hal_rate_mask(hw
, sta
, rssi_level
);
1942 rtl92ce_update_hal_rate_table(hw
, sta
);
1945 void rtl92ce_update_channel_access_setting(struct ieee80211_hw
*hw
)
1947 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1948 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
1951 rtlpriv
->cfg
->ops
->set_hw_reg(hw
, HW_VAR_SLOT_TIME
,
1952 (u8
*)&mac
->slot_time
);
1953 if (!mac
->ht_enable
)
1954 sifs_timer
= 0x0a0a;
1956 sifs_timer
= 0x1010;
1957 rtlpriv
->cfg
->ops
->set_hw_reg(hw
, HW_VAR_SIFS
, (u8
*)&sifs_timer
);
1960 bool rtl92ce_gpio_radio_on_off_checking(struct ieee80211_hw
*hw
, u8
*valid
)
1962 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1963 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
1964 struct rtl_pci
*rtlpci
= rtl_pcidev(rtl_pcipriv(hw
));
1965 enum rf_pwrstate e_rfpowerstate_toset
;
1967 bool actuallyset
= false;
1970 if (rtlpci
->being_init_adapter
)
1973 if (ppsc
->swrf_processing
)
1976 spin_lock_irqsave(&rtlpriv
->locks
.rf_ps_lock
, flag
);
1977 if (ppsc
->rfchange_inprogress
) {
1978 spin_unlock_irqrestore(&rtlpriv
->locks
.rf_ps_lock
, flag
);
1981 ppsc
->rfchange_inprogress
= true;
1982 spin_unlock_irqrestore(&rtlpriv
->locks
.rf_ps_lock
, flag
);
1985 rtl_write_byte(rtlpriv
, REG_MAC_PINMUX_CFG
, rtl_read_byte(rtlpriv
,
1986 REG_MAC_PINMUX_CFG
)&~(BIT(3)));
1988 u1tmp
= rtl_read_byte(rtlpriv
, REG_GPIO_IO_SEL
);
1989 e_rfpowerstate_toset
= (u1tmp
& BIT(3)) ? ERFON
: ERFOFF
;
1991 if ((ppsc
->hwradiooff
) && (e_rfpowerstate_toset
== ERFON
)) {
1992 RT_TRACE(rtlpriv
, COMP_RF
, DBG_DMESG
,
1993 ("GPIOChangeRF - HW Radio ON, RF ON\n"));
1995 e_rfpowerstate_toset
= ERFON
;
1996 ppsc
->hwradiooff
= false;
1998 } else if ((ppsc
->hwradiooff
== false)
1999 && (e_rfpowerstate_toset
== ERFOFF
)) {
2000 RT_TRACE(rtlpriv
, COMP_RF
, DBG_DMESG
,
2001 ("GPIOChangeRF - HW Radio OFF, RF OFF\n"));
2003 e_rfpowerstate_toset
= ERFOFF
;
2004 ppsc
->hwradiooff
= true;
2009 spin_lock_irqsave(&rtlpriv
->locks
.rf_ps_lock
, flag
);
2010 ppsc
->rfchange_inprogress
= false;
2011 spin_unlock_irqrestore(&rtlpriv
->locks
.rf_ps_lock
, flag
);
2013 if (ppsc
->reg_rfps_level
& RT_RF_OFF_LEVL_HALT_NIC
)
2014 RT_SET_PS_LEVEL(ppsc
, RT_RF_OFF_LEVL_HALT_NIC
);
2016 spin_lock_irqsave(&rtlpriv
->locks
.rf_ps_lock
, flag
);
2017 ppsc
->rfchange_inprogress
= false;
2018 spin_unlock_irqrestore(&rtlpriv
->locks
.rf_ps_lock
, flag
);
2022 return !ppsc
->hwradiooff
;
2026 void rtl92ce_set_key(struct ieee80211_hw
*hw
, u32 key_index
,
2027 u8
*p_macaddr
, bool is_group
, u8 enc_algo
,
2028 bool is_wepkey
, bool clear_all
)
2030 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
2031 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
2032 struct rtl_efuse
*rtlefuse
= rtl_efuse(rtl_priv(hw
));
2033 u8
*macaddr
= p_macaddr
;
2035 bool is_pairwise
= false;
2037 static u8 cam_const_addr
[4][6] = {
2038 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
2039 {0x00, 0x00, 0x00, 0x00, 0x00, 0x01},
2040 {0x00, 0x00, 0x00, 0x00, 0x00, 0x02},
2041 {0x00, 0x00, 0x00, 0x00, 0x00, 0x03}
2043 static u8 cam_const_broad
[] = {
2044 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
2050 u8 clear_number
= 5;
2052 RT_TRACE(rtlpriv
, COMP_SEC
, DBG_DMESG
, ("clear_all\n"));
2054 for (idx
= 0; idx
< clear_number
; idx
++) {
2055 rtl_cam_mark_invalid(hw
, cam_offset
+ idx
);
2056 rtl_cam_empty_entry(hw
, cam_offset
+ idx
);
2059 memset(rtlpriv
->sec
.key_buf
[idx
], 0,
2061 rtlpriv
->sec
.key_len
[idx
] = 0;
2067 case WEP40_ENCRYPTION
:
2068 enc_algo
= CAM_WEP40
;
2070 case WEP104_ENCRYPTION
:
2071 enc_algo
= CAM_WEP104
;
2073 case TKIP_ENCRYPTION
:
2074 enc_algo
= CAM_TKIP
;
2076 case AESCCMP_ENCRYPTION
:
2080 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
, ("switch case "
2082 enc_algo
= CAM_TKIP
;
2086 if (is_wepkey
|| rtlpriv
->sec
.use_defaultkey
) {
2087 macaddr
= cam_const_addr
[key_index
];
2088 entry_id
= key_index
;
2091 macaddr
= cam_const_broad
;
2092 entry_id
= key_index
;
2094 if (mac
->opmode
== NL80211_IFTYPE_AP
) {
2095 entry_id
= rtl_cam_get_free_entry(hw
,
2097 if (entry_id
>= TOTAL_CAM_ENTRY
) {
2098 RT_TRACE(rtlpriv
, COMP_SEC
,
2100 ("Can not find free hw"
2101 " security cam entry\n"));
2105 entry_id
= CAM_PAIRWISE_KEY_POSITION
;
2108 key_index
= PAIRWISE_KEYIDX
;
2113 if (rtlpriv
->sec
.key_len
[key_index
] == 0) {
2114 RT_TRACE(rtlpriv
, COMP_SEC
, DBG_DMESG
,
2115 ("delete one entry, entry_id is %d\n",
2117 if (mac
->opmode
== NL80211_IFTYPE_AP
)
2118 rtl_cam_del_entry(hw
, p_macaddr
);
2119 rtl_cam_delete_one_entry(hw
, p_macaddr
, entry_id
);
2121 RT_TRACE(rtlpriv
, COMP_SEC
, DBG_LOUD
,
2122 ("The insert KEY length is %d\n",
2123 rtlpriv
->sec
.key_len
[PAIRWISE_KEYIDX
]));
2124 RT_TRACE(rtlpriv
, COMP_SEC
, DBG_LOUD
,
2125 ("The insert KEY is %x %x\n",
2126 rtlpriv
->sec
.key_buf
[0][0],
2127 rtlpriv
->sec
.key_buf
[0][1]));
2129 RT_TRACE(rtlpriv
, COMP_SEC
, DBG_DMESG
,
2130 ("add one entry\n"));
2132 RT_PRINT_DATA(rtlpriv
, COMP_SEC
, DBG_LOUD
,
2133 "Pairwiase Key content :",
2134 rtlpriv
->sec
.pairwise_key
,
2136 key_len
[PAIRWISE_KEYIDX
]);
2138 RT_TRACE(rtlpriv
, COMP_SEC
, DBG_DMESG
,
2139 ("set Pairwiase key\n"));
2141 rtl_cam_add_one_entry(hw
, macaddr
, key_index
,
2143 CAM_CONFIG_NO_USEDK
,
2145 key_buf
[key_index
]);
2147 RT_TRACE(rtlpriv
, COMP_SEC
, DBG_DMESG
,
2148 ("set group key\n"));
2150 if (mac
->opmode
== NL80211_IFTYPE_ADHOC
) {
2151 rtl_cam_add_one_entry(hw
,
2154 CAM_PAIRWISE_KEY_POSITION
,
2156 CAM_CONFIG_NO_USEDK
,
2157 rtlpriv
->sec
.key_buf
2161 rtl_cam_add_one_entry(hw
, macaddr
, key_index
,
2163 CAM_CONFIG_NO_USEDK
,
2164 rtlpriv
->sec
.key_buf
[entry_id
]);
2171 static void rtl8192ce_bt_var_init(struct ieee80211_hw
*hw
)
2173 struct rtl_pci_priv
*rtlpcipriv
= rtl_pcipriv(hw
);
2175 rtlpcipriv
->bt_coexist
.bt_coexistence
=
2176 rtlpcipriv
->bt_coexist
.eeprom_bt_coexist
;
2177 rtlpcipriv
->bt_coexist
.bt_ant_num
=
2178 rtlpcipriv
->bt_coexist
.eeprom_bt_ant_num
;
2179 rtlpcipriv
->bt_coexist
.bt_coexist_type
=
2180 rtlpcipriv
->bt_coexist
.eeprom_bt_type
;
2182 if (rtlpcipriv
->bt_coexist
.reg_bt_iso
== 2)
2183 rtlpcipriv
->bt_coexist
.bt_ant_isolation
=
2184 rtlpcipriv
->bt_coexist
.eeprom_bt_ant_isolation
;
2186 rtlpcipriv
->bt_coexist
.bt_ant_isolation
=
2187 rtlpcipriv
->bt_coexist
.reg_bt_iso
;
2189 rtlpcipriv
->bt_coexist
.bt_radio_shared_type
=
2190 rtlpcipriv
->bt_coexist
.eeprom_bt_radio_shared
;
2192 if (rtlpcipriv
->bt_coexist
.bt_coexistence
) {
2194 if (rtlpcipriv
->bt_coexist
.reg_bt_sco
== 1)
2195 rtlpcipriv
->bt_coexist
.bt_service
= BT_OTHER_ACTION
;
2196 else if (rtlpcipriv
->bt_coexist
.reg_bt_sco
== 2)
2197 rtlpcipriv
->bt_coexist
.bt_service
= BT_SCO
;
2198 else if (rtlpcipriv
->bt_coexist
.reg_bt_sco
== 4)
2199 rtlpcipriv
->bt_coexist
.bt_service
= BT_BUSY
;
2200 else if (rtlpcipriv
->bt_coexist
.reg_bt_sco
== 5)
2201 rtlpcipriv
->bt_coexist
.bt_service
= BT_OTHERBUSY
;
2203 rtlpcipriv
->bt_coexist
.bt_service
= BT_IDLE
;
2205 rtlpcipriv
->bt_coexist
.bt_edca_ul
= 0;
2206 rtlpcipriv
->bt_coexist
.bt_edca_dl
= 0;
2207 rtlpcipriv
->bt_coexist
.bt_rssi_state
= 0xff;
2211 void rtl8192ce_read_bt_coexist_info_from_hwpg(struct ieee80211_hw
*hw
,
2212 bool auto_load_fail
, u8
*hwinfo
)
2214 struct rtl_pci_priv
*rtlpcipriv
= rtl_pcipriv(hw
);
2217 if (!auto_load_fail
) {
2218 rtlpcipriv
->bt_coexist
.eeprom_bt_coexist
=
2219 ((hwinfo
[RF_OPTION1
] & 0xe0) >> 5);
2220 value
= hwinfo
[RF_OPTION4
];
2221 rtlpcipriv
->bt_coexist
.eeprom_bt_type
= ((value
& 0xe) >> 1);
2222 rtlpcipriv
->bt_coexist
.eeprom_bt_ant_num
= (value
& 0x1);
2223 rtlpcipriv
->bt_coexist
.eeprom_bt_ant_isolation
=
2224 ((value
& 0x10) >> 4);
2225 rtlpcipriv
->bt_coexist
.eeprom_bt_radio_shared
=
2226 ((value
& 0x20) >> 5);
2228 rtlpcipriv
->bt_coexist
.eeprom_bt_coexist
= 0;
2229 rtlpcipriv
->bt_coexist
.eeprom_bt_type
= BT_2WIRE
;
2230 rtlpcipriv
->bt_coexist
.eeprom_bt_ant_num
= ANT_X2
;
2231 rtlpcipriv
->bt_coexist
.eeprom_bt_ant_isolation
= 0;
2232 rtlpcipriv
->bt_coexist
.eeprom_bt_radio_shared
= BT_RADIO_SHARED
;
2235 rtl8192ce_bt_var_init(hw
);
2238 void rtl8192ce_bt_reg_init(struct ieee80211_hw
*hw
)
2240 struct rtl_pci_priv
*rtlpcipriv
= rtl_pcipriv(hw
);
2242 /* 0:Low, 1:High, 2:From Efuse. */
2243 rtlpcipriv
->bt_coexist
.reg_bt_iso
= 2;
2244 /* 0:Idle, 1:None-SCO, 2:SCO, 3:From Counter. */
2245 rtlpcipriv
->bt_coexist
.reg_bt_sco
= 3;
2246 /* 0:Disable BT control A-MPDU, 1:Enable BT control A-MPDU. */
2247 rtlpcipriv
->bt_coexist
.reg_bt_sco
= 0;
2251 void rtl8192ce_bt_hw_init(struct ieee80211_hw
*hw
)
2253 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
2254 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
2255 struct rtl_pci_priv
*rtlpcipriv
= rtl_pcipriv(hw
);
2259 if (rtlpcipriv
->bt_coexist
.bt_coexistence
&&
2260 ((rtlpcipriv
->bt_coexist
.bt_coexist_type
== BT_CSR_BC4
) ||
2261 rtlpcipriv
->bt_coexist
.bt_coexist_type
== BT_CSR_BC8
)) {
2263 if (rtlpcipriv
->bt_coexist
.bt_ant_isolation
)
2264 rtl_write_byte(rtlpriv
, REG_GPIO_MUXCFG
, 0xa0);
2266 u1_tmp
= rtl_read_byte(rtlpriv
, 0x4fd) &
2267 BIT_OFFSET_LEN_MASK_32(0, 1);
2269 ((rtlpcipriv
->bt_coexist
.bt_ant_isolation
== 1) ?
2270 0 : BIT_OFFSET_LEN_MASK_32(1, 1)) |
2271 ((rtlpcipriv
->bt_coexist
.bt_service
== BT_SCO
) ?
2272 0 : BIT_OFFSET_LEN_MASK_32(2, 1));
2273 rtl_write_byte(rtlpriv
, 0x4fd, u1_tmp
);
2275 rtl_write_dword(rtlpriv
, REG_BT_COEX_TABLE
+4, 0xaaaa9aaa);
2276 rtl_write_dword(rtlpriv
, REG_BT_COEX_TABLE
+8, 0xffbd0040);
2277 rtl_write_dword(rtlpriv
, REG_BT_COEX_TABLE
+0xc, 0x40000010);
2279 /* Config to 1T1R. */
2280 if (rtlphy
->rf_type
== RF_1T1R
) {
2281 u1_tmp
= rtl_read_byte(rtlpriv
, ROFDM0_TRXPATHENABLE
);
2282 u1_tmp
&= ~(BIT_OFFSET_LEN_MASK_32(1, 1));
2283 rtl_write_byte(rtlpriv
, ROFDM0_TRXPATHENABLE
, u1_tmp
);
2285 u1_tmp
= rtl_read_byte(rtlpriv
, ROFDM1_TRXPATHENABLE
);
2286 u1_tmp
&= ~(BIT_OFFSET_LEN_MASK_32(1, 1));
2287 rtl_write_byte(rtlpriv
, ROFDM1_TRXPATHENABLE
, u1_tmp
);
2292 void rtl92ce_suspend(struct ieee80211_hw
*hw
)
2296 void rtl92ce_resume(struct ieee80211_hw
*hw
)