wifi: rtw89: 8922a: rfk: support firmware command RX DCK v1 format
authorPing-Ke Shih <pkshih@realtek.com>
Fri, 13 Sep 2024 07:13:37 +0000 (15:13 +0800)
committerPing-Ke Shih <pkshih@realtek.com>
Fri, 20 Sep 2024 02:46:05 +0000 (10:46 +0800)
RX DCK stands for receiver DC calibration. The v1 format adds a field to
indicate the calibration is for operation channel or an average value for
all scanning channels. Update the format accordingly, and increase
firmware format sequence to 2.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20240913071340.41822-3-pkshih@realtek.com
drivers/net/wireless/realtek/rtw89/core.h
drivers/net/wireless/realtek/rtw89/fw.c
drivers/net/wireless/realtek/rtw89/fw.h
drivers/net/wireless/realtek/rtw89/phy.c
drivers/net/wireless/realtek/rtw89/phy.h
drivers/net/wireless/realtek/rtw89/rtw8922a.c

index 4ed9034fdb46416fb30b611a90d25ca9c45b2547..64b7fd1f6079784317d766c086d87f160d1e47f4 100644 (file)
@@ -4445,6 +4445,7 @@ enum rtw89_fw_feature {
        RTW89_FW_FEATURE_SCAN_OFFLOAD_BE_V0,
        RTW89_FW_FEATURE_WOW_REASON_V1,
        RTW89_FW_FEATURE_RFK_PRE_NOTIFY_V0,
+       RTW89_FW_FEATURE_RFK_RXDCK_V0,
 };
 
 struct rtw89_fw_suit {
index d9b0e7ebe619a3a2d7a2f01b82338c95113b358b..93a338bbf59c5bf3fb5aeff2e6b396ccb646af2f 100644 (file)
@@ -687,6 +687,7 @@ static const struct __fw_feat_cfg fw_feat_tbl[] = {
        __CFG_FW_FEAT(RTL8922A, ge, 0, 35, 12, 0, BEACON_FILTER),
        __CFG_FW_FEAT(RTL8922A, ge, 0, 35, 22, 0, WOW_REASON_V1),
        __CFG_FW_FEAT(RTL8922A, lt, 0, 35, 31, 0, RFK_PRE_NOTIFY_V0),
+       __CFG_FW_FEAT(RTL8922A, lt, 0, 35, 42, 0, RFK_RXDCK_V0),
 };
 
 static void rtw89_fw_iterate_feature_cfg(struct rtw89_fw_info *fw,
@@ -5518,30 +5519,44 @@ fail:
 }
 
 int rtw89_fw_h2c_rf_rxdck(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy_idx,
-                         const struct rtw89_chan *chan)
+                         const struct rtw89_chan *chan, bool is_chl_k)
 {
+       struct rtw89_h2c_rf_rxdck_v0 *v0;
        struct rtw89_h2c_rf_rxdck *h2c;
        u32 len = sizeof(*h2c);
        struct sk_buff *skb;
+       int ver = -1;
        int ret;
 
+       if (RTW89_CHK_FW_FEATURE(RFK_RXDCK_V0, &rtwdev->fw)) {
+               len = sizeof(*v0);
+               ver = 0;
+       }
+
        skb = rtw89_fw_h2c_alloc_skb_with_hdr(rtwdev, len);
        if (!skb) {
                rtw89_err(rtwdev, "failed to alloc skb for h2c RF RXDCK\n");
                return -ENOMEM;
        }
        skb_put(skb, len);
-       h2c = (struct rtw89_h2c_rf_rxdck *)skb->data;
+       v0 = (struct rtw89_h2c_rf_rxdck_v0 *)skb->data;
+
+       v0->len = len;
+       v0->phy = phy_idx;
+       v0->is_afe = false;
+       v0->kpath = RF_AB;
+       v0->cur_band = chan->band_type;
+       v0->cur_bw = chan->band_width;
+       v0->cur_ch = chan->channel;
+       v0->rxdck_dbg_en = rtw89_debug_is_enabled(rtwdev, RTW89_DBG_RFK);
+
+       if (ver == 0)
+               goto hdr;
 
-       h2c->len = len;
-       h2c->phy = phy_idx;
-       h2c->is_afe = false;
-       h2c->kpath = RF_AB;
-       h2c->cur_band = chan->band_type;
-       h2c->cur_bw = chan->band_width;
-       h2c->cur_ch = chan->channel;
-       h2c->rxdck_dbg_en = rtw89_debug_is_enabled(rtwdev, RTW89_DBG_RFK);
+       h2c = (struct rtw89_h2c_rf_rxdck *)skb->data;
+       h2c->is_chl_k = is_chl_k;
 
+hdr:
        rtw89_h2c_pkt_set_hdr(rtwdev, skb, FWCMD_TYPE_H2C,
                              H2C_CAT_OUTSRC, H2C_CL_OUTSRC_RF_FW_RFK,
                              H2C_FUNC_RFK_RXDCK_OFFLOAD, 0, 0, len);
index ad47e77d740b25f1815b27ad1a99c86a7f6e89c4..78820bd28098f95189ad32ff7b02d6364c1e11d1 100644 (file)
@@ -4286,7 +4286,7 @@ struct rtw89_h2c_rf_dack {
        __le32 type;
 } __packed;
 
-struct rtw89_h2c_rf_rxdck {
+struct rtw89_h2c_rf_rxdck_v0 {
        u8 len;
        u8 phy;
        u8 is_afe;
@@ -4297,6 +4297,11 @@ struct rtw89_h2c_rf_rxdck {
        u8 rxdck_dbg_en;
 } __packed;
 
+struct rtw89_h2c_rf_rxdck {
+       struct rtw89_h2c_rf_rxdck_v0 v0;
+       u8 is_chl_k;
+} __packed;
+
 enum rtw89_rf_log_type {
        RTW89_RF_RUN_LOG = 0,
        RTW89_RF_RPT_LOG = 1,
@@ -4501,7 +4506,7 @@ int rtw89_fw_h2c_rf_txgapk(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy_idx,
 int rtw89_fw_h2c_rf_dack(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy_idx,
                         const struct rtw89_chan *chan);
 int rtw89_fw_h2c_rf_rxdck(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy_idx,
-                         const struct rtw89_chan *chan);
+                         const struct rtw89_chan *chan, bool is_chl_k);
 int rtw89_fw_h2c_raw_with_hdr(struct rtw89_dev *rtwdev,
                              u8 h2c_class, u8 h2c_func, u8 *buf, u16 len,
                              bool rack, bool dack);
index c7165e757842be758b23b70d915fe55b204b7f67..0c0d25e602c9afb5865186a7b726c7eb367f4e98 100644 (file)
@@ -3171,13 +3171,13 @@ EXPORT_SYMBOL(rtw89_phy_rfk_dack_and_wait);
 int rtw89_phy_rfk_rxdck_and_wait(struct rtw89_dev *rtwdev,
                                 enum rtw89_phy_idx phy_idx,
                                 const struct rtw89_chan *chan,
-                                unsigned int ms)
+                                bool is_chl_k, unsigned int ms)
 {
        int ret;
 
        rtw89_phy_rfk_report_prep(rtwdev);
 
-       ret = rtw89_fw_h2c_rf_rxdck(rtwdev, phy_idx, chan);
+       ret = rtw89_fw_h2c_rf_rxdck(rtwdev, phy_idx, chan, is_chl_k);
        if (ret)
                return ret;
 
index 6dd8ec46939acd41503b2d3b9444061a77665d67..d00faf151d39a25b393cd2a363caa1eed470b7ad 100644 (file)
@@ -929,7 +929,7 @@ int rtw89_phy_rfk_dack_and_wait(struct rtw89_dev *rtwdev,
 int rtw89_phy_rfk_rxdck_and_wait(struct rtw89_dev *rtwdev,
                                 enum rtw89_phy_idx phy_idx,
                                 const struct rtw89_chan *chan,
-                                unsigned int ms);
+                                bool is_chl_k, unsigned int ms);
 void rtw89_phy_rfk_tssi_fill_fwcmd_efuse_to_de(struct rtw89_dev *rtwdev,
                                               enum rtw89_phy_idx phy,
                                               const struct rtw89_chan *chan,
index fb422bff4912d0c6541d856a12bb6bee7e054c58..c2be460f6238e4a6920187ca3886724ab5116a9e 100644 (file)
@@ -13,7 +13,7 @@
 #include "rtw8922a_rfk.h"
 #include "util.h"
 
-#define RTW8922A_FW_FORMAT_MAX 1
+#define RTW8922A_FW_FORMAT_MAX 2
 #define RTW8922A_FW_BASENAME "rtw89/rtw8922a_fw"
 #define RTW8922A_MODULE_FIRMWARE \
        RTW8922A_FW_BASENAME "-" __stringify(RTW8922A_FW_FORMAT_MAX) ".bin"
@@ -1998,7 +1998,7 @@ static void rtw8922a_rfk_init_late(struct rtw89_dev *rtwdev)
        rtw89_phy_rfk_pre_ntfy_and_wait(rtwdev, RTW89_PHY_0, 5);
 
        rtw89_phy_rfk_dack_and_wait(rtwdev, RTW89_PHY_0, chan, 58);
-       rtw89_phy_rfk_rxdck_and_wait(rtwdev, RTW89_PHY_0, chan, 32);
+       rtw89_phy_rfk_rxdck_and_wait(rtwdev, RTW89_PHY_0, chan, false, 32);
 }
 
 static void _wait_rx_mode(struct rtw89_dev *rtwdev, u8 kpath)
@@ -2037,7 +2037,7 @@ static void rtw8922a_rfk_channel(struct rtw89_dev *rtwdev, struct rtw89_vif *rtw
        rtw89_phy_rfk_iqk_and_wait(rtwdev, phy_idx, chan, 84);
        rtw89_phy_rfk_tssi_and_wait(rtwdev, phy_idx, chan, RTW89_TSSI_NORMAL, 20);
        rtw89_phy_rfk_dpk_and_wait(rtwdev, phy_idx, chan, 34);
-       rtw89_phy_rfk_rxdck_and_wait(rtwdev, RTW89_PHY_0, chan, 32);
+       rtw89_phy_rfk_rxdck_and_wait(rtwdev, RTW89_PHY_0, chan, true, 32);
 
        rtw89_chip_resume_sch_tx(rtwdev, phy_idx, tx_en);
        rtw89_btc_ntfy_wl_rfk(rtwdev, phy_map, BTC_WRFKT_CHLK, BTC_WRFK_STOP);