1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /****************************************************************************** 3 * 4 * Copyright(c) 2007 - 2017 Realtek Corporation. 5 * 6 * This program is free software; you can redistribute it and/or modify it 7 * under the terms of version 2 of the GNU General Public License as 8 * published by the Free Software Foundation. 9 * 10 * This program is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 * more details. 14 * 15 *****************************************************************************/ 16 #ifndef __HAL_PHY_H__ 17 #define __HAL_PHY_H__ 18 19 20 #if DISABLE_BB_RF 21 #define HAL_FW_ENABLE 0 22 #define HAL_MAC_ENABLE 0 23 #define HAL_BB_ENABLE 0 24 #define HAL_RF_ENABLE 0 25 #else /* FPGA_PHY and ASIC */ 26 #define HAL_FW_ENABLE 1 27 #define HAL_MAC_ENABLE 1 28 #define HAL_BB_ENABLE 1 29 #define HAL_RF_ENABLE 1 30 #endif 31 32 #define RF6052_MAX_TX_PWR 0x3F 33 #define RF6052_MAX_REG_88E 0xFF 34 #define RF6052_MAX_REG_92C 0x7F 35 36 #define RF6052_MAX_REG \ 37 ((RF6052_MAX_REG_88E > RF6052_MAX_REG_92C) ? RF6052_MAX_REG_88E : RF6052_MAX_REG_92C) 38 39 #define GET_RF6052_REAL_MAX_REG(_Adapter) \ 40 (IS_HARDWARE_TYPE_8188E(_Adapter) ? RF6052_MAX_REG_88E : RF6052_MAX_REG_92C) 41 42 #define RF6052_MAX_PATH 2 43 44 /* 45 * Antenna detection method, i.e., using single tone detection or RSSI reported from each antenna detected. 46 * Added by Roger, 2013.05.22. 47 * */ 48 #define ANT_DETECT_BY_SINGLE_TONE BIT0 49 #define ANT_DETECT_BY_RSSI BIT1 50 #define IS_ANT_DETECT_SUPPORT_SINGLE_TONE(__Adapter) ((GET_HAL_DATA(__Adapter)->AntDetection) & ANT_DETECT_BY_SINGLE_TONE) 51 #define IS_ANT_DETECT_SUPPORT_RSSI(__Adapter) ((GET_HAL_DATA(__Adapter)->AntDetection) & ANT_DETECT_BY_RSSI) 52 53 54 /*--------------------------Define Parameters-------------------------------*/ 55 typedef enum _RF_CHIP { 56 RF_CHIP_MIN = 0, /* 0 */ 57 RF_8225 = 1, /* 1 11b/g RF for verification only */ 58 RF_8256 = 2, /* 2 11b/g/n */ 59 RF_8258 = 3, /* 3 11a/b/g/n RF */ 60 RF_6052 = 4, /* 4 11b/g/n RF */ 61 RF_PSEUDO_11N = 5, /* 5, It is a temporality RF. */ 62 RF_CHIP_MAX 63 } RF_CHIP_E, *PRF_CHIP_E; 64 65 typedef enum _ANTENNA_PATH { 66 ANTENNA_NONE = 0, 67 ANTENNA_D = 1, 68 ANTENNA_C = 2, 69 ANTENNA_CD = 3, 70 ANTENNA_B = 4, 71 ANTENNA_BD = 5, 72 ANTENNA_BC = 6, 73 ANTENNA_BCD = 7, 74 ANTENNA_A = 8, 75 ANTENNA_AD = 9, 76 ANTENNA_AC = 10, 77 ANTENNA_ACD = 11, 78 ANTENNA_AB = 12, 79 ANTENNA_ABD = 13, 80 ANTENNA_ABC = 14, 81 ANTENNA_ABCD = 15 82 } ANTENNA_PATH; 83 84 typedef enum _RF_CONTENT { 85 radioa_txt = 0x1000, 86 radiob_txt = 0x1001, 87 radioc_txt = 0x1002, 88 radiod_txt = 0x1003 89 } RF_CONTENT; 90 91 typedef enum _BaseBand_Config_Type { 92 BaseBand_Config_PHY_REG = 0, /* Radio Path A */ 93 BaseBand_Config_AGC_TAB = 1, /* Radio Path B */ 94 BaseBand_Config_AGC_TAB_2G = 2, 95 BaseBand_Config_AGC_TAB_5G = 3, 96 BaseBand_Config_PHY_REG_PG 97 } BaseBand_Config_Type, *PBaseBand_Config_Type; 98 99 typedef enum _HW_BLOCK { 100 HW_BLOCK_MAC = 0, 101 HW_BLOCK_PHY0 = 1, 102 HW_BLOCK_PHY1 = 2, 103 HW_BLOCK_RF = 3, 104 HW_BLOCK_MAXIMUM = 4, /* Never use this */ 105 } HW_BLOCK_E, *PHW_BLOCK_E; 106 107 typedef enum _WIRELESS_MODE { 108 WIRELESS_MODE_UNKNOWN = 0x00, 109 WIRELESS_MODE_A = 0x01, 110 WIRELESS_MODE_B = 0x02, 111 WIRELESS_MODE_G = 0x04, 112 WIRELESS_MODE_AUTO = 0x08, 113 WIRELESS_MODE_N_24G = 0x10, 114 WIRELESS_MODE_N_5G = 0x20, 115 WIRELESS_MODE_AC_5G = 0x40, 116 WIRELESS_MODE_AC_24G = 0x80, 117 WIRELESS_MODE_AC_ONLY = 0x100, 118 } WIRELESS_MODE; 119 120 typedef enum _SwChnlCmdID { 121 CmdID_End, 122 CmdID_SetTxPowerLevel, 123 CmdID_BBRegWrite10, 124 CmdID_WritePortUlong, 125 CmdID_WritePortUshort, 126 CmdID_WritePortUchar, 127 CmdID_RF_WriteReg, 128 } SwChnlCmdID; 129 130 typedef struct _SwChnlCmd { 131 SwChnlCmdID CmdID; 132 u32 Para1; 133 u32 Para2; 134 u32 msDelay; 135 } SwChnlCmd; 136 137 typedef struct _R_ANTENNA_SELECT_OFDM { 138 u32 r_tx_antenna:4; 139 u32 r_ant_l:4; 140 u32 r_ant_non_ht:4; 141 u32 r_ant_ht1:4; 142 u32 r_ant_ht2:4; 143 u32 r_ant_ht_s1:4; 144 u32 r_ant_non_ht_s1:4; 145 u32 OFDM_TXSC:2; 146 u32 Reserved:2; 147 } R_ANTENNA_SELECT_OFDM; 148 149 typedef struct _R_ANTENNA_SELECT_CCK { 150 u8 r_cckrx_enable_2:2; 151 u8 r_cckrx_enable:2; 152 u8 r_ccktx_enable:4; 153 } R_ANTENNA_SELECT_CCK; 154 155 156 /*--------------------------Exported Function prototype---------------------*/ 157 u32 158 PHY_CalculateBitShift( 159 u32 BitMask 160 ); 161 162 #ifdef CONFIG_RF_SHADOW_RW 163 typedef struct RF_Shadow_Compare_Map { 164 /* Shadow register value */ 165 u32 Value; 166 /* Compare or not flag */ 167 u8 Compare; 168 /* Record If it had ever modified unpredicted */ 169 u8 ErrorOrNot; 170 /* Recorver Flag */ 171 u8 Recorver; 172 /* */ 173 u8 Driver_Write; 174 } RF_SHADOW_T; 175 176 u32 177 PHY_RFShadowRead( 178 PADAPTER Adapter, 179 enum rf_path eRFPath, 180 u32 Offset); 181 182 void 183 PHY_RFShadowWrite( 184 PADAPTER Adapter, 185 enum rf_path eRFPath, 186 u32 Offset, 187 u32 Data); 188 189 BOOLEAN 190 PHY_RFShadowCompare( 191 PADAPTER Adapter, 192 enum rf_path eRFPath, 193 u32 Offset); 194 195 void 196 PHY_RFShadowRecorver( 197 PADAPTER Adapter, 198 enum rf_path eRFPath, 199 u32 Offset); 200 201 void 202 PHY_RFShadowCompareAll( 203 PADAPTER Adapter); 204 205 void 206 PHY_RFShadowRecorverAll( 207 PADAPTER Adapter); 208 209 void 210 PHY_RFShadowCompareFlagSet( 211 PADAPTER Adapter, 212 enum rf_path eRFPath, 213 u32 Offset, 214 u8 Type); 215 216 void 217 PHY_RFShadowRecorverFlagSet( 218 PADAPTER Adapter, 219 enum rf_path eRFPath, 220 u32 Offset, 221 u8 Type); 222 223 void 224 PHY_RFShadowCompareFlagSetAll( 225 PADAPTER Adapter); 226 227 void 228 PHY_RFShadowRecorverFlagSetAll( 229 PADAPTER Adapter); 230 231 void 232 PHY_RFShadowRefresh( 233 PADAPTER Adapter); 234 #endif /*#CONFIG_RF_SHADOW_RW*/ 235 #endif /* __HAL_COMMON_H__ */ 236