OSDN Git Service

rtw88: store firmware feature in firmware header
authorChin-Yen Lee <timlee@realtek.com>
Fri, 30 Oct 2020 08:48:24 +0000 (16:48 +0800)
committerKalle Valo <kvalo@codeaurora.org>
Sat, 7 Nov 2020 15:51:03 +0000 (17:51 +0200)
Some functions need the support of firmware with special version.
In order to get the feature of current firmware, we store the information
in firmware header and parse after firmware is loaded. The current feature
list in firmware header includes checking leave lps via C2H and
supported lps deep mode.

Signed-off-by: Chin-Yen Lee <timlee@realtek.com>
Signed-off-by: Tzu-En Huang <tehuang@realtek.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20201030084826.9034-3-tehuang@realtek.com
drivers/net/wireless/realtek/rtw88/fw.h
drivers/net/wireless/realtek/rtw88/main.c
drivers/net/wireless/realtek/rtw88/main.h

index 0864454..5b74830 100644 (file)
@@ -72,6 +72,14 @@ enum rtw_fw_rf_type {
        FW_RF_MAX_TYPE = 0xF,
 };
 
+enum rtw_fw_feature {
+       FW_FEATURE_SIG = BIT(0),
+       FW_FEATURE_LPS_C2H = BIT(1),
+       FW_FEATURE_LCLK = BIT(2),
+       FW_FEATURE_PG = BIT(3),
+       FW_FEATURE_MAX = BIT(31),
+};
+
 struct rtw_coex_info_req {
        u8 seq;
        u8 op_code;
@@ -177,7 +185,7 @@ struct rtw_fw_hdr {
        u8 subversion;
        u8 subindex;
        __le32 rsvd;            /* 0x08 */
-       __le32 rsvd2;           /* 0x0C */
+       __le32 feature;         /* 0x0C */
        u8 month;               /* 0x10 */
        u8 day;
        u8 hour;
index 565efd8..259ad84 100644 (file)
@@ -1259,6 +1259,17 @@ static void rtw_unset_supported_band(struct ieee80211_hw *hw,
        kfree(hw->wiphy->bands[NL80211_BAND_5GHZ]);
 }
 
+static void __update_firmware_feature(struct rtw_dev *rtwdev,
+                                     struct rtw_fw_state *fw)
+{
+       u32 feature;
+       const struct rtw_fw_hdr *fw_hdr =
+                               (const struct rtw_fw_hdr *)fw->firmware->data;
+
+       feature = le32_to_cpu(fw_hdr->feature);
+       fw->feature = feature & FW_FEATURE_SIG ? feature : 0;
+}
+
 static void __update_firmware_info(struct rtw_dev *rtwdev,
                                   struct rtw_fw_state *fw)
 {
@@ -1269,6 +1280,8 @@ static void __update_firmware_info(struct rtw_dev *rtwdev,
        fw->version = le16_to_cpu(fw_hdr->version);
        fw->sub_version = fw_hdr->subversion;
        fw->sub_index = fw_hdr->subindex;
+
+       __update_firmware_feature(rtwdev, fw);
 }
 
 static void __update_firmware_info_legacy(struct rtw_dev *rtwdev,
index fb2b1d4..82d4645 100644 (file)
@@ -1634,6 +1634,7 @@ struct rtw_fw_state {
        u8 sub_index;
        u16 h2c_version;
        u8 prev_dump_seq;
+       u32 feature;
 };
 
 struct rtw_hal {