Skip to content

Commit 5d6651f

Browse files
rtlwifi-linuxKalle Valo
authored andcommitted
rtw88: 8821c: support RFE type2 wifi NIC
RFE type2 is a new NIC which has one RF antenna shares with BT. Update phy parameter to verstion V57 to allow initial procedure to load extra AGC table for sharing antenna NIC. Signed-off-by: Guo-Feng Fan <vincent_fann@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20210202055012.8296-4-pkshih@realtek.com
1 parent b0d3016 commit 5d6651f

File tree

6 files changed

+468
-0
lines changed

6 files changed

+468
-0
lines changed

drivers/net/wireless/realtek/rtw88/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,6 +1590,8 @@ static int rtw_chip_board_info_setup(struct rtw_dev *rtwdev)
15901590
rtw_phy_setup_phy_cond(rtwdev, 0);
15911591

15921592
rtw_phy_init_tx_power(rtwdev);
1593+
if (rfe_def->agc_btg_tbl)
1594+
rtw_load_table(rtwdev, rfe_def->agc_btg_tbl);
15931595
rtw_load_table(rtwdev, rfe_def->phy_pg_tbl);
15941596
rtw_load_table(rtwdev, rfe_def->txpwr_lmt_tbl);
15951597
rtw_phy_tx_power_by_rate_config(hal);

drivers/net/wireless/realtek/rtw88/main.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,13 +1042,20 @@ enum rtw_rfe_fem {
10421042
struct rtw_rfe_def {
10431043
const struct rtw_table *phy_pg_tbl;
10441044
const struct rtw_table *txpwr_lmt_tbl;
1045+
const struct rtw_table *agc_btg_tbl;
10451046
};
10461047

10471048
#define RTW_DEF_RFE(chip, bb_pg, pwrlmt) { \
10481049
.phy_pg_tbl = &rtw ## chip ## _bb_pg_type ## bb_pg ## _tbl, \
10491050
.txpwr_lmt_tbl = &rtw ## chip ## _txpwr_lmt_type ## pwrlmt ## _tbl, \
10501051
}
10511052

1053+
#define RTW_DEF_RFE_EXT(chip, bb_pg, pwrlmt, btg) { \
1054+
.phy_pg_tbl = &rtw ## chip ## _bb_pg_type ## bb_pg ## _tbl, \
1055+
.txpwr_lmt_tbl = &rtw ## chip ## _txpwr_lmt_type ## pwrlmt ## _tbl, \
1056+
.agc_btg_tbl = &rtw ## chip ## _agc_btg_type ## btg ## _tbl, \
1057+
}
1058+
10521059
#define RTW_PWR_TRK_5G_1 0
10531060
#define RTW_PWR_TRK_5G_2 1
10541061
#define RTW_PWR_TRK_5G_3 2

drivers/net/wireless/realtek/rtw88/rtw8821c.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ static void rtw8821ce_efuse_parsing(struct rtw_efuse *efuse,
2525
ether_addr_copy(efuse->addr, map->e.mac_addr);
2626
}
2727

28+
enum rtw8821ce_rf_set {
29+
SWITCH_TO_BTG,
30+
SWITCH_TO_WLG,
31+
SWITCH_TO_WLA,
32+
SWITCH_TO_BT,
33+
};
34+
2835
static int rtw8821c_read_efuse(struct rtw_dev *rtwdev, u8 *log_map)
2936
{
3037
struct rtw_efuse *efuse = &rtwdev->efuse;
@@ -228,6 +235,40 @@ static void rtw8821c_cfg_ldo25(struct rtw_dev *rtwdev, bool enable)
228235
rtw_write8(rtwdev, REG_LDO_EFUSE_CTRL + 3, ldo_pwr);
229236
}
230237

238+
static void rtw8821c_switch_rf_set(struct rtw_dev *rtwdev, u8 rf_set)
239+
{
240+
u32 reg;
241+
242+
rtw_write32_set(rtwdev, REG_DMEM_CTRL, BIT_WL_RST);
243+
rtw_write32_set(rtwdev, REG_SYS_CTRL, BIT_FEN_EN);
244+
245+
reg = rtw_read32(rtwdev, REG_RFECTL);
246+
switch (rf_set) {
247+
case SWITCH_TO_BTG:
248+
reg |= B_BTG_SWITCH;
249+
reg &= ~(B_CTRL_SWITCH | B_WL_SWITCH | B_WLG_SWITCH |
250+
B_WLA_SWITCH);
251+
rtw_write32_mask(rtwdev, REG_ENRXCCA, MASKBYTE2, BTG_CCA);
252+
rtw_write32_mask(rtwdev, REG_ENTXCCK, MASKLWORD, BTG_LNA);
253+
break;
254+
case SWITCH_TO_WLG:
255+
reg |= B_WL_SWITCH | B_WLG_SWITCH;
256+
reg &= ~(B_BTG_SWITCH | B_CTRL_SWITCH | B_WLA_SWITCH);
257+
rtw_write32_mask(rtwdev, REG_ENRXCCA, MASKBYTE2, WLG_CCA);
258+
rtw_write32_mask(rtwdev, REG_ENTXCCK, MASKLWORD, WLG_LNA);
259+
break;
260+
case SWITCH_TO_WLA:
261+
reg |= B_WL_SWITCH | B_WLA_SWITCH;
262+
reg &= ~(B_BTG_SWITCH | B_CTRL_SWITCH | B_WLG_SWITCH);
263+
break;
264+
case SWITCH_TO_BT:
265+
default:
266+
break;
267+
}
268+
269+
rtw_write32(rtwdev, REG_RFECTL, reg);
270+
}
271+
231272
static void rtw8821c_set_channel_rf(struct rtw_dev *rtwdev, u8 channel, u8 bw)
232273
{
233274
u32 rf_reg18;
@@ -261,9 +302,14 @@ static void rtw8821c_set_channel_rf(struct rtw_dev *rtwdev, u8 channel, u8 bw)
261302
}
262303

