From: Chien-Hsun Liao <ben.liao@xxxxxxxxxxx> We rearrange the coding style of trx mode setting based on ofdm_tx, ofdm_rx, cck_tx and cck_rx. We also modify cck_rx 1r setting because the original is incorrect and could cause the degradation of sensitivity. Signed-off-by: Chien-Hsun Liao <ben.liao@xxxxxxxxxxx> Signed-off-by: Yan-Hsuan Chuang <yhchuang@xxxxxxxxxxx> --- drivers/net/wireless/realtek/rtw88/rtw8822c.c | 132 ++++++++++++++------------ 1 file changed, 72 insertions(+), 60 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822c.c b/drivers/net/wireless/realtek/rtw88/rtw8822c.c index c10894e..40008d7 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8822c.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8822c.c @@ -524,81 +524,26 @@ static void rtw8822c_set_channel(struct rtw_dev *rtwdev, u8 channel, u8 bw, rtw8822c_toggle_igi(rtwdev); } -static void rtw8822c_config_trx_mode(struct rtw_dev *rtwdev, u8 tx_path, - u8 rx_path, bool is_tx2_path) +static void rtw8822c_config_cck_rx_path(struct rtw_dev *rtwdev, u8 rx_path) { - if ((tx_path | rx_path) & BB_PATH_A) - rtw_write32_mask(rtwdev, REG_ORITXCODE, MASK20BITS, 0x33312); - else - rtw_write32_mask(rtwdev, REG_ORITXCODE, MASK20BITS, 0x11111); - if ((tx_path | rx_path) & BB_PATH_B) - rtw_write32_mask(rtwdev, REG_ORITXCODE2, MASK20BITS, 0x33312); - else - rtw_write32_mask(rtwdev, REG_ORITXCODE2, MASK20BITS, 0x11111); - - rtw_write32_mask(rtwdev, REG_RXCCKSEL, 0xf0000000, 0x8); - rtw_write32_mask(rtwdev, REG_CCKPATH, BIT(30), 0x1); - - if (tx_path == BB_PATH_A) - rtw_write32_mask(rtwdev, REG_RXCCKSEL, 0xf0000000, 0x8); - else if (tx_path == BB_PATH_B) - rtw_write32_mask(rtwdev, REG_RXCCKSEL, 0xf0000000, 0x4); - else if (tx_path == BB_PATH_AB) - rtw_write32_mask(rtwdev, REG_RXCCKSEL, 0xf0000000, 0xc); - - rtw_write32_mask(rtwdev, REG_TXANTSEG, 0xf, tx_path); - rtw_write32_mask(rtwdev, REG_ENFN, BIT(16), 0x0); - rtw_write32_mask(rtwdev, REG_ENFN, BIT(31), 0x1); - - if (tx_path == BB_PATH_A) { - rtw_write32_mask(rtwdev, REG_ANTMAP0, 0xf, 0x1); - rtw_write32_mask(rtwdev, REG_TXLGMAP, 0x3, 0x0); - rtw_write32_mask(rtwdev, REG_TXLGMAP, 0xc, 0x0); - } else if (tx_path == BB_PATH_B) { - rtw_write32_mask(rtwdev, REG_ANTMAP0, 0xf, 0x2); - rtw_write32_mask(rtwdev, REG_TXLGMAP, 0x3, 0x0); - rtw_write32_mask(rtwdev, REG_TXLGMAP, 0xc, 0x0); - } else if (tx_path == BB_PATH_AB) { - rtw_write32_mask(rtwdev, REG_ANTMAP0, 0xf, 0x3); - rtw_write32_mask(rtwdev, REG_TXLGMAP, 0x3, 0x0); - rtw_write32_mask(rtwdev, REG_TXLGMAP, 0xc, 0x1); - } - - if (tx_path == BB_PATH_A || tx_path == BB_PATH_B) { - rtw_write32_mask(rtwdev, REG_ANTMAP0, 0xf0, 0x1); - rtw_write32_mask(rtwdev, REG_TXLGMAP, 0x300, 0x0); - rtw_write32_mask(rtwdev, REG_TXLGMAP, 0xc00, 0x0); - } else if (tx_path == BB_PATH_AB) { - rtw_write32_mask(rtwdev, REG_ANTMAP0, 0xf0, 0x3); - rtw_write32_mask(rtwdev, REG_TXLGMAP, 0x300, 0x0); - rtw_write32_mask(rtwdev, REG_TXLGMAP, 0xc00, 0x1); - } - rtw_write32_mask(rtwdev, REG_TXANT, 0xf, tx_path); - if (rx_path == BB_PATH_A || rx_path == BB_PATH_B) { + rtw_write32_mask(rtwdev, REG_CCANRX, 0x00060000, 0x0); rtw_write32_mask(rtwdev, REG_CCANRX, 0x00600000, 0x0); } else if (rx_path == BB_PATH_AB) { rtw_write32_mask(rtwdev, REG_CCANRX, 0x00600000, 0x1); rtw_write32_mask(rtwdev, REG_CCANRX, 0x00060000, 0x1); } - rtw_write32_mask(rtwdev, REG_RXCCKSEL, 0x0f000000, 0x0); - if (rx_path == BB_PATH_A) rtw_write32_mask(rtwdev, REG_RXCCKSEL, 0x0f000000, 0x0); else if (rx_path == BB_PATH_B) rtw_write32_mask(rtwdev, REG_RXCCKSEL, 0x0f000000, 0x5); else if (rx_path == BB_PATH_AB) rtw_write32_mask(rtwdev, REG_RXCCKSEL, 0x0f000000, 0x1); +} - rtw_write32_mask(rtwdev, REG_ANTMAP, MASKBYTE3LOWNIBBLE, rx_path); - rtw_write32_mask(rtwdev, REG_ANTMAP, 0x000F0000, rx_path); - - if (!(rx_path & BB_PATH_A)) - rtw_write_rf(rtwdev, 0, 0, 0xf0000, 0x1); - if (!(rx_path & BB_PATH_B)) - rtw_write_rf(rtwdev, 1, 0, 0xf0000, 0x1); - +static void rtw8822c_config_ofdm_rx_path(struct rtw_dev *rtwdev, u8 rx_path) +{ if (rx_path == BB_PATH_A || rx_path == BB_PATH_B) { rtw_write32_mask(rtwdev, REG_RXFNCTL, 0x300, 0x0); rtw_write32_mask(rtwdev, REG_RXFNCTL, 0x600000, 0x0); @@ -613,6 +558,73 @@ static void rtw8822c_config_trx_mode(struct rtw_dev *rtwdev, u8 tx_path, rtw_write32_mask(rtwdev, REG_MRCM, BIT(24), 0x1); } + rtw_write32_mask(rtwdev, 0x824, 0x0f000000, rx_path); + rtw_write32_mask(rtwdev, 0x824, 0x000f0000, rx_path); +} + +static void rtw8822c_config_rx_path(struct rtw_dev *rtwdev, u8 rx_path) +{ + rtw8822c_config_cck_rx_path(rtwdev, rx_path); + rtw8822c_config_ofdm_rx_path(rtwdev, rx_path); +} + +static void rtw8822c_config_cck_tx_path(struct rtw_dev *rtwdev, u8 tx_path, + bool is_tx2_path) +{ + if (tx_path == BB_PATH_A) { + rtw_write32_mask(rtwdev, REG_RXCCKSEL, 0xf0000000, 0x8); + } else if (tx_path == BB_PATH_B) { + rtw_write32_mask(rtwdev, REG_RXCCKSEL, 0xf0000000, 0x4); + } else { + if (is_tx2_path) + rtw_write32_mask(rtwdev, REG_RXCCKSEL, 0xf0000000, 0xc); + else + rtw_write32_mask(rtwdev, REG_RXCCKSEL, 0xf0000000, 0x8); + } +} + +static void rtw8822c_config_ofdm_tx_path(struct rtw_dev *rtwdev, u8 tx_path, + bool is_tx2_path) +{ + if (tx_path == BB_PATH_A) { + rtw_write32_mask(rtwdev, REG_ANTMAP0, 0xff, 0x11); + rtw_write32_mask(rtwdev, REG_TXLGMAP, 0xff, 0x0); + } else if (tx_path == BB_PATH_B) { + rtw_write32_mask(rtwdev, REG_ANTMAP0, 0xff, 0x12); + rtw_write32_mask(rtwdev, REG_TXLGMAP, 0xff, 0x0); + } else { + if (is_tx2_path) { + rtw_write32_mask(rtwdev, REG_ANTMAP0, 0xff, 0x33); + rtw_write32_mask(rtwdev, REG_TXLGMAP, 0xffff, 0x0404); + } else { + rtw_write32_mask(rtwdev, REG_ANTMAP0, 0xff, 0x31); + rtw_write32_mask(rtwdev, REG_TXLGMAP, 0xffff, 0x0400); + } + } +} + +static void rtw8822c_config_tx_path(struct rtw_dev *rtwdev, u8 tx_path, + bool is_tx2_path) +{ + rtw8822c_config_cck_tx_path(rtwdev, tx_path, is_tx2_path); + rtw8822c_config_ofdm_tx_path(rtwdev, tx_path, is_tx2_path); +} + +static void rtw8822c_config_trx_mode(struct rtw_dev *rtwdev, u8 tx_path, + u8 rx_path, bool is_tx2_path) +{ + if ((tx_path | rx_path) & BB_PATH_A) + rtw_write32_mask(rtwdev, REG_ORITXCODE, MASK20BITS, 0x33312); + else + rtw_write32_mask(rtwdev, REG_ORITXCODE, MASK20BITS, 0x11111); + if ((tx_path | rx_path) & BB_PATH_B) + rtw_write32_mask(rtwdev, REG_ORITXCODE2, MASK20BITS, 0x33312); + else + rtw_write32_mask(rtwdev, REG_ORITXCODE2, MASK20BITS, 0x11111); + + rtw8822c_config_rx_path(rtwdev, rx_path); + rtw8822c_config_tx_path(rtwdev, tx_path, is_tx2_path); + rtw8822c_toggle_igi(rtwdev); } -- 2.7.4