]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: rtw89: fw: consider hardware AID for firmware elements
authorPing-Ke Shih <pkshih@realtek.com>
Tue, 6 Jan 2026 03:09:10 +0000 (11:09 +0800)
committerPing-Ke Shih <pkshih@realtek.com>
Fri, 9 Jan 2026 05:49:09 +0000 (13:49 +0800)
The coming chip RTL8922D has variant of hardware with different AID. Add
AID field to header of firmware elements, and compare AID with the value
read from hardware.

Currently, apply this rule to BB and RF parameters.

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

index 5d114c4a7c1eb426be2e8250adc2bbe89dd08d61..03659f07de8c23121801559cbc21bef55484f7bf 100644 (file)
@@ -1061,42 +1061,47 @@ int rtw89_build_phy_tbl_from_elm(struct rtw89_dev *rtwdev,
                                 const union rtw89_fw_element_arg arg)
 {
        struct rtw89_fw_elm_info *elm_info = &rtwdev->fw.elm_info;
-       struct rtw89_phy_table *tbl;
+       struct rtw89_hal *hal = &rtwdev->hal;
+       struct rtw89_phy_table *tbl, **pp;
        struct rtw89_reg2_def *regs;
-       enum rtw89_rf_path rf_path;
+       bool radio = false;
        u32 n_regs, i;
+       u16 aid;
        u8 idx;
 
-       tbl = kzalloc(sizeof(*tbl), GFP_KERNEL);
-       if (!tbl)
-               return -ENOMEM;
-
        switch (le32_to_cpu(elm->id)) {
        case RTW89_FW_ELEMENT_ID_BB_REG:
-               elm_info->bb_tbl = tbl;
+               pp = &elm_info->bb_tbl;
                break;
        case RTW89_FW_ELEMENT_ID_BB_GAIN:
-               elm_info->bb_gain = tbl;
+               pp = &elm_info->bb_gain;
                break;
        case RTW89_FW_ELEMENT_ID_RADIO_A:
        case RTW89_FW_ELEMENT_ID_RADIO_B:
        case RTW89_FW_ELEMENT_ID_RADIO_C:
        case RTW89_FW_ELEMENT_ID_RADIO_D:
-               rf_path = arg.rf_path;
                idx = elm->u.reg2.idx;
+               pp = &elm_info->rf_radio[idx];
 
-               elm_info->rf_radio[idx] = tbl;
-               tbl->rf_path = rf_path;
-               tbl->config = rtw89_phy_config_rf_reg_v1;
+               radio = true;
                break;
        case RTW89_FW_ELEMENT_ID_RF_NCTL:
-               elm_info->rf_nctl = tbl;
+               pp = &elm_info->rf_nctl;
                break;
        default:
-               kfree(tbl);
                return -ENOENT;
        }
 
+       aid = le16_to_cpu(elm->aid);
+       if (aid && aid != hal->aid)
+               return 1; /* ignore if aid not matched */
+       else if (*pp)
+               return 1; /* ignore if an element is existing */
+
+       tbl = kzalloc(sizeof(*tbl), GFP_KERNEL);
+       if (!tbl)
+               return -ENOMEM;
+
        n_regs = le32_to_cpu(elm->size) / sizeof(tbl->regs[0]);
        regs = kcalloc(n_regs, sizeof(*regs), GFP_KERNEL);
        if (!regs)
@@ -1110,6 +1115,13 @@ int rtw89_build_phy_tbl_from_elm(struct rtw89_dev *rtwdev,
        tbl->n_regs = n_regs;
        tbl->regs = regs;
 
+       if (radio) {
+               tbl->rf_path = arg.rf_path;
+               tbl->config = rtw89_phy_config_rf_reg_v1;
+       }
+
+       *pp = tbl;
+
        return 0;
 
 out:
index 760730da07ebf63ae81c50488a3e0704e1d6a020..1542634f0146f69ebc624359d6229b533d4dbd5f 100644 (file)
@@ -4311,7 +4311,8 @@ struct rtw89_fw_element_hdr {
        __le32 id; /* enum rtw89_fw_element_id */
        __le32 size; /* exclude header size */
        u8 ver[4];
-       __le32 rsvd0;
+       __le16 aid; /* should match rtw89_hal::aid */
+       __le16 rsvd0;
        __le32 rsvd1;
        __le32 rsvd2;
        union {