1 /* SPDX-License-Identifier: GPL-2.0 */
2 /******************************************************************************
4 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
6 ******************************************************************************/
10 #include "odm_precomp.h"
11 #include <hal_btcoex.h>
16 /* <Roger_Notes> For RTL8723 WiFi/BT/GPS multi-function configuration. 2010.10.06. */
19 RT_MULTI_FUNC_NONE = 0x00,
20 RT_MULTI_FUNC_WIFI = 0x01,
21 RT_MULTI_FUNC_BT = 0x02,
22 RT_MULTI_FUNC_GPS = 0x04,
25 /* <Roger_Notes> For RTL8723 WiFi PDn/GPIO polarity control configuration. 2010.10.08. */
27 enum rt_polarity_ctl {
28 RT_POLARITY_LOW_ACT = 0,
29 RT_POLARITY_HIGH_ACT = 1,
32 /* For RTL8723 regulator mode. by tynli. 2011.01.14. */
33 enum rt_regulator_mode {
34 RT_SWITCHING_REGULATOR = 0,
39 RT_AMPDU_BURST_NONE = 0,
40 RT_AMPDU_BURST_92D = 1,
41 RT_AMPDU_BURST_88E = 2,
42 RT_AMPDU_BURST_8812_4 = 3,
43 RT_AMPDU_BURST_8812_8 = 4,
44 RT_AMPDU_BURST_8812_12 = 5,
45 RT_AMPDU_BURST_8812_15 = 6,
46 RT_AMPDU_BURST_8723B = 7,
49 #define CHANNEL_MAX_NUMBER (14) /* 14 is the max channel number */
50 #define CHANNEL_MAX_NUMBER_2G 14
51 #define MAX_PG_GROUP 13
53 /* Tx Power Limit Table Size */
54 #define MAX_REGULATION_NUM 4
55 #define MAX_2_4G_BANDWIDTH_NUM 2
56 #define MAX_RATE_SECTION_NUM 3 /* CCK:1, OFDM:1, HT:1 */
58 /* duplicate code, will move to ODM ######### */
59 /* define IQK_MAC_REG_NUM 4 */
60 /* define IQK_ADDA_REG_NUM 16 */
62 /* define IQK_BB_REG_NUM 10 */
64 /* define HP_THERMAL_NUM 8 */
65 /* duplicate code, will move to ODM ######### */
68 SINGLEMAC_SINGLEPHY, /* SMSP */
69 DUALMAC_DUALPHY, /* DMDP */
70 DUALMAC_SINGLEPHY, /* DMSP */
73 #define PAGE_SIZE_128 128
74 #define PAGE_SIZE_256 256
75 #define PAGE_SIZE_512 512
80 #define DYNAMIC_FUNC_BT BIT0
87 /* Upper and Lower Signal threshold for Rate Adaptive */
88 int UndecoratedSmoothedPWDB;
89 int UndecoratedSmoothedCCK;
90 int EntryMinUndecoratedSmoothedPWDB;
91 int EntryMaxUndecoratedSmoothedPWDB;
92 int MinUndecoratedPWDBForDM;
93 int LastMinUndecoratedPWDBForDM;
95 s32 UndecoratedSmoothedBeacon;
97 /* duplicate code, will move to ODM ######### */
99 u8 bDynamicTxPowerEnable;
101 u8 DynamicTxHighPowerLvl;/* Add by Jacken Tx Power Control for Near/Far Range 2008/03/06 */
103 /* for tx power tracking */
106 u8 bTXPowerTrackingInit;
107 u8 TxPowerTrackControl; /* for mp mode, turn off txpwrtracking as default */
110 u8 ThermalMeter[2]; /* ThermalMeter, index 0 for RFIC0, and 1 for RFIC1 */
119 u32 APKoutput[2][2]; /* path A/B; output1_1a/output1_2a */
121 u8 bAPKThermalMeterIgnore;
130 u32 ADDA_backup[IQK_ADDA_REG_NUM];
131 u32 IQK_MAC_backup[IQK_MAC_REG_NUM];
132 u32 IQK_BB_backup_recover[9];
133 u32 IQK_BB_backup[IQK_BB_REG_NUM];
135 u8 PowerIndex_backup[6];
144 u8 ThermalValue_HP[HP_THERMAL_NUM];
145 u8 ThermalValue_HP_index;
148 /* for TxPwrTracking2 */
154 u32 TXPowerTrackingCallbackCnt; /* cosa add for debug */
156 u32 prv_traffic_idx; /* edca turbo */
157 /* duplicate code, will move to ODM ######### */
159 /* Add for Reading Initial Data Rate SEL Register 0x484 during watchdog. Using for fill tx desc. 2011.3.21 by Thomas */
164 struct hal_com_data {
165 struct hal_version VersionID;
166 enum rt_multi_func MultiFunc; /* For multi-function consideration. */
167 enum rt_polarity_ctl PolarityCtl; /* For Wifi PDn Polarity control. */
168 enum rt_regulator_mode RegulatorMode; /* switching regulator or LDO */
171 u16 FirmwareVersionRev;
172 u16 FirmwareSubVersion;
173 u16 FirmwareSignature;
175 /* current WIFI_PHY values */
176 enum wireless_mode CurrentWirelessMode;
177 enum channel_width CurrentChannelBW;
179 u8 CurrentCenterFrequencyIndex1;
180 u8 nCur40MhzPrimeSC;/* Control channel sub-carrier */
181 u8 nCur80MhzPrimeSC; /* used for primary 40MHz of 80MHz mode */
185 u16 ForcedDataRate;/* Force Data Rate. 0: Auto, 0x02: 1M ~ 0x6C: 54M. */
197 u8 DefaultInitialGain[4];
198 /* EEPROM setting. */
203 u8 EEPROMSubCustomerID;
206 u8 EEPROMThermalMeter;
207 u8 EEPROMBluetoothCoexist;
208 u8 EEPROMBluetoothType;
209 u8 EEPROMBluetoothAntNum;
210 u8 EEPROMBluetoothAntIsolation;
211 u8 EEPROMBluetoothRadioShared;
212 u8 bTXPowerDataReadFromEEPORM;
213 u8 bAPKThermalMeterIgnore;
214 u8 bDisableSWChannelPlan; /* flag of disable software change channel plan */
217 u8 EfuseUsedPercentage;
219 struct efuse_hal EfuseHal;
222 u8 Index24G_CCK_Base[MAX_RF_PATH][CHANNEL_MAX_NUMBER];
223 u8 Index24G_BW40_Base[MAX_RF_PATH][CHANNEL_MAX_NUMBER];
224 /* If only one tx, only BW20 and OFDM are used. */
225 s8 CCK_24G_Diff[MAX_RF_PATH][MAX_TX_COUNT];
226 s8 OFDM_24G_Diff[MAX_RF_PATH][MAX_TX_COUNT];
227 s8 BW20_24G_Diff[MAX_RF_PATH][MAX_TX_COUNT];
228 s8 BW40_24G_Diff[MAX_RF_PATH][MAX_TX_COUNT];
232 u8 TxPwrInPercentage;
234 u8 TxPwrCalibrateRate;
235 /* TX power by rate table */
236 /* RF: at most 2 = AB = 0/1 */
237 /* CCK = 0 OFDM = 1 HT-MCS 0-7 = 2 */
240 s8 TxPwrByRateOffset[MAX_RF_PATH_NUM][TX_PWR_BY_RATE_NUM_RATE];
243 /* 2 Power Limit Table */
244 u8 TxPwrLevelCck[RF_PATH_MAX_92C_88E][CHANNEL_MAX_NUMBER];
245 u8 TxPwrLevelHT40_1S[RF_PATH_MAX_92C_88E][CHANNEL_MAX_NUMBER]; /* For HT 40MHZ pwr */
246 u8 TxPwrLevelHT40_2S[RF_PATH_MAX_92C_88E][CHANNEL_MAX_NUMBER]; /* For HT 40MHZ pwr */
247 s8 TxPwrHt20Diff[RF_PATH_MAX_92C_88E][CHANNEL_MAX_NUMBER];/* HT 20<->40 Pwr diff */
248 u8 TxPwrLegacyHtDiff[RF_PATH_MAX_92C_88E][CHANNEL_MAX_NUMBER];/* For HT<->legacy pwr diff */
250 /* Power Limit Table for 2.4G */
251 s8 TxPwrLimit_2_4G[MAX_REGULATION_NUM]
252 [MAX_2_4G_BANDWIDTH_NUM]
253 [MAX_RATE_SECTION_NUM]
254 [CHANNEL_MAX_NUMBER_2G]
257 /* Store the original power by rate value of the base of each rate section of rf path A & B */
258 u8 TxPwrByRateBase2_4G[MAX_RF_PATH_NUM][MAX_RATE_SECTION_NUM];
260 /* For power group */
261 u8 PwrGroupHT20[RF_PATH_MAX_92C_88E][CHANNEL_MAX_NUMBER];
262 u8 PwrGroupHT40[RF_PATH_MAX_92C_88E][CHANNEL_MAX_NUMBER];
268 u8 LegacyHTTxPowerDiff;/* Legacy to HT rate power diff */
269 /* The current Tx Power Level */
270 u8 CurrentCckTxPwrIdx;
271 u8 CurrentOfdm24GTxPwrIdx;
272 u8 CurrentBW2024GTxPwrIdx;
273 u8 CurrentBW4024GTxPwrIdx;
275 /* Read/write are allow for following hardware information variables */
277 u32 MCSTxPowerLevelOriginalOffset[MAX_PG_GROUP][16];
278 u32 CCKTxPowerLevelOriginalOffset;
281 u32 AntennaTxPath; /* Antenna path Tx */
282 u32 AntennaRxPath; /* Antenna path Rx */
300 bool bChnlBWInitialized;
303 u8 bLedOpenDrain; /* Support Open-drain arrangement for controlling the LED. Added by Roger, 2009.10.16. */
304 u8 TxPowerTrackControl; /* for mp mode, turn off txpwrtracking as default */
305 u8 b1x1RecvCombine; /* for 1T1R receive combining */
307 u32 AcParam_BE; /* Original parameter for BE, use for EDCA turbo. */
309 struct bb_register_def PHYRegDef[4]; /* Radio A/B/C/D */
316 /* for host message to fw */
321 /* Beacon function related global variable. */
334 u8 ant_path; /* for 8723B s0/s1 selection */
336 u8 u1ForcedIgiLb; /* forced IGI lower bound */
338 u8 bDumpRxPkt;/* for debug */
339 u8 bDumpTxPkt;/* for debug */
340 u8 FwRsvdPageStartOffset; /* 2010.06.23. Added by tynli. Reserve page start offset except beacon in TxQ. */
342 /* 2010/08/09 MH Add CU power down mode. */
345 /* Add for dual MAC 0--Mac0 1--Mac1 */
351 /* 2010/12/10 MH Add for USB aggregation mode dynamic scheme. */
352 bool UsbRxHighSpeedMode;
354 /* 2010/11/22 MH Add for slim combo debug mode selective. */
355 /* This is used for fix the drawback of CU TSMC-A/UMC-A cut. HW auto suspend ability. Close BT clock. */
358 /* u8 AMPDUDensity; */
360 /* Auto FSM to Turn On, include clock, isolation, power control for MAC only */
364 struct submit_ctx iqk_sctx;
366 enum rt_ampdu_burst AMPDUBurstMode; /* 92C maybe not use, but for compile successfully */
371 /* SDIO Tx FIFO related. */
372 /* HIQ, MID, LOW, PUB free pages; padapter->xmitpriv.free_txpg */
373 u8 SdioTxFIFOFreePage[SDIO_TX_FREE_PG_QUEUE];
374 spinlock_t SdioTxFIFOFreePageLock;
375 u8 SdioTxOQTMaxFreeSpace;
376 u8 SdioTxOQTFreeSpace;
379 /* SDIO Rx FIFO related. */
383 u32 sdio_tx_max_len[SDIO_MAX_TX_QUEUE];/* H, N, L, used for sdio tx aggregation max length per queue */
385 struct dm_priv dmpriv;
386 struct dm_odm_t odmpriv;
388 /* For bluetooth co-existance */
389 struct bt_coexist bt_coexist;
391 /* Interrupt related register information. */
396 #define GET_HAL_DATA(__padapter) ((struct hal_com_data *)((__padapter)->HalData))
397 #define GET_HAL_RFPATH_NUM(__padapter) (((struct hal_com_data *)((__padapter)->HalData))->NumTotalRFPath)
398 #define RT_GetInterfaceSelection(_Adapter) (GET_HAL_DATA(_Adapter)->InterfaceSel)
400 #endif /* __HAL_DATA_H__ */