1 /******************************************************************************
3 * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
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 ******************************************************************************/
17 #include <linux/firmware.h>
18 #include <drv_types.h>
19 #include <rtw_efuse.h>
21 #include <rtl8723a_hal.h>
22 #include <usb_ops_linux.h>
24 static void _FWDownloadEnable(struct rtw_adapter
*padapter
, bool enable
)
30 tmp
= rtl8723au_read8(padapter
, REG_SYS_FUNC_EN
+ 1);
31 rtl8723au_write8(padapter
, REG_SYS_FUNC_EN
+ 1, tmp
| 0x04);
33 /* MCU firmware download enable. */
34 tmp
= rtl8723au_read8(padapter
, REG_MCUFWDL
);
35 rtl8723au_write8(padapter
, REG_MCUFWDL
, tmp
| 0x01);
38 tmp
= rtl8723au_read8(padapter
, REG_MCUFWDL
+ 2);
39 rtl8723au_write8(padapter
, REG_MCUFWDL
+ 2, tmp
& 0xf7);
41 /* MCU firmware download disable. */
42 tmp
= rtl8723au_read8(padapter
, REG_MCUFWDL
);
43 rtl8723au_write8(padapter
, REG_MCUFWDL
, tmp
& 0xfe);
45 /* Reserved for fw extension. */
46 rtl8723au_write8(padapter
, REG_MCUFWDL
+ 1, 0x00);
50 static int _BlockWrite(struct rtw_adapter
*padapter
, void *buffer
, u32 buffSize
)
54 if (buffSize
> MAX_PAGE_SIZE
)
57 ret
= rtl8723au_writeN(padapter
, FW_8723A_START_ADDRESS
,
64 _PageWrite(struct rtw_adapter
*padapter
, u32 page
, void *buffer
, u32 size
)
67 u8 u8Page
= (u8
) (page
& 0x07);
69 value8
= (rtl8723au_read8(padapter
, REG_MCUFWDL
+ 2) & 0xF8) | u8Page
;
70 rtl8723au_write8(padapter
, REG_MCUFWDL
+ 2, value8
);
72 return _BlockWrite(padapter
, buffer
, size
);
75 static int _WriteFW(struct rtw_adapter
*padapter
, void *buffer
, u32 size
)
77 /* Since we need dynamic decide method of dwonload fw, so we
78 call this function to get chip version. */
79 /* We can remove _ReadChipVersion from ReadpadapterInfo8192C later. */
81 u32 pageNums
, remainSize
;
83 u8
*bufferPtr
= (u8
*) buffer
;
85 pageNums
= size
/ MAX_PAGE_SIZE
;
86 /* RT_ASSERT((pageNums <= 4),
87 ("Page numbers should not greater then 4 \n")); */
88 remainSize
= size
% MAX_PAGE_SIZE
;
90 for (page
= 0; page
< pageNums
; page
++) {
91 offset
= page
* MAX_PAGE_SIZE
;
92 ret
= _PageWrite(padapter
, page
, bufferPtr
+ offset
,
99 offset
= pageNums
* MAX_PAGE_SIZE
;
101 ret
= _PageWrite(padapter
, page
, bufferPtr
+ offset
,
107 RT_TRACE(_module_hal_init_c_
, _drv_info_
,
108 ("_WriteFW Done- for Normal chip.\n"));
114 static int _FWFreeToGo(struct rtw_adapter
*padapter
)
119 /* polling CheckSum report */
121 value32
= rtl8723au_read32(padapter
, REG_MCUFWDL
);
122 if (value32
& FWDL_ChkSum_rpt
)
124 } while (counter
++ < POLLING_READY_TIMEOUT_COUNT
);
126 if (counter
>= POLLING_READY_TIMEOUT_COUNT
) {
127 RT_TRACE(_module_hal_init_c_
, _drv_err_
,
128 ("%s: chksum report fail! REG_MCUFWDL:0x%08x\n",
132 RT_TRACE(_module_hal_init_c_
, _drv_info_
,
133 ("%s: Checksum report OK! REG_MCUFWDL:0x%08x\n", __func__
,
136 value32
= rtl8723au_read32(padapter
, REG_MCUFWDL
);
137 value32
|= MCUFWDL_RDY
;
138 value32
&= ~WINTINI_RDY
;
139 rtl8723au_write32(padapter
, REG_MCUFWDL
, value32
);
141 /* polling for FW ready */
144 value32
= rtl8723au_read32(padapter
, REG_MCUFWDL
);
145 if (value32
& WINTINI_RDY
) {
146 RT_TRACE(_module_hal_init_c_
, _drv_info_
,
147 ("%s: Polling FW ready success!! "
148 "REG_MCUFWDL:0x%08x\n",
153 } while (counter
++ < POLLING_READY_TIMEOUT_COUNT
);
155 RT_TRACE(_module_hal_init_c_
, _drv_err_
,
156 ("%s: Polling FW ready fail!! REG_MCUFWDL:0x%08x\n",
161 #define IS_FW_81xxC(padapter) (((GET_HAL_DATA(padapter))->FirmwareSignature & 0xFFF0) == 0x88C0)
163 void rtl8723a_FirmwareSelfReset(struct rtw_adapter
*padapter
)
165 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
169 if (!(IS_FW_81xxC(padapter
) &&
170 ((pHalData
->FirmwareVersion
< 0x21) ||
171 (pHalData
->FirmwareVersion
== 0x21 &&
172 pHalData
->FirmwareSubVersion
< 0x01)))) {
173 /* after 88C Fw v33.1 */
174 /* 0x1cf = 0x20. Inform 8051 to reset. 2009.12.25. tynli_test */
175 rtl8723au_write8(padapter
, REG_HMETFR
+ 3, 0x20);
177 u1bTmp
= rtl8723au_read8(padapter
, REG_SYS_FUNC_EN
+ 1);
178 while (u1bTmp
& BIT(2)) {
183 u1bTmp
= rtl8723au_read8(padapter
, REG_SYS_FUNC_EN
+ 1);
185 RT_TRACE(_module_hal_init_c_
, _drv_info_
,
186 ("-%s: 8051 reset success (%d)\n", __func__
,
190 /* force firmware reset */
191 u1bTmp
= rtl8723au_read8(padapter
, REG_SYS_FUNC_EN
+ 1);
192 rtl8723au_write8(padapter
, REG_SYS_FUNC_EN
+ 1,
200 /* Download 8192C firmware code. */
203 int rtl8723a_FirmwareDownload(struct rtw_adapter
*padapter
)
205 int rtStatus
= _SUCCESS
;
206 u8 writeFW_retry
= 0;
207 unsigned long fwdl_start_time
;
208 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
209 struct dvobj_priv
*dvobj
= adapter_to_dvobj(padapter
);
210 struct device
*device
= dvobj_to_dev(dvobj
);
211 struct rt_8723a_firmware_hdr
*pFwHdr
= NULL
;
212 const struct firmware
*fw
;
214 u8
*firmware_buf
= NULL
;
217 static int log_version
;
219 RT_TRACE(_module_hal_init_c_
, _drv_info_
, ("+%s\n", __func__
));
221 if (IS_8723A_A_CUT(pHalData
->VersionID
)) {
222 fw_name
= "rtlwifi/rtl8723aufw_A.bin";
223 RT_TRACE(_module_hal_init_c_
, _drv_info_
,
224 ("rtl8723a_FirmwareDownload: R8723FwImageArray_UMC "
225 "for RTL8723A A CUT\n"));
226 } else if (IS_8723A_B_CUT(pHalData
->VersionID
)) {
228 if (padapter
->registrypriv
.wifi_spec
== 1) {
229 fw_name
= "rtlwifi/rtl8723aufw_B_NoBT.bin";
230 DBG_8723A(" Rtl8723_FwUMCBCutImageArrayWithoutBT for "
233 if (rtl8723a_BT_coexist(padapter
)) {
234 fw_name
= "rtlwifi/rtl8723aufw_B.bin";
235 DBG_8723A(" Rtl8723_FwUMCBCutImageArrayWithBT "
236 "for RTL8723A B CUT\n");
238 fw_name
= "rtlwifi/rtl8723aufw_B_NoBT.bin";
239 DBG_8723A(" Rtl8723_FwUMCBCutImageArrayWithout "
240 "BT for RTL8723A B CUT\n");
244 /* <Roger_TODO> We should download proper RAM Code here
245 to match the ROM code. */
246 RT_TRACE(_module_hal_init_c_
, _drv_err_
,
247 ("%s: unknow version!\n", __func__
));
252 pr_info("rtl8723au: Loading firmware %s\n", fw_name
);
253 if (request_firmware(&fw
, fw_name
, device
)) {
254 pr_err("rtl8723au: request_firmware load failed\n");
259 pr_err("rtl8723au: Firmware %s not available\n", fw_name
);
263 firmware_buf
= kmemdup(fw
->data
, fw
->size
, GFP_KERNEL
);
270 release_firmware(fw
);
272 /* To Check Fw header. Added by tynli. 2009.12.04. */
273 pFwHdr
= (struct rt_8723a_firmware_hdr
*)firmware_buf
;
275 pHalData
->FirmwareVersion
= le16_to_cpu(pFwHdr
->Version
);
276 pHalData
->FirmwareSubVersion
= pFwHdr
->Subversion
;
277 pHalData
->FirmwareSignature
= le16_to_cpu(pFwHdr
->Signature
);
279 DBG_8723A("%s: fw_ver =%d fw_subver =%d sig = 0x%x\n",
280 __func__
, pHalData
->FirmwareVersion
,
281 pHalData
->FirmwareSubVersion
, pHalData
->FirmwareSignature
);
284 pr_info("%sFirmware Version %d, SubVersion %d, Signature "
285 "0x%x\n", DRIVER_PREFIX
, pHalData
->FirmwareVersion
,
286 pHalData
->FirmwareSubVersion
,
287 pHalData
->FirmwareSignature
);
289 if (IS_FW_HEADER_EXIST(pFwHdr
)) {
290 /* Shift 32 bytes for FW header */
292 fw_size
= fw_size
- 32;
295 /* Suggested by Filen. If 8051 is running in RAM code, driver should
296 inform Fw to reset by itself, */
297 /* or it will cause download Fw fail. 2010.02.01. by tynli. */
298 if (rtl8723au_read8(padapter
, REG_MCUFWDL
) & RAM_DL_SEL
) {
300 rtl8723a_FirmwareSelfReset(padapter
);
301 rtl8723au_write8(padapter
, REG_MCUFWDL
, 0x00);
304 _FWDownloadEnable(padapter
, true);
305 fwdl_start_time
= jiffies
;
307 /* reset the FWDL chksum */
308 rtl8723au_write8(padapter
, REG_MCUFWDL
,
309 rtl8723au_read8(padapter
, REG_MCUFWDL
) |
312 rtStatus
= _WriteFW(padapter
, buf
, fw_size
);
314 if (rtStatus
== _SUCCESS
||
315 (jiffies_to_msecs(jiffies
- fwdl_start_time
) > 500 &&
316 writeFW_retry
++ >= 3))
319 DBG_8723A("%s writeFW_retry:%u, time after fwdl_start_time:"
320 "%ums\n", __func__
, writeFW_retry
,
321 jiffies_to_msecs(jiffies
- fwdl_start_time
));
323 _FWDownloadEnable(padapter
, false);
324 if (_SUCCESS
!= rtStatus
) {
325 DBG_8723A("DL Firmware failed!\n");
329 rtStatus
= _FWFreeToGo(padapter
);
330 if (_SUCCESS
!= rtStatus
) {
331 RT_TRACE(_module_hal_init_c_
, _drv_err_
,
332 ("DL Firmware failed!\n"));
335 RT_TRACE(_module_hal_init_c_
, _drv_info_
,
336 ("Firmware is ready to run!\n"));
343 void rtl8723a_InitializeFirmwareVars(struct rtw_adapter
*padapter
)
345 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
347 /* Init Fw LPS related. */
348 padapter
->pwrctrlpriv
.bFwCurrentInPSMode
= false;
350 /* Init H2C counter. by tynli. 2009.12.09. */
351 pHalData
->LastHMEBoxNum
= 0;
355 /* Efuse related code */
358 hal_EfuseSwitchToBank(struct rtw_adapter
*padapter
, u8 bank
)
363 DBG_8723A("%s: Efuse switch bank to %d\n", __func__
, bank
);
364 value32
= rtl8723au_read32(padapter
, EFUSE_TEST
);
368 value32
= (value32
& ~EFUSE_SEL_MASK
) |
369 EFUSE_SEL(EFUSE_WIFI_SEL_0
);
372 value32
= (value32
& ~EFUSE_SEL_MASK
) |
373 EFUSE_SEL(EFUSE_BT_SEL_0
);
376 value32
= (value32
& ~EFUSE_SEL_MASK
) |
377 EFUSE_SEL(EFUSE_BT_SEL_1
);
380 value32
= (value32
& ~EFUSE_SEL_MASK
) |
381 EFUSE_SEL(EFUSE_BT_SEL_2
);
384 value32
= (value32
& ~EFUSE_SEL_MASK
) |
385 EFUSE_SEL(EFUSE_WIFI_SEL_0
);
389 rtl8723au_write32(padapter
, EFUSE_TEST
, value32
);
395 hal_ReadEFuse_WiFi(struct rtw_adapter
*padapter
,
396 u16 _offset
, u16 _size_byte
, u8
*pbuf
)
401 u8 efuseHeader
, efuseExtHdr
, efuseData
;
403 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
405 /* Do NOT excess total size of EFuse table.
406 Added by Roger, 2008.11.10. */
407 if ((_offset
+ _size_byte
) > EFUSE_MAP_LEN_8723A
) {
408 DBG_8723A("%s: Invalid offset(%#x) with read bytes(%#x)!!\n",
409 __func__
, _offset
, _size_byte
);
413 efuseTbl
= kmalloc(EFUSE_MAP_LEN_8723A
, GFP_KERNEL
);
414 if (efuseTbl
== NULL
) {
415 DBG_8723A("%s: alloc efuseTbl fail!\n", __func__
);
418 /* 0xff will be efuse default value instead of 0x00. */
419 memset(efuseTbl
, 0xFF, EFUSE_MAP_LEN_8723A
);
421 /* switch bank back to bank 0 for later BT and wifi use. */
422 hal_EfuseSwitchToBank(padapter
, 0);
424 while (AVAILABLE_EFUSE_ADDR(eFuse_Addr
)) {
425 ReadEFuseByte23a(padapter
, eFuse_Addr
++, &efuseHeader
);
426 if (efuseHeader
== 0xFF) {
427 DBG_8723A("%s: data end at address =%#x\n", __func__
,
432 /* Check PG header for section num. */
433 if (EXT_HEADER(efuseHeader
)) { /* extended header */
434 offset
= GET_HDR_OFFSET_2_0(efuseHeader
);
436 ReadEFuseByte23a(padapter
, eFuse_Addr
++, &efuseExtHdr
);
437 if (ALL_WORDS_DISABLED(efuseExtHdr
)) {
441 offset
|= ((efuseExtHdr
& 0xF0) >> 1);
442 wden
= (efuseExtHdr
& 0x0F);
444 offset
= ((efuseHeader
>> 4) & 0x0f);
445 wden
= (efuseHeader
& 0x0f);
448 if (offset
< EFUSE_MAX_SECTION_8723A
) {
450 /* Get word enable value from PG header */
452 addr
= offset
* PGPKT_DATA_SIZE
;
453 for (i
= 0; i
< EFUSE_MAX_WORD_UNIT
; i
++) {
454 /* Check word enable condition in the section */
455 if (!(wden
& (0x01 << i
))) {
456 ReadEFuseByte23a(padapter
, eFuse_Addr
++,
458 efuseTbl
[addr
] = efuseData
;
460 ReadEFuseByte23a(padapter
, eFuse_Addr
++,
462 efuseTbl
[addr
+ 1] = efuseData
;
467 DBG_8723A(KERN_ERR
"%s: offset(%d) is illegal!!\n",
469 eFuse_Addr
+= Efuse_CalculateWordCnts23a(wden
) * 2;
473 /* Copy from Efuse map to output pointer memory!!! */
474 for (i
= 0; i
< _size_byte
; i
++)
475 pbuf
[i
] = efuseTbl
[_offset
+ i
];
477 /* Calculate Efuse utilization */
478 EFUSE_GetEfuseDefinition23a(padapter
, EFUSE_WIFI
,
479 TYPE_AVAILABLE_EFUSE_BYTES_TOTAL
, &total
);
480 used
= eFuse_Addr
- 1;
481 pHalData
->EfuseUsedBytes
= used
;
487 hal_ReadEFuse_BT(struct rtw_adapter
*padapter
,
488 u16 _offset
, u16 _size_byte
, u8
*pbuf
)
493 u8 efuseHeader
, efuseExtHdr
, efuseData
;
496 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
498 /* Do NOT excess total size of EFuse table.
499 Added by Roger, 2008.11.10. */
500 if ((_offset
+ _size_byte
) > EFUSE_BT_MAP_LEN
) {
501 DBG_8723A("%s: Invalid offset(%#x) with read bytes(%#x)!!\n",
502 __func__
, _offset
, _size_byte
);
506 efuseTbl
= kmalloc(EFUSE_BT_MAP_LEN
, GFP_KERNEL
);
507 if (efuseTbl
== NULL
) {
508 DBG_8723A("%s: efuseTbl malloc fail!\n", __func__
);
511 /* 0xff will be efuse default value instead of 0x00. */
512 memset(efuseTbl
, 0xFF, EFUSE_BT_MAP_LEN
);
514 EFUSE_GetEfuseDefinition23a(padapter
, EFUSE_BT
,
515 TYPE_AVAILABLE_EFUSE_BYTES_BANK
, &total
);
517 for (bank
= 1; bank
< EFUSE_MAX_BANK
; bank
++) {
518 if (hal_EfuseSwitchToBank(padapter
, bank
) == false) {
519 DBG_8723A("%s: hal_EfuseSwitchToBank Fail!!\n",
526 while (AVAILABLE_EFUSE_ADDR(eFuse_Addr
)) {
527 ReadEFuseByte23a(padapter
, eFuse_Addr
++, &efuseHeader
);
528 if (efuseHeader
== 0xFF)
531 /* Check PG header for section num. */
532 if (EXT_HEADER(efuseHeader
)) { /* extended header */
533 offset
= GET_HDR_OFFSET_2_0(efuseHeader
);
535 ReadEFuseByte23a(padapter
, eFuse_Addr
++,
537 if (ALL_WORDS_DISABLED(efuseExtHdr
)) {
541 offset
|= ((efuseExtHdr
& 0xF0) >> 1);
542 wden
= (efuseExtHdr
& 0x0F);
544 offset
= ((efuseHeader
>> 4) & 0x0f);
545 wden
= (efuseHeader
& 0x0f);
548 if (offset
< EFUSE_BT_MAX_SECTION
) {
551 /* Get word enable value from PG header */
553 addr
= offset
* PGPKT_DATA_SIZE
;
554 for (i
= 0; i
< EFUSE_MAX_WORD_UNIT
; i
++) {
555 /* Check word enable condition in
557 if (!(wden
& (0x01 << i
))) {
558 ReadEFuseByte23a(padapter
,
561 efuseTbl
[addr
] = efuseData
;
563 ReadEFuseByte23a(padapter
,
566 efuseTbl
[addr
+ 1] = efuseData
;
572 "%s: offset(%d) is illegal!!\n",
574 eFuse_Addr
+= Efuse_CalculateWordCnts23a(wden
) * 2;
578 if ((eFuse_Addr
- 1) < total
) {
579 DBG_8723A("%s: bank(%d) data end at %#x\n",
580 __func__
, bank
, eFuse_Addr
- 1);
585 /* switch bank back to bank 0 for later BT and wifi use. */
586 hal_EfuseSwitchToBank(padapter
, 0);
588 /* Copy from Efuse map to output pointer memory!!! */
589 for (i
= 0; i
< _size_byte
; i
++)
590 pbuf
[i
] = efuseTbl
[_offset
+ i
];
593 /* Calculate Efuse utilization. */
595 EFUSE_GetEfuseDefinition23a(padapter
, EFUSE_BT
,
596 TYPE_AVAILABLE_EFUSE_BYTES_TOTAL
, &total
);
597 used
= (EFUSE_BT_REAL_BANK_CONTENT_LEN
* (bank
- 1)) + eFuse_Addr
- 1;
598 pHalData
->BTEfuseUsedBytes
= used
;
605 rtl8723a_readefuse(struct rtw_adapter
*padapter
,
606 u8 efuseType
, u16 _offset
, u16 _size_byte
, u8
*pbuf
)
608 if (efuseType
== EFUSE_WIFI
)
609 hal_ReadEFuse_WiFi(padapter
, _offset
, _size_byte
, pbuf
);
611 hal_ReadEFuse_BT(padapter
, _offset
, _size_byte
, pbuf
);
614 u16
rtl8723a_EfuseGetCurrentSize_WiFi(struct rtw_adapter
*padapter
)
617 u8 hoffset
= 0, hworden
= 0;
618 u8 efuse_data
, word_cnts
= 0;
619 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
621 efuse_addr
= pHalData
->EfuseUsedBytes
;
623 DBG_8723A("%s: start_efuse_addr = 0x%X\n", __func__
, efuse_addr
);
625 /* switch bank back to bank 0 for later BT and wifi use. */
626 hal_EfuseSwitchToBank(padapter
, 0);
628 while (AVAILABLE_EFUSE_ADDR(efuse_addr
)) {
629 if (efuse_OneByteRead23a(padapter
, efuse_addr
, &efuse_data
) ==
631 DBG_8723A(KERN_ERR
"%s: efuse_OneByteRead23a Fail! "
632 "addr = 0x%X !!\n", __func__
, efuse_addr
);
636 if (efuse_data
== 0xFF)
639 if (EXT_HEADER(efuse_data
)) {
640 hoffset
= GET_HDR_OFFSET_2_0(efuse_data
);
642 efuse_OneByteRead23a(padapter
, efuse_addr
, &efuse_data
);
643 if (ALL_WORDS_DISABLED(efuse_data
)) {
647 hoffset
|= ((efuse_data
& 0xF0) >> 1);
648 hworden
= efuse_data
& 0x0F;
650 hoffset
= (efuse_data
>> 4) & 0x0F;
651 hworden
= efuse_data
& 0x0F;
654 word_cnts
= Efuse_CalculateWordCnts23a(hworden
);
655 efuse_addr
+= (word_cnts
* 2) + 1;
658 pHalData
->EfuseUsedBytes
= efuse_addr
;
660 DBG_8723A("%s: CurrentSize =%d\n", __func__
, efuse_addr
);
665 u16
rtl8723a_EfuseGetCurrentSize_BT(struct rtw_adapter
*padapter
)
670 u8 hoffset
= 0, hworden
= 0;
671 u8 efuse_data
, word_cnts
= 0;
673 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
675 btusedbytes
= pHalData
->BTEfuseUsedBytes
;
677 efuse_addr
= (u16
) ((btusedbytes
% EFUSE_BT_REAL_BANK_CONTENT_LEN
));
678 startBank
= (u8
) (1 + (btusedbytes
/ EFUSE_BT_REAL_BANK_CONTENT_LEN
));
680 DBG_8723A("%s: start from bank =%d addr = 0x%X\n", __func__
, startBank
,
683 EFUSE_GetEfuseDefinition23a(padapter
, EFUSE_BT
,
684 TYPE_AVAILABLE_EFUSE_BYTES_BANK
, &retU2
);
686 for (bank
= startBank
; bank
< EFUSE_MAX_BANK
; bank
++) {
687 if (hal_EfuseSwitchToBank(padapter
, bank
) == false) {
688 DBG_8723A(KERN_ERR
"%s: switch bank(%d) Fail!!\n",
690 bank
= EFUSE_MAX_BANK
;
694 /* only when bank is switched we have to reset
696 if (bank
!= startBank
)
699 while (AVAILABLE_EFUSE_ADDR(efuse_addr
)) {
700 if (efuse_OneByteRead23a(padapter
, efuse_addr
,
701 &efuse_data
) == _FAIL
) {
702 DBG_8723A(KERN_ERR
"%s: efuse_OneByteRead23a Fail!"
704 __func__
, efuse_addr
);
705 bank
= EFUSE_MAX_BANK
;
709 if (efuse_data
== 0xFF)
712 if (EXT_HEADER(efuse_data
)) {
713 hoffset
= GET_HDR_OFFSET_2_0(efuse_data
);
715 efuse_OneByteRead23a(padapter
, efuse_addr
,
717 if (ALL_WORDS_DISABLED(efuse_data
)) {
722 hoffset
|= ((efuse_data
& 0xF0) >> 1);
723 hworden
= efuse_data
& 0x0F;
725 hoffset
= (efuse_data
>> 4) & 0x0F;
726 hworden
= efuse_data
& 0x0F;
728 word_cnts
= Efuse_CalculateWordCnts23a(hworden
);
729 /* read next header */
730 efuse_addr
+= (word_cnts
* 2) + 1;
733 /* Check if we need to check next bank efuse */
734 if (efuse_addr
< retU2
) {
735 break; /* don't need to check next bank. */
739 retU2
= ((bank
- 1) * EFUSE_BT_REAL_BANK_CONTENT_LEN
) + efuse_addr
;
740 pHalData
->BTEfuseUsedBytes
= retU2
;
742 DBG_8723A("%s: CurrentSize =%d\n", __func__
, retU2
);
747 rtl8723a_EfusePgPacketRead(struct rtw_adapter
*padapter
, u8 offset
, u8
*data
)
749 u8 efuse_data
, word_cnts
= 0;
751 u8 hoffset
= 0, hworden
= 0;
759 EFUSE_GetEfuseDefinition23a(padapter
, EFUSE_WIFI
, TYPE_EFUSE_MAX_SECTION
,
761 if (offset
> max_section
) {
762 DBG_8723A("%s: Packet offset(%d) is illegal(>%d)!\n",
763 __func__
, offset
, max_section
);
767 memset(data
, 0xFF, PGPKT_DATA_SIZE
);
771 /* <Roger_TODO> Efuse has been pre-programmed dummy 5Bytes at the
772 end of Efuse by CP. */
773 /* Skip dummy parts to prevent unexpected data read from Efuse. */
774 /* By pass right now. 2009.02.19. */
776 while (AVAILABLE_EFUSE_ADDR(efuse_addr
)) {
777 if (efuse_OneByteRead23a(padapter
, efuse_addr
++, &efuse_data
) ==
783 if (efuse_data
== 0xFF)
786 if (EXT_HEADER(efuse_data
)) {
787 hoffset
= GET_HDR_OFFSET_2_0(efuse_data
);
788 efuse_OneByteRead23a(padapter
, efuse_addr
++, &efuse_data
);
789 if (ALL_WORDS_DISABLED(efuse_data
)) {
790 DBG_8723A("%s: Error!! All words disabled!\n",
795 hoffset
|= ((efuse_data
& 0xF0) >> 1);
796 hworden
= efuse_data
& 0x0F;
798 hoffset
= (efuse_data
>> 4) & 0x0F;
799 hworden
= efuse_data
& 0x0F;
802 if (hoffset
== offset
) {
803 for (i
= 0; i
< EFUSE_MAX_WORD_UNIT
; i
++) {
804 /* Check word enable condition in the section */
805 if (!(hworden
& (0x01 << i
))) {
806 ReadEFuseByte23a(padapter
, efuse_addr
++,
808 data
[i
* 2] = efuse_data
;
810 ReadEFuseByte23a(padapter
, efuse_addr
++,
812 data
[(i
* 2) + 1] = efuse_data
;
816 word_cnts
= Efuse_CalculateWordCnts23a(hworden
);
817 efuse_addr
+= word_cnts
* 2;
824 void rtl8723a_read_chip_version(struct rtw_adapter
*padapter
)
827 struct hal_version ChipVersion
;
828 struct hal_data_8723a
*pHalData
;
830 pHalData
= GET_HAL_DATA(padapter
);
832 value32
= rtl8723au_read32(padapter
, REG_SYS_CFG
);
833 ChipVersion
.ICType
= CHIP_8723A
;
834 ChipVersion
.ChipType
= ((value32
& RTL_ID
) ? TEST_CHIP
: NORMAL_CHIP
);
835 ChipVersion
.RFType
= RF_TYPE_1T1R
;
836 ChipVersion
.VendorType
=
837 ((value32
& VENDOR_ID
) ? CHIP_VENDOR_UMC
: CHIP_VENDOR_TSMC
);
838 ChipVersion
.CUTVersion
= (value32
& CHIP_VER_RTL_MASK
) >> CHIP_VER_RTL_SHIFT
; /* IC version (CUT) */
840 /* For regulator mode. by tynli. 2011.01.14 */
841 pHalData
->RegulatorMode
= ((value32
& SPS_SEL
) ?
842 RT_LDO_REGULATOR
: RT_SWITCHING_REGULATOR
);
844 value32
= rtl8723au_read32(padapter
, REG_GPIO_OUTSTS
);
845 /* ROM code version. */
846 ChipVersion
.ROMVer
= ((value32
& RF_RL_ID
) >> 20);
848 /* For multi-function consideration. Added by Roger, 2010.10.06. */
849 pHalData
->MultiFunc
= RT_MULTI_FUNC_NONE
;
850 value32
= rtl8723au_read32(padapter
, REG_MULTI_FUNC_CTRL
);
851 pHalData
->MultiFunc
|=
852 ((value32
& WL_FUNC_EN
) ? RT_MULTI_FUNC_WIFI
: 0);
853 pHalData
->MultiFunc
|= ((value32
& BT_FUNC_EN
) ? RT_MULTI_FUNC_BT
: 0);
854 pHalData
->MultiFunc
|=
855 ((value32
& GPS_FUNC_EN
) ? RT_MULTI_FUNC_GPS
: 0);
856 pHalData
->PolarityCtl
=
857 ((value32
& WL_HWPDN_SL
) ? RT_POLARITY_HIGH_ACT
:
858 RT_POLARITY_LOW_ACT
);
859 dump_chip_info23a(ChipVersion
);
860 pHalData
->VersionID
= ChipVersion
;
862 if (IS_1T2R(ChipVersion
))
863 pHalData
->rf_type
= RF_1T2R
;
864 else if (IS_2T2R(ChipVersion
))
865 pHalData
->rf_type
= RF_2T2R
;
867 pHalData
->rf_type
= RF_1T1R
;
869 MSG_8723A("RF_Type is %x!!\n", pHalData
->rf_type
);
874 /* 20100209 Joseph: */
875 /* This function is used only for 92C to set REG_BCN_CTRL(0x550) register. */
876 /* We just reserve the value of the register in variable
877 pHalData->RegBcnCtrlVal and then operate */
878 /* the value of the register via atomic operation. */
879 /* This prevents from race condition when setting this register. */
880 /* The value of pHalData->RegBcnCtrlVal is initialized in
881 HwConfigureRTL8192CE() function. */
883 void SetBcnCtrlReg23a(struct rtw_adapter
*padapter
, u8 SetBits
, u8 ClearBits
)
887 val8
= rtl8723au_read8(padapter
, REG_BCN_CTRL
);
891 rtl8723au_write8(padapter
, REG_BCN_CTRL
, val8
);
894 void rtl8723a_InitBeaconParameters(struct rtw_adapter
*padapter
)
896 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
898 rtl8723au_write16(padapter
, REG_BCN_CTRL
, 0x1010);
900 /* TODO: Remove these magic number */
901 rtl8723au_write16(padapter
, REG_TBTT_PROHIBIT
, 0x6404); /* ms */
902 /* Firmware will control REG_DRVERLYINT when power saving is enable, */
903 /* so don't set this register on STA mode. */
904 if (check_fwstate(&padapter
->mlmepriv
, WIFI_STATION_STATE
) == false)
905 rtl8723au_write8(padapter
, REG_DRVERLYINT
,
906 DRIVER_EARLY_INT_TIME
);
908 rtl8723au_write8(padapter
, REG_BCNDMATIM
, BCN_DMA_ATIME_INT_TIME
);
910 /* Suggested by designer timchen. Change beacon AIFS to the
911 largest number beacause test chip does not contension before
912 sending beacon. by tynli. 2009.11.03 */
913 rtl8723au_write16(padapter
, REG_BCNTCFG
, 0x660F);
916 static void ResumeTxBeacon(struct rtw_adapter
*padapter
)
918 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
920 /* 2010.03.01. Marked by tynli. No need to call workitem beacause
921 we record the value */
922 /* which should be read from register to a global variable. */
924 RT_TRACE(_module_hci_hal_init_c_
, _drv_info_
, ("+ResumeTxBeacon\n"));
926 pHalData
->RegFwHwTxQCtrl
|= BIT(6);
927 rtl8723au_write8(padapter
, REG_FWHW_TXQ_CTRL
+ 2,
928 pHalData
->RegFwHwTxQCtrl
);
929 rtl8723au_write8(padapter
, REG_TBTT_PROHIBIT
+ 1, 0xff);
930 pHalData
->RegReg542
|= BIT(0);
931 rtl8723au_write8(padapter
, REG_TBTT_PROHIBIT
+ 2, pHalData
->RegReg542
);
934 static void StopTxBeacon(struct rtw_adapter
*padapter
)
936 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
938 /* 2010.03.01. Marked by tynli. No need to call workitem beacause
939 we record the value */
940 /* which should be read from register to a global variable. */
942 RT_TRACE(_module_hci_hal_init_c_
, _drv_info_
, ("+StopTxBeacon\n"));
944 pHalData
->RegFwHwTxQCtrl
&= ~BIT(6);
945 rtl8723au_write8(padapter
, REG_FWHW_TXQ_CTRL
+ 2,
946 pHalData
->RegFwHwTxQCtrl
);
947 rtl8723au_write8(padapter
, REG_TBTT_PROHIBIT
+ 1, 0x64);
948 pHalData
->RegReg542
&= ~BIT(0);
949 rtl8723au_write8(padapter
, REG_TBTT_PROHIBIT
+ 2, pHalData
->RegReg542
);
952 static void _BeaconFunctionEnable(struct rtw_adapter
*padapter
, u8 Enable
,
955 SetBcnCtrlReg23a(padapter
, DIS_TSF_UDT
| EN_BCN_FUNCTION
| DIS_BCNQ_SUB
,
957 rtl8723au_write8(padapter
, REG_RD_CTRL
+ 1, 0x6F);
960 void rtl8723a_SetBeaconRelatedRegisters(struct rtw_adapter
*padapter
)
963 struct mlme_ext_priv
*pmlmeext
= &padapter
->mlmeextpriv
;
964 struct mlme_ext_info
*pmlmeinfo
= &pmlmeext
->mlmext_info
;
966 /* reset TSF, enable update TSF, correcting TSF On Beacon */
968 /* REG_BCN_INTERVAL */
971 /* REG_TBTT_PROHIBIT */
973 /* REG_BCN_MAX_ERR */
974 /* REG_BCNTCFG (0x510) */
975 /* REG_DUAL_TSF_RST */
976 /* REG_BCN_CTRL (0x550) */
981 rtl8723au_write16(padapter
, REG_ATIMWND
, 2);
984 /* Beacon interval (in unit of TU). */
986 rtl8723au_write16(padapter
, REG_BCN_INTERVAL
, pmlmeinfo
->bcn_interval
);
988 rtl8723a_InitBeaconParameters(padapter
);
990 rtl8723au_write8(padapter
, REG_SLOT
, 0x09);
993 /* Reset TSF Timer to zero, added by Roger. 2008.06.24 */
995 value32
= rtl8723au_read32(padapter
, REG_TCR
);
997 rtl8723au_write32(padapter
, REG_TCR
, value32
);
1000 rtl8723au_write32(padapter
, REG_TCR
, value32
);
1002 /* NOTE: Fix test chip's bug (about contention windows's randomness) */
1003 if (check_fwstate(&padapter
->mlmepriv
, WIFI_ADHOC_STATE
|
1004 WIFI_ADHOC_MASTER_STATE
| WIFI_AP_STATE
) == true) {
1005 rtl8723au_write8(padapter
, REG_RXTSF_OFFSET_CCK
, 0x50);
1006 rtl8723au_write8(padapter
, REG_RXTSF_OFFSET_OFDM
, 0x50);
1009 _BeaconFunctionEnable(padapter
, true, true);
1011 ResumeTxBeacon(padapter
);
1012 SetBcnCtrlReg23a(padapter
, DIS_BCNQ_SUB
, 0);
1015 void rtl8723a_SetHalODMVar(struct rtw_adapter
*Adapter
,
1016 enum hal_odm_variable eVariable
,
1017 void *pValue1
, bool bSet
)
1019 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(Adapter
);
1020 struct dm_odm_t
*podmpriv
= &pHalData
->odmpriv
;
1021 switch (eVariable
) {
1022 case HAL_ODM_STA_INFO
:
1024 struct sta_info
*psta
= (struct sta_info
*)pValue1
;
1027 DBG_8723A("Set STA_(%d) info\n", psta
->mac_id
);
1028 ODM_CmnInfoPtrArrayHook23a(podmpriv
,
1029 ODM_CMNINFO_STA_STATUS
,
1030 psta
->mac_id
, psta
);
1032 DBG_8723A("Clean STA_(%d) info\n", psta
->mac_id
);
1033 ODM_CmnInfoPtrArrayHook23a(podmpriv
,
1034 ODM_CMNINFO_STA_STATUS
,
1035 psta
->mac_id
, NULL
);
1039 case HAL_ODM_P2P_STATE
:
1040 ODM_CmnInfoUpdate23a(podmpriv
, ODM_CMNINFO_WIFI_DIRECT
, bSet
);
1042 case HAL_ODM_WIFI_DISPLAY_STATE
:
1043 ODM_CmnInfoUpdate23a(podmpriv
, ODM_CMNINFO_WIFI_DISPLAY
, bSet
);
1050 void rtl8723a_notch_filter(struct rtw_adapter
*adapter
, bool enable
)
1053 DBG_8723A("Enable notch filter\n");
1054 rtl8723au_write8(adapter
, rOFDM0_RxDSP
+ 1,
1055 rtl8723au_read8(adapter
, rOFDM0_RxDSP
+ 1) |
1058 DBG_8723A("Disable notch filter\n");
1059 rtl8723au_write8(adapter
, rOFDM0_RxDSP
+ 1,
1060 rtl8723au_read8(adapter
, rOFDM0_RxDSP
+ 1) &
1065 bool c2h_id_filter_ccx_8723a(u8 id
)
1068 if (id
== C2H_CCX_TX_RPT
)
1074 int c2h_handler_8723a(struct rtw_adapter
*padapter
, struct c2h_evt_hdr
*c2h_evt
)
1079 if (c2h_evt
== NULL
) {
1080 DBG_8723A("%s c2h_evt is NULL\n", __func__
);
1085 switch (c2h_evt
->id
) {
1087 RT_TRACE(_module_hal_init_c_
, _drv_info_
,
1088 ("C2HCommandHandler: %s\n", c2h_evt
->payload
));
1091 case C2H_CCX_TX_RPT
:
1092 handle_txrpt_ccx_8723a(padapter
, c2h_evt
->payload
);
1094 case C2H_EXT_RA_RPT
:
1096 case C2H_HW_INFO_EXCH
:
1097 RT_TRACE(_module_hal_init_c_
, _drv_info_
,
1098 ("[BT], C2H_HW_INFO_EXCH\n"));
1099 for (i
= 0; i
< c2h_evt
->plen
; i
++) {
1100 RT_TRACE(_module_hal_init_c_
, _drv_info_
,
1101 ("[BT], tmpBuf[%d]= 0x%x\n", i
,
1102 c2h_evt
->payload
[i
]));
1106 case C2H_C2H_H2C_TEST
:
1107 RT_TRACE(_module_hal_init_c_
, _drv_info_
,
1108 ("[BT], C2H_H2C_TEST\n"));
1109 RT_TRACE(_module_hal_init_c_
, _drv_info_
,
1110 ("[BT], tmpBuf[0]/[1]/[2]/[3]/[4]= 0x%x/ 0x%x/ "
1111 "0x%x/ 0x%x/ 0x%x\n", c2h_evt
->payload
[0],
1112 c2h_evt
->payload
[1], c2h_evt
->payload
[2],
1113 c2h_evt
->payload
[3], c2h_evt
->payload
[4]));
1117 DBG_8723A("%s , Got C2H_BT_INFO \n", __func__
);
1118 rtl8723a_fw_c2h_BT_info(padapter
,
1119 c2h_evt
->payload
, c2h_evt
->plen
);
1131 void rtl8723a_InitAntenna_Selection(struct rtw_adapter
*padapter
)
1135 val
= rtl8723au_read8(padapter
, REG_LEDCFG2
);
1136 /* Let 8051 take control antenna settting */
1137 val
|= BIT(7); /* DPDT_SEL_EN, 0x4C[23] */
1138 rtl8723au_write8(padapter
, REG_LEDCFG2
, val
);
1141 void rtl8723a_CheckAntenna_Selection(struct rtw_adapter
*padapter
)
1145 val
= rtl8723au_read8(padapter
, REG_LEDCFG2
);
1146 /* Let 8051 take control antenna settting */
1147 if (!(val
& BIT(7))) {
1148 val
|= BIT(7); /* DPDT_SEL_EN, 0x4C[23] */
1149 rtl8723au_write8(padapter
, REG_LEDCFG2
, val
);
1153 void rtl8723a_DeinitAntenna_Selection(struct rtw_adapter
*padapter
)
1157 val
= rtl8723au_read8(padapter
, REG_LEDCFG2
);
1158 /* Let 8051 take control antenna settting */
1159 val
&= ~BIT(7); /* DPDT_SEL_EN, clear 0x4C[23] */
1160 rtl8723au_write8(padapter
, REG_LEDCFG2
, val
);
1163 void rtl8723a_init_default_value(struct rtw_adapter
*padapter
)
1165 struct hal_data_8723a
*pHalData
;
1166 struct dm_priv
*pdmpriv
;
1169 pHalData
= GET_HAL_DATA(padapter
);
1170 pdmpriv
= &pHalData
->dmpriv
;
1172 /* init default value */
1173 pHalData
->fw_ractrl
= false;
1174 pHalData
->bIQKInitialized
= false;
1175 if (!padapter
->pwrctrlpriv
.bkeepfwalive
)
1176 pHalData
->LastHMEBoxNum
= 0;
1178 pHalData
->bIQKInitialized
= false;
1180 /* init dm default value */
1181 pdmpriv
->TM_Trigger
= 0; /* for IQK */
1182 /* pdmpriv->binitialized = false; */
1183 /* pdmpriv->prv_traffic_idx = 3; */
1184 /* pdmpriv->initialize = 0; */
1186 pdmpriv
->ThermalValue_HP_index
= 0;
1187 for (i
= 0; i
< HP_THERMAL_NUM
; i
++)
1188 pdmpriv
->ThermalValue_HP
[i
] = 0;
1190 /* init Efuse variables */
1191 pHalData
->EfuseUsedBytes
= 0;
1192 pHalData
->BTEfuseUsedBytes
= 0;
1195 u8
GetEEPROMSize8723A(struct rtw_adapter
*padapter
)
1200 cr
= rtl8723au_read16(padapter
, REG_9346CR
);
1201 /* 6: EEPROM used is 93C46, 4: boot from E-Fuse. */
1202 size
= (cr
& BOOT_FROM_EEPROM
) ? 6 : 4;
1204 MSG_8723A("EEPROM type is %s\n", size
== 4 ? "E-FUSE" : "93C46");
1211 /* LLT R/W/Init function */
1214 static int _LLTWrite(struct rtw_adapter
*padapter
, u32 address
, u32 data
)
1216 int status
= _SUCCESS
;
1218 u32 value
= _LLT_INIT_ADDR(address
) | _LLT_INIT_DATA(data
) |
1219 _LLT_OP(_LLT_WRITE_ACCESS
);
1220 u16 LLTReg
= REG_LLT_INIT
;
1222 rtl8723au_write32(padapter
, LLTReg
, value
);
1226 value
= rtl8723au_read32(padapter
, LLTReg
);
1227 if (_LLT_NO_ACTIVE
== _LLT_OP_VALUE(value
)) {
1231 if (count
> POLLING_LLT_THRESHOLD
) {
1232 RT_TRACE(_module_hal_init_c_
, _drv_err_
,
1233 ("Failed to polling write LLT done at "
1234 "address %d!\n", address
));
1243 int InitLLTTable23a(struct rtw_adapter
*padapter
, u32 boundary
)
1245 int status
= _SUCCESS
;
1247 u32 txpktbuf_bndy
= boundary
;
1248 u32 Last_Entry_Of_TxPktBuf
= LAST_ENTRY_OF_TX_PKT_BUFFER
;
1250 for (i
= 0; i
< (txpktbuf_bndy
- 1); i
++) {
1251 status
= _LLTWrite(padapter
, i
, i
+ 1);
1252 if (status
!= _SUCCESS
) {
1258 status
= _LLTWrite(padapter
, (txpktbuf_bndy
- 1), 0xFF);
1259 if (status
!= _SUCCESS
) {
1263 /* Make the other pages as ring buffer */
1264 /* This ring buffer is used as beacon buffer if we config this
1265 MAC as two MAC transfer. */
1266 /* Otherwise used as local loopback buffer. */
1267 for (i
= txpktbuf_bndy
; i
< Last_Entry_Of_TxPktBuf
; i
++) {
1268 status
= _LLTWrite(padapter
, i
, (i
+ 1));
1269 if (_SUCCESS
!= status
) {
1274 /* Let last entry point to the start entry of ring buffer */
1275 status
= _LLTWrite(padapter
, Last_Entry_Of_TxPktBuf
, txpktbuf_bndy
);
1276 if (status
!= _SUCCESS
) {
1283 static void _DisableGPIO(struct rtw_adapter
*padapter
)
1285 /***************************************
1286 j. GPIO_PIN_CTRL 0x44[31:0]= 0x000
1287 k.Value = GPIO_PIN_CTRL[7:0]
1288 l. GPIO_PIN_CTRL 0x44[31:0] = 0x00FF0000 | (value <<8); write external PIN level
1289 m. GPIO_MUXCFG 0x42 [15:0] = 0x0780
1290 n. LEDCFG 0x4C[15:0] = 0x8080
1291 ***************************************/
1295 /* 1. Disable GPIO[7:0] */
1296 rtl8723au_write16(padapter
, REG_GPIO_PIN_CTRL
+ 2, 0x0000);
1297 value32
= rtl8723au_read32(padapter
, REG_GPIO_PIN_CTRL
) & 0xFFFF00FF;
1298 u4bTmp
= value32
& 0x000000FF;
1299 value32
|= ((u4bTmp
<< 8) | 0x00FF0000);
1300 rtl8723au_write32(padapter
, REG_GPIO_PIN_CTRL
, value32
);
1303 /* <Roger_Notes> For RTL8723u multi-function configuration which
1304 was autoload from Efuse offset 0x0a and 0x0b, */
1305 /* WLAN HW GPIO[9], GPS HW GPIO[10] and BT HW GPIO[11]. */
1306 /* Added by Roger, 2010.10.07. */
1308 /* 2. Disable GPIO[8] and GPIO[12] */
1310 /* Configure all pins as input mode. */
1311 rtl8723au_write16(padapter
, REG_GPIO_IO_SEL_2
, 0x0000);
1312 value32
= rtl8723au_read32(padapter
, REG_GPIO_PIN_CTRL_2
) & 0xFFFF001F;
1313 u4bTmp
= value32
& 0x0000001F;
1314 /* Set pin 8, 10, 11 and pin 12 to output mode. */
1315 value32
|= ((u4bTmp
<< 8) | 0x001D0000);
1316 rtl8723au_write32(padapter
, REG_GPIO_PIN_CTRL_2
, value32
);
1318 /* 3. Disable LED0 & 1 */
1319 rtl8723au_write16(padapter
, REG_LEDCFG0
, 0x8080);
1320 } /* end of _DisableGPIO() */
1322 static void _DisableRFAFEAndResetBB8192C(struct rtw_adapter
*padapter
)
1324 /**************************************
1325 a. TXPAUSE 0x522[7:0] = 0xFF Pause MAC TX queue
1326 b. RF path 0 offset 0x00 = 0x00 disable RF
1327 c. APSD_CTRL 0x600[7:0] = 0x40
1328 d. SYS_FUNC_EN 0x02[7:0] = 0x16 reset BB state machine
1329 e. SYS_FUNC_EN 0x02[7:0] = 0x14 reset BB state machine
1330 ***************************************/
1331 u8 eRFPath
= 0, value8
= 0;
1333 rtl8723au_write8(padapter
, REG_TXPAUSE
, 0xFF);
1335 PHY_SetRFReg(padapter
, (enum RF_RADIO_PATH
) eRFPath
, 0x0, bMaskByte0
, 0x0);
1338 rtl8723au_write8(padapter
, REG_APSD_CTRL
, value8
); /* 0x40 */
1340 /* Set BB reset at first */
1342 value8
|= (FEN_USBD
| FEN_USBA
| FEN_BB_GLB_RSTn
);
1343 rtl8723au_write8(padapter
, REG_SYS_FUNC_EN
, value8
); /* 0x16 */
1345 /* Set global reset. */
1346 value8
&= ~FEN_BB_GLB_RSTn
;
1347 rtl8723au_write8(padapter
, REG_SYS_FUNC_EN
, value8
); /* 0x14 */
1349 /* 2010/08/12 MH We need to set BB/GLBAL reset to save power
1352 /* RT_TRACE(COMP_INIT, DBG_LOUD, ("======> RF off and reset BB.\n")); */
1355 static void _DisableRFAFEAndResetBB(struct rtw_adapter
*padapter
)
1357 _DisableRFAFEAndResetBB8192C(padapter
);
1360 static void _ResetDigitalProcedure1_92C(struct rtw_adapter
*padapter
,
1363 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
1365 if (IS_FW_81xxC(padapter
) && (pHalData
->FirmwareVersion
<= 0x20)) {
1366 /*****************************
1367 f. MCUFWDL 0x80[7:0]= 0 reset MCU ready status
1368 g. SYS_FUNC_EN 0x02[10]= 0 reset MCU register, (8051 reset)
1369 h. SYS_FUNC_EN 0x02[15-12]= 5 reset MAC register, DCORE
1370 i. SYS_FUNC_EN 0x02[10]= 1 enable MCU register,
1372 ******************************/
1374 rtl8723au_write8(padapter
, REG_MCUFWDL
, 0);
1376 valu16
= rtl8723au_read16(padapter
, REG_SYS_FUNC_EN
);
1377 /* reset MCU , 8051 */
1378 rtl8723au_write16(padapter
, REG_SYS_FUNC_EN
,
1379 valu16
& (~FEN_CPUEN
));
1381 valu16
= rtl8723au_read16(padapter
, REG_SYS_FUNC_EN
) & 0x0FFF;
1383 rtl8723au_write16(padapter
, REG_SYS_FUNC_EN
,
1384 valu16
| (FEN_HWPDN
| FEN_ELDR
));
1386 valu16
= rtl8723au_read16(padapter
, REG_SYS_FUNC_EN
);
1387 /* enable MCU , 8051 */
1388 rtl8723au_write16(padapter
, REG_SYS_FUNC_EN
,
1389 valu16
| FEN_CPUEN
);
1393 /* 2010/08/12 MH For USB SS, we can not stop 8051 when we
1394 are trying to enter IPS/HW&SW radio off. For
1395 S3/S4/S5/Disable, we can stop 8051 because */
1396 /* we will init FW when power on again. */
1397 /* If we want to SS mode, we can not reset 8051. */
1398 if (rtl8723au_read8(padapter
, REG_MCUFWDL
) & BIT(1)) {
1399 /* IF fw in RAM code, do reset */
1400 if (padapter
->bFWReady
) {
1401 /* 2010/08/25 MH Accordign to RD alfred's
1402 suggestion, we need to disable other */
1403 /* HRCV INT to influence 8051 reset. */
1404 rtl8723au_write8(padapter
, REG_FWIMR
, 0x20);
1405 /* 2011/02/15 MH According to Alex's
1406 suggestion, close mask to prevent
1407 incorrect FW write operation. */
1408 rtl8723au_write8(padapter
, REG_FTIMR
, 0x00);
1409 rtl8723au_write8(padapter
, REG_FSIMR
, 0x00);
1411 /* 8051 reset by self */
1412 rtl8723au_write8(padapter
, REG_HMETFR
+ 3,
1415 while ((retry_cnts
++ < 100) &&
1417 rtl8723au_read16(padapter
,
1418 REG_SYS_FUNC_EN
))) {
1419 udelay(50); /* us */
1422 if (retry_cnts
>= 100) {
1423 /* Reset MAC and Enable 8051 */
1424 rtl8723au_write8(padapter
,
1425 REG_SYS_FUNC_EN
+ 1,
1431 /* Reset MAC and Enable 8051 */
1432 rtl8723au_write8(padapter
, REG_SYS_FUNC_EN
+ 1, 0x54);
1433 rtl8723au_write8(padapter
, REG_MCUFWDL
, 0);
1437 /*****************************
1438 Without HW auto state machine
1439 g. SYS_CLKR 0x08[15:0] = 0x30A3 disable MAC clock
1440 h. AFE_PLL_CTRL 0x28[7:0] = 0x80 disable AFE PLL
1441 i. AFE_XTAL_CTRL 0x24[15:0] = 0x880F gated AFE DIG_CLOCK
1442 j. SYS_ISO_CTRL 0x00[7:0] = 0xF9 isolated digital to PON
1443 ******************************/
1444 /* modify to 0x70A3 by Scott. */
1445 rtl8723au_write16(padapter
, REG_SYS_CLKR
, 0x70A3);
1446 rtl8723au_write8(padapter
, REG_AFE_PLL_CTRL
, 0x80);
1447 rtl8723au_write16(padapter
, REG_AFE_XTAL_CTRL
, 0x880F);
1448 rtl8723au_write8(padapter
, REG_SYS_ISO_CTRL
, 0xF9);
1450 /* Disable all RF/BB power */
1451 rtl8723au_write8(padapter
, REG_RF_CTRL
, 0x00);
1455 static void _ResetDigitalProcedure1(struct rtw_adapter
*padapter
,
1458 _ResetDigitalProcedure1_92C(padapter
, bWithoutHWSM
);
1461 static void _ResetDigitalProcedure2(struct rtw_adapter
*padapter
)
1463 /*****************************
1464 k. SYS_FUNC_EN 0x03[7:0] = 0x44 disable ELDR runction
1465 l. SYS_CLKR 0x08[15:0] = 0x3083 disable ELDR clock
1466 m. SYS_ISO_CTRL 0x01[7:0] = 0x83 isolated ELDR to PON
1467 ******************************/
1468 /* modify to 0x70a3 by Scott. */
1469 rtl8723au_write16(padapter
, REG_SYS_CLKR
, 0x70a3);
1470 /* modify to 0x82 by Scott. */
1471 rtl8723au_write8(padapter
, REG_SYS_ISO_CTRL
+ 1, 0x82);
1474 static void _DisableAnalog(struct rtw_adapter
*padapter
, bool bWithoutHWSM
)
1476 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
1481 /*****************************
1482 n. LDOA15_CTRL 0x20[7:0] = 0x04 disable A15 power
1483 o. LDOV12D_CTRL 0x21[7:0] = 0x54 disable digital core power
1484 r. When driver call disable, the ASIC will turn off remaining
1486 ******************************/
1488 rtl8723au_write8(padapter
, REG_LDOA15_CTRL
, 0x04);
1489 /* rtl8723au_write8(padapter, REG_LDOV12D_CTRL, 0x54); */
1491 value8
= rtl8723au_read8(padapter
, REG_LDOV12D_CTRL
);
1492 value8
&= (~LDV12_EN
);
1493 rtl8723au_write8(padapter
, REG_LDOV12D_CTRL
, value8
);
1494 /* RT_TRACE(COMP_INIT, DBG_LOUD,
1495 (" REG_LDOV12D_CTRL Reg0x21:0x%02x.\n", value8)); */
1498 /*****************************
1499 h. SPS0_CTRL 0x11[7:0] = 0x23 enter PFM mode
1500 i. APS_FSMCO 0x04[15:0] = 0x4802 set USB suspend
1501 ******************************/
1503 if (IS_81xxC_VENDOR_UMC_B_CUT(pHalData
->VersionID
))
1506 rtl8723au_write8(padapter
, REG_SPS0_CTRL
, value8
);
1509 /* value16 |= (APDM_HOST | FSM_HSUS |/PFM_ALDN); */
1510 /* 2010/08/31 According to Filen description, we need to
1511 use HW to shut down 8051 automatically. */
1512 /* Becasue suspend operatione need the asistance of 8051
1514 value16
|= (APDM_HOST
| AFSM_HSUS
| PFM_ALDN
);
1516 value16
|= (APDM_HOST
| AFSM_HSUS
| PFM_ALDN
);
1519 rtl8723au_write16(padapter
, REG_APS_FSMCO
, value16
); /* 0x4802 */
1521 rtl8723au_write8(padapter
, REG_RSV_CTRL
, 0x0e);
1524 /* HW Auto state machine */
1525 int CardDisableHWSM(struct rtw_adapter
*padapter
, u8 resetMCU
)
1527 int rtStatus
= _SUCCESS
;
1529 if (padapter
->bSurpriseRemoved
) {
1532 /* RF Off Sequence ==== */
1533 _DisableRFAFEAndResetBB(padapter
);
1535 /* ==== Reset digital sequence ====== */
1536 _ResetDigitalProcedure1(padapter
, false);
1538 /* ==== Pull GPIO PIN to balance level and LED control ====== */
1539 _DisableGPIO(padapter
);
1541 /* ==== Disable analog sequence === */
1542 _DisableAnalog(padapter
, false);
1544 RT_TRACE(_module_hci_hal_init_c_
, _drv_info_
,
1545 ("======> Card disable finished.\n"));
1550 /* without HW Auto state machine */
1551 int CardDisableWithoutHWSM(struct rtw_adapter
*padapter
)
1553 int rtStatus
= _SUCCESS
;
1555 /* RT_TRACE(COMP_INIT, DBG_LOUD,
1556 ("======> Card Disable Without HWSM .\n")); */
1557 if (padapter
->bSurpriseRemoved
) {
1561 /* RF Off Sequence ==== */
1562 _DisableRFAFEAndResetBB(padapter
);
1564 /* ==== Reset digital sequence ====== */
1565 _ResetDigitalProcedure1(padapter
, true);
1567 /* ==== Pull GPIO PIN to balance level and LED control ====== */
1568 _DisableGPIO(padapter
);
1570 /* ==== Reset digital sequence ====== */
1571 _ResetDigitalProcedure2(padapter
);
1573 /* ==== Disable analog sequence === */
1574 _DisableAnalog(padapter
, true);
1576 /* RT_TRACE(COMP_INIT, DBG_LOUD,
1577 ("<====== Card Disable Without HWSM .\n")); */
1581 void Hal_InitPGData(struct rtw_adapter
*padapter
, u8
*PROMContent
)
1583 struct eeprom_priv
*pEEPROM
= GET_EEPROM_EFUSE_PRIV(padapter
);
1585 if (false == pEEPROM
->bautoload_fail_flag
) { /* autoload OK. */
1586 if (!pEEPROM
->EepromOrEfuse
) {
1587 /* Read EFUSE real map to shadow. */
1588 EFUSE_ShadowMapUpdate23a(padapter
, EFUSE_WIFI
);
1589 memcpy((void *)PROMContent
,
1590 (void *)pEEPROM
->efuse_eeprom_data
,
1593 } else { /* autoload fail */
1594 RT_TRACE(_module_hci_hal_init_c_
, _drv_notice_
,
1595 ("AutoLoad Fail reported from CR9346!!\n"));
1596 /* pHalData->AutoloadFailFlag = true; */
1597 /* update to default value 0xFF */
1598 if (false == pEEPROM
->EepromOrEfuse
)
1599 EFUSE_ShadowMapUpdate23a(padapter
, EFUSE_WIFI
);
1600 memcpy((void *)PROMContent
, (void *)pEEPROM
->efuse_eeprom_data
,
1605 void Hal_EfuseParseIDCode(struct rtw_adapter
*padapter
, u8
*hwinfo
)
1607 struct eeprom_priv
*pEEPROM
= GET_EEPROM_EFUSE_PRIV(padapter
);
1608 /* struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); */
1611 /* Checl 0x8129 again for making sure autoload status!! */
1612 EEPROMId
= le16_to_cpu(*((u16
*) hwinfo
));
1613 if (EEPROMId
!= RTL_EEPROM_ID
) {
1614 DBG_8723A("EEPROM ID(%#x) is invalid!!\n", EEPROMId
);
1615 pEEPROM
->bautoload_fail_flag
= true;
1617 pEEPROM
->bautoload_fail_flag
= false;
1620 RT_TRACE(_module_hal_init_c_
, _drv_info_
,
1621 ("EEPROM ID = 0x%04x\n", EEPROMId
));
1624 static void Hal_EEValueCheck(u8 EEType
, void *pInValue
, void *pOutValue
)
1630 pIn
= (u8
*) pInValue
;
1631 pOut
= (u8
*) pOutValue
;
1635 RT_TRACE(_module_hci_hal_init_c_
, _drv_err_
,
1636 ("EETYPE_TX_PWR, value =%d is invalid, set "
1637 "to default = 0x%x\n",
1638 *pIn
, EEPROM_Default_TxPowerLevel
));
1639 *pOut
= EEPROM_Default_TxPowerLevel
;
1649 Hal_ReadPowerValueFromPROM_8723A(struct txpowerinfo
*pwrInfo
,
1650 u8
*PROMContent
, bool AutoLoadFail
)
1652 u32 rfPath
, eeAddr
, group
, rfPathMax
= 1;
1654 memset(pwrInfo
, 0, sizeof(*pwrInfo
));
1657 for (group
= 0; group
< MAX_CHNL_GROUP
; group
++) {
1658 for (rfPath
= 0; rfPath
< rfPathMax
; rfPath
++) {
1659 pwrInfo
->CCKIndex
[rfPath
][group
] =
1660 EEPROM_Default_TxPowerLevel
;
1661 pwrInfo
->HT40_1SIndex
[rfPath
][group
] =
1662 EEPROM_Default_TxPowerLevel
;
1663 pwrInfo
->HT40_2SIndexDiff
[rfPath
][group
] =
1664 EEPROM_Default_HT40_2SDiff
;
1665 pwrInfo
->HT20IndexDiff
[rfPath
][group
] =
1666 EEPROM_Default_HT20_Diff
;
1667 pwrInfo
->OFDMIndexDiff
[rfPath
][group
] =
1668 EEPROM_Default_LegacyHTTxPowerDiff
;
1669 pwrInfo
->HT40MaxOffset
[rfPath
][group
] =
1670 EEPROM_Default_HT40_PwrMaxOffset
;
1671 pwrInfo
->HT20MaxOffset
[rfPath
][group
] =
1672 EEPROM_Default_HT20_PwrMaxOffset
;
1675 pwrInfo
->TSSI_A
[0] = EEPROM_Default_TSSI
;
1679 for (rfPath
= 0; rfPath
< rfPathMax
; rfPath
++) {
1680 for (group
= 0; group
< MAX_CHNL_GROUP
; group
++) {
1682 EEPROM_CCK_TX_PWR_INX_8723A
+ (rfPath
* 3) + group
;
1683 /* pwrInfo->CCKIndex[rfPath][group] =
1684 PROMContent[eeAddr]; */
1685 Hal_EEValueCheck(EETYPE_TX_PWR
, &PROMContent
[eeAddr
],
1686 &pwrInfo
->CCKIndex
[rfPath
][group
]);
1687 eeAddr
= EEPROM_HT40_1S_TX_PWR_INX_8723A
+
1688 (rfPath
* 3) + group
;
1689 /* pwrInfo->HT40_1SIndex[rfPath][group] =
1690 PROMContent[eeAddr]; */
1691 Hal_EEValueCheck(EETYPE_TX_PWR
, &PROMContent
[eeAddr
],
1692 &pwrInfo
->HT40_1SIndex
[rfPath
][group
]);
1696 for (group
= 0; group
< MAX_CHNL_GROUP
; group
++) {
1697 for (rfPath
= 0; rfPath
< rfPathMax
; rfPath
++) {
1698 pwrInfo
->HT40_2SIndexDiff
[rfPath
][group
] = 0;
1699 pwrInfo
->HT20IndexDiff
[rfPath
][group
] =
1701 [EEPROM_HT20_TX_PWR_INX_DIFF_8723A
+
1702 group
] >> (rfPath
* 4)) & 0xF;
1703 /* 4bit sign number to 8 bit sign number */
1704 if (pwrInfo
->HT20IndexDiff
[rfPath
][group
] & BIT(3))
1705 pwrInfo
->HT20IndexDiff
[rfPath
][group
] |= 0xF0;
1707 pwrInfo
->OFDMIndexDiff
[rfPath
][group
] =
1708 (PROMContent
[EEPROM_OFDM_TX_PWR_INX_DIFF_8723A
+
1709 group
] >> (rfPath
* 4)) & 0xF;
1711 pwrInfo
->HT40MaxOffset
[rfPath
][group
] =
1712 (PROMContent
[EEPROM_HT40_MAX_PWR_OFFSET_8723A
+
1713 group
] >> (rfPath
* 4)) & 0xF;
1715 pwrInfo
->HT20MaxOffset
[rfPath
][group
] =
1716 (PROMContent
[EEPROM_HT20_MAX_PWR_OFFSET_8723A
+
1717 group
] >> (rfPath
* 4)) & 0xF;
1721 pwrInfo
->TSSI_A
[0] = PROMContent
[EEPROM_TSSI_A_8723A
];
1724 static u8
Hal_GetChnlGroup(u8 chnl
)
1728 if (chnl
< 3) /* Cjanel 1-3 */
1730 else if (chnl
< 9) /* Channel 4-9 */
1732 else /* Channel 10-14 */
1739 Hal_EfuseParsetxpowerinfo_8723A(struct rtw_adapter
*padapter
,
1740 u8
*PROMContent
, bool AutoLoadFail
)
1742 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
1743 struct txpowerinfo pwrInfo
;
1744 u8 rfPath
, ch
, group
, rfPathMax
= 1;
1747 Hal_ReadPowerValueFromPROM_8723A(&pwrInfo
, PROMContent
, AutoLoadFail
);
1748 for (rfPath
= 0; rfPath
< rfPathMax
; rfPath
++) {
1749 for (ch
= 0; ch
< CHANNEL_MAX_NUMBER
; ch
++) {
1750 group
= Hal_GetChnlGroup(ch
);
1752 pHalData
->TxPwrLevelCck
[rfPath
][ch
] =
1753 pwrInfo
.CCKIndex
[rfPath
][group
];
1754 pHalData
->TxPwrLevelHT40_1S
[rfPath
][ch
] =
1755 pwrInfo
.HT40_1SIndex
[rfPath
][group
];
1757 pHalData
->TxPwrHt20Diff
[rfPath
][ch
] =
1758 pwrInfo
.HT20IndexDiff
[rfPath
][group
];
1759 pHalData
->TxPwrLegacyHtDiff
[rfPath
][ch
] =
1760 pwrInfo
.OFDMIndexDiff
[rfPath
][group
];
1761 pHalData
->PwrGroupHT20
[rfPath
][ch
] =
1762 pwrInfo
.HT20MaxOffset
[rfPath
][group
];
1763 pHalData
->PwrGroupHT40
[rfPath
][ch
] =
1764 pwrInfo
.HT40MaxOffset
[rfPath
][group
];
1766 pwr
= pwrInfo
.HT40_1SIndex
[rfPath
][group
];
1767 diff
= pwrInfo
.HT40_2SIndexDiff
[rfPath
][group
];
1769 pHalData
->TxPwrLevelHT40_2S
[rfPath
][ch
] =
1770 (pwr
> diff
) ? (pwr
- diff
) : 0;
1773 for (rfPath
= 0; rfPath
< RF_PATH_MAX
; rfPath
++) {
1774 for (ch
= 0; ch
< CHANNEL_MAX_NUMBER
; ch
++) {
1775 RT_TRACE(_module_hci_hal_init_c_
, _drv_info_
,
1776 ("RF(%u)-Ch(%u) [CCK / HT40_1S / HT40_2S] = "
1777 "[0x%x / 0x%x / 0x%x]\n",
1779 pHalData
->TxPwrLevelCck
[rfPath
][ch
],
1780 pHalData
->TxPwrLevelHT40_1S
[rfPath
][ch
],
1781 pHalData
->TxPwrLevelHT40_2S
[rfPath
][ch
]));
1785 for (ch
= 0; ch
< CHANNEL_MAX_NUMBER
; ch
++) {
1786 RT_TRACE(_module_hci_hal_init_c_
, _drv_info_
,
1787 ("RF-A Ht20 to HT40 Diff[%u] = 0x%x(%d)\n", ch
,
1788 pHalData
->TxPwrHt20Diff
[RF_PATH_A
][ch
],
1789 pHalData
->TxPwrHt20Diff
[RF_PATH_A
][ch
]));
1791 for (ch
= 0; ch
< CHANNEL_MAX_NUMBER
; ch
++)
1792 RT_TRACE(_module_hci_hal_init_c_
, _drv_info_
,
1793 ("RF-A Legacy to Ht40 Diff[%u] = 0x%x\n", ch
,
1794 pHalData
->TxPwrLegacyHtDiff
[RF_PATH_A
][ch
]));
1795 for (ch
= 0; ch
< CHANNEL_MAX_NUMBER
; ch
++) {
1796 RT_TRACE(_module_hci_hal_init_c_
, _drv_info_
,
1797 ("RF-B Ht20 to HT40 Diff[%u] = 0x%x(%d)\n", ch
,
1798 pHalData
->TxPwrHt20Diff
[RF_PATH_B
][ch
],
1799 pHalData
->TxPwrHt20Diff
[RF_PATH_B
][ch
]));
1801 for (ch
= 0; ch
< CHANNEL_MAX_NUMBER
; ch
++)
1802 RT_TRACE(_module_hci_hal_init_c_
, _drv_info_
,
1803 ("RF-B Legacy to HT40 Diff[%u] = 0x%x\n", ch
,
1804 pHalData
->TxPwrLegacyHtDiff
[RF_PATH_B
][ch
]));
1805 if (!AutoLoadFail
) {
1806 struct registry_priv
*registry_par
= &padapter
->registrypriv
;
1807 if (registry_par
->regulatory_tid
== 0xff) {
1808 if (PROMContent
[RF_OPTION1_8723A
] == 0xff)
1809 pHalData
->EEPROMRegulatory
= 0;
1811 pHalData
->EEPROMRegulatory
=
1812 PROMContent
[RF_OPTION1_8723A
] & 0x7;
1814 pHalData
->EEPROMRegulatory
=
1815 registry_par
->regulatory_tid
;
1818 pHalData
->EEPROMRegulatory
= 0;
1820 RT_TRACE(_module_hci_hal_init_c_
, _drv_info_
,
1821 ("EEPROMRegulatory = 0x%x\n", pHalData
->EEPROMRegulatory
));
1824 pHalData
->bTXPowerDataReadFromEEPORM
= true;
1828 Hal_EfuseParseBTCoexistInfo_8723A(struct rtw_adapter
*padapter
,
1829 u8
*hwinfo
, bool AutoLoadFail
)
1831 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
1835 if (!AutoLoadFail
) {
1836 tmpu4
= rtl8723au_read32(padapter
, REG_MULTI_FUNC_CTRL
);
1837 if (tmpu4
& BT_FUNC_EN
)
1838 pHalData
->EEPROMBluetoothCoexist
= 1;
1840 pHalData
->EEPROMBluetoothCoexist
= 0;
1841 pHalData
->EEPROMBluetoothType
= BT_RTL8723A
;
1843 /* The following need to be checked with newer version of */
1845 tempval
= hwinfo
[RF_OPTION4_8723A
];
1846 pHalData
->EEPROMBluetoothAntNum
= (tempval
& 0x1);
1847 pHalData
->EEPROMBluetoothAntIsolation
= ((tempval
& 0x10) >> 4);
1848 pHalData
->EEPROMBluetoothRadioShared
= ((tempval
& 0x20) >> 5);
1850 pHalData
->EEPROMBluetoothCoexist
= 0;
1851 pHalData
->EEPROMBluetoothType
= BT_RTL8723A
;
1852 pHalData
->EEPROMBluetoothAntNum
= Ant_x2
;
1853 pHalData
->EEPROMBluetoothAntIsolation
= 0;
1854 pHalData
->EEPROMBluetoothRadioShared
= BT_Radio_Shared
;
1857 rtl8723a_BT_init_hal_vars(padapter
);
1861 Hal_EfuseParseEEPROMVer(struct rtw_adapter
*padapter
,
1862 u8
*hwinfo
, bool AutoLoadFail
)
1864 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
1867 pHalData
->EEPROMVersion
= hwinfo
[EEPROM_VERSION_8723A
];
1869 pHalData
->EEPROMVersion
= 1;
1870 RT_TRACE(_module_hci_hal_init_c_
, _drv_info_
,
1871 ("Hal_EfuseParseEEPROMVer(), EEVer = %d\n",
1872 pHalData
->EEPROMVersion
));
1876 rtl8723a_EfuseParseChnlPlan(struct rtw_adapter
*padapter
,
1877 u8
*hwinfo
, bool AutoLoadFail
)
1879 padapter
->mlmepriv
.ChannelPlan
=
1880 hal_com_get_channel_plan23a(padapter
, hwinfo
?
1881 hwinfo
[EEPROM_ChannelPlan_8723A
]:0xFF,
1882 padapter
->registrypriv
.channel_plan
,
1883 RT_CHANNEL_DOMAIN_WORLD_WIDE_13
,
1886 DBG_8723A("mlmepriv.ChannelPlan = 0x%02x\n",
1887 padapter
->mlmepriv
.ChannelPlan
);
1891 Hal_EfuseParseCustomerID(struct rtw_adapter
*padapter
,
1892 u8
*hwinfo
, bool AutoLoadFail
)
1894 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
1896 if (!AutoLoadFail
) {
1897 pHalData
->EEPROMCustomerID
= hwinfo
[EEPROM_CustomID_8723A
];
1898 pHalData
->EEPROMSubCustomerID
=
1899 hwinfo
[EEPROM_SubCustomID_8723A
];
1901 pHalData
->EEPROMCustomerID
= 0;
1902 pHalData
->EEPROMSubCustomerID
= 0;
1904 RT_TRACE(_module_hci_hal_init_c_
, _drv_info_
,
1905 ("EEPROM Customer ID: 0x%2x\n", pHalData
->EEPROMCustomerID
));
1906 RT_TRACE(_module_hci_hal_init_c_
, _drv_info_
,
1907 ("EEPROM SubCustomer ID: 0x%02x\n",
1908 pHalData
->EEPROMSubCustomerID
));
1912 Hal_EfuseParseAntennaDiversity(struct rtw_adapter
*padapter
,
1913 u8
*hwinfo
, bool AutoLoadFail
)
1918 Hal_EfuseParseRateIndicationOption(struct rtw_adapter
*padapter
,
1919 u8
*hwinfo
, bool AutoLoadFail
)
1924 Hal_EfuseParseXtal_8723A(struct rtw_adapter
*pAdapter
,
1925 u8
*hwinfo
, u8 AutoLoadFail
)
1927 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(pAdapter
);
1929 if (!AutoLoadFail
) {
1930 pHalData
->CrystalCap
= hwinfo
[EEPROM_XTAL_K_8723A
];
1931 if (pHalData
->CrystalCap
== 0xFF)
1932 pHalData
->CrystalCap
= EEPROM_Default_CrystalCap_8723A
;
1934 pHalData
->CrystalCap
= EEPROM_Default_CrystalCap_8723A
;
1936 RT_TRACE(_module_hci_hal_init_c_
, _drv_info_
,
1937 ("%s: CrystalCap = 0x%2x\n", __func__
,
1938 pHalData
->CrystalCap
));
1942 Hal_EfuseParseThermalMeter_8723A(struct rtw_adapter
*padapter
,
1943 u8
*PROMContent
, bool AutoloadFail
)
1945 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
1948 /* ThermalMeter from EEPROM */
1950 if (AutoloadFail
== false)
1951 pHalData
->EEPROMThermalMeter
=
1952 PROMContent
[EEPROM_THERMAL_METER_8723A
];
1954 pHalData
->EEPROMThermalMeter
= EEPROM_Default_ThermalMeter
;
1956 if ((pHalData
->EEPROMThermalMeter
== 0xff) || (AutoloadFail
== true)) {
1957 pHalData
->bAPKThermalMeterIgnore
= true;
1958 pHalData
->EEPROMThermalMeter
= EEPROM_Default_ThermalMeter
;
1961 DBG_8723A("%s: ThermalMeter = 0x%x\n", __func__
,
1962 pHalData
->EEPROMThermalMeter
);
1965 void Hal_InitChannelPlan23a(struct rtw_adapter
*padapter
)
1969 static void rtl8723a_cal_txdesc_chksum(struct tx_desc
*ptxdesc
)
1971 u16
*usPtr
= (u16
*) ptxdesc
;
1972 u32 count
= 16; /* (32 bytes / 2 bytes per XOR) => 16 times */
1977 ptxdesc
->txdw7
&= cpu_to_le32(0xffff0000);
1979 for (index
= 0; index
< count
; index
++) {
1980 checksum
^= le16_to_cpu(*(usPtr
+ index
));
1983 ptxdesc
->txdw7
|= cpu_to_le32(checksum
& 0x0000ffff);
1986 static void fill_txdesc_sectype(struct pkt_attrib
*pattrib
,
1987 struct txdesc_8723a
*ptxdesc
)
1989 if ((pattrib
->encrypt
> 0) && !pattrib
->bswenc
) {
1990 switch (pattrib
->encrypt
) {
1992 case WLAN_CIPHER_SUITE_WEP40
:
1993 case WLAN_CIPHER_SUITE_WEP104
:
1994 case WLAN_CIPHER_SUITE_TKIP
:
1995 ptxdesc
->sectype
= 1;
1998 case WLAN_CIPHER_SUITE_CCMP
:
1999 ptxdesc
->sectype
= 3;
2009 static void fill_txdesc_vcs(struct pkt_attrib
*pattrib
,
2010 struct txdesc_8723a
*ptxdesc
)
2012 /* DBG_8723A("cvs_mode =%d\n", pattrib->vcs_mode); */
2014 switch (pattrib
->vcs_mode
) {
2020 ptxdesc
->cts2self
= 1;
2028 if (pattrib
->vcs_mode
) {
2029 ptxdesc
->hw_rts_en
= 1; /* ENABLE HW RTS */
2032 if (pattrib
->ht_en
) {
2033 if (pattrib
->bwmode
& HT_CHANNEL_WIDTH_40
)
2034 ptxdesc
->rts_bw
= 1;
2036 switch (pattrib
->ch_offset
) {
2037 case HAL_PRIME_CHNL_OFFSET_DONT_CARE
:
2038 ptxdesc
->rts_sc
= 0;
2041 case HAL_PRIME_CHNL_OFFSET_LOWER
:
2042 ptxdesc
->rts_sc
= 1;
2045 case HAL_PRIME_CHNL_OFFSET_UPPER
:
2046 ptxdesc
->rts_sc
= 2;
2050 ptxdesc
->rts_sc
= 3; /* Duplicate */
2057 static void fill_txdesc_phy(struct pkt_attrib
*pattrib
,
2058 struct txdesc_8723a
*ptxdesc
)
2060 if (pattrib
->ht_en
) {
2061 if (pattrib
->bwmode
& HT_CHANNEL_WIDTH_40
)
2062 ptxdesc
->data_bw
= 1;
2064 switch (pattrib
->ch_offset
) {
2065 case HAL_PRIME_CHNL_OFFSET_DONT_CARE
:
2066 ptxdesc
->data_sc
= 0;
2069 case HAL_PRIME_CHNL_OFFSET_LOWER
:
2070 ptxdesc
->data_sc
= 1;
2073 case HAL_PRIME_CHNL_OFFSET_UPPER
:
2074 ptxdesc
->data_sc
= 2;
2078 ptxdesc
->data_sc
= 3; /* Duplicate */
2084 static void rtl8723a_fill_default_txdesc(struct xmit_frame
*pxmitframe
,
2087 struct rtw_adapter
*padapter
;
2088 struct hal_data_8723a
*pHalData
;
2089 struct dm_priv
*pdmpriv
;
2090 struct mlme_ext_priv
*pmlmeext
;
2091 struct mlme_ext_info
*pmlmeinfo
;
2092 struct pkt_attrib
*pattrib
;
2093 struct txdesc_8723a
*ptxdesc
;
2096 padapter
= pxmitframe
->padapter
;
2097 pHalData
= GET_HAL_DATA(padapter
);
2098 pdmpriv
= &pHalData
->dmpriv
;
2099 pmlmeext
= &padapter
->mlmeextpriv
;
2100 pmlmeinfo
= &pmlmeext
->mlmext_info
;
2102 pattrib
= &pxmitframe
->attrib
;
2103 bmcst
= is_multicast_ether_addr(pattrib
->ra
);
2105 ptxdesc
= (struct txdesc_8723a
*)pbuf
;
2107 if (pxmitframe
->frame_tag
== DATA_FRAMETAG
) {
2108 ptxdesc
->macid
= pattrib
->mac_id
; /* CAM_ID(MAC_ID) */
2110 if (pattrib
->ampdu_en
== true)
2111 ptxdesc
->agg_en
= 1; /* AGG EN */
2113 ptxdesc
->bk
= 1; /* AGG BK */
2115 ptxdesc
->qsel
= pattrib
->qsel
;
2116 ptxdesc
->rate_id
= pattrib
->raid
;
2118 fill_txdesc_sectype(pattrib
, ptxdesc
);
2120 ptxdesc
->seq
= pattrib
->seqnum
;
2122 if ((pattrib
->ether_type
!= 0x888e) &&
2123 (pattrib
->ether_type
!= 0x0806) &&
2124 (pattrib
->dhcp_pkt
!= 1)) {
2125 /* Non EAP & ARP & DHCP type data packet */
2127 fill_txdesc_vcs(pattrib
, ptxdesc
);
2128 fill_txdesc_phy(pattrib
, ptxdesc
);
2130 ptxdesc
->rtsrate
= 8; /* RTS Rate = 24M */
2131 ptxdesc
->data_ratefb_lmt
= 0x1F;
2132 ptxdesc
->rts_ratefb_lmt
= 0xF;
2134 /* use REG_INIDATA_RATE_SEL value */
2136 pdmpriv
->INIDATA_RATE
[pattrib
->mac_id
];
2139 /* EAP data packet and ARP packet. */
2140 /* Use the 1M data rate to send the EAP/ARP packet. */
2141 /* This will maybe make the handshake smooth. */
2143 ptxdesc
->bk
= 1; /* AGG BK */
2144 ptxdesc
->userate
= 1; /* driver uses rate */
2145 if (pmlmeinfo
->preamble_mode
== PREAMBLE_SHORT
)
2146 ptxdesc
->data_short
= 1;
2147 ptxdesc
->datarate
= MRateToHwRate23a(pmlmeext
->tx_rate
);
2149 } else if (pxmitframe
->frame_tag
== MGNT_FRAMETAG
) {
2150 /* RT_TRACE(_module_hal_xmit_c_, _drv_notice_,
2151 ("%s: MGNT_FRAMETAG\n", __func__)); */
2153 ptxdesc
->macid
= pattrib
->mac_id
; /* CAM_ID(MAC_ID) */
2154 ptxdesc
->qsel
= pattrib
->qsel
;
2155 ptxdesc
->rate_id
= pattrib
->raid
; /* Rate ID */
2156 ptxdesc
->seq
= pattrib
->seqnum
;
2157 ptxdesc
->userate
= 1; /* driver uses rate, 1M */
2158 ptxdesc
->rty_lmt_en
= 1; /* retry limit enable */
2159 ptxdesc
->data_rt_lmt
= 6; /* retry limit = 6 */
2161 /* CCX-TXRPT ack for xmit mgmt frames. */
2162 if (pxmitframe
->ack_report
)
2165 ptxdesc
->datarate
= MRateToHwRate23a(pmlmeext
->tx_rate
);
2166 } else if (pxmitframe
->frame_tag
== TXAGG_FRAMETAG
) {
2167 RT_TRACE(_module_hal_xmit_c_
, _drv_warning_
,
2168 ("%s: TXAGG_FRAMETAG\n", __func__
));
2170 RT_TRACE(_module_hal_xmit_c_
, _drv_warning_
,
2171 ("%s: frame_tag = 0x%x\n", __func__
,
2172 pxmitframe
->frame_tag
));
2174 ptxdesc
->macid
= 4; /* CAM_ID(MAC_ID) */
2175 ptxdesc
->rate_id
= 6; /* Rate ID */
2176 ptxdesc
->seq
= pattrib
->seqnum
;
2177 ptxdesc
->userate
= 1; /* driver uses rate */
2178 ptxdesc
->datarate
= MRateToHwRate23a(pmlmeext
->tx_rate
);
2181 ptxdesc
->pktlen
= pattrib
->last_txcmdsz
;
2182 ptxdesc
->offset
= TXDESC_SIZE
+ OFFSET_SZ
;
2189 /* 2009.11.05. tynli_test. Suggested by SD4 Filen for FW LPS. */
2190 /* (1) The sequence number of each non-Qos frame / broadcast /
2191 * multicast / mgnt frame should be controled by Hw because Fw
2192 * will also send null data which we cannot control when Fw LPS enable.
2193 * --> default enable non-Qos data sequense number.
2194 2010.06.23. by tynli. */
2195 /* (2) Enable HW SEQ control for beacon packet,
2196 * because we use Hw beacon. */
2197 /* (3) Use HW Qos SEQ to control the seq num of Ext port
2198 * non-Qos packets. */
2199 /* 2010.06.23. Added by tynli. */
2200 if (!pattrib
->qos_en
) {
2201 /* Hw set sequence number */
2202 ptxdesc
->hwseq_en
= 1; /* HWSEQ_EN */
2203 ptxdesc
->hwseq_sel
= 0; /* HWSEQ_SEL */
2211 * pxmitframe xmitframe
2212 * pbuf where to fill tx desc
2214 void rtl8723a_update_txdesc(struct xmit_frame
*pxmitframe
, u8
*pbuf
)
2216 struct tx_desc
*pdesc
;
2218 pdesc
= (struct tx_desc
*)pbuf
;
2219 memset(pdesc
, 0, sizeof(struct tx_desc
));
2221 rtl8723a_fill_default_txdesc(pxmitframe
, pbuf
);
2223 pdesc
->txdw0
= cpu_to_le32(pdesc
->txdw0
);
2224 pdesc
->txdw1
= cpu_to_le32(pdesc
->txdw1
);
2225 pdesc
->txdw2
= cpu_to_le32(pdesc
->txdw2
);
2226 pdesc
->txdw3
= cpu_to_le32(pdesc
->txdw3
);
2227 pdesc
->txdw4
= cpu_to_le32(pdesc
->txdw4
);
2228 pdesc
->txdw5
= cpu_to_le32(pdesc
->txdw5
);
2229 pdesc
->txdw6
= cpu_to_le32(pdesc
->txdw6
);
2230 pdesc
->txdw7
= cpu_to_le32(pdesc
->txdw7
);
2231 rtl8723a_cal_txdesc_chksum(pdesc
);
2235 * Description: In normal chip, we should send some packet to Hw which
2236 * will be used by Fw in FW LPS mode. The function is to fill the Tx
2237 * descriptor of this packets, then
2239 /* Fw can tell Hw to send these packet derectly. */
2240 /* Added by tynli. 2009.10.15. */
2242 void rtl8723a_fill_fake_txdesc(struct rtw_adapter
*padapter
, u8
*pDesc
,
2243 u32 BufferLen
, u8 IsPsPoll
, u8 IsBTQosNull
)
2245 struct tx_desc
*ptxdesc
;
2247 /* Clear all status */
2248 ptxdesc
= (struct tx_desc
*)pDesc
;
2249 memset(pDesc
, 0, TXDESC_SIZE
);
2252 /* own, bFirstSeg, bLastSeg; */
2253 ptxdesc
->txdw0
|= cpu_to_le32(OWN
| FSG
| LSG
);
2255 /* 32 bytes for TX Desc */
2256 ptxdesc
->txdw0
|= cpu_to_le32(((TXDESC_SIZE
+ OFFSET_SZ
) <<
2257 OFFSET_SHT
) & 0x00ff0000);
2259 /* Buffer size + command header */
2260 ptxdesc
->txdw0
|= cpu_to_le32(BufferLen
& 0x0000ffff);
2263 /* Fixed queue of Mgnt queue */
2264 ptxdesc
->txdw1
|= cpu_to_le32((QSLT_MGNT
<< QSEL_SHT
) & 0x00001f00);
2266 /* Set NAVUSEHDR to prevent Ps-poll AId filed to be changed
2267 to error vlaue by Hw. */
2269 ptxdesc
->txdw1
|= cpu_to_le32(NAVUSEHDR
);
2271 /* Hw set sequence number */
2272 ptxdesc
->txdw4
|= cpu_to_le32(BIT(7));
2273 /* set bit3 to 1. Suugested by TimChen. 2009.12.29. */
2274 ptxdesc
->txdw3
|= cpu_to_le32((8 << 28));
2277 if (true == IsBTQosNull
) {
2278 ptxdesc
->txdw2
|= cpu_to_le32(BIT(23)); /* BT NULL */
2282 ptxdesc
->txdw4
|= cpu_to_le32(BIT(8)); /* driver uses rate */
2284 /* USB interface drop packet if the checksum of descriptor isn't
2286 /* Using this checksum can let hardware recovery from packet bulk
2287 out error (e.g. Cancel URC, Bulk out error.). */
2288 rtl8723a_cal_txdesc_chksum(ptxdesc
);
2291 void hw_var_set_opmode(struct rtw_adapter
*padapter
, u8 mode
)
2295 if (mode
== MSR_INFRA
|| mode
== MSR_NOLINK
) {
2296 StopTxBeacon(padapter
);
2298 /* disable atim wnd */
2299 val8
= DIS_TSF_UDT
| EN_BCN_FUNCTION
| DIS_ATIM
;
2300 SetBcnCtrlReg23a(padapter
, val8
, ~val8
);
2301 } else if (mode
== MSR_ADHOC
) {
2302 ResumeTxBeacon(padapter
);
2304 val8
= DIS_TSF_UDT
| EN_BCN_FUNCTION
| DIS_BCNQ_SUB
;
2305 SetBcnCtrlReg23a(padapter
, val8
, ~val8
);
2306 } else if (mode
== MSR_AP
) {
2307 /* add NULL Data and BT NULL Data Packets to FW RSVD Page */
2308 rtl8723a_set_BTCoex_AP_mode_FwRsvdPkt_cmd(padapter
);
2310 ResumeTxBeacon(padapter
);
2312 val8
= DIS_TSF_UDT
| DIS_BCNQ_SUB
;
2313 SetBcnCtrlReg23a(padapter
, val8
, ~val8
);
2316 /* rtl8723au_write32(padapter, REG_RCR, 0x70002a8e);
2317 CBSSID_DATA must set to 0 */
2318 /* CBSSID_DATA must set to 0 */
2319 rtl8723au_write32(padapter
, REG_RCR
, 0x7000228e);
2320 /* enable to rx data frame */
2321 rtl8723au_write16(padapter
, REG_RXFLTMAP2
, 0xFFFF);
2322 /* enable to rx ps-poll */
2323 rtl8723au_write16(padapter
, REG_RXFLTMAP1
, 0x0400);
2325 /* Beacon Control related register for first time */
2327 rtl8723au_write8(padapter
, REG_BCNDMATIM
, 0x02);
2329 rtl8723au_write8(padapter
, REG_DRVERLYINT
, 0x05);
2330 /* 10ms for port0 */
2331 rtl8723au_write8(padapter
, REG_ATIMWND
, 0x0a);
2332 rtl8723au_write16(padapter
, REG_BCNTCFG
, 0x00);
2333 rtl8723au_write16(padapter
, REG_TBTT_PROHIBIT
, 0xff04);
2334 /* +32767 (~32ms) */
2335 rtl8723au_write16(padapter
, REG_TSFTR_SYN_OFFSET
, 0x7fff);
2338 rtl8723au_write8(padapter
, REG_DUAL_TSF_RST
, BIT(0));
2340 /* enable BCN Function */
2341 /* don't enable update TSF (due to TSF update when
2342 beacon/probe rsp are received) */
2343 val8
= DIS_TSF_UDT
| EN_BCN_FUNCTION
|
2344 EN_TXBCN_RPT
| DIS_BCNQ_SUB
;
2345 SetBcnCtrlReg23a(padapter
, val8
, ~val8
);
2348 val8
= rtl8723au_read8(padapter
, MSR
);
2349 val8
= (val8
& 0xC) | mode
;
2350 rtl8723au_write8(padapter
, MSR
, val8
);
2353 void hw_var_set_macaddr(struct rtw_adapter
*padapter
, u8
*val
)
2358 reg_macid
= REG_MACID
;
2360 for (idx
= 0; idx
< 6; idx
++)
2361 rtl8723au_write8(padapter
, (reg_macid
+ idx
), val
[idx
]);
2364 void hw_var_set_bssid(struct rtw_adapter
*padapter
, u8
*val
)
2369 reg_bssid
= REG_BSSID
;
2371 for (idx
= 0; idx
< 6; idx
++)
2372 rtl8723au_write8(padapter
, (reg_bssid
+ idx
), val
[idx
]);
2375 void hw_var_set_correct_tsf(struct rtw_adapter
*padapter
)
2379 struct mlme_ext_priv
*pmlmeext
= &padapter
->mlmeextpriv
;
2380 struct mlme_ext_info
*pmlmeinfo
= &pmlmeext
->mlmext_info
;
2382 /* tsf = pmlmeext->TSFValue - ((u32)pmlmeext->TSFValue %
2383 (pmlmeinfo->bcn_interval*1024)) - 1024; us */
2384 tsf
= pmlmeext
->TSFValue
-
2385 do_div(pmlmeext
->TSFValue
,
2386 (pmlmeinfo
->bcn_interval
* 1024)) - 1024; /* us */
2388 if (((pmlmeinfo
->state
& 0x03) == MSR_ADHOC
) ||
2389 ((pmlmeinfo
->state
& 0x03) == MSR_AP
)) {
2390 /* pHalData->RegTxPause |= STOP_BCNQ;BIT(6) */
2391 /* rtl8723au_write8(padapter, REG_TXPAUSE,
2392 (rtl8723au_read8(Adapter, REG_TXPAUSE)|BIT(6))); */
2393 StopTxBeacon(padapter
);
2396 reg_tsftr
= REG_TSFTR
;
2398 /* disable related TSF function */
2399 SetBcnCtrlReg23a(padapter
, 0, EN_BCN_FUNCTION
);
2401 rtl8723au_write32(padapter
, reg_tsftr
, tsf
);
2402 rtl8723au_write32(padapter
, reg_tsftr
+ 4, tsf
>> 32);
2404 /* enable related TSF function */
2405 SetBcnCtrlReg23a(padapter
, EN_BCN_FUNCTION
, 0);
2407 if (((pmlmeinfo
->state
& 0x03) == MSR_ADHOC
) ||
2408 ((pmlmeinfo
->state
& 0x03) == MSR_AP
))
2409 ResumeTxBeacon(padapter
);
2412 void hw_var_set_mlme_disconnect(struct rtw_adapter
*padapter
)
2414 /* reject all data frames */
2415 rtl8723au_write16(padapter
, REG_RXFLTMAP2
, 0);
2418 rtl8723au_write8(padapter
, REG_DUAL_TSF_RST
, BIT(0));
2420 /* disable update TSF */
2421 SetBcnCtrlReg23a(padapter
, DIS_TSF_UDT
, 0);
2424 void hw_var_set_mlme_join(struct rtw_adapter
*padapter
, u8 type
)
2426 u8 RetryLimit
= 0x30;
2428 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
2429 struct mlme_priv
*pmlmepriv
= &padapter
->mlmepriv
;
2431 if (type
== 0) { /* prepare to join */
2434 /* enable to rx data frame.Accept all data frame */
2435 /* rtl8723au_write32(padapter, REG_RCR,
2436 rtl8723au_read32(padapter, REG_RCR)|RCR_ADF); */
2437 rtl8723au_write16(padapter
, REG_RXFLTMAP2
, 0xFFFF);
2439 v32
= rtl8723au_read32(padapter
, REG_RCR
);
2440 v32
|= RCR_CBSSID_DATA
| RCR_CBSSID_BCN
;
2441 rtl8723au_write32(padapter
, REG_RCR
, v32
);
2443 if (check_fwstate(pmlmepriv
, WIFI_STATION_STATE
) == true)
2445 (pHalData
->CustomerID
== RT_CID_CCX
) ? 7 : 48;
2446 else /* Ad-hoc Mode */
2448 } else if (type
== 1) { /* joinbss_event callback when join res < 0 */
2449 /* config RCR to receive different BSSID & not to
2450 receive data frame during linking */
2451 rtl8723au_write16(padapter
, REG_RXFLTMAP2
, 0);
2452 } else if (type
== 2) { /* sta add event callback */
2453 /* enable update TSF */
2454 SetBcnCtrlReg23a(padapter
, 0, DIS_TSF_UDT
);
2456 if (check_fwstate(pmlmepriv
,
2457 WIFI_ADHOC_STATE
| WIFI_ADHOC_MASTER_STATE
)) {
2458 /* fixed beacon issue for 8191su........... */
2459 rtl8723au_write8(padapter
, 0x542, 0x02);
2464 rtl8723au_write16(padapter
, REG_RL
,
2465 RetryLimit
<< RETRY_LIMIT_SHORT_SHIFT
| RetryLimit
<<
2466 RETRY_LIMIT_LONG_SHIFT
);
2470 /* prepare to join */
2471 rtl8723a_BT_wifiassociate_notify(padapter
, true);
2474 /* joinbss_event callback when join res < 0 */
2475 rtl8723a_BT_wifiassociate_notify(padapter
, false);
2478 /* sta add event callback */
2479 /* BT_WifiMediaStatusNotify(padapter, RT_MEDIA_CONNECT); */