1 /****************************************************************************** 2 * 3 * Copyright(c) 2012 - 2017 Realtek Corporation. 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 *****************************************************************************/ 15 #ifndef __RTL8192E_HAL_H__ 16 #define __RTL8192E_HAL_H__ 17 18 /* #include "hal_com.h" */ 19 20 #include "hal_data.h" 21 22 /* include HAL Related header after HAL Related compiling flags */ 23 #include "rtl8192e_spec.h" 24 #include "rtl8192e_rf.h" 25 #include "rtl8192e_dm.h" 26 #include "rtl8192e_recv.h" 27 #include "rtl8192e_xmit.h" 28 #include "rtl8192e_cmd.h" 29 #include "rtl8192e_led.h" 30 #include "Hal8192EPwrSeq.h" 31 #include "Hal8192EPhyReg.h" 32 #include "Hal8192EPhyCfg.h" 33 34 35 #ifdef DBG_CONFIG_ERROR_DETECT 36 #include "rtl8192e_sreset.h" 37 #endif 38 39 /* --------------------------------------------------------------------- 40 * RTL8192E Power Configuration CMDs for PCIe interface 41 * --------------------------------------------------------------------- */ 42 #define Rtl8192E_NIC_PWR_ON_FLOW rtl8192E_power_on_flow 43 #define Rtl8192E_NIC_RF_OFF_FLOW rtl8192E_radio_off_flow 44 #define Rtl8192E_NIC_DISABLE_FLOW rtl8192E_card_disable_flow 45 #define Rtl8192E_NIC_ENABLE_FLOW rtl8192E_card_enable_flow 46 #define Rtl8192E_NIC_SUSPEND_FLOW rtl8192E_suspend_flow 47 #define Rtl8192E_NIC_RESUME_FLOW rtl8192E_resume_flow 48 #define Rtl8192E_NIC_PDN_FLOW rtl8192E_hwpdn_flow 49 #define Rtl8192E_NIC_LPS_ENTER_FLOW rtl8192E_enter_lps_flow 50 #define Rtl8192E_NIC_LPS_LEAVE_FLOW rtl8192E_leave_lps_flow 51 52 53 #if 1 /* download firmware related data structure */ 54 #define FW_SIZE_8192E 0x8000 /* Compatible with RTL8192e Maximal RAM code size 32k */ 55 #define FW_START_ADDRESS 0x1000 56 #define FW_END_ADDRESS 0x5FFF 57 58 59 #define IS_FW_HEADER_EXIST_8192E(_pFwHdr) ((GET_FIRMWARE_HDR_SIGNATURE_8192E(_pFwHdr) & 0xFFF0) == 0x92E0) 60 61 62 63 typedef struct _RT_FIRMWARE_8192E { 64 FIRMWARE_SOURCE eFWSource; 65 #ifdef CONFIG_EMBEDDED_FWIMG 66 u8 *szFwBuffer; 67 #else 68 u8 szFwBuffer[FW_SIZE_8192E]; 69 #endif 70 u32 ulFwLength; 71 } RT_FIRMWARE_8192E, *PRT_FIRMWARE_8192E; 72 73 /* 74 * This structure must be cared byte-ordering 75 * 76 * Added by tynli. 2009.12.04. */ 77 78 /* ***************************************************** 79 * Firmware Header(8-byte alinment required) 80 * ***************************************************** 81 * --- LONG WORD 0 ---- */ 82 #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 */ 83 #define GET_FIRMWARE_HDR_CATEGORY_8192E(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr, 16, 8) /* AP/NIC and USB/PCI */ 84 #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 */ 85 #define GET_FIRMWARE_HDR_VERSION_8192E(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+4, 0, 16)/* FW Version */ 86 #define GET_FIRMWARE_HDR_SUB_VER_8192E(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+4, 16, 8) /* FW Subversion, default 0x00 */ 87 #define GET_FIRMWARE_HDR_RSVD1_8192E(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+4, 24, 8) 88 89 /* --- LONG WORD 1 ---- */ 90 #define GET_FIRMWARE_HDR_MONTH_8192E(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+8, 0, 8) /* Release time Month field */ 91 #define GET_FIRMWARE_HDR_DATE_8192E(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+8, 8, 8) /* Release time Date field */ 92 #define GET_FIRMWARE_HDR_HOUR_8192E(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+8, 16, 8)/* Release time Hour field */ 93 #define GET_FIRMWARE_HDR_MINUTE_8192E(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+8, 24, 8)/* Release time Minute field */ 94 #define GET_FIRMWARE_HDR_ROMCODE_SIZE_8192E(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+12, 0, 16)/* The size of RAM code */ 95 #define GET_FIRMWARE_HDR_RSVD2_8192E(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+12, 16, 16) 96 97 /* --- LONG WORD 2 ---- */ 98 #define GET_FIRMWARE_HDR_SVN_IDX_8192E(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+16, 0, 32)/* The SVN entry index */ 99 #define GET_FIRMWARE_HDR_RSVD3_8192E(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+20, 0, 32) 100 101 /* --- LONG WORD 3 ---- */ 102 #define GET_FIRMWARE_HDR_RSVD4_8192E(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+24, 0, 32) 103 #define GET_FIRMWARE_HDR_RSVD5_8192E(__FwHdr) LE_BITS_TO_4BYTE(__FwHdr+28, 0, 32) 104 105 #endif /* download firmware related data structure */ 106 107 #define DRIVER_EARLY_INT_TIME_8192E 0x05 108 #define BCN_DMA_ATIME_INT_TIME_8192E 0x02 109 #define RX_DMA_SIZE_8192E 0x4000 /* 16K*/ 110 111 #ifdef CONFIG_WOWLAN 112 #define RESV_FMWF (WKFMCAM_SIZE * MAX_WKFM_CAM_NUM) /* 16 entries, for each is 24 bytes*/ 113 #else 114 #define RESV_FMWF 0 115 #endif 116 117 #ifdef CONFIG_FW_C2H_DEBUG 118 #define RX_DMA_RESERVED_SIZE_8192E 0x100 /* 256B, reserved for c2h debug message*/ 119 #else 120 #define RX_DMA_RESERVED_SIZE_8192E 0x40 /* 64B, reserved for c2h event(16bytes) or ccx(8 Bytes)*/ 121 #endif 122 #define MAX_RX_DMA_BUFFER_SIZE_8192E (RX_DMA_SIZE_8192E-RX_DMA_RESERVED_SIZE_8192E) /*RX 16K*/ 123 124 125 #define PAGE_SIZE_TX_92E PAGE_SIZE_256 126 127 /* For General Reserved Page Number(Beacon Queue is reserved page) 128 * if (CONFIG_2BCN_EN) Beacon:4, PS-Poll:1, Null Data:1,Prob Rsp:1,Qos Null Data:1 129 * Beacon: MAX_BEACON_LEN / PAGE_SIZE_TX_92E 130 * PS-Poll:1, Null Data:1,Prob Rsp:1,Qos Null Data:1,CTS-2-SELF / LTE QoS Null*/ 131 132 #define RSVD_PAGE_NUM_8192E (MAX_BEACON_LEN / PAGE_SIZE_TX_92E + 6) /*0x08*/ 133 /* For WoWLan , more reserved page 134 * ARP Rsp:1, RWC:1, GTK Info:1,GTK RSP:2,GTK EXT MEM:2, AOAC rpt: 1,PNO: 6 135 * NS offload: 2 NDP info: 1 136 */ 137 #ifdef CONFIG_WOWLAN 138 #define WOWLAN_PAGE_NUM_8192E 0x0b 139 #else 140 #define WOWLAN_PAGE_NUM_8192E 0x00 141 #endif 142 143 #ifdef CONFIG_PNO_SUPPORT 144 #undef WOWLAN_PAGE_NUM_8192E 145 #define WOWLAN_PAGE_NUM_8192E 0x0d 146 #endif 147 148 /* Note: 149 Tx FIFO Size : 64KB 150 Tx page Size : 256B 151 Total page numbers : 256(0x100) 152 */ 153 154 #define TOTAL_RSVD_PAGE_NUMBER_8192E (RSVD_PAGE_NUM_8192E + WOWLAN_PAGE_NUM_8192E) 155 156 #define TOTAL_PAGE_NUMBER_8192E (0x100) 157 #define TX_TOTAL_PAGE_NUMBER_8192E (TOTAL_PAGE_NUMBER_8192E - TOTAL_RSVD_PAGE_NUMBER_8192E) 158 159 #define TX_PAGE_BOUNDARY_8192E (TX_TOTAL_PAGE_NUMBER_8192E) /* beacon header start address */ 160 161 162 #define RSVD_PKT_LEN_92E (TOTAL_RSVD_PAGE_NUMBER_8192E * PAGE_SIZE_TX_92E) 163 164 #define TX_PAGE_LOAD_FW_BOUNDARY_8192E 0x47 /* 0xA5 */ 165 #define TX_PAGE_BOUNDARY_WOWLAN_8192E 0xE0 166 167 /* For Normal Chip Setting 168 * (HPQ + LPQ + NPQ + PUBQ) shall be TX_TOTAL_PAGE_NUMBER_92C */ 169 170 #define NORMAL_PAGE_NUM_HPQ_8192E 0x10 171 #define NORMAL_PAGE_NUM_LPQ_8192E 0x10 172 #define NORMAL_PAGE_NUM_NPQ_8192E 0x10 173 #define NORMAL_PAGE_NUM_EPQ_8192E 0x00 174 175 176 /* Note: For WMM Normal Chip Setting ,modify later */ 177 #define WMM_NORMAL_PAGE_NUM_HPQ_8192E NORMAL_PAGE_NUM_HPQ_8192E 178 #define WMM_NORMAL_PAGE_NUM_LPQ_8192E NORMAL_PAGE_NUM_LPQ_8192E 179 #define WMM_NORMAL_PAGE_NUM_NPQ_8192E NORMAL_PAGE_NUM_NPQ_8192E 180 181 182 /* ------------------------------------------------------------------------- 183 * Chip specific 184 * ------------------------------------------------------------------------- */ 185 186 /* pic buffer descriptor */ 187 #define RTL8192EE_SEG_NUM TX_BUFFER_SEG_NUM 188 #define TX_DESC_NUM_92E 128 189 #define RX_DESC_NUM_92E 128 190 191 /* ------------------------------------------------------------------------- 192 * Channel Plan 193 * ------------------------------------------------------------------------- */ 194 195 #define HWSET_MAX_SIZE_8192E 512 196 197 #define EFUSE_REAL_CONTENT_LEN_8192E 512 198 199 #define EFUSE_MAP_LEN_8192E 512 200 #define EFUSE_MAX_SECTION_8192E 64 201 #define EFUSE_MAX_WORD_UNIT_8192E 4 202 #define EFUSE_IC_ID_OFFSET_8192E 506 /* For some inferiority IC purpose. added by Roger, 2009.09.02. */ 203 #define AVAILABLE_EFUSE_ADDR_8192E(addr) (addr < EFUSE_REAL_CONTENT_LEN_8192E) 204 /* 205 * <Roger_Notes> To prevent out of boundary programming case, leave 1byte and program full section 206 * 9bytes + 1byt + 5bytes and pre 1byte. 207 * For worst case: 208 * | 1byte|----8bytes----|1byte|--5bytes--| 209 * | | Reserved(14bytes) | 210 * */ 211 #define EFUSE_OOB_PROTECT_BYTES_8192E 15 /* PG data exclude header, dummy 6 bytes frome CP test and reserved 1byte. */ 212 213 214 215 /* ******************************************************** 216 * EFUSE for BT definition 217 * ******************************************************** */ 218 #define EFUSE_BT_REAL_BANK_CONTENT_LEN_8192E 512 219 #define EFUSE_BT_REAL_CONTENT_LEN_8192E 1024 /* 512*2 */ 220 #define EFUSE_BT_MAP_LEN_8192E 1024 /* 1k bytes */ 221 #define EFUSE_BT_MAX_SECTION_8192E 128 /* 1024/8 */ 222 223 #define EFUSE_PROTECT_BYTES_BANK_8192E 16 224 #define EFUSE_MAX_BANK_8192E 3 225 /* *********************************************************** */ 226 227 #define INCLUDE_MULTI_FUNC_BT(_Adapter) (GET_HAL_DATA(_Adapter)->MultiFunc & RT_MULTI_FUNC_BT) 228 #define INCLUDE_MULTI_FUNC_GPS(_Adapter) (GET_HAL_DATA(_Adapter)->MultiFunc & RT_MULTI_FUNC_GPS) 229 230 /* #define IS_MULTI_FUNC_CHIP(_Adapter) (((((PHAL_DATA_TYPE)(_Adapter->HalData))->MultiFunc) & (RT_MULTI_FUNC_BT|RT_MULTI_FUNC_GPS)) ? _TRUE : _FALSE) */ 231 232 /* #define RT_IS_FUNC_DISABLED(__pAdapter, __FuncBits) ( (__pAdapter)->DisabledFunctions & (__FuncBits) ) */ 233 234 /* rtl8812_hal_init.c */ 235 void _8051Reset8192E(PADAPTER padapter); 236 s32 FirmwareDownload8192E(PADAPTER Adapter, BOOLEAN bUsedWoWLANFw); 237 void InitializeFirmwareVars8192E(PADAPTER padapter); 238 239 s32 InitLLTTable8192E(PADAPTER padapter, u8 txpktbuf_bndy); 240 241 /* EFuse */ 242 u8 GetEEPROMSize8192E(PADAPTER padapter); 243 void hal_InitPGData_8192E(PADAPTER padapter, u8 *PROMContent); 244 void Hal_EfuseParseIDCode8192E(PADAPTER padapter, u8 *hwinfo); 245 void Hal_ReadPROMVersion8192E(PADAPTER padapter, u8 *hwinfo, BOOLEAN AutoLoadFail); 246 void Hal_ReadPowerSavingMode8192E(PADAPTER padapter, u8 *hwinfo, BOOLEAN AutoLoadFail); 247 void Hal_ReadTxPowerInfo8192E(PADAPTER padapter, u8 *hwinfo, BOOLEAN AutoLoadFail); 248 void Hal_ReadBoardType8192E(PADAPTER pAdapter, u8 *hwinfo, BOOLEAN AutoLoadFail); 249 void Hal_ReadThermalMeter_8192E(PADAPTER Adapter, u8 *PROMContent, BOOLEAN AutoloadFail); 250 void Hal_ReadChannelPlan8192E(PADAPTER padapter, u8 *hwinfo, BOOLEAN AutoLoadFail); 251 void Hal_EfuseParseXtal_8192E(PADAPTER pAdapter, u8 *hwinfo, BOOLEAN AutoLoadFail); 252 void Hal_ReadAntennaDiversity8192E(PADAPTER pAdapter, u8 *PROMContent, BOOLEAN AutoLoadFail); 253 void Hal_ReadPAType_8192E(PADAPTER Adapter, u8 *PROMContent, BOOLEAN AutoloadFail); 254 void Hal_ReadAmplifierType_8192E(PADAPTER Adapter, u8 *PROMContent, BOOLEAN AutoloadFail); 255 void Hal_ReadRFEType_8192E(PADAPTER Adapter, u8 *PROMContent, BOOLEAN AutoloadFail); 256 void Hal_EfuseParseBTCoexistInfo8192E(PADAPTER Adapter, u8 *hwinfo, BOOLEAN AutoLoadFail); 257 void Hal_EfuseParseKFreeData_8192E(PADAPTER pAdapter, u8 *hwinfo, BOOLEAN AutoLoadFail); 258 259 u8 Hal_CrystalAFEAdjust(_adapter *Adapter); 260 261 BOOLEAN HalDetectPwrDownMode8192E(PADAPTER Adapter); 262 263 #if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN) 264 void Hal_DetectWoWMode(PADAPTER pAdapter); 265 #endif /* CONFIG_WOWLAN */ 266 267 /***********************************************************/ 268 /* RTL8192E-MAC Setting */ 269 void _InitQueueReservedPage_8192E(PADAPTER Adapter); 270 void _InitQueuePriority_8192E(PADAPTER Adapter); 271 void _InitTxBufferBoundary_8192E(PADAPTER Adapter, u8 txpktbuf_bndy); 272 void _InitPageBoundary_8192E(PADAPTER Adapter); 273 /* void _InitTransferPageSize_8192E(PADAPTER Adapter); */ 274 void _InitDriverInfoSize_8192E(PADAPTER Adapter, u8 drvInfoSize); 275 void _InitRDGSetting_8192E(PADAPTER Adapter); 276 void _InitID_8192E(PADAPTER Adapter); 277 void _InitNetworkType_8192E(PADAPTER Adapter); 278 void _InitWMACSetting_8192E(PADAPTER Adapter); 279 void _InitAdaptiveCtrl_8192E(PADAPTER Adapter); 280 void _InitEDCA_8192E(PADAPTER Adapter); 281 void _InitRetryFunction_8192E(PADAPTER Adapter); 282 void _BBTurnOnBlock_8192E(PADAPTER Adapter); 283 void _InitBeaconParameters_8192E(PADAPTER Adapter); 284 void _InitBeaconMaxError_8192E( 285 PADAPTER Adapter, 286 BOOLEAN InfraMode 287 ); 288 void SetBeaconRelatedRegisters8192E(PADAPTER padapter); 289 void hal_ReadRFType_8192E(PADAPTER Adapter); 290 /* RTL8192E-MAC Setting 291 ***********************************************************/ 292 293 u8 SetHwReg8192E(PADAPTER Adapter, u8 variable, u8 *val); 294 void GetHwReg8192E(PADAPTER Adapter, u8 variable, u8 *val); 295 u8 296 SetHalDefVar8192E( 297 PADAPTER Adapter, 298 HAL_DEF_VARIABLE eVariable, 299 void *pValue 300 ); 301 u8 302 GetHalDefVar8192E( 303 PADAPTER Adapter, 304 HAL_DEF_VARIABLE eVariable, 305 void *pValue 306 ); 307 308 void rtl8192e_set_hal_ops(struct hal_ops *pHalFunc); 309 void init_hal_spec_8192e(_adapter *adapter); 310 void rtl8192e_init_default_value(_adapter *padapter); 311 312 void rtl8192e_start_thread(_adapter *padapter); 313 void rtl8192e_stop_thread(_adapter *padapter); 314 315 #ifdef CONFIG_PCI_HCI 316 BOOLEAN InterruptRecognized8192EE(PADAPTER Adapter); 317 u16 get_txbd_rw_reg(u16 ff_hwaddr); 318 #endif 319 320 #ifdef CONFIG_SDIO_HCI 321 #ifdef CONFIG_SDIO_TX_ENABLE_AVAL_INT 322 void _init_available_page_threshold(PADAPTER padapter, u8 numHQ, u8 numNQ, u8 numLQ, u8 numPubQ); 323 #endif 324 #endif 325 326 #ifdef CONFIG_BT_COEXIST 327 void rtl8192e_combo_card_WifiOnlyHwInit(PADAPTER Adapter); 328 #endif 329 330 #endif /* __RTL8192E_HAL_H__ */ 331