rtl8192e_hal.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2007 - 2013 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 __RTL8192E_HAL_H__
  21. #define __RTL8192E_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 "rtl8192e_spec.h"
  30. #include "rtl8192e_rf.h"
  31. #include "rtl8192e_dm.h"
  32. #include "rtl8192e_recv.h"
  33. #include "rtl8192e_xmit.h"
  34. #include "rtl8192e_cmd.h"
  35. #include "rtl8192e_led.h"
  36. #include "Hal8192EPwrSeq.h"
  37. #include "Hal8192EPhyReg.h"
  38. #include "Hal8192EPhyCfg.h"
  39. #ifdef DBG_CONFIG_ERROR_DETECT
  40. #include "rtl8192e_sreset.h"
  41. #endif
  42. //---------------------------------------------------------------------
  43. // RTL8192E From header
  44. //---------------------------------------------------------------------
  45. #define RTL8192E_FW_IMG "rtl192E\\rtl8192Efw.bin"
  46. #define RTL8192E_FW_WW_IMG "rtl192E\\rtl8192Efwww.bin"
  47. #define RTL8192E_PHY_REG "rtl192E\\PHY_REG.txt"
  48. #define RTL8192E_PHY_RADIO_A "rtl192E\\RadioA.txt"
  49. #define RTL8192E_PHY_RADIO_B "rtl192E\\RadioB.txt"
  50. #define RTL8192E_TXPWR_TRACK "rtl192E\\TxPowerTrack.txt"
  51. #define RTL8192E_AGC_TAB "rtl192E\\AGC_TAB.txt"
  52. #define RTL8192E_PHY_MACREG "rtl192E\\MAC_REG.txt"
  53. #define RTL8192E_PHY_REG_PG "rtl192E\\PHY_REG_PG.txt"
  54. #define RTL8192E_PHY_REG_MP "rtl192E\\PHY_REG_MP.txt"
  55. #define RTL8192E_TXPWR_LMT "rtl192E\\TXPWR_LMT.txt"
  56. //---------------------------------------------------------------------
  57. // RTL8192E Power Configuration CMDs for PCIe interface
  58. //---------------------------------------------------------------------
  59. #define Rtl8192E_NIC_PWR_ON_FLOW rtl8192E_power_on_flow
  60. #define Rtl8192E_NIC_RF_OFF_FLOW rtl8192E_radio_off_flow
  61. #define Rtl8192E_NIC_DISABLE_FLOW rtl8192E_card_disable_flow
  62. #define Rtl8192E_NIC_ENABLE_FLOW rtl8192E_card_enable_flow
  63. #define Rtl8192E_NIC_SUSPEND_FLOW rtl8192E_suspend_flow
  64. #define Rtl8192E_NIC_RESUME_FLOW rtl8192E_resume_flow
  65. #define Rtl8192E_NIC_PDN_FLOW rtl8192E_hwpdn_flow
  66. #define Rtl8192E_NIC_LPS_ENTER_FLOW rtl8192E_enter_lps_flow
  67. #define Rtl8192E_NIC_LPS_LEAVE_FLOW rtl8192E_leave_lps_flow
  68. #if 1 // download firmware related data structure
  69. #define FW_SIZE_8192E 0x8000 // Compatible with RTL8192e Maximal RAM code size 32k
  70. #define FW_START_ADDRESS 0x1000
  71. #define FW_END_ADDRESS 0x5FFF
  72. #define IS_FW_HEADER_EXIST_8192E(_pFwHdr) ((GET_FIRMWARE_HDR_SIGNATURE_8192E(_pFwHdr) &0xFFF0) == 0x92E0)
  73. typedef struct _RT_FIRMWARE_8192E {
  74. FIRMWARE_SOURCE eFWSource;
  75. #ifdef CONFIG_EMBEDDED_FWIMG
  76. u8* szFwBuffer;
  77. #else
  78. u8 szFwBuffer[FW_SIZE_8192E];
  79. #endif
  80. u32 ulFwLength;
  81. #ifdef CONFIG_WOWLAN
  82. u8* szWoWLANFwBuffer;
  83. u32 ulWoWLANFwLength;
  84. #endif //CONFIG_WOWLAN
  85. } RT_FIRMWARE_8192E, *PRT_FIRMWARE_8192E;
  86. //
  87. // This structure must be cared byte-ordering
  88. //
  89. // Added by tynli. 2009.12.04.
  90. //=====================================================
  91. // Firmware Header(8-byte alinment required)
  92. //=====================================================
  93. //--- LONG WORD 0 ----
  94. #define GET_FIRMWARE_HDR_SIGNATURE_8192E(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr, 0, 16) // 92C0: test chip; 92C, 88C0: test chip; 88C1: MP A-cut; 92C1: MP A-cut
  95. #define GET_FIRMWARE_HDR_CATEGORY_8192E(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr, 16, 8) // AP/NIC and USB/PCI
  96. #define GET_FIRMWARE_HDR_FUNCTION_8192E(__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
  97. #define GET_FIRMWARE_HDR_VERSION_8192E(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+4, 0, 16)// FW Version
  98. #define GET_FIRMWARE_HDR_SUB_VER_8192E(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+4, 16, 8) // FW Subversion, default 0x00
  99. #define GET_FIRMWARE_HDR_RSVD1_8192E(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+4, 24, 8)
  100. //--- LONG WORD 1 ----
  101. #define GET_FIRMWARE_HDR_MONTH_8192E(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+8, 0, 8) // Release time Month field
  102. #define GET_FIRMWARE_HDR_DATE_8192E(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+8, 8, 8) // Release time Date field
  103. #define GET_FIRMWARE_HDR_HOUR_8192E(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+8, 16, 8)// Release time Hour field
  104. #define GET_FIRMWARE_HDR_MINUTE_8192E(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+8, 24, 8)// Release time Minute field
  105. #define GET_FIRMWARE_HDR_ROMCODE_SIZE_8192E(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+12, 0, 16)// The size of RAM code
  106. #define GET_FIRMWARE_HDR_RSVD2_8192E(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+12, 16, 16)
  107. //--- LONG WORD 2 ----
  108. #define GET_FIRMWARE_HDR_SVN_IDX_8192E(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+16, 0, 32)// The SVN entry index
  109. #define GET_FIRMWARE_HDR_RSVD3_8192E(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+20, 0, 32)
  110. //--- LONG WORD 3 ----
  111. #define GET_FIRMWARE_HDR_RSVD4_8192E(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+24, 0, 32)
  112. #define GET_FIRMWARE_HDR_RSVD5_8192E(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+28, 0, 32)
  113. #endif // download firmware related data structure
  114. #define DRIVER_EARLY_INT_TIME_8192E 0x05
  115. #define BCN_DMA_ATIME_INT_TIME_8192E 0x02
  116. #define MAX_RX_DMA_BUFFER_SIZE_8192E 0x3d00 //0x3E80 //0x3FFF // RX 16K reserved for WOW ?
  117. #define TX_TOTAL_PAGE_NUMBER_8192E 243 //0x00~0xF3 totoal pages: F4
  118. #define TX_PAGE_BOUNDARY_8192E (TX_TOTAL_PAGE_NUMBER_8192E + 1)//0xF4,Rserved 12 pages for BCN/PS-POLL..
  119. #define TX_PAGE_LOAD_FW_BOUNDARY_8192E 0x47 //0xA5
  120. #define TX_PAGE_BOUNDARY_WOWLAN_8192E 0xE0
  121. // For Normal Chip Setting
  122. // (HPQ + LPQ + NPQ + PUBQ) shall be TX_TOTAL_PAGE_NUMBER_92C
  123. #define NORMAL_PAGE_NUM_PUBQ_8192E 0xE0
  124. #define NORMAL_PAGE_NUM_LPQ_8192E 0x00
  125. #define NORMAL_PAGE_NUM_HPQ_8192E 0x08
  126. #define NORMAL_PAGE_NUM_NPQ_8192E 0x0C
  127. #define NORMAL_PAGE_NUM_EPQ_8192E 0x00
  128. //Note: For WMM Normal Chip Setting ,modify later
  129. #define WMM_NORMAL_TX_TOTAL_PAGE_NUMBER_8192E TX_PAGE_BOUNDARY_8192E
  130. #define WMM_NORMAL_TX_PAGE_BOUNDARY_8192E (WMM_NORMAL_TX_TOTAL_PAGE_NUMBER_8192E + 1)
  131. #define WMM_NORMAL_PAGE_NUM_PUBQ_8192E NORMAL_PAGE_NUM_PUBQ_8192E
  132. #define WMM_NORMAL_PAGE_NUM_HPQ_8192E NORMAL_PAGE_NUM_HPQ_8192E
  133. #define WMM_NORMAL_PAGE_NUM_LPQ_8192E NORMAL_PAGE_NUM_LPQ_8192E
  134. #define WMM_NORMAL_PAGE_NUM_NPQ_8192E NORMAL_PAGE_NUM_NPQ_8192E
  135. #define USB_JAGUAR_DUMMY_OFFSET_8192EU 2
  136. #define USB_JAGUAR_DUMMY_UNIT_8192EU 8
  137. #define USB_JAGUAR_ALL_DUMMY_LENGTH_8192EU (USB_JAGUAR_DUMMY_OFFSET_8192EU * USB_JAGUAR_DUMMY_UNIT_8192EU)
  138. #define USB_HWDESC_HEADER_LEN_8192EU (TX_DESC_SIZE_8192E + USB_JAGUAR_ALL_DUMMY_LENGTH_8192EU)
  139. //-------------------------------------------------------------------------
  140. // Chip specific
  141. //-------------------------------------------------------------------------
  142. //-------------------------------------------------------------------------
  143. // Channel Plan
  144. //-------------------------------------------------------------------------
  145. #define HWSET_MAX_SIZE_8192E 512
  146. #define EFUSE_REAL_CONTENT_LEN_8192E 512
  147. #define EFUSE_MAP_LEN_8192E 512
  148. #define EFUSE_MAX_SECTION_8192E 64
  149. #define EFUSE_MAX_WORD_UNIT_8192E 4
  150. #define EFUSE_IC_ID_OFFSET_8192E 506 //For some inferiority IC purpose. added by Roger, 2009.09.02.
  151. #define AVAILABLE_EFUSE_ADDR_8192E(addr) (addr < EFUSE_REAL_CONTENT_LEN_8192E)
  152. //
  153. // <Roger_Notes> To prevent out of boundary programming case, leave 1byte and program full section
  154. // 9bytes + 1byt + 5bytes and pre 1byte.
  155. // For worst case:
  156. // | 1byte|----8bytes----|1byte|--5bytes--|
  157. // | | Reserved(14bytes) |
  158. //
  159. #define EFUSE_OOB_PROTECT_BYTES_8192E 15 // PG data exclude header, dummy 6 bytes frome CP test and reserved 1byte.
  160. //========================================================
  161. // EFUSE for BT definition
  162. //========================================================
  163. #define EFUSE_BT_REAL_BANK_CONTENT_LEN_8192E 512
  164. #define EFUSE_BT_REAL_CONTENT_LEN_8192E 1024 // 512*2
  165. #define EFUSE_BT_MAP_LEN_8192E 1024 // 1k bytes
  166. #define EFUSE_BT_MAX_SECTION_8192E 128 // 1024/8
  167. #define EFUSE_PROTECT_BYTES_BANK_8192E 16
  168. #define EFUSE_MAX_BANK_8192E 3
  169. //===========================================================
  170. #define GET_RF_TYPE(priv) (GET_HAL_DATA(priv)->rf_type)
  171. #define INCLUDE_MULTI_FUNC_BT(_Adapter) (GET_HAL_DATA(_Adapter)->MultiFunc & RT_MULTI_FUNC_BT)
  172. #define INCLUDE_MULTI_FUNC_GPS(_Adapter) (GET_HAL_DATA(_Adapter)->MultiFunc & RT_MULTI_FUNC_GPS)
  173. //#define IS_MULTI_FUNC_CHIP(_Adapter) (((((PHAL_DATA_TYPE)(_Adapter->HalData))->MultiFunc) & (RT_MULTI_FUNC_BT|RT_MULTI_FUNC_GPS)) ? _TRUE : _FALSE)
  174. //#define RT_IS_FUNC_DISABLED(__pAdapter, __FuncBits) ( (__pAdapter)->DisabledFunctions & (__FuncBits) )
  175. #define GetDefaultAdapter(padapter) padapter
  176. // rtl8812_hal_init.c
  177. void _8051Reset8192E(PADAPTER padapter);
  178. s32 FirmwareDownload8192E(PADAPTER Adapter, BOOLEAN bUsedWoWLANFw);
  179. void InitializeFirmwareVars8192E(PADAPTER padapter);
  180. s32 InitLLTTable8192E(PADAPTER padapter, u8 txpktbuf_bndy);
  181. // EFuse
  182. u8 GetEEPROMSize8192E(PADAPTER padapter);
  183. void hal_InitPGData_8192E(PADAPTER padapter, u8* PROMContent);
  184. void Hal_EfuseParseIDCode8192E(PADAPTER padapter, u8 *hwinfo);
  185. void Hal_ReadPROMVersion8192E(PADAPTER padapter, u8 *hwinfo, BOOLEAN AutoLoadFail);
  186. void Hal_ReadTxPowerInfo8192E(PADAPTER padapter,u8* hwinfo,BOOLEAN AutoLoadFail);
  187. void Hal_ReadBoardType8192E(PADAPTER pAdapter,u8* hwinfo,BOOLEAN AutoLoadFail);
  188. void Hal_ReadThermalMeter_8192E(PADAPTER Adapter,u8* PROMContent,BOOLEAN AutoloadFail);
  189. void Hal_ReadChannelPlan8192E(PADAPTER padapter, u8 *hwinfo, BOOLEAN AutoLoadFail);
  190. void Hal_EfuseParseXtal_8192E(PADAPTER pAdapter,u8* hwinfo,BOOLEAN AutoLoadFail);
  191. void Hal_ReadAntennaDiversity8192E(PADAPTER pAdapter,u8* PROMContent,BOOLEAN AutoLoadFail);
  192. void Hal_ReadPAType_8192E(PADAPTER Adapter,u8* PROMContent, BOOLEAN AutoloadFail);
  193. void Hal_EfuseParseBTCoexistInfo8192E(PADAPTER Adapter, u8* hwinfo, BOOLEAN AutoLoadFail);
  194. u8 Hal_CrystalAFEAdjust(_adapter * Adapter);
  195. BOOLEAN HalDetectPwrDownMode8192E(PADAPTER Adapter);
  196. #ifdef CONFIG_WOWLAN
  197. void Hal_DetectWoWMode(PADAPTER pAdapter);
  198. #endif //CONFIG_WOWLAN
  199. /***********************************************************/
  200. // RTL8192E-MAC Setting
  201. VOID _InitTxBufferBoundary_8192E(IN PADAPTER Adapter,IN u8 txpktbuf_bndy);
  202. VOID _InitPageBoundary_8192E(IN PADAPTER Adapter);
  203. //VOID _InitTransferPageSize_8192E(IN PADAPTER Adapter);
  204. VOID _InitDriverInfoSize_8192E(IN PADAPTER Adapter,IN u8 drvInfoSize);
  205. VOID _InitRxSetting_8192E(PADAPTER Adapter);
  206. VOID _InitRDGSetting_8192E(PADAPTER Adapter);
  207. void _InitID_8192E(IN PADAPTER Adapter);
  208. VOID _InitNetworkType_8192E(IN PADAPTER Adapter);
  209. VOID _InitWMACSetting_8192E(IN PADAPTER Adapter);
  210. VOID _InitAdaptiveCtrl_8192E(IN PADAPTER Adapter);
  211. VOID _InitEDCA_8192E( IN PADAPTER Adapter);
  212. VOID _InitRetryFunction_8192E( IN PADAPTER Adapter);
  213. VOID _InitBeaconParameters_8192E(IN PADAPTER Adapter);
  214. VOID _InitBeaconMaxError_8192E(
  215. IN PADAPTER Adapter,
  216. IN BOOLEAN InfraMode
  217. );
  218. void _BBTurnOnBlock_8192E(PADAPTER padapter);
  219. void SetBeaconRelatedRegisters8192E(PADAPTER padapter);
  220. VOID hal_ReadRFType_8192E(PADAPTER Adapter);
  221. // RTL8192E-MAC Setting
  222. /***********************************************************/
  223. void SetHwReg8192E(PADAPTER Adapter, u8 variable, u8* val);
  224. void GetHwReg8192E(PADAPTER Adapter, u8 variable, u8* val);
  225. u8
  226. SetHalDefVar8192E(
  227. IN PADAPTER Adapter,
  228. IN HAL_DEF_VARIABLE eVariable,
  229. IN PVOID pValue
  230. );
  231. u8
  232. GetHalDefVar8192E(
  233. IN PADAPTER Adapter,
  234. IN HAL_DEF_VARIABLE eVariable,
  235. IN PVOID pValue
  236. );
  237. void rtl8192e_set_hal_ops(struct hal_ops *pHalFunc);
  238. void rtl8192e_init_default_value(_adapter * padapter);
  239. // register
  240. void SetBcnCtrlReg(PADAPTER padapter, u8 SetBits, u8 ClearBits);
  241. void rtl8192e_clone_haldata(_adapter *dst_adapter, _adapter *src_adapter);
  242. void rtl8192e_start_thread(_adapter *padapter);
  243. void rtl8192e_stop_thread(_adapter *padapter);
  244. #endif //__RTL8192E_HAL_H__