1
0
mirror of https://github.com/aircrack-ng/rtl8812au.git synced 2024-11-14 18:05:36 +00:00
rtl8812au/hal/phydm/halrf/halrf.c

2396 lines
56 KiB
C
Raw Normal View History

2018-06-22 16:48:32 +00:00
/******************************************************************************
*
2018-08-24 20:52:34 +00:00
* Copyright(c) 2007 - 2017 Realtek Corporation.
2018-06-22 16:48:32 +00:00
*
* 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
2018-08-24 20:52:34 +00:00
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
2018-06-22 16:48:32 +00:00
* more details.
*
2018-08-24 20:52:34 +00:00
* The full GNU General Public License is included in this distribution in the
* file called LICENSE.
*
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
* Hsinchu 300, Taiwan.
*
* Larry Finger <Larry.Finger@lwfinger.net>
*
2018-06-22 16:48:32 +00:00
*****************************************************************************/
2019-05-24 19:43:57 +00:00
/*@************************************************************
2018-06-22 16:48:32 +00:00
* include files
2019-05-24 19:43:57 +00:00
* ************************************************************
*/
2018-06-22 16:48:32 +00:00
#include "mp_precomp.h"
#include "phydm_precomp.h"
2019-05-24 19:43:57 +00:00
#if (RTL8822B_SUPPORT == 1 || RTL8821C_SUPPORT == 1 ||\
RTL8195B_SUPPORT == 1 || RTL8198F_SUPPORT == 1 ||\
RTL8814B_SUPPORT == 1 || RTL8822C_SUPPORT == 1)
void _iqk_page_switch(void *dm_void)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
if (dm->support_ic_type == ODM_RTL8821C)
2018-08-24 20:52:34 +00:00
odm_write_4byte(dm, 0x1b00, 0xf8000008);
2019-05-24 19:43:57 +00:00
else
2018-08-24 20:52:34 +00:00
odm_write_4byte(dm, 0x1b00, 0xf800000a);
2018-06-22 16:48:32 +00:00
}
2018-08-24 20:52:34 +00:00
u32 halrf_psd_log2base(u32 val)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
u8 j;
u32 tmp, tmp2, val_integerd_b = 0, tindex, shiftcount = 0;
u32 result, val_fractiond_b = 0;
u32 table_fraction[21] = {
0, 432, 332, 274, 232, 200, 174, 151, 132, 115,
100, 86, 74, 62, 51, 42, 32, 23, 15, 7, 0};
2018-06-22 16:48:32 +00:00
if (val == 0)
return 0;
tmp = val;
while (1) {
if (tmp == 1)
break;
tmp = (tmp >> 1);
shiftcount++;
}
val_integerd_b = shiftcount + 1;
tmp2 = 1;
for (j = 1; j <= val_integerd_b; j++)
tmp2 = tmp2 * 2;
tmp = (val * 100) / tmp2;
tindex = tmp / 5;
if (tindex > 20)
tindex = 20;
val_fractiond_b = table_fraction[tindex];
result = val_integerd_b * 100 - val_fractiond_b;
2019-05-24 19:43:57 +00:00
return result;
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
void phydm_get_iqk_cfir(void *dm_void, u8 idx, u8 path, boolean debug)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct dm_iqk_info *iqk_info = &dm->IQK_info;
2018-06-22 16:48:32 +00:00
u8 i, ch;
u32 tmp;
2019-05-24 19:43:57 +00:00
u32 bit_mask_20_16 = BIT(20) | BIT(19) | BIT(18) | BIT(17) | BIT(16);
2018-06-22 16:48:32 +00:00
if (debug)
ch = 2;
else
ch = 0;
2019-05-24 19:43:57 +00:00
odm_set_bb_reg(dm, R_0x1b00, MASKDWORD, 0xf8000008 | path << 1);
if (idx == 0)
odm_set_bb_reg(dm, R_0x1b0c, BIT(13) | BIT(12), 0x3);
else
odm_set_bb_reg(dm, R_0x1b0c, BIT(13) | BIT(12), 0x1);
odm_set_bb_reg(dm, R_0x1bd4, bit_mask_20_16, 0x10);
for (i = 0; i < 8; i++) {
odm_set_bb_reg(dm, R_0x1bd8, MASKDWORD, 0xe0000001 + (i * 4));
tmp = odm_get_bb_reg(dm, R_0x1bfc, MASKDWORD);
iqk_info->iqk_cfir_real[ch][path][idx][i] =
(tmp & 0x0fff0000) >> 16;
iqk_info->iqk_cfir_imag[ch][path][idx][i] = tmp & 0xfff;
}
odm_set_bb_reg(dm, R_0x1bd8, MASKDWORD, 0x0);
odm_set_bb_reg(dm, R_0x1b0c, BIT(13) | BIT(12), 0x0);
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
void halrf_iqk_xym_enable(struct dm_struct *dm, u8 xym_enable)
2018-06-22 16:48:32 +00:00
{
2018-08-24 20:52:34 +00:00
struct dm_iqk_info *iqk_info = &dm->IQK_info;
2018-06-22 16:48:32 +00:00
if (xym_enable == 0)
2018-08-24 20:52:34 +00:00
iqk_info->xym_read = false;
2018-06-22 16:48:32 +00:00
else
2018-08-24 20:52:34 +00:00
iqk_info->xym_read = true;
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_IQK, "[IQK]%-20s %s\n", "xym_read = ",
(iqk_info->xym_read ? "true" : "false"));
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
/*xym_type => 0: rx_sym; 1: tx_xym; 2:gs1_xym; 3:gs2_sym; 4: rxk1_xym*/
void halrf_iqk_xym_read(void *dm_void, u8 path, u8 xym_type)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct dm_iqk_info *iqk_info = &dm->IQK_info;
2018-06-22 16:48:32 +00:00
u8 i, start, num;
u32 tmp1, tmp2;
2018-08-24 20:52:34 +00:00
if (!iqk_info->xym_read)
2018-06-22 16:48:32 +00:00
return;
2018-08-24 20:52:34 +00:00
if (*dm->band_width == 0) {
2018-06-22 16:48:32 +00:00
start = 3;
num = 4;
2019-05-24 19:43:57 +00:00
} else if (*dm->band_width == 1) {
2018-06-22 16:48:32 +00:00
start = 2;
num = 6;
2019-05-24 19:43:57 +00:00
} else {
2018-06-22 16:48:32 +00:00
start = 0;
2019-05-24 19:43:57 +00:00
num = 10;
}
2018-08-24 20:52:34 +00:00
odm_write_4byte(dm, 0x1b00, 0xf8000008);
2019-05-24 19:43:57 +00:00
tmp1 = odm_read_4byte(dm, 0x1b1c);
2018-08-24 20:52:34 +00:00
odm_write_4byte(dm, 0x1b1c, 0xa2193c32);
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
odm_write_4byte(dm, 0x1b00, 0xf800000a);
tmp2 = odm_read_4byte(dm, 0x1b1c);
2018-08-24 20:52:34 +00:00
odm_write_4byte(dm, 0x1b1c, 0xa2193c32);
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
for (path = 0; path < 2; path++) {
2018-08-24 20:52:34 +00:00
odm_write_4byte(dm, 0x1b00, 0xf8000008 | path << 1);
2019-05-24 19:43:57 +00:00
switch (xym_type) {
case 0:
for (i = 0; i < num; i++) {
odm_write_4byte(dm, 0x1b14, 0xe6 + start + i);
odm_write_4byte(dm, 0x1b14, 0x0);
iqk_info->rx_xym[path][i] =
odm_read_4byte(dm, 0x1b38);
}
break;
case 1:
for (i = 0; i < num; i++) {
odm_write_4byte(dm, 0x1b14, 0xe6 + start + i);
odm_write_4byte(dm, 0x1b14, 0x0);
iqk_info->tx_xym[path][i] =
odm_read_4byte(dm, 0x1b38);
}
2018-06-22 16:48:32 +00:00
break;
2019-05-24 19:43:57 +00:00
case 2:
for (i = 0; i < 6; i++) {
odm_write_4byte(dm, 0x1b14, 0xe0 + i);
odm_write_4byte(dm, 0x1b14, 0x0);
iqk_info->gs1_xym[path][i] =
odm_read_4byte(dm, 0x1b38);
}
2018-06-22 16:48:32 +00:00
break;
2019-05-24 19:43:57 +00:00
case 3:
for (i = 0; i < 6; i++) {
odm_write_4byte(dm, 0x1b14, 0xe0 + i);
odm_write_4byte(dm, 0x1b14, 0x0);
iqk_info->gs2_xym[path][i] =
odm_read_4byte(dm, 0x1b38);
}
2018-06-22 16:48:32 +00:00
break;
2019-05-24 19:43:57 +00:00
case 4:
for (i = 0; i < 6; i++) {
odm_write_4byte(dm, 0x1b14, 0xe0 + i);
odm_write_4byte(dm, 0x1b14, 0x0);
iqk_info->rxk1_xym[path][i] =
odm_read_4byte(dm, 0x1b38);
}
2018-06-22 16:48:32 +00:00
break;
}
2018-08-24 20:52:34 +00:00
odm_write_4byte(dm, 0x1b38, 0x20000000);
odm_write_4byte(dm, 0x1b00, 0xf8000008);
odm_write_4byte(dm, 0x1b1c, tmp1);
odm_write_4byte(dm, 0x1b00, 0xf800000a);
odm_write_4byte(dm, 0x1b1c, tmp2);
_iqk_page_switch(dm);
2018-06-22 16:48:32 +00:00
}
}
2019-05-24 19:43:57 +00:00
/*xym_type => 0: rx_sym; 1: tx_xym; 2:gs1_xym; 3:gs2_sym; 4: rxk1_xym*/
void halrf_iqk_xym_show(struct dm_struct *dm, u8 xym_type)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
u8 num, path, path_num, i;
struct dm_iqk_info *iqk_info = &dm->IQK_info;
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
if (dm->rf_type == RF_1T1R)
2018-06-22 16:48:32 +00:00
path_num = 0x1;
2019-05-24 19:43:57 +00:00
else if (dm->rf_type == RF_2T2R)
2018-06-22 16:48:32 +00:00
path_num = 0x2;
else
path_num = 0x4;
2018-08-24 20:52:34 +00:00
if (*dm->band_width == CHANNEL_WIDTH_20)
2018-06-22 16:48:32 +00:00
num = 4;
2018-08-24 20:52:34 +00:00
else if (*dm->band_width == CHANNEL_WIDTH_40)
2018-06-22 16:48:32 +00:00
num = 6;
else
num = 10;
2019-05-24 19:43:57 +00:00
for (path = 0; path < path_num; path++) {
switch (xym_type) {
2018-06-22 16:48:32 +00:00
case 0:
2019-05-24 19:43:57 +00:00
for (i = 0; i < num; i++)
RF_DBG(dm, DBG_RF_IQK,
"[IQK]%-20s %-2d: 0x%x\n",
(path == 0) ? "PATH A RX-XYM " :
"PATH B RX-XYM", i,
iqk_info->rx_xym[path][i]);
2018-06-22 16:48:32 +00:00
break;
case 1:
2019-05-24 19:43:57 +00:00
for (i = 0; i < num; i++)
RF_DBG(dm, DBG_RF_IQK,
"[IQK]%-20s %-2d: 0x%x\n",
(path == 0) ? "PATH A TX-XYM " :
"PATH B TX-XYM", i,
iqk_info->tx_xym[path][i]);
2018-06-22 16:48:32 +00:00
break;
case 2:
2019-05-24 19:43:57 +00:00
for (i = 0; i < 6; i++)
RF_DBG(dm, DBG_RF_IQK,
"[IQK]%-20s %-2d: 0x%x\n",
(path == 0) ? "PATH A GS1-XYM " :
"PATH B GS1-XYM", i,
iqk_info->gs1_xym[path][i]);
2018-06-22 16:48:32 +00:00
break;
case 3:
2019-05-24 19:43:57 +00:00
for (i = 0; i < 6; i++)
RF_DBG(dm, DBG_RF_IQK,
"[IQK]%-20s %-2d: 0x%x\n",
(path == 0) ? "PATH A GS2-XYM " :
"PATH B GS2-XYM", i,
iqk_info->gs2_xym[path][i]);
break;
case 4:
for (i = 0; i < 6; i++)
RF_DBG(dm, DBG_RF_IQK,
"[IQK]%-20s %-2d: 0x%x\n",
(path == 0) ? "PATH A RXK1-XYM " :
"PATH B RXK1-XYM", i,
iqk_info->rxk1_xym[path][i]);
2018-06-22 16:48:32 +00:00
break;
}
}
}
2019-05-24 19:43:57 +00:00
void halrf_iqk_xym_dump(void *dm_void)
2018-06-22 16:48:32 +00:00
{
u32 tmp1, tmp2;
2019-05-24 19:43:57 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-08-24 20:52:34 +00:00
odm_write_4byte(dm, 0x1b00, 0xf8000008);
2019-05-24 19:43:57 +00:00
tmp1 = odm_read_4byte(dm, 0x1b1c);
odm_write_4byte(dm, 0x1b00, 0xf800000a);
tmp2 = odm_read_4byte(dm, 0x1b1c);
#if 0
/*halrf_iqk_xym_read(dm, xym_type);*/
#endif
odm_write_4byte(dm, 0x1b00, 0xf8000008);
odm_write_4byte(dm, 0x1b1c, tmp1);
odm_write_4byte(dm, 0x1b00, 0xf800000a);
odm_write_4byte(dm, 0x1b1c, tmp2);
_iqk_page_switch(dm);
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
void halrf_iqk_info_dump(void *dm_void, u32 *_used, char *output, u32 *_out_len)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-06-22 16:48:32 +00:00
u32 used = *_used;
2019-05-24 19:43:57 +00:00
u32 out_len = *_out_len;
2018-06-22 16:48:32 +00:00
u8 rf_path, j, reload_iqk = 0;
u32 tmp;
2019-05-24 19:43:57 +00:00
/*two channel, PATH, TX/RX, 0:pass 1 :fail*/
boolean iqk_result[2][NUM][2];
struct dm_iqk_info *iqk_info = &dm->IQK_info;
2018-08-24 20:52:34 +00:00
2019-05-24 19:43:57 +00:00
if (!(dm->support_ic_type & (ODM_RTL8822B | ODM_RTL8821C)))
return;
2018-08-24 20:52:34 +00:00
2019-05-24 19:43:57 +00:00
/* IQK INFO */
PDM_SNPF(out_len, used, output + used, out_len - used, "%-20s\n",
"% IQK Info %");
PDM_SNPF(out_len, used, output + used, out_len - used, "%-20s\n",
(dm->fw_offload_ability & PHYDM_RF_IQK_OFFLOAD) ? "FW-IQK" :
"Driver-IQK");
reload_iqk = (u8)odm_get_bb_reg(dm, R_0x1bf0, BIT(16));
PDM_SNPF(out_len, used, output + used, out_len - used, "%-20s: %s\n",
"reload", (reload_iqk) ? "True" : "False");
PDM_SNPF(out_len, used, output + used, out_len - used, "%-20s: %s\n",
"rfk_forbidden", (iqk_info->rfk_forbidden) ? "True" : "False");
#if (RTL8814A_SUPPORT == 1 || RTL8822B_SUPPORT == 1 || \
RTL8821C_SUPPORT == 1 || RTL8195B_SUPPORT == 1 ||\
RTL8814B_SUPPORT == 1 || RTL8822C_SUPPORT == 1)
PDM_SNPF(out_len, used, output + used, out_len - used, "%-20s: %s\n",
"segment_iqk", (iqk_info->segment_iqk) ? "True" : "False");
2018-06-22 16:48:32 +00:00
#endif
2019-05-24 19:43:57 +00:00
PDM_SNPF(out_len, used, output + used, out_len - used, "%-20s:%d %d\n",
"iqk count / fail count", dm->n_iqk_cnt, dm->n_iqk_fail_cnt);
2018-08-24 20:52:34 +00:00
2019-05-24 19:43:57 +00:00
PDM_SNPF(out_len, used, output + used, out_len - used, "%-20s: %d\n",
"channel", *dm->channel);
2018-08-24 20:52:34 +00:00
if (*dm->band_width == CHANNEL_WIDTH_20)
PDM_SNPF(out_len, used, output + used, out_len - used,
2019-05-24 19:43:57 +00:00
"%-20s: %s\n", "bandwidth", "BW_20");
2018-08-24 20:52:34 +00:00
else if (*dm->band_width == CHANNEL_WIDTH_40)
PDM_SNPF(out_len, used, output + used, out_len - used,
2019-05-24 19:43:57 +00:00
"%-20s: %s\n", "bandwidth", "BW_40");
2018-08-24 20:52:34 +00:00
else if (*dm->band_width == CHANNEL_WIDTH_80)
PDM_SNPF(out_len, used, output + used, out_len - used,
2019-05-24 19:43:57 +00:00
"%-20s: %s\n", "bandwidth", "BW_80");
2018-08-24 20:52:34 +00:00
else if (*dm->band_width == CHANNEL_WIDTH_160)
PDM_SNPF(out_len, used, output + used, out_len - used,
2019-05-24 19:43:57 +00:00
"%-20s: %s\n", "bandwidth", "BW_160");
2018-06-22 16:48:32 +00:00
else
2018-08-24 20:52:34 +00:00
PDM_SNPF(out_len, used, output + used, out_len - used,
2019-05-24 19:43:57 +00:00
"%-20s: %s\n", "bandwidth", "BW_UNKNOWN");
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
PDM_SNPF(out_len, used, output + used, out_len - used,
2019-05-24 19:43:57 +00:00
"%-20s: %llu %s\n", "progressing_time",
dm->rf_calibrate_info.iqk_total_progressing_time, "(ms)");
2018-08-24 20:52:34 +00:00
tmp = odm_read_4byte(dm, 0x1bf0);
2019-05-24 19:43:57 +00:00
for (rf_path = RF_PATH_A; rf_path <= RF_PATH_B; rf_path++)
for (j = 0; j < 2; j++)
iqk_result[0][rf_path][j] = (boolean)
(tmp & (BIT(rf_path + (j * 4)) >> (rf_path + (j * 4))));
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
PDM_SNPF(out_len, used, output + used, out_len - used,
2019-05-24 19:43:57 +00:00
"%-20s: 0x%08x\n", "Reg0x1bf0", tmp);
PDM_SNPF(out_len, used, output + used, out_len - used, "%-20s: %s\n",
"PATH_A-Tx result",
(iqk_result[0][RF_PATH_A][0]) ? "Fail" : "Pass");
PDM_SNPF(out_len, used, output + used, out_len - used, "%-20s: %s\n",
"PATH_A-Rx result",
(iqk_result[0][RF_PATH_A][1]) ? "Fail" : "Pass");
#if (RTL8822B_SUPPORT == 1)
PDM_SNPF(out_len, used, output + used, out_len - used, "%-20s: %s\n",
"PATH_B-Tx result",
(iqk_result[0][RF_PATH_B][0]) ? "Fail" : "Pass");
PDM_SNPF(out_len, used, output + used, out_len - used, "%-20s: %s\n",
"PATH_B-Rx result",
(iqk_result[0][RF_PATH_B][1]) ? "Fail" : "Pass");
2018-06-22 16:48:32 +00:00
#endif
*_used = used;
*_out_len = out_len;
}
2019-05-24 19:43:57 +00:00
void halrf_get_fw_version(void *dm_void)
2018-06-22 16:48:32 +00:00
{
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
2019-05-24 19:43:57 +00:00
struct _hal_rf_ *rf = &dm->rf_table;
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
rf->fw_ver = (dm->fw_version << 16) | dm->fw_sub_version;
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
void halrf_iqk_dbg(void *dm_void)
2018-06-22 16:48:32 +00:00
{
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
2019-05-24 19:43:57 +00:00
u8 rf_path, j;
2018-06-22 16:48:32 +00:00
u32 tmp;
2019-05-24 19:43:57 +00:00
/*two channel, PATH, TX/RX, 0:pass 1 :fail*/
boolean iqk_result[2][NUM][2];
struct dm_iqk_info *iqk_info = &dm->IQK_info;
struct _hal_rf_ *rf = &dm->rf_table;
2018-06-22 16:48:32 +00:00
/* IQK INFO */
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_IQK, "%-20s\n", "====== IQK Info ======");
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_IQK, "%-20s\n",
(dm->fw_offload_ability & PHYDM_RF_IQK_OFFLOAD) ? "FW-IQK" :
"Driver-IQK");
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
if (dm->fw_offload_ability & PHYDM_RF_IQK_OFFLOAD) {
halrf_get_fw_version(dm);
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_IQK, "%-20s: 0x%x\n", "FW_VER", rf->fw_ver);
} else {
RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "IQK_VER", HALRF_IQK_VER);
}
2018-08-24 20:52:34 +00:00
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "reload",
(iqk_info->is_reload) ? "True" : "False");
2018-08-24 20:52:34 +00:00
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_IQK, "%-20s: %d %d\n", "iqk count / fail count",
dm->n_iqk_cnt, dm->n_iqk_fail_cnt);
2018-08-24 20:52:34 +00:00
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_IQK, "%-20s: %d\n", "channel", *dm->channel);
2018-08-24 20:52:34 +00:00
if (*dm->band_width == CHANNEL_WIDTH_20)
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "bandwidth", "BW_20");
2018-08-24 20:52:34 +00:00
else if (*dm->band_width == CHANNEL_WIDTH_40)
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "bandwidth", "BW_40");
2018-08-24 20:52:34 +00:00
else if (*dm->band_width == CHANNEL_WIDTH_80)
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "bandwidth", "BW_80");
2018-08-24 20:52:34 +00:00
else if (*dm->band_width == CHANNEL_WIDTH_160)
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "bandwidth", "BW_160");
2018-06-22 16:48:32 +00:00
else
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "bandwidth",
"BW_UNKNOWN");
#if 0
2018-06-22 16:48:32 +00:00
/*
2019-05-24 19:43:57 +00:00
* RF_DBG(dm, DBG_RF_IQK, "%-20s: %llu %s\n",
* "progressing_time",
* dm->rf_calibrate_info.iqk_total_progressing_time, "(ms)");
*/
#endif
RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "rfk_forbidden",
(iqk_info->rfk_forbidden) ? "True" : "False");
#if (RTL8814A_SUPPORT == 1 || RTL8822B_SUPPORT == 1 || \
RTL8821C_SUPPORT == 1 || RTL8195B_SUPPORT == 1 ||\
RTL8814B_SUPPORT == 1 || RTL8822C_SUPPORT == 1)
RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "segment_iqk",
(iqk_info->segment_iqk) ? "True" : "False");
2018-06-22 16:48:32 +00:00
#endif
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_IQK, "%-20s: %llu %s\n", "progressing_time",
dm->rf_calibrate_info.iqk_progressing_time, "(ms)");
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
tmp = odm_read_4byte(dm, 0x1bf0);
2019-05-24 19:43:57 +00:00
for (rf_path = RF_PATH_A; rf_path <= RF_PATH_B; rf_path++)
for (j = 0; j < 2; j++)
iqk_result[0][rf_path][j] = (boolean)
(tmp & (BIT(rf_path + (j * 4)) >> (rf_path + (j * 4))));
RF_DBG(dm, DBG_RF_IQK, "%-20s: 0x%08x\n", "Reg0x1bf0", tmp);
RF_DBG(dm, DBG_RF_IQK, "%-20s: 0x%08x\n", "Reg0x1be8",
odm_read_4byte(dm, 0x1be8));
RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "PATH_A-Tx result",
(iqk_result[0][RF_PATH_A][0]) ? "Fail" : "Pass");
RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "PATH_A-Rx result",
(iqk_result[0][RF_PATH_A][1]) ? "Fail" : "Pass");
#if (RTL8822B_SUPPORT == 1)
RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "PATH_B-Tx result",
(iqk_result[0][RF_PATH_B][0]) ? "Fail" : "Pass");
RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "PATH_B-Rx result",
(iqk_result[0][RF_PATH_B][1]) ? "Fail" : "Pass");
2018-06-22 16:48:32 +00:00
#endif
}
2019-05-24 19:43:57 +00:00
2018-08-24 20:52:34 +00:00
void halrf_lck_dbg(struct dm_struct *dm)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_IQK, "%-20s\n", "====== LCK Info ======");
#if 0
/*RF_DBG(dm, DBG_RF_IQK, "%-20s\n",
* (dm->fw_offload_ability & PHYDM_RF_IQK_OFFLOAD) ? "LCK" : "RTK"));
*/
#endif
RF_DBG(dm, DBG_RF_IQK, "%-20s: %llu %s\n", "progressing_time",
dm->rf_calibrate_info.lck_progressing_time, "(ms)");
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
void halrf_iqk_dbg_cfir_backup(struct dm_struct *dm)
2018-06-22 16:48:32 +00:00
{
2018-08-24 20:52:34 +00:00
struct dm_iqk_info *iqk_info = &dm->IQK_info;
2019-05-24 19:43:57 +00:00
u8 path, idx, i;
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_IQK, "[IQK]%-20s\n", "backup TX/RX CFIR");
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
for (path = 0; path < 2; path++)
for (idx = 0; idx < 2; idx++)
2018-08-24 20:52:34 +00:00
phydm_get_iqk_cfir(dm, idx, path, true);
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
for (path = 0; path < 2; path++) {
2018-06-22 16:48:32 +00:00
for (idx = 0; idx < 2; idx++) {
2019-05-24 19:43:57 +00:00
for (i = 0; i < 8; i++) {
RF_DBG(dm, DBG_RF_IQK,
"[IQK]%-7s %-3s CFIR_real: %-2d: 0x%x\n",
(path == 0) ? "PATH A" : "PATH B",
(idx == 0) ? "TX" : "RX", i,
iqk_info->iqk_cfir_real[2][path][idx][i])
;
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
for (i = 0; i < 8; i++) {
RF_DBG(dm, DBG_RF_IQK,
"[IQK]%-7s %-3s CFIR_img:%-2d: 0x%x\n",
(path == 0) ? "PATH A" : "PATH B",
(idx == 0) ? "TX" : "RX", i,
iqk_info->iqk_cfir_imag[2][path][idx][i])
;
2018-06-22 16:48:32 +00:00
}
}
}
}
2019-05-24 19:43:57 +00:00
void halrf_iqk_dbg_cfir_backup_update(struct dm_struct *dm)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
struct dm_iqk_info *iqk = &dm->IQK_info;
2018-06-22 16:48:32 +00:00
u8 i, path, idx;
2019-05-24 19:43:57 +00:00
u32 bmask13_12 = BIT(13) | BIT(12);
u32 bmask20_16 = BIT(20) | BIT(19) | BIT(18) | BIT(17) | BIT(16);
u32 data;
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
if (iqk->iqk_cfir_real[2][0][0][0] == 0) {
RF_DBG(dm, DBG_RF_IQK, "[IQK]%-20s\n", "CFIR is invalid");
2018-06-22 16:48:32 +00:00
return;
}
for (path = 0; path < 2; path++) {
for (idx = 0; idx < 2; idx++) {
2019-05-24 19:43:57 +00:00
odm_set_bb_reg(dm, R_0x1b00, MASKDWORD,
0xf8000008 | path << 1);
odm_set_bb_reg(dm, R_0x1b2c, MASKDWORD, 0x7);
odm_set_bb_reg(dm, R_0x1b38, MASKDWORD, 0x20000000);
odm_set_bb_reg(dm, R_0x1b3c, MASKDWORD, 0x20000000);
odm_set_bb_reg(dm, R_0x1bcc, MASKDWORD, 0x00000000);
2018-06-22 16:48:32 +00:00
if (idx == 0)
2019-05-24 19:43:57 +00:00
odm_set_bb_reg(dm, R_0x1b0c, bmask13_12, 0x3);
2018-06-22 16:48:32 +00:00
else
2019-05-24 19:43:57 +00:00
odm_set_bb_reg(dm, R_0x1b0c, bmask13_12, 0x1);
odm_set_bb_reg(dm, R_0x1bd4, bmask20_16, 0x10);
2018-06-22 16:48:32 +00:00
for (i = 0; i < 8; i++) {
2019-05-24 19:43:57 +00:00
data = ((0xc0000000 >> idx) + 0x3) + (i * 4) +
(iqk->iqk_cfir_real[2][path][idx][i]
<< 9);
odm_write_4byte(dm, 0x1bd8, data);
data = ((0xc0000000 >> idx) + 0x1) + (i * 4) +
(iqk->iqk_cfir_imag[2][path][idx][i]
<< 9);
odm_write_4byte(dm, 0x1bd8, data);
#if 0
/*odm_write_4byte(dm, 0x1bd8, iqk->iqk_cfir_real[2][path][idx][i]);*/
/*odm_write_4byte(dm, 0x1bd8, iqk->iqk_cfir_imag[2][path][idx][i]);*/
#endif
2018-06-22 16:48:32 +00:00
}
}
2019-05-24 19:43:57 +00:00
odm_set_bb_reg(dm, R_0x1bd8, MASKDWORD, 0x0);
odm_set_bb_reg(dm, R_0x1b0c, bmask13_12, 0x0);
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_IQK, "[IQK]%-20s\n", "update new CFIR");
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
void halrf_iqk_dbg_cfir_reload(struct dm_struct *dm)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
struct dm_iqk_info *iqk = &dm->IQK_info;
2018-06-22 16:48:32 +00:00
u8 i, path, idx;
2019-05-24 19:43:57 +00:00
u32 bmask13_12 = BIT(13) | BIT(12);
u32 bmask20_16 = BIT(20) | BIT(19) | BIT(18) | BIT(17) | BIT(16);
u32 data;
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
if (iqk->iqk_cfir_real[0][0][0][0] == 0) {
RF_DBG(dm, DBG_RF_IQK, "[IQK]%-20s\n", "CFIR is invalid");
2018-06-22 16:48:32 +00:00
return;
}
for (path = 0; path < 2; path++) {
for (idx = 0; idx < 2; idx++) {
2019-05-24 19:43:57 +00:00
odm_set_bb_reg(dm, R_0x1b00, MASKDWORD,
0xf8000008 | path << 1);
odm_set_bb_reg(dm, R_0x1b2c, MASKDWORD, 0x7);
odm_set_bb_reg(dm, R_0x1b38, MASKDWORD, 0x20000000);
odm_set_bb_reg(dm, R_0x1b3c, MASKDWORD, 0x20000000);
odm_set_bb_reg(dm, R_0x1bcc, MASKDWORD, 0x00000000);
2018-06-22 16:48:32 +00:00
if (idx == 0)
2019-05-24 19:43:57 +00:00
odm_set_bb_reg(dm, R_0x1b0c, bmask13_12, 0x3);
2018-06-22 16:48:32 +00:00
else
2019-05-24 19:43:57 +00:00
odm_set_bb_reg(dm, R_0x1b0c, bmask13_12, 0x1);
odm_set_bb_reg(dm, R_0x1bd4, bmask20_16, 0x10);
2018-06-22 16:48:32 +00:00
for (i = 0; i < 8; i++) {
2019-05-24 19:43:57 +00:00
#if 0
/*odm_write_4byte(dm, 0x1bd8, iqk->iqk_cfir_real[0][path][idx][i]);*/
/*odm_write_4byte(dm, 0x1bd8, iqk->iqk_cfir_imag[0][path][idx][i]);*/
#endif
data = ((0xc0000000 >> idx) + 0x3) + (i * 4) +
(iqk->iqk_cfir_real[0][path][idx][i]
<< 9);
odm_write_4byte(dm, 0x1bd8, data);
data = ((0xc0000000 >> idx) + 0x1) + (i * 4) +
(iqk->iqk_cfir_imag[0][path][idx][i]
<< 9);
odm_write_4byte(dm, 0x1bd8, data);
2018-06-22 16:48:32 +00:00
}
}
2019-05-24 19:43:57 +00:00
odm_set_bb_reg(dm, R_0x1bd8, MASKDWORD, 0x0);
odm_set_bb_reg(dm, R_0x1b0c, bmask13_12, 0x0);
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_IQK, "[IQK]%-20s\n", "write CFIR with default value");
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
void halrf_iqk_dbg_cfir_write(struct dm_struct *dm, u8 type, u32 path, u32 idx,
u32 i, u32 data)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
struct dm_iqk_info *iqk_info = &dm->IQK_info;
2018-06-22 16:48:32 +00:00
if (type == 0)
2018-08-24 20:52:34 +00:00
iqk_info->iqk_cfir_real[2][path][idx][i] = data;
2018-06-22 16:48:32 +00:00
else
2018-08-24 20:52:34 +00:00
iqk_info->iqk_cfir_imag[2][path][idx][i] = data;
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
void halrf_iqk_dbg_cfir_backup_show(struct dm_struct *dm)
2018-06-22 16:48:32 +00:00
{
2018-08-24 20:52:34 +00:00
struct dm_iqk_info *iqk_info = &dm->IQK_info;
2019-05-24 19:43:57 +00:00
u8 path, idx, i;
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_IQK, "[IQK]%-20s\n", "backup TX/RX CFIR");
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
for (path = 0; path < 2; path++) {
2018-06-22 16:48:32 +00:00
for (idx = 0; idx < 2; idx++) {
2019-05-24 19:43:57 +00:00
for (i = 0; i < 8; i++) {
RF_DBG(dm, DBG_RF_IQK,
"[IQK]%-10s %-3s CFIR_real:%-2d: 0x%x\n",
(path == 0) ? "PATH A" : "PATH B",
(idx == 0) ? "TX" : "RX", i,
iqk_info->iqk_cfir_real[2][path][idx][i])
;
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
for (i = 0; i < 8; i++) {
RF_DBG(dm, DBG_RF_IQK,
"[IQK]%-10s %-3s CFIR_img:%-2d: 0x%x\n",
(path == 0) ? "PATH A" : "PATH B",
(idx == 0) ? "TX" : "RX", i,
iqk_info->iqk_cfir_imag[2][path][idx][i])
;
2018-06-22 16:48:32 +00:00
}
}
}
}
2019-05-24 19:43:57 +00:00
void halrf_do_imr_test(void *dm_void, u8 flag_imr_test)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-06-22 16:48:32 +00:00
if (flag_imr_test != 0x0)
2018-08-24 20:52:34 +00:00
switch (dm->support_ic_type) {
2018-06-22 16:48:32 +00:00
#if (RTL8822B_SUPPORT == 1)
case ODM_RTL8822B:
2018-08-24 20:52:34 +00:00
do_imr_test_8822b(dm);
2018-06-22 16:48:32 +00:00
break;
#endif
#if (RTL8821C_SUPPORT == 1)
case ODM_RTL8821C:
2018-08-24 20:52:34 +00:00
do_imr_test_8821c(dm);
2018-06-22 16:48:32 +00:00
break;
#endif
default:
2019-05-24 19:43:57 +00:00
break;
2018-06-22 16:48:32 +00:00
}
}
2019-05-24 19:43:57 +00:00
void halrf_iqk_debug(void *dm_void, u32 *const dm_value, u32 *_used,
char *output, u32 *_out_len)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
#if 0
2018-06-22 16:48:32 +00:00
/*dm_value[0]=0x0: backup from SRAM & show*/
/*dm_value[0]=0x1: write backup CFIR to SRAM*/
/*dm_value[0]=0x2: reload default CFIR to SRAM*/
/*dm_value[0]=0x3: show backup*/
/*dm_value[0]=0x10: write backup CFIR real part*/
/*--> dm_value[1]:path, dm_value[2]:tx/rx, dm_value[3]:index, dm_value[4]:data*/
/*dm_value[0]=0x11: write backup CFIR imag*/
2019-05-24 19:43:57 +00:00
/*--> dm_value[1]:path, dm_value[2]:tx/rx, dm_value[3]:index, dm_value[4]:data*/
2018-06-22 16:48:32 +00:00
/*dm_value[0]=0x20 :xym_read enable*/
2019-05-24 19:43:57 +00:00
/*--> dm_value[1]:0:disable, 1:enable*/
2018-06-22 16:48:32 +00:00
/*if dm_value[0]=0x20 = enable, */
/*0x1:show rx_sym; 0x2: tx_xym; 0x3:gs1_xym; 0x4:gs2_sym; 0x5:rxk1_xym*/
2019-05-24 19:43:57 +00:00
#endif
2018-06-22 16:48:32 +00:00
if (dm_value[0] == 0x0)
2018-08-24 20:52:34 +00:00
halrf_iqk_dbg_cfir_backup(dm);
2018-06-22 16:48:32 +00:00
else if (dm_value[0] == 0x1)
2018-08-24 20:52:34 +00:00
halrf_iqk_dbg_cfir_backup_update(dm);
2018-06-22 16:48:32 +00:00
else if (dm_value[0] == 0x2)
2018-08-24 20:52:34 +00:00
halrf_iqk_dbg_cfir_reload(dm);
2018-06-22 16:48:32 +00:00
else if (dm_value[0] == 0x3)
2018-08-24 20:52:34 +00:00
halrf_iqk_dbg_cfir_backup_show(dm);
2018-06-22 16:48:32 +00:00
else if (dm_value[0] == 0x10)
2019-05-24 19:43:57 +00:00
halrf_iqk_dbg_cfir_write(dm, 0, dm_value[1], dm_value[2],
dm_value[3], dm_value[4]);
2018-06-22 16:48:32 +00:00
else if (dm_value[0] == 0x11)
2019-05-24 19:43:57 +00:00
halrf_iqk_dbg_cfir_write(dm, 1, dm_value[1], dm_value[2],
dm_value[3], dm_value[4]);
2018-06-22 16:48:32 +00:00
else if (dm_value[0] == 0x20)
2018-08-24 20:52:34 +00:00
halrf_iqk_xym_enable(dm, (u8)dm_value[1]);
2018-06-22 16:48:32 +00:00
else if (dm_value[0] == 0x21)
2019-05-24 19:43:57 +00:00
halrf_iqk_xym_show(dm, (u8)dm_value[1]);
2018-06-22 16:48:32 +00:00
else if (dm_value[0] == 0x30)
2018-08-24 20:52:34 +00:00
halrf_do_imr_test(dm, (u8)dm_value[1]);
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
void halrf_iqk_hwtx_check(void *dm_void, boolean is_check)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
#if 0
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct dm_iqk_info *iqk_info = &dm->IQK_info;
2018-06-22 16:48:32 +00:00
u32 tmp_b04;
2019-05-24 19:43:57 +00:00
if (is_check) {
iqk_info->is_hwtx = (boolean)odm_get_bb_reg(dm, R_0xb00, BIT(8));
} else {
2018-08-24 20:52:34 +00:00
if (iqk_info->is_hwtx) {
tmp_b04 = odm_read_4byte(dm, 0xb04);
2019-05-24 19:43:57 +00:00
odm_set_bb_reg(dm, R_0xb04, BIT(3) | BIT(2), 0x0);
2018-08-24 20:52:34 +00:00
odm_write_4byte(dm, 0xb04, tmp_b04);
2018-06-22 16:48:32 +00:00
}
}
2019-05-24 19:43:57 +00:00
#endif
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
void halrf_segment_iqk_trigger(void *dm_void, boolean clear,
boolean segment_iqk)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct dm_iqk_info *iqk_info = &dm->IQK_info;
struct _hal_rf_ *rf = &dm->rf_table;
2018-06-22 16:48:32 +00:00
u64 start_time;
2019-05-24 19:43:57 +00:00
2018-06-22 16:48:32 +00:00
#if (DM_ODM_SUPPORT_TYPE & (ODM_WIN))
2018-08-24 20:52:34 +00:00
if (odm_check_power_status(dm) == false)
2018-06-22 16:48:32 +00:00
return;
#endif
2019-05-24 19:43:57 +00:00
if (dm->mp_mode &&
rf->is_con_tx &&
rf->is_single_tone &&
rf->is_carrier_suppresion)
if (*dm->mp_mode &&
((*rf->is_con_tx ||
*rf->is_single_tone ||
*rf->is_carrier_suppresion)))
2018-06-22 16:48:32 +00:00
return;
#if (DM_ODM_SUPPORT_TYPE == ODM_CE)
2018-08-24 20:52:34 +00:00
if (!(rf->rf_supportability & HAL_RF_IQK))
2018-06-22 16:48:32 +00:00
return;
#endif
#if DISABLE_BB_RF
return;
#endif
2018-08-24 20:52:34 +00:00
if (iqk_info->rfk_forbidden)
2018-06-22 16:48:32 +00:00
return;
2018-08-24 20:52:34 +00:00
if (!dm->rf_calibrate_info.is_iqk_in_progress) {
odm_acquire_spin_lock(dm, RT_IQK_SPINLOCK);
dm->rf_calibrate_info.is_iqk_in_progress = true;
odm_release_spin_lock(dm, RT_IQK_SPINLOCK);
start_time = odm_get_current_time(dm);
dm->IQK_info.segment_iqk = segment_iqk;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
switch (dm->support_ic_type) {
2018-06-22 16:48:32 +00:00
#if (RTL8822B_SUPPORT == 1)
case ODM_RTL8822B:
2018-08-24 20:52:34 +00:00
phy_iq_calibrate_8822b(dm, clear, segment_iqk);
2018-06-22 16:48:32 +00:00
break;
#endif
2019-05-24 19:43:57 +00:00
#if (RTL8822C_SUPPORT == 1)
case ODM_RTL8822C:
phy_iq_calibrate_8822c(dm, clear, segment_iqk);
break;
#endif
2018-06-22 16:48:32 +00:00
#if (RTL8821C_SUPPORT == 1)
case ODM_RTL8821C:
2018-08-24 20:52:34 +00:00
phy_iq_calibrate_8821c(dm, clear, segment_iqk);
2018-06-22 16:48:32 +00:00
break;
#endif
#if (RTL8814B_SUPPORT == 1)
case ODM_RTL8814B:
break;
#endif
2019-05-24 19:43:57 +00:00
#if (RTL8195B_SUPPORT == 1)
case ODM_RTL8195B:
phy_iq_calibrate_8195b(dm, clear, segment_iqk);
break;
#endif
#if (RTL8198F_SUPPORT == 1)
case ODM_RTL8198F:
phy_iq_calibrate_8198f(dm, clear, segment_iqk);
break;
#endif
2018-06-22 16:48:32 +00:00
default:
break;
}
2019-05-24 19:43:57 +00:00
dm->rf_calibrate_info.iqk_progressing_time =
odm_get_progressing_time(dm, start_time);
RF_DBG(dm, DBG_RF_IQK, "[IQK]IQK progressing_time = %lld ms\n",
dm->rf_calibrate_info.iqk_progressing_time);
2018-08-24 20:52:34 +00:00
odm_acquire_spin_lock(dm, RT_IQK_SPINLOCK);
dm->rf_calibrate_info.is_iqk_in_progress = false;
odm_release_spin_lock(dm, RT_IQK_SPINLOCK);
} else {
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_IQK,
"== Return the IQK CMD, because RFKs in Progress ==\n");
}
2018-06-22 16:48:32 +00:00
}
#endif
2019-05-24 19:43:57 +00:00
u8 halrf_match_iqk_version(void *dm_void)
2018-08-24 20:52:34 +00:00
{
struct dm_struct *dm = (struct dm_struct *)dm_void;
u32 iqk_version = 0;
char temp[10] = {0};
2019-05-24 19:43:57 +00:00
odm_move_memory(dm, temp, HALRF_IQK_VER, sizeof(temp));
2018-08-24 20:52:34 +00:00
PHYDM_SSCANF(temp + 2, DCMD_HEX, &iqk_version);
2019-05-24 19:43:57 +00:00
2018-08-24 20:52:34 +00:00
if (dm->support_ic_type == ODM_RTL8822B) {
2019-05-24 19:43:57 +00:00
if (iqk_version >= 0x24 && (odm_get_hw_img_version(dm) >= 72))
2018-08-24 20:52:34 +00:00
return 1;
2019-05-24 19:43:57 +00:00
else if ((iqk_version <= 0x23) &&
(odm_get_hw_img_version(dm) <= 71))
2018-08-24 20:52:34 +00:00
return 1;
else
return 0;
}
if (dm->support_ic_type == ODM_RTL8821C) {
2019-05-24 19:43:57 +00:00
if (iqk_version >= 0x18 && (odm_get_hw_img_version(dm) >= 37))
2018-08-24 20:52:34 +00:00
return 1;
else
return 0;
}
return 1;
}
2019-05-24 19:43:57 +00:00
void halrf_rf_lna_setting(void *dm_void, enum halrf_lna_set type)
2018-06-22 16:48:32 +00:00
{
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
switch (dm->support_ic_type) {
2018-06-22 16:48:32 +00:00
#if (RTL8188E_SUPPORT == 1)
2019-05-24 19:43:57 +00:00
case ODM_RTL8188E:
halrf_rf_lna_setting_8188e(dm, type);
break;
2018-06-22 16:48:32 +00:00
#endif
#if (RTL8192E_SUPPORT == 1)
2019-05-24 19:43:57 +00:00
case ODM_RTL8192E:
halrf_rf_lna_setting_8192e(dm, type);
break;
2018-06-22 16:48:32 +00:00
#endif
2019-05-24 19:43:57 +00:00
#if (RTL8192F_SUPPORT == 1)
case ODM_RTL8192F:
halrf_rf_lna_setting_8192f(dm, type);
break;
#endif
2018-06-22 16:48:32 +00:00
#if (RTL8723B_SUPPORT == 1)
2019-05-24 19:43:57 +00:00
case ODM_RTL8723B:
halrf_rf_lna_setting_8723b(dm, type);
break;
2018-06-22 16:48:32 +00:00
#endif
#if (RTL8812A_SUPPORT == 1)
2019-05-24 19:43:57 +00:00
case ODM_RTL8812:
halrf_rf_lna_setting_8812a(dm, type);
break;
2018-06-22 16:48:32 +00:00
#endif
#if ((RTL8821A_SUPPORT == 1) || (RTL8881A_SUPPORT == 1))
2019-05-24 19:43:57 +00:00
case ODM_RTL8881A:
case ODM_RTL8821:
halrf_rf_lna_setting_8821a(dm, type);
break;
2018-06-22 16:48:32 +00:00
#endif
#if (RTL8822B_SUPPORT == 1)
2019-05-24 19:43:57 +00:00
case ODM_RTL8822B:
halrf_rf_lna_setting_8822b(dm_void, type);
break;
#endif
#if (RTL8822C_SUPPORT == 1)
case ODM_RTL8822C:
halrf_rf_lna_setting_8822c(dm_void, type);
break;
2018-06-22 16:48:32 +00:00
#endif
#if (RTL8821C_SUPPORT == 1)
2019-05-24 19:43:57 +00:00
case ODM_RTL8821C:
halrf_rf_lna_setting_8821c(dm_void, type);
break;
2018-06-22 16:48:32 +00:00
#endif
2019-05-24 19:43:57 +00:00
#if (RTL8814B_SUPPORT == 1)
case ODM_RTL8814B:
2018-06-22 16:48:32 +00:00
break;
2019-05-24 19:43:57 +00:00
#endif
default:
break;
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
}
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
void halrf_support_ability_debug(void *dm_void, char input[][16], u32 *_used,
char *output, u32 *_out_len)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct _hal_rf_ *rf = &dm->rf_table;
u32 dm_value[10] = {0};
2018-06-22 16:48:32 +00:00
u32 used = *_used;
u32 out_len = *_out_len;
2019-05-24 19:43:57 +00:00
u8 i;
for (i = 0; i < 5; i++)
if (input[i + 1])
PHYDM_SSCANF(input[i + 2], DCMD_DECIMAL, &dm_value[i]);
2018-06-22 16:48:32 +00:00
if (dm_value[0] == 100) {
2018-08-24 20:52:34 +00:00
PDM_SNPF(out_len, used, output + used, out_len - used,
2019-05-24 19:43:57 +00:00
"\n[RF Supportability]\n");
2018-08-24 20:52:34 +00:00
PDM_SNPF(out_len, used, output + used, out_len - used,
2019-05-24 19:43:57 +00:00
"00. (( %s ))Power Tracking\n",
((rf->rf_supportability & HAL_RF_TX_PWR_TRACK) ?
("V") : (".")));
2018-08-24 20:52:34 +00:00
PDM_SNPF(out_len, used, output + used, out_len - used,
2019-05-24 19:43:57 +00:00
"01. (( %s ))IQK\n",
((rf->rf_supportability & HAL_RF_IQK) ? ("V") :
(".")));
2018-08-24 20:52:34 +00:00
PDM_SNPF(out_len, used, output + used, out_len - used,
2019-05-24 19:43:57 +00:00
"02. (( %s ))LCK\n",
((rf->rf_supportability & HAL_RF_LCK) ? ("V") :
(".")));
2018-08-24 20:52:34 +00:00
PDM_SNPF(out_len, used, output + used, out_len - used,
2019-05-24 19:43:57 +00:00
"03. (( %s ))DPK\n",
((rf->rf_supportability & HAL_RF_DPK) ? ("V") :
(".")));
2018-08-24 20:52:34 +00:00
PDM_SNPF(out_len, used, output + used, out_len - used,
2019-05-24 19:43:57 +00:00
"04. (( %s ))HAL_RF_TXGAPK\n",
((rf->rf_supportability & HAL_RF_TXGAPK) ? ("V") :
(".")));
#if (RTL8192F_SUPPORT == 1)
2018-08-24 20:52:34 +00:00
PDM_SNPF(out_len, used, output + used, out_len - used,
2019-05-24 19:43:57 +00:00
"07. (( %s ))HAL_2GBAND_SHIFT\n",
((rf->rf_supportability & HAL_2GBAND_SHIFT) ? ("V") :
(".")));
#endif
} else {
if (dm_value[1] == 1) /* enable */
rf->rf_supportability |= BIT(dm_value[0]);
else if (dm_value[1] == 2) /* disable */
rf->rf_supportability &= ~(BIT(dm_value[0]));
else
PDM_SNPF(out_len, used, output + used, out_len - used,
"[Warning!!!] 1:enable, 2:disable\n");
2018-06-22 16:48:32 +00:00
}
2018-08-24 20:52:34 +00:00
PDM_SNPF(out_len, used, output + used, out_len - used,
2019-05-24 19:43:57 +00:00
"\nCurr-RF_supportability = 0x%x\n\n", rf->rf_supportability);
2018-06-22 16:48:32 +00:00
*_used = used;
*_out_len = out_len;
}
2019-05-24 19:43:57 +00:00
void halrf_support_band_shift_debug(void *dm_void, char input[][16], u32 *_used,
char *output, u32 *_out_len)
{
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct _hal_rf_ *rf = &dm->rf_table;
//u32 band_value[2] = {00};
u32 dm_value[10] = {0};
u32 used = *_used;
u32 out_len = *_out_len;
u8 i;
#if (RTL8192F_SUPPORT == 1)
for (i = 0; i < 7; i++)
if (input[i + 1])
PHYDM_SSCANF(input[i + 2], DCMD_DECIMAL, &dm_value[i]);
if (!(rf->rf_supportability & HAL_2GBAND_SHIFT)) {
PDM_SNPF(out_len, used, output + used, out_len - used,
"\nCurr-RF_supportability[07. (( . ))HAL_2GBAND_SHIFT]\nNo RF Band Shift,default: 2.4G!\n");
} else {
if (dm_value[0] == 01) {
rf->rf_shift_band = HAL_RF_2P3;
PDM_SNPF(out_len, used, output + used, out_len - used,
"\n[rf_shift_band] = %d\nRF Band Shift to 2.3G!\n",
rf->rf_shift_band);
} else if (dm_value[0] == 02) {
rf->rf_shift_band = HAL_RF_2P5;
PDM_SNPF(out_len, used, output + used, out_len - used,
"\n[rf_shift_band] = %d\nRF Band Shift to 2.5G!\n",
rf->rf_shift_band);
} else {
rf->rf_shift_band = HAL_RF_2P4;
PDM_SNPF(out_len, used, output + used, out_len - used,
"\n[rf_shift_band] = %d\nNo RF Band Shift,default: 2.4G!\n",
rf->rf_shift_band);
}
}
*_used = used;
*_out_len = out_len;
#endif
}
void halrf_cmn_info_init(void *dm_void, enum halrf_cmninfo_init cmn_info,
u32 value)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct _hal_rf_ *rf = &dm->rf_table;
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
switch (cmn_info) {
case HALRF_CMNINFO_EEPROM_THERMAL_VALUE:
2018-08-24 20:52:34 +00:00
rf->eeprom_thermal = (u8)value;
2018-06-22 16:48:32 +00:00
break;
2019-05-24 19:43:57 +00:00
case HALRF_CMNINFO_PWT_TYPE:
rf->pwt_type = (u8)value;
2018-06-22 16:48:32 +00:00
break;
default:
break;
}
}
2019-05-24 19:43:57 +00:00
void halrf_cmn_info_hook(void *dm_void, enum halrf_cmninfo_hook cmn_info,
void *value)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct _hal_rf_ *rf = &dm->rf_table;
switch (cmn_info) {
case HALRF_CMNINFO_CON_TX:
2018-08-24 20:52:34 +00:00
rf->is_con_tx = (boolean *)value;
2018-06-22 16:48:32 +00:00
break;
2019-05-24 19:43:57 +00:00
case HALRF_CMNINFO_SINGLE_TONE:
rf->is_single_tone = (boolean *)value;
2018-06-22 16:48:32 +00:00
break;
2019-05-24 19:43:57 +00:00
case HALRF_CMNINFO_CARRIER_SUPPRESSION:
rf->is_carrier_suppresion = (boolean *)value;
2018-06-22 16:48:32 +00:00
break;
2019-05-24 19:43:57 +00:00
case HALRF_CMNINFO_MP_RATE_INDEX:
2018-08-24 20:52:34 +00:00
rf->mp_rate_index = (u8 *)value;
2018-06-22 16:48:32 +00:00
break;
default:
/*do nothing*/
break;
}
}
2019-05-24 19:43:57 +00:00
void halrf_cmn_info_set(void *dm_void, u32 cmn_info, u64 value)
2018-06-22 16:48:32 +00:00
{
/* This init variable may be changed in run time. */
2019-05-24 19:43:57 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct _hal_rf_ *rf = &dm->rf_table;
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
switch (cmn_info) {
case HALRF_CMNINFO_ABILITY:
rf->rf_supportability = (u32)value;
break;
case HALRF_CMNINFO_DPK_EN:
rf->dpk_en = (u8)value;
break;
case HALRF_CMNINFO_RFK_FORBIDDEN:
dm->IQK_info.rfk_forbidden = (boolean)value;
break;
#if (RTL8814A_SUPPORT == 1 || RTL8822B_SUPPORT == 1 || \
RTL8821C_SUPPORT == 1 || RTL8195B_SUPPORT == 1 ||\
RTL8814B_SUPPORT == 1 || RTL8822C_SUPPORT == 1)
case HALRF_CMNINFO_IQK_SEGMENT:
dm->IQK_info.segment_iqk = (boolean)value;
break;
#endif
case HALRF_CMNINFO_RATE_INDEX:
rf->p_rate_index = (u32)value;
break;
2018-07-02 16:49:32 +00:00
#if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2019-05-24 19:43:57 +00:00
case HALRF_CMNINFO_MP_PSD_POINT:
rf->halrf_psd_data.point = (u32)value;
break;
case HALRF_CMNINFO_MP_PSD_START_POINT:
rf->halrf_psd_data.start_point = (u32)value;
break;
case HALRF_CMNINFO_MP_PSD_STOP_POINT:
rf->halrf_psd_data.stop_point = (u32)value;
break;
case HALRF_CMNINFO_MP_PSD_AVERAGE:
rf->halrf_psd_data.average = (u32)value;
break;
2018-07-02 16:49:32 +00:00
#endif
2019-05-24 19:43:57 +00:00
default:
/* do nothing */
break;
2018-06-22 16:48:32 +00:00
}
}
2019-05-24 19:43:57 +00:00
u64 halrf_cmn_info_get(void *dm_void, u32 cmn_info)
2018-06-22 16:48:32 +00:00
{
/* This init variable may be changed in run time. */
2019-05-24 19:43:57 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct _hal_rf_ *rf = &dm->rf_table;
u64 return_value = 0;
switch (cmn_info) {
case HALRF_CMNINFO_ABILITY:
return_value = (u32)rf->rf_supportability;
break;
case HALRF_CMNINFO_RFK_FORBIDDEN:
return_value = dm->IQK_info.rfk_forbidden;
break;
#if (RTL8814A_SUPPORT == 1 || RTL8822B_SUPPORT == 1 || \
RTL8821C_SUPPORT == 1 || RTL8195B_SUPPORT == 1 ||\
RTL8814B_SUPPORT == 1 || RTL8822C_SUPPORT == 1)
case HALRF_CMNINFO_IQK_SEGMENT:
return_value = dm->IQK_info.segment_iqk;
break;
#endif
default:
/* do nothing */
break;
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
return return_value;
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
void halrf_supportability_init_mp(void *dm_void)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct _hal_rf_ *rf = &dm->rf_table;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
switch (dm->support_ic_type) {
2018-06-22 16:48:32 +00:00
case ODM_RTL8814B:
2019-05-24 19:43:57 +00:00
#if (RTL8814B_SUPPORT == 1)
rf->rf_supportability =
HAL_RF_TX_PWR_TRACK |
HAL_RF_IQK |
HAL_RF_LCK |
/*@HAL_RF_DPK |*/
2018-06-22 16:48:32 +00:00
0;
2019-05-24 19:43:57 +00:00
#endif
2018-06-22 16:48:32 +00:00
break;
2019-05-24 19:43:57 +00:00
#if (RTL8822B_SUPPORT == 1)
2018-06-22 16:48:32 +00:00
case ODM_RTL8822B:
2019-05-24 19:43:57 +00:00
rf->rf_supportability =
HAL_RF_TX_PWR_TRACK |
HAL_RF_IQK |
HAL_RF_LCK |
/*@HAL_RF_DPK |*/
2018-06-22 16:48:32 +00:00
0;
break;
2019-05-24 19:43:57 +00:00
#endif
#if (RTL8822C_SUPPORT == 1)
case ODM_RTL8822C:
rf->rf_supportability =
HAL_RF_TX_PWR_TRACK |
HAL_RF_IQK |
HAL_RF_LCK |
/*@HAL_RF_DPK |*/
0;
break;
#endif
#if (RTL8821C_SUPPORT == 1)
2018-06-22 16:48:32 +00:00
case ODM_RTL8821C:
2019-05-24 19:43:57 +00:00
rf->rf_supportability =
HAL_RF_TX_PWR_TRACK |
HAL_RF_IQK |
HAL_RF_LCK |
/*@HAL_RF_DPK |*/
/*@HAL_RF_TXGAPK |*/
2018-06-22 16:48:32 +00:00
0;
break;
2019-05-24 19:43:57 +00:00
#endif
#if (RTL8192F_SUPPORT == 1)
case ODM_RTL8192F:
rf->rf_supportability =
HAL_RF_TX_PWR_TRACK |
HAL_RF_IQK |
HAL_RF_LCK |
/*@HAL_2GBAND_SHIFT |*/
/*@HAL_RF_DPK |*/
/*@HAL_RF_TXGAPK |*/
0;
break;
#endif
#if (RTL8195B_SUPPORT == 1)
case ODM_RTL8195B:
rf->rf_supportability =
HAL_RF_TX_PWR_TRACK |
HAL_RF_IQK |
HAL_RF_LCK |
HAL_RF_DPK |
HAL_RF_TXGAPK |
0;
break;
#endif
2018-06-22 16:48:32 +00:00
default:
2019-05-24 19:43:57 +00:00
rf->rf_supportability =
HAL_RF_TX_PWR_TRACK |
HAL_RF_IQK |
HAL_RF_LCK |
/*@HAL_RF_DPK |*/
/*@HAL_RF_TXGAPK |*/
2018-06-22 16:48:32 +00:00
0;
break;
}
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_INIT,
"IC = ((0x%x)), RF_Supportability Init MP = ((0x%x))\n",
dm->support_ic_type, rf->rf_supportability);
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
void halrf_supportability_init(void *dm_void)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct _hal_rf_ *rf = &dm->rf_table;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
switch (dm->support_ic_type) {
2018-06-22 16:48:32 +00:00
case ODM_RTL8814B:
2019-05-24 19:43:57 +00:00
#if (RTL8814B_SUPPORT == 1)
rf->rf_supportability =
HAL_RF_TX_PWR_TRACK |
HAL_RF_IQK |
HAL_RF_LCK |
/*@HAL_RF_DPK |*/
2018-06-22 16:48:32 +00:00
0;
2019-05-24 19:43:57 +00:00
#endif
2018-06-22 16:48:32 +00:00
break;
2019-05-24 19:43:57 +00:00
#if (RTL8822B_SUPPORT == 1)
2018-06-22 16:48:32 +00:00
case ODM_RTL8822B:
2019-05-24 19:43:57 +00:00
rf->rf_supportability =
HAL_RF_TX_PWR_TRACK |
HAL_RF_IQK |
HAL_RF_LCK |
/*@HAL_RF_DPK |*/
2018-06-22 16:48:32 +00:00
0;
break;
2019-05-24 19:43:57 +00:00
#endif
#if (RTL8822C_SUPPORT == 1)
case ODM_RTL8822C:
rf->rf_supportability =
HAL_RF_TX_PWR_TRACK |
HAL_RF_IQK |
HAL_RF_LCK |
HAL_RF_DPK |
0;
break;
#endif
#if (RTL8821C_SUPPORT == 1)
2018-06-22 16:48:32 +00:00
case ODM_RTL8821C:
2019-05-24 19:43:57 +00:00
rf->rf_supportability =
HAL_RF_TX_PWR_TRACK |
HAL_RF_IQK |
HAL_RF_LCK |
/*@HAL_RF_DPK |*/
/*@HAL_RF_TXGAPK |*/
0;
break;
#endif
#if (RTL8192F_SUPPORT == 1)
case ODM_RTL8192F:
rf->rf_supportability =
HAL_RF_TX_PWR_TRACK |
HAL_RF_IQK |
HAL_RF_LCK |
/*HAL_2GBAND_SHIFT |*/
/*@HAL_RF_DPK |*/
/*@HAL_RF_TXGAPK |*/
2018-06-22 16:48:32 +00:00
0;
break;
2019-05-24 19:43:57 +00:00
#endif
#if (RTL8195B_SUPPORT == 1)
case ODM_RTL8195B:
rf->rf_supportability =
HAL_RF_TX_PWR_TRACK |
HAL_RF_IQK |
HAL_RF_LCK |
HAL_RF_DPK |
HAL_RF_TXGAPK |
0;
break;
#endif
2018-06-22 16:48:32 +00:00
default:
2019-05-24 19:43:57 +00:00
rf->rf_supportability =
HAL_RF_TX_PWR_TRACK |
HAL_RF_IQK |
HAL_RF_LCK |
/*@HAL_RF_DPK |*/
2018-06-22 16:48:32 +00:00
0;
break;
}
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_INIT,
"IC = ((0x%x)), RF_Supportability Init = ((0x%x))\n",
dm->support_ic_type, rf->rf_supportability);
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
void halrf_watchdog(void *dm_void)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
#if 0
/*RF_DBG(dm, DBG_RF_TMP, "%s\n", __func__);*/
#endif
2018-08-24 20:52:34 +00:00
phydm_rf_watchdog(dm);
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
2018-06-22 16:48:32 +00:00
#if 0
void
halrf_iqk_init(
2018-08-24 20:52:34 +00:00
void *dm_void
2018-06-22 16:48:32 +00:00
)
{
2019-05-24 19:43:57 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct _hal_rf_ *rf = &dm->rf_table;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
switch (dm->support_ic_type) {
2019-05-24 19:43:57 +00:00
#if (RTL8814B_SUPPORT == 1)
2018-06-22 16:48:32 +00:00
case ODM_RTL8814B:
break;
2019-05-24 19:43:57 +00:00
#endif
#if (RTL8822B_SUPPORT == 1)
2018-06-22 16:48:32 +00:00
case ODM_RTL8822B:
2018-08-24 20:52:34 +00:00
_iq_calibrate_8822b_init(dm);
2018-06-22 16:48:32 +00:00
break;
2019-05-24 19:43:57 +00:00
#endif
#if (RTL8822C_SUPPORT == 1)
case ODM_RTL8822C:
_iq_calibrate_8822c_init(dm);
break;
#endif
#if (RTL8821C_SUPPORT == 1)
2018-06-22 16:48:32 +00:00
case ODM_RTL8821C:
break;
2019-05-24 19:43:57 +00:00
#endif
2018-06-22 16:48:32 +00:00
default:
break;
}
}
#endif
2019-05-24 19:43:57 +00:00
void halrf_dack_trigger(void *dm_void)
{
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct _hal_rf_ *rf = &dm->rf_table;
u64 start_time;
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
start_time = odm_get_current_time(dm);
switch (dm->support_ic_type) {
#if (RTL8822C_SUPPORT == 1)
case ODM_RTL8822C:
halrf_dac_cal_8822c(dm);
break;
#endif
default:
break;
}
rf->dpk_progressing_time = odm_get_progressing_time(dm, start_time);
RF_DBG(dm, DBG_RF_DACK, "[DACK]DACK progressing_time = %lld ms\n",
rf->dpk_progressing_time);
}
void halrf_iqk_trigger(void *dm_void, boolean is_recovery)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct dm_iqk_info *iqk_info = &dm->IQK_info;
struct dm_dpk_info *dpk_info = &dm->dpk_info;
struct _hal_rf_ *rf = &dm->rf_table;
2018-06-22 16:48:32 +00:00
u64 start_time;
#if (DM_ODM_SUPPORT_TYPE & (ODM_WIN))
2018-08-24 20:52:34 +00:00
if (odm_check_power_status(dm) == false)
2018-06-22 16:48:32 +00:00
return;
#endif
2019-05-24 19:43:57 +00:00
if (dm->mp_mode &&
rf->is_con_tx &&
rf->is_single_tone &&
rf->is_carrier_suppresion)
if (*dm->mp_mode &&
((*rf->is_con_tx ||
*rf->is_single_tone ||
*rf->is_carrier_suppresion)))
2018-06-22 16:48:32 +00:00
return;
2018-08-24 20:52:34 +00:00
if (!(rf->rf_supportability & HAL_RF_IQK))
2018-06-22 16:48:32 +00:00
return;
#if DISABLE_BB_RF
return;
#endif
2018-08-24 20:52:34 +00:00
if (iqk_info->rfk_forbidden)
2018-06-22 16:48:32 +00:00
return;
2018-08-24 20:52:34 +00:00
if (!dm->rf_calibrate_info.is_iqk_in_progress) {
odm_acquire_spin_lock(dm, RT_IQK_SPINLOCK);
dm->rf_calibrate_info.is_iqk_in_progress = true;
odm_release_spin_lock(dm, RT_IQK_SPINLOCK);
start_time = odm_get_current_time(dm);
switch (dm->support_ic_type) {
2019-05-24 19:43:57 +00:00
#if (RTL8188E_SUPPORT == 1)
2018-06-22 16:48:32 +00:00
case ODM_RTL8188E:
2018-08-24 20:52:34 +00:00
phy_iq_calibrate_8188e(dm, is_recovery);
2018-06-22 16:48:32 +00:00
break;
#endif
2019-05-24 19:43:57 +00:00
#if (RTL8188F_SUPPORT == 1)
2018-06-22 16:48:32 +00:00
case ODM_RTL8188F:
2018-08-24 20:52:34 +00:00
phy_iq_calibrate_8188f(dm, is_recovery);
2018-06-22 16:48:32 +00:00
break;
#endif
2019-05-24 19:43:57 +00:00
#if (RTL8192E_SUPPORT == 1)
2018-06-22 16:48:32 +00:00
case ODM_RTL8192E:
2018-08-24 20:52:34 +00:00
phy_iq_calibrate_8192e(dm, is_recovery);
2018-06-22 16:48:32 +00:00
break;
#endif
2019-05-24 19:43:57 +00:00
#if (RTL8197F_SUPPORT == 1)
2018-06-22 16:48:32 +00:00
case ODM_RTL8197F:
2018-08-24 20:52:34 +00:00
phy_iq_calibrate_8197f(dm, is_recovery);
2018-06-22 16:48:32 +00:00
break;
#endif
2019-05-24 19:43:57 +00:00
#if (RTL8192F_SUPPORT == 1)
case ODM_RTL8192F:
phy_iq_calibrate_8192f(dm, is_recovery);
break;
#endif
#if (RTL8703B_SUPPORT == 1)
2018-06-22 16:48:32 +00:00
case ODM_RTL8703B:
2018-08-24 20:52:34 +00:00
phy_iq_calibrate_8703b(dm, is_recovery);
2018-06-22 16:48:32 +00:00
break;
#endif
2019-05-24 19:43:57 +00:00
#if (RTL8710B_SUPPORT == 1)
2018-06-22 16:48:32 +00:00
case ODM_RTL8710B:
2018-08-24 20:52:34 +00:00
phy_iq_calibrate_8710b(dm, is_recovery);
2018-06-22 16:48:32 +00:00
break;
#endif
2019-05-24 19:43:57 +00:00
#if (RTL8723B_SUPPORT == 1)
2018-06-22 16:48:32 +00:00
case ODM_RTL8723B:
2018-08-24 20:52:34 +00:00
phy_iq_calibrate_8723b(dm, is_recovery);
2018-06-22 16:48:32 +00:00
break;
#endif
2019-05-24 19:43:57 +00:00
#if (RTL8723D_SUPPORT == 1)
2018-06-22 16:48:32 +00:00
case ODM_RTL8723D:
2018-08-24 20:52:34 +00:00
phy_iq_calibrate_8723d(dm, is_recovery);
2018-06-22 16:48:32 +00:00
break;
#endif
2019-05-24 19:43:57 +00:00
#if (RTL8721D_SUPPORT == 1)
case ODM_RTL8721D:
phy_iq_calibrate_8721d(dm, is_recovery);
break;
#endif
#if (RTL8812A_SUPPORT == 1)
2018-06-22 16:48:32 +00:00
case ODM_RTL8812:
2018-08-24 20:52:34 +00:00
phy_iq_calibrate_8812a(dm, is_recovery);
2018-06-22 16:48:32 +00:00
break;
#endif
2019-05-24 19:43:57 +00:00
#if (RTL8821A_SUPPORT == 1)
2018-06-22 16:48:32 +00:00
case ODM_RTL8821:
2018-08-24 20:52:34 +00:00
phy_iq_calibrate_8821a(dm, is_recovery);
2018-06-22 16:48:32 +00:00
break;
#endif
2019-05-24 19:43:57 +00:00
#if (RTL8814A_SUPPORT == 1)
2018-06-22 16:48:32 +00:00
case ODM_RTL8814A:
2018-08-24 20:52:34 +00:00
phy_iq_calibrate_8814a(dm, is_recovery);
2018-06-22 16:48:32 +00:00
break;
#endif
2019-05-24 19:43:57 +00:00
#if (RTL8822B_SUPPORT == 1)
2018-06-22 16:48:32 +00:00
case ODM_RTL8822B:
2018-08-24 20:52:34 +00:00
phy_iq_calibrate_8822b(dm, false, false);
2018-06-22 16:48:32 +00:00
break;
#endif
2019-05-24 19:43:57 +00:00
#if (RTL8822C_SUPPORT == 1)
case ODM_RTL8822C:
phy_iq_calibrate_8822c(dm, false, false);
/*halrf_do_tssi_8822c(dm);*/
do_dpk_8822c(dm);
break;
#endif
#if (RTL8821C_SUPPORT == 1)
2018-06-22 16:48:32 +00:00
case ODM_RTL8821C:
2018-08-24 20:52:34 +00:00
phy_iq_calibrate_8821c(dm, false, false);
2018-06-22 16:48:32 +00:00
break;
#endif
2019-05-24 19:43:57 +00:00
#if (RTL8814B_SUPPORT == 1)
2018-06-22 16:48:32 +00:00
case ODM_RTL8814B:
2019-05-24 19:43:57 +00:00
phy_iq_calibrate_8814b(dm, false, false);
break;
#endif
#if (RTL8195B_SUPPORT == 1)
case ODM_RTL8195B:
phy_iq_calibrate_8195b(dm, false, false);
break;
#endif
#if (RTL8198F_SUPPORT == 1)
case ODM_RTL8198F:
phy_iq_calibrate_8198f(dm, false, false);
2018-06-22 16:48:32 +00:00
break;
#endif
2019-05-24 19:43:57 +00:00
2018-06-22 16:48:32 +00:00
default:
break;
}
2019-05-24 19:43:57 +00:00
dm->rf_calibrate_info.iqk_progressing_time =
odm_get_progressing_time(dm, start_time);
RF_DBG(dm, DBG_RF_IQK, "[IQK]IQK progressing_time = %lld ms\n",
dm->rf_calibrate_info.iqk_progressing_time);
2018-08-24 20:52:34 +00:00
odm_acquire_spin_lock(dm, RT_IQK_SPINLOCK);
dm->rf_calibrate_info.is_iqk_in_progress = false;
odm_release_spin_lock(dm, RT_IQK_SPINLOCK);
} else {
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_IQK,
"== Return the IQK CMD, because RFKs in Progress ==\n");
}
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
void halrf_lck_trigger(void *dm_void)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct dm_iqk_info *iqk_info = &dm->IQK_info;
struct _hal_rf_ *rf = &dm->rf_table;
2018-06-22 16:48:32 +00:00
u64 start_time;
2019-05-24 19:43:57 +00:00
2018-06-22 16:48:32 +00:00
#if (DM_ODM_SUPPORT_TYPE & (ODM_WIN))
2018-08-24 20:52:34 +00:00
if (odm_check_power_status(dm) == false)
2018-06-22 16:48:32 +00:00
return;
#endif
2019-05-24 19:43:57 +00:00
if (dm->mp_mode &&
rf->is_con_tx &&
rf->is_single_tone &&
rf->is_carrier_suppresion)
if (*dm->mp_mode &&
((*rf->is_con_tx ||
*rf->is_single_tone ||
*rf->is_carrier_suppresion)))
2018-06-22 16:48:32 +00:00
return;
2018-08-24 20:52:34 +00:00
if (!(rf->rf_supportability & HAL_RF_LCK))
2018-06-22 16:48:32 +00:00
return;
#if DISABLE_BB_RF
2019-05-24 19:43:57 +00:00
return;
2018-06-22 16:48:32 +00:00
#endif
2018-08-24 20:52:34 +00:00
if (iqk_info->rfk_forbidden)
2018-06-22 16:48:32 +00:00
return;
2018-08-24 20:52:34 +00:00
while (*dm->is_scan_in_process) {
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_IQK, "[LCK]scan is in process, bypass LCK\n");
2018-06-22 16:48:32 +00:00
return;
}
2018-08-24 20:52:34 +00:00
if (!dm->rf_calibrate_info.is_lck_in_progress) {
odm_acquire_spin_lock(dm, RT_IQK_SPINLOCK);
dm->rf_calibrate_info.is_lck_in_progress = true;
odm_release_spin_lock(dm, RT_IQK_SPINLOCK);
start_time = odm_get_current_time(dm);
switch (dm->support_ic_type) {
2018-06-22 16:48:32 +00:00
#if (RTL8188E_SUPPORT == 1)
case ODM_RTL8188E:
2018-08-24 20:52:34 +00:00
phy_lc_calibrate_8188e(dm);
2018-06-22 16:48:32 +00:00
break;
#endif
#if (RTL8188F_SUPPORT == 1)
case ODM_RTL8188F:
2018-08-24 20:52:34 +00:00
phy_lc_calibrate_8188f(dm);
2018-06-22 16:48:32 +00:00
break;
#endif
#if (RTL8192E_SUPPORT == 1)
case ODM_RTL8192E:
2018-08-24 20:52:34 +00:00
phy_lc_calibrate_8192e(dm);
2018-06-22 16:48:32 +00:00
break;
#endif
#if (RTL8197F_SUPPORT == 1)
case ODM_RTL8197F:
2018-08-24 20:52:34 +00:00
phy_lc_calibrate_8197f(dm);
2018-06-22 16:48:32 +00:00
break;
#endif
2019-05-24 19:43:57 +00:00
#if (RTL8192F_SUPPORT == 1)
case ODM_RTL8192F:
phy_lc_calibrate_8192f(dm);
break;
#endif
2018-06-22 16:48:32 +00:00
#if (RTL8703B_SUPPORT == 1)
case ODM_RTL8703B:
2018-08-24 20:52:34 +00:00
phy_lc_calibrate_8703b(dm);
2018-06-22 16:48:32 +00:00
break;
#endif
#if (RTL8710B_SUPPORT == 1)
case ODM_RTL8710B:
2018-08-24 20:52:34 +00:00
phy_lc_calibrate_8710b(dm);
2018-06-22 16:48:32 +00:00
break;
#endif
2019-05-24 19:43:57 +00:00
#if (RTL8721D_SUPPORT == 1)
case ODM_RTL8721D:
phy_lc_calibrate_8721d(dm);
break;
#endif
#if (RTL8723B_SUPPORT == 1)
2018-06-22 16:48:32 +00:00
case ODM_RTL8723B:
2018-08-24 20:52:34 +00:00
phy_lc_calibrate_8723b(dm);
2018-06-22 16:48:32 +00:00
break;
#endif
#if (RTL8723D_SUPPORT == 1)
case ODM_RTL8723D:
2018-08-24 20:52:34 +00:00
phy_lc_calibrate_8723d(dm);
2018-06-22 16:48:32 +00:00
break;
#endif
#if (RTL8812A_SUPPORT == 1)
case ODM_RTL8812:
2018-08-24 20:52:34 +00:00
phy_lc_calibrate_8812a(dm);
2018-06-22 16:48:32 +00:00
break;
#endif
2019-05-24 19:43:57 +00:00
#if (RTL8821A_SUPPORT == 1)
2018-06-22 16:48:32 +00:00
case ODM_RTL8821:
2018-08-24 20:52:34 +00:00
phy_lc_calibrate_8821a(dm);
2018-06-22 16:48:32 +00:00
break;
#endif
2019-05-24 19:43:57 +00:00
#if (RTL8814A_SUPPORT == 1)
2018-06-22 16:48:32 +00:00
case ODM_RTL8814A:
2018-08-24 20:52:34 +00:00
phy_lc_calibrate_8814a(dm);
2018-06-22 16:48:32 +00:00
break;
#endif
2019-05-24 19:43:57 +00:00
#if (RTL8822B_SUPPORT == 1)
2018-06-22 16:48:32 +00:00
case ODM_RTL8822B:
2018-08-24 20:52:34 +00:00
phy_lc_calibrate_8822b(dm);
2018-06-22 16:48:32 +00:00
break;
#endif
2019-05-24 19:43:57 +00:00
#if (RTL8822C_SUPPORT == 1)
case ODM_RTL8822C:
phy_lc_calibrate_8822c(dm);
break;
#endif
#if (RTL8821C_SUPPORT == 1)
2018-06-22 16:48:32 +00:00
case ODM_RTL8821C:
2018-08-24 20:52:34 +00:00
phy_lc_calibrate_8821c(dm);
2018-06-22 16:48:32 +00:00
break;
#endif
2019-05-24 19:43:57 +00:00
#if (RTL8814B_SUPPORT == 1)
2018-06-22 16:48:32 +00:00
case ODM_RTL8814B:
break;
#endif
default:
break;
}
2019-05-24 19:43:57 +00:00
dm->rf_calibrate_info.lck_progressing_time =
odm_get_progressing_time(dm, start_time);
RF_DBG(dm, DBG_RF_IQK, "[IQK]LCK progressing_time = %lld ms\n",
dm->rf_calibrate_info.lck_progressing_time);
2018-06-22 16:48:32 +00:00
#if (RTL8822B_SUPPORT == 1 || RTL8821C_SUPPORT == 1)
2018-08-24 20:52:34 +00:00
halrf_lck_dbg(dm);
2018-06-22 16:48:32 +00:00
#endif
2018-08-24 20:52:34 +00:00
odm_acquire_spin_lock(dm, RT_IQK_SPINLOCK);
dm->rf_calibrate_info.is_lck_in_progress = false;
2019-05-24 19:43:57 +00:00
odm_release_spin_lock(dm, RT_IQK_SPINLOCK);
} else {
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_IQK,
"= Return the LCK CMD, because RFK is in Progress =\n");
}
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
void halrf_aac_check(struct dm_struct *dm)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
switch (dm->support_ic_type) {
#if (RTL8821C_SUPPORT == 1)
case ODM_RTL8821C:
#if 0
aac_check_8821c(dm);
#endif
break;
#endif
#if (RTL8822B_SUPPORT == 1)
case ODM_RTL8822B:
#if 1
aac_check_8822b(dm);
#endif
break;
#endif
default:
break;
}
}
void halrf_init(void *dm_void)
{
struct dm_struct *dm = (struct dm_struct *)dm_void;
RF_DBG(dm, DBG_RF_INIT, "HALRF_Init\n");
halrf_init_debug_setting(dm);
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
if (*dm->mp_mode)
2018-08-24 20:52:34 +00:00
halrf_supportability_init_mp(dm);
2018-06-22 16:48:32 +00:00
else
2018-08-24 20:52:34 +00:00
halrf_supportability_init(dm);
2019-05-24 19:43:57 +00:00
#if 1
2018-06-22 16:48:32 +00:00
/*Init all RF funciton*/
2019-05-24 19:43:57 +00:00
halrf_aac_check(dm);
halrf_dack_trigger(dm);
#endif
halrf_tssi_init(dm);
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
void halrf_dpk_trigger(void *dm_void)
{
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct _hal_rf_ *rf = &dm->rf_table;
struct dm_dpk_info *dpk_info = &dm->dpk_info;
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
u64 start_time;
start_time = odm_get_current_time(dm);
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
switch (dm->support_ic_type) {
#if (RTL8822C_SUPPORT == 1)
case ODM_RTL8822C:
do_dpk_8822c(dm);
break;
#endif
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
#if (RTL8197F_SUPPORT == 1)
case ODM_RTL8197F:
do_dpk_8197f(dm);
break;
#endif
#if (RTL8192F_SUPPORT == 1)
case ODM_RTL8192F:
do_dpk_8192f(dm);
break;
#endif
#if (RTL8198F_SUPPORT == 1)
case ODM_RTL8198F:
do_dpk_8198f(dm);
break;
#endif
#if (RTL8814B_SUPPORT == 1)
case ODM_RTL8814B:
break;
#endif
#endif
#if (DM_ODM_SUPPORT_TYPE & (ODM_IOT))
#if (RTL8195B_SUPPORT == 1)
case ODM_RTL8195B:
if (!dpk_info->is_dpk_by_channel) {
dpk_by_channel(dm); /*do dpk 9 ch*/
dpk_result_summary_8195b(dm);
} else {
/*do dpk 1 ch*/
do_dpk_8195b(dm, false);
}
break;
#endif
#endif
default:
break;
}
rf->dpk_progressing_time = odm_get_progressing_time(dm, start_time);
RF_DBG(dm, DBG_RF_DPK, "[DPK]DPK progressing_time = %lld ms\n",
rf->dpk_progressing_time);
}
u8 halrf_dpk_result_check(void *dm_void)
{
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct dm_dpk_info *dpk_info = &dm->dpk_info;
u8 result = 0;
switch (dm->support_ic_type) {
#if (RTL8822C_SUPPORT == 1)
case ODM_RTL8822C:
if (dpk_info->dpk_path_ok == 0x3)
result = 1;
else
result = 0;
break;
#endif
#if (RTL8195B_SUPPORT == 1)
case ODM_RTL8195B:
if (dpk_info->dpk_path_ok == 0x1)
result = 1;
else
result = 0;
break;
#endif
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
#if (RTL8197F_SUPPORT == 1)
case ODM_RTL8197F:
if (dpk_info->dpk_path_ok == 0x3)
result = 1;
else
result = 0;
break;
#endif
#if (RTL8192F_SUPPORT == 1)
case ODM_RTL8192F:
if (dpk_info->dpk_path_ok == 0x3)
result = 1;
else
result = 0;
break;
#endif
#if (RTL8198F_SUPPORT == 1)
case ODM_RTL8198F:
if (dpk_info->dpk_path_ok == 0xf)
result = 1;
else
result = 0;
break;
#endif
#endif
default:
break;
}
return result;
}
void halrf_dpk_sram_read(void *dm_void)
{
struct dm_struct *dm = (struct dm_struct *)dm_void;
u8 path, group;
switch (dm->support_ic_type) {
#if (RTL8822C_SUPPORT == 1)
case ODM_RTL8822C:
dpk_coef_read_8822c(dm);
break;
#endif
#if (RTL8195B_SUPPORT == 1)
case ODM_RTL8195B:
dpk_sram_read_8195b(dm);
break;
#endif
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
#if (RTL8197F_SUPPORT == 1)
case ODM_RTL8197F:
dpk_sram_read_8197f(dm);
break;
#endif
#if (RTL8192F_SUPPORT == 1)
case ODM_RTL8192F:
dpk_sram_read_8192f(dm);
break;
#endif
#if (RTL8198F_SUPPORT == 1)
case ODM_RTL8198F:
dpk_sram_read_8198f(dm);
break;
#endif
#endif
default:
break;
}
}
void halrf_dpk_enable_disable(void *dm_void)
{
struct dm_struct *dm = (struct dm_struct *)dm_void;
switch (dm->support_ic_type) {
#if (RTL8822C_SUPPORT == 1)
case ODM_RTL8822C:
dpk_enable_disable_8822c(dm);
break;
#endif
#if (RTL8195B_SUPPORT == 1)
case ODM_RTL8195B:
dpk_enable_disable_8195b(dm);
break;
#endif
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
#if (RTL8197F_SUPPORT == 1)
case ODM_RTL8197F:
phy_dpk_enable_disable_8197f(dm);
break;
#endif
#if (RTL8192F_SUPPORT == 1)
case ODM_RTL8192F:
phy_dpk_enable_disable_8192f(dm);
break;
#endif
#if (RTL8198F_SUPPORT == 1)
case ODM_RTL8198F:
dpk_enable_disable_8198f(dm);
break;
#endif
#endif
default:
break;
}
}
void halrf_dpk_track(void *dm_void)
{
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct dm_dpk_info *dpk_info = &dm->dpk_info;
switch (dm->support_ic_type) {
#if (RTL8822C_SUPPORT == 1)
case ODM_RTL8822C:
dpk_track_8822c(dm);
break;
#endif
#if (RTL8195B_SUPPORT == 1)
case ODM_RTL8195B:
dpk_track_8195b(dm);
break;
#endif
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
#if (RTL8197F_SUPPORT == 1)
case ODM_RTL8197F:
phy_dpk_track_8197f(dm);
break;
#endif
#if (RTL8192F_SUPPORT == 1)
case ODM_RTL8192F:
phy_dpk_track_8192f(dm);
break;
#endif
#if (RTL8198F_SUPPORT == 1)
case ODM_RTL8198F:
dpk_track_8198f(dm);
break;
#endif
#endif
default:
break;
}
}
void halrf_dpk_reload(void *dm_void)
{
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct dm_dpk_info *dpk_info = &dm->dpk_info;
switch (dm->support_ic_type) {
#if (RTL8195B_SUPPORT == 1)
case ODM_RTL8195B:
dpk_reload_8195b(dm);
break;
#endif
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
#if (RTL8197F_SUPPORT == 1)
case ODM_RTL8197F:
if (dpk_info->dpk_path_ok > 0)
dpk_reload_8197f(dm);
break;
#endif
#if (RTL8192F_SUPPORT == 1)
case ODM_RTL8192F:
if (dpk_info->dpk_path_ok > 0)
dpk_reload_8192f(dm);
break;
#endif
#if (RTL8198F_SUPPORT == 1)
case ODM_RTL8198F:
if (dpk_info->dpk_path_ok > 0)
dpk_reload_8198f(dm);
break;
#endif
#endif
default:
break;
}
}
enum hal_status
halrf_config_rfk_with_header_file(void *dm_void, u32 config_type)
{
struct dm_struct *dm = (struct dm_struct *)dm_void;
enum hal_status result = HAL_STATUS_SUCCESS;
#if 0
#if (RTL8822B_SUPPORT == 1)
if (dm->support_ic_type == ODM_RTL8822B) {
if (config_type == CONFIG_BB_RF_CAL_INIT)
odm_read_and_config_mp_8822b_cal_init(dm);
}
#endif
#endif
#if (RTL8198F_SUPPORT == 1)
if (dm->support_ic_type == ODM_RTL8198F) {
if (config_type == CONFIG_BB_RF_CAL_INIT)
odm_read_and_config_mp_8198f_cal_init(dm);
}
#endif
#if (RTL8822C_SUPPORT == 1)
if (dm->support_ic_type == ODM_RTL8822C) {
if (config_type == CONFIG_BB_RF_CAL_INIT)
odm_read_and_config_mp_8822c_cal_init(dm);
}
#endif
#if (RTL8814B_SUPPORT == 1)
if (dm->support_ic_type == ODM_RTL8814B) {
if (config_type == CONFIG_BB_RF_CAL_INIT)
odm_read_and_config_mp_8814b_cal_init(dm);
}
#endif
#if (RTL8195B_SUPPORT == 1)
if (dm->support_ic_type == ODM_RTL8195B) {
if (config_type == CONFIG_BB_RF_CAL_INIT)
odm_read_and_config_mp_8195b_cal_init(dm);
}
#endif
return result;
}
void halrf_txgapk_trigger(void *dm_void)
{
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct _hal_rf_ *rf = &dm->rf_table;
u64 start_time;
start_time = odm_get_current_time(dm);
switch (dm->support_ic_type) {
#if (DM_ODM_SUPPORT_TYPE & (ODM_IOT))
#if (RTL8195B_SUPPORT == 1)
case ODM_RTL8195B:
phy_txgap_calibrate_8195b(dm, false);
break;
#endif
#endif
default:
break;
}
rf->dpk_progressing_time =
odm_get_progressing_time(dm_void, start_time);
RF_DBG(dm, DBG_RF_TXGAPK, "[TGGC]TXGAPK progressing_time = %lld ms\n",
rf->dpk_progressing_time);
}
void halrf_tssi_init(void *dm_void)
{
struct dm_struct *dm = (struct dm_struct *)dm_void;
#if (RTL8822C_SUPPORT == 1)
halrf_tssi_init_8822c(dm);
#endif
}
void halrf_do_tssi(void *dm_void)
{
struct dm_struct *dm = (struct dm_struct *)dm_void;
#if (RTL8822C_SUPPORT == 1)
halrf_do_tssi_8822c(dm);
#endif
}
void halrf_set_tssi_value(void *dm_void, u32 tssi_value)
{
struct dm_struct *dm = (struct dm_struct *)dm_void;
#if (RTL8822C_SUPPORT == 1)
halrf_set_tssi_value_8822c(dm, tssi_value);
#endif
}
u32 halrf_query_tssi_value(void *dm_void)
{
struct dm_struct *dm = (struct dm_struct *)dm_void;
#if (RTL8822C_SUPPORT == 1)
return halrf_query_tssi_value_8822c(dm);
#endif
return 0;
}
/*Golbal function*/
void halrf_reload_bp(void *dm_void, u32 *bp_reg, u32 *bp, u32 num)
{
struct dm_struct *dm = (struct dm_struct *)dm_void;
u32 i;
for (i = 0; i < num; i++)
odm_write_4byte(dm, bp_reg[i], bp[i]);
}
void halrf_reload_bprf(void *dm_void, u32 *bp_reg, u32 bp[][4], u32 num,
u8 ss)
{
struct dm_struct *dm = (struct dm_struct *)dm_void;
u32 i, path;
for (i = 0; i < num; i++) {
for (path = 0; path < ss; path++)
odm_set_rf_reg(dm, (enum rf_path)path, bp_reg[i],
MASK20BITS, bp[i][path]);
}
}
void halrf_bp(void *dm_void, u32 *bp_reg, u32 *bp, u32 num)
{
struct dm_struct *dm = (struct dm_struct *)dm_void;
u32 i;
for (i = 0; i < num; i++)
bp[i] = odm_read_4byte(dm, bp_reg[i]);
}
void halrf_bprf(void *dm_void, u32 *bp_reg, u32 bp[][4], u32 num, u8 ss)
{
struct dm_struct *dm = (struct dm_struct *)dm_void;
u32 i, path;
for (i = 0; i < num; i++) {
for (path = 0; path < ss; path++) {
bp[i][path] =
odm_get_rf_reg(dm, (enum rf_path)path,
bp_reg[i], MASK20BITS);
}
}
}
void halrf_swap(void *dm_void, u32 *v1, u32 *v2)
{
struct dm_struct *dm = (struct dm_struct *)dm_void;
u32 temp;
temp = *v1;
*v1 = *v2;
*v2 = temp;
}
void halrf_bubble(void *dm_void, u32 *v1, u32 *v2)
{
struct dm_struct *dm = (struct dm_struct *)dm_void;
u32 temp;
if (*v1 >= 0x200 && *v2 >= 0x200) {
if (*v1 > *v2)
halrf_swap(dm, v1, v2);
} else if (*v1 < 0x200 && *v2 < 0x200) {
if (*v1 > *v2)
halrf_swap(dm, v1, v2);
} else if (*v1 < 0x200 && *v2 >= 0x200) {
halrf_swap(dm, v1, v2);
}
}
void halrf_b_sort(void *dm_void, u32 *iv, u32 *qv)
{
struct dm_struct *dm = (struct dm_struct *)dm_void;
u32 temp;
u32 i, j;
RF_DBG(dm, DBG_RF_DACK, "[DACK]bubble!!!!!!!!!!!!");
for (i = 0; i < SN - 1; i++) {
for (j = 0; j < (SN - 1 - i) ; j++) {
halrf_bubble(dm, &iv[j], &iv[j + 1]);
halrf_bubble(dm, &qv[j], &qv[j + 1]);
}
}
}
void halrf_minmax_compare(void *dm_void, u32 value, u32 *min,
u32 *max)
{
struct dm_struct *dm = (struct dm_struct *)dm_void;
if (value >= 0x200) {
if (*min >= 0x200) {
if (*min > value)
*min = value;
} else {
*min = value;
}
if (*max >= 0x200) {
if (*max < value)
*max = value;
}
} else {
if (*min < 0x200) {
if (*min > value)
*min = value;
}
if (*max >= 0x200) {
*max = value;
} else {
if (*max < value)
*max = value;
}
}
}
u32 halrf_delta(void *dm_void, u32 v1, u32 v2)
{
struct dm_struct *dm = (struct dm_struct *)dm_void;
if (v1 >= 0x200 && v2 >= 0x200) {
if (v1 > v2)
return v1 - v2;
else
return v2 - v1;
} else if (v1 >= 0x200 && v2 < 0x200) {
return v2 + (0x400 - v1);
} else if (v1 < 0x200 && v2 >= 0x200) {
return v1 + (0x400 - v2);
}
if (v1 > v2)
return v1 - v2;
else
return v2 - v1;
}
boolean halrf_compare(void *dm_void, u32 value)
{
struct dm_struct *dm = (struct dm_struct *)dm_void;
boolean fail = false;
if (value >= 0x200 && (0x400 - value) > 0x64)
fail = true;
else if (value < 0x200 && value > 0x64)
fail = true;
if (fail)
RF_DBG(dm, DBG_RF_DACK, "[DACK]overflow!!!!!!!!!!!!!!!");
return fail;
}
void halrf_mode(void *dm_void, u32 *i_value, u32 *q_value)
{
struct dm_struct *dm = (struct dm_struct *)dm_void;
u32 iv[SN], qv[SN], im[SN], qm[SN], temp, temp1, temp2;
u32 p, m, t;
u32 i_max = 0, q_max = 0, i_min = 0x0, q_min = 0x0, c = 0x0;
u32 i_delta, q_delta;
u8 i, j, ii = 0, qi = 0;
boolean fail = false;
ODM_delay_ms(10);
for (i = 0; i < SN; i++) {
im[i] = 0;
qm[i] = 0;
}
i = 0;
c = 0;
while (i < SN && c < 1000) {
c++;
temp = odm_get_bb_reg(dm, 0x2dbc, 0x3fffff);
iv[i] = (temp & 0x3ff000) >> 12;
qv[i] = temp & 0x3ff;
fail = false;
if (halrf_compare(dm, iv[i]))
fail = true;
if (halrf_compare(dm, qv[i]))
fail = true;
if (!fail)
i++;
}
c = 0;
do {
c++;
i_min = iv[0];
i_max = iv[0];
q_min = qv[0];
q_max = qv[0];
for (i = 0; i < SN; i++) {
halrf_minmax_compare(dm, iv[i], &i_min, &i_max);
halrf_minmax_compare(dm, qv[i], &q_min, &q_max);
}
RF_DBG(dm, DBG_RF_DACK, "[DACK]i_min=0x%x, i_max=0x%x",
i_min, i_max);
RF_DBG(dm, DBG_RF_DACK, "[DACK]q_min=0x%x, q_max=0x%x",
q_min, q_max);
if (i_max < 0x200 && i_min < 0x200)
i_delta = i_max - i_min;
else if (i_max >= 0x200 && i_min >= 0x200)
i_delta = i_max - i_min;
else
i_delta = i_max + (0x400 - i_min);
if (q_max < 0x200 && q_min < 0x200)
q_delta = q_max - q_min;
else if (q_max >= 0x200 && q_min >= 0x200)
q_delta = q_max - q_min;
else
q_delta = q_max + (0x400 - q_min);
RF_DBG(dm, DBG_RF_DACK, "[DACK]i_delta=0x%x, q_delta=0x%x",
i_delta, q_delta);
halrf_b_sort(dm, iv, qv);
if (i_delta > 5 || q_delta > 5) {
temp = odm_get_bb_reg(dm, 0x2dbc, 0x3fffff);
iv[0] = (temp & 0x3ff000) >> 12;
qv[0] = temp & 0x3ff;
temp = odm_get_bb_reg(dm, 0x2dbc, 0x3fffff);
iv[SN - 1] = (temp & 0x3ff000) >> 12;
qv[SN - 1] = temp & 0x3ff;
} else {
break;
}
} while (c < 100);
#if 1
#if 0
for (i = 0; i < SN; i++)
RF_DBG(dm, DBG_RF_DACK, "[DACK]iv[%d] = 0x%x\n", i, iv[i]);
for (i = 0; i < SN; i++)
RF_DBG(dm, DBG_RF_DACK, "[DACK]qv[%d] = 0x%x\n", i, qv[i]);
#endif
/*i*/
m = 0;
p = 0;
for (i = 10; i < SN - 10; i++) {
if (iv[i] > 0x200)
m = (0x400 - iv[i]) + m;
else
p = iv[i] + p;
}
if (p > m) {
t = p - m;
t = t / (SN - 20);
} else {
t = m - p;
t = t / (SN - 20);
if (t != 0x0)
t = 0x400 - t;
}
*i_value = t;
/*q*/
m = 0;
p = 0;
for (i = 10; i < SN - 10; i++) {
if (qv[i] > 0x200)
m = (0x400 - qv[i]) + m;
else
p = qv[i] + p;
}
if (p > m) {
t = p - m;
t = t / (SN - 20);
} else {
t = m - p;
t = t / (SN - 20);
if (t != 0x0)
t = 0x400 - t;
}
*q_value = t;
#endif
}
2018-06-22 16:48:32 +00:00