| 1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
| 2 |
/****************************************************************************** |
| 3 |
* |
| 4 |
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. |
| 5 |
* |
| 6 |
******************************************************************************/ |
| 7 |
#ifndef __RTL8723B_HAL_H__ |
| 8 |
#define __RTL8723B_HAL_H__ |
| 9 |
|
| 10 |
#include "hal_data.h" |
| 11 |
|
| 12 |
#include "rtl8723b_spec.h" |
| 13 |
#include "rtl8723b_rf.h" |
| 14 |
#include "rtl8723b_dm.h" |
| 15 |
#include "rtl8723b_recv.h" |
| 16 |
#include "rtl8723b_xmit.h" |
| 17 |
#include "rtl8723b_cmd.h" |
| 18 |
#include "hal_pwr_seq.h" |
| 19 |
#include "Hal8192CPhyReg.h" |
| 20 |
#include "hal_phy_cfg.h" |
| 21 |
|
| 22 |
/* */ |
| 23 |
/* RTL8723B From header */ |
| 24 |
/* */ |
| 25 |
|
| 26 |
#define FW_8723B_SIZE 0x8000 |
| 27 |
#define FW_8723B_START_ADDRESS 0x1000 |
| 28 |
#define FW_8723B_END_ADDRESS 0x1FFF /* 0x5FFF */ |
| 29 |
|
| 30 |
#define IS_FW_HEADER_EXIST_8723B(fw_hdr) \ |
| 31 |
((le16_to_cpu(fw_hdr->signature) & 0xFFF0) == 0x5300) |
| 32 |
|
| 33 |
struct rt_firmware { |
| 34 |
u32 fw_length; |
| 35 |
u8 *fw_buffer_sz; |
| 36 |
}; |
| 37 |
|
| 38 |
/* This structure must be carefully byte-ordered. */ |
| 39 |
struct rt_firmware_hdr { |
| 40 |
/* 8-byte alignment required */ |
| 41 |
|
| 42 |
/* LONG WORD 0 ---- */ |
| 43 |
__le16 signature; /* 92C0: test chip; 92C, 88C0: test chip; |
| 44 |
* 88C1: MP A-cut; 92C1: MP A-cut |
| 45 |
*/ |
| 46 |
u8 category; /* AP/NIC and USB/PCI */ |
| 47 |
u8 function; /* Reserved for different FW function indications, |
| 48 |
* for further use when driver needs to download |
| 49 |
* different FW in different conditions. |
| 50 |
*/ |
| 51 |
__le16 version; /* FW Version */ |
| 52 |
__le16 subversion; /* FW Subversion, default 0x00 */ |
| 53 |
|
| 54 |
/* LONG WORD 1 ---- */ |
| 55 |
u8 month; /* Release time Month field */ |
| 56 |
u8 date; /* Release time Date field */ |
| 57 |
u8 hour; /* Release time Hour field */ |
| 58 |
u8 minute; /* Release time Minute field */ |
| 59 |
|
| 60 |
__le16 ram_code_size; /* The size of RAM code */ |
| 61 |
__le16 rsvd2; |
| 62 |
|
| 63 |
/* LONG WORD 2 ---- */ |
| 64 |
__le32 svn_idx; /* The SVN entry index */ |
| 65 |
__le32 rsvd3; |
| 66 |
|
| 67 |
/* LONG WORD 3 ---- */ |
| 68 |
__le32 rsvd4; |
| 69 |
__le32 rsvd5; |
| 70 |
}; |
| 71 |
|
| 72 |
#define DRIVER_EARLY_INT_TIME_8723B 0x05 |
| 73 |
#define BCN_DMA_ATIME_INT_TIME_8723B 0x02 |
| 74 |
|
| 75 |
/* for 8723B */ |
| 76 |
/* TX 32K, RX 16K, Page size 128B for TX, 8B for RX */ |
| 77 |
#define PAGE_SIZE_TX_8723B 128 |
| 78 |
#define PAGE_SIZE_RX_8723B 8 |
| 79 |
|
| 80 |
#define RX_DMA_SIZE_8723B 0x4000 /* 16K */ |
| 81 |
#define RX_DMA_RESERVED_SIZE_8723B 0x80 /* 128B, reserved for tx report */ |
| 82 |
#define RX_DMA_BOUNDARY_8723B \ |
| 83 |
(RX_DMA_SIZE_8723B - RX_DMA_RESERVED_SIZE_8723B - 1) |
| 84 |
|
| 85 |
/* Note: We will divide number of pages equally for each queue other than the |
| 86 |
* public queue! |
| 87 |
*/ |
| 88 |
|
| 89 |
/* For General Reserved Page Number(Beacon Queue is reserved page) */ |
| 90 |
/* Beacon:2, PS-Poll:1, Null Data:1, Qos Null Data:1, BT Qos Null Data:1 */ |
| 91 |
#define BCNQ_PAGE_NUM_8723B 0x08 |
| 92 |
#define BCNQ1_PAGE_NUM_8723B 0x00 |
| 93 |
|
| 94 |
#define MAX_RX_DMA_BUFFER_SIZE_8723B 0x2800 /* RX 10K */ |
| 95 |
|
| 96 |
/* For WoWLan, more reserved page */ |
| 97 |
/* ARP Rsp:1, RWC:1, GTK Info:1, GTK RSP:2, GTK EXT MEM:2, PNO: 6 */ |
| 98 |
#define WOWLAN_PAGE_NUM_8723B 0x00 |
| 99 |
|
| 100 |
#define TX_TOTAL_PAGE_NUMBER_8723B \ |
| 101 |
(0xFF - BCNQ_PAGE_NUM_8723B - \ |
| 102 |
BCNQ1_PAGE_NUM_8723B - \ |
| 103 |
WOWLAN_PAGE_NUM_8723B) |
| 104 |
#define TX_PAGE_BOUNDARY_8723B (TX_TOTAL_PAGE_NUMBER_8723B + 1) |
| 105 |
|
| 106 |
#define WMM_NORMAL_TX_TOTAL_PAGE_NUMBER_8723B TX_TOTAL_PAGE_NUMBER_8723B |
| 107 |
#define WMM_NORMAL_TX_PAGE_BOUNDARY_8723B \ |
| 108 |
(WMM_NORMAL_TX_TOTAL_PAGE_NUMBER_8723B + 1) |
| 109 |
|
| 110 |
/* For Normal Chip Setting */ |
| 111 |
/* (HPQ + LPQ + NPQ + PUBQ) shall be TX_TOTAL_PAGE_NUMBER_8723B */ |
| 112 |
#define NORMAL_PAGE_NUM_HPQ_8723B 0x0C |
| 113 |
#define NORMAL_PAGE_NUM_LPQ_8723B 0x02 |
| 114 |
#define NORMAL_PAGE_NUM_NPQ_8723B 0x02 |
| 115 |
|
| 116 |
/* Note: For Normal Chip Setting, modify later */ |
| 117 |
#define WMM_NORMAL_PAGE_NUM_HPQ_8723B 0x30 |
| 118 |
#define WMM_NORMAL_PAGE_NUM_LPQ_8723B 0x20 |
| 119 |
#define WMM_NORMAL_PAGE_NUM_NPQ_8723B 0x20 |
| 120 |
|
| 121 |
#include "HalVerDef.h" |
| 122 |
#include "hal_com.h" |
| 123 |
|
| 124 |
#define EFUSE_OOB_PROTECT_BYTES 15 |
| 125 |
|
| 126 |
#define HAL_EFUSE_MEMORY |
| 127 |
|
| 128 |
#define HWSET_MAX_SIZE_8723B 512 |
| 129 |
#define EFUSE_REAL_CONTENT_LEN_8723B 512 |
| 130 |
#define EFUSE_MAP_LEN_8723B 512 |
| 131 |
#define EFUSE_MAX_SECTION_8723B 64 |
| 132 |
|
| 133 |
#define EFUSE_IC_ID_OFFSET 506 /* For some inferiority IC purpose. |
| 134 |
* Added by Roger, 2009.09.02. |
| 135 |
*/ |
| 136 |
#define AVAILABLE_EFUSE_ADDR(addr) (addr < EFUSE_REAL_CONTENT_LEN_8723B) |
| 137 |
|
| 138 |
#define EFUSE_ACCESS_ON 0x69 /* For RTL8723 only. */ |
| 139 |
#define EFUSE_ACCESS_OFF 0x00 /* For RTL8723 only. */ |
| 140 |
|
| 141 |
/* */ |
| 142 |
/* EFUSE for BT definition */ |
| 143 |
/* */ |
| 144 |
#define EFUSE_BT_REAL_BANK_CONTENT_LEN 512 |
| 145 |
#define EFUSE_BT_REAL_CONTENT_LEN 1536 /* 512*3 */ |
| 146 |
#define EFUSE_BT_MAP_LEN 1024 /* 1k bytes */ |
| 147 |
#define EFUSE_BT_MAX_SECTION 128 /* 1024/8 */ |
| 148 |
|
| 149 |
#define EFUSE_PROTECT_BYTES_BANK 16 |
| 150 |
|
| 151 |
/* Description: Determine the types of C2H events that are the same in driver |
| 152 |
* and FW; First constructed by tynli. 2009.10.09. |
| 153 |
*/ |
| 154 |
enum { |
| 155 |
C2H_DBG = 0, |
| 156 |
C2H_TSF = 1, |
| 157 |
C2H_AP_RPT_RSP = 2, |
| 158 |
C2H_CCX_TX_RPT = 3, /* The FW notify the report |
| 159 |
* of the specific tx packet. |
| 160 |
*/ |
| 161 |
C2H_BT_RSSI = 4, |
| 162 |
C2H_BT_OP_MODE = 5, |
| 163 |
C2H_EXT_RA_RPT = 6, |
| 164 |
C2H_8723B_BT_INFO = 9, |
| 165 |
C2H_HW_INFO_EXCH = 10, |
| 166 |
C2H_8723B_BT_MP_INFO = 11, |
| 167 |
MAX_C2HEVENT |
| 168 |
}; |
| 169 |
|
| 170 |
struct c2h_evt_hdr_t { |
| 171 |
u8 CmdID; |
| 172 |
u8 CmdLen; |
| 173 |
u8 CmdSeq; |
| 174 |
} __attribute__((__packed__)); |
| 175 |
|
| 176 |
enum { /* tag_Package_Definition */ |
| 177 |
PACKAGE_DEFAULT, |
| 178 |
PACKAGE_QFN68, |
| 179 |
PACKAGE_TFBGA90, |
| 180 |
PACKAGE_TFBGA80, |
| 181 |
PACKAGE_TFBGA79 |
| 182 |
}; |
| 183 |
|
| 184 |
#define INCLUDE_MULTI_FUNC_BT(_Adapter) \ |
| 185 |
(GET_HAL_DATA(_Adapter)->MultiFunc & RT_MULTI_FUNC_BT) |
| 186 |
#define INCLUDE_MULTI_FUNC_GPS(_Adapter) \ |
| 187 |
(GET_HAL_DATA(_Adapter)->MultiFunc & RT_MULTI_FUNC_GPS) |
| 188 |
|
| 189 |
/* rtl8723a_hal_init.c */ |
| 190 |
s32 rtl8723b_FirmwareDownload(struct adapter *padapter, bool bUsedWoWLANFw); |
| 191 |
void rtl8723b_FirmwareSelfReset(struct adapter *padapter); |
| 192 |
void rtl8723b_InitializeFirmwareVars(struct adapter *padapter); |
| 193 |
|
| 194 |
void rtl8723b_InitAntenna_Selection(struct adapter *padapter); |
| 195 |
void rtl8723b_init_default_value(struct adapter *padapter); |
| 196 |
|
| 197 |
s32 rtl8723b_InitLLTTable(struct adapter *padapter); |
| 198 |
|
| 199 |
/* EFuse */ |
| 200 |
u8 GetEEPROMSize8723B(struct adapter *padapter); |
| 201 |
void Hal_InitPGData(struct adapter *padapter, u8 *PROMContent); |
| 202 |
void Hal_EfuseParseIDCode(struct adapter *padapter, u8 *hwinfo); |
| 203 |
void Hal_EfuseParseTxPowerInfo_8723B(struct adapter *padapter, u8 *PROMContent, |
| 204 |
bool AutoLoadFail); |
| 205 |
void Hal_EfuseParseBTCoexistInfo_8723B(struct adapter *padapter, u8 *hwinfo, |
| 206 |
bool AutoLoadFail); |
| 207 |
void Hal_EfuseParseEEPROMVer_8723B(struct adapter *padapter, u8 *hwinfo, |
| 208 |
bool AutoLoadFail); |
| 209 |
void Hal_EfuseParseChnlPlan_8723B(struct adapter *padapter, u8 *hwinfo, |
| 210 |
bool AutoLoadFail); |
| 211 |
void Hal_EfuseParseCustomerID_8723B(struct adapter *padapter, u8 *hwinfo, |
| 212 |
bool AutoLoadFail); |
| 213 |
void Hal_EfuseParseXtal_8723B(struct adapter *padapter, u8 *hwinfo, |
| 214 |
bool AutoLoadFail); |
| 215 |
void Hal_EfuseParseThermalMeter_8723B(struct adapter *padapter, u8 *hwinfo, |
| 216 |
u8 AutoLoadFail); |
| 217 |
void Hal_EfuseParsePackageType_8723B(struct adapter *padapter, u8 *hwinfo, |
| 218 |
bool AutoLoadFail); |
| 219 |
void Hal_EfuseParseVoltage_8723B(struct adapter *padapter, u8 *hwinfo, |
| 220 |
bool AutoLoadFail); |
| 221 |
|
| 222 |
void C2HPacketHandler_8723B(struct adapter *padapter, u8 *pbuffer, u16 length); |
| 223 |
|
| 224 |
void SetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val); |
| 225 |
void GetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val); |
| 226 |
u8 GetHalDefVar8723B(struct adapter *padapter, enum hal_def_variable variable, |
| 227 |
void *pval); |
| 228 |
|
| 229 |
/* register */ |
| 230 |
void rtl8723b_InitBeaconParameters(struct adapter *padapter); |
| 231 |
void _InitBurstPktLen_8723BS(struct adapter *adapter); |
| 232 |
void _8051Reset8723(struct adapter *padapter); |
| 233 |
|
| 234 |
int FirmwareDownloadBT(struct adapter *adapter, struct rt_firmware *firmware); |
| 235 |
|
| 236 |
void CCX_FwC2HTxRpt_8723b(struct adapter *padapter, u8 *pdata, u8 len); |
| 237 |
s32 c2h_id_filter_ccx_8723b(u8 *buf); |
| 238 |
s32 c2h_handler_8723b(struct adapter *padapter, u8 *pC2hEvent); |
| 239 |
u8 MRateToHwRate8723B(u8 rate); |
| 240 |
u8 HwRateToMRate8723B(u8 rate); |
| 241 |
|
| 242 |
void Hal_ReadRFGainOffset(struct adapter *padapter, u8 *hwinfo, |
| 243 |
bool AutoLoadFail); |
| 244 |
|
| 245 |
#endif |