rtw88: 8821c: correct functions and support RFE type2 card
Ping-Ke Shih
maintainercover rtw88: 8821c: correct functions and support RFE type2 card
Fix incorrect access address alignment and CCK RSSI report. And, support 8821CE RFE type 2 card by third patch with newer firmware.
Guo-Feng Fan (3):
rtw88: coex: 8821c: correct antenna switch function
rtw88: 8821c: Correct CCK RSSI
rtw88: 8821c: support RFE type2 wifi NIC
drivers/net/wireless/realtek/rtw88/main.c | 2 + drivers/net/wireless/realtek/rtw88/main.h | 7 + drivers/net/wireless/realtek/rtw88/rtw8821c.c | 109 ++++- drivers/net/wireless/realtek/rtw88/rtw8821c.h | 22 + .../wireless/realtek/rtw88/rtw8821c_table.c | 397 ++++++++++++++++++ .../wireless/realtek/rtw88/rtw8821c_table.h | 1 + 6 files changed, 525 insertions(+), 13 deletions(-)
Signature · 1 line
2.21.0
Ping-Ke Shih
maintainerPATCH 1/3 rtw88: coex: 8821c: correct antenna switch function
From: Guo-Feng Fan <[email protected]>
This patch fixes a defect that uses incorrect function to access registers. Use 8 and 32 bit access function to access 8 and 32 bit long data respectively.
--- drivers/net/wireless/realtek/rtw88/rtw8821c.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/net/wireless/realtek/rtw88/rtw8821c.c +8 -8
@@ -719,8 +719,8 @@ static void rtw8821c_coex_cfg_ant_switch(struct rtw_dev *rtwdev, u8 ctrl_type, regval = (!polarity_inverse ?0x1 :0x2 ); } -rtw_write8_mask (rtwdev,REG_RFE_CTRL8 ,BIT_MASK_R_RFE_SEL_15 , - regval); +rtw_write32_mask (rtwdev,REG_RFE_CTRL8 ,BIT_MASK_R_RFE_SEL_15 , + regval);break ;case COEX_SWITCH_CTRL_BY_PTA :rtw_write32_clr (rtwdev,REG_LED_CFG ,BIT_DPDT_SEL_EN );
@@ -730,8 +730,8 @@ static void rtw8821c_coex_cfg_ant_switch(struct rtw_dev *rtwdev, u8 ctrl_type, PTA_CTRL_PIN); regval = (!polarity_inverse ?0x2 :0x1 ); -rtw_write8_mask (rtwdev,REG_RFE_CTRL8 ,BIT_MASK_R_RFE_SEL_15 , - regval); +rtw_write32_mask (rtwdev,REG_RFE_CTRL8 ,BIT_MASK_R_RFE_SEL_15 , + regval);break ;case COEX_SWITCH_CTRL_BY_ANTDIV :rtw_write32_clr (rtwdev,REG_LED_CFG ,BIT_DPDT_SEL_EN );
@@ -757,11 +757,11 @@ static void rtw8821c_coex_cfg_ant_switch(struct rtw_dev *rtwdev, u8 ctrl_type, }if (ctrl_type ==COEX_SWITCH_CTRL_BY_BT ) { -rtw_write32_clr (rtwdev,REG_CTRL_TYPE ,BIT_CTRL_TYPE1 ); -rtw_write32_clr (rtwdev,REG_CTRL_TYPE ,BIT_CTRL_TYPE2 ); +rtw_write8_clr (rtwdev,REG_CTRL_TYPE ,BIT_CTRL_TYPE1 ); +rtw_write8_clr (rtwdev,REG_CTRL_TYPE ,BIT_CTRL_TYPE2 ); }else { -rtw_write32_set (rtwdev,REG_CTRL_TYPE ,BIT_CTRL_TYPE1 ); -rtw_write32_set (rtwdev,REG_CTRL_TYPE ,BIT_CTRL_TYPE2 ); +rtw_write8_set (rtwdev,REG_CTRL_TYPE ,BIT_CTRL_TYPE1 ); +rtw_write8_set (rtwdev,REG_CTRL_TYPE ,BIT_CTRL_TYPE2 ); } }
Signature · 1 line
2.21.0
Re: [PATCH 1/3] rtw88: coex: 8821c: correct antenna switch function
Quoted 8 lines · Ping-Ke Shih
From: Guo-Feng Fan <[email protected]>
This patch fixes a defect that uses incorrect function to access registers. Use 8 and 32 bit access function to access 8 and 32 bit long data respectively.
Signed-off-by Guo-Feng Fan <[email protected]>Signed-off-by Ping-Ke Shih <[email protected]>
3 patches applied to wireless-drivers-next.git, thanks.
adba838af159 rtw88: coex: 8821c: correct antenna switch function b0d3016f4238 rtw88: 8821c: Correct CCK RSSI 5d6651fe8583 rtw88: 8821c: support RFE type2 wifi NIC
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Ping-Ke Shih
maintainerPATCH 2/3 rtw88: 8821c: Correct CCK RSSI
In reply to Ping-Ke ShihFrom: Guo-Feng Fan <[email protected]>
Incorrect CCK RSSI may cause periodically scan from upper layer.
8821c phy status does NOT has actual value of CCK power. It provides only lna and vga index. Driver have to use these indexes to calculate actual RSSI.
--- drivers/net/wireless/realtek/rtw88/rtw8821c.c | 46 +++++++++++++++++-- drivers/net/wireless/realtek/rtw88/rtw8821c.h | 8 ++++ 2 files changed, 49 insertions(+), 5 deletions(-)
drivers/net/wireless/realtek/rtw88/rtw8821c.c +41 -5
@@ -15,6 +15,10 @@#include "debug.h" #include "bf.h" +static const s8 lna_gain_table_0[8 ] = {22 ,8 ,-6 ,-22 ,-31 ,-40 ,-46 ,-52 }; +static const s8 lna_gain_table_1[16 ] = {10 ,6 ,2 ,-2 ,-6 ,-10 ,-14 ,-17 , +-20 ,-24 ,-28 ,-31 ,-34 ,-37 ,-40 ,-44 }; +static void rtw8821ce_efuse_parsing (struct rtw_efuse *efuse,struct rtw8821c_efuse *map) {
@@ -426,17 +430,49 @@ static void rtw8821c_set_channel(struct rtw_dev *rtwdev, u8 channel, u8 bw,rtw8821c_set_channel_rxdfir (rtwdev, bw); } +static s8 get_cck_rx_pwr (struct rtw_dev *rtwdev,u8 lna_idx,u8 vga_idx) +{ +struct rtw_efuse *efuse = &rtwdev->efuse; +const s8 *lna_gain_table; +int lna_gain_table_size; +s8 rx_pwr_all =0 ; +s8 lna_gain =0 ; + +if (efuse->rfe_option ==0 ) { + lna_gain_table = lna_gain_table_0; + lna_gain_table_size =ARRAY_SIZE (lna_gain_table_0); + }else { + lna_gain_table = lna_gain_table_1; + lna_gain_table_size =ARRAY_SIZE (lna_gain_table_1); + } + +if (lna_idx >= lna_gain_table_size) { +rtw_info (rtwdev,"incorrect lna index (%d)\n" , lna_idx); +return -120 ; + } + + lna_gain = lna_gain_table[lna_idx]; + rx_pwr_all = lna_gain -2 * vga_idx; + +return rx_pwr_all; +} +static void query_phy_status_page0 (struct rtw_dev *rtwdev,u8 *phy_status,struct rtw_rx_pkt_stat *pkt_stat) { -s8 min_rx_power =-120 ; -u8 pwdb =GET_PHY_STAT_P0_PWDB (phy_status); +s8 rx_power; +u8 lna_idx =0 ; +u8 vga_idx =0 ; - pkt_stat->rx_power[RF_PATH_A ] = pwdb -100 ; + vga_idx =GET_PHY_STAT_P0_VGA (phy_status); + lna_idx =FIELD_PREP (BIT_LNA_H_MASK ,GET_PHY_STAT_P0_LNA_H (phy_status)) | +FIELD_PREP (BIT_LNA_L_MASK ,GET_PHY_STAT_P0_LNA_L (phy_status)); + rx_power =get_cck_rx_pwr (rtwdev, lna_idx, vga_idx); + + pkt_stat->rx_power[RF_PATH_A ] = rx_power; pkt_stat->rssi =rtw_phy_rf_power_2_rssi (pkt_stat->rx_power,1 ); pkt_stat->bw =RTW_CHANNEL_WIDTH_20 ; - pkt_stat->signal_power =max (pkt_stat->rx_power[RF_PATH_A ], - min_rx_power); + pkt_stat->signal_power = rx_power; } static void query_phy_status_page1(struct rtw_dev *rtwdev, u8 *phy_status,
drivers/net/wireless/realtek/rtw88/rtw8821c.h +8 -0
@@ -148,6 +148,14 @@ _rtw_write32s_mask(struct rtw_dev *rtwdev, u32 addr, u32 mask, u32 data)/* phy status page0 */ #define GET_PHY_STAT_P0_PWDB (phy_stat) \ le32_get_bits(*((__le32 *)(phy_stat) + 0x00), GENMASK(15, 8)) +#define GET_PHY_STAT_P0_VGA (phy_stat) \ + le32_get_bits(*((__le32 *)(phy_stat) + 0x03), GENMASK(12, 8)) +#define GET_PHY_STAT_P0_LNA_L (phy_stat) \ + le32_get_bits(*((__le32 *)(phy_stat) + 0x03), GENMASK(15, 13)) +#define GET_PHY_STAT_P0_LNA_H (phy_stat) \ + le32_get_bits(*((__le32 *)(phy_stat) + 0x03), BIT(23)) +#define BIT_LNA_H_MASK BIT(3) +#define BIT_LNA_L_MASK GENMASK(2, 0)/* phy status page1 */ #define GET_PHY_STAT_P1_PWDB_A (phy_stat) \
Signature · 1 line
2.21.0
Ping-Ke Shih
maintainerPATCH 3/3 rtw88: 8821c: support RFE type2 wifi NIC
In reply to Ping-Ke ShihFrom: Guo-Feng Fan <[email protected]>
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.
--- drivers/net/wireless/realtek/rtw88/main.c | 2 + drivers/net/wireless/realtek/rtw88/main.h | 7 + drivers/net/wireless/realtek/rtw88/rtw8821c.c | 47 +++ drivers/net/wireless/realtek/rtw88/rtw8821c.h | 14 + .../wireless/realtek/rtw88/rtw8821c_table.c | 397 ++++++++++++++++++ .../wireless/realtek/rtw88/rtw8821c_table.h | 1 + 6 files changed, 468 insertions(+)
drivers/net/wireless/realtek/rtw88/main.c +2 -0
@@ -1590,6 +1590,8 @@ static int rtw_chip_board_info_setup(struct rtw_dev *rtwdev)rtw_phy_setup_phy_cond (rtwdev,0 );rtw_phy_init_tx_power (rtwdev); +if (rfe_def->agc_btg_tbl) +rtw_load_table (rtwdev, rfe_def->agc_btg_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);
drivers/net/wireless/realtek/rtw88/main.h +7 -0
@@ -1042,6 +1042,7 @@ enum rtw_rfe_fem {struct rtw_rfe_def {const struct rtw_table *phy_pg_tbl;const struct rtw_table *txpwr_lmt_tbl; +const struct rtw_table *agc_btg_tbl; };#define RTW_DEF_RFE (chip, bb_pg, pwrlmt) { \
@@ -1049,6 +1050,12 @@ struct rtw_rfe_def { .txpwr_lmt_tbl = &rtw ## chip ## _txpwr_lmt_type ## pwrlmt ## _tbl, \ } +#define RTW_DEF_RFE_EXT (chip, bb_pg, pwrlmt, btg) { \ + .phy_pg_tbl = &rtw ## chip ## _bb_pg_type ## bb_pg ## _tbl, \ + .txpwr_lmt_tbl = &rtw ## chip ## _txpwr_lmt_type ## pwrlmt ## _tbl, \ + .agc_btg_tbl = &rtw ## chip ## _agc_btg_type ## btg ## _tbl, \ + } +#define RTW_PWR_TRK_5G_1 0#define RTW_PWR_TRK_5G_2 1#define RTW_PWR_TRK_5G_3 2
drivers/net/wireless/realtek/rtw88/rtw8821c.c +47 -0
74 lines not on this page · raw message
drivers/net/wireless/realtek/rtw88/rtw8821c.h +14 -0
@@ -181,6 +181,8 @@ _rtw_write32s_mask(struct rtw_dev *rtwdev, u32 addr, u32 mask, u32 data)#define GET_PHY_STAT_P1_RXSNR_B (phy_stat) \ le32_get_bits(*((__le32 *)(phy_stat) + 0x06), GENMASK(15, 8)) +#define REG_SYS_CTRL 0x000 +#define BIT_FEN_EN BIT(26)#define REG_INIRTS_RATE_SEL 0x0480#define REG_HTSTFWT 0x800#define REG_RXPSEL 0x808
@@ -212,6 +214,11 @@ _rtw_write32s_mask(struct rtw_dev *rtwdev, u32 addr, u32 mask, u32 data)#define REG_FA_CCK 0xa5c#define REG_RXDESC 0xa2c#define REG_ENTXCCK 0xa80 +#define BTG_LNA 0xfc84 +#define WLG_LNA 0x7532 +#define REG_ENRXCCA 0xa84 +#define BTG_CCA 0x0e +#define WLG_CCA 0x12#define REG_PWRTH2 0xaa8#define REG_CSRATIO 0xaaa#define REG_TXFILTER 0xaac
@@ -225,6 +232,11 @@ _rtw_write32s_mask(struct rtw_dev *rtwdev, u32 addr, u32 mask, u32 data)#define REG_RFESEL0 0xcb0#define REG_RFESEL8 0xcb4#define REG_RFECTL 0xcb8 +#define B_BTG_SWITCH BIT(16) +#define B_CTRL_SWITCH BIT(18) +#define B_WL_SWITCH (BIT(20) | BIT(22)) +#define B_WLG_SWITCH BIT(21) +#define B_WLA_SWITCH BIT(23)#define REG_RFEINV 0xcbc#define REG_AGCTR_B 0xe08#define REG_RXIGI_B 0xe50
@@ -235,6 +247,8 @@ _rtw_write32s_mask(struct rtw_dev *rtwdev, u32 addr, u32 mask, u32 data)#define REG_CCA_OFDM 0xf08#define REG_FA_OFDM 0xf48#define REG_CCA_CCK 0xfcc +#define REG_DMEM_CTRL 0x1080 +#define BIT_WL_RST BIT(16)#define REG_ANTWT 0x1904#define REG_IQKFAILMSK 0x1bf0#define BIT_MASK_R_RFE_SEL_15 GENMASK(31, 28)
drivers/net/wireless/realtek/rtw88/rtw8821c_table.c +397 -0
410 lines not on this page · raw message
drivers/net/wireless/realtek/rtw88/rtw8821c_table.h +1 -0
@@ -7,6 +7,7 @@extern const struct rtw_table rtw8821c_mac_tbl;extern const struct rtw_table rtw8821c_agc_tbl; +extern const struct rtw_table rtw8821c_agc_btg_type2_tbl;extern const struct rtw_table rtw8821c_bb_tbl;extern const struct rtw_table rtw8821c_bb_pg_type0_tbl;extern const struct rtw_table rtw8821c_rf_a_tbl;
Signature · 1 line
2.21.0
Re: [PATCH 3/3] rtw88: 8821c: support RFE type2 wifi NIC
Quoted 9 lines · Ping-Ke Shih
From: Guo-Feng Fan <[email protected]>
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 <[email protected]>Signed-off-by Ping-Ke Shih <[email protected]>
For the series,