263304
if (channel <= 14) {
305+
if (rtwdev->efuse.rfe_option == 0)
306+
rtw8821c_switch_rf_set(rtwdev, SWITCH_TO_WLG);
307+
else if (rtwdev->efuse.rfe_option == 2)
308+
rtw8821c_switch_rf_set(rtwdev, SWITCH_TO_BTG);
264309
rtw_write_rf(rtwdev, RF_PATH_A, RF_LUTDBG, BIT(6), 0x1);
265310
rtw_write_rf(rtwdev, RF_PATH_A, 0x64, 0xf, 0xf);
266311
} else {
312+
rtw8821c_switch_rf_set(rtwdev, SWITCH_TO_WLA);
267313
rtw_write_rf(rtwdev, RF_PATH_A, RF_LUTDBG, BIT(6), 0x0);
268314
}
269315

@@ -1450,6 +1496,7 @@ static const struct rtw_intf_phy_para_table phy_para_table_8821c = {
14501496

14511497
static const struct rtw_rfe_def rtw8821c_rfe_defs[] = {
14521498
[0] = RTW_DEF_RFE(8821c, 0, 0),
1499+
[2] = RTW_DEF_RFE_EXT(8821c, 0, 0, 2),
14531500
};
14541501

14551502
static struct rtw_hw_reg rtw8821c_dig[] = {

drivers/net/wireless/realtek/rtw88/rtw8821c.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ _rtw_write32s_mask(struct rtw_dev *rtwdev, u32 addr, u32 mask, u32 data)
181181
#define GET_PHY_STAT_P1_RXSNR_B(phy_stat) \
182182
le32_get_bits(*((__le32 *)(phy_stat) + 0x06), GENMASK(15, 8))
183183

184+
#define REG_SYS_CTRL 0x000
185+
#define BIT_FEN_EN BIT(26)
184186
#define REG_INIRTS_RATE_SEL 0x0480
185187
#define REG_HTSTFWT 0x800
186188
#define REG_RXPSEL 0x808
@@ -212,6 +214,11 @@ _rtw_write32s_mask(struct rtw_dev *rtwdev, u32 addr, u32 mask, u32 data)
212214
#define REG_FA_CCK 0xa5c
213215
#define REG_RXDESC 0xa2c
214216
#define REG_ENTXCCK 0xa80
217+
#define BTG_LNA 0xfc84
218+
#define WLG_LNA 0x7532
219+
#define REG_ENRXCCA 0xa84
220+
#define BTG_CCA 0x0e
221+
#define WLG_CCA 0x12
215222
#define REG_PWRTH2 0xaa8
216223
#define REG_CSRATIO 0xaaa
217224
#define REG_TXFILTER 0xaac
@@ -225,6 +232,11 @@ _rtw_write32s_mask(struct rtw_dev *rtwdev, u32 addr, u32 mask, u32 data)
225232
#define REG_RFESEL0 0xcb0
226233
#define REG_RFESEL8 0xcb4
227234
#define REG_RFECTL 0xcb8
235+
#define B_BTG_SWITCH BIT(16)
236+
#define B_CTRL_SWITCH BIT(18)
237+
#define B_WL_SWITCH (BIT(20) | BIT(22))
238+
#define B_WLG_SWITCH BIT(21)
239+
#define B_WLA_SWITCH BIT(23)
228240
#define REG_RFEINV 0xcbc
229241
#define REG_AGCTR_B 0xe08
230242
#define REG_RXIGI_B 0xe50
@@ -235,6 +247,8 @@ _rtw_write32s_mask(struct rtw_dev *rtwdev, u32 addr, u32 mask, u32 data)
235247
#define REG_CCA_OFDM 0xf08
236248
#define REG_FA_OFDM 0xf48
237249
#define REG_CCA_CCK 0xfcc
250+
#define REG_DMEM_CTRL 0x1080
251+
#define BIT_WL_RST BIT(16)
238252
#define REG_ANTWT 0x1904
239253
#define REG_IQKFAILMSK 0x1bf0
240254
#define BIT_MASK_R_RFE_SEL_15 GENMASK(31, 28)

0 commit comments

Comments
 (0)