net: wireless: rockchip_wlan: add rtl8723cs support
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rtl8723cs / 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 _RF_TYPE {
60         RF_TYPE_MIN = 0,        /* 0 */
61         RF_8225 = 1,                    /* 1 11b/g RF for verification only */
62         RF_8256 = 2,                    /* 2 11b/g/n */
63         RF_8258 = 3,                    /* 3 11a/b/g/n RF */
64         RF_6052 = 4,                    /* 4 11b/g/n RF */
65         RF_PSEUDO_11N = 5,      /* 5, It is a temporality RF. */
66         RF_TYPE_MAX
67 } RF_TYPE_E, *PRF_TYPE_E;
68
69 #define TX_1S                   0
70 #define TX_2S                   1
71 #define TX_3S                   2
72 #define TX_4S                   3
73
74 typedef enum _ANTENNA_PATH {
75         ANTENNA_NONE    = 0,
76         ANTENNA_D               = 1,
77         ANTENNA_C               = 2,
78         ANTENNA_CD      = 3,
79         ANTENNA_B               = 4,
80         ANTENNA_BD      = 5,
81         ANTENNA_BC      = 6,
82         ANTENNA_BCD     = 7,
83         ANTENNA_A               = 8,
84         ANTENNA_AD      = 9,
85         ANTENNA_AC      = 10,
86         ANTENNA_ACD     = 11,
87         ANTENNA_AB      = 12,
88         ANTENNA_ABD     = 13,
89         ANTENNA_ABC     = 14,
90         ANTENNA_ABCD    = 15
91 } ANTENNA_PATH;
92
93 typedef enum _RF_CONTENT {
94         radioa_txt = 0x1000,
95         radiob_txt = 0x1001,
96         radioc_txt = 0x1002,
97         radiod_txt = 0x1003
98 } RF_CONTENT;
99
100 typedef enum _BaseBand_Config_Type {
101         BaseBand_Config_PHY_REG = 0,                    /* Radio Path A */
102         BaseBand_Config_AGC_TAB = 1,                    /* Radio Path B */
103         BaseBand_Config_AGC_TAB_2G = 2,
104         BaseBand_Config_AGC_TAB_5G = 3,
105         BaseBand_Config_PHY_REG_PG
106 } BaseBand_Config_Type, *PBaseBand_Config_Type;
107
108 typedef enum _HW_BLOCK {
109         HW_BLOCK_MAC = 0,
110         HW_BLOCK_PHY0 = 1,
111         HW_BLOCK_PHY1 = 2,
112         HW_BLOCK_RF = 3,
113         HW_BLOCK_MAXIMUM = 4, /* Never use this */
114 } HW_BLOCK_E, *PHW_BLOCK_E;
115
116 typedef enum _WIRELESS_MODE {
117         WIRELESS_MODE_UNKNOWN = 0x00,
118         WIRELESS_MODE_A = 0x01,
119         WIRELESS_MODE_B = 0x02,
120         WIRELESS_MODE_G = 0x04,
121         WIRELESS_MODE_AUTO = 0x08,
122         WIRELESS_MODE_N_24G = 0x10,
123         WIRELESS_MODE_N_5G = 0x20,
124         WIRELESS_MODE_AC_5G = 0x40,
125         WIRELESS_MODE_AC_24G  = 0x80,
126         WIRELESS_MODE_AC_ONLY  = 0x100,
127 } WIRELESS_MODE;
128
129 typedef enum _SwChnlCmdID {
130         CmdID_End,
131         CmdID_SetTxPowerLevel,
132         CmdID_BBRegWrite10,
133         CmdID_WritePortUlong,
134         CmdID_WritePortUshort,
135         CmdID_WritePortUchar,
136         CmdID_RF_WriteReg,
137 } SwChnlCmdID;
138
139 typedef struct _SwChnlCmd {
140         SwChnlCmdID     CmdID;
141         u32                             Para1;
142         u32                             Para2;
143         u32                             msDelay;
144 } SwChnlCmd;
145
146 typedef struct _R_ANTENNA_SELECT_OFDM {
147         u32                     r_tx_antenna:4;
148         u32                     r_ant_l:4;
149         u32                     r_ant_non_ht:4;
150         u32                     r_ant_ht1:4;
151         u32                     r_ant_ht2:4;
152         u32                     r_ant_ht_s1:4;
153         u32                     r_ant_non_ht_s1:4;
154         u32                     OFDM_TXSC:2;
155         u32                     Reserved:2;
156 } R_ANTENNA_SELECT_OFDM;
157
158 typedef struct _R_ANTENNA_SELECT_CCK {
159         u8                      r_cckrx_enable_2:2;
160         u8                      r_cckrx_enable:2;
161         u8                      r_ccktx_enable:4;
162 } R_ANTENNA_SELECT_CCK;
163
164 typedef struct RF_Shadow_Compare_Map {
165         /* Shadow register value */
166         u32             Value;
167         /* Compare or not flag */
168         u8              Compare;
169         /* Record If it had ever modified unpredicted */
170         u8              ErrorOrNot;
171         /* Recorver Flag */
172         u8              Recorver;
173         /*  */
174         u8              Driver_Write;
175 } RF_SHADOW_T;
176
177 /*--------------------------Exported Function prototype---------------------*/
178
179 u32
180 PHY_CalculateBitShift(
181         u32 BitMask
182 );
183
184 u32
185 PHY_RFShadowRead(
186         IN      PADAPTER                Adapter,
187         IN      u8                              eRFPath,
188         IN      u32                             Offset);
189
190 VOID
191 PHY_RFShadowWrite(
192         IN      PADAPTER                Adapter,
193         IN      u8                              eRFPath,
194         IN      u32                             Offset,
195         IN      u32                             Data);
196
197 BOOLEAN
198 PHY_RFShadowCompare(
199         IN      PADAPTER                Adapter,
200         IN      u8                              eRFPath,
201         IN      u32                             Offset);
202
203 VOID
204 PHY_RFShadowRecorver(
205         IN      PADAPTER                Adapter,
206         IN      u8                              eRFPath,
207         IN      u32                             Offset);
208
209 VOID
210 PHY_RFShadowCompareAll(
211         IN      PADAPTER                Adapter);
212
213 VOID
214 PHY_RFShadowRecorverAll(
215         IN      PADAPTER                Adapter);
216
217 VOID
218 PHY_RFShadowCompareFlagSet(
219         IN      PADAPTER                Adapter,
220         IN      u8                              eRFPath,
221         IN      u32                             Offset,
222         IN      u8                              Type);
223
224 VOID
225 PHY_RFShadowRecorverFlagSet(
226         IN      PADAPTER                Adapter,
227         IN      u8                              eRFPath,
228         IN      u32                             Offset,
229         IN      u8                              Type);
230
231 VOID
232 PHY_RFShadowCompareFlagSetAll(
233         IN      PADAPTER                Adapter);
234
235 VOID
236 PHY_RFShadowRecorverFlagSetAll(
237         IN      PADAPTER                Adapter);
238
239 VOID
240 PHY_RFShadowRefresh(
241         IN      PADAPTER                Adapter);
242
243 #endif /* __HAL_COMMON_H__ */