@@ -1042,8 +1042,7 @@ static int rtw_chip_board_info_setup(struct rtw_dev *rtwdev)
rtw_phy_setup_phy_cond(rtwdev, 0);
rtw_hw_init_tx_power(hal);
- if (rtwdev->chip->id != RTW_CHIP_TYPE_8822C)
- rtw_load_table(rtwdev, rfe_def->phy_pg_tbl);
+ rtw_load_table(rtwdev, rfe_def->phy_pg_tbl);
rtw_load_table(rtwdev, rfe_def->txpwr_lmt_tbl);
rtw_phy_tx_power_by_rate_config(hal);
rtw_phy_tx_power_limit_config(hal);
@@ -807,6 +807,8 @@ struct rtw_chip_info {
u8 csi_buf_pg_num;
u8 dig_max;
u8 dig_min;
+ u8 txgi_factor;
+ bool is_pwr_by_rate_dec;
bool ht_supported;
bool vht_supported;
@@ -959,13 +959,16 @@ static u8 rtw_get_channel_group(u8 channel)
}
}
-static u8 phy_get_2g_tx_power_index(struct rtw_2g_txpwr_idx *pwr_idx_2g,
+static u8 phy_get_2g_tx_power_index(struct rtw_dev *rtwdev,
+ struct rtw_2g_txpwr_idx *pwr_idx_2g,
enum rtw_bandwidth bandwidth,
u8 rate, u8 group)
{
+ struct rtw_chip_info *chip = rtwdev->chip;
u8 tx_power;
bool mcs_rate;
bool above_2ss;
+ u8 factor = chip->txgi_factor;
if (rate <= DESC_RATE11M)
tx_power = pwr_idx_2g->cck_base[group];
@@ -973,7 +976,7 @@ static u8 phy_get_2g_tx_power_index(struct rtw_2g_txpwr_idx *pwr_idx_2g,
tx_power = pwr_idx_2g->bw40_base[group];
if (rate >= DESC_RATE6M && rate <= DESC_RATE54M)
- tx_power += pwr_idx_2g->ht_1s_diff.ofdm;
+ tx_power += pwr_idx_2g->ht_1s_diff.ofdm * factor;
mcs_rate = (rate >= DESC_RATEMCS0 && rate <= DESC_RATEMCS15) ||
(rate >= DESC_RATEVHT1SS_MCS0 &&
@@ -988,28 +991,31 @@ static u8 phy_get_2g_tx_power_index(struct rtw_2g_txpwr_idx *pwr_idx_2g,
default:
WARN_ON(1);
case RTW_CHANNEL_WIDTH_20:
- tx_power += pwr_idx_2g->ht_1s_diff.bw20;
+ tx_power += pwr_idx_2g->ht_1s_diff.bw20 * factor;
if (above_2ss)
- tx_power += pwr_idx_2g->ht_2s_diff.bw20;
+ tx_power += pwr_idx_2g->ht_2s_diff.bw20 * factor;
break;
case RTW_CHANNEL_WIDTH_40:
/* bw40 is the base power */
if (above_2ss)
- tx_power += pwr_idx_2g->ht_2s_diff.bw40;
+ tx_power += pwr_idx_2g->ht_2s_diff.bw40 * factor;
break;
}
return tx_power;
}
-static u8 phy_get_5g_tx_power_index(struct rtw_5g_txpwr_idx *pwr_idx_5g,
+static u8 phy_get_5g_tx_power_index(struct rtw_dev *rtwdev,
+ struct rtw_5g_txpwr_idx *pwr_idx_5g,
enum rtw_bandwidth bandwidth,
u8 rate, u8 group)
{
+ struct rtw_chip_info *chip = rtwdev->chip;
u8 tx_power;
u8 upper, lower;
bool mcs_rate;
bool above_2ss;
+ u8 factor = chip->txgi_factor;
tx_power = pwr_idx_5g->bw40_base[group];
@@ -1020,7 +1026,7 @@ static u8 phy_get_5g_tx_power_index(struct rtw_5g_txpwr_idx *pwr_idx_5g,
(rate >= DESC_RATEVHT2SS_MCS0);
if (!mcs_rate) {
- tx_power += pwr_idx_5g->ht_1s_diff.ofdm;
+ tx_power += pwr_idx_5g->ht_1s_diff.ofdm * factor;
return tx_power;
}
@@ -1028,14 +1034,14 @@ static u8 phy_get_5g_tx_power_index(struct rtw_5g_txpwr_idx *pwr_idx_5g,
default:
WARN_ON(1);
case RTW_CHANNEL_WIDTH_20:
- tx_power += pwr_idx_5g->ht_1s_diff.bw20;
+ tx_power += pwr_idx_5g->ht_1s_diff.bw20 * factor;
if (above_2ss)
- tx_power += pwr_idx_5g->ht_2s_diff.bw20;
+ tx_power += pwr_idx_5g->ht_2s_diff.bw20 * factor;
break;
case RTW_CHANNEL_WIDTH_40:
/* bw40 is the base power */
if (above_2ss)
- tx_power += pwr_idx_5g->ht_2s_diff.bw40;
+ tx_power += pwr_idx_5g->ht_2s_diff.bw40 * factor;
break;
case RTW_CHANNEL_WIDTH_80:
/* the base idx of bw80 is the average of bw40+/bw40- */
@@ -1043,9 +1049,9 @@ static u8 phy_get_5g_tx_power_index(struct rtw_5g_txpwr_idx *pwr_idx_5g,
upper = pwr_idx_5g->bw40_base[group + 1];
tx_power = (lower + upper) / 2;
- tx_power += pwr_idx_5g->vht_1s_diff.bw80;
+ tx_power += pwr_idx_5g->vht_1s_diff.bw80 * factor;
if (above_2ss)
- tx_power += pwr_idx_5g->vht_2s_diff.bw80;
+ tx_power += pwr_idx_5g->vht_2s_diff.bw80 * factor;
break;
}
@@ -1108,12 +1114,14 @@ u8 phy_get_tx_power_index(void *adapter, u8 rf_path, u8 rate,
/* base power index for 2.4G/5G */
if (channel <= 14) {
band = PHY_BAND_2G;
- tx_power = phy_get_2g_tx_power_index(&pwr_idx->pwr_idx_2g,
+ tx_power = phy_get_2g_tx_power_index(rtwdev,
+ &pwr_idx->pwr_idx_2g,
bandwidth, rate, group);
offset = hal->tx_pwr_by_rate_offset_2g[rf_path][rate];
} else {
band = PHY_BAND_5G;
- tx_power = phy_get_5g_tx_power_index(&pwr_idx->pwr_idx_5g,
+ tx_power = phy_get_5g_tx_power_index(rtwdev,
+ &pwr_idx->pwr_idx_5g,
bandwidth, rate, group);
offset = hal->tx_pwr_by_rate_offset_5g[rf_path][rate];
}
@@ -1167,6 +1175,14 @@ void phy_set_tx_power_index_by_rs(void *adapter, u8 ch, u8 path, u8 rs)
}
}
+static u8 tbl_to_dec_pwr_by_rate(struct rtw_dev *rtwdev, u32 hex, u8 i)
+{
+ if (rtwdev->chip->is_pwr_by_rate_dec)
+ return bcd_to_dec_pwr_by_rate(hex, i);
+ else
+ return (hex >> (i * 8)) & 0xFF;
+}
+
static void phy_get_rate_values_of_txpwr_by_rate(struct rtw_dev *rtwdev,
u32 addr, u32 mask,
u32 val, u8 *rate,
@@ -1182,7 +1198,7 @@ static void phy_get_rate_values_of_txpwr_by_rate(struct rtw_dev *rtwdev,
rate[2] = DESC_RATE12M;
rate[3] = DESC_RATE18M;
for (i = 0; i < 4; ++i)
- pwr_by_rate[i] = bcd_to_dec_pwr_by_rate(val, i);
+ pwr_by_rate[i] = tbl_to_dec_pwr_by_rate(rtwdev, val, i);
*rate_num = 4;
break;
case 0xE04:
@@ -1192,7 +1208,7 @@ static void phy_get_rate_values_of_txpwr_by_rate(struct rtw_dev *rtwdev,
rate[2] = DESC_RATE48M;
rate[3] = DESC_RATE54M;
for (i = 0; i < 4; ++i)
- pwr_by_rate[i] = bcd_to_dec_pwr_by_rate(val, i);
+ pwr_by_rate[i] = tbl_to_dec_pwr_by_rate(rtwdev, val, i);
*rate_num = 4;
break;
case 0xE08:
@@ -1207,7 +1223,7 @@ static void phy_get_rate_values_of_txpwr_by_rate(struct rtw_dev *rtwdev,
rate[2] = DESC_RATE11M;
for (i = 1; i < 4; ++i)
pwr_by_rate[i - 1] =
- bcd_to_dec_pwr_by_rate(val, i);
+ tbl_to_dec_pwr_by_rate(rtwdev, val, i);
*rate_num = 3;
} else if (mask == 0x000000ff) {
rate[0] = DESC_RATE11M;
@@ -1222,7 +1238,7 @@ static void phy_get_rate_values_of_txpwr_by_rate(struct rtw_dev *rtwdev,
rate[2] = DESC_RATEMCS2;
rate[3] = DESC_RATEMCS3;
for (i = 0; i < 4; ++i)
- pwr_by_rate[i] = bcd_to_dec_pwr_by_rate(val, i);
+ pwr_by_rate[i] = tbl_to_dec_pwr_by_rate(rtwdev, val, i);
*rate_num = 4;
break;
case 0xE14:
@@ -1232,7 +1248,7 @@ static void phy_get_rate_values_of_txpwr_by_rate(struct rtw_dev *rtwdev,
rate[2] = DESC_RATEMCS6;
rate[3] = DESC_RATEMCS7;
for (i = 0; i < 4; ++i)
- pwr_by_rate[i] = bcd_to_dec_pwr_by_rate(val, i);
+ pwr_by_rate[i] = tbl_to_dec_pwr_by_rate(rtwdev, val, i);
*rate_num = 4;
break;
case 0xE18:
@@ -1242,7 +1258,7 @@ static void phy_get_rate_values_of_txpwr_by_rate(struct rtw_dev *rtwdev,
rate[2] = DESC_RATEMCS10;
rate[3] = DESC_RATEMCS11;
for (i = 0; i < 4; ++i)
- pwr_by_rate[i] = bcd_to_dec_pwr_by_rate(val, i);
+ pwr_by_rate[i] = tbl_to_dec_pwr_by_rate(rtwdev, val, i);
*rate_num = 4;
break;
case 0xE1C:
@@ -1252,7 +1268,7 @@ static void phy_get_rate_values_of_txpwr_by_rate(struct rtw_dev *rtwdev,
rate[2] = DESC_RATEMCS14;
rate[3] = DESC_RATEMCS15;
for (i = 0; i < 4; ++i)
- pwr_by_rate[i] = bcd_to_dec_pwr_by_rate(val, i);
+ pwr_by_rate[i] = tbl_to_dec_pwr_by_rate(rtwdev, val, i);
*rate_num = 4;
break;
@@ -1261,7 +1277,8 @@ static void phy_get_rate_values_of_txpwr_by_rate(struct rtw_dev *rtwdev,
rate[1] = DESC_RATE2M;
rate[2] = DESC_RATE5_5M;
for (i = 1; i < 4; ++i)
- pwr_by_rate[i - 1] = bcd_to_dec_pwr_by_rate(val, i);
+ pwr_by_rate[i - 1] = tbl_to_dec_pwr_by_rate(rtwdev,
+ val, i);
*rate_num = 3;
break;
case 0xC20:
@@ -1273,7 +1290,7 @@ static void phy_get_rate_values_of_txpwr_by_rate(struct rtw_dev *rtwdev,
rate[2] = DESC_RATE5_5M;
rate[3] = DESC_RATE11M;
for (i = 0; i < 4; ++i)
- pwr_by_rate[i] = bcd_to_dec_pwr_by_rate(val, i);
+ pwr_by_rate[i] = tbl_to_dec_pwr_by_rate(rtwdev, val, i);
*rate_num = 4;
break;
case 0xC24:
@@ -1285,7 +1302,7 @@ static void phy_get_rate_values_of_txpwr_by_rate(struct rtw_dev *rtwdev,
rate[2] = DESC_RATE12M;
rate[3] = DESC_RATE18M;
for (i = 0; i < 4; ++i)
- pwr_by_rate[i] = bcd_to_dec_pwr_by_rate(val, i);
+ pwr_by_rate[i] = tbl_to_dec_pwr_by_rate(rtwdev, val, i);
*rate_num = 4;
break;
case 0xC28:
@@ -1297,7 +1314,7 @@ static void phy_get_rate_values_of_txpwr_by_rate(struct rtw_dev *rtwdev,
rate[2] = DESC_RATE48M;
rate[3] = DESC_RATE54M;
for (i = 0; i < 4; ++i)
- pwr_by_rate[i] = bcd_to_dec_pwr_by_rate(val, i);
+ pwr_by_rate[i] = tbl_to_dec_pwr_by_rate(rtwdev, val, i);
*rate_num = 4;
break;
case 0xC2C:
@@ -1309,7 +1326,7 @@ static void phy_get_rate_values_of_txpwr_by_rate(struct rtw_dev *rtwdev,
rate[2] = DESC_RATEMCS2;
rate[3] = DESC_RATEMCS3;
for (i = 0; i < 4; ++i)
- pwr_by_rate[i] = bcd_to_dec_pwr_by_rate(val, i);
+ pwr_by_rate[i] = tbl_to_dec_pwr_by_rate(rtwdev, val, i);
*rate_num = 4;
break;
case 0xC30:
@@ -1321,7 +1338,7 @@ static void phy_get_rate_values_of_txpwr_by_rate(struct rtw_dev *rtwdev,
rate[2] = DESC_RATEMCS6;
rate[3] = DESC_RATEMCS7;
for (i = 0; i < 4; ++i)
- pwr_by_rate[i] = bcd_to_dec_pwr_by_rate(val, i);
+ pwr_by_rate[i] = tbl_to_dec_pwr_by_rate(rtwdev, val, i);
*rate_num = 4;
break;
case 0xC34:
@@ -1333,7 +1350,7 @@ static void phy_get_rate_values_of_txpwr_by_rate(struct rtw_dev *rtwdev,
rate[2] = DESC_RATEMCS10;
rate[3] = DESC_RATEMCS11;
for (i = 0; i < 4; ++i)
- pwr_by_rate[i] = bcd_to_dec_pwr_by_rate(val, i);
+ pwr_by_rate[i] = tbl_to_dec_pwr_by_rate(rtwdev, val, i);
*rate_num = 4;
break;
case 0xC38:
@@ -1345,7 +1362,7 @@ static void phy_get_rate_values_of_txpwr_by_rate(struct rtw_dev *rtwdev,
rate[2] = DESC_RATEMCS14;
rate[3] = DESC_RATEMCS15;
for (i = 0; i < 4; ++i)
- pwr_by_rate[i] = bcd_to_dec_pwr_by_rate(val, i);
+ pwr_by_rate[i] = tbl_to_dec_pwr_by_rate(rtwdev, val, i);
*rate_num = 4;
break;
case 0xC3C:
@@ -1357,7 +1374,7 @@ static void phy_get_rate_values_of_txpwr_by_rate(struct rtw_dev *rtwdev,
rate[2] = DESC_RATEVHT1SS_MCS2;
rate[3] = DESC_RATEVHT1SS_MCS3;
for (i = 0; i < 4; ++i)
- pwr_by_rate[i] = bcd_to_dec_pwr_by_rate(val, i);
+ pwr_by_rate[i] = tbl_to_dec_pwr_by_rate(rtwdev, val, i);
*rate_num = 4;
break;
case 0xC40:
@@ -1369,7 +1386,7 @@ static void phy_get_rate_values_of_txpwr_by_rate(struct rtw_dev *rtwdev,
rate[2] = DESC_RATEVHT1SS_MCS6;
rate[3] = DESC_RATEVHT1SS_MCS7;
for (i = 0; i < 4; ++i)
- pwr_by_rate[i] = bcd_to_dec_pwr_by_rate(val, i);
+ pwr_by_rate[i] = tbl_to_dec_pwr_by_rate(rtwdev, val, i);
*rate_num = 4;
break;
case 0xC44:
@@ -1381,7 +1398,7 @@ static void phy_get_rate_values_of_txpwr_by_rate(struct rtw_dev *rtwdev,
rate[2] = DESC_RATEVHT2SS_MCS0;
rate[3] = DESC_RATEVHT2SS_MCS1;
for (i = 0; i < 4; ++i)
- pwr_by_rate[i] = bcd_to_dec_pwr_by_rate(val, i);
+ pwr_by_rate[i] = tbl_to_dec_pwr_by_rate(rtwdev, val, i);
*rate_num = 4;
break;
case 0xC48:
@@ -1393,7 +1410,7 @@ static void phy_get_rate_values_of_txpwr_by_rate(struct rtw_dev *rtwdev,
rate[2] = DESC_RATEVHT2SS_MCS4;
rate[3] = DESC_RATEVHT2SS_MCS5;
for (i = 0; i < 4; ++i)
- pwr_by_rate[i] = bcd_to_dec_pwr_by_rate(val, i);
+ pwr_by_rate[i] = tbl_to_dec_pwr_by_rate(rtwdev, val, i);
*rate_num = 4;
break;
case 0xC4C:
@@ -1405,7 +1422,7 @@ static void phy_get_rate_values_of_txpwr_by_rate(struct rtw_dev *rtwdev,
rate[2] = DESC_RATEVHT2SS_MCS8;
rate[3] = DESC_RATEVHT2SS_MCS9;
for (i = 0; i < 4; ++i)
- pwr_by_rate[i] = bcd_to_dec_pwr_by_rate(val, i);
+ pwr_by_rate[i] = tbl_to_dec_pwr_by_rate(rtwdev, val, i);
*rate_num = 4;
break;
case 0xCD8:
@@ -1417,7 +1434,7 @@ static void phy_get_rate_values_of_txpwr_by_rate(struct rtw_dev *rtwdev,
rate[2] = DESC_RATEMCS18;
rate[3] = DESC_RATEMCS19;
for (i = 0; i < 4; ++i)
- pwr_by_rate[i] = bcd_to_dec_pwr_by_rate(val, i);
+ pwr_by_rate[i] = tbl_to_dec_pwr_by_rate(rtwdev, val, i);
*rate_num = 4;
break;
case 0xCDC:
@@ -1429,7 +1446,7 @@ static void phy_get_rate_values_of_txpwr_by_rate(struct rtw_dev *rtwdev,
rate[2] = DESC_RATEMCS22;
rate[3] = DESC_RATEMCS23;
for (i = 0; i < 4; ++i)
- pwr_by_rate[i] = bcd_to_dec_pwr_by_rate(val, i);
+ pwr_by_rate[i] = tbl_to_dec_pwr_by_rate(rtwdev, val, i);
*rate_num = 4;
break;
case 0xCE0:
@@ -1441,7 +1458,7 @@ static void phy_get_rate_values_of_txpwr_by_rate(struct rtw_dev *rtwdev,
rate[2] = DESC_RATEVHT3SS_MCS2;
rate[3] = DESC_RATEVHT3SS_MCS3;
for (i = 0; i < 4; ++i)
- pwr_by_rate[i] = bcd_to_dec_pwr_by_rate(val, i);
+ pwr_by_rate[i] = tbl_to_dec_pwr_by_rate(rtwdev, val, i);
*rate_num = 4;
break;
case 0xCE4:
@@ -1453,7 +1470,7 @@ static void phy_get_rate_values_of_txpwr_by_rate(struct rtw_dev *rtwdev,
rate[2] = DESC_RATEVHT3SS_MCS6;
rate[3] = DESC_RATEVHT3SS_MCS7;
for (i = 0; i < 4; ++i)
- pwr_by_rate[i] = bcd_to_dec_pwr_by_rate(val, i);
+ pwr_by_rate[i] = tbl_to_dec_pwr_by_rate(rtwdev, val, i);
*rate_num = 4;
break;
case 0xCE8:
@@ -1463,7 +1480,7 @@ static void phy_get_rate_values_of_txpwr_by_rate(struct rtw_dev *rtwdev,
rate[0] = DESC_RATEVHT3SS_MCS8;
rate[1] = DESC_RATEVHT3SS_MCS9;
for (i = 0; i < 2; ++i)
- pwr_by_rate[i] = bcd_to_dec_pwr_by_rate(val, i);
+ pwr_by_rate[i] = tbl_to_dec_pwr_by_rate(rtwdev, val, i);
*rate_num = 2;
break;
default:
@@ -1563,6 +1563,8 @@ struct rtw_chip_info rtw8822b_hw_spec = {
.ptct_efuse_size = 96,
.txff_size = 262144,
.rxff_size = 24576,
+ .txgi_factor = 1,
+ .is_pwr_by_rate_dec = true,
.csi_buf_pg_num = 0,
.band = RTW_BAND_2G | RTW_BAND_5G,
.page_size = 128,
@@ -1180,6 +1180,8 @@ struct rtw_chip_info rtw8822c_hw_spec = {
.ptct_efuse_size = 124,
.txff_size = 262144,
.rxff_size = 24576,
+ .txgi_factor = 2,
+ .is_pwr_by_rate_dec = false,
.csi_buf_pg_num = 50,
.band = RTW_BAND_2G | RTW_BAND_5G,
.page_size = 128,