]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: rtw89: phy: update TSSI flow for RTL8922D
authorZong-Zhe Yang <kevin_yang@realtek.com>
Sat, 17 Jan 2026 04:41:54 +0000 (12:41 +0800)
committerPing-Ke Shih <pkshih@realtek.com>
Thu, 22 Jan 2026 02:16:01 +0000 (10:16 +0800)
TSSI is to do TX compensation caused by temperature. The RTL8922D defines
different H2C command format. Update it accordingly.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260117044157.2392958-7-pkshih@realtek.com
drivers/net/wireless/realtek/rtw89/fw.c
drivers/net/wireless/realtek/rtw89/phy.c

index 5e405b57121f035846505230a1896cded3e11572..5f98ca592a3ef5002cde029c67d9676df58e6b0f 100644 (file)
@@ -7291,6 +7291,7 @@ fail:
 int rtw89_fw_h2c_rf_tssi(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy_idx,
                         const struct rtw89_chan *chan, enum rtw89_tssi_mode tssi_mode)
 {
+       const struct rtw89_chip_info *chip = rtwdev->chip;
        struct rtw89_efuse *efuse = &rtwdev->efuse;
        struct rtw89_hal *hal = &rtwdev->hal;
        struct rtw89_h2c_rf_tssi *h2c;
@@ -7311,11 +7312,15 @@ int rtw89_fw_h2c_rf_tssi(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy_idx,
        h2c->ch = chan->channel;
        h2c->bw = chan->band_width;
        h2c->band = chan->band_type;
-       h2c->hwtx_en = true;
        h2c->cv = hal->cv;
        h2c->tssi_mode = tssi_mode;
        h2c->rfe_type = efuse->rfe_type;
 
+       if (chip->chip_id == RTL8922A)
+               h2c->hwtx_en = true;
+       else
+               h2c->hwtx_en = false;
+
        rtw89_phy_rfk_tssi_fill_fwcmd_efuse_to_de(rtwdev, phy_idx, chan, h2c);
        rtw89_phy_rfk_tssi_fill_fwcmd_tmeter_tbl(rtwdev, phy_idx, chan, h2c);
 
index c9bd3b7c54894bc8e4423bdf010b7d528a2fd379..f3ef5673cb6a7d199b8eb3d3cb5c1f169851c5b2 100644 (file)
@@ -4566,6 +4566,7 @@ void rtw89_phy_rfk_tssi_fill_fwcmd_efuse_to_de(struct rtw89_dev *rtwdev,
                                               const struct rtw89_chan *chan,
                                               struct rtw89_h2c_rf_tssi *h2c)
 {
+       const struct rtw89_chip_info *chip = rtwdev->chip;
        struct rtw89_tssi_info *tssi_info = &rtwdev->tssi;
        u8 ch = chan->channel;
        s8 trim_de;
@@ -4589,9 +4590,14 @@ void rtw89_phy_rfk_tssi_fill_fwcmd_efuse_to_de(struct rtw89_dev *rtwdev,
                cck_de = tssi_info->tssi_cck[i][gidx];
                val = u32_get_bits(cck_de + trim_de, 0xff);
 
-               h2c->curr_tssi_cck_de[i] = 0x0;
-               h2c->curr_tssi_cck_de_20m[i] = val;
-               h2c->curr_tssi_cck_de_40m[i] = val;
+               if (chip->chip_id == RTL8922A) {
+                       h2c->curr_tssi_cck_de[i] = 0x0;
+                       h2c->curr_tssi_cck_de_20m[i] = val;
+                       h2c->curr_tssi_cck_de_40m[i] = val;
+               } else {
+                       h2c->curr_tssi_cck_de[i] = val;
+               }
+
                h2c->curr_tssi_efuse_cck_de[i] = cck_de;
 
                rtw89_debug(rtwdev, RTW89_DBG_TSSI,
@@ -4600,12 +4606,17 @@ void rtw89_phy_rfk_tssi_fill_fwcmd_efuse_to_de(struct rtw89_dev *rtwdev,
                ofdm_de = phy_tssi_get_ofdm_de(rtwdev, phy, chan, i);
                val = u32_get_bits(ofdm_de + trim_de, 0xff);
 
-               h2c->curr_tssi_ofdm_de[i] = 0x0;
-               h2c->curr_tssi_ofdm_de_20m[i] = val;
-               h2c->curr_tssi_ofdm_de_40m[i] = val;
-               h2c->curr_tssi_ofdm_de_80m[i] = val;
-               h2c->curr_tssi_ofdm_de_160m[i] = val;
-               h2c->curr_tssi_ofdm_de_320m[i] = val;
+               if (chip->chip_id == RTL8922A) {
+                       h2c->curr_tssi_ofdm_de[i] = 0x0;
+                       h2c->curr_tssi_ofdm_de_20m[i] = val;
+                       h2c->curr_tssi_ofdm_de_40m[i] = val;
+                       h2c->curr_tssi_ofdm_de_80m[i] = val;
+                       h2c->curr_tssi_ofdm_de_160m[i] = val;
+                       h2c->curr_tssi_ofdm_de_320m[i] = val;
+               } else {
+                       h2c->curr_tssi_ofdm_de[i] = val;
+               }
+
                h2c->curr_tssi_efuse_ofdm_de[i] = ofdm_de;
 
                rtw89_debug(rtwdev, RTW89_DBG_TSSI,
@@ -4620,10 +4631,12 @@ void rtw89_phy_rfk_tssi_fill_fwcmd_tmeter_tbl(struct rtw89_dev *rtwdev,
 {
        struct rtw89_fw_txpwr_track_cfg *trk = rtwdev->fw.elm_info.txpwr_trk;
        struct rtw89_tssi_info *tssi_info = &rtwdev->tssi;
+       const struct rtw89_chip_info *chip = rtwdev->chip;
        const s8 *thm_up[RF_PATH_B + 1] = {};
        const s8 *thm_down[RF_PATH_B + 1] = {};
        u8 subband = chan->subband_type;
-       s8 thm_ofst[128] = {0};
+       s8 thm_ofst[128] = {};
+       int multiplier;
        u8 thermal;
        u8 path;
        u8 i, j;
@@ -4687,6 +4700,11 @@ void rtw89_phy_rfk_tssi_fill_fwcmd_tmeter_tbl(struct rtw89_dev *rtwdev,
        rtw89_debug(rtwdev, RTW89_DBG_TSSI,
                    "[TSSI] tmeter tbl on subband: %u\n", subband);
 
+       if (chip->chip_id == RTL8922A)
+               multiplier = 1;
+       else
+               multiplier = -1;
+
        for (path = RF_PATH_A; path <= RF_PATH_B; path++) {
                thermal = tssi_info->thermal[path];
                rtw89_debug(rtwdev, RTW89_DBG_TSSI,
@@ -4701,16 +4719,20 @@ void rtw89_phy_rfk_tssi_fill_fwcmd_tmeter_tbl(struct rtw89_dev *rtwdev,
                h2c->pg_thermal[path] = thermal;
 
                i = 0;
-               for (j = 0; j < 64; j++)
+               for (j = 0; j < 64; j++) {
                        thm_ofst[j] = i < DELTA_SWINGIDX_SIZE ?
                                      thm_up[path][i++] :
                                      thm_up[path][DELTA_SWINGIDX_SIZE - 1];
+                       thm_ofst[j] *= multiplier;
+               }
 
                i = 1;
-               for (j = 127; j >= 64; j--)
+               for (j = 127; j >= 64; j--) {
                        thm_ofst[j] = i < DELTA_SWINGIDX_SIZE ?
                                      -thm_down[path][i++] :
                                      -thm_down[path][DELTA_SWINGIDX_SIZE - 1];
+                       thm_ofst[j] *= multiplier;
+               }
 
                for (i = 0; i < 128; i += 4) {
                        h2c->ftable[path][i + 0] = thm_ofst[i + 3];