rtl8188e_hal.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  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 __RTL8188E_HAL_H__
  21. #define __RTL8188E_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 "rtl8188e_spec.h"
  30. #include "Hal8188EPhyReg.h"
  31. #include "Hal8188EPhyCfg.h"
  32. #include "rtl8188e_rf.h"
  33. #include "rtl8188e_dm.h"
  34. #include "rtl8188e_recv.h"
  35. #include "rtl8188e_xmit.h"
  36. #include "rtl8188e_cmd.h"
  37. #include "rtl8188e_led.h"
  38. #include "Hal8188EPwrSeq.h"
  39. #ifdef DBG_CONFIG_ERROR_DETECT
  40. #include "rtl8188e_sreset.h"
  41. #endif
  42. // Fw Array
  43. #define Rtl8188E_FwImageArray Rtl8188EFwImgArray
  44. #define Rtl8188E_FWImgArrayLength Rtl8188EFWImgArrayLength
  45. #ifdef CONFIG_WOWLAN
  46. #define Rtl8188E_FwWoWImageArray Array_MP_8188E_FW_WoWLAN
  47. #define Rtl8188E_FwWoWImgArrayLength ArrayLength_MP_8188E_FW_WoWLAN
  48. #endif //CONFIG_WOWLAN
  49. #ifdef CONFIG_SDIO_HCI
  50. //TODO: We should define 8188ES firmware related macro settings here!!
  51. //TODO: The following need to check!!
  52. #define RTL8188E_FW_UMC_IMG "rtl8188E\\rtl8188efw.bin"
  53. #define RTL8188E_PHY_REG "rtl8188E\\PHY_REG_1T.txt"
  54. #define RTL8188E_PHY_RADIO_A "rtl8188E\\radio_a_1T.txt"
  55. #define RTL8188E_PHY_RADIO_B "rtl8188E\\radio_b_1T.txt"
  56. #define RTL8188E_AGC_TAB "rtl8188E\\AGC_TAB_1T.txt"
  57. #define RTL8188E_PHY_MACREG "rtl8188E\\MAC_REG.txt"
  58. #define RTL8188E_PHY_REG_PG "rtl8188E\\PHY_REG_PG.txt"
  59. #define RTL8188E_PHY_REG_MP "rtl8188E\\PHY_REG_MP.txt"
  60. //---------------------------------------------------------------------
  61. // RTL8188E From header
  62. //---------------------------------------------------------------------
  63. #if 0
  64. #define Rtl8188E_PHY_REG_Array_PG Rtl8188ESPHY_REG_Array_PG
  65. #define Rtl8188E_PHY_REG_Array_PGLength Rtl8188ESPHY_REG_Array_PGLength
  66. #endif
  67. //---------------------------------------------------------------------
  68. // RTL8188E Power Configuration CMDs for USB/SDIO interfaces
  69. //---------------------------------------------------------------------
  70. #define Rtl8188E_NIC_PWR_ON_FLOW rtl8188E_power_on_flow
  71. #define Rtl8188E_NIC_RF_OFF_FLOW rtl8188E_radio_off_flow
  72. #define Rtl8188E_NIC_DISABLE_FLOW rtl8188E_card_disable_flow
  73. #define Rtl8188E_NIC_ENABLE_FLOW rtl8188E_card_enable_flow
  74. #define Rtl8188E_NIC_SUSPEND_FLOW rtl8188E_suspend_flow
  75. #define Rtl8188E_NIC_RESUME_FLOW rtl8188E_resume_flow
  76. #define Rtl8188E_NIC_PDN_FLOW rtl8188E_hwpdn_flow
  77. #define Rtl8188E_NIC_LPS_ENTER_FLOW rtl8188E_enter_lps_flow
  78. #define Rtl8188E_NIC_LPS_LEAVE_FLOW rtl8188E_leave_lps_flow
  79. #elif defined(CONFIG_USB_HCI)
  80. #define RTL8188E_FW_UMC_IMG "rtl8188E\\rtl8188efw.bin"
  81. #define RTL8188E_PHY_REG "rtl8188E\\PHY_REG_1T.txt"
  82. #define RTL8188E_PHY_RADIO_A "rtl8188E\\radio_a_1T.txt"
  83. #define RTL8188E_PHY_RADIO_B "rtl8188E\\radio_b_1T.txt"
  84. #define RTL8188E_AGC_TAB "rtl8188E\\AGC_TAB_1T.txt"
  85. #define RTL8188E_PHY_MACREG "rtl8188E\\MAC_REG.txt"
  86. #define RTL8188E_PHY_REG_PG "rtl8188E\\PHY_REG_PG.txt"
  87. #define RTL8188E_PHY_REG_MP "rtl8188E\\PHY_REG_MP.txt"
  88. #if 0
  89. #define Rtl8188E_PHY_REG_Array_PG Rtl8188EUPHY_REG_Array_PG
  90. #define Rtl8188E_PHY_REG_Array_PGLength Rtl8188EUPHY_REG_Array_PGLength
  91. #endif
  92. //---------------------------------------------------------------------
  93. // RTL8188E Power Configuration CMDs for USB/SDIO interfaces
  94. //---------------------------------------------------------------------
  95. #define Rtl8188E_NIC_PWR_ON_FLOW rtl8188E_power_on_flow
  96. #define Rtl8188E_NIC_RF_OFF_FLOW rtl8188E_radio_off_flow
  97. #define Rtl8188E_NIC_DISABLE_FLOW rtl8188E_card_disable_flow
  98. #define Rtl8188E_NIC_ENABLE_FLOW rtl8188E_card_enable_flow
  99. #define Rtl8188E_NIC_SUSPEND_FLOW rtl8188E_suspend_flow
  100. #define Rtl8188E_NIC_RESUME_FLOW rtl8188E_resume_flow
  101. #define Rtl8188E_NIC_PDN_FLOW rtl8188E_hwpdn_flow
  102. #define Rtl8188E_NIC_LPS_ENTER_FLOW rtl8188E_enter_lps_flow
  103. #define Rtl8188E_NIC_LPS_LEAVE_FLOW rtl8188E_leave_lps_flow
  104. #elif defined(CONFIG_PCI_HCI)
  105. #define RTL8188E_FW_UMC_IMG "rtl8188E\\rtl8188efw.bin"
  106. #define RTL8188E_PHY_REG "rtl8188E\\PHY_REG_1T.txt"
  107. #define RTL8188E_PHY_RADIO_A "rtl8188E\\radio_a_1T.txt"
  108. #define RTL8188E_PHY_RADIO_B "rtl8188E\\radio_b_1T.txt"
  109. #define RTL8188E_AGC_TAB "rtl8188E\\AGC_TAB_1T.txt"
  110. #define RTL8188E_PHY_MACREG "rtl8188E\\MAC_REG.txt"
  111. #define RTL8188E_PHY_REG_PG "rtl8188E\\PHY_REG_PG.txt"
  112. #define RTL8188E_PHY_REG_MP "rtl8188E\\PHY_REG_MP.txt"
  113. #define Rtl8188E_PHY_REG_Array_PG Rtl8188EEPHY_REG_Array_PG
  114. #define Rtl8188E_PHY_REG_Array_PGLength Rtl8188EEPHY_REG_Array_PGLength
  115. #ifndef CONFIG_PHY_SETTING_WITH_ODM
  116. #if MP_DRIVER == 1
  117. #define Rtl8188ES_PHY_REG_Array_MP Rtl8188ESPHY_REG_Array_MP
  118. #endif
  119. #endif
  120. //---------------------------------------------------------------------
  121. // RTL8188E Power Configuration CMDs for USB/SDIO/PCIE interfaces
  122. //---------------------------------------------------------------------
  123. #define Rtl8188E_NIC_PWR_ON_FLOW rtl8188E_power_on_flow
  124. #define Rtl8188E_NIC_RF_OFF_FLOW rtl8188E_radio_off_flow
  125. #define Rtl8188E_NIC_DISABLE_FLOW rtl8188E_card_disable_flow
  126. #define Rtl8188E_NIC_ENABLE_FLOW rtl8188E_card_enable_flow
  127. #define Rtl8188E_NIC_SUSPEND_FLOW rtl8188E_suspend_flow
  128. #define Rtl8188E_NIC_RESUME_FLOW rtl8188E_resume_flow
  129. #define Rtl8188E_NIC_PDN_FLOW rtl8188E_hwpdn_flow
  130. #define Rtl8188E_NIC_LPS_ENTER_FLOW rtl8188E_enter_lps_flow
  131. #define Rtl8188E_NIC_LPS_LEAVE_FLOW rtl8188E_leave_lps_flow
  132. #endif //CONFIG_***_HCI
  133. #if 1 // download firmware related data structure
  134. #define FW_8188E_SIZE 0x4000 //16384,16k
  135. #define FW_8188E_START_ADDRESS 0x1000
  136. #define FW_8188E_END_ADDRESS 0x1FFF //0x5FFF
  137. #define IS_FW_HEADER_EXIST_88E(_pFwHdr) ((le16_to_cpu(_pFwHdr->Signature)&0xFFF0) == 0x88E0)
  138. typedef struct _RT_FIRMWARE_8188E {
  139. FIRMWARE_SOURCE eFWSource;
  140. #ifdef CONFIG_EMBEDDED_FWIMG
  141. u8* szFwBuffer;
  142. #else
  143. u8 szFwBuffer[FW_8188E_SIZE];
  144. #endif
  145. u32 ulFwLength;
  146. #ifdef CONFIG_WOWLAN
  147. u8* szWoWLANFwBuffer;
  148. u32 ulWoWLANFwLength;
  149. #endif //CONFIG_WOWLAN
  150. } RT_FIRMWARE_8188E, *PRT_FIRMWARE_8188E;
  151. //
  152. // This structure must be cared byte-ordering
  153. //
  154. typedef struct _RT_8188E_FIRMWARE_HDR
  155. {
  156. // 8-byte alinment required
  157. //--- LONG WORD 0 ----
  158. u16 Signature; // 92C0: test chip; 92C, 88C0: test chip; 88C1: MP A-cut; 92C1: MP A-cut
  159. u8 Category; // AP/NIC and USB/PCI
  160. u8 Function; // Reserved for different FW function indcation, for further use when driver needs to download different FW in different conditions
  161. u16 Version; // FW Version
  162. u8 Subversion; // FW Subversion, default 0x00
  163. u16 Rsvd1;
  164. //--- LONG WORD 1 ----
  165. u8 Month; // Release time Month field
  166. u8 Date; // Release time Date field
  167. u8 Hour; // Release time Hour field
  168. u8 Minute; // Release time Minute field
  169. u16 RamCodeSize; // The size of RAM code
  170. u8 Foundry;
  171. u8 Rsvd2;
  172. //--- LONG WORD 2 ----
  173. u32 SvnIdx; // The SVN entry index
  174. u32 Rsvd3;
  175. //--- LONG WORD 3 ----
  176. u32 Rsvd4;
  177. u32 Rsvd5;
  178. }RT_8188E_FIRMWARE_HDR, *PRT_8188E_FIRMWARE_HDR;
  179. #endif // download firmware related data structure
  180. #define DRIVER_EARLY_INT_TIME_8188E 0x05
  181. #define BCN_DMA_ATIME_INT_TIME_8188E 0x02
  182. #define MAX_RX_DMA_BUFFER_SIZE_88E 0x2400 //9k for 88E nornal chip , //MaxRxBuff=10k-max(TxReportSize(64*8), WOLPattern(16*24))
  183. #define MAX_TX_REPORT_BUFFER_SIZE 0x0400 // 1k
  184. // Note: We will divide number of page equally for each queue other than public queue!
  185. // 22k = 22528 bytes = 176 pages (@page = 128 bytes)
  186. // must reserved about 7 pages for LPS => 176-7 = 169 (0xA9)
  187. // 2*BCN / 1*ps-poll / 1*null-data /1*prob_rsp /1*QOS null-data /1*BT QOS null-data
  188. #define TX_TOTAL_PAGE_NUMBER_88E 0xA9// 169 (21632=> 21k)
  189. #ifdef RTL8188ES_MAC_LOOPBACK
  190. #define TX_PAGE_BOUNDARY_88E 0x48 //72
  191. #else //TX_PAGE_BOUNDARY_LOOPBACK_MODE
  192. #define TX_PAGE_BOUNDARY_88E (TX_TOTAL_PAGE_NUMBER_88E + 1)
  193. #endif
  194. //Note: For Normal Chip Setting ,modify later
  195. #define WMM_NORMAL_TX_TOTAL_PAGE_NUMBER TX_TOTAL_PAGE_NUMBER_88E //0xA9 , 0xb0=>176=>22k
  196. #define WMM_NORMAL_TX_PAGE_BOUNDARY_88E (WMM_NORMAL_TX_TOTAL_PAGE_NUMBER + 1) //0xA9
  197. //-------------------------------------------------------------------------
  198. // Chip specific
  199. //-------------------------------------------------------------------------
  200. #define CHIP_BONDING_IDENTIFIER(_value) (((_value)>>22)&0x3)
  201. #define CHIP_BONDING_92C_1T2R 0x1
  202. #define CHIP_BONDING_88C_USB_MCARD 0x2
  203. #define CHIP_BONDING_88C_USB_HP 0x1
  204. //-------------------------------------------------------------------------
  205. // Channel Plan
  206. //-------------------------------------------------------------------------
  207. #define EFUSE_REAL_CONTENT_LEN 512
  208. #define EFUSE_MAP_LEN 128
  209. #define EFUSE_MAX_SECTION 16
  210. #define EFUSE_IC_ID_OFFSET 506 //For some inferiority IC purpose. added by Roger, 2009.09.02.
  211. #define AVAILABLE_EFUSE_ADDR(addr) (addr < EFUSE_REAL_CONTENT_LEN)
  212. //
  213. // <Roger_Notes>
  214. // To prevent out of boundary programming case,
  215. // leave 1byte and program full section
  216. // 9bytes + 1byt + 5bytes and pre 1byte.
  217. // For worst case:
  218. // | 1byte|----8bytes----|1byte|--5bytes--|
  219. // | | Reserved(14bytes) |
  220. //
  221. #define EFUSE_OOB_PROTECT_BYTES 15 // PG data exclude header, dummy 6 bytes frome CP test and reserved 1byte.
  222. #define HWSET_MAX_SIZE_88E 512
  223. #define EFUSE_REAL_CONTENT_LEN_88E 256
  224. #define EFUSE_MAP_LEN_88E 512
  225. #define EFUSE_MAX_SECTION_88E 64
  226. #define EFUSE_MAX_WORD_UNIT_88E 4
  227. #define EFUSE_IC_ID_OFFSET_88E 506 //For some inferiority IC purpose. added by Roger, 2009.09.02.
  228. #define AVAILABLE_EFUSE_ADDR_88E(addr) (addr < EFUSE_REAL_CONTENT_LEN_88E)
  229. // <Roger_Notes> To prevent out of boundary programming case, leave 1byte and program full section
  230. // 9bytes + 1byt + 5bytes and pre 1byte.
  231. // For worst case:
  232. // | 2byte|----8bytes----|1byte|--7bytes--| //92D
  233. #define EFUSE_OOB_PROTECT_BYTES_88E 18 // PG data exclude header, dummy 7 bytes frome CP test and reserved 1byte.
  234. #define EFUSE_PROTECT_BYTES_BANK_88E 16
  235. //========================================================
  236. // EFUSE for BT definition
  237. //========================================================
  238. #define EFUSE_BT_REAL_CONTENT_LEN 1536 // 512*3
  239. #define EFUSE_BT_MAP_LEN 1024 // 1k bytes
  240. #define EFUSE_BT_MAX_SECTION 128 // 1024/8
  241. #define EFUSE_PROTECT_BYTES_BANK 16
  242. #define GET_RF_TYPE(priv) (GET_HAL_DATA(priv)->rf_type)
  243. #define INCLUDE_MULTI_FUNC_BT(_Adapter) (GET_HAL_DATA(_Adapter)->MultiFunc & RT_MULTI_FUNC_BT)
  244. #define INCLUDE_MULTI_FUNC_GPS(_Adapter) (GET_HAL_DATA(_Adapter)->MultiFunc & RT_MULTI_FUNC_GPS)
  245. //#define IS_MULTI_FUNC_CHIP(_Adapter) (((((PHAL_DATA_TYPE)(_Adapter->HalData))->MultiFunc) & (RT_MULTI_FUNC_BT|RT_MULTI_FUNC_GPS)) ? _TRUE : _FALSE)
  246. //#define RT_IS_FUNC_DISABLED(__pAdapter, __FuncBits) ( (__pAdapter)->DisabledFunctions & (__FuncBits) )
  247. #ifdef CONFIG_PCI_HCI
  248. void InterruptRecognized8188EE(PADAPTER Adapter, PRT_ISR_CONTENT pIsrContent);
  249. void UpdateInterruptMask8188EE(PADAPTER Adapter, u32 AddMSR, u32 AddMSR1, u32 RemoveMSR, u32 RemoveMSR1);
  250. #endif //CONFIG_PCI_HCI
  251. // rtl8188e_hal_init.c
  252. s32 rtl8188e_FirmwareDownload(PADAPTER padapter, BOOLEAN bUsedWoWLANFw);
  253. void _8051Reset88E(PADAPTER padapter);
  254. void rtl8188e_InitializeFirmwareVars(PADAPTER padapter);
  255. s32 InitLLTTable(PADAPTER padapter, u8 txpktbuf_bndy);
  256. // EFuse
  257. u8 GetEEPROMSize8188E(PADAPTER padapter);
  258. void Hal_InitPGData88E(PADAPTER padapter);
  259. void Hal_EfuseParseIDCode88E(PADAPTER padapter, u8 *hwinfo);
  260. void Hal_ReadTxPowerInfo88E(PADAPTER padapter,u8* hwinfo,BOOLEAN AutoLoadFail);
  261. void Hal_EfuseParseEEPROMVer88E(PADAPTER padapter, u8 *hwinfo, BOOLEAN AutoLoadFail);
  262. void rtl8188e_EfuseParseChnlPlan(PADAPTER padapter, u8 *hwinfo, BOOLEAN AutoLoadFail);
  263. void Hal_EfuseParseCustomerID88E(PADAPTER padapter, u8 *hwinfo, BOOLEAN AutoLoadFail);
  264. void Hal_ReadAntennaDiversity88E (PADAPTER pAdapter,u8*PROMContent,BOOLEAN AutoLoadFail);
  265. void Hal_ReadThermalMeter_88E(PADAPTER Adapter,u8* PROMContent,BOOLEAN AutoloadFail);
  266. void Hal_EfuseParseXtal_8188E(PADAPTER pAdapter,u8* hwinfo,BOOLEAN AutoLoadFail);
  267. void Hal_EfuseParseBoardType88E(PADAPTER pAdapter,u8* hwinfo,BOOLEAN AutoLoadFail);
  268. void Hal_ReadPowerSavingMode88E(PADAPTER pAdapter,u8* hwinfo,BOOLEAN AutoLoadFail);
  269. BOOLEAN HalDetectPwrDownMode88E(PADAPTER Adapter);
  270. #ifdef CONFIG_WOWLAN
  271. void Hal_DetectWoWMode(PADAPTER pAdapter);
  272. #endif //CONFIG_WOWLAN
  273. //RT_CHANNEL_DOMAIN rtl8723a_HalMapChannelPlan(PADAPTER padapter, u8 HalChannelPlan);
  274. //VERSION_8192C rtl8723a_ReadChipVersion(PADAPTER padapter);
  275. //void rtl8723a_ReadBluetoothCoexistInfo(PADAPTER padapter, u8 *PROMContent, BOOLEAN AutoloadFail);
  276. void Hal_InitChannelPlan(PADAPTER padapter);
  277. void rtl8188e_set_hal_ops(struct hal_ops *pHalFunc);
  278. // register
  279. void SetBcnCtrlReg(PADAPTER padapter, u8 SetBits, u8 ClearBits);
  280. void rtl8188e_clone_haldata(_adapter *dst_adapter, _adapter *src_adapter);
  281. void rtl8188e_start_thread(_adapter *padapter);
  282. void rtl8188e_stop_thread(_adapter *padapter);
  283. void rtw_IOL_cmd_tx_pkt_buf_dump(ADAPTER *Adapter,int data_len);
  284. #ifdef CONFIG_IOL_EFUSE_PATCH
  285. s32 rtl8188e_iol_efuse_patch(PADAPTER padapter);
  286. #endif//CONFIG_IOL_EFUSE_PATCH
  287. void _InitTransferPageSize(PADAPTER padapter);
  288. #endif //__RTL8188E_HAL_H__