net: wireless: rockchip_wlan: add rtl8723cs support
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rtl8723cs / hal / phydm / phydm_pathdiv.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
21 #ifndef __PHYDMPATHDIV_H__
22 #define    __PHYDMPATHDIV_H__
23 /*#define PATHDIV_VERSION "2.0" //2014.11.04*/
24 #define PATHDIV_VERSION "3.1" /*2015.07.29 by YuChen*/
25
26 #if (defined(CONFIG_PATH_DIVERSITY))
27 #define USE_PATH_A_AS_DEFAULT_ANT   /* for 8814 dynamic TX path selection */
28
29 #define NUM_RESET_DTP_PERIOD 5
30 #define ANT_DECT_RSSI_TH 3
31
32 #define PATH_A 1
33 #define PATH_B 2
34 #define PATH_C 3
35 #define PATH_D 4
36
37 #define PHYDM_AUTO_PATH 0
38 #define PHYDM_FIX_PATH          1
39
40 #define NUM_CHOOSE2_FROM4 6
41 #define NUM_CHOOSE3_FROM4 4
42
43
44 #define         PHYDM_A          BIT(0)
45 #define         PHYDM_B          BIT(1)
46 #define         PHYDM_C          BIT(2)
47 #define         PHYDM_D          BIT(3)
48 #define         PHYDM_AB         (BIT(0) | BIT1)  /* 0 */
49 #define         PHYDM_AC         (BIT(0) | BIT2)  /* 1 */
50 #define         PHYDM_AD         (BIT(0) | BIT3)  /* 2 */
51 #define         PHYDM_BC         (BIT(1) | BIT2)  /* 3 */
52 #define         PHYDM_BD         (BIT(1) | BIT3)  /* 4 */
53 #define         PHYDM_CD         (BIT(2) | BIT3)  /* 5 */
54
55 #define         PHYDM_ABC        (BIT(0) | BIT1 | BIT2) /* 0*/
56 #define         PHYDM_ABD        (BIT(0) | BIT1 | BIT3) /* 1*/
57 #define         PHYDM_ACD        (BIT(0) | BIT2 | BIT3) /* 2*/
58 #define         PHYDM_BCD        (BIT(1) | BIT2 | BIT3) /* 3*/
59
60 #define         PHYDM_ABCD       (BIT(0) | BIT(1) | BIT(2) | BIT(3))
61
62
63 enum phydm_dtp_state {
64         PHYDM_DTP_INIT = 1,
65         PHYDM_DTP_RUNNING_1
66
67 };
68
69 enum phydm_path_div_type {
70         PHYDM_2R_PATH_DIV = 1,
71         PHYDM_4R_PATH_DIV = 2
72 };
73
74 void
75 phydm_process_rssi_for_path_div(
76         void                    *p_dm_void,
77         void                    *p_phy_info_void,
78         void                    *p_pkt_info_void
79 );
80
81 struct _ODM_PATH_DIVERSITY_ {
82         u8      resp_tx_path;
83         u8      path_sel[ODM_ASSOCIATE_ENTRY_NUM];
84         u32     path_a_sum[ODM_ASSOCIATE_ENTRY_NUM];
85         u32     path_b_sum[ODM_ASSOCIATE_ENTRY_NUM];
86         u16     path_a_cnt[ODM_ASSOCIATE_ENTRY_NUM];
87         u16     path_b_cnt[ODM_ASSOCIATE_ENTRY_NUM];
88         u8      phydm_path_div_type;
89 #if RTL8814A_SUPPORT
90
91         u32     path_a_sum_all;
92         u32     path_b_sum_all;
93         u32     path_c_sum_all;
94         u32     path_d_sum_all;
95
96         u32     path_a_cnt_all;
97         u32     path_b_cnt_all;
98         u32     path_c_cnt_all;
99         u32     path_d_cnt_all;
100
101         u8      dtp_period;
102         boolean is_become_linked;
103         boolean is_u3_mode;
104         u8      num_tx_path;
105         u8      default_path;
106         u8      num_candidate;
107         u8      ant_candidate_1;
108         u8      ant_candidate_2;
109         u8      ant_candidate_3;
110         u8     phydm_dtp_state;
111         u8      dtp_check_patha_counter;
112         boolean fix_path_bfer;
113         u8      search_space_2[NUM_CHOOSE2_FROM4];
114         u8      search_space_3[NUM_CHOOSE3_FROM4];
115
116         u8      pre_tx_path;
117         u8      use_path_a_as_default_ant;
118         boolean is_path_a_exist;
119
120 #endif
121 };
122
123
124 #endif /* #if(defined(CONFIG_PATH_DIVERSITY)) */
125
126 void
127 phydm_c2h_dtp_handler(
128         void    *p_dm_void,
129         u8   *cmd_buf,
130         u8      cmd_len
131 );
132
133 void
134 odm_path_diversity_init(
135         void    *p_dm_void
136 );
137
138 void
139 odm_path_diversity(
140         void    *p_dm_void
141 );
142
143 void
144 odm_pathdiv_debug(
145         void            *p_dm_void,
146         u32             *const dm_value,
147         u32             *_used,
148         char            *output,
149         u32             *_out_len
150 );
151
152
153
154 /* 1 [OLD IC]-------------------------------------------------------------------------------- */
155
156
157
158
159
160
161 #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN))
162
163 /* #define   PATHDIV_ENABLE      1 */
164 #define dm_path_div_rssi_check  odm_path_div_chk_per_pkt_rssi
165 #define path_div_check_before_link8192c odm_path_diversity_before_link92c
166
167
168
169
170 struct _path_div_parameter_define_ {
171         u32 org_5g_rege30;
172         u32 org_5g_regc14;
173         u32 org_5g_regca0;
174         u32 swt_5g_rege30;
175         u32 swt_5g_regc14;
176         u32 swt_5g_regca0;
177         /* for 2G IQK information */
178         u32 org_2g_regc80;
179         u32 org_2g_regc4c;
180         u32 org_2g_regc94;
181         u32 org_2g_regc14;
182         u32 org_2g_regca0;
183
184         u32 swt_2g_regc80;
185         u32 swt_2g_regc4c;
186         u32 swt_2g_regc94;
187         u32 swt_2g_regc14;
188         u32 swt_2g_regca0;
189 };
190
191 void
192 odm_path_diversity_init_92c(
193         struct _ADAPTER *adapter
194 );
195
196 void
197 odm_2t_path_diversity_init_92c(
198         struct _ADAPTER *adapter
199 );
200
201 void
202 odm_1t_path_diversity_init_92c(
203         struct _ADAPTER *adapter
204 );
205
206 boolean
207 odm_is_connected_92c(
208         struct _ADAPTER *adapter
209 );
210
211 boolean
212 odm_path_diversity_before_link92c(
213         /* struct _ADAPTER*     adapter */
214         struct PHY_DM_STRUCT            *p_dm_odm
215 );
216
217 void
218 odm_path_diversity_after_link_92c(
219         struct _ADAPTER *adapter
220 );
221
222 void
223 odm_set_resp_path_92c(
224         struct _ADAPTER *adapter,
225         u8      default_resp_path
226 );
227
228 void
229 odm_ofdm_tx_path_diversity_92c(
230         struct _ADAPTER *adapter
231 );
232
233 void
234 odm_cck_tx_path_diversity_92c(
235         struct _ADAPTER *adapter
236 );
237
238 void
239 odm_reset_path_diversity_92c(
240         struct _ADAPTER *adapter
241 );
242
243 void
244 odm_cck_tx_path_diversity_callback(
245         struct timer_list               *p_timer
246 );
247
248 void
249 odm_cck_tx_path_diversity_work_item_callback(
250         void            *p_context
251 );
252
253 void
254 odm_path_div_chk_ant_switch_callback(
255         struct timer_list               *p_timer
256 );
257
258 void
259 odm_path_div_chk_ant_switch_workitem_callback(
260         void            *p_context
261 );
262
263
264 void
265 odm_path_div_chk_ant_switch(
266         struct PHY_DM_STRUCT    *p_dm_odm
267 );
268
269 void
270 odm_cck_path_diversity_chk_per_pkt_rssi(
271         struct _ADAPTER         *adapter,
272         boolean                 is_def_port,
273         boolean                 is_match_bssid,
274         struct _WLAN_STA        *p_entry,
275         PRT_RFD                 p_rfd,
276         u8                      *p_desc
277 );
278
279 void
280 odm_path_div_chk_per_pkt_rssi(
281         struct _ADAPTER         *adapter,
282         boolean                 is_def_port,
283         boolean                 is_match_bssid,
284         struct _WLAN_STA        *p_entry,
285         PRT_RFD                 p_rfd
286 );
287
288 void
289 odm_path_div_rest_after_link(
290         struct PHY_DM_STRUCT            *p_dm_odm
291 );
292
293 void
294 odm_fill_tx_path_in_txdesc(
295         struct _ADAPTER *adapter,
296         PRT_TCB         p_tcb,
297         u8              *p_desc
298 );
299
300 void
301 odm_path_div_init_92d(
302         struct PHY_DM_STRUCT    *p_dm_odm
303 );
304
305 u8
306 odm_sw_ant_div_select_scan_chnl(
307         struct _ADAPTER *adapter
308 );
309
310 void
311 odm_sw_ant_div_construct_scan_chnl(
312         struct _ADAPTER *adapter,
313         u8              scan_chnl
314 );
315
316 #endif       /* #if(DM_ODM_SUPPORT_TYPE & (ODM_WIN)) */
317
318
319 #endif           /* #ifndef  __ODMPATHDIV_H__ */