rtl8812a_hal.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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 __RTL8812A_HAL_H__
  21. #define __RTL8812A_HAL_H__
  22. //#include "hal_com.h"
  23. #if 1
  24. #include "hal_data.h"
  25. #else
  26. #include "../hal/OUTSRC/odm_precomp.h"
  27. #endif
  28. //include HAL Related header after HAL Related compiling flags
  29. #include "rtl8812a_spec.h"
  30. #include "rtl8812a_rf.h"
  31. #include "rtl8812a_dm.h"
  32. #include "rtl8812a_recv.h"
  33. #include "rtl8812a_xmit.h"
  34. #include "rtl8812a_cmd.h"
  35. #include "rtl8812a_led.h"
  36. #include "Hal8812PwrSeq.h"
  37. #include "Hal8821APwrSeq.h" //for 8821A/8811A
  38. #include "Hal8812PhyReg.h"
  39. #include "Hal8812PhyCfg.h"
  40. #ifdef DBG_CONFIG_ERROR_DETECT
  41. #include "rtl8812a_sreset.h"
  42. #endif
  43. //---------------------------------------------------------------------
  44. // RTL8812AU From header
  45. //---------------------------------------------------------------------
  46. #define RTL8812_FW_IMG "rtl8812AU\\rtl8812Ufw.bin"
  47. #define RTL8812_FW_WW_IMG "rtl8812AU\\rtl8812Ufwww.bin"
  48. #define RTL8812_PHY_REG "rtl8812AU\\PHY_REG.txt"
  49. #define RTL8812_PHY_RADIO_A "rtl8812AU\\RadioA.txt"
  50. #define RTL8812_PHY_RADIO_B "rtl8812AU\\RadioB.txt"
  51. #define RTL8812_TXPWR_TRACK "rtl8812AU\\TxPowerTrack.txt"
  52. #define RTL8812_AGC_TAB "rtl8812AU\\AGC_TAB.txt"
  53. #define RTL8812_PHY_MACREG "rtl8812AU\\MAC_REG.txt"
  54. #define RTL8812_PHY_REG_PG "rtl8812AU\\PHY_REG_PG.txt"
  55. #define RTL8812_PHY_REG_MP "rtl8812AU\\PHY_REG_MP.txt"
  56. #define RTL8812_TXPWR_LMT "rtl8812AU\\TXPWR_LMT.txt"
  57. //---------------------------------------------------------------------
  58. // RTL8821U From file
  59. //---------------------------------------------------------------------
  60. #define RTL8821_FW_IMG "rtl8821AU\\rtl8821Ufw.bin"
  61. #define RTL8821_FW_WW_IMG "rtl8821AU\\rtl8821Ufwww.bin"
  62. #define RTL8821_PHY_REG "rtl8821AU\\PHY_REG.txt"
  63. #define RTL8821_PHY_RADIO_A "rtl8821AU\\RadioA.txt"
  64. #define RTL8821_PHY_RADIO_B "rtl8821AU\\RadioB.txt"
  65. #define RTL8821_TXPWR_TRACK "rtl8821AU\\TxPowerTrack.txt"
  66. #define RTL8821_AGC_TAB "rtl8821AU\\AGC_TAB.txt"
  67. #define RTL8821_PHY_MACREG "rtl8821AU\\MAC_REG.txt"
  68. #define RTL8821_PHY_REG_PG "rtl8821AU\\PHY_REG_PG.txt"
  69. #define RTL8821_PHY_REG_MP "rtl8821AU\\PHY_REG_MP.txt"
  70. #define RTL8821_TXPWR_LMT "rtl8821AU\\TXPWR_LMT.txt"
  71. //---------------------------------------------------------------------
  72. // RTL8812 Power Configuration CMDs for PCIe interface
  73. //---------------------------------------------------------------------
  74. #define Rtl8812_NIC_PWR_ON_FLOW rtl8812_power_on_flow
  75. #define Rtl8812_NIC_RF_OFF_FLOW rtl8812_radio_off_flow
  76. #define Rtl8812_NIC_DISABLE_FLOW rtl8812_card_disable_flow
  77. #define Rtl8812_NIC_ENABLE_FLOW rtl8812_card_enable_flow
  78. #define Rtl8812_NIC_SUSPEND_FLOW rtl8812_suspend_flow
  79. #define Rtl8812_NIC_RESUME_FLOW rtl8812_resume_flow
  80. #define Rtl8812_NIC_PDN_FLOW rtl8812_hwpdn_flow
  81. #define Rtl8812_NIC_LPS_ENTER_FLOW rtl8812_enter_lps_flow
  82. #define Rtl8812_NIC_LPS_LEAVE_FLOW rtl8812_leave_lps_flow
  83. //---------------------------------------------------------------------
  84. // RTL8821 Power Configuration CMDs for PCIe interface
  85. //---------------------------------------------------------------------
  86. #define Rtl8821A_NIC_PWR_ON_FLOW rtl8821A_power_on_flow
  87. #define Rtl8821A_NIC_RF_OFF_FLOW rtl8821A_radio_off_flow
  88. #define Rtl8821A_NIC_DISABLE_FLOW rtl8821A_card_disable_flow
  89. #define Rtl8821A_NIC_ENABLE_FLOW rtl8821A_card_enable_flow
  90. #define Rtl8821A_NIC_SUSPEND_FLOW rtl8821A_suspend_flow
  91. #define Rtl8821A_NIC_RESUME_FLOW rtl8821A_resume_flow
  92. #define Rtl8821A_NIC_PDN_FLOW rtl8821A_hwpdn_flow
  93. #define Rtl8821A_NIC_LPS_ENTER_FLOW rtl8821A_enter_lps_flow
  94. #define Rtl8821A_NIC_LPS_LEAVE_FLOW rtl8821A_leave_lps_flow
  95. #if 1 // download firmware related data structure
  96. #define FW_SIZE_8812 0x8000 // Compatible with RTL8723 Maximal RAM code size 24K. modified to 32k, TO compatible with 92d maximal fw size 32k
  97. #define FW_START_ADDRESS 0x1000
  98. #define FW_END_ADDRESS 0x5FFF
  99. typedef struct _RT_FIRMWARE_8812 {
  100. FIRMWARE_SOURCE eFWSource;
  101. #ifdef CONFIG_EMBEDDED_FWIMG
  102. u8* szFwBuffer;
  103. #else
  104. u8 szFwBuffer[FW_SIZE_8812];
  105. #endif
  106. u32 ulFwLength;
  107. #ifdef CONFIG_WOWLAN
  108. u8* szWoWLANFwBuffer;
  109. u32 ulWoWLANFwLength;
  110. #endif //CONFIG_WOWLAN
  111. } RT_FIRMWARE_8812, *PRT_FIRMWARE_8812;
  112. //
  113. // This structure must be cared byte-ordering
  114. //
  115. // Added by tynli. 2009.12.04.
  116. #define IS_FW_HEADER_EXIST_8812(_pFwHdr) ((GET_FIRMWARE_HDR_SIGNATURE_8812(_pFwHdr) &0xFFF0) == 0x9500)
  117. #define IS_FW_HEADER_EXIST_8821(_pFwHdr) ((GET_FIRMWARE_HDR_SIGNATURE_8812(_pFwHdr) &0xFFF0) == 0x2100)
  118. //=====================================================
  119. // Firmware Header(8-byte alinment required)
  120. //=====================================================
  121. //--- LONG WORD 0 ----
  122. #define GET_FIRMWARE_HDR_SIGNATURE_8812(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr, 0, 16) // 92C0: test chip; 92C, 88C0: test chip; 88C1: MP A-cut; 92C1: MP A-cut
  123. #define GET_FIRMWARE_HDR_CATEGORY_8812(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr, 16, 8) // AP/NIC and USB/PCI
  124. #define GET_FIRMWARE_HDR_FUNCTION_8812(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr, 24, 8) // Reserved for different FW function indcation, for further use when driver needs to download different FW in different conditions
  125. #define GET_FIRMWARE_HDR_VERSION_8812(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+4, 0, 16)// FW Version
  126. #define GET_FIRMWARE_HDR_SUB_VER_8812(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+4, 16, 8) // FW Subversion, default 0x00
  127. #define GET_FIRMWARE_HDR_RSVD1_8812(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+4, 24, 8)
  128. //--- LONG WORD 1 ----
  129. #define GET_FIRMWARE_HDR_MONTH_8812(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+8, 0, 8) // Release time Month field
  130. #define GET_FIRMWARE_HDR_DATE_8812(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+8, 8, 8) // Release time Date field
  131. #define GET_FIRMWARE_HDR_HOUR_8812(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+8, 16, 8)// Release time Hour field
  132. #define GET_FIRMWARE_HDR_MINUTE_8812(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+8, 24, 8)// Release time Minute field
  133. #define GET_FIRMWARE_HDR_ROMCODE_SIZE_8812(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+12, 0, 16)// The size of RAM code
  134. #define GET_FIRMWARE_HDR_RSVD2_8812(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+12, 16, 16)
  135. //--- LONG WORD 2 ----
  136. #define GET_FIRMWARE_HDR_SVN_IDX_8812(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+16, 0, 32)// The SVN entry index
  137. #define GET_FIRMWARE_HDR_RSVD3_8812(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+20, 0, 32)
  138. //--- LONG WORD 3 ----
  139. #define GET_FIRMWARE_HDR_RSVD4_8812(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+24, 0, 32)
  140. #define GET_FIRMWARE_HDR_RSVD5_8812(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+28, 0, 32)
  141. #endif // download firmware related data structure
  142. #define DRIVER_EARLY_INT_TIME_8812 0x05
  143. #define BCN_DMA_ATIME_INT_TIME_8812 0x02
  144. //for 8812
  145. #define MAX_RX_DMA_BUFFER_SIZE_8812 0x3E80 //0x3FFF // RX 16K
  146. #define TX_TOTAL_PAGE_NUMBER_8812 0xF8
  147. #define TX_PAGE_BOUNDARY_8812 (TX_TOTAL_PAGE_NUMBER_8812 + 1)
  148. #define TX_PAGE_LOAD_FW_BOUNDARY_8812 0x47 //0xA5
  149. #define TX_PAGE_BOUNDARY_WOWLAN_8812 0xE0
  150. // For Normal Chip Setting
  151. // (HPQ + LPQ + NPQ + PUBQ) shall be TX_TOTAL_PAGE_NUMBER_92C
  152. #define NORMAL_PAGE_NUM_PUBQ_8812 0xD8
  153. #define NORMAL_PAGE_NUM_LPQ_8812 0x10
  154. #define NORMAL_PAGE_NUM_HPQ_8812 0x10
  155. #define NORMAL_PAGE_NUM_NPQ_8812 0x00
  156. //Note: For WMM Normal Chip Setting ,modify later
  157. #define WMM_NORMAL_TX_TOTAL_PAGE_NUMBER_8812 0xFB
  158. #define WMM_NORMAL_TX_PAGE_BOUNDARY_8812 (WMM_NORMAL_TX_TOTAL_PAGE_NUMBER_8812 + 1)
  159. #define WMM_NORMAL_PAGE_NUM_PUBQ_8812 0x8B
  160. #define WMM_NORMAL_PAGE_NUM_HPQ_8812 0x30
  161. #define WMM_NORMAL_PAGE_NUM_LPQ_8812 0x20
  162. #define WMM_NORMAL_PAGE_NUM_NPQ_8812 0x20
  163. // for 8821A
  164. // TX 64K, RX 16K, Page size 256B for TX, 128B for RX
  165. #define PAGE_SIZE_TX_8821A 256
  166. #define PAGE_SIZE_RX_8821A 128
  167. #define MAX_RX_DMA_BUFFER_SIZE_8821 0x3E80 // RX 16K
  168. // For Normal Chip Setting
  169. #define TX_TOTAL_PAGE_NUMBER_8821 0xF7
  170. #define TX_PAGE_BOUNDARY_8821 (TX_TOTAL_PAGE_NUMBER_8821 + 1)
  171. //#define TX_PAGE_BOUNDARY_WOWLAN_8821 0xE0
  172. // (HPQ + LPQ + NPQ + PUBQ) shall be TX_TOTAL_PAGE_NUMBER
  173. #define NORMAL_PAGE_NUM_PUBQ_8821 0xE7
  174. #define NORMAL_PAGE_NUM_LPQ_8821 0x08
  175. #define NORMAL_PAGE_NUM_HPQ_8821 0x08
  176. #define NORMAL_PAGE_NUM_NPQ_8821 0x00
  177. // For WMM Normal Chip Setting
  178. #define WMM_NORMAL_TX_TOTAL_PAGE_NUMBER_8821 0xFB
  179. #define WMM_NORMAL_TX_PAGE_BOUNDARY_8821 (WMM_NORMAL_TX_TOTAL_PAGE_NUMBER_8821 + 1)
  180. #define WMM_NORMAL_PAGE_NUM_PUBQ_8821 0x8B
  181. #define WMM_NORMAL_PAGE_NUM_HPQ_8821 0x30
  182. #define WMM_NORMAL_PAGE_NUM_LPQ_8821 0x20
  183. #define WMM_NORMAL_PAGE_NUM_NPQ_8821 0x20
  184. #define EFUSE_HIDDEN_812AU 0
  185. #define EFUSE_HIDDEN_812AU_VS 1
  186. #define EFUSE_HIDDEN_812AU_VL 2
  187. #define EFUSE_HIDDEN_812AU_VN 3
  188. #ifdef CONFIG_PCI_HCI
  189. #define EFUSE_REAL_CONTENT_LEN_JAGUAR 1024
  190. #define HWSET_MAX_SIZE_JAGUAR 1024
  191. #else
  192. #define EFUSE_REAL_CONTENT_LEN_JAGUAR 512
  193. #define HWSET_MAX_SIZE_JAGUAR 512
  194. #endif
  195. #define EFUSE_MAX_BANK_8812A 2
  196. #define EFUSE_MAP_LEN_JAGUAR 512
  197. #define EFUSE_MAX_SECTION_JAGUAR 64
  198. #define EFUSE_MAX_WORD_UNIT_JAGUAR 4
  199. #define EFUSE_IC_ID_OFFSET_JAGUAR 506 //For some inferiority IC purpose. added by Roger, 2009.09.02.
  200. #define AVAILABLE_EFUSE_ADDR_8812(addr) (addr < EFUSE_REAL_CONTENT_LEN_JAGUAR)
  201. // <Roger_Notes> To prevent out of boundary programming case, leave 1byte and program full section
  202. // 9bytes + 1byt + 5bytes and pre 1byte.
  203. // For worst case:
  204. // | 2byte|----8bytes----|1byte|--7bytes--| //92D
  205. #define EFUSE_OOB_PROTECT_BYTES_JAGUAR 18 // PG data exclude header, dummy 7 bytes frome CP test and reserved 1byte.
  206. #define EFUSE_PROTECT_BYTES_BANK_JAGUAR 16
  207. // Added for different registry settings to adjust TxPwr index. added by Roger, 2010.03.09.
  208. typedef enum _TX_PWR_PERCENTAGE{
  209. TX_PWR_PERCENTAGE_0 = 0x01, // 12.5%
  210. TX_PWR_PERCENTAGE_1 = 0x02, // 25%
  211. TX_PWR_PERCENTAGE_2 = 0x04, // 50%
  212. TX_PWR_PERCENTAGE_3 = 0x08, //100%, default target output power.
  213. } TX_PWR_PERCENTAGE;
  214. #define GET_RF_TYPE(priv) (GET_HAL_DATA(priv)->rf_type)
  215. #define INCLUDE_MULTI_FUNC_BT(_Adapter) (GET_HAL_DATA(_Adapter)->MultiFunc & RT_MULTI_FUNC_BT)
  216. #define INCLUDE_MULTI_FUNC_GPS(_Adapter) (GET_HAL_DATA(_Adapter)->MultiFunc & RT_MULTI_FUNC_GPS)
  217. //#define IS_MULTI_FUNC_CHIP(_Adapter) (((((PHAL_DATA_TYPE)(_Adapter->HalData))->MultiFunc) & (RT_MULTI_FUNC_BT|RT_MULTI_FUNC_GPS)) ? _TRUE : _FALSE)
  218. //#define RT_IS_FUNC_DISABLED(__pAdapter, __FuncBits) ( (__pAdapter)->DisabledFunctions & (__FuncBits) )
  219. #define GetRegTxBBSwing_2G(_Adapter) (_Adapter->registrypriv.TxBBSwing_2G)
  220. #define GetRegTxBBSwing_5G(_Adapter) (_Adapter->registrypriv.TxBBSwing_5G)
  221. #define GetRegAmplifierType2G(_Adapter) (_Adapter->registrypriv.AmplifierType_2G)
  222. #define GetRegAmplifierType5G(_Adapter) (_Adapter->registrypriv.AmplifierType_5G)
  223. #define GetRegbENRFEType(_Adapter) (_Adapter->registrypriv.bEn_RFE)
  224. #define GetRegRFEType(_Adapter) (_Adapter->registrypriv.RFE_Type)
  225. #define GetDefaultAdapter(padapter) padapter
  226. // rtl8812_hal_init.c
  227. void _8051Reset8812(PADAPTER padapter);
  228. s32 FirmwareDownload8812(PADAPTER Adapter, BOOLEAN bUsedWoWLANFw);
  229. void InitializeFirmwareVars8812(PADAPTER padapter);
  230. s32 InitLLTTable8812(PADAPTER padapter, u8 txpktbuf_bndy);
  231. void InitRDGSetting8812A(PADAPTER padapter);
  232. void CheckAutoloadState8812A(PADAPTER padapter);
  233. // EFuse
  234. u8 GetEEPROMSize8812A(PADAPTER padapter);
  235. void InitPGData8812A(PADAPTER padapter);
  236. void Hal_EfuseParseIDCode8812A(PADAPTER padapter, u8 *hwinfo);
  237. void Hal_ReadPROMVersion8812A(PADAPTER padapter, u8 *hwinfo, BOOLEAN AutoLoadFail);
  238. void Hal_ReadTxPowerInfo8812A(PADAPTER padapter,u8* hwinfo,BOOLEAN AutoLoadFail);
  239. void Hal_ReadBoardType8812A(PADAPTER pAdapter,u8* hwinfo,BOOLEAN AutoLoadFail);
  240. void Hal_ReadThermalMeter_8812A(PADAPTER Adapter,u8* PROMContent,BOOLEAN AutoloadFail);
  241. void Hal_ReadChannelPlan8812A(PADAPTER padapter, u8 *hwinfo, BOOLEAN AutoLoadFail);
  242. void Hal_EfuseParseXtal_8812A(PADAPTER pAdapter,u8* hwinfo,BOOLEAN AutoLoadFail);
  243. void Hal_ReadAntennaDiversity8812A(PADAPTER pAdapter,u8* PROMContent,BOOLEAN AutoLoadFail);
  244. void Hal_ReadPAType_8812A(PADAPTER Adapter,u8* PROMContent, BOOLEAN AutoloadFail);
  245. void Hal_ReadPAType_8821A(PADAPTER Adapter,u8* PROMContent, BOOLEAN AutoloadFail);
  246. void Hal_ReadRFEType_8812A(PADAPTER Adapter,u8* PROMContent, BOOLEAN AutoloadFail);
  247. void Hal_EfuseParseBTCoexistInfo8812A(PADAPTER Adapter, u8* hwinfo, BOOLEAN AutoLoadFail);
  248. void hal_ReadUsbType_8812AU(PADAPTER Adapter, u8 *PROMContent, BOOLEAN AutoloadFail);
  249. BOOLEAN HalDetectPwrDownMode8812(PADAPTER Adapter);
  250. #ifdef CONFIG_WOWLAN
  251. void Hal_DetectWoWMode(PADAPTER pAdapter);
  252. #endif //CONFIG_WOWLAN
  253. void _InitBeaconParameters_8812A(PADAPTER padapter);
  254. void SetBeaconRelatedRegisters8812A(PADAPTER padapter);
  255. void ReadRFType8812A(PADAPTER padapter);
  256. void InitDefaultValue8821A(PADAPTER padapter);
  257. void SetHwReg8812A(PADAPTER padapter, u8 variable, u8 *pval);
  258. void GetHwReg8812A(PADAPTER padapter, u8 variable, u8 *pval);
  259. u8 SetHalDefVar8812A(PADAPTER padapter, HAL_DEF_VARIABLE variable, void *pval);
  260. u8 GetHalDefVar8812A(PADAPTER padapter, HAL_DEF_VARIABLE variable, void *pval);
  261. void rtl8812_set_hal_ops(struct hal_ops *pHalFunc);
  262. // register
  263. void SetBcnCtrlReg(PADAPTER padapter, u8 SetBits, u8 ClearBits);
  264. void rtl8812_clone_haldata(PADAPTER dst_adapter, PADAPTER src_adapter);
  265. void rtl8812_start_thread(PADAPTER padapter);
  266. void rtl8812_stop_thread(PADAPTER padapter);
  267. #endif //__RTL8188E_HAL_H__