blob: dd383b1482e926367fe045fca6f1ca832ca54b9e [file] [log] [blame]
Larry Fingerc592e632012-10-25 13:46:32 -05001/******************************************************************************
2 *
3 * Copyright(c) 2009-2012 Realtek Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * 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
17 *
18 * The full GNU General Public License is included in this distribution in the
19 * file called LICENSE.
20 *
21 * Contact Information:
22 * wlanfae <wlanfae@realtek.com>
23 * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
24 * Hsinchu 300, Taiwan.
25 *
26 * Larry Finger <Larry.Finger@lwfinger.net>
27 *
28 *****************************************************************************/
29
30#include "../wifi.h"
31#include "../efuse.h"
32#include "../base.h"
33#include "../regd.h"
34#include "../cam.h"
35#include "../ps.h"
36#include "../pci.h"
37#include "reg.h"
38#include "def.h"
39#include "phy.h"
40#include "dm.h"
Larry Finger57d9d9632014-02-28 15:16:49 -060041#include "../rtl8723com/dm_common.h"
Larry Fingerc592e632012-10-25 13:46:32 -050042#include "fw.h"
Larry Fingercbd0c852014-02-28 15:16:48 -060043#include "../rtl8723com/fw_common.h"
Larry Fingerc592e632012-10-25 13:46:32 -050044#include "led.h"
45#include "hw.h"
Larry Fingerc592e632012-10-25 13:46:32 -050046#include "pwrseq.h"
47#include "btc.h"
48
49static void _rtl8723ae_set_bcn_ctrl_reg(struct ieee80211_hw *hw,
50 u8 set_bits, u8 clear_bits)
51{
52 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
53 struct rtl_priv *rtlpriv = rtl_priv(hw);
54
55 rtlpci->reg_bcn_ctrl_val |= set_bits;
56 rtlpci->reg_bcn_ctrl_val &= ~clear_bits;
57
58 rtl_write_byte(rtlpriv, REG_BCN_CTRL, (u8) rtlpci->reg_bcn_ctrl_val);
59}
60
61static void _rtl8723ae_stop_tx_beacon(struct ieee80211_hw *hw)
62{
63 struct rtl_priv *rtlpriv = rtl_priv(hw);
64 u8 tmp1byte;
65
66 tmp1byte = rtl_read_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2);
67 rtl_write_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2, tmp1byte & (~BIT(6)));
68 rtl_write_byte(rtlpriv, REG_TBTT_PROHIBIT + 1, 0x64);
69 tmp1byte = rtl_read_byte(rtlpriv, REG_TBTT_PROHIBIT + 2);
70 tmp1byte &= ~(BIT(0));
71 rtl_write_byte(rtlpriv, REG_TBTT_PROHIBIT + 2, tmp1byte);
72}
73
74static void _rtl8723ae_resume_tx_beacon(struct ieee80211_hw *hw)
75{
76 struct rtl_priv *rtlpriv = rtl_priv(hw);
77 u8 tmp1byte;
78
79 tmp1byte = rtl_read_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2);
80 rtl_write_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2, tmp1byte | BIT(6));
81 rtl_write_byte(rtlpriv, REG_TBTT_PROHIBIT + 1, 0xff);
82 tmp1byte = rtl_read_byte(rtlpriv, REG_TBTT_PROHIBIT + 2);
83 tmp1byte |= BIT(1);
84 rtl_write_byte(rtlpriv, REG_TBTT_PROHIBIT + 2, tmp1byte);
85}
86
87static void _rtl8723ae_enable_bcn_sufunc(struct ieee80211_hw *hw)
88{
89 _rtl8723ae_set_bcn_ctrl_reg(hw, 0, BIT(1));
90}
91
92static void _rtl8723ae_disable_bcn_sufunc(struct ieee80211_hw *hw)
93{
94 _rtl8723ae_set_bcn_ctrl_reg(hw, BIT(1), 0);
95}
96
97void rtl8723ae_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
98{
99 struct rtl_priv *rtlpriv = rtl_priv(hw);
100 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
101 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
102
103 switch (variable) {
104 case HW_VAR_RCR:
105 *((u32 *) (val)) = rtlpci->receive_config;
106 break;
107 case HW_VAR_RF_STATE:
108 *((enum rf_pwrstate *)(val)) = ppsc->rfpwr_state;
109 break;
110 case HW_VAR_FWLPS_RF_ON:{
111 enum rf_pwrstate rfState;
112 u32 val_rcr;
113
114 rtlpriv->cfg->ops->get_hw_reg(hw,
115 HW_VAR_RF_STATE,
116 (u8 *) (&rfState));
117 if (rfState == ERFOFF) {
118 *((bool *) (val)) = true;
119 } else {
120 val_rcr = rtl_read_dword(rtlpriv, REG_RCR);
121 val_rcr &= 0x00070000;
122 if (val_rcr)
123 *((bool *) (val)) = false;
124 else
125 *((bool *) (val)) = true;
126 }
127 break; }
128 case HW_VAR_FW_PSMODE_STATUS:
129 *((bool *) (val)) = ppsc->fw_current_inpsmode;
130 break;
131 case HW_VAR_CORRECT_TSF:{
132 u64 tsf;
133 u32 *ptsf_low = (u32 *)&tsf;
134 u32 *ptsf_high = ((u32 *)&tsf) + 1;
135
136 *ptsf_high = rtl_read_dword(rtlpriv, (REG_TSFTR + 4));
137 *ptsf_low = rtl_read_dword(rtlpriv, REG_TSFTR);
138
139 *((u64 *) (val)) = tsf;
140
141 break; }
142 default:
143 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
144 "switch case not process\n");
145 break;
146 }
147}
148
149void rtl8723ae_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
150{
151 struct rtl_priv *rtlpriv = rtl_priv(hw);
152 struct rtl_pci_priv *pcipriv = 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_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
156 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
157 u8 idx;
158
159 switch (variable) {
160 case HW_VAR_ETHER_ADDR:
161 for (idx = 0; idx < ETH_ALEN; idx++) {
162 rtl_write_byte(rtlpriv, (REG_MACID + idx),
163 val[idx]);
164 }
165 break;
166 case HW_VAR_BASIC_RATE:{
167 u16 rate_cfg = ((u16 *) val)[0];
168 u8 rate_index = 0;
169 rate_cfg = rate_cfg & 0x15f;
170 rate_cfg |= 0x01;
171 rtl_write_byte(rtlpriv, REG_RRSR, rate_cfg & 0xff);
172 rtl_write_byte(rtlpriv, REG_RRSR + 1,
173 (rate_cfg >> 8) & 0xff);
174 while (rate_cfg > 0x1) {
175 rate_cfg = (rate_cfg >> 1);
176 rate_index++;
177 }
178 rtl_write_byte(rtlpriv, REG_INIRTS_RATE_SEL,
179 rate_index);
180 break; }
181 case HW_VAR_BSSID:
182 for (idx = 0; idx < ETH_ALEN; idx++) {
183 rtl_write_byte(rtlpriv, (REG_BSSID + idx),
184 val[idx]);
185 }
186 break;
187 case HW_VAR_SIFS:
188 rtl_write_byte(rtlpriv, REG_SIFS_CTX + 1, val[0]);
189 rtl_write_byte(rtlpriv, REG_SIFS_TRX + 1, val[1]);
190
191 rtl_write_byte(rtlpriv, REG_SPEC_SIFS + 1, val[0]);
192 rtl_write_byte(rtlpriv, REG_MAC_SPEC_SIFS + 1, val[0]);
193
194 if (!mac->ht_enable)
195 rtl_write_word(rtlpriv, REG_RESP_SIFS_OFDM,
196 0x0e0e);
197 else
198 rtl_write_word(rtlpriv, REG_RESP_SIFS_OFDM,
199 *((u16 *) val));
200 break;
201 case HW_VAR_SLOT_TIME:{
202 u8 e_aci;
203
204 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD,
205 "HW_VAR_SLOT_TIME %x\n", val[0]);
206
207 rtl_write_byte(rtlpriv, REG_SLOT, val[0]);
208
209 for (e_aci = 0; e_aci < AC_MAX; e_aci++) {
210 rtlpriv->cfg->ops->set_hw_reg(hw,
211 HW_VAR_AC_PARAM,
212 (u8 *) (&e_aci));
213 }
214 break; }
215 case HW_VAR_ACK_PREAMBLE:{
216 u8 reg_tmp;
217 u8 short_preamble = (bool) (*(u8 *) val);
218 reg_tmp = (mac->cur_40_prime_sc) << 5;
219 if (short_preamble)
220 reg_tmp |= 0x80;
221
222 rtl_write_byte(rtlpriv, REG_RRSR + 2, reg_tmp);
223 break; }
224 case HW_VAR_AMPDU_MIN_SPACE:{
225 u8 min_spacing_to_set;
226 u8 sec_min_space;
227
228 min_spacing_to_set = *((u8 *) val);
229 if (min_spacing_to_set <= 7) {
230 sec_min_space = 0;
231
232 if (min_spacing_to_set < sec_min_space)
233 min_spacing_to_set = sec_min_space;
234
235 mac->min_space_cfg = ((mac->min_space_cfg &
236 0xf8) |
237 min_spacing_to_set);
238
239 *val = min_spacing_to_set;
240
241 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD,
242 "Set HW_VAR_AMPDU_MIN_SPACE: %#x\n",
243 mac->min_space_cfg);
244
245 rtl_write_byte(rtlpriv, REG_AMPDU_MIN_SPACE,
246 mac->min_space_cfg);
247 }
248 break; }
249 case HW_VAR_SHORTGI_DENSITY:{
250 u8 density_to_set;
251
252 density_to_set = *((u8 *) val);
253 mac->min_space_cfg |= (density_to_set << 3);
254
255 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD,
256 "Set HW_VAR_SHORTGI_DENSITY: %#x\n",
257 mac->min_space_cfg);
258
259 rtl_write_byte(rtlpriv, REG_AMPDU_MIN_SPACE,
260 mac->min_space_cfg);
261
262 break; }
263 case HW_VAR_AMPDU_FACTOR:{
264 u8 regtoset_normal[4] = {0x41, 0xa8, 0x72, 0xb9};
265 u8 regtoset_bt[4] = {0x31, 0x74, 0x42, 0x97};
266 u8 factor_toset;
267 u8 *p_regtoset = NULL;
268 u8 index;
269
270 if ((pcipriv->bt_coexist.bt_coexistence) &&
271 (pcipriv->bt_coexist.bt_coexist_type == BT_CSR_BC4))
272 p_regtoset = regtoset_bt;
273 else
274 p_regtoset = regtoset_normal;
275
276 factor_toset = *((u8 *) val);
277 if (factor_toset <= 3) {
278 factor_toset = (1 << (factor_toset + 2));
279 if (factor_toset > 0xf)
280 factor_toset = 0xf;
281
282 for (index = 0; index < 4; index++) {
283 if ((p_regtoset[index] & 0xf0) >
284 (factor_toset << 4))
285 p_regtoset[index] =
286 (p_regtoset[index] & 0x0f) |
287 (factor_toset << 4);
288
289 if ((p_regtoset[index] & 0x0f) >
290 factor_toset)
291 p_regtoset[index] =
292 (p_regtoset[index] & 0xf0) |
293 (factor_toset);
294
295 rtl_write_byte(rtlpriv,
296 (REG_AGGLEN_LMT + index),
297 p_regtoset[index]);
298
299 }
300
301 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD,
302 "Set HW_VAR_AMPDU_FACTOR: %#x\n",
303 factor_toset);
304 }
305 break; }
306 case HW_VAR_AC_PARAM:{
307 u8 e_aci = *((u8 *) val);
Larry Finger57d9d9632014-02-28 15:16:49 -0600308 rtl8723_dm_init_edca_turbo(hw);
Larry Fingerc592e632012-10-25 13:46:32 -0500309
Larry Finger2cddad32014-02-28 15:16:46 -0600310 if (rtlpci->acm_method != EACMWAY2_SW)
Larry Fingerc592e632012-10-25 13:46:32 -0500311 rtlpriv->cfg->ops->set_hw_reg(hw,
312 HW_VAR_ACM_CTRL,
313 (u8 *) (&e_aci));
314 break; }
315 case HW_VAR_ACM_CTRL:{
316 u8 e_aci = *((u8 *) val);
317 union aci_aifsn *p_aci_aifsn =
318 (union aci_aifsn *)(&(mac->ac[0].aifs));
319 u8 acm = p_aci_aifsn->f.acm;
320 u8 acm_ctrl = rtl_read_byte(rtlpriv, REG_ACMHWCTRL);
321
322 acm_ctrl |= ((rtlpci->acm_method == 2) ? 0x0 : 0x1);
323
324 if (acm) {
325 switch (e_aci) {
326 case AC0_BE:
327 acm_ctrl |= AcmHw_BeqEn;
328 break;
329 case AC2_VI:
330 acm_ctrl |= AcmHw_ViqEn;
331 break;
332 case AC3_VO:
333 acm_ctrl |= AcmHw_VoqEn;
334 break;
335 default:
336 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
337 "HW_VAR_ACM_CTRL acm set failed: eACI is %d\n",
338 acm);
339 break;
340 }
341 } else {
342 switch (e_aci) {
343 case AC0_BE:
344 acm_ctrl &= (~AcmHw_BeqEn);
345 break;
346 case AC2_VI:
347 acm_ctrl &= (~AcmHw_ViqEn);
348 break;
349 case AC3_VO:
350 acm_ctrl &= (~AcmHw_BeqEn);
351 break;
352 default:
353 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
354 "switch case not processed\n");
355 break;
356 }
357 }
358
359 RT_TRACE(rtlpriv, COMP_QOS, DBG_TRACE,
360 "SetHwReg8190pci(): [HW_VAR_ACM_CTRL] Write 0x%X\n",
361 acm_ctrl);
362 rtl_write_byte(rtlpriv, REG_ACMHWCTRL, acm_ctrl);
363 break; }
364 case HW_VAR_RCR:
365 rtl_write_dword(rtlpriv, REG_RCR, ((u32 *) (val))[0]);
366 rtlpci->receive_config = ((u32 *) (val))[0];
367 break;
368 case HW_VAR_RETRY_LIMIT:{
369 u8 retry_limit = ((u8 *) (val))[0];
370
371 rtl_write_word(rtlpriv, REG_RL,
372 retry_limit << RETRY_LIMIT_SHORT_SHIFT |
373 retry_limit << RETRY_LIMIT_LONG_SHIFT);
374 break; }
375 case HW_VAR_DUAL_TSF_RST:
376 rtl_write_byte(rtlpriv, REG_DUAL_TSF_RST, (BIT(0) | BIT(1)));
377 break;
378 case HW_VAR_EFUSE_BYTES:
379 rtlefuse->efuse_usedbytes = *((u16 *) val);
380 break;
381 case HW_VAR_EFUSE_USAGE:
382 rtlefuse->efuse_usedpercentage = *((u8 *) val);
383 break;
384 case HW_VAR_IO_CMD:
385 rtl8723ae_phy_set_io_cmd(hw, (*(enum io_type *)val));
386 break;
387 case HW_VAR_WPA_CONFIG:
388 rtl_write_byte(rtlpriv, REG_SECCFG, *((u8 *) val));
389 break;
390 case HW_VAR_SET_RPWM:{
391 u8 rpwm_val;
392
393 rpwm_val = rtl_read_byte(rtlpriv, REG_PCIE_HRPWM);
394 udelay(1);
395
396 if (rpwm_val & BIT(7)) {
397 rtl_write_byte(rtlpriv, REG_PCIE_HRPWM,
398 (*(u8 *) val));
399 } else {
400 rtl_write_byte(rtlpriv, REG_PCIE_HRPWM,
401 ((*(u8 *) val) | BIT(7)));
402 }
403
404 break; }
405 case HW_VAR_H2C_FW_PWRMODE:{
406 u8 psmode = (*(u8 *) val);
407
408 if (psmode != FW_PS_ACTIVE_MODE)
409 rtl8723ae_dm_rf_saving(hw, true);
410
411 rtl8723ae_set_fw_pwrmode_cmd(hw, (*(u8 *) val));
412 break; }
413 case HW_VAR_FW_PSMODE_STATUS:
414 ppsc->fw_current_inpsmode = *((bool *) val);
415 break;
416 case HW_VAR_H2C_FW_JOINBSSRPT:{
417 u8 mstatus = (*(u8 *) val);
418 u8 tmp_regcr, tmp_reg422;
419 bool recover = false;
420
421 if (mstatus == RT_MEDIA_CONNECT) {
422 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_AID, NULL);
423
424 tmp_regcr = rtl_read_byte(rtlpriv, REG_CR + 1);
425 rtl_write_byte(rtlpriv, REG_CR + 1,
426 (tmp_regcr | BIT(0)));
427
428 _rtl8723ae_set_bcn_ctrl_reg(hw, 0, BIT(3));
429 _rtl8723ae_set_bcn_ctrl_reg(hw, BIT(4), 0);
430
431 tmp_reg422 = rtl_read_byte(rtlpriv,
432 REG_FWHW_TXQ_CTRL + 2);
433 if (tmp_reg422 & BIT(6))
434 recover = true;
435 rtl_write_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2,
436 tmp_reg422 & (~BIT(6)));
437
438 rtl8723ae_set_fw_rsvdpagepkt(hw, 0);
439
440 _rtl8723ae_set_bcn_ctrl_reg(hw, BIT(3), 0);
441 _rtl8723ae_set_bcn_ctrl_reg(hw, 0, BIT(4));
442
443 if (recover)
444 rtl_write_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2,
445 tmp_reg422);
446
447 rtl_write_byte(rtlpriv, REG_CR + 1,
448 (tmp_regcr & ~(BIT(0))));
449 }
450 rtl8723ae_set_fw_joinbss_report_cmd(hw, (*(u8 *) val));
451
452 break; }
Larry Finger4b04edc2013-03-24 22:06:39 -0500453 case HW_VAR_H2C_FW_P2P_PS_OFFLOAD:
454 rtl8723ae_set_p2p_ps_offload_cmd(hw, (*(u8 *)val));
455 break;
Larry Fingerc592e632012-10-25 13:46:32 -0500456 case HW_VAR_AID:{
457 u16 u2btmp;
458 u2btmp = rtl_read_word(rtlpriv, REG_BCN_PSR_RPT);
459 u2btmp &= 0xC000;
460 rtl_write_word(rtlpriv, REG_BCN_PSR_RPT, (u2btmp |
461 mac->assoc_id));
462 break; }
463 case HW_VAR_CORRECT_TSF:{
464 u8 btype_ibss = ((u8 *) (val))[0];
465
466 if (btype_ibss == true)
467 _rtl8723ae_stop_tx_beacon(hw);
468
469 _rtl8723ae_set_bcn_ctrl_reg(hw, 0, BIT(3));
470
471 rtl_write_dword(rtlpriv, REG_TSFTR,
472 (u32) (mac->tsf & 0xffffffff));
473 rtl_write_dword(rtlpriv, REG_TSFTR + 4,
474 (u32) ((mac->tsf >> 32) & 0xffffffff));
475
476 _rtl8723ae_set_bcn_ctrl_reg(hw, BIT(3), 0);
477
478 if (btype_ibss == true)
479 _rtl8723ae_resume_tx_beacon(hw);
480 break; }
Larry Finger4b04edc2013-03-24 22:06:39 -0500481 case HW_VAR_FW_LPS_ACTION: {
482 bool enter_fwlps = *((bool *)val);
483 u8 rpwm_val, fw_pwrmode;
484 bool fw_current_inps;
485
486 if (enter_fwlps) {
487 rpwm_val = 0x02; /* RF off */
488 fw_current_inps = true;
489 rtlpriv->cfg->ops->set_hw_reg(hw,
490 HW_VAR_FW_PSMODE_STATUS,
491 (u8 *)(&fw_current_inps));
492 rtlpriv->cfg->ops->set_hw_reg(hw,
493 HW_VAR_H2C_FW_PWRMODE,
494 (u8 *)(&ppsc->fwctrl_psmode));
495
496 rtlpriv->cfg->ops->set_hw_reg(hw,
497 HW_VAR_SET_RPWM,
498 (u8 *)(&rpwm_val));
499 } else {
500 rpwm_val = 0x0C; /* RF on */
501 fw_pwrmode = FW_PS_ACTIVE_MODE;
502 fw_current_inps = false;
503 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SET_RPWM,
504 (u8 *)(&rpwm_val));
505 rtlpriv->cfg->ops->set_hw_reg(hw,
506 HW_VAR_H2C_FW_PWRMODE,
507 (u8 *)(&fw_pwrmode));
508
509 rtlpriv->cfg->ops->set_hw_reg(hw,
510 HW_VAR_FW_PSMODE_STATUS,
511 (u8 *)(&fw_current_inps));
512 }
513 break; }
Larry Fingerc592e632012-10-25 13:46:32 -0500514 default:
515 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
516 "switch case not processed\n");
517 break;
518 }
519}
520
521static bool _rtl8723ae_llt_write(struct ieee80211_hw *hw, u32 address, u32 data)
522{
523 struct rtl_priv *rtlpriv = rtl_priv(hw);
524 bool status = true;
525 long count = 0;
526 u32 value = _LLT_INIT_ADDR(address) |
527 _LLT_INIT_DATA(data) | _LLT_OP(_LLT_WRITE_ACCESS);
528
529 rtl_write_dword(rtlpriv, REG_LLT_INIT, value);
530
531 do {
532 value = rtl_read_dword(rtlpriv, REG_LLT_INIT);
533 if (_LLT_NO_ACTIVE == _LLT_OP_VALUE(value))
534 break;
535
536 if (count > POLLING_LLT_THRESHOLD) {
537 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
538 "Failed to polling write LLT done at address %d!\n",
539 address);
540 status = false;
541 break;
542 }
543 } while (++count);
544
545 return status;
546}
547
548static bool _rtl8723ae_llt_table_init(struct ieee80211_hw *hw)
549{
550 struct rtl_priv *rtlpriv = rtl_priv(hw);
551 unsigned short i;
552 u8 txpktbuf_bndy;
553 u8 maxPage;
554 bool status;
555 u8 ubyte;
556
557 maxPage = 255;
558 txpktbuf_bndy = 246;
559
560 rtl_write_byte(rtlpriv, REG_CR, 0x8B);
561
562 rtl_write_word(rtlpriv, REG_RQPN_NPQ, 0x0000);
563
564 rtl_write_dword(rtlpriv, REG_RQPN, 0x80ac1c29);
565 rtl_write_byte(rtlpriv, REG_RQPN_NPQ, 0x03);
566
567 rtl_write_dword(rtlpriv, REG_TRXFF_BNDY, (0x27FF0000 | txpktbuf_bndy));
568 rtl_write_byte(rtlpriv, REG_TDECTRL + 1, txpktbuf_bndy);
569
570 rtl_write_byte(rtlpriv, REG_TXPKTBUF_BCNQ_BDNY, txpktbuf_bndy);
571 rtl_write_byte(rtlpriv, REG_TXPKTBUF_MGQ_BDNY, txpktbuf_bndy);
572
573 rtl_write_byte(rtlpriv, 0x45D, txpktbuf_bndy);
574 rtl_write_byte(rtlpriv, REG_PBP, 0x11);
575 rtl_write_byte(rtlpriv, REG_RX_DRVINFO_SZ, 0x4);
576
577 for (i = 0; i < (txpktbuf_bndy - 1); i++) {
578 status = _rtl8723ae_llt_write(hw, i, i + 1);
579 if (true != status)
580 return status;
581 }
582
583 status = _rtl8723ae_llt_write(hw, (txpktbuf_bndy - 1), 0xFF);
584 if (true != status)
585 return status;
586
587 for (i = txpktbuf_bndy; i < maxPage; i++) {
588 status = _rtl8723ae_llt_write(hw, i, (i + 1));
589 if (true != status)
590 return status;
591 }
592
593 status = _rtl8723ae_llt_write(hw, maxPage, txpktbuf_bndy);
594 if (true != status)
595 return status;
596
597 rtl_write_byte(rtlpriv, REG_CR, 0xff);
598 ubyte = rtl_read_byte(rtlpriv, REG_RQPN + 3);
599 rtl_write_byte(rtlpriv, REG_RQPN + 3, ubyte | BIT(7));
600
601 return true;
602}
603
604static void _rtl8723ae_gen_refresh_led_state(struct ieee80211_hw *hw)
605{
606 struct rtl_priv *rtlpriv = rtl_priv(hw);
607 struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw);
608 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
609 struct rtl_led *pLed0 = &(pcipriv->ledctl.sw_led0);
610
611 if (rtlpriv->rtlhal.up_first_time)
612 return;
613
614 if (ppsc->rfoff_reason == RF_CHANGE_BY_IPS)
615 rtl8723ae_sw_led_on(hw, pLed0);
616 else if (ppsc->rfoff_reason == RF_CHANGE_BY_INIT)
617 rtl8723ae_sw_led_on(hw, pLed0);
618 else
619 rtl8723ae_sw_led_off(hw, pLed0);
620}
621
622static bool _rtl8712e_init_mac(struct ieee80211_hw *hw)
623{
624 struct rtl_priv *rtlpriv = rtl_priv(hw);
625 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
626 unsigned char bytetmp;
627 unsigned short wordtmp;
628 u16 retry = 0;
629 u16 tmpu2b;
630 bool mac_func_enable;
631
632 rtl_write_byte(rtlpriv, REG_RSV_CTRL, 0x00);
633 bytetmp = rtl_read_byte(rtlpriv, REG_CR);
634 if (bytetmp == 0xFF)
635 mac_func_enable = true;
636 else
637 mac_func_enable = false;
638
639
640 /* HW Power on sequence */
641 if (!rtl_hal_pwrseqcmdparsing(rtlpriv, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK,
642 PWR_INTF_PCI_MSK, Rtl8723_NIC_ENABLE_FLOW))
643 return false;
644
645 bytetmp = rtl_read_byte(rtlpriv, REG_PCIE_CTRL_REG+2);
646 rtl_write_byte(rtlpriv, REG_PCIE_CTRL_REG+2, bytetmp | BIT(4));
647
648 /* eMAC time out function enable, 0x369[7]=1 */
649 bytetmp = rtl_read_byte(rtlpriv, 0x369);
650 rtl_write_byte(rtlpriv, 0x369, bytetmp | BIT(7));
651
652 /* ePHY reg 0x1e bit[4]=1 using MDIO interface,
653 * we should do this before Enabling ASPM backdoor.
654 */
655 do {
656 rtl_write_word(rtlpriv, 0x358, 0x5e);
657 udelay(100);
658 rtl_write_word(rtlpriv, 0x356, 0xc280);
659 rtl_write_word(rtlpriv, 0x354, 0xc290);
660 rtl_write_word(rtlpriv, 0x358, 0x3e);
661 udelay(100);
662 rtl_write_word(rtlpriv, 0x358, 0x5e);
663 udelay(100);
664 tmpu2b = rtl_read_word(rtlpriv, 0x356);
665 retry++;
666 } while (tmpu2b != 0xc290 && retry < 100);
667
668 if (retry >= 100) {
669 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
670 "InitMAC(): ePHY configure fail!!!\n");
671 return false;
672 }
673
674 rtl_write_word(rtlpriv, REG_CR, 0x2ff);
675 rtl_write_word(rtlpriv, REG_CR + 1, 0x06);
676
677 if (!mac_func_enable) {
678 if (_rtl8723ae_llt_table_init(hw) == false)
679 return false;
680 }
681
682 rtl_write_dword(rtlpriv, REG_HISR, 0xffffffff);
683 rtl_write_byte(rtlpriv, REG_HISRE, 0xff);
684
685 rtl_write_word(rtlpriv, REG_TRXFF_BNDY + 2, 0x27ff);
686
687 wordtmp = rtl_read_word(rtlpriv, REG_TRXDMA_CTRL) & 0xf;
688 wordtmp |= 0xF771;
689 rtl_write_word(rtlpriv, REG_TRXDMA_CTRL, wordtmp);
690
691 rtl_write_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 1, 0x1F);
692 rtl_write_dword(rtlpriv, REG_RCR, rtlpci->receive_config);
693 rtl_write_word(rtlpriv, REG_RXFLTMAP2, 0xFFFF);
694 rtl_write_dword(rtlpriv, REG_TCR, rtlpci->transmit_config);
695
696 rtl_write_byte(rtlpriv, 0x4d0, 0x0);
697
698 rtl_write_dword(rtlpriv, REG_BCNQ_DESA,
699 ((u64) rtlpci->tx_ring[BEACON_QUEUE].dma) &
700 DMA_BIT_MASK(32));
701 rtl_write_dword(rtlpriv, REG_MGQ_DESA,
702 (u64) rtlpci->tx_ring[MGNT_QUEUE].dma &
703 DMA_BIT_MASK(32));
704 rtl_write_dword(rtlpriv, REG_VOQ_DESA,
705 (u64) rtlpci->tx_ring[VO_QUEUE].dma & DMA_BIT_MASK(32));
706 rtl_write_dword(rtlpriv, REG_VIQ_DESA,
707 (u64) rtlpci->tx_ring[VI_QUEUE].dma & DMA_BIT_MASK(32));
708 rtl_write_dword(rtlpriv, REG_BEQ_DESA,
709 (u64) rtlpci->tx_ring[BE_QUEUE].dma & DMA_BIT_MASK(32));
710 rtl_write_dword(rtlpriv, REG_BKQ_DESA,
711 (u64) rtlpci->tx_ring[BK_QUEUE].dma & DMA_BIT_MASK(32));
712 rtl_write_dword(rtlpriv, REG_HQ_DESA,
713 (u64) rtlpci->tx_ring[HIGH_QUEUE].dma &
714 DMA_BIT_MASK(32));
715 rtl_write_dword(rtlpriv, REG_RX_DESA,
716 (u64) rtlpci->rx_ring[RX_MPDU_QUEUE].dma &
717 DMA_BIT_MASK(32));
718
719 rtl_write_byte(rtlpriv, REG_PCIE_CTRL_REG + 3, 0x74);
720
721 rtl_write_dword(rtlpriv, REG_INT_MIG, 0);
722
723 bytetmp = rtl_read_byte(rtlpriv, REG_APSD_CTRL);
724 rtl_write_byte(rtlpriv, REG_APSD_CTRL, bytetmp & ~BIT(6));
725 do {
726 retry++;
727 bytetmp = rtl_read_byte(rtlpriv, REG_APSD_CTRL);
728 } while ((retry < 200) && (bytetmp & BIT(7)));
729
730 _rtl8723ae_gen_refresh_led_state(hw);
731
732 rtl_write_dword(rtlpriv, REG_MCUTST_1, 0x0);
733
734 return true;
735}
736
737static void _rtl8723ae_hw_configure(struct ieee80211_hw *hw)
738{
739 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
740 struct rtl_priv *rtlpriv = rtl_priv(hw);
741 struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw);
742 u8 reg_bw_opmode;
Larry Fingerb26f5f02013-02-01 10:40:27 -0600743 u32 reg_prsr;
Larry Fingerc592e632012-10-25 13:46:32 -0500744
745 reg_bw_opmode = BW_OPMODE_20MHZ;
Larry Fingerc592e632012-10-25 13:46:32 -0500746 reg_prsr = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
747
748 rtl_write_byte(rtlpriv, REG_INIRTS_RATE_SEL, 0x8);
749
750 rtl_write_byte(rtlpriv, REG_BWOPMODE, reg_bw_opmode);
751
752 rtl_write_dword(rtlpriv, REG_RRSR, reg_prsr);
753
754 rtl_write_byte(rtlpriv, REG_SLOT, 0x09);
755
756 rtl_write_byte(rtlpriv, REG_AMPDU_MIN_SPACE, 0x0);
757
758 rtl_write_word(rtlpriv, REG_FWHW_TXQ_CTRL, 0x1F80);
759
760 rtl_write_word(rtlpriv, REG_RL, 0x0707);
761
762 rtl_write_dword(rtlpriv, REG_BAR_MODE_CTRL, 0x02012802);
763
764 rtl_write_byte(rtlpriv, REG_HWSEQ_CTRL, 0xFF);
765
766 rtl_write_dword(rtlpriv, REG_DARFRC, 0x01000000);
767 rtl_write_dword(rtlpriv, REG_DARFRC + 4, 0x07060504);
768 rtl_write_dword(rtlpriv, REG_RARFRC, 0x01000000);
769 rtl_write_dword(rtlpriv, REG_RARFRC + 4, 0x07060504);
770
771 if ((pcipriv->bt_coexist.bt_coexistence) &&
772 (pcipriv->bt_coexist.bt_coexist_type == BT_CSR_BC4))
773 rtl_write_dword(rtlpriv, REG_AGGLEN_LMT, 0x97427431);
774 else
775 rtl_write_dword(rtlpriv, REG_AGGLEN_LMT, 0xb972a841);
776
777 rtl_write_byte(rtlpriv, REG_ATIMWND, 0x2);
778
779 rtl_write_byte(rtlpriv, REG_BCN_MAX_ERR, 0xff);
780
781 rtlpci->reg_bcn_ctrl_val = 0x1f;
782 rtl_write_byte(rtlpriv, REG_BCN_CTRL, rtlpci->reg_bcn_ctrl_val);
783
784 rtl_write_byte(rtlpriv, REG_TBTT_PROHIBIT + 1, 0xff);
785
786 rtl_write_byte(rtlpriv, REG_TBTT_PROHIBIT + 1, 0xff);
787
788 rtl_write_byte(rtlpriv, REG_PIFS, 0x1C);
789 rtl_write_byte(rtlpriv, REG_AGGR_BREAK_TIME, 0x16);
790
791 if ((pcipriv->bt_coexist.bt_coexistence) &&
792 (pcipriv->bt_coexist.bt_coexist_type == BT_CSR_BC4)) {
793 rtl_write_word(rtlpriv, REG_NAV_PROT_LEN, 0x0020);
794 rtl_write_word(rtlpriv, REG_PROT_MODE_CTRL, 0x0402);
795 } else {
796 rtl_write_word(rtlpriv, REG_NAV_PROT_LEN, 0x0020);
797 rtl_write_word(rtlpriv, REG_NAV_PROT_LEN, 0x0020);
798 }
799
800 if ((pcipriv->bt_coexist.bt_coexistence) &&
801 (pcipriv->bt_coexist.bt_coexist_type == BT_CSR_BC4))
802 rtl_write_dword(rtlpriv, REG_FAST_EDCA_CTRL, 0x03086666);
803 else
804 rtl_write_dword(rtlpriv, REG_FAST_EDCA_CTRL, 0x086666);
805
806 rtl_write_byte(rtlpriv, REG_ACKTO, 0x40);
807
808 rtl_write_word(rtlpriv, REG_SPEC_SIFS, 0x1010);
809 rtl_write_word(rtlpriv, REG_MAC_SPEC_SIFS, 0x1010);
810
811 rtl_write_word(rtlpriv, REG_SIFS_CTX, 0x1010);
812
813 rtl_write_word(rtlpriv, REG_SIFS_TRX, 0x1010);
814
815 rtl_write_dword(rtlpriv, REG_MAR, 0xffffffff);
816 rtl_write_dword(rtlpriv, REG_MAR + 4, 0xffffffff);
817
818 rtl_write_dword(rtlpriv, 0x394, 0x1);
819}
820
821static void _rtl8723ae_enable_aspm_back_door(struct ieee80211_hw *hw)
822{
823 struct rtl_priv *rtlpriv = rtl_priv(hw);
824 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
825
826 rtl_write_byte(rtlpriv, 0x34b, 0x93);
827 rtl_write_word(rtlpriv, 0x350, 0x870c);
828 rtl_write_byte(rtlpriv, 0x352, 0x1);
829
830 if (ppsc->support_backdoor)
831 rtl_write_byte(rtlpriv, 0x349, 0x1b);
832 else
833 rtl_write_byte(rtlpriv, 0x349, 0x03);
834
835 rtl_write_word(rtlpriv, 0x350, 0x2718);
836 rtl_write_byte(rtlpriv, 0x352, 0x1);
837}
838
839void rtl8723ae_enable_hw_security_config(struct ieee80211_hw *hw)
840{
841 struct rtl_priv *rtlpriv = rtl_priv(hw);
842 u8 sec_reg_value;
843
844 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
845 "PairwiseEncAlgorithm = %d GroupEncAlgorithm = %d\n",
846 rtlpriv->sec.pairwise_enc_algorithm,
847 rtlpriv->sec.group_enc_algorithm);
848
849 if (rtlpriv->cfg->mod_params->sw_crypto || rtlpriv->sec.use_sw_sec) {
850 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
851 "not open hw encryption\n");
852 return;
853 }
854
855 sec_reg_value = SCR_TxEncEnable | SCR_RxDecEnable;
856
857 if (rtlpriv->sec.use_defaultkey) {
858 sec_reg_value |= SCR_TxUseDK;
859 sec_reg_value |= SCR_RxUseDK;
860 }
861
862 sec_reg_value |= (SCR_RXBCUSEDK | SCR_TXBCUSEDK);
863
864 rtl_write_byte(rtlpriv, REG_CR + 1, 0x02);
865
866 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
867 "The SECR-value %x\n", sec_reg_value);
868
869 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_WPA_CONFIG, &sec_reg_value);
870
871}
872
873int rtl8723ae_hw_init(struct ieee80211_hw *hw)
874{
875 struct rtl_priv *rtlpriv = rtl_priv(hw);
876 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
877 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
878 struct rtl_phy *rtlphy = &(rtlpriv->phy);
879 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
880 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
881 bool rtstatus = true;
882 int err;
883 u8 tmp_u1b;
Larry Fingerbfc10102014-03-04 16:53:53 -0600884 unsigned long flags;
Larry Fingerc592e632012-10-25 13:46:32 -0500885
886 rtlpriv->rtlhal.being_init_adapter = true;
Larry Fingerbfc10102014-03-04 16:53:53 -0600887 /* As this function can take a very long time (up to 350 ms)
888 * and can be called with irqs disabled, reenable the irqs
889 * to let the other devices continue being serviced.
890 *
891 * It is safe doing so since our own interrupts will only be enabled
892 * in a subsequent step.
893 */
894 local_save_flags(flags);
895 local_irq_enable();
896
Larry Fingerc592e632012-10-25 13:46:32 -0500897 rtlpriv->intf_ops->disable_aspm(hw);
898 rtstatus = _rtl8712e_init_mac(hw);
899 if (rtstatus != true) {
900 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Init MAC failed\n");
901 err = 1;
Larry Fingerbfc10102014-03-04 16:53:53 -0600902 goto exit;
Larry Fingerc592e632012-10-25 13:46:32 -0500903 }
904
Larry Fingercbd0c852014-02-28 15:16:48 -0600905 err = rtl8723_download_fw(hw, false);
Larry Fingerc592e632012-10-25 13:46:32 -0500906 if (err) {
907 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
908 "Failed to download FW. Init HW without FW now..\n");
909 err = 1;
Larry Fingerbfc10102014-03-04 16:53:53 -0600910 goto exit;
Larry Fingerc592e632012-10-25 13:46:32 -0500911 } else {
912 rtlhal->fw_ready = true;
913 }
914
915 rtlhal->last_hmeboxnum = 0;
916 rtl8723ae_phy_mac_config(hw);
917 /* because the last function modifies RCR, we update
918 * rcr var here, or TP will be unstable as ther receive_config
919 * is wrong, RX RCR_ACRC32 will cause TP unstable & Rx
920 * RCR_APP_ICV will cause mac80211 unassoc for cisco 1252
921 */
922 rtlpci->receive_config = rtl_read_dword(rtlpriv, REG_RCR);
923 rtlpci->receive_config &= ~(RCR_ACRC32 | RCR_AICV);
924 rtl_write_dword(rtlpriv, REG_RCR, rtlpci->receive_config);
925
926 rtl8723ae_phy_bb_config(hw);
927 rtlphy->rf_mode = RF_OP_BY_SW_3WIRE;
928 rtl8723ae_phy_rf_config(hw);
929 if (IS_VENDOR_UMC_A_CUT(rtlhal->version)) {
930 rtl_set_rfreg(hw, RF90_PATH_A, RF_RX_G1, MASKDWORD, 0x30255);
931 rtl_set_rfreg(hw, RF90_PATH_A, RF_RX_G2, MASKDWORD, 0x50a00);
932 } else if (IS_81xxC_VENDOR_UMC_B_CUT(rtlhal->version)) {
933 rtl_set_rfreg(hw, RF90_PATH_A, 0x0C, MASKDWORD, 0x894AE);
934 rtl_set_rfreg(hw, RF90_PATH_A, 0x0A, MASKDWORD, 0x1AF31);
935 rtl_set_rfreg(hw, RF90_PATH_A, RF_IPA, MASKDWORD, 0x8F425);
936 rtl_set_rfreg(hw, RF90_PATH_A, RF_SYN_G2, MASKDWORD, 0x4F200);
937 rtl_set_rfreg(hw, RF90_PATH_A, RF_RCK1, MASKDWORD, 0x44053);
938 rtl_set_rfreg(hw, RF90_PATH_A, RF_RCK2, MASKDWORD, 0x80201);
939 }
940 rtlphy->rfreg_chnlval[0] = rtl_get_rfreg(hw, (enum radio_path)0,
941 RF_CHNLBW, RFREG_OFFSET_MASK);
942 rtlphy->rfreg_chnlval[1] = rtl_get_rfreg(hw, (enum radio_path)1,
943 RF_CHNLBW, RFREG_OFFSET_MASK);
944 rtl_set_bbreg(hw, RFPGA0_RFMOD, BCCKEN, 0x1);
945 rtl_set_bbreg(hw, RFPGA0_RFMOD, BOFDMEN, 0x1);
946 rtl_set_bbreg(hw, RFPGA0_ANALOGPARAMETER2, BIT(10), 1);
947 _rtl8723ae_hw_configure(hw);
948 rtl_cam_reset_all_entry(hw);
949 rtl8723ae_enable_hw_security_config(hw);
950
951 ppsc->rfpwr_state = ERFON;
952
953 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ETHER_ADDR, mac->mac_addr);
954 _rtl8723ae_enable_aspm_back_door(hw);
955 rtlpriv->intf_ops->enable_aspm(hw);
956
957 rtl8723ae_bt_hw_init(hw);
958
959 if (ppsc->rfpwr_state == ERFON) {
960 rtl8723ae_phy_set_rfpath_switch(hw, 1);
961 if (rtlphy->iqk_initialized) {
962 rtl8723ae_phy_iq_calibrate(hw, true);
963 } else {
964 rtl8723ae_phy_iq_calibrate(hw, false);
965 rtlphy->iqk_initialized = true;
966 }
967
968 rtl8723ae_phy_lc_calibrate(hw);
969 }
970
971 tmp_u1b = efuse_read_1byte(hw, 0x1FA);
972 if (!(tmp_u1b & BIT(0))) {
973 rtl_set_rfreg(hw, RF90_PATH_A, 0x15, 0x0F, 0x05);
974 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "PA BIAS path A\n");
975 }
976
977 if (!(tmp_u1b & BIT(4))) {
978 tmp_u1b = rtl_read_byte(rtlpriv, 0x16) & 0x0F;
979 rtl_write_byte(rtlpriv, 0x16, tmp_u1b | 0x80);
980 udelay(10);
981 rtl_write_byte(rtlpriv, 0x16, tmp_u1b | 0x90);
982 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "under 1.5V\n");
983 }
984 rtl8723ae_dm_init(hw);
Larry Fingerbfc10102014-03-04 16:53:53 -0600985exit:
986 local_irq_restore(flags);
Larry Fingerc592e632012-10-25 13:46:32 -0500987 rtlpriv->rtlhal.being_init_adapter = false;
988 return err;
989}
990
991static enum version_8723e _rtl8723ae_read_chip_version(struct ieee80211_hw *hw)
992{
993 struct rtl_priv *rtlpriv = rtl_priv(hw);
994 struct rtl_phy *rtlphy = &(rtlpriv->phy);
995 enum version_8723e version = 0x0000;
996 u32 value32;
997
998 value32 = rtl_read_dword(rtlpriv, REG_SYS_CFG);
999 if (value32 & TRP_VAUX_EN) {
1000 version = (enum version_8723e)(version |
1001 ((value32 & VENDOR_ID) ? CHIP_VENDOR_UMC : 0));
1002 /* RTL8723 with BT function. */
1003 version = (enum version_8723e)(version |
1004 ((value32 & BT_FUNC) ? CHIP_8723 : 0));
1005
1006 } else {
1007 /* Normal mass production chip. */
1008 version = (enum version_8723e) NORMAL_CHIP;
1009 version = (enum version_8723e)(version |
1010 ((value32 & VENDOR_ID) ? CHIP_VENDOR_UMC : 0));
1011 /* RTL8723 with BT function. */
1012 version = (enum version_8723e)(version |
1013 ((value32 & BT_FUNC) ? CHIP_8723 : 0));
1014 if (IS_CHIP_VENDOR_UMC(version))
1015 version = (enum version_8723e)(version |
1016 ((value32 & CHIP_VER_RTL_MASK)));/* IC version (CUT) */
1017 if (IS_8723_SERIES(version)) {
1018 value32 = rtl_read_dword(rtlpriv, REG_GPIO_OUTSTS);
1019 /* ROM code version */
1020 version = (enum version_8723e)(version |
1021 ((value32 & RF_RL_ID)>>20));
1022 }
1023 }
1024
1025 if (IS_8723_SERIES(version)) {
1026 value32 = rtl_read_dword(rtlpriv, REG_MULTI_FUNC_CTRL);
1027 rtlphy->polarity_ctl = ((value32 & WL_HWPDN_SL) ?
1028 RT_POLARITY_HIGH_ACT :
1029 RT_POLARITY_LOW_ACT);
1030 }
1031 switch (version) {
1032 case VERSION_TEST_UMC_CHIP_8723:
1033 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1034 "Chip Version ID: VERSION_TEST_UMC_CHIP_8723.\n");
1035 break;
1036 case VERSION_NORMAL_UMC_CHIP_8723_1T1R_A_CUT:
1037 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1038 "Chip Version ID: VERSION_NORMAL_UMC_CHIP_8723_1T1R_A_CUT.\n");
1039 break;
1040 case VERSION_NORMAL_UMC_CHIP_8723_1T1R_B_CUT:
1041 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1042 "Chip Version ID: VERSION_NORMAL_UMC_CHIP_8723_1T1R_B_CUT.\n");
1043 break;
1044 default:
1045 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1046 "Chip Version ID: Unknown. Bug?\n");
1047 break;
1048 }
1049
1050 if (IS_8723_SERIES(version))
1051 rtlphy->rf_type = RF_1T1R;
1052
1053 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Chip RF Type: %s\n",
1054 (rtlphy->rf_type == RF_2T2R) ? "RF_2T2R" : "RF_1T1R");
1055
1056 return version;
1057}
1058
1059static int _rtl8723ae_set_media_status(struct ieee80211_hw *hw,
1060 enum nl80211_iftype type)
1061{
1062 struct rtl_priv *rtlpriv = rtl_priv(hw);
1063 u8 bt_msr = rtl_read_byte(rtlpriv, MSR) & 0xfc;
1064 enum led_ctl_mode ledaction = LED_CTL_NO_LINK;
1065
1066 rtl_write_dword(rtlpriv, REG_BCN_CTRL, 0);
1067 RT_TRACE(rtlpriv, COMP_BEACON, DBG_LOUD,
1068 "clear 0x550 when set HW_VAR_MEDIA_STATUS\n");
1069
1070 if (type == NL80211_IFTYPE_UNSPECIFIED ||
1071 type == NL80211_IFTYPE_STATION) {
1072 _rtl8723ae_stop_tx_beacon(hw);
1073 _rtl8723ae_enable_bcn_sufunc(hw);
1074 } else if (type == NL80211_IFTYPE_ADHOC ||
1075 type == NL80211_IFTYPE_AP) {
1076 _rtl8723ae_resume_tx_beacon(hw);
1077 _rtl8723ae_disable_bcn_sufunc(hw);
1078 } else {
1079 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
1080 "Set HW_VAR_MEDIA_STATUS: No such media status(%x).\n",
1081 type);
1082 }
1083
1084 switch (type) {
1085 case NL80211_IFTYPE_UNSPECIFIED:
1086 bt_msr |= MSR_NOLINK;
1087 ledaction = LED_CTL_LINK;
1088 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1089 "Set Network type to NO LINK!\n");
1090 break;
1091 case NL80211_IFTYPE_ADHOC:
1092 bt_msr |= MSR_ADHOC;
1093 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1094 "Set Network type to Ad Hoc!\n");
1095 break;
1096 case NL80211_IFTYPE_STATION:
1097 bt_msr |= MSR_INFRA;
1098 ledaction = LED_CTL_LINK;
1099 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1100 "Set Network type to STA!\n");
1101 break;
1102 case NL80211_IFTYPE_AP:
1103 bt_msr |= MSR_AP;
1104 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1105 "Set Network type to AP!\n");
1106 break;
1107 default:
1108 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1109 "Network type %d not supported!\n",
1110 type);
1111 return 1;
1112 break;
1113
1114 }
1115
1116 rtl_write_byte(rtlpriv, (MSR), bt_msr);
1117 rtlpriv->cfg->ops->led_control(hw, ledaction);
1118 if ((bt_msr & 0x03) == MSR_AP)
1119 rtl_write_byte(rtlpriv, REG_BCNTCFG + 1, 0x00);
1120 else
1121 rtl_write_byte(rtlpriv, REG_BCNTCFG + 1, 0x66);
1122 return 0;
1123}
1124
1125void rtl8723ae_set_check_bssid(struct ieee80211_hw *hw, bool check_bssid)
1126{
1127 struct rtl_priv *rtlpriv = rtl_priv(hw);
Peter Wue51048c2014-02-14 19:03:44 +01001128 u32 reg_rcr;
Larry Fingerc592e632012-10-25 13:46:32 -05001129
1130 if (rtlpriv->psc.rfpwr_state != ERFON)
1131 return;
1132
Peter Wue51048c2014-02-14 19:03:44 +01001133 rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_RCR, (u8 *)(&reg_rcr));
1134
Larry Fingerc592e632012-10-25 13:46:32 -05001135 if (check_bssid == true) {
1136 reg_rcr |= (RCR_CBSSID_DATA | RCR_CBSSID_BCN);
1137 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RCR,
1138 (u8 *)(&reg_rcr));
1139 _rtl8723ae_set_bcn_ctrl_reg(hw, 0, BIT(4));
1140 } else if (check_bssid == false) {
1141 reg_rcr &= (~(RCR_CBSSID_DATA | RCR_CBSSID_BCN));
1142 _rtl8723ae_set_bcn_ctrl_reg(hw, BIT(4), 0);
1143 rtlpriv->cfg->ops->set_hw_reg(hw,
1144 HW_VAR_RCR, (u8 *) (&reg_rcr));
1145 }
1146}
1147
1148int rtl8723ae_set_network_type(struct ieee80211_hw *hw,
1149 enum nl80211_iftype type)
1150{
1151 struct rtl_priv *rtlpriv = rtl_priv(hw);
1152
1153 if (_rtl8723ae_set_media_status(hw, type))
1154 return -EOPNOTSUPP;
1155
1156 if (rtlpriv->mac80211.link_state == MAC80211_LINKED) {
1157 if (type != NL80211_IFTYPE_AP)
1158 rtl8723ae_set_check_bssid(hw, true);
1159 } else {
1160 rtl8723ae_set_check_bssid(hw, false);
1161 }
1162 return 0;
1163}
1164
1165/* don't set REG_EDCA_BE_PARAM here because mac80211 will send pkt when scan */
1166void rtl8723ae_set_qos(struct ieee80211_hw *hw, int aci)
1167{
1168 struct rtl_priv *rtlpriv = rtl_priv(hw);
1169
Larry Finger57d9d9632014-02-28 15:16:49 -06001170 rtl8723_dm_init_edca_turbo(hw);
Larry Fingerc592e632012-10-25 13:46:32 -05001171 switch (aci) {
1172 case AC1_BK:
1173 rtl_write_dword(rtlpriv, REG_EDCA_BK_PARAM, 0xa44f);
1174 break;
1175 case AC0_BE:
1176 /* rtl_write_dword(rtlpriv, REG_EDCA_BE_PARAM, u4ac_param); */
1177 break;
1178 case AC2_VI:
1179 rtl_write_dword(rtlpriv, REG_EDCA_VI_PARAM, 0x5e4322);
1180 break;
1181 case AC3_VO:
1182 rtl_write_dword(rtlpriv, REG_EDCA_VO_PARAM, 0x2f3222);
1183 break;
1184 default:
1185 RT_ASSERT(false, "invalid aci: %d !\n", aci);
1186 break;
1187 }
1188}
1189
1190void rtl8723ae_enable_interrupt(struct ieee80211_hw *hw)
1191{
1192 struct rtl_priv *rtlpriv = rtl_priv(hw);
1193 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
1194
1195 rtl_write_dword(rtlpriv, 0x3a8, rtlpci->irq_mask[0] & 0xFFFFFFFF);
1196 rtl_write_dword(rtlpriv, 0x3ac, rtlpci->irq_mask[1] & 0xFFFFFFFF);
1197 rtlpci->irq_enabled = true;
1198}
1199
1200void rtl8723ae_disable_interrupt(struct ieee80211_hw *hw)
1201{
1202 struct rtl_priv *rtlpriv = rtl_priv(hw);
1203 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
1204
1205 rtl_write_dword(rtlpriv, 0x3a8, IMR8190_DISABLED);
1206 rtl_write_dword(rtlpriv, 0x3ac, IMR8190_DISABLED);
1207 rtlpci->irq_enabled = false;
1208 synchronize_irq(rtlpci->pdev->irq);
1209}
1210
1211static void _rtl8723ae_poweroff_adapter(struct ieee80211_hw *hw)
1212{
1213 struct rtl_priv *rtlpriv = rtl_priv(hw);
1214 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
1215 u8 u1tmp;
1216
1217 /* Combo (PCIe + USB) Card and PCIe-MF Card */
1218 /* 1. Run LPS WL RFOFF flow */
1219 rtl_hal_pwrseqcmdparsing(rtlpriv, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK,
1220 PWR_INTF_PCI_MSK, Rtl8723_NIC_LPS_ENTER_FLOW);
1221
1222 /* 2. 0x1F[7:0] = 0 */
1223 /* turn off RF */
1224 rtl_write_byte(rtlpriv, REG_RF_CTRL, 0x00);
1225 if ((rtl_read_byte(rtlpriv, REG_MCUFWDL) & BIT(7)) && rtlhal->fw_ready)
1226 rtl8723ae_firmware_selfreset(hw);
1227
1228 /* Reset MCU. Suggested by Filen. */
1229 u1tmp = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN+1);
1230 rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN+1, (u1tmp & (~BIT(2))));
1231
1232 /* g. MCUFWDL 0x80[1:0]=0 */
1233 /* reset MCU ready status */
1234 rtl_write_byte(rtlpriv, REG_MCUFWDL, 0x00);
1235
1236 /* HW card disable configuration. */
1237 rtl_hal_pwrseqcmdparsing(rtlpriv, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK,
1238 PWR_INTF_PCI_MSK, Rtl8723_NIC_DISABLE_FLOW);
1239
1240 /* Reset MCU IO Wrapper */
1241 u1tmp = rtl_read_byte(rtlpriv, REG_RSV_CTRL + 1);
1242 rtl_write_byte(rtlpriv, REG_RSV_CTRL + 1, (u1tmp & (~BIT(0))));
1243 u1tmp = rtl_read_byte(rtlpriv, REG_RSV_CTRL + 1);
1244 rtl_write_byte(rtlpriv, REG_RSV_CTRL + 1, u1tmp | BIT(0));
1245
1246 /* 7. RSV_CTRL 0x1C[7:0] = 0x0E */
1247 /* lock ISO/CLK/Power control register */
1248 rtl_write_byte(rtlpriv, REG_RSV_CTRL, 0x0e);
1249}
1250
1251void rtl8723ae_card_disable(struct ieee80211_hw *hw)
1252{
1253 struct rtl_priv *rtlpriv = rtl_priv(hw);
1254 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
1255 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
1256 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
1257 enum nl80211_iftype opmode;
1258
1259 mac->link_state = MAC80211_NOLINK;
1260 opmode = NL80211_IFTYPE_UNSPECIFIED;
1261 _rtl8723ae_set_media_status(hw, opmode);
1262 if (rtlpci->driver_is_goingto_unload ||
1263 ppsc->rfoff_reason > RF_CHANGE_BY_PS)
1264 rtlpriv->cfg->ops->led_control(hw, LED_CTL_POWER_OFF);
1265 RT_SET_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC);
1266 _rtl8723ae_poweroff_adapter(hw);
1267
1268 /* after power off we should do iqk again */
1269 rtlpriv->phy.iqk_initialized = false;
1270}
1271
1272void rtl8723ae_interrupt_recognized(struct ieee80211_hw *hw,
1273 u32 *p_inta, u32 *p_intb)
1274{
1275 struct rtl_priv *rtlpriv = rtl_priv(hw);
1276 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
1277
1278 *p_inta = rtl_read_dword(rtlpriv, 0x3a0) & rtlpci->irq_mask[0];
1279 rtl_write_dword(rtlpriv, 0x3a0, *p_inta);
1280}
1281
1282void rtl8723ae_set_beacon_related_registers(struct ieee80211_hw *hw)
1283{
1284
1285 struct rtl_priv *rtlpriv = rtl_priv(hw);
1286 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
1287 u16 bcn_interval, atim_window;
1288
1289 bcn_interval = mac->beacon_interval;
1290 atim_window = 2; /*FIX MERGE */
1291 rtl8723ae_disable_interrupt(hw);
1292 rtl_write_word(rtlpriv, REG_ATIMWND, atim_window);
1293 rtl_write_word(rtlpriv, REG_BCN_INTERVAL, bcn_interval);
1294 rtl_write_word(rtlpriv, REG_BCNTCFG, 0x660f);
1295 rtl_write_byte(rtlpriv, REG_RXTSF_OFFSET_CCK, 0x18);
1296 rtl_write_byte(rtlpriv, REG_RXTSF_OFFSET_OFDM, 0x18);
1297 rtl_write_byte(rtlpriv, 0x606, 0x30);
1298 rtl8723ae_enable_interrupt(hw);
1299}
1300
1301void rtl8723ae_set_beacon_interval(struct ieee80211_hw *hw)
1302{
1303 struct rtl_priv *rtlpriv = rtl_priv(hw);
1304 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
1305 u16 bcn_interval = mac->beacon_interval;
1306
1307 RT_TRACE(rtlpriv, COMP_BEACON, DBG_DMESG,
1308 "beacon_interval:%d\n", bcn_interval);
1309 rtl8723ae_disable_interrupt(hw);
1310 rtl_write_word(rtlpriv, REG_BCN_INTERVAL, bcn_interval);
1311 rtl8723ae_enable_interrupt(hw);
1312}
1313
1314void rtl8723ae_update_interrupt_mask(struct ieee80211_hw *hw,
1315 u32 add_msr, u32 rm_msr)
1316{
1317 struct rtl_priv *rtlpriv = rtl_priv(hw);
1318 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
1319
1320 RT_TRACE(rtlpriv, COMP_INTR, DBG_LOUD,
1321 "add_msr:%x, rm_msr:%x\n", add_msr, rm_msr);
1322
1323 if (add_msr)
1324 rtlpci->irq_mask[0] |= add_msr;
1325 if (rm_msr)
1326 rtlpci->irq_mask[0] &= (~rm_msr);
1327 rtl8723ae_disable_interrupt(hw);
1328 rtl8723ae_enable_interrupt(hw);
1329}
1330
1331static u8 _rtl8723ae_get_chnl_group(u8 chnl)
1332{
1333 u8 group;
1334
1335 if (chnl < 3)
1336 group = 0;
1337 else if (chnl < 9)
1338 group = 1;
1339 else
1340 group = 2;
1341 return group;
1342}
1343
1344static void _rtl8723ae_read_txpower_info_from_hwpg(struct ieee80211_hw *hw,
1345 bool autoload_fail,
1346 u8 *hwinfo)
1347{
1348 struct rtl_priv *rtlpriv = rtl_priv(hw);
1349 struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
1350 u8 rf_path, index, tempval;
1351 u16 i;
1352
1353 for (rf_path = 0; rf_path < 1; rf_path++) {
1354 for (i = 0; i < 3; i++) {
1355 if (!autoload_fail) {
1356 rtlefuse->eeprom_chnlarea_txpwr_cck
1357 [rf_path][i] =
1358 hwinfo[EEPROM_TXPOWERCCK + rf_path * 3 + i];
1359 rtlefuse->eeprom_chnlarea_txpwr_ht40_1s
1360 [rf_path][i] =
1361 hwinfo[EEPROM_TXPOWERHT40_1S + rf_path *
1362 3 + i];
1363 } else {
1364 rtlefuse->eeprom_chnlarea_txpwr_cck
1365 [rf_path][i] =
1366 EEPROM_DEFAULT_TXPOWERLEVEL;
1367 rtlefuse->eeprom_chnlarea_txpwr_ht40_1s
1368 [rf_path][i] =
1369 EEPROM_DEFAULT_TXPOWERLEVEL;
1370 }
1371 }
1372 }
1373
1374 for (i = 0; i < 3; i++) {
1375 if (!autoload_fail)
1376 tempval = hwinfo[EEPROM_TXPOWERHT40_2SDIFF + i];
1377 else
1378 tempval = EEPROM_DEFAULT_HT40_2SDIFF;
1379 rtlefuse->eprom_chnl_txpwr_ht40_2sdf[RF90_PATH_A][i] =
1380 (tempval & 0xf);
1381 rtlefuse->eprom_chnl_txpwr_ht40_2sdf[RF90_PATH_B][i] =
1382 ((tempval & 0xf0) >> 4);
1383 }
1384
1385 for (rf_path = 0; rf_path < 2; rf_path++)
1386 for (i = 0; i < 3; i++)
1387 RTPRINT(rtlpriv, FINIT, INIT_EEPROM,
1388 "RF(%d) EEPROM CCK Area(%d) = 0x%x\n", rf_path,
1389 i, rtlefuse->eeprom_chnlarea_txpwr_cck
1390 [rf_path][i]);
1391 for (rf_path = 0; rf_path < 2; rf_path++)
1392 for (i = 0; i < 3; i++)
1393 RTPRINT(rtlpriv, FINIT, INIT_EEPROM,
1394 "RF(%d) EEPROM HT40 1S Area(%d) = 0x%x\n",
1395 rf_path, i,
1396 rtlefuse->eeprom_chnlarea_txpwr_ht40_1s
1397 [rf_path][i]);
1398 for (rf_path = 0; rf_path < 2; rf_path++)
1399 for (i = 0; i < 3; i++)
1400 RTPRINT(rtlpriv, FINIT, INIT_EEPROM,
1401 "RF(%d) EEPROM HT40 2S Diff Area(%d) = 0x%x\n",
1402 rf_path, i,
1403 rtlefuse->eprom_chnl_txpwr_ht40_2sdf
1404 [rf_path][i]);
1405
1406 for (rf_path = 0; rf_path < 2; rf_path++) {
1407 for (i = 0; i < 14; i++) {
1408 index = _rtl8723ae_get_chnl_group((u8) i);
1409
1410 rtlefuse->txpwrlevel_cck[rf_path][i] =
1411 rtlefuse->eeprom_chnlarea_txpwr_cck
1412 [rf_path][index];
1413 rtlefuse->txpwrlevel_ht40_1s[rf_path][i] =
1414 rtlefuse->eeprom_chnlarea_txpwr_ht40_1s
1415 [rf_path][index];
1416
1417 if ((rtlefuse->eeprom_chnlarea_txpwr_ht40_1s
1418 [rf_path][index] -
1419 rtlefuse->eprom_chnl_txpwr_ht40_2sdf[rf_path]
1420 [index]) > 0) {
1421 rtlefuse->txpwrlevel_ht40_2s[rf_path][i] =
1422 rtlefuse->eeprom_chnlarea_txpwr_ht40_1s
1423 [rf_path][index] -
1424 rtlefuse->eprom_chnl_txpwr_ht40_2sdf
1425 [rf_path][index];
1426 } else {
1427 rtlefuse->txpwrlevel_ht40_2s[rf_path][i] = 0;
1428 }
1429 }
1430
1431 for (i = 0; i < 14; i++) {
Larry Fingere6deaf82013-03-24 22:06:55 -05001432 RTPRINT(rtlpriv, FINIT, INIT_TXPOWER,
Larry Fingerc592e632012-10-25 13:46:32 -05001433 "RF(%d)-Ch(%d) [CCK / HT40_1S / HT40_2S] = "
1434 "[0x%x / 0x%x / 0x%x]\n", rf_path, i,
1435 rtlefuse->txpwrlevel_cck[rf_path][i],
1436 rtlefuse->txpwrlevel_ht40_1s[rf_path][i],
1437 rtlefuse->txpwrlevel_ht40_2s[rf_path][i]);
1438 }
1439 }
1440
1441 for (i = 0; i < 3; i++) {
1442 if (!autoload_fail) {
1443 rtlefuse->eeprom_pwrlimit_ht40[i] =
1444 hwinfo[EEPROM_TXPWR_GROUP + i];
1445 rtlefuse->eeprom_pwrlimit_ht20[i] =
1446 hwinfo[EEPROM_TXPWR_GROUP + 3 + i];
1447 } else {
1448 rtlefuse->eeprom_pwrlimit_ht40[i] = 0;
1449 rtlefuse->eeprom_pwrlimit_ht20[i] = 0;
1450 }
1451 }
1452
1453 for (rf_path = 0; rf_path < 2; rf_path++) {
1454 for (i = 0; i < 14; i++) {
1455 index = _rtl8723ae_get_chnl_group((u8) i);
1456
1457 if (rf_path == RF90_PATH_A) {
1458 rtlefuse->pwrgroup_ht20[rf_path][i] =
1459 (rtlefuse->eeprom_pwrlimit_ht20[index] &
1460 0xf);
1461 rtlefuse->pwrgroup_ht40[rf_path][i] =
1462 (rtlefuse->eeprom_pwrlimit_ht40[index] &
1463 0xf);
1464 } else if (rf_path == RF90_PATH_B) {
1465 rtlefuse->pwrgroup_ht20[rf_path][i] =
1466 ((rtlefuse->eeprom_pwrlimit_ht20[index] &
1467 0xf0) >> 4);
1468 rtlefuse->pwrgroup_ht40[rf_path][i] =
1469 ((rtlefuse->eeprom_pwrlimit_ht40[index] &
1470 0xf0) >> 4);
1471 }
1472
Larry Fingere6deaf82013-03-24 22:06:55 -05001473 RTPRINT(rtlpriv, FINIT, INIT_TXPOWER,
Larry Fingerc592e632012-10-25 13:46:32 -05001474 "RF-%d pwrgroup_ht20[%d] = 0x%x\n", rf_path, i,
1475 rtlefuse->pwrgroup_ht20[rf_path][i]);
Larry Fingere6deaf82013-03-24 22:06:55 -05001476 RTPRINT(rtlpriv, FINIT, INIT_TXPOWER,
Larry Fingerc592e632012-10-25 13:46:32 -05001477 "RF-%d pwrgroup_ht40[%d] = 0x%x\n", rf_path, i,
1478 rtlefuse->pwrgroup_ht40[rf_path][i]);
1479 }
1480 }
1481
1482 for (i = 0; i < 14; i++) {
1483 index = _rtl8723ae_get_chnl_group((u8) i);
1484
1485 if (!autoload_fail)
1486 tempval = hwinfo[EEPROM_TXPOWERHT20DIFF + index];
1487 else
1488 tempval = EEPROM_DEFAULT_HT20_DIFF;
1489
1490 rtlefuse->txpwr_ht20diff[RF90_PATH_A][i] = (tempval & 0xF);
1491 rtlefuse->txpwr_ht20diff[RF90_PATH_B][i] =
1492 ((tempval >> 4) & 0xF);
1493
1494 if (rtlefuse->txpwr_ht20diff[RF90_PATH_A][i] & BIT(3))
1495 rtlefuse->txpwr_ht20diff[RF90_PATH_A][i] |= 0xF0;
1496
1497 if (rtlefuse->txpwr_ht20diff[RF90_PATH_B][i] & BIT(3))
1498 rtlefuse->txpwr_ht20diff[RF90_PATH_B][i] |= 0xF0;
1499
1500 index = _rtl8723ae_get_chnl_group((u8) i);
1501
1502 if (!autoload_fail)
1503 tempval = hwinfo[EEPROM_TXPOWER_OFDMDIFF + index];
1504 else
1505 tempval = EEPROM_DEFAULT_LEGACYHTTXPOWERDIFF;
1506
1507 rtlefuse->txpwr_legacyhtdiff[RF90_PATH_A][i] = (tempval & 0xF);
1508 rtlefuse->txpwr_legacyhtdiff[RF90_PATH_B][i] =
1509 ((tempval >> 4) & 0xF);
1510 }
1511
1512 rtlefuse->legacy_ht_txpowerdiff =
1513 rtlefuse->txpwr_legacyhtdiff[RF90_PATH_A][7];
1514
1515 for (i = 0; i < 14; i++)
Larry Fingere6deaf82013-03-24 22:06:55 -05001516 RTPRINT(rtlpriv, FINIT, INIT_TXPOWER,
Larry Fingerc592e632012-10-25 13:46:32 -05001517 "RF-A Ht20 to HT40 Diff[%d] = 0x%x\n", i,
1518 rtlefuse->txpwr_ht20diff[RF90_PATH_A][i]);
1519 for (i = 0; i < 14; i++)
Larry Fingere6deaf82013-03-24 22:06:55 -05001520 RTPRINT(rtlpriv, FINIT, INIT_TXPOWER,
Larry Fingerc592e632012-10-25 13:46:32 -05001521 "RF-A Legacy to Ht40 Diff[%d] = 0x%x\n", i,
1522 rtlefuse->txpwr_legacyhtdiff[RF90_PATH_A][i]);
1523 for (i = 0; i < 14; i++)
Larry Fingere6deaf82013-03-24 22:06:55 -05001524 RTPRINT(rtlpriv, FINIT, INIT_TXPOWER,
Larry Fingerc592e632012-10-25 13:46:32 -05001525 "RF-B Ht20 to HT40 Diff[%d] = 0x%x\n", i,
1526 rtlefuse->txpwr_ht20diff[RF90_PATH_B][i]);
1527 for (i = 0; i < 14; i++)
Larry Fingere6deaf82013-03-24 22:06:55 -05001528 RTPRINT(rtlpriv, FINIT, INIT_TXPOWER,
Larry Fingerc592e632012-10-25 13:46:32 -05001529 "RF-B Legacy to HT40 Diff[%d] = 0x%x\n", i,
1530 rtlefuse->txpwr_legacyhtdiff[RF90_PATH_B][i]);
1531
1532 if (!autoload_fail)
1533 rtlefuse->eeprom_regulatory = (hwinfo[RF_OPTION1] & 0x7);
1534 else
1535 rtlefuse->eeprom_regulatory = 0;
Larry Fingere6deaf82013-03-24 22:06:55 -05001536 RTPRINT(rtlpriv, FINIT, INIT_TXPOWER,
Larry Fingerc592e632012-10-25 13:46:32 -05001537 "eeprom_regulatory = 0x%x\n", rtlefuse->eeprom_regulatory);
1538
1539 if (!autoload_fail)
1540 rtlefuse->eeprom_tssi[RF90_PATH_A] = hwinfo[EEPROM_TSSI_A];
1541 else
1542 rtlefuse->eeprom_tssi[RF90_PATH_A] = EEPROM_DEFAULT_TSSI;
Larry Fingere6deaf82013-03-24 22:06:55 -05001543 RTPRINT(rtlpriv, FINIT, INIT_TXPOWER,
Larry Fingerc592e632012-10-25 13:46:32 -05001544 "TSSI_A = 0x%x, TSSI_B = 0x%x\n",
1545 rtlefuse->eeprom_tssi[RF90_PATH_A],
1546 rtlefuse->eeprom_tssi[RF90_PATH_B]);
1547
1548 if (!autoload_fail)
1549 tempval = hwinfo[EEPROM_THERMAL_METER];
1550 else
1551 tempval = EEPROM_DEFAULT_THERMALMETER;
1552 rtlefuse->eeprom_thermalmeter = (tempval & 0x1f);
1553
1554 if (rtlefuse->eeprom_thermalmeter == 0x1f || autoload_fail)
1555 rtlefuse->apk_thermalmeterignore = true;
1556
1557 rtlefuse->thermalmeter[0] = rtlefuse->eeprom_thermalmeter;
Larry Fingere6deaf82013-03-24 22:06:55 -05001558 RTPRINT(rtlpriv, FINIT, INIT_TXPOWER,
Larry Fingerc592e632012-10-25 13:46:32 -05001559 "thermalmeter = 0x%x\n", rtlefuse->eeprom_thermalmeter);
1560}
1561
1562static void _rtl8723ae_read_adapter_info(struct ieee80211_hw *hw,
1563 bool pseudo_test)
1564{
1565 struct rtl_priv *rtlpriv = rtl_priv(hw);
1566 struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
1567 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
1568 u16 i, usvalue;
1569 u8 hwinfo[HWSET_MAX_SIZE];
1570 u16 eeprom_id;
1571
1572 if (pseudo_test) {
1573 /* need add */
1574 return;
1575 }
1576 if (rtlefuse->epromtype == EEPROM_BOOT_EFUSE) {
1577 rtl_efuse_shadow_map_update(hw);
1578
1579 memcpy(hwinfo, &rtlefuse->efuse_map[EFUSE_INIT_MAP][0],
1580 HWSET_MAX_SIZE);
1581 } else if (rtlefuse->epromtype == EEPROM_93C46) {
1582 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1583 "RTL819X Not boot from eeprom, check it !!");
1584 }
1585
1586 RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_DMESG, ("MAP\n"),
1587 hwinfo, HWSET_MAX_SIZE);
1588
1589 eeprom_id = *((u16 *)&hwinfo[0]);
1590 if (eeprom_id != RTL8190_EEPROM_ID) {
1591 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
1592 "EEPROM ID(%#x) is invalid!!\n", eeprom_id);
1593 rtlefuse->autoload_failflag = true;
1594 } else {
1595 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Autoload OK\n");
1596 rtlefuse->autoload_failflag = false;
1597 }
1598
1599 if (rtlefuse->autoload_failflag == true)
1600 return;
1601
1602 rtlefuse->eeprom_vid = *(u16 *) &hwinfo[EEPROM_VID];
1603 rtlefuse->eeprom_did = *(u16 *) &hwinfo[EEPROM_DID];
1604 rtlefuse->eeprom_svid = *(u16 *) &hwinfo[EEPROM_SVID];
1605 rtlefuse->eeprom_smid = *(u16 *) &hwinfo[EEPROM_SMID];
1606 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1607 "EEPROMId = 0x%4x\n", eeprom_id);
1608 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1609 "EEPROM VID = 0x%4x\n", rtlefuse->eeprom_vid);
1610 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1611 "EEPROM DID = 0x%4x\n", rtlefuse->eeprom_did);
1612 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1613 "EEPROM SVID = 0x%4x\n", rtlefuse->eeprom_svid);
1614 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1615 "EEPROM SMID = 0x%4x\n", rtlefuse->eeprom_smid);
1616
1617 for (i = 0; i < 6; i += 2) {
1618 usvalue = *(u16 *)&hwinfo[EEPROM_MAC_ADDR + i];
1619 *((u16 *) (&rtlefuse->dev_addr[i])) = usvalue;
1620 }
1621
1622 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
1623 "dev_addr: %pM\n", rtlefuse->dev_addr);
1624
1625 _rtl8723ae_read_txpower_info_from_hwpg(hw,
1626 rtlefuse->autoload_failflag, hwinfo);
1627
1628 rtl8723ae_read_bt_coexist_info_from_hwpg(hw,
1629 rtlefuse->autoload_failflag, hwinfo);
1630
Joe Perches9cb76aa2014-03-24 10:46:20 -07001631 rtlefuse->eeprom_channelplan = hwinfo[EEPROM_CHANNELPLAN];
Larry Fingerc592e632012-10-25 13:46:32 -05001632 rtlefuse->eeprom_version = *(u16 *)&hwinfo[EEPROM_VERSION];
1633 rtlefuse->txpwr_fromeprom = true;
Joe Perches9cb76aa2014-03-24 10:46:20 -07001634 rtlefuse->eeprom_oemid = hwinfo[EEPROM_CUSTOMER_ID];
Larry Fingerc592e632012-10-25 13:46:32 -05001635
1636 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1637 "EEPROM Customer ID: 0x%2x\n", rtlefuse->eeprom_oemid);
1638
1639 /* set channel paln to world wide 13 */
1640 rtlefuse->channel_plan = COUNTRY_CODE_WORLD_WIDE_13;
1641
1642 if (rtlhal->oem_id == RT_CID_DEFAULT) {
1643 switch (rtlefuse->eeprom_oemid) {
1644 case EEPROM_CID_DEFAULT:
1645 if (rtlefuse->eeprom_did == 0x8176) {
1646 if (CHK_SVID_SMID(0x10EC, 0x6151) ||
1647 CHK_SVID_SMID(0x10EC, 0x6152) ||
1648 CHK_SVID_SMID(0x10EC, 0x6154) ||
1649 CHK_SVID_SMID(0x10EC, 0x6155) ||
1650 CHK_SVID_SMID(0x10EC, 0x6177) ||
1651 CHK_SVID_SMID(0x10EC, 0x6178) ||
1652 CHK_SVID_SMID(0x10EC, 0x6179) ||
1653 CHK_SVID_SMID(0x10EC, 0x6180) ||
1654 CHK_SVID_SMID(0x10EC, 0x8151) ||
1655 CHK_SVID_SMID(0x10EC, 0x8152) ||
1656 CHK_SVID_SMID(0x10EC, 0x8154) ||
1657 CHK_SVID_SMID(0x10EC, 0x8155) ||
1658 CHK_SVID_SMID(0x10EC, 0x8181) ||
1659 CHK_SVID_SMID(0x10EC, 0x8182) ||
1660 CHK_SVID_SMID(0x10EC, 0x8184) ||
1661 CHK_SVID_SMID(0x10EC, 0x8185) ||
1662 CHK_SVID_SMID(0x10EC, 0x9151) ||
1663 CHK_SVID_SMID(0x10EC, 0x9152) ||
1664 CHK_SVID_SMID(0x10EC, 0x9154) ||
1665 CHK_SVID_SMID(0x10EC, 0x9155) ||
1666 CHK_SVID_SMID(0x10EC, 0x9181) ||
1667 CHK_SVID_SMID(0x10EC, 0x9182) ||
1668 CHK_SVID_SMID(0x10EC, 0x9184) ||
1669 CHK_SVID_SMID(0x10EC, 0x9185))
1670 rtlhal->oem_id = RT_CID_TOSHIBA;
1671 else if (rtlefuse->eeprom_svid == 0x1025)
Larry Finger2cddad32014-02-28 15:16:46 -06001672 rtlhal->oem_id = RT_CID_819X_ACER;
Larry Fingerc592e632012-10-25 13:46:32 -05001673 else if (CHK_SVID_SMID(0x10EC, 0x6191) ||
1674 CHK_SVID_SMID(0x10EC, 0x6192) ||
1675 CHK_SVID_SMID(0x10EC, 0x6193) ||
1676 CHK_SVID_SMID(0x10EC, 0x7191) ||
1677 CHK_SVID_SMID(0x10EC, 0x7192) ||
1678 CHK_SVID_SMID(0x10EC, 0x7193) ||
1679 CHK_SVID_SMID(0x10EC, 0x8191) ||
1680 CHK_SVID_SMID(0x10EC, 0x8192) ||
1681 CHK_SVID_SMID(0x10EC, 0x8193))
Larry Finger2cddad32014-02-28 15:16:46 -06001682 rtlhal->oem_id = RT_CID_819X_SAMSUNG;
Larry Fingerc592e632012-10-25 13:46:32 -05001683 else if (CHK_SVID_SMID(0x10EC, 0x8195) ||
1684 CHK_SVID_SMID(0x10EC, 0x9195) ||
1685 CHK_SVID_SMID(0x10EC, 0x7194) ||
1686 CHK_SVID_SMID(0x10EC, 0x8200) ||
1687 CHK_SVID_SMID(0x10EC, 0x8201) ||
1688 CHK_SVID_SMID(0x10EC, 0x8202) ||
1689 CHK_SVID_SMID(0x10EC, 0x9200))
Larry Finger2cddad32014-02-28 15:16:46 -06001690 rtlhal->oem_id = RT_CID_819X_LENOVO;
Larry Fingerc592e632012-10-25 13:46:32 -05001691 else if (CHK_SVID_SMID(0x10EC, 0x8197) ||
1692 CHK_SVID_SMID(0x10EC, 0x9196))
Larry Finger2cddad32014-02-28 15:16:46 -06001693 rtlhal->oem_id = RT_CID_819X_CLEVO;
Larry Fingerc592e632012-10-25 13:46:32 -05001694 else if (CHK_SVID_SMID(0x1028, 0x8194) ||
1695 CHK_SVID_SMID(0x1028, 0x8198) ||
1696 CHK_SVID_SMID(0x1028, 0x9197) ||
1697 CHK_SVID_SMID(0x1028, 0x9198))
Larry Finger2cddad32014-02-28 15:16:46 -06001698 rtlhal->oem_id = RT_CID_819X_DELL;
Larry Fingerc592e632012-10-25 13:46:32 -05001699 else if (CHK_SVID_SMID(0x103C, 0x1629))
Larry Finger2cddad32014-02-28 15:16:46 -06001700 rtlhal->oem_id = RT_CID_819X_HP;
Larry Fingerc592e632012-10-25 13:46:32 -05001701 else if (CHK_SVID_SMID(0x1A32, 0x2315))
Larry Finger2cddad32014-02-28 15:16:46 -06001702 rtlhal->oem_id = RT_CID_819X_QMI;
Larry Fingerc592e632012-10-25 13:46:32 -05001703 else if (CHK_SVID_SMID(0x10EC, 0x8203))
Larry Finger2cddad32014-02-28 15:16:46 -06001704 rtlhal->oem_id = RT_CID_819X_PRONETS;
Larry Fingerc592e632012-10-25 13:46:32 -05001705 else if (CHK_SVID_SMID(0x1043, 0x84B5))
1706 rtlhal->oem_id =
Larry Finger2cddad32014-02-28 15:16:46 -06001707 RT_CID_819X_EDIMAX_ASUS;
Larry Fingerc592e632012-10-25 13:46:32 -05001708 else
1709 rtlhal->oem_id = RT_CID_DEFAULT;
1710 } else if (rtlefuse->eeprom_did == 0x8178) {
1711 if (CHK_SVID_SMID(0x10EC, 0x6181) ||
1712 CHK_SVID_SMID(0x10EC, 0x6182) ||
1713 CHK_SVID_SMID(0x10EC, 0x6184) ||
1714 CHK_SVID_SMID(0x10EC, 0x6185) ||
1715 CHK_SVID_SMID(0x10EC, 0x7181) ||
1716 CHK_SVID_SMID(0x10EC, 0x7182) ||
1717 CHK_SVID_SMID(0x10EC, 0x7184) ||
1718 CHK_SVID_SMID(0x10EC, 0x7185) ||
1719 CHK_SVID_SMID(0x10EC, 0x8181) ||
1720 CHK_SVID_SMID(0x10EC, 0x8182) ||
1721 CHK_SVID_SMID(0x10EC, 0x8184) ||
1722 CHK_SVID_SMID(0x10EC, 0x8185) ||
1723 CHK_SVID_SMID(0x10EC, 0x9181) ||
1724 CHK_SVID_SMID(0x10EC, 0x9182) ||
1725 CHK_SVID_SMID(0x10EC, 0x9184) ||
1726 CHK_SVID_SMID(0x10EC, 0x9185))
1727 rtlhal->oem_id = RT_CID_TOSHIBA;
1728 else if (rtlefuse->eeprom_svid == 0x1025)
Larry Finger2cddad32014-02-28 15:16:46 -06001729 rtlhal->oem_id = RT_CID_819X_ACER;
Larry Fingerc592e632012-10-25 13:46:32 -05001730 else if (CHK_SVID_SMID(0x10EC, 0x8186))
Larry Finger2cddad32014-02-28 15:16:46 -06001731 rtlhal->oem_id = RT_CID_819X_PRONETS;
Larry Fingerc592e632012-10-25 13:46:32 -05001732 else if (CHK_SVID_SMID(0x1043, 0x8486))
1733 rtlhal->oem_id =
Larry Finger2cddad32014-02-28 15:16:46 -06001734 RT_CID_819X_EDIMAX_ASUS;
Larry Fingerc592e632012-10-25 13:46:32 -05001735 else
1736 rtlhal->oem_id = RT_CID_DEFAULT;
1737 } else {
1738 rtlhal->oem_id = RT_CID_DEFAULT;
1739 }
1740 break;
1741 case EEPROM_CID_TOSHIBA:
1742 rtlhal->oem_id = RT_CID_TOSHIBA;
1743 break;
1744 case EEPROM_CID_CCX:
1745 rtlhal->oem_id = RT_CID_CCX;
1746 break;
1747 case EEPROM_CID_QMI:
Larry Finger2cddad32014-02-28 15:16:46 -06001748 rtlhal->oem_id = RT_CID_819X_QMI;
Larry Fingerc592e632012-10-25 13:46:32 -05001749 break;
1750 case EEPROM_CID_WHQL:
1751 break;
1752 default:
1753 rtlhal->oem_id = RT_CID_DEFAULT;
1754 break;
1755
1756 }
1757 }
1758}
1759
1760static void _rtl8723ae_hal_customized_behavior(struct ieee80211_hw *hw)
1761{
1762 struct rtl_priv *rtlpriv = rtl_priv(hw);
1763 struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw);
1764 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
1765
Larry Fingere6deaf82013-03-24 22:06:55 -05001766 pcipriv->ledctl.led_opendrain = true;
Larry Fingerc592e632012-10-25 13:46:32 -05001767 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
1768 "RT Customized ID: 0x%02X\n", rtlhal->oem_id);
1769}
1770
1771void rtl8723ae_read_eeprom_info(struct ieee80211_hw *hw)
1772{
1773 struct rtl_priv *rtlpriv = rtl_priv(hw);
1774 struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
1775 struct rtl_phy *rtlphy = &(rtlpriv->phy);
1776 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
1777 u8 tmp_u1b;
1778 u32 value32;
1779
1780 value32 = rtl_read_dword(rtlpriv, rtlpriv->cfg->maps[EFUSE_TEST]);
1781 value32 = (value32 & ~EFUSE_SEL_MASK) | EFUSE_SEL(EFUSE_WIFI_SEL_0);
1782 rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[EFUSE_TEST], value32);
1783
1784 rtlhal->version = _rtl8723ae_read_chip_version(hw);
1785
1786 if (get_rf_type(rtlphy) == RF_1T1R)
1787 rtlpriv->dm.rfpath_rxenable[0] = true;
1788 else
1789 rtlpriv->dm.rfpath_rxenable[0] =
1790 rtlpriv->dm.rfpath_rxenable[1] = true;
1791 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "VersionID = 0x%4x\n",
1792 rtlhal->version);
1793
1794 tmp_u1b = rtl_read_byte(rtlpriv, REG_9346CR);
1795 if (tmp_u1b & BIT(4)) {
1796 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "Boot from EEPROM\n");
1797 rtlefuse->epromtype = EEPROM_93C46;
1798 } else {
1799 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "Boot from EFUSE\n");
1800 rtlefuse->epromtype = EEPROM_BOOT_EFUSE;
1801 }
1802 if (tmp_u1b & BIT(5)) {
1803 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Autoload OK\n");
1804 rtlefuse->autoload_failflag = false;
1805 _rtl8723ae_read_adapter_info(hw, false);
1806 } else {
1807 rtlefuse->autoload_failflag = true;
1808 _rtl8723ae_read_adapter_info(hw, false);
1809 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Autoload ERR!!\n");
1810 }
1811 _rtl8723ae_hal_customized_behavior(hw);
1812}
1813
1814static void rtl8723ae_update_hal_rate_table(struct ieee80211_hw *hw,
1815 struct ieee80211_sta *sta)
1816{
1817 struct rtl_priv *rtlpriv = rtl_priv(hw);
1818 struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw);
1819 struct rtl_phy *rtlphy = &(rtlpriv->phy);
1820 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
1821 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
1822 u32 ratr_value;
1823 u8 ratr_index = 0;
1824 u8 nmode = mac->ht_enable;
1825 u8 mimo_ps = IEEE80211_SMPS_OFF;
1826 u8 curtxbw_40mhz = mac->bw_40;
1827 u8 curshortgi_40mhz = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40) ?
1828 1 : 0;
1829 u8 curshortgi_20mhz = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20) ?
1830 1 : 0;
1831 enum wireless_mode wirelessmode = mac->mode;
1832
1833 if (rtlhal->current_bandtype == BAND_ON_5G)
1834 ratr_value = sta->supp_rates[1] << 4;
1835 else
1836 ratr_value = sta->supp_rates[0];
1837 if (mac->opmode == NL80211_IFTYPE_ADHOC)
1838 ratr_value = 0xfff;
1839 ratr_value |= (sta->ht_cap.mcs.rx_mask[1] << 20 |
1840 sta->ht_cap.mcs.rx_mask[0] << 12);
1841 switch (wirelessmode) {
1842 case WIRELESS_MODE_B:
1843 if (ratr_value & 0x0000000c)
1844 ratr_value &= 0x0000000d;
1845 else
1846 ratr_value &= 0x0000000f;
1847 break;
1848 case WIRELESS_MODE_G:
1849 ratr_value &= 0x00000FF5;
1850 break;
1851 case WIRELESS_MODE_N_24G:
1852 case WIRELESS_MODE_N_5G:
1853 nmode = 1;
1854 if (mimo_ps == IEEE80211_SMPS_STATIC) {
1855 ratr_value &= 0x0007F005;
1856 } else {
1857 u32 ratr_mask;
1858
1859 if (get_rf_type(rtlphy) == RF_1T2R ||
1860 get_rf_type(rtlphy) == RF_1T1R)
1861 ratr_mask = 0x000ff005;
1862 else
1863 ratr_mask = 0x0f0ff005;
1864
1865 ratr_value &= ratr_mask;
1866 }
1867 break;
1868 default:
1869 if (rtlphy->rf_type == RF_1T2R)
1870 ratr_value &= 0x000ff0ff;
1871 else
1872 ratr_value &= 0x0f0ff0ff;
1873
1874 break;
1875 }
1876
1877 if ((pcipriv->bt_coexist.bt_coexistence) &&
1878 (pcipriv->bt_coexist.bt_coexist_type == BT_CSR_BC4) &&
1879 (pcipriv->bt_coexist.bt_cur_state) &&
1880 (pcipriv->bt_coexist.bt_ant_isolation) &&
1881 ((pcipriv->bt_coexist.bt_service == BT_SCO) ||
1882 (pcipriv->bt_coexist.bt_service == BT_BUSY)))
1883 ratr_value &= 0x0fffcfc0;
1884 else
1885 ratr_value &= 0x0FFFFFFF;
1886
1887 if (nmode && ((curtxbw_40mhz && curshortgi_40mhz) ||
1888 (!curtxbw_40mhz && curshortgi_20mhz)))
1889 ratr_value |= 0x10000000;
1890
1891 rtl_write_dword(rtlpriv, REG_ARFR0 + ratr_index * 4, ratr_value);
1892
1893 RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG,
1894 "%x\n", rtl_read_dword(rtlpriv, REG_ARFR0));
1895}
1896
1897static void rtl8723ae_update_hal_rate_mask(struct ieee80211_hw *hw,
1898 struct ieee80211_sta *sta, u8 rssi_level)
1899{
1900 struct rtl_priv *rtlpriv = rtl_priv(hw);
1901 struct rtl_phy *rtlphy = &(rtlpriv->phy);
1902 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
1903 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
1904 struct rtl_sta_info *sta_entry = NULL;
1905 u32 ratr_bitmap;
1906 u8 ratr_index;
Johannes Berge1a0c6b2013-02-07 11:47:44 +01001907 u8 curtxbw_40mhz = (sta->bandwidth >= IEEE80211_STA_RX_BW_40) ? 1 : 0;
Larry Fingerc592e632012-10-25 13:46:32 -05001908 u8 curshortgi_40mhz = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40) ?
1909 1 : 0;
1910 u8 curshortgi_20mhz = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20) ?
1911 1 : 0;
1912 enum wireless_mode wirelessmode = 0;
1913 bool shortgi = false;
1914 u8 rate_mask[5];
1915 u8 macid = 0;
1916 u8 mimo_ps = IEEE80211_SMPS_OFF;
1917
1918 sta_entry = (struct rtl_sta_info *) sta->drv_priv;
1919 wirelessmode = sta_entry->wireless_mode;
1920 if (mac->opmode == NL80211_IFTYPE_STATION)
1921 curtxbw_40mhz = mac->bw_40;
1922 else if (mac->opmode == NL80211_IFTYPE_AP ||
1923 mac->opmode == NL80211_IFTYPE_ADHOC)
1924 macid = sta->aid + 1;
1925
1926 if (rtlhal->current_bandtype == BAND_ON_5G)
1927 ratr_bitmap = sta->supp_rates[1] << 4;
1928 else
1929 ratr_bitmap = sta->supp_rates[0];
1930 if (mac->opmode == NL80211_IFTYPE_ADHOC)
1931 ratr_bitmap = 0xfff;
1932 ratr_bitmap |= (sta->ht_cap.mcs.rx_mask[1] << 20 |
1933 sta->ht_cap.mcs.rx_mask[0] << 12);
1934 switch (wirelessmode) {
1935 case WIRELESS_MODE_B:
1936 ratr_index = RATR_INX_WIRELESS_B;
1937 if (ratr_bitmap & 0x0000000c)
1938 ratr_bitmap &= 0x0000000d;
1939 else
1940 ratr_bitmap &= 0x0000000f;
1941 break;
1942 case WIRELESS_MODE_G:
1943 ratr_index = RATR_INX_WIRELESS_GB;
1944
1945 if (rssi_level == 1)
1946 ratr_bitmap &= 0x00000f00;
1947 else if (rssi_level == 2)
1948 ratr_bitmap &= 0x00000ff0;
1949 else
1950 ratr_bitmap &= 0x00000ff5;
1951 break;
1952 case WIRELESS_MODE_A:
1953 ratr_index = RATR_INX_WIRELESS_A;
1954 ratr_bitmap &= 0x00000ff0;
1955 break;
1956 case WIRELESS_MODE_N_24G:
1957 case WIRELESS_MODE_N_5G:
1958 ratr_index = RATR_INX_WIRELESS_NGB;
1959
1960 if (mimo_ps == IEEE80211_SMPS_STATIC) {
1961 if (rssi_level == 1)
1962 ratr_bitmap &= 0x00070000;
1963 else if (rssi_level == 2)
1964 ratr_bitmap &= 0x0007f000;
1965 else
1966 ratr_bitmap &= 0x0007f005;
1967 } else {
1968 if (rtlphy->rf_type == RF_1T2R ||
1969 rtlphy->rf_type == RF_1T1R) {
1970 if (curtxbw_40mhz) {
1971 if (rssi_level == 1)
1972 ratr_bitmap &= 0x000f0000;
1973 else if (rssi_level == 2)
1974 ratr_bitmap &= 0x000ff000;
1975 else
1976 ratr_bitmap &= 0x000ff015;
1977 } else {
1978 if (rssi_level == 1)
1979 ratr_bitmap &= 0x000f0000;
1980 else if (rssi_level == 2)
1981 ratr_bitmap &= 0x000ff000;
1982 else
1983 ratr_bitmap &= 0x000ff005;
1984 }
1985 } else {
1986 if (curtxbw_40mhz) {
1987 if (rssi_level == 1)
1988 ratr_bitmap &= 0x0f0f0000;
1989 else if (rssi_level == 2)
1990 ratr_bitmap &= 0x0f0ff000;
1991 else
1992 ratr_bitmap &= 0x0f0ff015;
1993 } else {
1994 if (rssi_level == 1)
1995 ratr_bitmap &= 0x0f0f0000;
1996 else if (rssi_level == 2)
1997 ratr_bitmap &= 0x0f0ff000;
1998 else
1999 ratr_bitmap &= 0x0f0ff005;
2000 }
2001 }
2002 }
2003
2004 if ((curtxbw_40mhz && curshortgi_40mhz) ||
2005 (!curtxbw_40mhz && curshortgi_20mhz)) {
2006 if (macid == 0)
2007 shortgi = true;
2008 else if (macid == 1)
2009 shortgi = false;
2010 }
2011 break;
2012 default:
2013 ratr_index = RATR_INX_WIRELESS_NGB;
2014
2015 if (rtlphy->rf_type == RF_1T2R)
2016 ratr_bitmap &= 0x000ff0ff;
2017 else
2018 ratr_bitmap &= 0x0f0ff0ff;
2019 break;
2020 }
2021 sta_entry->ratr_index = ratr_index;
2022
2023 RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG,
2024 "ratr_bitmap :%x\n", ratr_bitmap);
2025 /* convert ratr_bitmap to le byte array */
2026 rate_mask[0] = ratr_bitmap;
2027 rate_mask[1] = (ratr_bitmap >>= 8);
2028 rate_mask[2] = (ratr_bitmap >>= 8);
2029 rate_mask[3] = ((ratr_bitmap >> 8) & 0x0f) | (ratr_index << 4);
2030 rate_mask[4] = macid | (shortgi ? 0x20 : 0x00) | 0x80;
2031 RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG,
2032 "Rate_index:%x, ratr_bitmap: %*phC\n",
2033 ratr_index, 5, rate_mask);
2034 rtl8723ae_fill_h2c_cmd(hw, H2C_RA_MASK, 5, rate_mask);
2035}
2036
2037void rtl8723ae_update_hal_rate_tbl(struct ieee80211_hw *hw,
2038 struct ieee80211_sta *sta, u8 rssi_level)
2039{
2040 struct rtl_priv *rtlpriv = rtl_priv(hw);
2041
2042 if (rtlpriv->dm.useramask)
2043 rtl8723ae_update_hal_rate_mask(hw, sta, rssi_level);
2044 else
2045 rtl8723ae_update_hal_rate_table(hw, sta);
2046}
2047
2048void rtl8723ae_update_channel_access_setting(struct ieee80211_hw *hw)
2049{
2050 struct rtl_priv *rtlpriv = rtl_priv(hw);
2051 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
2052 u16 sifs_timer;
2053
Joe Perches9cb76aa2014-03-24 10:46:20 -07002054 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SLOT_TIME, &mac->slot_time);
Larry Fingerc592e632012-10-25 13:46:32 -05002055 if (!mac->ht_enable)
2056 sifs_timer = 0x0a0a;
2057 else
2058 sifs_timer = 0x1010;
2059 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SIFS, (u8 *)&sifs_timer);
2060}
2061
2062bool rtl8723ae_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 *valid)
2063{
2064 struct rtl_priv *rtlpriv = rtl_priv(hw);
2065 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
2066 struct rtl_phy *rtlphy = &(rtlpriv->phy);
Larry Fingerb26f5f02013-02-01 10:40:27 -06002067 enum rf_pwrstate e_rfpowerstate_toset;
Larry Fingerc592e632012-10-25 13:46:32 -05002068 u8 u1tmp;
2069 bool actuallyset = false;
2070
2071 if (rtlpriv->rtlhal.being_init_adapter)
2072 return false;
2073
2074 if (ppsc->swrf_processing)
2075 return false;
2076
2077 spin_lock(&rtlpriv->locks.rf_ps_lock);
2078 if (ppsc->rfchange_inprogress) {
2079 spin_unlock(&rtlpriv->locks.rf_ps_lock);
2080 return false;
2081 } else {
2082 ppsc->rfchange_inprogress = true;
2083 spin_unlock(&rtlpriv->locks.rf_ps_lock);
2084 }
2085
Larry Fingerc592e632012-10-25 13:46:32 -05002086 rtl_write_byte(rtlpriv, REG_GPIO_IO_SEL_2,
2087 rtl_read_byte(rtlpriv, REG_GPIO_IO_SEL_2)&~(BIT(1)));
2088
2089 u1tmp = rtl_read_byte(rtlpriv, REG_GPIO_PIN_CTRL_2);
2090
2091 if (rtlphy->polarity_ctl)
2092 e_rfpowerstate_toset = (u1tmp & BIT(1)) ? ERFOFF : ERFON;
2093 else
2094 e_rfpowerstate_toset = (u1tmp & BIT(1)) ? ERFON : ERFOFF;
2095
2096 if ((ppsc->hwradiooff == true) && (e_rfpowerstate_toset == ERFON)) {
2097 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG,
2098 "GPIOChangeRF - HW Radio ON, RF ON\n");
2099
2100 e_rfpowerstate_toset = ERFON;
2101 ppsc->hwradiooff = false;
2102 actuallyset = true;
2103 } else if ((ppsc->hwradiooff == false)
2104 && (e_rfpowerstate_toset == ERFOFF)) {
2105 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG,
2106 "GPIOChangeRF - HW Radio OFF, RF OFF\n");
2107
2108 e_rfpowerstate_toset = ERFOFF;
2109 ppsc->hwradiooff = true;
2110 actuallyset = true;
2111 }
2112
2113 if (actuallyset) {
2114 spin_lock(&rtlpriv->locks.rf_ps_lock);
2115 ppsc->rfchange_inprogress = false;
2116 spin_unlock(&rtlpriv->locks.rf_ps_lock);
2117 } else {
2118 if (ppsc->reg_rfps_level & RT_RF_OFF_LEVL_HALT_NIC)
2119 RT_SET_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC);
2120
2121 spin_lock(&rtlpriv->locks.rf_ps_lock);
2122 ppsc->rfchange_inprogress = false;
2123 spin_unlock(&rtlpriv->locks.rf_ps_lock);
2124 }
2125
2126 *valid = 1;
2127 return !ppsc->hwradiooff;
2128}
2129
2130void rtl8723ae_set_key(struct ieee80211_hw *hw, u32 key_index,
2131 u8 *p_macaddr, bool is_group, u8 enc_algo,
2132 bool is_wepkey, bool clear_all)
2133{
2134 struct rtl_priv *rtlpriv = rtl_priv(hw);
2135 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
2136 struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
2137 u8 *macaddr = p_macaddr;
2138 u32 entry_id = 0;
2139 bool is_pairwise = false;
2140 static u8 cam_const_addr[4][6] = {
2141 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
2142 {0x00, 0x00, 0x00, 0x00, 0x00, 0x01},
2143 {0x00, 0x00, 0x00, 0x00, 0x00, 0x02},
2144 {0x00, 0x00, 0x00, 0x00, 0x00, 0x03}
2145 };
2146 static u8 cam_const_broad[] = {
2147 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
2148 };
2149
2150 if (clear_all) {
2151 u8 idx = 0;
2152 u8 cam_offset = 0;
2153 u8 clear_number = 5;
2154
2155 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "clear_all\n");
2156
2157 for (idx = 0; idx < clear_number; idx++) {
2158 rtl_cam_mark_invalid(hw, cam_offset + idx);
2159 rtl_cam_empty_entry(hw, cam_offset + idx);
2160
2161 if (idx < 5) {
2162 memset(rtlpriv->sec.key_buf[idx], 0,
2163 MAX_KEY_LEN);
2164 rtlpriv->sec.key_len[idx] = 0;
2165 }
2166 }
2167 } else {
2168 switch (enc_algo) {
2169 case WEP40_ENCRYPTION:
2170 enc_algo = CAM_WEP40;
2171 break;
2172 case WEP104_ENCRYPTION:
2173 enc_algo = CAM_WEP104;
2174 break;
2175 case TKIP_ENCRYPTION:
2176 enc_algo = CAM_TKIP;
2177 break;
2178 case AESCCMP_ENCRYPTION:
2179 enc_algo = CAM_AES;
2180 break;
2181 default:
2182 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
2183 "switch case not processed\n");
2184 enc_algo = CAM_TKIP;
2185 break;
2186 }
2187
2188 if (is_wepkey || rtlpriv->sec.use_defaultkey) {
2189 macaddr = cam_const_addr[key_index];
2190 entry_id = key_index;
2191 } else {
2192 if (is_group) {
2193 macaddr = cam_const_broad;
2194 entry_id = key_index;
2195 } else {
2196 if (mac->opmode == NL80211_IFTYPE_AP) {
2197 entry_id = rtl_cam_get_free_entry(hw,
2198 macaddr);
2199 if (entry_id >= TOTAL_CAM_ENTRY) {
2200 RT_TRACE(rtlpriv, COMP_SEC,
2201 DBG_EMERG,
2202 "Can not find free hw security cam entry\n");
2203 return;
2204 }
2205 } else {
2206 entry_id = CAM_PAIRWISE_KEY_POSITION;
2207 }
2208
2209 key_index = PAIRWISE_KEYIDX;
2210 is_pairwise = true;
2211 }
2212 }
2213
2214 if (rtlpriv->sec.key_len[key_index] == 0) {
2215 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
2216 "delete one entry, entry_id is %d\n",
2217 entry_id);
2218 if (mac->opmode == NL80211_IFTYPE_AP)
2219 rtl_cam_del_entry(hw, p_macaddr);
2220 rtl_cam_delete_one_entry(hw, p_macaddr, entry_id);
2221 } else {
2222 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
2223 "add one entry\n");
2224 if (is_pairwise) {
2225 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
2226 "set Pairwiase key\n");
2227
2228 rtl_cam_add_one_entry(hw, macaddr, key_index,
2229 entry_id, enc_algo,
2230 CAM_CONFIG_NO_USEDK,
2231 rtlpriv->sec.key_buf[key_index]);
2232 } else {
2233 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
2234 "set group key\n");
2235
2236 if (mac->opmode == NL80211_IFTYPE_ADHOC) {
2237 rtl_cam_add_one_entry(hw,
2238 rtlefuse->dev_addr,
2239 PAIRWISE_KEYIDX,
2240 CAM_PAIRWISE_KEY_POSITION,
2241 enc_algo,
2242 CAM_CONFIG_NO_USEDK,
2243 rtlpriv->sec.key_buf
2244 [entry_id]);
2245 }
2246
2247 rtl_cam_add_one_entry(hw, macaddr, key_index,
2248 entry_id, enc_algo,
2249 CAM_CONFIG_NO_USEDK,
2250 rtlpriv->sec.key_buf[entry_id]);
2251 }
2252
2253 }
2254 }
2255}
2256
2257static void rtl8723ae_bt_var_init(struct ieee80211_hw *hw)
2258{
2259 struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw);
2260 struct rtl_priv *rtlpriv = rtl_priv(hw);
2261
2262 pcipriv->bt_coexist.bt_coexistence =
2263 pcipriv->bt_coexist.eeprom_bt_coexist;
2264 pcipriv->bt_coexist.bt_ant_num =
2265 pcipriv->bt_coexist.eeprom_bt_ant_num;
2266 pcipriv->bt_coexist.bt_coexist_type =
2267 pcipriv->bt_coexist.eeprom_bt_type;
2268
2269 pcipriv->bt_coexist.bt_ant_isolation =
2270 pcipriv->bt_coexist.eeprom_bt_ant_isol;
2271
2272 pcipriv->bt_coexist.bt_radio_shared_type =
2273 pcipriv->bt_coexist.eeprom_bt_radio_shared;
2274
2275 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE,
2276 "BT Coexistance = 0x%x\n",
2277 pcipriv->bt_coexist.bt_coexistence);
2278
2279 if (pcipriv->bt_coexist.bt_coexistence) {
2280 pcipriv->bt_coexist.bt_busy_traffic = false;
2281 pcipriv->bt_coexist.bt_traffic_mode_set = false;
2282 pcipriv->bt_coexist.bt_non_traffic_mode_set = false;
2283
2284 pcipriv->bt_coexist.cstate = 0;
2285 pcipriv->bt_coexist.previous_state = 0;
2286
2287 if (pcipriv->bt_coexist.bt_ant_num == ANT_X2) {
2288 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE,
2289 "BlueTooth BT_Ant_Num = Antx2\n");
2290 } else if (pcipriv->bt_coexist.bt_ant_num == ANT_X1) {
2291 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE,
2292 "BlueTooth BT_Ant_Num = Antx1\n");
2293 }
2294
2295 switch (pcipriv->bt_coexist.bt_coexist_type) {
2296 case BT_2WIRE:
2297 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE,
2298 "BlueTooth BT_CoexistType = BT_2Wire\n");
2299 break;
2300 case BT_ISSC_3WIRE:
2301 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE,
2302 "BlueTooth BT_CoexistType = BT_ISSC_3Wire\n");
2303 break;
2304 case BT_ACCEL:
2305 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE,
2306 "BlueTooth BT_CoexistType = BT_ACCEL\n");
2307 break;
2308 case BT_CSR_BC4:
2309 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE,
2310 "BlueTooth BT_CoexistType = BT_CSR_BC4\n");
2311 break;
2312 case BT_CSR_BC8:
2313 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE,
2314 "BlueTooth BT_CoexistType = BT_CSR_BC8\n");
2315 break;
2316 case BT_RTL8756:
2317 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE,
2318 "BlueTooth BT_CoexistType = BT_RTL8756\n");
2319 break;
2320 default:
2321 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE,
2322 "BlueTooth BT_CoexistType = Unknown\n");
2323 break;
2324 }
2325 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE,
2326 "BlueTooth BT_Ant_isolation = %d\n",
2327 pcipriv->bt_coexist.bt_ant_isolation);
2328 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE,
2329 "BT_RadioSharedType = 0x%x\n",
2330 pcipriv->bt_coexist.bt_radio_shared_type);
2331 pcipriv->bt_coexist.bt_active_zero_cnt = 0;
2332 pcipriv->bt_coexist.cur_bt_disabled = false;
2333 pcipriv->bt_coexist.pre_bt_disabled = false;
2334 }
2335}
2336
2337void rtl8723ae_read_bt_coexist_info_from_hwpg(struct ieee80211_hw *hw,
2338 bool auto_load_fail, u8 *hwinfo)
2339{
2340 struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw);
2341 struct rtl_priv *rtlpriv = rtl_priv(hw);
2342 u8 value;
2343 u32 tmpu_32;
2344
2345 if (!auto_load_fail) {
2346 tmpu_32 = rtl_read_dword(rtlpriv, REG_MULTI_FUNC_CTRL);
2347 if (tmpu_32 & BIT(18))
2348 pcipriv->bt_coexist.eeprom_bt_coexist = 1;
2349 else
2350 pcipriv->bt_coexist.eeprom_bt_coexist = 0;
2351 value = hwinfo[RF_OPTION4];
2352 pcipriv->bt_coexist.eeprom_bt_type = BT_RTL8723A;
2353 pcipriv->bt_coexist.eeprom_bt_ant_num = (value & 0x1);
2354 pcipriv->bt_coexist.eeprom_bt_ant_isol = ((value & 0x10) >> 4);
2355 pcipriv->bt_coexist.eeprom_bt_radio_shared =
2356 ((value & 0x20) >> 5);
2357 } else {
2358 pcipriv->bt_coexist.eeprom_bt_coexist = 0;
2359 pcipriv->bt_coexist.eeprom_bt_type = BT_RTL8723A;
2360 pcipriv->bt_coexist.eeprom_bt_ant_num = ANT_X2;
2361 pcipriv->bt_coexist.eeprom_bt_ant_isol = 0;
2362 pcipriv->bt_coexist.eeprom_bt_radio_shared = BT_RADIO_SHARED;
2363 }
2364
2365 rtl8723ae_bt_var_init(hw);
2366}
2367
2368void rtl8723ae_bt_reg_init(struct ieee80211_hw *hw)
2369{
2370 struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw);
2371
2372 /* 0:Low, 1:High, 2:From Efuse. */
2373 pcipriv->bt_coexist.reg_bt_iso = 2;
2374 /* 0:Idle, 1:None-SCO, 2:SCO, 3:From Counter. */
2375 pcipriv->bt_coexist.reg_bt_sco = 3;
2376 /* 0:Disable BT control A-MPDU, 1:Enable BT control A-MPDU. */
2377 pcipriv->bt_coexist.reg_bt_sco = 0;
2378}
2379
2380
2381void rtl8723ae_bt_hw_init(struct ieee80211_hw *hw)
2382{
2383}
2384
2385void rtl8723ae_suspend(struct ieee80211_hw *hw)
2386{
2387}
2388
2389void rtl8723ae_resume(struct ieee80211_hw *hw)
2390{
2391}
2392
2393/* Turn on AAP (RCR:bit 0) for promicuous mode. */
2394void rtl8723ae_allow_all_destaddr(struct ieee80211_hw *hw,
2395 bool allow_all_da, bool write_into_reg)
2396{
2397 struct rtl_priv *rtlpriv = rtl_priv(hw);
2398 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
2399
2400 if (allow_all_da) /* Set BIT0 */
2401 rtlpci->receive_config |= RCR_AAP;
2402 else /* Clear BIT0 */
2403 rtlpci->receive_config &= ~RCR_AAP;
2404
2405 if (write_into_reg)
2406 rtl_write_dword(rtlpriv, REG_RCR, rtlpci->receive_config);
2407
2408
2409 RT_TRACE(rtlpriv, COMP_TURBO | COMP_INIT, DBG_LOUD,
2410 "receive_config=0x%08X, write_into_reg=%d\n",
2411 rtlpci->receive_config, write_into_reg);
2412}