Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
nu11secur1ty
GitHub Repository: nu11secur1ty/Kali-Linux
Path: blob/master/ALFA-W1F1/RTL8814AU/hal/phydm/halrf/halrf.c
1308 views
1
/******************************************************************************
2
*
3
* Copyright(c) 2007 - 2017 Realtek Corporation.
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
* The full GNU General Public License is included in this distribution in the
15
* file called LICENSE.
16
*
17
* Contact Information:
18
* wlanfae <[email protected]>
19
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
20
* Hsinchu 300, Taiwan.
21
*
22
* Larry Finger <[email protected]>
23
*
24
*****************************************************************************/
25
26
/*@************************************************************
27
* include files
28
* ************************************************************
29
*/
30
31
#include "mp_precomp.h"
32
#include "phydm_precomp.h"
33
34
#if (RTL8822B_SUPPORT == 1 || RTL8821C_SUPPORT == 1 ||\
35
RTL8195B_SUPPORT == 1 || RTL8198F_SUPPORT == 1 ||\
36
RTL8814B_SUPPORT == 1 || RTL8822C_SUPPORT == 1 ||\
37
RTL8812F_SUPPORT == 1 || RTL8710C_SUPPORT == 1 ||\
38
RTL8197G_SUPPORT == 1)
39
40
void _iqk_check_if_reload(void *dm_void)
41
{
42
struct dm_struct *dm = (struct dm_struct *)dm_void;
43
struct dm_iqk_info *iqk_info = &dm->IQK_info;
44
45
iqk_info->is_reload = (boolean)odm_get_bb_reg(dm, R_0x1bf0, BIT(16));
46
}
47
48
void _iqk_page_switch(void *dm_void)
49
{
50
struct dm_struct *dm = (struct dm_struct *)dm_void;
51
52
if (dm->support_ic_type == ODM_RTL8821C)
53
odm_write_4byte(dm, 0x1b00, 0xf8000008);
54
else
55
odm_write_4byte(dm, 0x1b00, 0xf800000a);
56
}
57
58
u32 halrf_psd_log2base(u32 val)
59
{
60
u8 j;
61
u32 tmp, tmp2, val_integerd_b = 0, tindex, shiftcount = 0;
62
u32 result, val_fractiond_b = 0;
63
u32 table_fraction[21] = {
64
0, 432, 332, 274, 232, 200, 174, 151, 132, 115,
65
100, 86, 74, 62, 51, 42, 32, 23, 15, 7, 0};
66
67
if (val == 0)
68
return 0;
69
70
tmp = val;
71
72
while (1) {
73
if (tmp == 1)
74
break;
75
76
tmp = (tmp >> 1);
77
shiftcount++;
78
}
79
80
val_integerd_b = shiftcount + 1;
81
82
tmp2 = 1;
83
for (j = 1; j <= val_integerd_b; j++)
84
tmp2 = tmp2 * 2;
85
86
tmp = (val * 100) / tmp2;
87
tindex = tmp / 5;
88
89
if (tindex > 20)
90
tindex = 20;
91
92
val_fractiond_b = table_fraction[tindex];
93
94
result = val_integerd_b * 100 - val_fractiond_b;
95
96
return result;
97
}
98
99
void halrf_iqk_xym_enable(struct dm_struct *dm, u8 xym_enable)
100
{
101
struct dm_iqk_info *iqk_info = &dm->IQK_info;
102
103
if (xym_enable == 0)
104
iqk_info->xym_read = false;
105
else
106
iqk_info->xym_read = true;
107
108
RF_DBG(dm, DBG_RF_IQK, "[IQK]%-20s %s\n", "xym_read = ",
109
(iqk_info->xym_read ? "true" : "false"));
110
}
111
112
/*xym_type => 0: rx_sym; 1: tx_xym; 2:gs1_xym; 3:gs2_sym; 4: rxk1_xym*/
113
void halrf_iqk_xym_read(void *dm_void, u8 path, u8 xym_type)
114
{
115
struct dm_struct *dm = (struct dm_struct *)dm_void;
116
struct dm_iqk_info *iqk_info = &dm->IQK_info;
117
u8 i, start, num;
118
u32 tmp1, tmp2;
119
120
if (!iqk_info->xym_read)
121
return;
122
123
if (*dm->band_width == 0) {
124
start = 3;
125
num = 4;
126
} else if (*dm->band_width == 1) {
127
start = 2;
128
num = 6;
129
} else {
130
start = 0;
131
num = 10;
132
}
133
134
odm_write_4byte(dm, 0x1b00, 0xf8000008);
135
tmp1 = odm_read_4byte(dm, 0x1b1c);
136
odm_write_4byte(dm, 0x1b1c, 0xa2193c32);
137
138
odm_write_4byte(dm, 0x1b00, 0xf800000a);
139
tmp2 = odm_read_4byte(dm, 0x1b1c);
140
odm_write_4byte(dm, 0x1b1c, 0xa2193c32);
141
142
for (path = 0; path < 2; path++) {
143
odm_write_4byte(dm, 0x1b00, 0xf8000008 | path << 1);
144
switch (xym_type) {
145
case 0:
146
for (i = 0; i < num; i++) {
147
odm_write_4byte(dm, 0x1b14, 0xe6 + start + i);
148
odm_write_4byte(dm, 0x1b14, 0x0);
149
iqk_info->rx_xym[path][i] =
150
odm_read_4byte(dm, 0x1b38);
151
}
152
break;
153
case 1:
154
for (i = 0; i < num; i++) {
155
odm_write_4byte(dm, 0x1b14, 0xe6 + start + i);
156
odm_write_4byte(dm, 0x1b14, 0x0);
157
iqk_info->tx_xym[path][i] =
158
odm_read_4byte(dm, 0x1b38);
159
}
160
break;
161
case 2:
162
for (i = 0; i < 6; i++) {
163
odm_write_4byte(dm, 0x1b14, 0xe0 + i);
164
odm_write_4byte(dm, 0x1b14, 0x0);
165
iqk_info->gs1_xym[path][i] =
166
odm_read_4byte(dm, 0x1b38);
167
}
168
break;
169
case 3:
170
for (i = 0; i < 6; i++) {
171
odm_write_4byte(dm, 0x1b14, 0xe0 + i);
172
odm_write_4byte(dm, 0x1b14, 0x0);
173
iqk_info->gs2_xym[path][i] =
174
odm_read_4byte(dm, 0x1b38);
175
}
176
break;
177
case 4:
178
for (i = 0; i < 6; i++) {
179
odm_write_4byte(dm, 0x1b14, 0xe0 + i);
180
odm_write_4byte(dm, 0x1b14, 0x0);
181
iqk_info->rxk1_xym[path][i] =
182
odm_read_4byte(dm, 0x1b38);
183
}
184
break;
185
}
186
odm_write_4byte(dm, 0x1b38, 0x20000000);
187
odm_write_4byte(dm, 0x1b00, 0xf8000008);
188
odm_write_4byte(dm, 0x1b1c, tmp1);
189
odm_write_4byte(dm, 0x1b00, 0xf800000a);
190
odm_write_4byte(dm, 0x1b1c, tmp2);
191
_iqk_page_switch(dm);
192
}
193
}
194
195
/*xym_type => 0: rx_sym; 1: tx_xym; 2:gs1_xym; 3:gs2_sym; 4: rxk1_xym*/
196
void halrf_iqk_xym_show(struct dm_struct *dm, u8 xym_type)
197
{
198
u8 num, path, path_num, i;
199
struct dm_iqk_info *iqk_info = &dm->IQK_info;
200
201
if (dm->rf_type == RF_1T1R)
202
path_num = 0x1;
203
else if (dm->rf_type == RF_2T2R)
204
path_num = 0x2;
205
else
206
path_num = 0x4;
207
208
if (*dm->band_width == CHANNEL_WIDTH_20)
209
num = 4;
210
else if (*dm->band_width == CHANNEL_WIDTH_40)
211
num = 6;
212
else
213
num = 10;
214
215
for (path = 0; path < path_num; path++) {
216
switch (xym_type) {
217
case 0:
218
for (i = 0; i < num; i++)
219
RF_DBG(dm, DBG_RF_IQK,
220
"[IQK]%-20s %-2d: 0x%x\n",
221
(path == 0) ? "PATH A RX-XYM " :
222
"PATH B RX-XYM", i,
223
iqk_info->rx_xym[path][i]);
224
break;
225
case 1:
226
for (i = 0; i < num; i++)
227
RF_DBG(dm, DBG_RF_IQK,
228
"[IQK]%-20s %-2d: 0x%x\n",
229
(path == 0) ? "PATH A TX-XYM " :
230
"PATH B TX-XYM", i,
231
iqk_info->tx_xym[path][i]);
232
break;
233
case 2:
234
for (i = 0; i < 6; i++)
235
RF_DBG(dm, DBG_RF_IQK,
236
"[IQK]%-20s %-2d: 0x%x\n",
237
(path == 0) ? "PATH A GS1-XYM " :
238
"PATH B GS1-XYM", i,
239
iqk_info->gs1_xym[path][i]);
240
break;
241
case 3:
242
for (i = 0; i < 6; i++)
243
RF_DBG(dm, DBG_RF_IQK,
244
"[IQK]%-20s %-2d: 0x%x\n",
245
(path == 0) ? "PATH A GS2-XYM " :
246
"PATH B GS2-XYM", i,
247
iqk_info->gs2_xym[path][i]);
248
break;
249
case 4:
250
for (i = 0; i < 6; i++)
251
RF_DBG(dm, DBG_RF_IQK,
252
"[IQK]%-20s %-2d: 0x%x\n",
253
(path == 0) ? "PATH A RXK1-XYM " :
254
"PATH B RXK1-XYM", i,
255
iqk_info->rxk1_xym[path][i]);
256
break;
257
}
258
}
259
}
260
261
void halrf_iqk_xym_dump(void *dm_void)
262
{
263
u32 tmp1, tmp2;
264
struct dm_struct *dm = (struct dm_struct *)dm_void;
265
266
odm_write_4byte(dm, 0x1b00, 0xf8000008);
267
tmp1 = odm_read_4byte(dm, 0x1b1c);
268
odm_write_4byte(dm, 0x1b00, 0xf800000a);
269
tmp2 = odm_read_4byte(dm, 0x1b1c);
270
#if 0
271
/*halrf_iqk_xym_read(dm, xym_type);*/
272
#endif
273
odm_write_4byte(dm, 0x1b00, 0xf8000008);
274
odm_write_4byte(dm, 0x1b1c, tmp1);
275
odm_write_4byte(dm, 0x1b00, 0xf800000a);
276
odm_write_4byte(dm, 0x1b1c, tmp2);
277
_iqk_page_switch(dm);
278
}
279
280
void halrf_iqk_info_dump(void *dm_void, u32 *_used, char *output, u32 *_out_len)
281
{
282
struct dm_struct *dm = (struct dm_struct *)dm_void;
283
u32 used = *_used;
284
u32 out_len = *_out_len;
285
u8 rf_path, j, reload_iqk = 0;
286
u32 tmp;
287
/*two channel, PATH, TX/RX, 0:pass 1 :fail*/
288
boolean iqk_result[2][NUM][2];
289
struct dm_iqk_info *iqk_info = &dm->IQK_info;
290
291
if (!(dm->support_ic_type & (ODM_RTL8822B | ODM_RTL8821C)))
292
return;
293
294
/* IQK INFO */
295
PDM_SNPF(out_len, used, output + used, out_len - used, "%-20s\n",
296
"% IQK Info %");
297
PDM_SNPF(out_len, used, output + used, out_len - used, "%-20s\n",
298
(dm->fw_offload_ability & PHYDM_RF_IQK_OFFLOAD) ? "FW-IQK" :
299
"Driver-IQK");
300
301
reload_iqk = (u8)odm_get_bb_reg(dm, R_0x1bf0, BIT(16));
302
PDM_SNPF(out_len, used, output + used, out_len - used, "%-20s: %s\n",
303
"reload", (reload_iqk) ? "True" : "False");
304
305
PDM_SNPF(out_len, used, output + used, out_len - used, "%-20s: %s\n",
306
"rfk_forbidden", (iqk_info->rfk_forbidden) ? "True" : "False");
307
#if (RTL8814A_SUPPORT == 1 || RTL8822B_SUPPORT == 1 || \
308
RTL8821C_SUPPORT == 1 || RTL8195B_SUPPORT == 1 ||\
309
RTL8814B_SUPPORT == 1 || RTL8822C_SUPPORT == 1)
310
PDM_SNPF(out_len, used, output + used, out_len - used, "%-20s: %s\n",
311
"segment_iqk", (iqk_info->segment_iqk) ? "True" : "False");
312
#endif
313
314
PDM_SNPF(out_len, used, output + used, out_len - used, "%-20s:%d %d\n",
315
"iqk count / fail count", dm->n_iqk_cnt, dm->n_iqk_fail_cnt);
316
317
PDM_SNPF(out_len, used, output + used, out_len - used, "%-20s: %d\n",
318
"channel", *dm->channel);
319
320
if (*dm->band_width == CHANNEL_WIDTH_20)
321
PDM_SNPF(out_len, used, output + used, out_len - used,
322
"%-20s: %s\n", "bandwidth", "BW_20");
323
else if (*dm->band_width == CHANNEL_WIDTH_40)
324
PDM_SNPF(out_len, used, output + used, out_len - used,
325
"%-20s: %s\n", "bandwidth", "BW_40");
326
else if (*dm->band_width == CHANNEL_WIDTH_80)
327
PDM_SNPF(out_len, used, output + used, out_len - used,
328
"%-20s: %s\n", "bandwidth", "BW_80");
329
else if (*dm->band_width == CHANNEL_WIDTH_160)
330
PDM_SNPF(out_len, used, output + used, out_len - used,
331
"%-20s: %s\n", "bandwidth", "BW_160");
332
else if (*dm->band_width == CHANNEL_WIDTH_80_80)
333
PDM_SNPF(out_len, used, output + used, out_len - used,
334
"%-20s: %s\n", "bandwidth", "BW_80_80");
335
else
336
PDM_SNPF(out_len, used, output + used, out_len - used,
337
"%-20s: %s\n", "bandwidth", "BW_UNKNOWN");
338
339
PDM_SNPF(out_len, used, output + used, out_len - used,
340
"%-20s: %llu %s\n", "progressing_time",
341
dm->rf_calibrate_info.iqk_total_progressing_time, "(ms)");
342
343
tmp = odm_read_4byte(dm, 0x1bf0);
344
for (rf_path = RF_PATH_A; rf_path <= RF_PATH_B; rf_path++)
345
for (j = 0; j < 2; j++)
346
iqk_result[0][rf_path][j] = (boolean)
347
(tmp & (BIT(rf_path + (j * 4)) >> (rf_path + (j * 4))));
348
349
PDM_SNPF(out_len, used, output + used, out_len - used,
350
"%-20s: 0x%08x\n", "Reg0x1bf0", tmp);
351
PDM_SNPF(out_len, used, output + used, out_len - used, "%-20s: %s\n",
352
"PATH_A-Tx result",
353
(iqk_result[0][RF_PATH_A][0]) ? "Fail" : "Pass");
354
PDM_SNPF(out_len, used, output + used, out_len - used, "%-20s: %s\n",
355
"PATH_A-Rx result",
356
(iqk_result[0][RF_PATH_A][1]) ? "Fail" : "Pass");
357
#if (RTL8822B_SUPPORT == 1)
358
PDM_SNPF(out_len, used, output + used, out_len - used, "%-20s: %s\n",
359
"PATH_B-Tx result",
360
(iqk_result[0][RF_PATH_B][0]) ? "Fail" : "Pass");
361
PDM_SNPF(out_len, used, output + used, out_len - used, "%-20s: %s\n",
362
"PATH_B-Rx result",
363
(iqk_result[0][RF_PATH_B][1]) ? "Fail" : "Pass");
364
#endif
365
*_used = used;
366
*_out_len = out_len;
367
}
368
369
void halrf_get_fw_version(void *dm_void)
370
{
371
struct dm_struct *dm = (struct dm_struct *)dm_void;
372
struct _hal_rf_ *rf = &dm->rf_table;
373
374
rf->fw_ver = (dm->fw_version << 16) | dm->fw_sub_version;
375
}
376
377
void halrf_iqk_dbg(void *dm_void)
378
{
379
struct dm_struct *dm = (struct dm_struct *)dm_void;
380
u8 rf_path, j;
381
u32 tmp;
382
/*two channel, PATH, TX/RX, 0:pass 1 :fail*/
383
boolean iqk_result[2][NUM][2];
384
struct dm_iqk_info *iqk_info = &dm->IQK_info;
385
struct _hal_rf_ *rf = &dm->rf_table;
386
387
/* IQK INFO */
388
RF_DBG(dm, DBG_RF_IQK, "%-20s\n", "====== IQK Info ======");
389
390
RF_DBG(dm, DBG_RF_IQK, "%-20s\n",
391
(dm->fw_offload_ability & PHYDM_RF_IQK_OFFLOAD) ? "FW-IQK" :
392
"Driver-IQK");
393
394
if (dm->fw_offload_ability & PHYDM_RF_IQK_OFFLOAD) {
395
halrf_get_fw_version(dm);
396
RF_DBG(dm, DBG_RF_IQK, "%-20s: 0x%x\n", "FW_VER", rf->fw_ver);
397
} else {
398
RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "IQK_VER", HALRF_IQK_VER);
399
}
400
401
RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "reload",
402
(iqk_info->is_reload) ? "True" : "False");
403
404
RF_DBG(dm, DBG_RF_IQK, "%-20s: %d %d\n", "iqk count / fail count",
405
dm->n_iqk_cnt, dm->n_iqk_fail_cnt);
406
407
RF_DBG(dm, DBG_RF_IQK, "%-20s: %d\n", "channel", *dm->channel);
408
409
if (*dm->band_width == CHANNEL_WIDTH_20)
410
RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "bandwidth", "BW_20");
411
else if (*dm->band_width == CHANNEL_WIDTH_40)
412
RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "bandwidth", "BW_40");
413
else if (*dm->band_width == CHANNEL_WIDTH_80)
414
RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "bandwidth", "BW_80");
415
else if (*dm->band_width == CHANNEL_WIDTH_160)
416
RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "bandwidth", "BW_160");
417
else if (*dm->band_width == CHANNEL_WIDTH_80_80)
418
RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "bandwidth", "BW_80_80");
419
else
420
RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "bandwidth",
421
"BW_UNKNOWN");
422
#if 0
423
/*
424
* RF_DBG(dm, DBG_RF_IQK, "%-20s: %llu %s\n",
425
* "progressing_time",
426
* dm->rf_calibrate_info.iqk_total_progressing_time, "(ms)");
427
*/
428
#endif
429
RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "rfk_forbidden",
430
(iqk_info->rfk_forbidden) ? "True" : "False");
431
#if (RTL8814A_SUPPORT == 1 || RTL8822B_SUPPORT == 1 || \
432
RTL8821C_SUPPORT == 1 || RTL8195B_SUPPORT == 1 ||\
433
RTL8814B_SUPPORT == 1 || RTL8822C_SUPPORT == 1)
434
RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "segment_iqk",
435
(iqk_info->segment_iqk) ? "True" : "False");
436
#endif
437
438
RF_DBG(dm, DBG_RF_IQK, "%-20s: %llu %s\n", "progressing_time",
439
dm->rf_calibrate_info.iqk_progressing_time, "(ms)");
440
441
tmp = odm_read_4byte(dm, 0x1bf0);
442
for (rf_path = RF_PATH_A; rf_path <= RF_PATH_B; rf_path++)
443
for (j = 0; j < 2; j++)
444
iqk_result[0][rf_path][j] = (boolean)
445
(tmp & (BIT(rf_path + (j * 4)) >> (rf_path + (j * 4))));
446
447
RF_DBG(dm, DBG_RF_IQK, "%-20s: 0x%08x\n", "Reg0x1bf0", tmp);
448
RF_DBG(dm, DBG_RF_IQK, "%-20s: 0x%08x\n", "Reg0x1be8",
449
odm_read_4byte(dm, 0x1be8));
450
RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "PATH_A-Tx result",
451
(iqk_result[0][RF_PATH_A][0]) ? "Fail" : "Pass");
452
RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "PATH_A-Rx result",
453
(iqk_result[0][RF_PATH_A][1]) ? "Fail" : "Pass");
454
#if (RTL8822B_SUPPORT == 1)
455
RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "PATH_B-Tx result",
456
(iqk_result[0][RF_PATH_B][0]) ? "Fail" : "Pass");
457
RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "PATH_B-Rx result",
458
(iqk_result[0][RF_PATH_B][1]) ? "Fail" : "Pass");
459
#endif
460
}
461
462
void halrf_lck_dbg(struct dm_struct *dm)
463
{
464
RF_DBG(dm, DBG_RF_IQK, "%-20s\n", "====== LCK Info ======");
465
#if 0
466
/*RF_DBG(dm, DBG_RF_IQK, "%-20s\n",
467
* (dm->fw_offload_ability & PHYDM_RF_IQK_OFFLOAD) ? "LCK" : "RTK"));
468
*/
469
#endif
470
RF_DBG(dm, DBG_RF_IQK, "%-20s: %llu %s\n", "progressing_time",
471
dm->rf_calibrate_info.lck_progressing_time, "(ms)");
472
}
473
void phydm_get_iqk_cfir(void *dm_void, u8 idx, u8 path, boolean debug)
474
{
475
struct dm_struct *dm = (struct dm_struct *)dm_void;
476
477
switch (dm->support_ic_type) {
478
#if (RTL8822B_SUPPORT == 1)
479
case ODM_RTL8822B:
480
phy_get_iqk_cfir_8822b(dm, idx, path, debug);
481
break;
482
#endif
483
#if (RTL8822C_SUPPORT == 1)
484
case ODM_RTL8822C:
485
phy_get_iqk_cfir_8822c(dm, idx, path, debug);
486
break;
487
#endif
488
default:
489
break;
490
}
491
}
492
493
494
void halrf_iqk_dbg_cfir_backup(void *dm_void)
495
{
496
struct dm_struct *dm = (struct dm_struct *)dm_void;
497
struct dm_iqk_info *iqk_info = &dm->IQK_info;
498
u8 path, idx, i;
499
500
switch (dm->support_ic_type) {
501
#if (RTL8822B_SUPPORT == 1)
502
case ODM_RTL8822B:
503
phy_iqk_dbg_cfir_backup_8822b(dm);
504
break;
505
#endif
506
#if (RTL8822C_SUPPORT == 1)
507
case ODM_RTL8822C:
508
phy_iqk_dbg_cfir_backup_8822c(dm);
509
break;
510
#endif
511
default:
512
break;
513
}
514
515
}
516
517
void halrf_iqk_dbg_cfir_backup_update(void *dm_void)
518
{
519
struct dm_struct *dm = (struct dm_struct *)dm_void;
520
struct dm_iqk_info *iqk = &dm->IQK_info;
521
u8 i, path, idx;
522
u32 bmask13_12 = BIT(13) | BIT(12);
523
u32 bmask20_16 = BIT(20) | BIT(19) | BIT(18) | BIT(17) | BIT(16);
524
u32 data;
525
526
switch (dm->support_ic_type) {
527
#if (RTL8822B_SUPPORT == 1)
528
case ODM_RTL8822B:
529
phy_iqk_dbg_cfir_backup_update_8822b(dm);
530
break;
531
#endif
532
#if (RTL8822C_SUPPORT == 1)
533
case ODM_RTL8822C:
534
phy_iqk_dbg_cfir_backup_update_8822c(dm);
535
break;
536
#endif
537
default:
538
break;
539
}
540
}
541
542
void halrf_iqk_dbg_cfir_reload(void *dm_void)
543
{
544
struct dm_struct *dm = (struct dm_struct *)dm_void;
545
struct dm_iqk_info *iqk = &dm->IQK_info;
546
u8 i, path, idx;
547
u32 bmask13_12 = BIT(13) | BIT(12);
548
u32 bmask20_16 = BIT(20) | BIT(19) | BIT(18) | BIT(17) | BIT(16);
549
u32 data;
550
551
switch (dm->support_ic_type) {
552
#if (RTL8822B_SUPPORT == 1)
553
case ODM_RTL8822B:
554
phy_iqk_dbg_cfir_reload_8822b(dm);
555
break;
556
#endif
557
#if (RTL8822C_SUPPORT == 1)
558
case ODM_RTL8822C:
559
phy_iqk_dbg_cfir_reload_8822c(dm);
560
break;
561
#endif
562
default:
563
break;
564
}
565
}
566
567
void halrf_iqk_dbg_cfir_write(void *dm_void, u8 type, u32 path, u32 idx,
568
u32 i, u32 data)
569
{
570
struct dm_struct *dm = (struct dm_struct *)dm_void;
571
struct dm_iqk_info *iqk_info = &dm->IQK_info;
572
573
switch (dm->support_ic_type) {
574
#if (RTL8822B_SUPPORT == 1)
575
case ODM_RTL8822B:
576
phy_iqk_dbg_cfir_write_8822b(dm, type, path, idx, i, data);
577
break;
578
#endif
579
#if (RTL8822C_SUPPORT == 1)
580
case ODM_RTL8822C:
581
phy_iqk_dbg_cfir_write_8822c(dm, type, path, idx, i, data);
582
break;
583
#endif
584
default:
585
break;
586
}
587
}
588
589
void halrf_iqk_dbg_cfir_backup_show(void *dm_void)
590
{
591
struct dm_struct *dm = (struct dm_struct *)dm_void;
592
struct dm_iqk_info *iqk_info = &dm->IQK_info;
593
u8 path, idx, i;
594
595
switch (dm->support_ic_type) {
596
#if (RTL8822B_SUPPORT == 1)
597
case ODM_RTL8822B:
598
phy_iqk_dbg_cfir_backup_8822b(dm);
599
break;
600
#endif
601
#if (RTL8822C_SUPPORT == 1)
602
case ODM_RTL8822C:
603
phy_iqk_dbg_cfir_backup_8822c(dm);
604
break;
605
#endif
606
default:
607
break;
608
}
609
}
610
611
void halrf_do_imr_test(void *dm_void, u8 flag_imr_test)
612
{
613
struct dm_struct *dm = (struct dm_struct *)dm_void;
614
615
if (flag_imr_test != 0x0)
616
switch (dm->support_ic_type) {
617
#if (RTL8822B_SUPPORT == 1)
618
case ODM_RTL8822B:
619
do_imr_test_8822b(dm);
620
break;
621
#endif
622
#if (RTL8821C_SUPPORT == 1)
623
case ODM_RTL8821C:
624
do_imr_test_8821c(dm);
625
break;
626
#endif
627
default:
628
break;
629
}
630
}
631
632
void halrf_iqk_debug(void *dm_void, u32 *const dm_value, u32 *_used,
633
char *output, u32 *_out_len)
634
{
635
struct dm_struct *dm = (struct dm_struct *)dm_void;
636
637
#if 0
638
/*dm_value[0]=0x0: backup from SRAM & show*/
639
/*dm_value[0]=0x1: write backup CFIR to SRAM*/
640
/*dm_value[0]=0x2: reload default CFIR to SRAM*/
641
/*dm_value[0]=0x3: show backup*/
642
/*dm_value[0]=0x10: write backup CFIR real part*/
643
/*--> dm_value[1]:path, dm_value[2]:tx/rx, dm_value[3]:index, dm_value[4]:data*/
644
/*dm_value[0]=0x11: write backup CFIR imag*/
645
/*--> dm_value[1]:path, dm_value[2]:tx/rx, dm_value[3]:index, dm_value[4]:data*/
646
/*dm_value[0]=0x20 :xym_read enable*/
647
/*--> dm_value[1]:0:disable, 1:enable*/
648
/*if dm_value[0]=0x20 = enable, */
649
/*0x1:show rx_sym; 0x2: tx_xym; 0x3:gs1_xym; 0x4:gs2_sym; 0x5:rxk1_xym*/
650
#endif
651
if (dm_value[0] == 0x0)
652
halrf_iqk_dbg_cfir_backup(dm);
653
else if (dm_value[0] == 0x1)
654
halrf_iqk_dbg_cfir_backup_update(dm);
655
else if (dm_value[0] == 0x2)
656
halrf_iqk_dbg_cfir_reload(dm);
657
else if (dm_value[0] == 0x3)
658
halrf_iqk_dbg_cfir_backup_show(dm);
659
else if (dm_value[0] == 0x10)
660
halrf_iqk_dbg_cfir_write(dm, 0, dm_value[1], dm_value[2],
661
dm_value[3], dm_value[4]);
662
else if (dm_value[0] == 0x11)
663
halrf_iqk_dbg_cfir_write(dm, 1, dm_value[1], dm_value[2],
664
dm_value[3], dm_value[4]);
665
else if (dm_value[0] == 0x20)
666
halrf_iqk_xym_enable(dm, (u8)dm_value[1]);
667
else if (dm_value[0] == 0x21)
668
halrf_iqk_xym_show(dm, (u8)dm_value[1]);
669
else if (dm_value[0] == 0x30)
670
halrf_do_imr_test(dm, (u8)dm_value[1]);
671
}
672
673
void halrf_iqk_hwtx_check(void *dm_void, boolean is_check)
674
{
675
#if 0
676
struct dm_struct *dm = (struct dm_struct *)dm_void;
677
struct dm_iqk_info *iqk_info = &dm->IQK_info;
678
u32 tmp_b04;
679
680
if (is_check) {
681
iqk_info->is_hwtx = (boolean)odm_get_bb_reg(dm, R_0xb00, BIT(8));
682
} else {
683
if (iqk_info->is_hwtx) {
684
tmp_b04 = odm_read_4byte(dm, 0xb04);
685
odm_set_bb_reg(dm, R_0xb04, BIT(3) | BIT(2), 0x0);
686
odm_write_4byte(dm, 0xb04, tmp_b04);
687
}
688
}
689
#endif
690
}
691
#endif
692
693
u8 halrf_match_iqk_version(void *dm_void)
694
{
695
struct dm_struct *dm = (struct dm_struct *)dm_void;
696
697
u32 iqk_version = 0;
698
char temp[10] = {0};
699
700
odm_move_memory(dm, temp, HALRF_IQK_VER, sizeof(temp));
701
PHYDM_SSCANF(temp + 2, DCMD_HEX, &iqk_version);
702
703
if (dm->support_ic_type == ODM_RTL8822B) {
704
if (iqk_version >= 0x24 && (odm_get_hw_img_version(dm) >= 72))
705
return 1;
706
else if ((iqk_version <= 0x23) &&
707
(odm_get_hw_img_version(dm) <= 71))
708
return 1;
709
else
710
return 0;
711
}
712
713
if (dm->support_ic_type == ODM_RTL8821C) {
714
if (iqk_version >= 0x18 && (odm_get_hw_img_version(dm) >= 37))
715
return 1;
716
else
717
return 0;
718
}
719
720
return 1;
721
}
722
723
void halrf_rf_lna_setting(void *dm_void, enum halrf_lna_set type)
724
{
725
struct dm_struct *dm = (struct dm_struct *)dm_void;
726
727
switch (dm->support_ic_type) {
728
#if (RTL8188E_SUPPORT == 1)
729
case ODM_RTL8188E:
730
halrf_rf_lna_setting_8188e(dm, type);
731
break;
732
#endif
733
#if (RTL8192E_SUPPORT == 1)
734
case ODM_RTL8192E:
735
halrf_rf_lna_setting_8192e(dm, type);
736
break;
737
#endif
738
#if (RTL8192F_SUPPORT == 1)
739
case ODM_RTL8192F:
740
halrf_rf_lna_setting_8192f(dm, type);
741
break;
742
#endif
743
744
#if (RTL8723B_SUPPORT == 1)
745
case ODM_RTL8723B:
746
halrf_rf_lna_setting_8723b(dm, type);
747
break;
748
#endif
749
#if (RTL8812A_SUPPORT == 1)
750
case ODM_RTL8812:
751
halrf_rf_lna_setting_8812a(dm, type);
752
break;
753
#endif
754
#if ((RTL8821A_SUPPORT == 1) || (RTL8881A_SUPPORT == 1))
755
case ODM_RTL8881A:
756
case ODM_RTL8821:
757
halrf_rf_lna_setting_8821a(dm, type);
758
break;
759
#endif
760
#if (RTL8822B_SUPPORT == 1)
761
case ODM_RTL8822B:
762
halrf_rf_lna_setting_8822b(dm_void, type);
763
break;
764
#endif
765
#if (RTL8822C_SUPPORT == 1)
766
case ODM_RTL8822C:
767
halrf_rf_lna_setting_8822c(dm_void, type);
768
break;
769
#endif
770
#if (RTL8812F_SUPPORT == 1)
771
case ODM_RTL8812F:
772
halrf_rf_lna_setting_8812f(dm_void, type);
773
break;
774
#endif
775
#if (RTL8821C_SUPPORT == 1)
776
case ODM_RTL8821C:
777
halrf_rf_lna_setting_8821c(dm_void, type);
778
break;
779
#endif
780
#if (RTL8814B_SUPPORT == 1)
781
case ODM_RTL8814B:
782
break;
783
#endif
784
default:
785
break;
786
}
787
}
788
789
void halrf_support_ability_debug(void *dm_void, char input[][16], u32 *_used,
790
char *output, u32 *_out_len)
791
{
792
struct dm_struct *dm = (struct dm_struct *)dm_void;
793
struct _hal_rf_ *rf = &dm->rf_table;
794
u32 dm_value[10] = {0};
795
u32 used = *_used;
796
u32 out_len = *_out_len;
797
u8 i;
798
799
for (i = 0; i < 5; i++)
800
if (input[i + 1])
801
PHYDM_SSCANF(input[i + 2], DCMD_DECIMAL, &dm_value[i]);
802
803
if (dm_value[0] == 100) {
804
PDM_SNPF(out_len, used, output + used, out_len - used,
805
"\n[RF Supportability]\n");
806
PDM_SNPF(out_len, used, output + used, out_len - used,
807
"00. (( %s ))Power Tracking\n",
808
((rf->rf_supportability & HAL_RF_TX_PWR_TRACK) ?
809
("V") : (".")));
810
PDM_SNPF(out_len, used, output + used, out_len - used,
811
"01. (( %s ))IQK\n",
812
((rf->rf_supportability & HAL_RF_IQK) ? ("V") :
813
(".")));
814
PDM_SNPF(out_len, used, output + used, out_len - used,
815
"02. (( %s ))LCK\n",
816
((rf->rf_supportability & HAL_RF_LCK) ? ("V") :
817
(".")));
818
PDM_SNPF(out_len, used, output + used, out_len - used,
819
"03. (( %s ))DPK\n",
820
((rf->rf_supportability & HAL_RF_DPK) ? ("V") :
821
(".")));
822
PDM_SNPF(out_len, used, output + used, out_len - used,
823
"04. (( %s ))HAL_RF_TXGAPK\n",
824
((rf->rf_supportability & HAL_RF_TXGAPK) ? ("V") :
825
(".")));
826
#ifdef CONFIG_2G_BAND_SHIFT
827
PDM_SNPF(out_len, used, output + used, out_len - used,
828
"07. (( %s ))HAL_2GBAND_SHIFT\n",
829
((rf->rf_supportability & HAL_2GBAND_SHIFT) ? ("V") :
830
(".")));
831
#endif
832
833
} else {
834
if (dm_value[1] == 1) /* enable */
835
rf->rf_supportability |= BIT(dm_value[0]);
836
else if (dm_value[1] == 2) /* disable */
837
rf->rf_supportability &= ~(BIT(dm_value[0]));
838
else
839
PDM_SNPF(out_len, used, output + used, out_len - used,
840
"[Warning!!!] 1:enable, 2:disable\n");
841
}
842
PDM_SNPF(out_len, used, output + used, out_len - used,
843
"\nCurr-RF_supportability = 0x%x\n\n", rf->rf_supportability);
844
845
*_used = used;
846
*_out_len = out_len;
847
}
848
849
#ifdef CONFIG_2G_BAND_SHIFT
850
void halrf_support_band_shift_debug(void *dm_void, char input[][16], u32 *_used,
851
char *output, u32 *_out_len)
852
{
853
struct dm_struct *dm = (struct dm_struct *)dm_void;
854
struct _hal_rf_ *rf = &dm->rf_table;
855
//u32 band_value[2] = {00};
856
u32 dm_value[10] = {0};
857
u32 used = *_used;
858
u32 out_len = *_out_len;
859
u8 i;
860
861
#if (RTL8192F_SUPPORT == 1)
862
for (i = 0; i < 7; i++)
863
if (input[i + 1])
864
PHYDM_SSCANF(input[i + 2], DCMD_DECIMAL, &dm_value[i]);
865
866
if (!(rf->rf_supportability & HAL_2GBAND_SHIFT)) {
867
PDM_SNPF(out_len, used, output + used, out_len - used,
868
"\nCurr-RF_supportability[07. (( . ))HAL_2GBAND_SHIFT]\nNo RF Band Shift,default: 2.4G!\n");
869
} else {
870
if (dm_value[0] == 01) {
871
rf->rf_shift_band = HAL_RF_2P3;
872
halrf_lck_trigger(dm);
873
PDM_SNPF(out_len, used, output + used, out_len - used,
874
"\n[rf_shift_band] = %d\nRF Band Shift to 2.3G!\n",
875
rf->rf_shift_band);
876
} else if (dm_value[0] == 02) {
877
rf->rf_shift_band = HAL_RF_2P5;
878
halrf_lck_trigger(dm);
879
PDM_SNPF(out_len, used, output + used, out_len - used,
880
"\n[rf_shift_band] = %d\nRF Band Shift to 2.5G!\n",
881
rf->rf_shift_band);
882
} else {
883
rf->rf_shift_band = HAL_RF_2P4;
884
halrf_lck_trigger(dm);
885
PDM_SNPF(out_len, used, output + used, out_len - used,
886
"\n[rf_shift_band] = %d\nNo RF Band Shift,default: 2.4G!\n",
887
rf->rf_shift_band);
888
}
889
}
890
*_used = used;
891
*_out_len = out_len;
892
#endif
893
}
894
#endif
895
896
void halrf_cmn_info_init(void *dm_void, enum halrf_cmninfo_init cmn_info,
897
u32 value)
898
{
899
struct dm_struct *dm = (struct dm_struct *)dm_void;
900
struct _hal_rf_ *rf = &dm->rf_table;
901
902
switch (cmn_info) {
903
case HALRF_CMNINFO_EEPROM_THERMAL_VALUE:
904
rf->eeprom_thermal = (u8)value;
905
break;
906
case HALRF_CMNINFO_PWT_TYPE:
907
rf->pwt_type = (u8)value;
908
break;
909
default:
910
break;
911
}
912
}
913
914
void halrf_cmn_info_hook(void *dm_void, enum halrf_cmninfo_hook cmn_info,
915
void *value)
916
{
917
struct dm_struct *dm = (struct dm_struct *)dm_void;
918
struct _hal_rf_ *rf = &dm->rf_table;
919
920
switch (cmn_info) {
921
case HALRF_CMNINFO_CON_TX:
922
rf->is_con_tx = (boolean *)value;
923
break;
924
case HALRF_CMNINFO_SINGLE_TONE:
925
rf->is_single_tone = (boolean *)value;
926
break;
927
case HALRF_CMNINFO_CARRIER_SUPPRESSION:
928
rf->is_carrier_suppresion = (boolean *)value;
929
break;
930
case HALRF_CMNINFO_MP_RATE_INDEX:
931
rf->mp_rate_index = (u8 *)value;
932
break;
933
case HALRF_CMNINFO_MANUAL_RF_SUPPORTABILITY:
934
rf->manual_rf_supportability = (u32 *)value;
935
break;
936
default:
937
/*do nothing*/
938
break;
939
}
940
}
941
942
void halrf_cmn_info_set(void *dm_void, u32 cmn_info, u64 value)
943
{
944
/* This init variable may be changed in run time. */
945
struct dm_struct *dm = (struct dm_struct *)dm_void;
946
struct _hal_rf_ *rf = &dm->rf_table;
947
948
switch (cmn_info) {
949
case HALRF_CMNINFO_ABILITY:
950
rf->rf_supportability = (u32)value;
951
break;
952
953
case HALRF_CMNINFO_DPK_EN:
954
rf->dpk_en = (u8)value;
955
break;
956
case HALRF_CMNINFO_RFK_FORBIDDEN:
957
dm->IQK_info.rfk_forbidden = (boolean)value;
958
break;
959
#if (RTL8814A_SUPPORT == 1 || RTL8822B_SUPPORT == 1 || \
960
RTL8821C_SUPPORT == 1 || RTL8195B_SUPPORT == 1 ||\
961
RTL8814B_SUPPORT == 1 || RTL8822C_SUPPORT == 1)
962
case HALRF_CMNINFO_IQK_SEGMENT:
963
dm->IQK_info.segment_iqk = (boolean)value;
964
break;
965
#endif
966
case HALRF_CMNINFO_RATE_INDEX:
967
rf->p_rate_index = (u32)value;
968
break;
969
/*#if (DM_ODM_SUPPORT_TYPE & ODM_WIN)*/
970
case HALRF_CMNINFO_MP_PSD_POINT:
971
rf->halrf_psd_data.point = (u32)value;
972
break;
973
case HALRF_CMNINFO_MP_PSD_START_POINT:
974
rf->halrf_psd_data.start_point = (u32)value;
975
break;
976
case HALRF_CMNINFO_MP_PSD_STOP_POINT:
977
rf->halrf_psd_data.stop_point = (u32)value;
978
break;
979
case HALRF_CMNINFO_MP_PSD_AVERAGE:
980
rf->halrf_psd_data.average = (u32)value;
981
break;
982
/*#endif*/
983
default:
984
/* do nothing */
985
break;
986
}
987
}
988
989
u64 halrf_cmn_info_get(void *dm_void, u32 cmn_info)
990
{
991
/* This init variable may be changed in run time. */
992
struct dm_struct *dm = (struct dm_struct *)dm_void;
993
struct _hal_rf_ *rf = &dm->rf_table;
994
u64 return_value = 0;
995
996
switch (cmn_info) {
997
case HALRF_CMNINFO_ABILITY:
998
return_value = (u32)rf->rf_supportability;
999
break;
1000
case HALRF_CMNINFO_RFK_FORBIDDEN:
1001
return_value = dm->IQK_info.rfk_forbidden;
1002
break;
1003
#if (RTL8814A_SUPPORT == 1 || RTL8822B_SUPPORT == 1 || \
1004
RTL8821C_SUPPORT == 1 || RTL8195B_SUPPORT == 1 ||\
1005
RTL8814B_SUPPORT == 1 || RTL8822C_SUPPORT == 1)
1006
case HALRF_CMNINFO_IQK_SEGMENT:
1007
return_value = dm->IQK_info.segment_iqk;
1008
break;
1009
#endif
1010
default:
1011
/* do nothing */
1012
break;
1013
}
1014
1015
return return_value;
1016
}
1017
1018
void halrf_supportability_init_mp(void *dm_void)
1019
{
1020
struct dm_struct *dm = (struct dm_struct *)dm_void;
1021
struct _hal_rf_ *rf = &dm->rf_table;
1022
1023
switch (dm->support_ic_type) {
1024
case ODM_RTL8814B:
1025
#if (RTL8814B_SUPPORT == 1)
1026
rf->rf_supportability =
1027
/*HAL_RF_TX_PWR_TRACK |*/
1028
HAL_RF_IQK |
1029
HAL_RF_LCK |
1030
HAL_RF_DPK |
1031
HAL_RF_DACK |
1032
HAL_RF_DPK_TRACK |
1033
0;
1034
#endif
1035
break;
1036
#if (RTL8822B_SUPPORT == 1)
1037
case ODM_RTL8822B:
1038
rf->rf_supportability =
1039
/*HAL_RF_TX_PWR_TRACK |*/
1040
HAL_RF_IQK |
1041
HAL_RF_LCK |
1042
/*@HAL_RF_DPK |*/
1043
0;
1044
break;
1045
#endif
1046
#if (RTL8822C_SUPPORT == 1)
1047
case ODM_RTL8822C:
1048
rf->rf_supportability =
1049
/*HAL_RF_TX_PWR_TRACK |*/
1050
HAL_RF_IQK |
1051
HAL_RF_LCK |
1052
HAL_RF_DPK |
1053
HAL_RF_DACK |
1054
HAL_RF_DPK_TRACK |
1055
0;
1056
break;
1057
#endif
1058
#if (RTL8821C_SUPPORT == 1)
1059
case ODM_RTL8821C:
1060
rf->rf_supportability =
1061
/*HAL_RF_TX_PWR_TRACK |*/
1062
HAL_RF_IQK |
1063
HAL_RF_LCK |
1064
/*@HAL_RF_DPK |*/
1065
/*@HAL_RF_TXGAPK |*/
1066
0;
1067
break;
1068
#endif
1069
#if (RTL8195B_SUPPORT == 1)
1070
case ODM_RTL8195B:
1071
rf->rf_supportability =
1072
HAL_RF_TX_PWR_TRACK |
1073
HAL_RF_IQK |
1074
HAL_RF_LCK |
1075
HAL_RF_DPK |
1076
HAL_RF_TXGAPK |
1077
HAL_RF_DPK_TRACK |
1078
0;
1079
break;
1080
#endif
1081
#if (RTL8812F_SUPPORT == 1)
1082
case ODM_RTL8812F:
1083
rf->rf_supportability =
1084
/*HAL_RF_TX_PWR_TRACK |*/
1085
HAL_RF_IQK |
1086
HAL_RF_LCK |
1087
HAL_RF_DPK |
1088
HAL_RF_DACK |
1089
HAL_RF_DPK_TRACK |
1090
0;
1091
break;
1092
#endif
1093
1094
#if (RTL8198F_SUPPORT == 1)
1095
case ODM_RTL8198F:
1096
rf->rf_supportability =
1097
/*HAL_RF_TX_PWR_TRACK |*/
1098
HAL_RF_IQK |
1099
HAL_RF_LCK |
1100
HAL_RF_DPK |
1101
/*@HAL_RF_TXGAPK |*/
1102
0;
1103
break;
1104
#endif
1105
1106
#if (RTL8192F_SUPPORT == 1)
1107
case ODM_RTL8192F:
1108
rf->rf_supportability =
1109
/*HAL_RF_TX_PWR_TRACK |*/
1110
HAL_RF_IQK |
1111
HAL_RF_LCK |
1112
HAL_RF_DPK |
1113
/*@HAL_RF_TXGAPK |*/
1114
#ifdef CONFIG_2G_BAND_SHIFT
1115
/*@HAL_2GBAND_SHIFT |*/
1116
#endif
1117
0;
1118
break;
1119
#endif
1120
1121
#if (RTL8197F_SUPPORT == 1)
1122
case ODM_RTL8197F:
1123
rf->rf_supportability =
1124
/*HAL_RF_TX_PWR_TRACK |*/
1125
HAL_RF_IQK |
1126
HAL_RF_LCK |
1127
HAL_RF_DPK |
1128
/*@HAL_RF_TXGAPK |*/
1129
0;
1130
break;
1131
#endif
1132
#if (RTL8197G_SUPPORT == 1)
1133
case ODM_RTL8197G:
1134
rf->rf_supportability =
1135
/*HAL_RF_TX_PWR_TRACK |*/
1136
HAL_RF_IQK |
1137
/*HAL_RF_LCK |*/
1138
HAL_RF_DPK |
1139
/*@HAL_RF_TXGAPK |*/
1140
/*HAL_RF_DPK_TRACK |*/
1141
0;
1142
break;
1143
#endif
1144
#if (RTL8721D_SUPPORT == 1)
1145
case ODM_RTL8721D:
1146
rf->rf_supportability =
1147
HAL_RF_TX_PWR_TRACK |
1148
HAL_RF_IQK |
1149
HAL_RF_LCK |
1150
HAL_RF_DPK |
1151
HAL_RF_DPK_TRACK |
1152
/*@HAL_RF_TXGAPK |*/
1153
0;
1154
break;
1155
#endif
1156
1157
default:
1158
rf->rf_supportability =
1159
/*HAL_RF_TX_PWR_TRACK |*/
1160
HAL_RF_IQK |
1161
HAL_RF_LCK |
1162
/*@HAL_RF_DPK |*/
1163
/*@HAL_RF_TXGAPK |*/
1164
0;
1165
break;
1166
}
1167
1168
RF_DBG(dm, DBG_RF_INIT,
1169
"IC = ((0x%x)), RF_Supportability Init MP = ((0x%x))\n",
1170
dm->support_ic_type, rf->rf_supportability);
1171
}
1172
1173
void halrf_supportability_init(void *dm_void)
1174
{
1175
struct dm_struct *dm = (struct dm_struct *)dm_void;
1176
struct _hal_rf_ *rf = &dm->rf_table;
1177
1178
switch (dm->support_ic_type) {
1179
case ODM_RTL8814B:
1180
#if (RTL8814B_SUPPORT == 1)
1181
rf->rf_supportability =
1182
HAL_RF_TX_PWR_TRACK |
1183
HAL_RF_IQK |
1184
HAL_RF_LCK |
1185
HAL_RF_DPK |
1186
HAL_RF_DACK |
1187
HAL_RF_DPK_TRACK |
1188
0;
1189
#endif
1190
break;
1191
#if (RTL8822B_SUPPORT == 1)
1192
case ODM_RTL8822B:
1193
rf->rf_supportability =
1194
HAL_RF_TX_PWR_TRACK |
1195
HAL_RF_IQK |
1196
HAL_RF_LCK |
1197
/*@HAL_RF_DPK |*/
1198
0;
1199
break;
1200
#endif
1201
#if (RTL8822C_SUPPORT == 1)
1202
case ODM_RTL8822C:
1203
rf->rf_supportability =
1204
HAL_RF_TX_PWR_TRACK |
1205
HAL_RF_IQK |
1206
HAL_RF_LCK |
1207
HAL_RF_DPK |
1208
HAL_RF_DACK |
1209
HAL_RF_DPK_TRACK |
1210
0;
1211
break;
1212
#endif
1213
#if (RTL8821C_SUPPORT == 1)
1214
case ODM_RTL8821C:
1215
rf->rf_supportability =
1216
HAL_RF_TX_PWR_TRACK |
1217
HAL_RF_IQK |
1218
HAL_RF_LCK |
1219
/*@HAL_RF_DPK |*/
1220
/*@HAL_RF_TXGAPK |*/
1221
0;
1222
break;
1223
#endif
1224
#if (RTL8195B_SUPPORT == 1)
1225
case ODM_RTL8195B:
1226
rf->rf_supportability =
1227
HAL_RF_TX_PWR_TRACK |
1228
HAL_RF_IQK |
1229
HAL_RF_LCK |
1230
HAL_RF_DPK |
1231
HAL_RF_TXGAPK |
1232
HAL_RF_DPK_TRACK |
1233
0;
1234
break;
1235
#endif
1236
#if (RTL8812F_SUPPORT == 1)
1237
case ODM_RTL8812F:
1238
rf->rf_supportability =
1239
HAL_RF_TX_PWR_TRACK |
1240
HAL_RF_IQK |
1241
HAL_RF_LCK |
1242
HAL_RF_DPK |
1243
HAL_RF_DACK |
1244
HAL_RF_DPK_TRACK |
1245
0;
1246
break;
1247
#endif
1248
1249
#if (RTL8198F_SUPPORT == 1)
1250
case ODM_RTL8198F:
1251
rf->rf_supportability =
1252
HAL_RF_TX_PWR_TRACK |
1253
HAL_RF_IQK |
1254
HAL_RF_LCK |
1255
HAL_RF_DPK |
1256
/*@HAL_RF_TXGAPK |*/
1257
0;
1258
break;
1259
#endif
1260
1261
#if (RTL8192F_SUPPORT == 1)
1262
case ODM_RTL8192F:
1263
rf->rf_supportability =
1264
HAL_RF_TX_PWR_TRACK |
1265
HAL_RF_IQK |
1266
HAL_RF_LCK |
1267
HAL_RF_DPK |
1268
/*@HAL_RF_TXGAPK |*/
1269
#ifdef CONFIG_2G_BAND_SHIFT
1270
/*@HAL_2GBAND_SHIFT |*/
1271
#endif
1272
0;
1273
break;
1274
#endif
1275
1276
#if (RTL8197F_SUPPORT == 1)
1277
case ODM_RTL8197F:
1278
rf->rf_supportability =
1279
HAL_RF_TX_PWR_TRACK |
1280
HAL_RF_IQK |
1281
HAL_RF_LCK |
1282
HAL_RF_DPK |
1283
/*@HAL_RF_TXGAPK |*/
1284
0;
1285
break;
1286
#endif
1287
#if (RTL8197G_SUPPORT == 1)
1288
case ODM_RTL8197G:
1289
rf->rf_supportability =
1290
HAL_RF_TX_PWR_TRACK |
1291
HAL_RF_IQK |
1292
/*HAL_RF_LCK |*/
1293
HAL_RF_DPK |
1294
/*@HAL_RF_TXGAPK |*/
1295
/*HAL_RF_DPK_TRACK |*/
1296
#ifdef CONFIG_2G_BAND_SHIFT
1297
HAL_2GBAND_SHIFT |
1298
#endif
1299
0;
1300
break;
1301
#endif
1302
#if (RTL8721D_SUPPORT == 1)
1303
case ODM_RTL8721D:
1304
rf->rf_supportability =
1305
HAL_RF_TX_PWR_TRACK |
1306
HAL_RF_IQK |
1307
HAL_RF_LCK |
1308
HAL_RF_DPK |
1309
HAL_RF_DPK_TRACK |
1310
/*@HAL_RF_TXGAPK |*/
1311
0;
1312
break;
1313
#endif
1314
1315
default:
1316
rf->rf_supportability =
1317
HAL_RF_TX_PWR_TRACK |
1318
HAL_RF_IQK |
1319
HAL_RF_LCK |
1320
/*@HAL_RF_DPK |*/
1321
0;
1322
break;
1323
}
1324
1325
RF_DBG(dm, DBG_RF_INIT,
1326
"IC = ((0x%x)), RF_Supportability Init = ((0x%x))\n",
1327
dm->support_ic_type, rf->rf_supportability);
1328
}
1329
1330
void halrf_watchdog(void *dm_void)
1331
{
1332
struct dm_struct *dm = (struct dm_struct *)dm_void;
1333
struct _hal_rf_ *rf = &dm->rf_table;
1334
#if 0
1335
/*RF_DBG(dm, DBG_RF_TMP, "%s\n", __func__);*/
1336
#endif
1337
1338
if (rf->is_dpk_in_progress || dm->rf_calibrate_info.is_iqk_in_progress ||
1339
rf->is_tssi_in_progress)
1340
return;
1341
1342
phydm_rf_watchdog(dm);
1343
halrf_dpk_track(dm);
1344
}
1345
1346
#if 0
1347
void
1348
halrf_iqk_init(
1349
void *dm_void
1350
)
1351
{
1352
struct dm_struct *dm = (struct dm_struct *)dm_void;
1353
struct _hal_rf_ *rf = &dm->rf_table;
1354
1355
switch (dm->support_ic_type) {
1356
#if (RTL8814B_SUPPORT == 1)
1357
case ODM_RTL8814B:
1358
break;
1359
#endif
1360
#if (RTL8822B_SUPPORT == 1)
1361
case ODM_RTL8822B:
1362
_iq_calibrate_8822b_init(dm);
1363
break;
1364
#endif
1365
#if (RTL8822C_SUPPORT == 1)
1366
case ODM_RTL8822C:
1367
_iq_calibrate_8822c_init(dm);
1368
break;
1369
#endif
1370
#if (RTL8821C_SUPPORT == 1)
1371
case ODM_RTL8821C:
1372
break;
1373
#endif
1374
1375
default:
1376
break;
1377
}
1378
}
1379
#endif
1380
1381
void halrf_reload_iqk(void *dm_void, boolean reset)
1382
{
1383
struct dm_struct *dm = (struct dm_struct *)dm_void;
1384
struct dm_iqk_info *iqk_info = &dm->IQK_info;
1385
u8 i, ch;
1386
u32 tmp;
1387
u32 bit_mask_20_16 = BIT(20) | BIT(19) | BIT(18) | BIT(17) | BIT(16);
1388
1389
switch (dm->support_ic_type) {
1390
#if (RTL8822C_SUPPORT == 1)
1391
case ODM_RTL8822C:
1392
iqk_reload_iqk_8822c(dm, reset);
1393
break;
1394
#endif
1395
default:
1396
break;
1397
}
1398
}
1399
1400
void halrf_rfk_handshake(void *dm_void, boolean is_before_k)
1401
{
1402
struct dm_struct *dm = (struct dm_struct *)dm_void;
1403
1404
if (*dm->mp_mode)
1405
return;
1406
1407
switch (dm->support_ic_type) {
1408
#if (RTL8822C_SUPPORT == 1)
1409
case ODM_RTL8822C:
1410
halrf_rfk_handshake_8822c(dm, is_before_k);
1411
break;
1412
#endif
1413
default:
1414
break;
1415
}
1416
}
1417
1418
void halrf_rf_k_connect_trigger(void *dm_void, boolean is_recovery,
1419
enum halrf_k_segment_time seg_time)
1420
{
1421
struct dm_struct *dm = (struct dm_struct *)dm_void;
1422
struct dm_dpk_info *dpk_info = &dm->dpk_info;
1423
struct _hal_rf_ *rf = &dm->rf_table;
1424
1425
if (dm->mp_mode && rf->is_con_tx && rf->is_single_tone &&
1426
rf->is_carrier_suppresion) {
1427
if (*dm->mp_mode &&
1428
(*rf->is_con_tx || *rf->is_single_tone ||
1429
*rf->is_carrier_suppresion))
1430
return;
1431
}
1432
/*[TX GAP K]*/
1433
1434
/*[LOK, IQK]*/
1435
halrf_segment_iqk_trigger(dm, true, seg_time);
1436
1437
/*[TSSI Trk]*/
1438
halrf_tssi_trigger(dm);
1439
1440
/*[DPK]*/
1441
if(dpk_info->is_dpk_by_channel == true)
1442
halrf_dpk_trigger(dm);
1443
else
1444
halrf_dpk_reload(dm);
1445
1446
//ADDA restore to MP_UI setting;
1447
config_halrf_path_adda_setting_trigger(dm);
1448
}
1449
1450
void config_halrf_path_adda_setting_trigger(void *dm_void)
1451
{
1452
struct dm_struct *dm = (struct dm_struct *)dm_void;
1453
1454
#if (RTL8814B_SUPPORT == 1)
1455
if (dm->support_ic_type & ODM_RTL8814B)
1456
config_phydm_path_adda_setting_8814b(dm);
1457
#endif
1458
1459
}
1460
1461
void halrf_dack_trigger(void *dm_void)
1462
{
1463
struct dm_struct *dm = (struct dm_struct *)dm_void;
1464
struct _hal_rf_ *rf = &dm->rf_table;
1465
1466
u64 start_time;
1467
1468
if (!(rf->rf_supportability & HAL_RF_DACK))
1469
return;
1470
1471
start_time = odm_get_current_time(dm);
1472
1473
switch (dm->support_ic_type) {
1474
#if (RTL8822C_SUPPORT == 1)
1475
case ODM_RTL8822C:
1476
halrf_dac_cal_8822c(dm);
1477
break;
1478
#endif
1479
#if (RTL8812F_SUPPORT == 1)
1480
case ODM_RTL8812F:
1481
halrf_dac_cal_8812f(dm);
1482
break;
1483
#endif
1484
#if (RTL8814B_SUPPORT == 1)
1485
case ODM_RTL8814B:
1486
halrf_dac_cal_8814b(dm);
1487
break;
1488
#endif
1489
default:
1490
break;
1491
}
1492
rf->dpk_progressing_time = odm_get_progressing_time(dm, start_time);
1493
RF_DBG(dm, DBG_RF_DACK, "[DACK]DACK progressing_time = %lld ms\n",
1494
rf->dpk_progressing_time);
1495
}
1496
1497
1498
void halrf_dack_dbg(void *dm_void)
1499
{
1500
struct dm_struct *dm = (struct dm_struct *)dm_void;
1501
struct _hal_rf_ *rf = &dm->rf_table;
1502
1503
u64 start_time;
1504
1505
if (!(rf->rf_supportability & HAL_RF_DACK))
1506
return;
1507
1508
switch (dm->support_ic_type) {
1509
#if (RTL8822C_SUPPORT == 1)
1510
case ODM_RTL8822C:
1511
halrf_dack_dbg_8822c(dm);
1512
break;
1513
#endif
1514
default:
1515
break;
1516
}
1517
}
1518
1519
1520
void halrf_segment_iqk_trigger(void *dm_void, boolean clear,
1521
boolean segment_iqk)
1522
{
1523
struct dm_struct *dm = (struct dm_struct *)dm_void;
1524
struct dm_iqk_info *iqk_info = &dm->IQK_info;
1525
struct _hal_rf_ *rf = &dm->rf_table;
1526
u64 start_time;
1527
1528
#if (DM_ODM_SUPPORT_TYPE & (ODM_WIN))
1529
if (odm_check_power_status(dm) == false)
1530
return;
1531
#endif
1532
1533
if (dm->mp_mode &&
1534
rf->is_con_tx &&
1535
rf->is_single_tone &&
1536
rf->is_carrier_suppresion)
1537
if (*dm->mp_mode &&
1538
((*rf->is_con_tx ||
1539
*rf->is_single_tone ||
1540
*rf->is_carrier_suppresion)))
1541
return;
1542
1543
#if (DM_ODM_SUPPORT_TYPE == ODM_CE)
1544
if (!(rf->rf_supportability & HAL_RF_IQK))
1545
return;
1546
#endif
1547
1548
#if DISABLE_BB_RF
1549
return;
1550
#endif
1551
if (iqk_info->rfk_forbidden)
1552
return;
1553
1554
halrf_rfk_handshake(dm, true);
1555
1556
if (!dm->rf_calibrate_info.is_iqk_in_progress) {
1557
odm_acquire_spin_lock(dm, RT_IQK_SPINLOCK);
1558
dm->rf_calibrate_info.is_iqk_in_progress = true;
1559
odm_release_spin_lock(dm, RT_IQK_SPINLOCK);
1560
start_time = odm_get_current_time(dm);
1561
dm->IQK_info.segment_iqk = segment_iqk;
1562
1563
switch (dm->support_ic_type) {
1564
#if (RTL8822B_SUPPORT == 1)
1565
case ODM_RTL8822B:
1566
phy_iq_calibrate_8822b(dm, clear, segment_iqk);
1567
break;
1568
#endif
1569
#if (RTL8822C_SUPPORT == 1)
1570
case ODM_RTL8822C:
1571
phy_iq_calibrate_8822c(dm, clear, segment_iqk);
1572
break;
1573
#endif
1574
#if (RTL8821C_SUPPORT == 1)
1575
case ODM_RTL8821C:
1576
phy_iq_calibrate_8821c(dm, clear, segment_iqk);
1577
break;
1578
#endif
1579
#if (RTL8814B_SUPPORT == 1)
1580
case ODM_RTL8814B:
1581
phy_iq_calibrate_8814b(dm, clear, segment_iqk);
1582
break;
1583
#endif
1584
#if (RTL8195B_SUPPORT == 1)
1585
case ODM_RTL8195B:
1586
phy_iq_calibrate_8195b(dm, clear, segment_iqk);
1587
break;
1588
#endif
1589
#if (RTL8710C_SUPPORT == 1)
1590
case ODM_RTL8710C:
1591
phy_iq_calibrate_8710c(dm, clear, segment_iqk);
1592
break;
1593
#endif
1594
#if (RTL8198F_SUPPORT == 1)
1595
case ODM_RTL8198F:
1596
phy_iq_calibrate_8198f(dm, clear, segment_iqk);
1597
break;
1598
#endif
1599
#if (RTL8812F_SUPPORT == 1)
1600
case ODM_RTL8812F:
1601
phy_iq_calibrate_8812f(dm, clear, segment_iqk);
1602
break;
1603
#endif
1604
#if (RTL8197G_SUPPORT == 1)
1605
case ODM_RTL8197G:
1606
phy_iq_calibrate_8197g(dm, clear, segment_iqk);
1607
break;
1608
#endif
1609
#if (RTL8188E_SUPPORT == 1)
1610
case ODM_RTL8188E:
1611
phy_iq_calibrate_8188e(dm, false);
1612
break;
1613
#endif
1614
#if (RTL8188F_SUPPORT == 1)
1615
case ODM_RTL8188F:
1616
phy_iq_calibrate_8188f(dm, false);
1617
break;
1618
#endif
1619
#if (RTL8192E_SUPPORT == 1)
1620
case ODM_RTL8192E:
1621
phy_iq_calibrate_8192e(dm, false);
1622
break;
1623
#endif
1624
#if (RTL8197F_SUPPORT == 1)
1625
case ODM_RTL8197F:
1626
phy_iq_calibrate_8197f(dm, false);
1627
break;
1628
#endif
1629
#if (RTL8192F_SUPPORT == 1)
1630
case ODM_RTL8192F:
1631
phy_iq_calibrate_8192f(dm, false);
1632
break;
1633
#endif
1634
#if (RTL8703B_SUPPORT == 1)
1635
case ODM_RTL8703B:
1636
phy_iq_calibrate_8703b(dm, false);
1637
break;
1638
#endif
1639
#if (RTL8710B_SUPPORT == 1)
1640
case ODM_RTL8710B:
1641
phy_iq_calibrate_8710b(dm, false);
1642
break;
1643
#endif
1644
#if (RTL8723B_SUPPORT == 1)
1645
case ODM_RTL8723B:
1646
phy_iq_calibrate_8723b(dm, false);
1647
break;
1648
#endif
1649
#if (RTL8723D_SUPPORT == 1)
1650
case ODM_RTL8723D:
1651
phy_iq_calibrate_8723d(dm, false);
1652
break;
1653
#endif
1654
#if (RTL8721D_SUPPORT == 1)
1655
case ODM_RTL8721D:
1656
phy_iq_calibrate_8721d(dm, false);
1657
break;
1658
#endif
1659
#if (RTL8812A_SUPPORT == 1)
1660
case ODM_RTL8812:
1661
phy_iq_calibrate_8812a(dm, false);
1662
break;
1663
#endif
1664
#if (RTL8821A_SUPPORT == 1)
1665
case ODM_RTL8821:
1666
phy_iq_calibrate_8821a(dm, false);
1667
break;
1668
#endif
1669
#if (RTL8814A_SUPPORT == 1)
1670
case ODM_RTL8814A:
1671
phy_iq_calibrate_8814a(dm, false);
1672
break;
1673
#endif
1674
default:
1675
break;
1676
}
1677
dm->rf_calibrate_info.iqk_progressing_time =
1678
odm_get_progressing_time(dm, start_time);
1679
RF_DBG(dm, DBG_RF_IQK, "[IQK]IQK progressing_time = %lld ms\n",
1680
dm->rf_calibrate_info.iqk_progressing_time);
1681
1682
odm_acquire_spin_lock(dm, RT_IQK_SPINLOCK);
1683
dm->rf_calibrate_info.is_iqk_in_progress = false;
1684
odm_release_spin_lock(dm, RT_IQK_SPINLOCK);
1685
1686
halrf_rfk_handshake(dm, false);
1687
} else {
1688
RF_DBG(dm, DBG_RF_IQK,
1689
"== Return the IQK CMD, because RFKs in Progress ==\n");
1690
}
1691
}
1692
1693
1694
void halrf_iqk_trigger(void *dm_void, boolean is_recovery)
1695
{
1696
struct dm_struct *dm = (struct dm_struct *)dm_void;
1697
struct dm_iqk_info *iqk_info = &dm->IQK_info;
1698
struct dm_dpk_info *dpk_info = &dm->dpk_info;
1699
struct _hal_rf_ *rf = &dm->rf_table;
1700
u64 start_time;
1701
1702
#if (DM_ODM_SUPPORT_TYPE & (ODM_WIN))
1703
if (odm_check_power_status(dm) == false)
1704
return;
1705
#endif
1706
1707
if (dm->mp_mode &&
1708
rf->is_con_tx &&
1709
rf->is_single_tone &&
1710
rf->is_carrier_suppresion)
1711
if (*dm->mp_mode &&
1712
((*rf->is_con_tx ||
1713
*rf->is_single_tone ||
1714
*rf->is_carrier_suppresion)))
1715
return;
1716
1717
if (!(rf->rf_supportability & HAL_RF_IQK))
1718
return;
1719
1720
#if DISABLE_BB_RF
1721
return;
1722
#endif
1723
1724
if (iqk_info->rfk_forbidden)
1725
return;
1726
1727
halrf_rfk_handshake(dm, true);
1728
1729
if (!dm->rf_calibrate_info.is_iqk_in_progress) {
1730
odm_acquire_spin_lock(dm, RT_IQK_SPINLOCK);
1731
dm->rf_calibrate_info.is_iqk_in_progress = true;
1732
odm_release_spin_lock(dm, RT_IQK_SPINLOCK);
1733
start_time = odm_get_current_time(dm);
1734
switch (dm->support_ic_type) {
1735
#if (RTL8188E_SUPPORT == 1)
1736
case ODM_RTL8188E:
1737
phy_iq_calibrate_8188e(dm, is_recovery);
1738
break;
1739
#endif
1740
#if (RTL8188F_SUPPORT == 1)
1741
case ODM_RTL8188F:
1742
phy_iq_calibrate_8188f(dm, is_recovery);
1743
break;
1744
#endif
1745
#if (RTL8192E_SUPPORT == 1)
1746
case ODM_RTL8192E:
1747
phy_iq_calibrate_8192e(dm, is_recovery);
1748
break;
1749
#endif
1750
#if (RTL8197F_SUPPORT == 1)
1751
case ODM_RTL8197F:
1752
phy_iq_calibrate_8197f(dm, is_recovery);
1753
break;
1754
#endif
1755
#if (RTL8192F_SUPPORT == 1)
1756
case ODM_RTL8192F:
1757
phy_iq_calibrate_8192f(dm, is_recovery);
1758
break;
1759
#endif
1760
#if (RTL8703B_SUPPORT == 1)
1761
case ODM_RTL8703B:
1762
phy_iq_calibrate_8703b(dm, is_recovery);
1763
break;
1764
#endif
1765
#if (RTL8710B_SUPPORT == 1)
1766
case ODM_RTL8710B:
1767
phy_iq_calibrate_8710b(dm, is_recovery);
1768
break;
1769
#endif
1770
#if (RTL8723B_SUPPORT == 1)
1771
case ODM_RTL8723B:
1772
phy_iq_calibrate_8723b(dm, is_recovery);
1773
break;
1774
#endif
1775
#if (RTL8723D_SUPPORT == 1)
1776
case ODM_RTL8723D:
1777
phy_iq_calibrate_8723d(dm, is_recovery);
1778
break;
1779
#endif
1780
#if (RTL8721D_SUPPORT == 1)
1781
case ODM_RTL8721D:
1782
phy_iq_calibrate_8721d(dm, is_recovery);
1783
break;
1784
#endif
1785
#if (RTL8812A_SUPPORT == 1)
1786
case ODM_RTL8812:
1787
phy_iq_calibrate_8812a(dm, is_recovery);
1788
break;
1789
#endif
1790
#if (RTL8821A_SUPPORT == 1)
1791
case ODM_RTL8821:
1792
phy_iq_calibrate_8821a(dm, is_recovery);
1793
break;
1794
#endif
1795
#if (RTL8814A_SUPPORT == 1)
1796
case ODM_RTL8814A:
1797
phy_iq_calibrate_8814a(dm, is_recovery);
1798
break;
1799
#endif
1800
#if (RTL8822B_SUPPORT == 1)
1801
case ODM_RTL8822B:
1802
phy_iq_calibrate_8822b(dm, false, false);
1803
break;
1804
#endif
1805
#if (RTL8822C_SUPPORT == 1)
1806
case ODM_RTL8822C:
1807
phy_iq_calibrate_8822c(dm, false, false);
1808
break;
1809
#endif
1810
#if (RTL8821C_SUPPORT == 1)
1811
case ODM_RTL8821C:
1812
phy_iq_calibrate_8821c(dm, false, false);
1813
break;
1814
#endif
1815
#if (RTL8814B_SUPPORT == 1)
1816
case ODM_RTL8814B:
1817
phy_iq_calibrate_8814b(dm, false, false);
1818
break;
1819
#endif
1820
#if (RTL8195B_SUPPORT == 1)
1821
case ODM_RTL8195B:
1822
phy_iq_calibrate_8195b(dm, false, false);
1823
break;
1824
#endif
1825
#if (RTL8710C_SUPPORT == 1)
1826
case ODM_RTL8710C:
1827
phy_iq_calibrate_8710c(dm, false, false);
1828
break;
1829
#endif
1830
#if (RTL8198F_SUPPORT == 1)
1831
case ODM_RTL8198F:
1832
phy_iq_calibrate_8198f(dm, false, false);
1833
break;
1834
#endif
1835
#if (RTL8812F_SUPPORT == 1)
1836
case ODM_RTL8812F:
1837
phy_iq_calibrate_8812f(dm, false, false);
1838
break;
1839
#endif
1840
#if (RTL8197G_SUPPORT == 1)
1841
case ODM_RTL8197G:
1842
phy_iq_calibrate_8197g(dm, false, false);
1843
break;
1844
#endif
1845
default:
1846
break;
1847
}
1848
rf->iqk_progressing_time = odm_get_progressing_time(dm, start_time);
1849
RF_DBG(dm, DBG_RF_LCK, "[IQK]Trigger IQK progressing_time = %lld ms\n",
1850
rf->iqk_progressing_time);
1851
odm_acquire_spin_lock(dm, RT_IQK_SPINLOCK);
1852
dm->rf_calibrate_info.is_iqk_in_progress = false;
1853
odm_release_spin_lock(dm, RT_IQK_SPINLOCK);
1854
1855
halrf_rfk_handshake(dm, false);
1856
} else {
1857
RF_DBG(dm, DBG_RF_IQK,
1858
"== Return the IQK CMD, because RFKs in Progress ==\n");
1859
}
1860
}
1861
1862
void halrf_lck_trigger(void *dm_void)
1863
{
1864
struct dm_struct *dm = (struct dm_struct *)dm_void;
1865
struct dm_iqk_info *iqk_info = &dm->IQK_info;
1866
struct _hal_rf_ *rf = &dm->rf_table;
1867
u64 start_time;
1868
1869
#if (DM_ODM_SUPPORT_TYPE & (ODM_WIN))
1870
if (odm_check_power_status(dm) == false)
1871
return;
1872
#endif
1873
1874
if (dm->mp_mode &&
1875
rf->is_con_tx &&
1876
rf->is_single_tone &&
1877
rf->is_carrier_suppresion)
1878
if (*dm->mp_mode &&
1879
((*rf->is_con_tx ||
1880
*rf->is_single_tone ||
1881
*rf->is_carrier_suppresion)))
1882
return;
1883
1884
if (!(rf->rf_supportability & HAL_RF_LCK))
1885
return;
1886
1887
#if DISABLE_BB_RF
1888
return;
1889
#endif
1890
if (iqk_info->rfk_forbidden)
1891
return;
1892
while (*dm->is_scan_in_process) {
1893
RF_DBG(dm, DBG_RF_IQK, "[LCK]scan is in process, bypass LCK\n");
1894
return;
1895
}
1896
1897
if (!dm->rf_calibrate_info.is_lck_in_progress) {
1898
odm_acquire_spin_lock(dm, RT_IQK_SPINLOCK);
1899
dm->rf_calibrate_info.is_lck_in_progress = true;
1900
odm_release_spin_lock(dm, RT_IQK_SPINLOCK);
1901
start_time = odm_get_current_time(dm);
1902
switch (dm->support_ic_type) {
1903
#if (RTL8188E_SUPPORT == 1)
1904
case ODM_RTL8188E:
1905
phy_lc_calibrate_8188e(dm);
1906
break;
1907
#endif
1908
#if (RTL8188F_SUPPORT == 1)
1909
case ODM_RTL8188F:
1910
phy_lc_calibrate_8188f(dm);
1911
break;
1912
#endif
1913
#if (RTL8192E_SUPPORT == 1)
1914
case ODM_RTL8192E:
1915
phy_lc_calibrate_8192e(dm);
1916
break;
1917
#endif
1918
#if (RTL8197F_SUPPORT == 1)
1919
case ODM_RTL8197F:
1920
phy_lc_calibrate_8197f(dm);
1921
break;
1922
#endif
1923
#if (RTL8192F_SUPPORT == 1)
1924
case ODM_RTL8192F:
1925
phy_lc_calibrate_8192f(dm);
1926
break;
1927
#endif
1928
#if (RTL8703B_SUPPORT == 1)
1929
case ODM_RTL8703B:
1930
phy_lc_calibrate_8703b(dm);
1931
break;
1932
#endif
1933
#if (RTL8710B_SUPPORT == 1)
1934
case ODM_RTL8710B:
1935
phy_lc_calibrate_8710b(dm);
1936
break;
1937
#endif
1938
#if (RTL8721D_SUPPORT == 1)
1939
case ODM_RTL8721D:
1940
phy_lc_calibrate_8721d(dm);
1941
break;
1942
#endif
1943
#if (RTL8723B_SUPPORT == 1)
1944
case ODM_RTL8723B:
1945
phy_lc_calibrate_8723b(dm);
1946
break;
1947
#endif
1948
#if (RTL8723D_SUPPORT == 1)
1949
case ODM_RTL8723D:
1950
phy_lc_calibrate_8723d(dm);
1951
break;
1952
#endif
1953
#if (RTL8812A_SUPPORT == 1)
1954
case ODM_RTL8812:
1955
phy_lc_calibrate_8812a(dm);
1956
break;
1957
#endif
1958
#if (RTL8821A_SUPPORT == 1)
1959
case ODM_RTL8821:
1960
phy_lc_calibrate_8821a(dm);
1961
break;
1962
#endif
1963
#if (RTL8814A_SUPPORT == 1)
1964
case ODM_RTL8814A:
1965
phy_lc_calibrate_8814a(dm);
1966
break;
1967
#endif
1968
#if (RTL8822B_SUPPORT == 1)
1969
case ODM_RTL8822B:
1970
phy_lc_calibrate_8822b(dm);
1971
break;
1972
#endif
1973
#if (RTL8822C_SUPPORT == 1)
1974
case ODM_RTL8822C:
1975
phy_lc_calibrate_8822c(dm);
1976
break;
1977
#endif
1978
#if (RTL8812F_SUPPORT == 1)
1979
case ODM_RTL8812F:
1980
phy_lc_calibrate_8812f(dm);
1981
break;
1982
#endif
1983
#if (RTL8821C_SUPPORT == 1)
1984
case ODM_RTL8821C:
1985
phy_lc_calibrate_8821c(dm);
1986
break;
1987
#endif
1988
#if (RTL8814B_SUPPORT == 1)
1989
case ODM_RTL8814B:
1990
break;
1991
#endif
1992
#if (RTL8710C_SUPPORT == 1)
1993
case ODM_RTL8710C:
1994
phy_lc_calibrate_8710c(dm);
1995
break;
1996
#endif
1997
default:
1998
break;
1999
}
2000
dm->rf_calibrate_info.lck_progressing_time =
2001
odm_get_progressing_time(dm, start_time);
2002
RF_DBG(dm, DBG_RF_IQK, "[IQK]LCK progressing_time = %lld ms\n",
2003
dm->rf_calibrate_info.lck_progressing_time);
2004
#if (RTL8822B_SUPPORT == 1 || RTL8821C_SUPPORT == 1)
2005
halrf_lck_dbg(dm);
2006
#endif
2007
odm_acquire_spin_lock(dm, RT_IQK_SPINLOCK);
2008
dm->rf_calibrate_info.is_lck_in_progress = false;
2009
odm_release_spin_lock(dm, RT_IQK_SPINLOCK);
2010
} else {
2011
RF_DBG(dm, DBG_RF_IQK,
2012
"= Return the LCK CMD, because RFK is in Progress =\n");
2013
}
2014
}
2015
2016
void halrf_aac_check(struct dm_struct *dm)
2017
{
2018
switch (dm->support_ic_type) {
2019
#if (RTL8821C_SUPPORT == 1)
2020
case ODM_RTL8821C:
2021
#if 0
2022
aac_check_8821c(dm);
2023
#endif
2024
break;
2025
#endif
2026
#if (RTL8822B_SUPPORT == 1)
2027
case ODM_RTL8822B:
2028
#if 1
2029
aac_check_8822b(dm);
2030
#endif
2031
break;
2032
#endif
2033
default:
2034
break;
2035
}
2036
}
2037
2038
void halrf_x2k_check(struct dm_struct *dm)
2039
{
2040
2041
switch (dm->support_ic_type) {
2042
case ODM_RTL8821C:
2043
#if (RTL8821C_SUPPORT == 1)
2044
#endif
2045
break;
2046
case ODM_RTL8822C:
2047
#if (RTL8822C_SUPPORT == 1)
2048
phy_x2_check_8822c(dm);
2049
break;
2050
#endif
2051
case ODM_RTL8812F:
2052
#if (RTL8812F_SUPPORT == 1)
2053
phy_x2_check_8812f(dm);
2054
break;
2055
#endif
2056
default:
2057
break;
2058
}
2059
}
2060
2061
void halrf_set_rfsupportability(void *dm_void)
2062
{
2063
struct dm_struct *dm = (struct dm_struct *)dm_void;
2064
struct _hal_rf_ *rf = &dm->rf_table;
2065
2066
if (rf->manual_rf_supportability &&
2067
*rf->manual_rf_supportability != 0xffffffff) {
2068
rf->rf_supportability = *rf->manual_rf_supportability;
2069
} else if (*dm->mp_mode) {
2070
halrf_supportability_init_mp(dm);
2071
} else {
2072
halrf_supportability_init(dm);
2073
}
2074
}
2075
2076
void halrf_init(void *dm_void)
2077
{
2078
struct dm_struct *dm = (struct dm_struct *)dm_void;
2079
struct _hal_rf_ *rf = &dm->rf_table;
2080
2081
RF_DBG(dm, DBG_RF_INIT, "HALRF_Init\n");
2082
rf->aac_checked = false;
2083
halrf_init_debug_setting(dm);
2084
halrf_set_rfsupportability(dm);
2085
#if 1
2086
/*Init all RF funciton*/
2087
halrf_aac_check(dm);
2088
halrf_dack_trigger(dm);
2089
halrf_x2k_check(dm);
2090
#endif
2091
2092
/*power trim, thrmal trim, pa bias*/
2093
phydm_config_new_kfree(dm);
2094
2095
/*TSSI Init*/
2096
halrf_tssi_dck(dm, true);
2097
halrf_tssi_get_efuse(dm);
2098
halrf_tssi_set_de(dm);
2099
}
2100
2101
void halrf_dpk_trigger(void *dm_void)
2102
{
2103
struct dm_struct *dm = (struct dm_struct *)dm_void;
2104
struct _hal_rf_ *rf = &dm->rf_table;
2105
struct dm_dpk_info *dpk_info = &dm->dpk_info;
2106
struct dm_iqk_info *iqk_info = &dm->IQK_info;
2107
2108
u64 start_time;
2109
2110
#if (DM_ODM_SUPPORT_TYPE & (ODM_WIN))
2111
if (odm_check_power_status(dm) == false)
2112
return;
2113
#endif
2114
2115
if (dm->mp_mode &&
2116
rf->is_con_tx &&
2117
rf->is_single_tone &&
2118
rf->is_carrier_suppresion)
2119
if (*dm->mp_mode &&
2120
((*rf->is_con_tx ||
2121
*rf->is_single_tone ||
2122
*rf->is_carrier_suppresion)))
2123
return;
2124
2125
if (!(rf->rf_supportability & HAL_RF_DPK))
2126
return;
2127
2128
#if DISABLE_BB_RF
2129
return;
2130
#endif
2131
2132
if (iqk_info->rfk_forbidden)
2133
return;
2134
2135
halrf_rfk_handshake(dm, true);
2136
2137
if (!rf->is_dpk_in_progress) {
2138
odm_acquire_spin_lock(dm, RT_IQK_SPINLOCK);
2139
rf->is_dpk_in_progress = true;
2140
odm_release_spin_lock(dm, RT_IQK_SPINLOCK);
2141
start_time = odm_get_current_time(dm);
2142
2143
switch (dm->support_ic_type) {
2144
#if (RTL8822C_SUPPORT == 1)
2145
case ODM_RTL8822C:
2146
do_dpk_8822c(dm);
2147
break;
2148
#endif
2149
2150
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
2151
#if (RTL8197F_SUPPORT == 1)
2152
case ODM_RTL8197F:
2153
do_dpk_8197f(dm);
2154
break;
2155
#endif
2156
#if (RTL8192F_SUPPORT == 1)
2157
case ODM_RTL8192F:
2158
do_dpk_8192f(dm);
2159
break;
2160
#endif
2161
2162
#if (RTL8198F_SUPPORT == 1)
2163
case ODM_RTL8198F:
2164
do_dpk_8198f(dm);
2165
break;
2166
#endif
2167
#if (RTL8812F_SUPPORT == 1)
2168
case ODM_RTL8812F:
2169
do_dpk_8812f(dm);
2170
break;
2171
#endif
2172
#if (RTL8197G_SUPPORT == 1)
2173
case ODM_RTL8197G:
2174
do_dpk_8197g(dm);
2175
break;
2176
#endif
2177
2178
#endif
2179
2180
#if (RTL8814B_SUPPORT == 1)
2181
case ODM_RTL8814B:
2182
do_dpk_8814b(dm);
2183
break;
2184
#endif
2185
2186
#if (DM_ODM_SUPPORT_TYPE & (ODM_IOT))
2187
#if (RTL8195B_SUPPORT == 1)
2188
case ODM_RTL8195B:
2189
do_dpk_8195b(dm);
2190
break;
2191
#endif
2192
#if (RTL8721D_SUPPORT == 1)
2193
case ODM_RTL8721D:
2194
do_dpk_8721d(dm);
2195
break;
2196
#endif
2197
#endif
2198
default:
2199
break;
2200
}
2201
rf->dpk_progressing_time = odm_get_progressing_time(dm, start_time);
2202
RF_DBG(dm, DBG_RF_DPK, "[DPK]DPK progressing_time = %lld ms\n",
2203
rf->dpk_progressing_time);
2204
2205
odm_acquire_spin_lock(dm, RT_IQK_SPINLOCK);
2206
rf->is_dpk_in_progress = false;
2207
odm_release_spin_lock(dm, RT_IQK_SPINLOCK);
2208
2209
halrf_rfk_handshake(dm, false);
2210
} else {
2211
RF_DBG(dm, DBG_RF_DPK,
2212
"== Return the DPK CMD, because RFKs in Progress ==\n");
2213
}
2214
}
2215
2216
void halrf_set_dpkbychannel(void *dm_void, boolean dpk_by_ch)
2217
{
2218
struct dm_struct *dm = (struct dm_struct *)dm_void;
2219
struct _hal_rf_ *rf = &dm->rf_table;
2220
struct dm_dpk_info *dpk_info = &dm->dpk_info;
2221
struct dm_iqk_info *iqk_info = &dm->IQK_info;
2222
2223
2224
switch (dm->support_ic_type) {
2225
#if (RTL8814B_SUPPORT == 1)
2226
case ODM_RTL8814B:
2227
dpk_set_dpkbychannel_8814b(dm, dpk_by_ch);
2228
break;
2229
#endif
2230
2231
#if (DM_ODM_SUPPORT_TYPE & (ODM_IOT))
2232
#if (RTL8195B_SUPPORT == 1)
2233
case ODM_RTL8195B:
2234
dpk_set_dpkbychannel_8195b(dm,dpk_by_ch);
2235
break;
2236
#endif
2237
#endif
2238
default:
2239
if (dpk_by_ch)
2240
dpk_info->is_dpk_by_channel = 1;
2241
else
2242
dpk_info->is_dpk_by_channel = 0;
2243
break;
2244
}
2245
2246
}
2247
2248
void halrf_set_dpkenable(void *dm_void, boolean is_dpk_enable)
2249
{
2250
struct dm_struct *dm = (struct dm_struct *)dm_void;
2251
struct _hal_rf_ *rf = &dm->rf_table;
2252
struct dm_dpk_info *dpk_info = &dm->dpk_info;
2253
struct dm_iqk_info *iqk_info = &dm->IQK_info;
2254
2255
2256
switch (dm->support_ic_type) {
2257
#if (RTL8814B_SUPPORT == 1)
2258
case ODM_RTL8814B:
2259
dpk_set_is_dpk_enable_8814b(dm, is_dpk_enable);
2260
break;
2261
#endif
2262
2263
#if (DM_ODM_SUPPORT_TYPE & (ODM_IOT))
2264
#if (RTL8195B_SUPPORT == 1)
2265
case ODM_RTL8195B:
2266
dpk_set_is_dpk_enable_8195b(dm, is_dpk_enable);
2267
break;
2268
#endif
2269
2270
#if (RTL8721D_SUPPORT == 1)
2271
case RTL8721D_SUPPORT:
2272
dpk_set_is_dpk_enable_8721d(dm, is_dpk_enable);
2273
break;
2274
#endif
2275
2276
#endif
2277
2278
2279
default:
2280
break;
2281
}
2282
2283
}
2284
boolean halrf_get_dpkbychannel(void *dm_void)
2285
{
2286
struct dm_struct *dm = (struct dm_struct *)dm_void;
2287
struct _hal_rf_ *rf = &dm->rf_table;
2288
struct dm_dpk_info *dpk_info = &dm->dpk_info;
2289
struct dm_iqk_info *iqk_info = &dm->IQK_info;
2290
boolean is_dpk_by_channel = true;
2291
2292
switch (dm->support_ic_type) {
2293
#if (RTL8814B_SUPPORT == 1)
2294
case ODM_RTL8814B:
2295
is_dpk_by_channel = dpk_get_dpkbychannel_8814b(dm);
2296
break;
2297
#endif
2298
2299
#if (DM_ODM_SUPPORT_TYPE & (ODM_IOT))
2300
#if (RTL8195B_SUPPORT == 1)
2301
case ODM_RTL8195B:
2302
is_dpk_by_channel = dpk_get_dpkbychannel_8195b(dm);
2303
break;
2304
#endif
2305
#endif
2306
2307
default:
2308
break;
2309
}
2310
return is_dpk_by_channel;
2311
2312
}
2313
2314
2315
boolean halrf_get_dpkenable(void *dm_void)
2316
{
2317
struct dm_struct *dm = (struct dm_struct *)dm_void;
2318
struct _hal_rf_ *rf = &dm->rf_table;
2319
struct dm_dpk_info *dpk_info = &dm->dpk_info;
2320
struct dm_iqk_info *iqk_info = &dm->IQK_info;
2321
boolean is_dpk_enable = true;
2322
2323
2324
switch (dm->support_ic_type) {
2325
#if (RTL8814B_SUPPORT == 1)
2326
case ODM_RTL8814B:
2327
is_dpk_enable = dpk_get_is_dpk_enable_8814b(dm);
2328
break;
2329
#endif
2330
2331
#if (DM_ODM_SUPPORT_TYPE & (ODM_IOT))
2332
#if (RTL8195B_SUPPORT == 1)
2333
case ODM_RTL8195B:
2334
is_dpk_enable = dpk_get_is_dpk_enable_8195b(dm);
2335
break;
2336
#endif
2337
#endif
2338
default:
2339
break;
2340
}
2341
return is_dpk_enable;
2342
2343
}
2344
2345
u8 halrf_dpk_result_check(void *dm_void)
2346
{
2347
struct dm_struct *dm = (struct dm_struct *)dm_void;
2348
struct dm_dpk_info *dpk_info = &dm->dpk_info;
2349
2350
u8 result = 0;
2351
2352
switch (dm->support_ic_type) {
2353
#if (RTL8822C_SUPPORT == 1)
2354
case ODM_RTL8822C:
2355
if (dpk_info->dpk_path_ok == 0x3)
2356
result = 1;
2357
else
2358
result = 0;
2359
break;
2360
#endif
2361
2362
#if (RTL8195B_SUPPORT == 1)
2363
case ODM_RTL8195B:
2364
if (dpk_info->dpk_path_ok == 0x1)
2365
result = 1;
2366
else
2367
result = 0;
2368
break;
2369
#endif
2370
2371
#if (RTL8721D_SUPPORT == 1)
2372
case ODM_RTL8721D:
2373
if (dpk_info->dpk_path_ok == 0x1)
2374
result = 1;
2375
else
2376
result = 0;
2377
break;
2378
#endif
2379
2380
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
2381
2382
#if (RTL8197F_SUPPORT == 1)
2383
case ODM_RTL8197F:
2384
if (dpk_info->dpk_path_ok == 0x3)
2385
result = 1;
2386
else
2387
result = 0;
2388
break;
2389
#endif
2390
2391
#if (RTL8192F_SUPPORT == 1)
2392
case ODM_RTL8192F:
2393
if (dpk_info->dpk_path_ok == 0x3)
2394
result = 1;
2395
else
2396
result = 0;
2397
break;
2398
#endif
2399
2400
#if (RTL8198F_SUPPORT == 1)
2401
case ODM_RTL8198F:
2402
if (dpk_info->dpk_path_ok == 0xf)
2403
result = 1;
2404
else
2405
result = 0;
2406
break;
2407
#endif
2408
2409
#if (RTL8814B_SUPPORT == 1)
2410
case ODM_RTL8814B:
2411
if (dpk_info->dpk_path_ok == 0xf)
2412
result = 1;
2413
else
2414
result = 0;
2415
break;
2416
#endif
2417
2418
#if (RTL8812F_SUPPORT == 1)
2419
case ODM_RTL8812F:
2420
if (dpk_info->dpk_path_ok == 0x3)
2421
result = 1;
2422
else
2423
result = 0;
2424
break;
2425
#endif
2426
2427
#if (RTL8197G_SUPPORT == 1)
2428
case ODM_RTL8197G:
2429
if (dpk_info->dpk_path_ok == 0x3)
2430
result = 1;
2431
else
2432
result = 0;
2433
break;
2434
#endif
2435
2436
#endif
2437
default:
2438
break;
2439
}
2440
return result;
2441
}
2442
2443
void halrf_dpk_sram_read(void *dm_void)
2444
{
2445
struct dm_struct *dm = (struct dm_struct *)dm_void;
2446
2447
u8 path, group;
2448
2449
switch (dm->support_ic_type) {
2450
#if (RTL8822C_SUPPORT == 1)
2451
case ODM_RTL8822C:
2452
dpk_coef_read_8822c(dm);
2453
break;
2454
#endif
2455
2456
#if (RTL8195B_SUPPORT == 1)
2457
case ODM_RTL8195B:
2458
dpk_sram_read_8195b(dm);
2459
break;
2460
#endif
2461
2462
#if (RTL8721D_SUPPORT == 1)
2463
case ODM_RTL8721D:
2464
dpk_sram_read_8721d(dm);
2465
break;
2466
#endif
2467
2468
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
2469
2470
#if (RTL8197F_SUPPORT == 1)
2471
case ODM_RTL8197F:
2472
dpk_sram_read_8197f(dm);
2473
break;
2474
#endif
2475
2476
#if (RTL8192F_SUPPORT == 1)
2477
case ODM_RTL8192F:
2478
dpk_sram_read_8192f(dm);
2479
break;
2480
#endif
2481
2482
#if (RTL8198F_SUPPORT == 1)
2483
case ODM_RTL8198F:
2484
dpk_sram_read_8198f(dm);
2485
break;
2486
#endif
2487
2488
#if (RTL8814B_SUPPORT == 1)
2489
case ODM_RTL8814B:
2490
dpk_sram_read_8814b(dm);
2491
break;
2492
#endif
2493
2494
#if (RTL8812F_SUPPORT == 1)
2495
case ODM_RTL8812F:
2496
dpk_coef_read_8812f(dm);
2497
break;
2498
#endif
2499
2500
#if (RTL8197G_SUPPORT == 1)
2501
case ODM_RTL8197G:
2502
dpk_sram_read_8197g(dm);
2503
break;
2504
#endif
2505
2506
#endif
2507
default:
2508
break;
2509
}
2510
}
2511
2512
void halrf_dpk_enable_disable(void *dm_void)
2513
{
2514
struct dm_struct *dm = (struct dm_struct *)dm_void;
2515
struct _hal_rf_ *rf = &dm->rf_table;
2516
2517
if (!(rf->rf_supportability & HAL_RF_DPK))
2518
return;
2519
2520
if (!rf->is_dpk_in_progress) {
2521
odm_acquire_spin_lock(dm, RT_IQK_SPINLOCK);
2522
rf->is_dpk_in_progress = true;
2523
odm_release_spin_lock(dm, RT_IQK_SPINLOCK);
2524
2525
switch (dm->support_ic_type) {
2526
#if (RTL8822C_SUPPORT == 1)
2527
case ODM_RTL8822C:
2528
dpk_enable_disable_8822c(dm);
2529
break;
2530
#endif
2531
#if (RTL8195B_SUPPORT == 1)
2532
case ODM_RTL8195B:
2533
dpk_enable_disable_8195b(dm);
2534
break;
2535
#endif
2536
#if (RTL8721D_SUPPORT == 1)
2537
case ODM_RTL8721D:
2538
phy_dpk_enable_disable_8721d(dm);
2539
break;
2540
#endif
2541
2542
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
2543
2544
#if (RTL8197F_SUPPORT == 1)
2545
case ODM_RTL8197F:
2546
phy_dpk_enable_disable_8197f(dm);
2547
break;
2548
#endif
2549
#if (RTL8192F_SUPPORT == 1)
2550
case ODM_RTL8192F:
2551
phy_dpk_enable_disable_8192f(dm);
2552
break;
2553
#endif
2554
2555
#if (RTL8198F_SUPPORT == 1)
2556
case ODM_RTL8198F:
2557
dpk_enable_disable_8198f(dm);
2558
break;
2559
#endif
2560
2561
#if (RTL8814B_SUPPORT == 1)
2562
case ODM_RTL8814B:
2563
dpk_enable_disable_8814b(dm);
2564
break;
2565
#endif
2566
2567
#if (RTL8812F_SUPPORT == 1)
2568
case ODM_RTL8812F:
2569
dpk_enable_disable_8812f(dm);
2570
break;
2571
#endif
2572
2573
#if (RTL8197G_SUPPORT == 1)
2574
case ODM_RTL8197G:
2575
dpk_enable_disable_8197g(dm);
2576
break;
2577
#endif
2578
2579
#endif
2580
default:
2581
break;
2582
}
2583
2584
odm_acquire_spin_lock(dm, RT_IQK_SPINLOCK);
2585
rf->is_dpk_in_progress = false;
2586
odm_release_spin_lock(dm, RT_IQK_SPINLOCK);
2587
} else {
2588
RF_DBG(dm, DBG_RF_DPK,
2589
"== Return the DPK CMD, because RFKs in Progress ==\n");
2590
}
2591
}
2592
2593
void halrf_dpk_track(void *dm_void)
2594
{
2595
struct dm_struct *dm = (struct dm_struct *)dm_void;
2596
struct dm_dpk_info *dpk_info = &dm->dpk_info;
2597
struct _hal_rf_ *rf = &dm->rf_table;
2598
2599
if (rf->is_dpk_in_progress || dm->rf_calibrate_info.is_iqk_in_progress ||
2600
dm->is_psd_in_process || (dpk_info->dpk_path_ok == 0) ||
2601
!(rf->rf_supportability & HAL_RF_DPK_TRACK) || rf->is_tssi_in_progress)
2602
return;
2603
2604
switch (dm->support_ic_type) {
2605
#if (RTL8814B_SUPPORT == 1)
2606
case ODM_RTL8814B:
2607
dpk_track_8814b(dm);
2608
break;
2609
#endif
2610
2611
#if (RTL8822C_SUPPORT == 1)
2612
case ODM_RTL8822C:
2613
dpk_track_8822c(dm);
2614
break;
2615
#endif
2616
2617
#if (RTL8195B_SUPPORT == 1)
2618
case ODM_RTL8195B:
2619
dpk_track_8195b(dm);
2620
break;
2621
#endif
2622
2623
#if (RTL8721D_SUPPORT == 1)
2624
case ODM_RTL8721D:
2625
phy_dpk_track_8721d(dm);
2626
break;
2627
#endif
2628
2629
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
2630
2631
#if (RTL8197F_SUPPORT == 1)
2632
case ODM_RTL8197F:
2633
phy_dpk_track_8197f(dm);
2634
break;
2635
#endif
2636
2637
#if (RTL8192F_SUPPORT == 1)
2638
case ODM_RTL8192F:
2639
phy_dpk_track_8192f(dm);
2640
break;
2641
#endif
2642
2643
#if (RTL8198F_SUPPORT == 1)
2644
case ODM_RTL8198F:
2645
dpk_track_8198f(dm);
2646
break;
2647
#endif
2648
2649
#if (RTL8812F_SUPPORT == 1)
2650
case ODM_RTL8812F:
2651
dpk_track_8812f(dm);
2652
break;
2653
#endif
2654
2655
#if (RTL8197G_SUPPORT == 1)
2656
case ODM_RTL8197G:
2657
dpk_track_8197g(dm);
2658
break;
2659
#endif
2660
2661
#endif
2662
default:
2663
break;
2664
}
2665
}
2666
2667
void halrf_set_dpk_track(void *dm_void, u8 enable)
2668
{
2669
struct dm_struct *dm = (struct dm_struct *)dm_void;
2670
struct _hal_rf_ *rf = &(dm->rf_table);
2671
2672
if (enable)
2673
rf->rf_supportability = rf->rf_supportability | HAL_RF_DPK_TRACK;
2674
else
2675
rf->rf_supportability = rf->rf_supportability & ~HAL_RF_DPK_TRACK;
2676
}
2677
2678
void halrf_dpk_reload(void *dm_void)
2679
{
2680
struct dm_struct *dm = (struct dm_struct *)dm_void;
2681
struct dm_dpk_info *dpk_info = &dm->dpk_info;
2682
2683
switch (dm->support_ic_type) {
2684
#if (RTL8195B_SUPPORT == 1)
2685
case ODM_RTL8195B:
2686
if (dpk_info->dpk_path_ok > 0)
2687
dpk_reload_8195b(dm);
2688
break;
2689
#endif
2690
#if (RTL8721D_SUPPORT == 1)
2691
case ODM_RTL8721D:
2692
if (dpk_info->dpk_path_ok > 0)
2693
dpk_reload_8721d(dm);
2694
break;
2695
#endif
2696
2697
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
2698
2699
#if (RTL8197F_SUPPORT == 1)
2700
case ODM_RTL8197F:
2701
if (dpk_info->dpk_path_ok > 0)
2702
dpk_reload_8197f(dm);
2703
break;
2704
#endif
2705
2706
#if (RTL8192F_SUPPORT == 1)
2707
case ODM_RTL8192F:
2708
if (dpk_info->dpk_path_ok > 0)
2709
dpk_reload_8192f(dm);
2710
2711
break;
2712
#endif
2713
2714
#if (RTL8198F_SUPPORT == 1)
2715
case ODM_RTL8198F:
2716
if (dpk_info->dpk_path_ok > 0)
2717
dpk_reload_8198f(dm);
2718
break;
2719
#endif
2720
2721
#if (RTL8814B_SUPPORT == 1)
2722
case ODM_RTL8814B:
2723
if (dpk_info->dpk_path_ok > 0)
2724
dpk_reload_8814b(dm);
2725
break;
2726
#endif
2727
2728
#endif
2729
default:
2730
break;
2731
}
2732
}
2733
2734
void halrf_dpk_info_rsvd_page(void *dm_void, u8 *buf, u32 *buf_size)
2735
{
2736
struct dm_struct *dm = (struct dm_struct *)dm_void;
2737
struct _hal_rf_ *rf = &dm->rf_table;
2738
struct dm_dpk_info *dpk_info = &dm->dpk_info;
2739
2740
if (!(rf->rf_supportability & HAL_RF_DPK) || rf->is_dpk_in_progress)
2741
return;
2742
2743
switch (dm->support_ic_type) {
2744
#if (RTL8822C_SUPPORT == 1)
2745
case ODM_RTL8822C:
2746
dpk_info_rsvd_page_8822c(dm, buf, buf_size);
2747
break;
2748
#endif
2749
default:
2750
break;
2751
}
2752
}
2753
2754
void halrf_iqk_info_rsvd_page(void *dm_void, u8 *buf, u32 *buf_size)
2755
{
2756
struct dm_struct *dm = (struct dm_struct *)dm_void;
2757
struct _hal_rf_ *rf = &dm->rf_table;
2758
2759
if (!(rf->rf_supportability & HAL_RF_IQK))
2760
return;
2761
2762
if (dm->rf_calibrate_info.is_iqk_in_progress)
2763
return;
2764
2765
switch (dm->support_ic_type) {
2766
#if (RTL8822C_SUPPORT == 1)
2767
case ODM_RTL8822C:
2768
iqk_info_rsvd_page_8822c(dm, buf, buf_size);
2769
break;
2770
#endif
2771
default:
2772
break;
2773
}
2774
}
2775
2776
enum hal_status
2777
halrf_config_rfk_with_header_file(void *dm_void, u32 config_type)
2778
{
2779
struct dm_struct *dm = (struct dm_struct *)dm_void;
2780
enum hal_status result = HAL_STATUS_SUCCESS;
2781
#if 0
2782
#if (RTL8822B_SUPPORT == 1)
2783
if (dm->support_ic_type == ODM_RTL8822B) {
2784
if (config_type == CONFIG_BB_RF_CAL_INIT)
2785
odm_read_and_config_mp_8822b_cal_init(dm);
2786
}
2787
#endif
2788
#endif
2789
#if (RTL8197G_SUPPORT == 1)
2790
if (dm->support_ic_type == ODM_RTL8197G) {
2791
if (config_type == CONFIG_BB_RF_CAL_INIT)
2792
odm_read_and_config_mp_8197g_cal_init(dm);
2793
}
2794
#endif
2795
#if (RTL8198F_SUPPORT == 1)
2796
if (dm->support_ic_type == ODM_RTL8198F) {
2797
if (config_type == CONFIG_BB_RF_CAL_INIT)
2798
odm_read_and_config_mp_8198f_cal_init(dm);
2799
}
2800
#endif
2801
#if (RTL8812F_SUPPORT == 1)
2802
if (dm->support_ic_type == ODM_RTL8812F) {
2803
if (config_type == CONFIG_BB_RF_CAL_INIT)
2804
odm_read_and_config_mp_8812f_cal_init(dm);
2805
}
2806
#endif
2807
#if (RTL8822C_SUPPORT == 1)
2808
if (dm->support_ic_type == ODM_RTL8822C) {
2809
if (config_type == CONFIG_BB_RF_CAL_INIT)
2810
odm_read_and_config_mp_8822c_cal_init(dm);
2811
}
2812
#endif
2813
#if (RTL8814B_SUPPORT == 1)
2814
if (dm->support_ic_type == ODM_RTL8814B) {
2815
if (config_type == CONFIG_BB_RF_CAL_INIT)
2816
odm_read_and_config_mp_8814b_cal_init(dm);
2817
}
2818
#endif
2819
#if (RTL8195B_SUPPORT == 1)
2820
if (dm->support_ic_type == ODM_RTL8195B) {
2821
if (config_type == CONFIG_BB_RF_CAL_INIT)
2822
odm_read_and_config_mp_8195b_cal_init(dm);
2823
}
2824
#endif
2825
#if (RTL8721D_SUPPORT == 1)
2826
if (dm->support_ic_type == ODM_RTL8721D) {
2827
if (config_type == CONFIG_BB_RF_CAL_INIT)
2828
odm_read_and_config_mp_8721d_cal_init(dm);
2829
}
2830
#endif
2831
2832
return result;
2833
}
2834
2835
void halrf_txgapk_trigger(void *dm_void)
2836
{
2837
struct dm_struct *dm = (struct dm_struct *)dm_void;
2838
struct _hal_rf_ *rf = &dm->rf_table;
2839
2840
u64 start_time;
2841
2842
start_time = odm_get_current_time(dm);
2843
2844
switch (dm->support_ic_type) {
2845
#if (DM_ODM_SUPPORT_TYPE & (ODM_IOT))
2846
#if (RTL8195B_SUPPORT == 1)
2847
case ODM_RTL8195B:
2848
phy_txgap_calibrate_8195b(dm, false);
2849
break;
2850
#endif
2851
#if (RTL8721D_SUPPORT == 1)
2852
case ODM_RTL8721D:
2853
phy_txgap_calibrate_8721d(dm, false);
2854
break;
2855
#endif
2856
2857
#endif
2858
2859
default:
2860
break;
2861
}
2862
rf->dpk_progressing_time =
2863
odm_get_progressing_time(dm_void, start_time);
2864
RF_DBG(dm, DBG_RF_TXGAPK, "[TGGC]TXGAPK progressing_time = %lld ms\n",
2865
rf->dpk_progressing_time);
2866
}
2867
2868
void halrf_tssi_get_efuse(void *dm_void)
2869
{
2870
struct dm_struct *dm = (struct dm_struct *)dm_void;
2871
2872
#if (RTL8822C_SUPPORT == 1)
2873
if (dm->support_ic_type & ODM_RTL8822C) {
2874
halrf_tssi_get_efuse_8822c(dm);
2875
halrf_get_efuse_thermal_pwrtype_8822c(dm);
2876
}
2877
#endif
2878
2879
#if (RTL8812F_SUPPORT == 1)
2880
if (dm->support_ic_type & ODM_RTL8812F) {
2881
halrf_tssi_get_efuse_8812f(dm);
2882
}
2883
#endif
2884
2885
#if (RTL8814B_SUPPORT == 1)
2886
if (dm->support_ic_type & ODM_RTL8814B) {
2887
halrf_tssi_get_efuse_8814b(dm);
2888
halrf_get_efuse_thermal_pwrtype_8814b(dm);
2889
}
2890
#endif
2891
2892
#if (RTL8197G_SUPPORT == 1)
2893
if (dm->support_ic_type & ODM_RTL8197G) {
2894
halrf_tssi_get_efuse_8197g(dm);
2895
}
2896
#endif
2897
2898
}
2899
2900
void halrf_do_rxbb_dck(void *dm_void)
2901
{
2902
struct dm_struct *dm = (struct dm_struct *)dm_void;
2903
2904
2905
#if (RTL8814B_SUPPORT == 1)
2906
if (dm->support_ic_type == ODM_RTL8814B)
2907
halrf_do_rxbb_dck_8814b(dm);
2908
#endif
2909
2910
}
2911
2912
void halrf_do_tssi(void *dm_void)
2913
{
2914
struct dm_struct *dm = (struct dm_struct *)dm_void;
2915
2916
#if (RTL8822C_SUPPORT == 1)
2917
if (dm->support_ic_type == ODM_RTL8822C)
2918
halrf_do_tssi_8822c(dm);
2919
#endif
2920
2921
#if (RTL8812F_SUPPORT == 1)
2922
if (dm->support_ic_type == ODM_RTL8812F)
2923
halrf_do_tssi_8812f(dm);
2924
#endif
2925
2926
#if (RTL8197G_SUPPORT == 1)
2927
if (dm->support_ic_type == ODM_RTL8197G)
2928
halrf_do_tssi_8197g(dm);
2929
#endif
2930
2931
}
2932
2933
void halrf_do_thermal(void *dm_void)
2934
{
2935
struct dm_struct *dm = (struct dm_struct *)dm_void;
2936
2937
#if (RTL8822C_SUPPORT == 1)
2938
if (dm->support_ic_type & ODM_RTL8822C)
2939
halrf_do_thermal_8822c(dm);
2940
#endif
2941
}
2942
2943
2944
2945
u32 halrf_set_tssi_value(void *dm_void, u32 tssi_value)
2946
{
2947
struct dm_struct *dm = (struct dm_struct *)dm_void;
2948
2949
#if (RTL8822C_SUPPORT == 1)
2950
if (dm->support_ic_type & ODM_RTL8822C)
2951
return halrf_set_tssi_value_8822c(dm, tssi_value);
2952
#endif
2953
2954
#if (RTL8814B_SUPPORT == 1)
2955
if (dm->support_ic_type & ODM_RTL8814B)
2956
return halrf_set_tssi_value_8814b(dm, tssi_value);
2957
#endif
2958
2959
return 0;
2960
}
2961
2962
void halrf_set_tssi_power(void *dm_void, s8 power)
2963
{
2964
struct dm_struct *dm = (struct dm_struct *)dm_void;
2965
2966
#if (RTL8822C_SUPPORT == 1)
2967
/*halrf_set_tssi_poewr_8822c(dm, power);*/
2968
#endif
2969
}
2970
2971
void halrf_tssi_set_de_for_tx_verify(void *dm_void, u32 tssi_de, u8 path)
2972
{
2973
struct dm_struct *dm = (struct dm_struct *)dm_void;
2974
2975
#if (RTL8822C_SUPPORT == 1)
2976
if (dm->support_ic_type & ODM_RTL8822C)
2977
halrf_tssi_set_de_for_tx_verify_8822c(dm, tssi_de, path);
2978
#endif
2979
2980
#if (RTL8814B_SUPPORT == 1)
2981
if (dm->support_ic_type & ODM_RTL8814B)
2982
halrf_tssi_set_de_for_tx_verify_8814b(dm, tssi_de, path);
2983
#endif
2984
2985
#if (RTL8812F_SUPPORT == 1)
2986
if (dm->support_ic_type & ODM_RTL8812F)
2987
halrf_tssi_set_de_for_tx_verify_8812f(dm, tssi_de, path);
2988
#endif
2989
2990
2991
}
2992
2993
u32 halrf_query_tssi_value(void *dm_void)
2994
{
2995
struct dm_struct *dm = (struct dm_struct *)dm_void;
2996
2997
#if (RTL8822C_SUPPORT == 1)
2998
if (dm->support_ic_type & ODM_RTL8822C)
2999
return halrf_query_tssi_value_8822c(dm);
3000
#endif
3001
3002
#if (RTL8814B_SUPPORT == 1)
3003
if (dm->support_ic_type & ODM_RTL8814B)
3004
return halrf_query_tssi_value_8814b(dm);
3005
#endif
3006
return 0;
3007
}
3008
3009
void halrf_tssi_cck(void *dm_void)
3010
{
3011
struct dm_struct *dm = (struct dm_struct *)dm_void;
3012
3013
#if (RTL8822C_SUPPORT == 1)
3014
/*halrf_tssi_cck_8822c(dm);*/
3015
if (dm->support_ic_type & ODM_RTL8822C)
3016
halrf_thermal_cck_8822c(dm);
3017
#endif
3018
3019
}
3020
3021
void halrf_thermal_cck(void *dm_void)
3022
{
3023
struct dm_struct *dm = (struct dm_struct *)dm_void;
3024
3025
#if (RTL8822C_SUPPORT == 1)
3026
if (dm->support_ic_type & ODM_RTL8822C)
3027
halrf_thermal_cck_8822c(dm);
3028
#endif
3029
3030
}
3031
3032
void halrf_tssi_set_de(void *dm_void)
3033
{
3034
struct dm_struct *dm = (struct dm_struct *)dm_void;
3035
3036
#if (RTL8814B_SUPPORT == 1)
3037
if (dm->support_ic_type & ODM_RTL8814B)
3038
halrf_tssi_set_de_8814b(dm);
3039
#endif
3040
}
3041
3042
void halrf_tssi_dck(void *dm_void, u8 direct_do)
3043
{
3044
struct dm_struct *dm = (struct dm_struct *)dm_void;
3045
3046
halrf_rfk_handshake(dm, true);
3047
3048
#if (RTL8814B_SUPPORT == 1)
3049
if (dm->support_ic_type & ODM_RTL8814B)
3050
halrf_tssi_dck_8814b(dm, direct_do);
3051
#endif
3052
3053
#if (RTL8822C_SUPPORT == 1)
3054
if (dm->support_ic_type & ODM_RTL8822C)
3055
halrf_tssi_dck_8822c(dm);
3056
#endif
3057
3058
#if (RTL8812F_SUPPORT == 1)
3059
if (dm->support_ic_type & ODM_RTL8812F)
3060
halrf_tssi_dck_8812f(dm);
3061
#endif
3062
3063
#if (RTL8197G_SUPPORT == 1)
3064
if (dm->support_ic_type == ODM_RTL8197G)
3065
halrf_tssi_dck_8197g(dm);
3066
#endif
3067
3068
halrf_rfk_handshake(dm, false);
3069
3070
}
3071
3072
void halrf_calculate_tssi_codeword(void *dm_void)
3073
{
3074
struct dm_struct *dm = (struct dm_struct *)dm_void;
3075
3076
#if (RTL8814B_SUPPORT == 1)
3077
if (dm->support_ic_type & ODM_RTL8814B)
3078
halrf_calculate_tssi_codeword_8814b(dm, RF_PATH_A);
3079
#endif
3080
3081
}
3082
3083
void halrf_set_tssi_codeword(void *dm_void)
3084
{
3085
struct dm_struct *dm = (struct dm_struct *)dm_void;
3086
struct _hal_rf_ *rf = &dm->rf_table;
3087
struct _halrf_tssi_data *tssi = &rf->halrf_tssi_data;
3088
3089
#if (RTL8814B_SUPPORT == 1)
3090
if (dm->support_ic_type & ODM_RTL8814B)
3091
halrf_set_tssi_codeword_8814b(dm, tssi->tssi_codeword);
3092
#endif
3093
}
3094
3095
u8 halrf_get_tssi_codeword_for_txindex(void *dm_void)
3096
{
3097
struct dm_struct *dm = (struct dm_struct *)dm_void;
3098
3099
#if (RTL8814B_SUPPORT == 1)
3100
if (dm->support_ic_type & ODM_RTL8814B)
3101
return 60;
3102
/*return halrf_get_tssi_codeword_8814b(dm);*/
3103
#endif
3104
3105
#if (RTL8822C_SUPPORT == 1)
3106
if (dm->support_ic_type & ODM_RTL8822C)
3107
return 64;
3108
#endif
3109
3110
#if (RTL8812F_SUPPORT == 1)
3111
if (dm->support_ic_type & ODM_RTL8812F)
3112
return 100;
3113
#endif
3114
3115
#if (RTL8197G_SUPPORT == 1)
3116
if (dm->support_ic_type & ODM_RTL8197G)
3117
return 100;
3118
#endif
3119
3120
return 60;
3121
}
3122
3123
u32 halrf_tssi_get_de(void *dm_void, u8 path)
3124
{
3125
struct dm_struct *dm = (struct dm_struct *)dm_void;
3126
3127
#if (RTL8822C_SUPPORT == 1)
3128
if (dm->support_ic_type & ODM_RTL8822C)
3129
return halrf_tssi_get_de_8822c(dm, path);
3130
#endif
3131
3132
#if (RTL8812F_SUPPORT == 1)
3133
if (dm->support_ic_type & ODM_RTL8812F)
3134
return halrf_tssi_get_de_8812f(dm, path);
3135
#endif
3136
3137
#if (RTL8814B_SUPPORT == 1)
3138
if (dm->support_ic_type & ODM_RTL8814B)
3139
return halrf_tssi_get_de_8814b(dm, path);
3140
#endif
3141
3142
#if (RTL8197G_SUPPORT == 1)
3143
if (dm->support_ic_type & ODM_RTL8197G)
3144
return halrf_tssi_get_de_8197g(dm, path);
3145
#endif
3146
return 0;
3147
}
3148
3149
void halrf_tssi_trigger(void *dm_void)
3150
{
3151
struct dm_struct *dm = (struct dm_struct *)dm_void;
3152
3153
halrf_calculate_tssi_codeword(dm);
3154
halrf_set_tssi_codeword(dm);
3155
halrf_tssi_dck(dm, false);
3156
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
3157
halrf_tssi_get_efuse(dm);
3158
#endif
3159
halrf_tssi_set_de(dm);
3160
halrf_do_tssi(dm);
3161
}
3162
3163
/*Golbal function*/
3164
void halrf_reload_bp(void *dm_void, u32 *bp_reg, u32 *bp, u32 num)
3165
{
3166
struct dm_struct *dm = (struct dm_struct *)dm_void;
3167
u32 i;
3168
3169
for (i = 0; i < num; i++)
3170
odm_write_4byte(dm, bp_reg[i], bp[i]);
3171
}
3172
3173
void halrf_reload_bprf(void *dm_void, u32 *bp_reg, u32 bp[][4], u32 num,
3174
u8 ss)
3175
{
3176
struct dm_struct *dm = (struct dm_struct *)dm_void;
3177
u32 i, path;
3178
3179
for (i = 0; i < num; i++) {
3180
for (path = 0; path < ss; path++)
3181
odm_set_rf_reg(dm, (enum rf_path)path, bp_reg[i],
3182
MASK20BITS, bp[i][path]);
3183
}
3184
}
3185
3186
void halrf_bp(void *dm_void, u32 *bp_reg, u32 *bp, u32 num)
3187
{
3188
struct dm_struct *dm = (struct dm_struct *)dm_void;
3189
u32 i;
3190
3191
for (i = 0; i < num; i++)
3192
bp[i] = odm_read_4byte(dm, bp_reg[i]);
3193
}
3194
3195
void halrf_bprf(void *dm_void, u32 *bp_reg, u32 bp[][4], u32 num, u8 ss)
3196
{
3197
struct dm_struct *dm = (struct dm_struct *)dm_void;
3198
u32 i, path;
3199
3200
for (i = 0; i < num; i++) {
3201
for (path = 0; path < ss; path++) {
3202
bp[i][path] =
3203
odm_get_rf_reg(dm, (enum rf_path)path,
3204
bp_reg[i], MASK20BITS);
3205
}
3206
}
3207
}
3208
3209
void halrf_swap(void *dm_void, u32 *v1, u32 *v2)
3210
{
3211
struct dm_struct *dm = (struct dm_struct *)dm_void;
3212
u32 temp;
3213
3214
temp = *v1;
3215
*v1 = *v2;
3216
*v2 = temp;
3217
}
3218
3219
void halrf_bubble(void *dm_void, u32 *v1, u32 *v2)
3220
{
3221
struct dm_struct *dm = (struct dm_struct *)dm_void;
3222
u32 temp;
3223
3224
if (*v1 >= 0x200 && *v2 >= 0x200) {
3225
if (*v1 > *v2)
3226
halrf_swap(dm, v1, v2);
3227
} else if (*v1 < 0x200 && *v2 < 0x200) {
3228
if (*v1 > *v2)
3229
halrf_swap(dm, v1, v2);
3230
} else if (*v1 < 0x200 && *v2 >= 0x200) {
3231
halrf_swap(dm, v1, v2);
3232
}
3233
}
3234
3235
void halrf_b_sort(void *dm_void, u32 *iv, u32 *qv)
3236
{
3237
struct dm_struct *dm = (struct dm_struct *)dm_void;
3238
u32 temp;
3239
u32 i, j;
3240
3241
RF_DBG(dm, DBG_RF_DACK, "[DACK]bubble!!!!!!!!!!!!");
3242
for (i = 0; i < SN - 1; i++) {
3243
for (j = 0; j < (SN - 1 - i) ; j++) {
3244
halrf_bubble(dm, &iv[j], &iv[j + 1]);
3245
halrf_bubble(dm, &qv[j], &qv[j + 1]);
3246
}
3247
}
3248
}
3249
3250
void halrf_minmax_compare(void *dm_void, u32 value, u32 *min,
3251
u32 *max)
3252
{
3253
struct dm_struct *dm = (struct dm_struct *)dm_void;
3254
3255
if (value >= 0x200) {
3256
if (*min >= 0x200) {
3257
if (*min > value)
3258
*min = value;
3259
} else {
3260
*min = value;
3261
}
3262
if (*max >= 0x200) {
3263
if (*max < value)
3264
*max = value;
3265
}
3266
} else {
3267
if (*min < 0x200) {
3268
if (*min > value)
3269
*min = value;
3270
}
3271
3272
if (*max >= 0x200) {
3273
*max = value;
3274
} else {
3275
if (*max < value)
3276
*max = value;
3277
}
3278
}
3279
}
3280
3281
u32 halrf_delta(void *dm_void, u32 v1, u32 v2)
3282
{
3283
struct dm_struct *dm = (struct dm_struct *)dm_void;
3284
3285
if (v1 >= 0x200 && v2 >= 0x200) {
3286
if (v1 > v2)
3287
return v1 - v2;
3288
else
3289
return v2 - v1;
3290
} else if (v1 >= 0x200 && v2 < 0x200) {
3291
return v2 + (0x400 - v1);
3292
} else if (v1 < 0x200 && v2 >= 0x200) {
3293
return v1 + (0x400 - v2);
3294
}
3295
3296
if (v1 > v2)
3297
return v1 - v2;
3298
else
3299
return v2 - v1;
3300
}
3301
3302
boolean halrf_compare(void *dm_void, u32 value)
3303
{
3304
struct dm_struct *dm = (struct dm_struct *)dm_void;
3305
3306
boolean fail = false;
3307
3308
if (value >= 0x200 && (0x400 - value) > 0x64)
3309
fail = true;
3310
else if (value < 0x200 && value > 0x64)
3311
fail = true;
3312
3313
if (fail)
3314
RF_DBG(dm, DBG_RF_DACK, "[DACK]overflow!!!!!!!!!!!!!!!");
3315
return fail;
3316
}
3317
3318
void halrf_mode(void *dm_void, u32 *i_value, u32 *q_value)
3319
{
3320
struct dm_struct *dm = (struct dm_struct *)dm_void;
3321
u32 iv[SN], qv[SN], im[SN], qm[SN], temp, temp1, temp2;
3322
u32 p, m, t;
3323
u32 i_max = 0, q_max = 0, i_min = 0x0, q_min = 0x0, c = 0x0;
3324
u32 i_delta, q_delta;
3325
u8 i, j, ii = 0, qi = 0;
3326
boolean fail = false;
3327
3328
ODM_delay_ms(10);
3329
for (i = 0; i < SN; i++) {
3330
im[i] = 0;
3331
qm[i] = 0;
3332
}
3333
i = 0;
3334
c = 0;
3335
while (i < SN && c < 1000) {
3336
c++;
3337
temp = odm_get_bb_reg(dm, 0x2dbc, 0x3fffff);
3338
iv[i] = (temp & 0x3ff000) >> 12;
3339
qv[i] = temp & 0x3ff;
3340
3341
fail = false;
3342
if (halrf_compare(dm, iv[i]))
3343
fail = true;
3344
if (halrf_compare(dm, qv[i]))
3345
fail = true;
3346
if (!fail)
3347
i++;
3348
}
3349
c = 0;
3350
do {
3351
c++;
3352
i_min = iv[0];
3353
i_max = iv[0];
3354
q_min = qv[0];
3355
q_max = qv[0];
3356
for (i = 0; i < SN; i++) {
3357
halrf_minmax_compare(dm, iv[i], &i_min, &i_max);
3358
halrf_minmax_compare(dm, qv[i], &q_min, &q_max);
3359
}
3360
RF_DBG(dm, DBG_RF_DACK, "[DACK]i_min=0x%x, i_max=0x%x",
3361
i_min, i_max);
3362
RF_DBG(dm, DBG_RF_DACK, "[DACK]q_min=0x%x, q_max=0x%x",
3363
q_min, q_max);
3364
if (i_max < 0x200 && i_min < 0x200)
3365
i_delta = i_max - i_min;
3366
else if (i_max >= 0x200 && i_min >= 0x200)
3367
i_delta = i_max - i_min;
3368
else
3369
i_delta = i_max + (0x400 - i_min);
3370
3371
if (q_max < 0x200 && q_min < 0x200)
3372
q_delta = q_max - q_min;
3373
else if (q_max >= 0x200 && q_min >= 0x200)
3374
q_delta = q_max - q_min;
3375
else
3376
q_delta = q_max + (0x400 - q_min);
3377
RF_DBG(dm, DBG_RF_DACK, "[DACK]i_delta=0x%x, q_delta=0x%x",
3378
i_delta, q_delta);
3379
halrf_b_sort(dm, iv, qv);
3380
if (i_delta > 5 || q_delta > 5) {
3381
temp = odm_get_bb_reg(dm, 0x2dbc, 0x3fffff);
3382
iv[0] = (temp & 0x3ff000) >> 12;
3383
qv[0] = temp & 0x3ff;
3384
temp = odm_get_bb_reg(dm, 0x2dbc, 0x3fffff);
3385
iv[SN - 1] = (temp & 0x3ff000) >> 12;
3386
qv[SN - 1] = temp & 0x3ff;
3387
} else {
3388
break;
3389
}
3390
} while (c < 100);
3391
#if 1
3392
#if 0
3393
for (i = 0; i < SN; i++)
3394
RF_DBG(dm, DBG_RF_DACK, "[DACK]iv[%d] = 0x%x\n", i, iv[i]);
3395
for (i = 0; i < SN; i++)
3396
RF_DBG(dm, DBG_RF_DACK, "[DACK]qv[%d] = 0x%x\n", i, qv[i]);
3397
#endif
3398
/*i*/
3399
m = 0;
3400
p = 0;
3401
for (i = 10; i < SN - 10; i++) {
3402
if (iv[i] > 0x200)
3403
m = (0x400 - iv[i]) + m;
3404
else
3405
p = iv[i] + p;
3406
}
3407
3408
if (p > m) {
3409
t = p - m;
3410
t = t / (SN - 20);
3411
} else {
3412
t = m - p;
3413
t = t / (SN - 20);
3414
if (t != 0x0)
3415
t = 0x400 - t;
3416
}
3417
*i_value = t;
3418
/*q*/
3419
m = 0;
3420
p = 0;
3421
for (i = 10; i < SN - 10; i++) {
3422
if (qv[i] > 0x200)
3423
m = (0x400 - qv[i]) + m;
3424
else
3425
p = qv[i] + p;
3426
}
3427
if (p > m) {
3428
t = p - m;
3429
t = t / (SN - 20);
3430
} else {
3431
t = m - p;
3432
t = t / (SN - 20);
3433
if (t != 0x0)
3434
t = 0x400 - t;
3435
}
3436
*q_value = t;
3437
#endif
3438
}
3439
3440
3441