]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: rtw89: configure RX antenna if chips can support
authorPing-Ke Shih <pkshih@realtek.com>
Tue, 11 Nov 2025 02:24:52 +0000 (10:24 +0800)
committerPing-Ke Shih <pkshih@realtek.com>
Thu, 13 Nov 2025 01:40:06 +0000 (09:40 +0800)
If chip->ops->cfg_txrx_path is implemented, a chip can support to configure
RX antenna, so accept setting via iw tool.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20251111022452.28093-9-pkshih@realtek.com
drivers/net/wireless/realtek/rtw89/mac80211.c
drivers/net/wireless/realtek/rtw89/rtw8852b_common.c
drivers/net/wireless/realtek/rtw89/rtw8852c.c
drivers/net/wireless/realtek/rtw89/rtw8922a.c

index 14c8864bd2013591e2213495c57308f71d583e3f..6f7571c7c2741a6059e1cf415553d7de850c1609 100644 (file)
@@ -1147,12 +1147,17 @@ int rtw89_ops_set_antenna(struct ieee80211_hw *hw, int radio_idx, u32 tx_ant, u3
 {
        struct rtw89_dev *rtwdev = hw->priv;
        struct rtw89_hal *hal = &rtwdev->hal;
+       const struct rtw89_chip_info *chip;
 
        lockdep_assert_wiphy(hw->wiphy);
 
+       chip = rtwdev->chip;
+
        if (hal->ant_diversity) {
                if (tx_ant != rx_ant || hweight32(tx_ant) != 1)
                        return -EINVAL;
+       } else if (chip->ops->cfg_txrx_path) {
+               /* With cfg_txrx_path ops, chips can configure rx_ant */
        } else if (rx_ant != hw->wiphy->available_antennas_rx && rx_ant != hal->antenna_rx) {
                return -EINVAL;
        }
index 3fb2972ae6f6fa7a9237c3408892e884d33748cf..4e72f49618372da206eac3f7d68b3f29109eeb34 100644 (file)
@@ -1747,11 +1747,15 @@ static void __rtw8852bx_bb_cfg_txrx_path(struct rtw89_dev *rtwdev)
        struct rtw89_hal *hal = &rtwdev->hal;
        const struct rtw89_chan *chan = rtw89_chan_get(rtwdev, RTW89_CHANCTX_0);
        enum rtw89_rf_path_bit rx_path = hal->antenna_rx ? hal->antenna_rx : RF_AB;
+       u8 rx_nss = rtwdev->hal.rx_nss;
+
+       if (rx_path != RF_AB)
+               rx_nss = 1;
 
        rtw8852bx_bb_ctrl_rx_path(rtwdev, rx_path, chan);
        rtw8852bx_bb_ctrl_rf_mode_rx_path(rtwdev, rx_path);
 
-       if (rtwdev->hal.rx_nss == 1) {
+       if (rx_nss == 1) {
                rtw89_phy_write32_mask(rtwdev, R_RXHT_MCS_LIMIT, B_RXHT_MCS_LIMIT, 0);
                rtw89_phy_write32_mask(rtwdev, R_RXVHT_MCS_LIMIT, B_RXVHT_MCS_LIMIT, 0);
                rtw89_phy_write32_mask(rtwdev, R_RXHE, B_RXHE_MAX_NSS, 0);
index 6be56c2fa0c74374145fb0edb9d58bf3ac2fbf3b..ee81a6792eee1efb0e5896e0a1eda5fe48436f1b 100644 (file)
@@ -2502,10 +2502,20 @@ static void rtw8852c_ctrl_nbtg_bt_tx(struct rtw89_dev *rtwdev, bool en,
 static void rtw8852c_bb_cfg_txrx_path(struct rtw89_dev *rtwdev)
 {
        struct rtw89_hal *hal = &rtwdev->hal;
+       u8 nrx_path = RF_PATH_AB;
+       u8 rx_nss = hal->rx_nss;
 
-       rtw8852c_bb_cfg_rx_path(rtwdev, RF_PATH_AB);
+       if (hal->antenna_rx == RF_A)
+               nrx_path = RF_PATH_A;
+       else if (hal->antenna_rx == RF_B)
+               nrx_path = RF_PATH_B;
 
-       if (hal->rx_nss == 1) {
+       if (nrx_path != RF_PATH_AB)
+               rx_nss = 1;
+
+       rtw8852c_bb_cfg_rx_path(rtwdev, nrx_path);
+
+       if (rx_nss == 1) {
                rtw89_phy_write32_mask(rtwdev, R_RXHT_MCS_LIMIT, B_RXHT_MCS_LIMIT, 0);
                rtw89_phy_write32_mask(rtwdev, R_RXVHT_MCS_LIMIT, B_RXVHT_MCS_LIMIT, 0);
                rtw89_phy_write32_mask(rtwdev, R_RXHE, B_RXHE_MAX_NSS, 0);
index 61f3a0a3f440fc98f991586c52831154106226e8..11e8b50a329199c0f225c6ba13e18dbb15c2baa2 100644 (file)
@@ -2347,19 +2347,29 @@ static void rtw8922a_bb_cfg_txrx_path(struct rtw89_dev *rtwdev)
        enum rtw89_band band = chan->band_type;
        struct rtw89_hal *hal = &rtwdev->hal;
        u8 ntx_path = RF_PATH_AB;
+       u8 nrx_path = RF_PATH_AB;
        u32 tx_en0, tx_en1;
+       u8 rx_nss = 2;
 
        if (hal->antenna_tx == RF_A)
                ntx_path = RF_PATH_A;
        else if (hal->antenna_tx == RF_B)
                ntx_path = RF_PATH_B;
 
+       if (hal->antenna_rx == RF_A)
+               nrx_path = RF_PATH_A;
+       else if (hal->antenna_rx == RF_B)
+               nrx_path = RF_PATH_B;
+
+       if (nrx_path != RF_PATH_AB)
+               rx_nss = 1;
+
        rtw8922a_hal_reset(rtwdev, RTW89_PHY_0, RTW89_MAC_0, band, &tx_en0, true);
        if (rtwdev->dbcc_en)
                rtw8922a_hal_reset(rtwdev, RTW89_PHY_1, RTW89_MAC_1, band,
                                   &tx_en1, true);
 
-       rtw8922a_ctrl_trx_path(rtwdev, ntx_path, 2, RF_PATH_AB, 2);
+       rtw8922a_ctrl_trx_path(rtwdev, ntx_path, 2, nrx_path, rx_nss);
 
        rtw8922a_hal_reset(rtwdev, RTW89_PHY_0, RTW89_MAC_0, band, &tx_en0, false);
        if (rtwdev->dbcc_en)