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