rtl8723b_hal.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
  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. *
  19. ******************************************************************************/
  20. #ifndef __RTL8723B_HAL_H__
  21. #define __RTL8723B_HAL_H__
  22. #include "hal_data.h"
  23. #include "rtl8723b_spec.h"
  24. #include "rtl8723b_rf.h"
  25. #include "rtl8723b_dm.h"
  26. #include "rtl8723b_recv.h"
  27. #include "rtl8723b_xmit.h"
  28. #include "rtl8723b_cmd.h"
  29. #include "rtl8723b_led.h"
  30. #include "Hal8723BPwrSeq.h"
  31. #include "Hal8723BPhyReg.h"
  32. #include "Hal8723BPhyCfg.h"
  33. #ifdef DBG_CONFIG_ERROR_DETECT
  34. #include "rtl8723b_sreset.h"
  35. #endif
  36. #ifdef CONFIG_BT_COEXIST
  37. #include "rtl8723b_bt-coexist.h"
  38. #endif
  39. #if defined(CONFIG_SDIO_HCI) || defined(CONFIG_GSPI_HCI)
  40. //2TODO: We should define 8192S firmware related macro settings here!!
  41. #define RTL819X_DEFAULT_RF_TYPE RF_1T2R
  42. #define RTL819X_TOTAL_RF_PATH 2
  43. //---------------------------------------------------------------------
  44. // RTL8723BS From file
  45. //---------------------------------------------------------------------
  46. #define RTL8723B_FW_IMG "rtl8723B\\rtl8723bfw.bin"
  47. #define RTL8723B_PHY_REG "rtl8723B\\PHY_REG_1T.txt"
  48. #define RTL8723B_PHY_RADIO_A "rtl8723B\\radio_a_1T.txt"
  49. #define RTL8723B_PHY_RADIO_B "rtl8723B\\radio_b_1T.txt"
  50. #define RTL8723B_TXPWR_TRACK "rtl8723B\\TxPowerTrack.txt"
  51. #define RTL8723B_AGC_TAB "rtl8723B\\AGC_TAB_1T.txt"
  52. #define RTL8723B_PHY_MACREG "rtl8723B\\MAC_REG.txt"
  53. #define RTL8723B_PHY_REG_PG "rtl8723B\\PHY_REG_PG.txt"
  54. #define RTL8723B_PHY_REG_MP "rtl8723B\\PHY_REG_MP.txt"
  55. //---------------------------------------------------------------------
  56. // RTL8723BS From header
  57. //---------------------------------------------------------------------
  58. //#define Rtl8723B_FwImageArray Array_MP_8723B_FW_NIC
  59. //#define Rtl8723B_FwImgArrayLength ArrayLength_MP_8723B_FW_NIC
  60. //#define Rtl8723B_FwWoWImageArray Array_MP_8723B_FW_WoWLAN
  61. //#define Rtl8723B_FwWoWImgArrayLength ArrayLength_MP_8723B_FW_WoWLAN
  62. #define Rtl8723B_PHY_REG_Array_PG Rtl8723SPHY_REG_Array_PG
  63. #define Rtl8723B_PHY_REG_Array_PGLength Rtl8723SPHY_REG_Array_PGLength
  64. #if MP_DRIVER == 1
  65. #define Rtl8723B_FwBTImgArray Rtl8723BFwBTImgArray
  66. #define Rtl8723B_FwBTImgArrayLength Rtl8723BFwBTImgArrayLength
  67. #define Rtl8723B_FwMPImageArray Rtl8723BFwMPImgArray
  68. #define Rtl8723B_FwMPImgArrayLength Rtl8723BMPImgArrayLength
  69. #define Rtl8723B_PHY_REG_Array_MP Rtl8723B_PHYREG_Array_MP
  70. #define Rtl8723B_PHY_REG_Array_MPLength Rtl8723B_PHYREG_Array_MPLength
  71. #endif
  72. #endif // CONFIG_SDIO_HCI
  73. #ifdef CONFIG_USB_HCI
  74. //2TODO: We should define 8192S firmware related macro settings here!!
  75. #define RTL819X_DEFAULT_RF_TYPE RF_1T2R
  76. #define RTL819X_TOTAL_RF_PATH 2
  77. //TODO: The following need to check!!
  78. #define RTL8723B_FW_IMG "rtl8192CU\\rtl8723bfw.bin"
  79. #define RTL8723B_PHY_REG "rtl8723B\\PHY_REG_1T.txt"
  80. #define RTL8723B_PHY_RADIO_A "rtl8723B\\radio_a_1T.txt"
  81. #define RTL8723B_PHY_RADIO_B "rtl8723B\\radio_b_1T.txt"
  82. #define RTL8723B_TXPWR_TRACK "rtl8723B\\TxPowerTrack.txt"
  83. #define RTL8723B_AGC_TAB "rtl8723B\\AGC_TAB_1T.txt"
  84. #define RTL8723B_PHY_MACREG "rtl8723B\\MAC_REG.txt"
  85. #define RTL8723B_PHY_REG_PG "rtl8723B\\PHY_REG_PG.txt"
  86. #define RTL8723B_PHY_REG_MP "rtl8723B\\PHY_REG_MP.txt"
  87. //---------------------------------------------------------------------
  88. // RTL8723S From header
  89. //---------------------------------------------------------------------
  90. // Fw Array
  91. //#define Rtl8723B_FwImageArray Rtl8723UFwImgArray
  92. //#define Rtl8723_FwUMCBCutImageArray Rtl8723UFwUMCBCutImgArray
  93. //#define Rtl8723B_ImgArrayLength Rtl8723UImgArrayLength
  94. //#define Rtl8723B_UMCBCutImgArrayLength Rtl8723UUMCBCutImgArrayLength
  95. //#define Rtl8723B_PHY_REG_Array_PG Rtl8723UPHY_REG_Array_PG
  96. //#define Rtl8723B_PHY_REG_Array_PGLength Rtl8723UPHY_REG_Array_PGLength
  97. #if MP_DRIVER == 1
  98. #define Rtl8723B_FwBTImgArray Rtl8723BFwBTImgArray
  99. #define Rtl8723B_FwBTImgArrayLength Rtl8723BFwBTImgArrayLength
  100. #define Rtl8723B_FwMPImageArray Rtl8723BFwMPImgArray
  101. #define Rtl8723B_FwMPImgArrayLength Rtl8723BMPImgArrayLength
  102. #define Rtl8723B_PHY_REG_Array_MP Rtl8723B_PHY_REG_Array_MP
  103. #define Rtl8723B_PHY_REG_Array_MPLength Rtl8723B_PHY_REG_Array_MPLength
  104. #endif
  105. #endif
  106. #define FW_8723B_SIZE 0x8000
  107. #define FW_8723B_START_ADDRESS 0x1000
  108. #define FW_8723B_END_ADDRESS 0x1FFF //0x5FFF
  109. #define IS_FW_HEADER_EXIST_8723B(_pFwHdr) ((le16_to_cpu(_pFwHdr->Signature)&0xFFF0) == 0x5300)
  110. typedef struct _RT_FIRMWARE {
  111. FIRMWARE_SOURCE eFWSource;
  112. #ifdef CONFIG_EMBEDDED_FWIMG
  113. u8* szFwBuffer;
  114. #else
  115. u8 szFwBuffer[FW_8723B_SIZE];
  116. #endif
  117. u32 ulFwLength;
  118. #ifdef CONFIG_EMBEDDED_FWIMG
  119. u8* szBTFwBuffer;
  120. #else
  121. u8 szBTFwBuffer[FW_8723B_SIZE];
  122. #endif
  123. u32 ulBTFwLength;
  124. #ifdef CONFIG_WOWLAN_8723
  125. u8* szWoWLANFwBuffer;
  126. u32 ulWoWLANFwLength;
  127. #endif //CONFIG_WOWLAN_8723
  128. } RT_FIRMWARE_8723B, *PRT_FIRMWARE_8723B;
  129. //
  130. // This structure must be cared byte-ordering
  131. //
  132. // Added by tynli. 2009.12.04.
  133. typedef struct _RT_8723B_FIRMWARE_HDR
  134. {
  135. // 8-byte alinment required
  136. //--- LONG WORD 0 ----
  137. u16 Signature; // 92C0: test chip; 92C, 88C0: test chip; 88C1: MP A-cut; 92C1: MP A-cut
  138. u8 Category; // AP/NIC and USB/PCI
  139. u8 Function; // Reserved for different FW function indcation, for further use when driver needs to download different FW in different conditions
  140. u16 Version; // FW Version
  141. u8 Subversion; // FW Subversion, default 0x00
  142. u16 Rsvd1;
  143. //--- LONG WORD 1 ----
  144. u8 Month; // Release time Month field
  145. u8 Date; // Release time Date field
  146. u8 Hour; // Release time Hour field
  147. u8 Minute; // Release time Minute field
  148. u16 RamCodeSize; // The size of RAM code
  149. u16 Rsvd2;
  150. //--- LONG WORD 2 ----
  151. u32 SvnIdx; // The SVN entry index
  152. u32 Rsvd3;
  153. //--- LONG WORD 3 ----
  154. u32 Rsvd4;
  155. u32 Rsvd5;
  156. }RT_8723B_FIRMWARE_HDR, *PRT_8723B_FIRMWARE_HDR;
  157. #define DRIVER_EARLY_INT_TIME_8723B 0x05
  158. #define BCN_DMA_ATIME_INT_TIME_8723B 0x02
  159. // Note: We will divide number of page equally for each queue other than public queue!
  160. #ifdef CONFIG_WOWLAN_8723
  161. #define TX_TOTAL_PAGE_NUMBER_8723B 0xF3
  162. #else
  163. #define TX_TOTAL_PAGE_NUMBER_8723B 0xF8
  164. #endif //CONFIG_WOWLAN_8723
  165. #define TX_PAGE_BOUNDARY_8723B (TX_TOTAL_PAGE_NUMBER_8723B + 1)
  166. #ifdef CONFIG_WOWLAN_8723
  167. // For Normal Chip Setting
  168. // (HPQ + LPQ + NPQ + PUBQ) shall be TX_TOTAL_PAGE_NUMBER_8723B
  169. #define NORMAL_PAGE_NUM_PUBQ_8723B 0xE2
  170. #define NORMAL_PAGE_NUM_HPQ_8723B 0x0C
  171. #define NORMAL_PAGE_NUM_LPQ_8723B 0x02
  172. #define NORMAL_PAGE_NUM_NPQ_8723B 0x02
  173. #else
  174. // For Normal Chip Setting
  175. // (HPQ + LPQ + NPQ + PUBQ) shall be TX_TOTAL_PAGE_NUMBER_8723B
  176. #define NORMAL_PAGE_NUM_PUBQ_8723B 0xE7
  177. #define NORMAL_PAGE_NUM_HPQ_8723B 0x0C
  178. #define NORMAL_PAGE_NUM_LPQ_8723B 0x02
  179. #define NORMAL_PAGE_NUM_NPQ_8723B 0x02
  180. #endif //CONFIG_WOWLAN_8723
  181. // For Test Chip Setting
  182. // (HPQ + LPQ + PUBQ) shall be TX_TOTAL_PAGE_NUMBER_8723B
  183. #define TEST_PAGE_NUM_PUBQ 0x7E
  184. // For Test Chip Setting
  185. #define WMM_TEST_TX_TOTAL_PAGE_NUMBER 0xF5
  186. #define WMM_TEST_TX_PAGE_BOUNDARY (WMM_TEST_TX_TOTAL_PAGE_NUMBER + 1) //F6
  187. #define WMM_TEST_PAGE_NUM_PUBQ 0xA3
  188. #define WMM_TEST_PAGE_NUM_HPQ 0x29
  189. #define WMM_TEST_PAGE_NUM_LPQ 0x29
  190. #ifdef CONFIG_WOWLAN_8723
  191. // Note: For Normal Chip Setting, modify later
  192. #define WMM_NORMAL_TX_TOTAL_PAGE_NUMBER 0xF3
  193. #define WMM_NORMAL_TX_PAGE_BOUNDARY (WMM_TEST_TX_TOTAL_PAGE_NUMBER + 1) //F6
  194. #define WMM_NORMAL_PAGE_NUM_PUBQ_8723B 0xAE
  195. #define WMM_NORMAL_PAGE_NUM_HPQ_8723B 0x29
  196. #define WMM_NORMAL_PAGE_NUM_LPQ_8723B 0x1C
  197. #define WMM_NORMAL_PAGE_NUM_NPQ_8723B 0x1C
  198. #else
  199. // Note: For Normal Chip Setting, modify later
  200. #define WMM_NORMAL_TX_TOTAL_PAGE_NUMBER 0xF5
  201. #define WMM_NORMAL_TX_PAGE_BOUNDARY (WMM_TEST_TX_TOTAL_PAGE_NUMBER + 1) //F6
  202. #define WMM_NORMAL_PAGE_NUM_PUBQ_8723B 0xB0
  203. #define WMM_NORMAL_PAGE_NUM_HPQ_8723B 0x29
  204. #define WMM_NORMAL_PAGE_NUM_LPQ_8723B 0x1C
  205. #define WMM_NORMAL_PAGE_NUM_NPQ_8723B 0x1C
  206. #endif //CONFIG_WOWLAN_8723
  207. #include "HalVerDef.h"
  208. #include "hal_com.h"
  209. #define EFUSE_OOB_PROTECT_BYTES 15
  210. #define HAL_EFUSE_MEMORY
  211. #define HWSET_MAX_SIZE_8723B 512
  212. #define EFUSE_REAL_CONTENT_LEN_8723B 512
  213. #define EFUSE_MAP_LEN_8723B 512
  214. #define EFUSE_MAX_SECTION_8723B 64
  215. #define EFUSE_IC_ID_OFFSET 506 //For some inferiority IC purpose. added by Roger, 2009.09.02.
  216. #define AVAILABLE_EFUSE_ADDR(addr) (addr < EFUSE_REAL_CONTENT_LEN_8723B)
  217. #define EFUSE_ACCESS_ON 0x69 // For RTL8723 only.
  218. #define EFUSE_ACCESS_OFF 0x00 // For RTL8723 only.
  219. //========================================================
  220. // EFUSE for BT definition
  221. //========================================================
  222. #define EFUSE_BT_REAL_BANK_CONTENT_LEN 512
  223. #define EFUSE_BT_REAL_CONTENT_LEN 1536 // 512*3
  224. #define EFUSE_BT_MAP_LEN 1024 // 1k bytes
  225. #define EFUSE_BT_MAX_SECTION 128 // 1024/8
  226. #define EFUSE_PROTECT_BYTES_BANK 16
  227. // Description: Determine the types of C2H events that are the same in driver and Fw.
  228. // Fisrt constructed by tynli. 2009.10.09.
  229. typedef enum _C2H_EVT
  230. {
  231. C2H_DBG = 0,
  232. C2H_TSF = 1,
  233. C2H_AP_RPT_RSP = 2,
  234. C2H_CCX_TX_RPT = 3, // The FW notify the report of the specific tx packet.
  235. C2H_BT_RSSI = 4,
  236. C2H_BT_OP_MODE = 5,
  237. C2H_EXT_RA_RPT = 6,
  238. C2H_8723B_BT_INFO = 9,
  239. C2H_HW_INFO_EXCH = 10,
  240. C2H_8723B_BT_MP_INFO = 11,
  241. MAX_C2HEVENT
  242. } C2H_EVT;
  243. #define GET_RF_TYPE(priv) (GET_HAL_DATA(priv)->rf_type)
  244. #define INCLUDE_MULTI_FUNC_BT(_Adapter) (GET_HAL_DATA(_Adapter)->MultiFunc & RT_MULTI_FUNC_BT)
  245. #define INCLUDE_MULTI_FUNC_GPS(_Adapter) (GET_HAL_DATA(_Adapter)->MultiFunc & RT_MULTI_FUNC_GPS)
  246. // rtl8723a_hal_init.c
  247. s32 rtl8723b_FirmwareDownload(PADAPTER padapter, BOOLEAN bUsedWoWLANFw);
  248. void rtl8723b_FirmwareSelfReset(PADAPTER padapter);
  249. void rtl8723b_InitializeFirmwareVars(PADAPTER padapter);
  250. void rtl8723b_InitAntenna_Selection(PADAPTER padapter);
  251. void rtl8723b_DeinitAntenna_Selection(PADAPTER padapter);
  252. void rtl8723b_CheckAntenna_Selection(PADAPTER padapter);
  253. void rtl8723b_init_default_value(PADAPTER padapter);
  254. s32 InitLLTTable(PADAPTER padapter, u32 boundary);
  255. s32 CardDisableHWSM(PADAPTER padapter, u8 resetMCU);
  256. s32 CardDisableWithoutHWSM(PADAPTER padapter);
  257. // EFuse
  258. u8 GetEEPROMSize8723B(PADAPTER padapter);
  259. void Hal_InitPGData(PADAPTER padapter, u8 *PROMContent);
  260. void Hal_EfuseParseIDCode(PADAPTER padapter, u8 *hwinfo);
  261. void Hal_EfuseParseTxPowerInfo_8723B(PADAPTER padapter, u8 *PROMContent, BOOLEAN AutoLoadFail);
  262. void Hal_EfuseParseBTCoexistInfo_8723B(PADAPTER padapter, u8 *hwinfo, BOOLEAN AutoLoadFail);
  263. void Hal_EfuseParseEEPROMVer_8723B(PADAPTER padapter, u8 *hwinfo, BOOLEAN AutoLoadFail);
  264. void Hal_EfuseParseChnlPlan_8723B(PADAPTER padapter, u8 *hwinfo, BOOLEAN AutoLoadFail);
  265. void Hal_EfuseParseCustomerID_8723B(PADAPTER padapter, u8 *hwinfo, BOOLEAN AutoLoadFail);
  266. void Hal_EfuseParseAntennaDiversity_8723B(PADAPTER padapter, u8 *hwinfo, BOOLEAN AutoLoadFail);
  267. void Hal_EfuseParseXtal_8723B(PADAPTER pAdapter, u8 *hwinfo, u8 AutoLoadFail);
  268. void Hal_EfuseParseThermalMeter_8723B(PADAPTER padapter, u8 *hwinfo, u8 AutoLoadFail);
  269. void rtl8723b_set_hal_ops(struct hal_ops *pHalFunc);
  270. void SetHwReg8723B(PADAPTER padapter, u8 variable, u8 *val);
  271. void GetHwReg8723B(PADAPTER padapter, u8 variable, u8 *val);
  272. #ifdef CONFIG_BT_COEXIST
  273. void rtl8723b_SingleDualAntennaDetection(PADAPTER padapter);
  274. #endif
  275. // register
  276. void SetBcnCtrlReg(PADAPTER padapter, u8 SetBits, u8 ClearBits);
  277. void rtl8723b_InitBeaconParameters(PADAPTER padapter);
  278. void rtl8723b_InitBeaconMaxError(PADAPTER padapter, u8 InfraMode);
  279. #ifdef CONFIG_WOWLAN_8723
  280. void _8051Reset8723(PADAPTER padapter);
  281. void Hal_DetectWoWMode(PADAPTER pAdapter);
  282. #endif //CONFIG_WOWLAN_8723
  283. void rtl8723b_clone_haldata(_adapter *dst_adapter, _adapter *src_adapter);
  284. void rtl8723b_start_thread(_adapter *padapter);
  285. void rtl8723b_stop_thread(_adapter *padapter);
  286. #if defined(CONFIG_CHECK_BT_HANG) && defined(CONFIG_BT_COEXIST)
  287. void rtl8723bs_init_checkbthang_workqueue(_adapter * adapter);
  288. void rtl8723bs_free_checkbthang_workqueue(_adapter * adapter);
  289. void rtl8723bs_cancle_checkbthang_workqueue(_adapter * adapter);
  290. void rtl8723bs_hal_check_bt_hang(_adapter * adapter);
  291. #endif
  292. #ifdef CONFIG_WOWLAN_8723
  293. void rtw_get_current_ip_address(PADAPTER padapter, u8 *pcurrentip);
  294. void rtw_get_sec_iv(PADAPTER padapter, u8*pcur_dot11txpn, u8 *StaAddr);
  295. #endif
  296. s32 c2h_id_filter_ccx_8723b(u8 id);
  297. s32 c2h_handler_8723b(PADAPTER padapter, struct c2h_evt_hdr *pC2hEvent);
  298. #endif