]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
wifi: rtw89: 8852bx: support different SAR configs by antenna
authorZong-Zhe Yang <kevin_yang@realtek.com>
Wed, 26 Mar 2025 02:06:43 +0000 (10:06 +0800)
committerPing-Ke Shih <pkshih@realtek.com>
Mon, 31 Mar 2025 06:29:52 +0000 (14:29 +0800)
Calculate difference of SAR configs between RF path A and RF path B.
And then, based on the calculated result, set the TX power reference
CR (control register). Finally, declare to support SAR by antenna in
8852b/8852bt chip info.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250326020643.14487-13-pkshih@realtek.com
drivers/net/wireless/realtek/rtw89/rtw8852b.c
drivers/net/wireless/realtek/rtw89/rtw8852b_common.c
drivers/net/wireless/realtek/rtw89/rtw8852bt.c

index 47233f0c6ea00308b1e57460c8b79bfa76b9bf14..dec736a07c54cf17fa292db576d6e005cff18ab5 100644 (file)
@@ -853,7 +853,7 @@ const struct rtw89_chip_info rtw8852b_chip_info = {
        .support_unii4          = true,
        .support_ant_gain       = true,
        .support_tas            = false,
-       .support_sar_by_ant     = false,
+       .support_sar_by_ant     = true,
        .ul_tb_waveform_ctrl    = true,
        .ul_tb_pwr_diff         = false,
        .rx_freq_frome_ie       = true,
index 99c9505b3cbd3dd18a61d7f72e8f31a90971c649..0cf03f18cbb1a6e073db91442052abcb7567f74b 100644 (file)
@@ -8,6 +8,7 @@
 #include "phy.h"
 #include "reg.h"
 #include "rtw8852b_common.h"
+#include "sar.h"
 #include "util.h"
 
 static const struct rtw89_reg3_def rtw8852bx_pmac_ht20_mcs7_tbl[] = {
@@ -1234,6 +1235,7 @@ static u32 rtw8852bx_bb_cal_txpwr_ref(struct rtw89_dev *rtwdev,
               u32_encode_bits(ref, B_DPD_REF);
 }
 
+/* @pwr_ofst (unit: 1/8 dBm): power of path A minus power of path B */
 static void rtw8852bx_set_txpwr_ref(struct rtw89_dev *rtwdev,
                                    enum rtw89_phy_idx phy_idx, s16 pwr_ofst)
 {
@@ -1336,6 +1338,27 @@ static void rtw8852bx_set_tx_shape(struct rtw89_dev *rtwdev,
                               tx_shape_ofdm);
 }
 
+static s16 rtw8852bx_get_txpwr_sar_diff(struct rtw89_dev *rtwdev,
+                                       const struct rtw89_chan *chan)
+{
+       struct rtw89_sar_parm sar_parm = {
+               .center_freq = chan->freq,
+               .force_path = true,
+       };
+       s16 sar_bb_a, sar_bb_b;
+       s8 sar_mac;
+
+       sar_parm.path = RF_PATH_A;
+       sar_mac = rtw89_query_sar(rtwdev, &sar_parm);
+       sar_bb_a = rtw89_phy_txpwr_mac_to_bb(rtwdev, sar_mac);
+
+       sar_parm.path = RF_PATH_B;
+       sar_mac = rtw89_query_sar(rtwdev, &sar_parm);
+       sar_bb_b = rtw89_phy_txpwr_mac_to_bb(rtwdev, sar_mac);
+
+       return sar_bb_a - sar_bb_b;
+}
+
 static void rtw8852bx_set_txpwr_diff(struct rtw89_dev *rtwdev,
                                     const struct rtw89_chan *chan,
                                     enum rtw89_phy_idx phy_idx)
@@ -1343,6 +1366,7 @@ static void rtw8852bx_set_txpwr_diff(struct rtw89_dev *rtwdev,
        s16 pwr_ofst;
 
        pwr_ofst = rtw89_phy_ant_gain_pwr_offset(rtwdev, chan);
+       pwr_ofst += rtw8852bx_get_txpwr_sar_diff(rtwdev, chan);
        rtw8852bx_set_txpwr_ref(rtwdev, phy_idx, pwr_ofst);
 }
 
index 0903e902d8f4e5f3b6275ac86b9222ad2f5fc741..3aaf70e32652ba1544915e05192a6d76f4aaef1d 100644 (file)
@@ -786,7 +786,7 @@ const struct rtw89_chip_info rtw8852bt_chip_info = {
        .support_unii4          = true,
        .support_ant_gain       = true,
        .support_tas            = false,
-       .support_sar_by_ant     = false,
+       .support_sar_by_ant     = true,
        .ul_tb_waveform_ctrl    = true,
        .ul_tb_pwr_diff         = false,
        .rx_freq_frome_ie       = true,