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 __RTL8188F_HAL_H__ 21 #define __RTL8188F_HAL_H__ 22 23 #include "hal_data.h" 24 25 #include "rtl8188f_spec.h" 26 #include "rtl8188f_rf.h" 27 #include "rtl8188f_dm.h" 28 #include "rtl8188f_recv.h" 29 #include "rtl8188f_xmit.h" 30 #include "rtl8188f_cmd.h" 31 #include "rtl8188f_led.h" 32 #include "Hal8188FPwrSeq.h" 33 #include "Hal8188FPhyReg.h" 34 #include "Hal8188FPhyCfg.h" 35 #ifdef DBG_CONFIG_ERROR_DETECT 36 #include "rtl8188f_sreset.h" 37 #endif 38 39 40 /* --------------------------------------------------------------------- 41 * RTL8188F From file 42 * --------------------------------------------------------------------- */ 43 #define RTL8188F_FW_IMG "rtl8188f/FW_NIC.bin" 44 #define RTL8188F_FW_WW_IMG "rtl8188f/FW_WoWLAN.bin" 45 #define RTL8188F_PHY_REG "rtl8188f/PHY_REG.txt" 46 #define RTL8188F_PHY_RADIO_A "rtl8188f/RadioA.txt" 47 #define RTL8188F_PHY_RADIO_B "rtl8188f/RadioB.txt" 48 #define RTL8188F_TXPWR_TRACK "rtl8188f/TxPowerTrack.txt" 49 #define RTL8188F_AGC_TAB "rtl8188f/AGC_TAB.txt" 50 #define RTL8188F_PHY_MACREG "rtl8188f/MAC_REG.txt" 51 #define RTL8188F_PHY_REG_PG "rtl8188f/PHY_REG_PG.txt" 52 #define RTL8188F_PHY_REG_MP "rtl8188f/PHY_REG_MP.txt" 53 #define RTL8188F_TXPWR_LMT "rtl8188f/TXPWR_LMT.txt" 54 55 /* --------------------------------------------------------------------- 56 * RTL8188F From header 57 * --------------------------------------------------------------------- */ 58 59 #if MP_DRIVER == 1 60 #define Rtl8188F_FwBTImgArray Rtl8188FFwBTImgArray 61 #define Rtl8188F_FwBTImgArrayLength Rtl8188FFwBTImgArrayLength 62 63 #define Rtl8188F_FwMPImageArray Rtl8188FFwMPImgArray 64 #define Rtl8188F_FwMPImgArrayLength Rtl8188FMPImgArrayLength 65 66 #define Rtl8188F_PHY_REG_Array_MP Rtl8188F_PHYREG_Array_MP 67 #define Rtl8188F_PHY_REG_Array_MPLength Rtl8188F_PHYREG_Array_MPLength 68 #endif 69 70 71 #define FW_8188F_SIZE 0x8000 72 #define FW_8188F_START_ADDRESS 0x1000 73 #define FW_8188F_END_ADDRESS 0x1FFF /* 0x5FFF */ 74 75 #define IS_FW_HEADER_EXIST_8188F(_pFwHdr) ((le16_to_cpu(_pFwHdr->Signature) & 0xFFF0) == 0x88F0) 76 77 typedef struct _RT_FIRMWARE { 78 FIRMWARE_SOURCE eFWSource; 79 #ifdef CONFIG_EMBEDDED_FWIMG 80 u8 *szFwBuffer; 81 #else 82 u8 szFwBuffer[FW_8188F_SIZE]; 83 #endif 84 u32 ulFwLength; 85 } RT_FIRMWARE_8188F, *PRT_FIRMWARE_8188F; 86 87 /* 88 * This structure must be cared byte-ordering 89 * 90 * Added by tynli. 2009.12.04. */ 91 typedef struct _RT_8188F_FIRMWARE_HDR { 92 /* 8-byte alinment required */ 93 94 /* --- LONG WORD 0 ---- */ 95 u16 Signature; /* 92C0: test chip; 92C, 88C0: test chip; 88C1: MP A-cut; 92C1: MP A-cut */ 96 u8 Category; /* AP/NIC and USB/PCI */ 97 u8 Function; /* Reserved for different FW function indcation, for further use when driver needs to download different FW in different conditions */ 98 u16 Version; /* FW Version */ 99 u16 Subversion; /* FW Subversion, default 0x00 */ 100 101 /* --- LONG WORD 1 ---- */ 102 u8 Month; /* Release time Month field */ 103 u8 Date; /* Release time Date field */ 104 u8 Hour; /* Release time Hour field */ 105 u8 Minute; /* Release time Minute field */ 106 u16 RamCodeSize; /* The size of RAM code */ 107 u16 Rsvd2; 108 109 /* --- LONG WORD 2 ---- */ 110 u32 SvnIdx; /* The SVN entry index */ 111 u32 Rsvd3; 112 113 /* --- LONG WORD 3 ---- */ 114 u32 Rsvd4; 115 u32 Rsvd5; 116 } RT_8188F_FIRMWARE_HDR, *PRT_8188F_FIRMWARE_HDR; 117 118 #define DRIVER_EARLY_INT_TIME_8188F 0x05 119 #define BCN_DMA_ATIME_INT_TIME_8188F 0x02 120 121 /* for 8188F 122 * TX 32K, RX 16K, Page size 128B for TX, 8B for RX */ 123 #define PAGE_SIZE_TX_8188F 128 124 #define PAGE_SIZE_RX_8188F 8 125 126 #define RX_DMA_SIZE_8188F 0x4000 /* 16K */ 127 #ifdef CONFIG_FW_C2H_DEBUG 128 #define RX_DMA_RESERVED_SIZE_8188F 0x100 /* 256B, reserved for c2h debug message */ 129 #else 130 #define RX_DMA_RESERVED_SIZE_8188F 0x80 /* 128B, reserved for tx report */ 131 #endif 132 133 #ifdef CONFIG_WOWLAN 134 #define RESV_FMWF (WKFMCAM_SIZE * MAX_WKFM_NUM) /* 16 entries, for each is 24 bytes*/ 135 #else 136 #define RESV_FMWF 0 137 #endif 138 139 #define RX_DMA_BOUNDARY_8188F (RX_DMA_SIZE_8188F - RX_DMA_RESERVED_SIZE_8188F - 1) 140 141 /* Note: We will divide number of page equally for each queue other than public queue! */ 142 143 /* For General Reserved Page Number(Beacon Queue is reserved page) 144 * Beacon:2, PS-Poll:1, Null Data:1,Qos Null Data:1,BT Qos Null Data:1 */ 145 #define BCNQ_PAGE_NUM_8188F 0x08 146 #ifdef CONFIG_CONCURRENT_MODE 147 #define BCNQ1_PAGE_NUM_8188F 0x08 /* 0x04 */ 148 #else 149 #define BCNQ1_PAGE_NUM_8188F 0x00 150 #endif 151 152 #ifdef CONFIG_PNO_SUPPORT 153 #undef BCNQ1_PAGE_NUM_8188F 154 #define BCNQ1_PAGE_NUM_8188F 0x00 /* 0x04 */ 155 #endif 156 157 /* For WoWLan , more reserved page 158 * ARP Rsp:1, RWC:1, GTK Info:1,GTK RSP:2,GTK EXT MEM:2, PNO: 6 */ 159 #ifdef CONFIG_WOWLAN 160 #define WOWLAN_PAGE_NUM_8188F 0x07 161 #else 162 #define WOWLAN_PAGE_NUM_8188F 0x00 163 #endif 164 165 #ifdef CONFIG_PNO_SUPPORT 166 #undef WOWLAN_PAGE_NUM_8188F 167 #define WOWLAN_PAGE_NUM_8188F 0x15 168 #endif 169 170 #ifdef CONFIG_AP_WOWLAN 171 #define AP_WOWLAN_PAGE_NUM_8188F 0x02 172 #endif 173 174 #define TX_TOTAL_PAGE_NUMBER_8188F (0xFF - BCNQ_PAGE_NUM_8188F - BCNQ1_PAGE_NUM_8188F - WOWLAN_PAGE_NUM_8188F) 175 #define TX_PAGE_BOUNDARY_8188F (TX_TOTAL_PAGE_NUMBER_8188F + 1) 176 177 #define WMM_NORMAL_TX_TOTAL_PAGE_NUMBER_8188F TX_TOTAL_PAGE_NUMBER_8188F 178 #define WMM_NORMAL_TX_PAGE_BOUNDARY_8188F (WMM_NORMAL_TX_TOTAL_PAGE_NUMBER_8188F + 1) 179 180 /* For Normal Chip Setting 181 * (HPQ + LPQ + NPQ + PUBQ) shall be TX_TOTAL_PAGE_NUMBER_8188F */ 182 #define NORMAL_PAGE_NUM_HPQ_8188F 0x0C 183 #define NORMAL_PAGE_NUM_LPQ_8188F 0x02 184 #define NORMAL_PAGE_NUM_NPQ_8188F 0x02 185 186 /* Note: For Normal Chip Setting, modify later */ 187 #define WMM_NORMAL_PAGE_NUM_HPQ_8188F 0x30 188 #define WMM_NORMAL_PAGE_NUM_LPQ_8188F 0x20 189 #define WMM_NORMAL_PAGE_NUM_NPQ_8188F 0x20 190 191 192 #include "HalVerDef.h" 193 #include "hal_com.h" 194 195 #define EFUSE_OOB_PROTECT_BYTES 15 196 197 #define HAL_EFUSE_MEMORY 198 199 #define HWSET_MAX_SIZE_8188F 512 200 #define EFUSE_REAL_CONTENT_LEN_8188F 512 201 #define EFUSE_MAP_LEN_8188F 512 202 #define EFUSE_MAX_SECTION_8188F 64 203 204 #define EFUSE_IC_ID_OFFSET 506 /* For some inferiority IC purpose. added by Roger, 2009.09.02. */ 205 #define AVAILABLE_EFUSE_ADDR(addr) (addr < EFUSE_REAL_CONTENT_LEN_8188F) 206 207 #define EFUSE_ACCESS_ON 0x69 /* For RTL8188 only. */ 208 #define EFUSE_ACCESS_OFF 0x00 /* For RTL8188 only. */ 209 210 /* ******************************************************** 211 * EFUSE for BT definition 212 * ******************************************************** */ 213 #define EFUSE_BT_REAL_BANK_CONTENT_LEN 512 214 #define EFUSE_BT_REAL_CONTENT_LEN 1536 /* 512*3 */ 215 #define EFUSE_BT_MAP_LEN 1024 /* 1k bytes */ 216 #define EFUSE_BT_MAX_SECTION 128 /* 1024/8 */ 217 218 #define EFUSE_PROTECT_BYTES_BANK 16 219 220 typedef struct _C2H_EVT_HDR { 221 u8 CmdID; 222 u8 CmdLen; 223 u8 CmdSeq; 224 } __attribute__((__packed__)) C2H_EVT_HDR, *PC2H_EVT_HDR; 225 226 #define INCLUDE_MULTI_FUNC_BT(_Adapter) (GET_HAL_DATA(_Adapter)->MultiFunc & RT_MULTI_FUNC_BT) 227 #define INCLUDE_MULTI_FUNC_GPS(_Adapter) (GET_HAL_DATA(_Adapter)->MultiFunc & RT_MULTI_FUNC_GPS) 228 229 /* rtl8188a_hal_init.c */ 230 s32 rtl8188f_FirmwareDownload(PADAPTER padapter, BOOLEAN bUsedWoWLANFw); 231 void rtl8188f_FirmwareSelfReset(PADAPTER padapter); 232 void rtl8188f_InitializeFirmwareVars(PADAPTER padapter); 233 234 void rtl8188f_InitAntenna_Selection(PADAPTER padapter); 235 void rtl8188f_DeinitAntenna_Selection(PADAPTER padapter); 236 void rtl8188f_CheckAntenna_Selection(PADAPTER padapter); 237 void rtl8188f_init_default_value(PADAPTER padapter); 238 239 s32 rtl8188f_InitLLTTable(PADAPTER padapter); 240 241 s32 CardDisableHWSM(PADAPTER padapter, u8 resetMCU); 242 s32 CardDisableWithoutHWSM(PADAPTER padapter); 243 244 /* EFuse */ 245 u8 GetEEPROMSize8188F(PADAPTER padapter); 246 void Hal_InitPGData(PADAPTER padapter, u8 *PROMContent); 247 void Hal_EfuseParseIDCode(PADAPTER padapter, u8 *hwinfo); 248 void Hal_EfuseParseTxPowerInfo_8188F(PADAPTER padapter, u8 *PROMContent, BOOLEAN AutoLoadFail); 249 /* void Hal_EfuseParseBTCoexistInfo_8188F(PADAPTER padapter, u8 *hwinfo, BOOLEAN AutoLoadFail); */ 250 void Hal_EfuseParseEEPROMVer_8188F(PADAPTER padapter, u8 *hwinfo, BOOLEAN AutoLoadFail); 251 void Hal_EfuseParseChnlPlan_8188F(PADAPTER padapter, u8 *hwinfo, BOOLEAN AutoLoadFail); 252 void Hal_EfuseParseCustomerID_8188F(PADAPTER padapter, u8 *hwinfo, BOOLEAN AutoLoadFail); 253 void Hal_EfuseParsePowerSavingMode_8188F(PADAPTER pAdapter, u8 *hwinfo, BOOLEAN AutoLoadFail); 254 void Hal_EfuseParseAntennaDiversity_8188F(PADAPTER padapter, u8 *hwinfo, BOOLEAN AutoLoadFail); 255 void Hal_EfuseParseXtal_8188F(PADAPTER pAdapter, u8 *hwinfo, u8 AutoLoadFail); 256 void Hal_EfuseParseThermalMeter_8188F(PADAPTER padapter, u8 *hwinfo, u8 AutoLoadFail); 257 void Hal_EfuseParseKFreeData_8188F(PADAPTER pAdapter, u8 *hwinfo, BOOLEAN AutoLoadFail); 258 259 #if 0 /* Do not need for rtl8188f */ 260 VOID Hal_EfuseParseVoltage_8188F(PADAPTER pAdapter, u8 *hwinfo, BOOLEAN AutoLoadFail); 261 #endif 262 263 #ifdef CONFIG_C2H_PACKET_EN 264 void rtl8188f_c2h_packet_handler(PADAPTER padapter, u8 *pbuf, u16 length); 265 #endif 266 267 void rtl8188f_set_pll_ref_clk_sel(_adapter *adapter, u8 sel); 268 269 void rtl8188f_set_hal_ops(struct hal_ops *pHalFunc); 270 void init_hal_spec_8188f(_adapter *adapter); 271 void SetHwReg8188F(PADAPTER padapter, u8 variable, u8 *val); 272 void GetHwReg8188F(PADAPTER padapter, u8 variable, u8 *val); 273 #ifdef CONFIG_C2H_PACKET_EN 274 void SetHwRegWithBuf8188F(PADAPTER padapter, u8 variable, u8 *pbuf, int len); 275 #endif /* CONFIG_C2H_PACKET_EN */ 276 u8 SetHalDefVar8188F(PADAPTER padapter, HAL_DEF_VARIABLE variable, void *pval); 277 u8 GetHalDefVar8188F(PADAPTER padapter, HAL_DEF_VARIABLE variable, void *pval); 278 279 /* register */ 280 void rtl8188f_InitBeaconParameters(PADAPTER padapter); 281 void rtl8188f_InitBeaconMaxError(PADAPTER padapter, u8 InfraMode); 282 void _InitBurstPktLen_8188FS(PADAPTER Adapter); 283 void _8051Reset8188(PADAPTER padapter); 284 #ifdef CONFIG_WOWLAN 285 void Hal_DetectWoWMode(PADAPTER pAdapter); 286 #endif /* CONFIG_WOWLAN */ 287 288 void rtl8188f_start_thread(_adapter *padapter); 289 void rtl8188f_stop_thread(_adapter *padapter); 290 291 #if defined(CONFIG_CHECK_BT_HANG) && defined(CONFIG_BT_COEXIST) 292 void rtl8188fs_init_checkbthang_workqueue(_adapter *adapter); 293 void rtl8188fs_free_checkbthang_workqueue(_adapter *adapter); 294 void rtl8188fs_cancle_checkbthang_workqueue(_adapter *adapter); 295 void rtl8188fs_hal_check_bt_hang(_adapter *adapter); 296 #endif 297 298 #ifdef CONFIG_GPIO_WAKEUP 299 void HalSetOutPutGPIO(PADAPTER padapter, u8 index, u8 OutPutValue); 300 #endif 301 302 int FirmwareDownloadBT(IN PADAPTER Adapter, PRT_MP_FIRMWARE pFirmware); 303 304 void CCX_FwC2HTxRpt_8188f(PADAPTER padapter, u8 *pdata, u8 len); 305 #ifdef CONFIG_FW_C2H_DEBUG 306 void Debug_FwC2H_8188f(PADAPTER padapter, u8 *pdata, u8 len); 307 #endif /* CONFIG_FW_C2H_DEBUG */ 308 s32 c2h_id_filter_ccx_8188f(u8 *buf); 309 s32 c2h_handler_8188f(PADAPTER padapter, u8 *pC2hEvent); 310 u8 MRateToHwRate8188F(u8 rate); 311 u8 HwRateToMRate8188F(u8 rate); 312 313 #ifdef CONFIG_PCI_HCI 314 BOOLEAN InterruptRecognized8188FE(PADAPTER Adapter); 315 VOID UpdateInterruptMask8188FE(PADAPTER Adapter, u32 AddMSR, u32 AddMSR1, u32 RemoveMSR, u32 RemoveMSR1); 316 #endif 317 318 #endif 319