add rk3288 pinctrl dts code
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rtl8188eu / include / hal_phy.h
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 __HAL_PHY_H__
21 #define __HAL_PHY_H__
22
23
24 #if DISABLE_BB_RF
25 #define HAL_FW_ENABLE                           0
26 #define HAL_MAC_ENABLE                  0
27 #define HAL_BB_ENABLE                           0
28 #define HAL_RF_ENABLE                           0
29 #else // FPGA_PHY and ASIC
30 #define         HAL_FW_ENABLE                           1
31 #define HAL_MAC_ENABLE                  1
32 #define HAL_BB_ENABLE                           1
33 #define HAL_RF_ENABLE                           1
34 #endif
35
36 #define RF6052_MAX_TX_PWR                       0x3F
37 #define RF6052_MAX_REG_88E                      0xFF
38 #define RF6052_MAX_REG_92C                      0x7F
39
40 #define RF6052_MAX_REG  \
41                 (RF6052_MAX_REG_88E > RF6052_MAX_REG_92C) ? RF6052_MAX_REG_88E: RF6052_MAX_REG_92C
42
43 #define GET_RF6052_REAL_MAX_REG(_Adapter)       \
44                 IS_HARDWARE_TYPE_8188E(_Adapter) ? RF6052_MAX_REG_88E : RF6052_MAX_REG_92C
45
46 #define RF6052_MAX_PATH                         2
47
48 //
49 // Antenna detection method, i.e., using single tone detection or RSSI reported from each antenna detected. 
50 // Added by Roger, 2013.05.22.
51 //
52 #define ANT_DETECT_BY_SINGLE_TONE       BIT0
53 #define ANT_DETECT_BY_RSSI                              BIT1
54 #define IS_ANT_DETECT_SUPPORT_SINGLE_TONE(__Adapter)            ((GET_HAL_DATA(__Adapter)->AntDetection) & ANT_DETECT_BY_SINGLE_TONE)
55 #define IS_ANT_DETECT_SUPPORT_RSSI(__Adapter)           ((GET_HAL_DATA(__Adapter)->AntDetection) & ANT_DETECT_BY_RSSI)
56
57
58 /*--------------------------Define Parameters-------------------------------*/
59 typedef enum _BAND_TYPE{
60         BAND_ON_2_4G = 0,
61         BAND_ON_5G,
62         BAND_ON_BOTH,
63         BANDMAX
64 }BAND_TYPE,*PBAND_TYPE;
65
66 typedef enum _RF_TYPE{
67         RF_TYPE_MIN = 0,        // 0
68         RF_8225=1,                      // 1 11b/g RF for verification only
69         RF_8256=2,                      // 2 11b/g/n 
70         RF_8258=3,                      // 3 11a/b/g/n RF
71         RF_6052=4,                      // 4 11b/g/n RF
72         RF_PSEUDO_11N=5,        // 5, It is a temporality RF. 
73         RF_TYPE_MAX
74 }RF_TYPE_E,*PRF_TYPE_E;
75
76 typedef enum _RF_PATH{
77         RF_PATH_A = 0,
78         RF_PATH_B,
79         RF_PATH_C,
80         RF_PATH_D
81 }RF_PATH, *PRF_PATH;
82
83 #define TX_1S                   0                       
84 #define TX_2S                   1                       
85 #define TX_3S                   2                       
86 #define TX_4S                   3
87
88 #define RF_PATH_MAX_92C_88E             2
89 #define RF_PATH_MAX_90_8812             4       //Max RF number 90 support 
90
91 typedef enum _ANTENNA_PATH{
92        ANTENNA_NONE     = 0,
93         ANTENNA_D               = 1,
94         ANTENNA_C               = 2,
95         ANTENNA_CD      = 3,
96         ANTENNA_B               = 4,
97         ANTENNA_BD      = 5,
98         ANTENNA_BC      = 6,
99         ANTENNA_BCD     = 7,
100         ANTENNA_A               = 8,
101         ANTENNA_AD      = 9,
102         ANTENNA_AC      = 10,
103         ANTENNA_ACD     = 11,
104         ANTENNA_AB      = 12,
105         ANTENNA_ABD     = 13,
106         ANTENNA_ABC     = 14,
107         ANTENNA_ABCD    = 15
108 } ANTENNA_PATH;
109
110 typedef enum _RF_CONTENT{
111         radioa_txt = 0x1000,
112         radiob_txt = 0x1001,
113         radioc_txt = 0x1002,
114         radiod_txt = 0x1003
115 } RF_CONTENT;
116
117 typedef enum _BaseBand_Config_Type{
118         BaseBand_Config_PHY_REG = 0,                    //Radio Path A
119         BaseBand_Config_AGC_TAB = 1,                    //Radio Path B
120         BaseBand_Config_AGC_TAB_2G = 2,
121         BaseBand_Config_AGC_TAB_5G = 3, 
122         BaseBand_Config_PHY_REG_PG
123 }BaseBand_Config_Type, *PBaseBand_Config_Type;
124
125 typedef enum _HW_BLOCK{
126         HW_BLOCK_MAC = 0,
127         HW_BLOCK_PHY0 = 1,
128         HW_BLOCK_PHY1 = 2,
129         HW_BLOCK_RF = 3,
130         HW_BLOCK_MAXIMUM = 4, // Never use this
131 }HW_BLOCK_E, *PHW_BLOCK_E;
132
133 typedef enum _WIRELESS_MODE {
134         WIRELESS_MODE_UNKNOWN = 0x00,
135         WIRELESS_MODE_A = 0x01,
136         WIRELESS_MODE_B = 0x02,
137         WIRELESS_MODE_G = 0x04,
138         WIRELESS_MODE_AUTO = 0x08,
139         WIRELESS_MODE_N_24G = 0x10,
140         WIRELESS_MODE_N_5G = 0x20,
141         WIRELESS_MODE_AC_5G = 0x40,
142         WIRELESS_MODE_AC_24G  = 0x80,
143         WIRELESS_MODE_AC_ONLY  = 0x100,
144 } WIRELESS_MODE;
145
146 typedef enum _SwChnlCmdID{
147         CmdID_End,
148         CmdID_SetTxPowerLevel,
149         CmdID_BBRegWrite10,
150         CmdID_WritePortUlong,
151         CmdID_WritePortUshort,
152         CmdID_WritePortUchar,
153         CmdID_RF_WriteReg,
154 }SwChnlCmdID;
155
156 typedef struct _SwChnlCmd{
157         SwChnlCmdID     CmdID;
158         u32                             Para1;
159         u32                             Para2;
160         u32                             msDelay;
161 }SwChnlCmd;
162
163 typedef struct _R_ANTENNA_SELECT_OFDM{  
164         u32                     r_tx_antenna:4; 
165         u32                     r_ant_l:4;
166         u32                     r_ant_non_ht:4; 
167         u32                     r_ant_ht1:4;
168         u32                     r_ant_ht2:4;
169         u32                     r_ant_ht_s1:4;
170         u32                     r_ant_non_ht_s1:4;
171         u32                     OFDM_TXSC:2;
172         u32                     Reserved:2;
173 }R_ANTENNA_SELECT_OFDM;
174
175 typedef struct _R_ANTENNA_SELECT_CCK{
176         u8                      r_cckrx_enable_2:2;     
177         u8                      r_cckrx_enable:2;
178         u8                      r_ccktx_enable:4;
179 }R_ANTENNA_SELECT_CCK;
180
181 typedef struct RF_Shadow_Compare_Map {
182         // Shadow register value
183         u32             Value;
184         // Compare or not flag
185         u8              Compare;
186         // Record If it had ever modified unpredicted
187         u8              ErrorOrNot;
188         // Recorver Flag
189         u8              Recorver;
190         //
191         u8              Driver_Write;
192 }RF_SHADOW_T;
193
194 /*--------------------------Exported Function prototype---------------------*/
195
196 u32
197 PHY_CalculateBitShift(
198         u32 BitMask
199         );
200
201 u32
202 PHY_RFShadowRead(
203         IN      PADAPTER                Adapter,
204         IN      u8                              eRFPath,
205         IN      u32                             Offset);
206
207 VOID
208 PHY_RFShadowWrite(
209         IN      PADAPTER                Adapter,
210         IN      u8                              eRFPath,
211         IN      u32                             Offset,
212         IN      u32                             Data);
213
214 BOOLEAN
215 PHY_RFShadowCompare(
216         IN      PADAPTER                Adapter,
217         IN      u8                              eRFPath,
218         IN      u32                             Offset);
219
220 VOID
221 PHY_RFShadowRecorver(
222         IN      PADAPTER                Adapter,
223         IN      u8                              eRFPath,
224         IN      u32                             Offset);
225
226 VOID
227 PHY_RFShadowCompareAll(
228         IN      PADAPTER                Adapter);
229
230 VOID
231 PHY_RFShadowRecorverAll(
232         IN      PADAPTER                Adapter);
233
234 VOID
235 PHY_RFShadowCompareFlagSet(
236         IN      PADAPTER                Adapter,
237         IN      u8                              eRFPath,
238         IN      u32                             Offset,
239         IN      u8                              Type);
240
241 VOID
242 PHY_RFShadowRecorverFlagSet(
243         IN      PADAPTER                Adapter,
244         IN      u8                              eRFPath,
245         IN      u32                             Offset,
246         IN      u8                              Type);
247
248 VOID
249 PHY_RFShadowCompareFlagSetAll(
250         IN      PADAPTER                Adapter);
251
252 VOID
253 PHY_RFShadowRecorverFlagSetAll(
254         IN      PADAPTER                Adapter);
255
256 VOID
257 PHY_RFShadowRefresh(
258         IN      PADAPTER                Adapter);
259
260 #endif //__HAL_COMMON_H__
261