wifi: mt76: mt7996: rework WA mcu command for mt7990
authorPeter Chiu <chui-hao.chiu@mediatek.com>
Wed, 9 Apr 2025 14:07:43 +0000 (22:07 +0800)
committerFelix Fietkau <nbd@nbd.name>
Wed, 21 May 2025 12:49:37 +0000 (14:49 +0200)
Since mt7990 lacks WA firmware, some WA commands are not supported or
need to be refactored to use the SDO command.
This is a preliminary patch to support mt7990 chipset.

Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Link: https://patch.msgid.link/20250409140750.724437-4-shayne.chen@mediatek.com
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
drivers/net/wireless/mediatek/mt76/mt7996/mcu.h

index 43237e518373f6b017bb113c7f77386f8b4c3df1..8226b975f7e639f4fc3a82c6418bf0946d44b16e 100644 (file)
@@ -1065,6 +1065,7 @@ enum {
        MCU_UNI_EVENT_WED_RRO = 0x57,
        MCU_UNI_EVENT_PER_STA_INFO = 0x6d,
        MCU_UNI_EVENT_ALL_STA_INFO = 0x6e,
+       MCU_UNI_EVENT_SDO = 0x83,
 };
 
 #define MCU_UNI_CMD_EVENT                      BIT(1)
@@ -1297,6 +1298,7 @@ enum {
        MCU_UNI_CMD_PER_STA_INFO = 0x6d,
        MCU_UNI_CMD_ALL_STA_INFO = 0x6e,
        MCU_UNI_CMD_ASSERT_DUMP = 0x6f,
+       MCU_UNI_CMD_SDO = 0x88,
 };
 
 enum {
index 1d12ccbacbcf658ffc4f559921b8e9b7ef71b486..a99e290faf1fc5fe5e2779afb0694bd2b56024a6 100644 (file)
@@ -338,8 +338,12 @@ exit:
 int mt7996_mcu_wa_cmd(struct mt7996_dev *dev, int cmd, u32 a1, u32 a2, u32 a3)
 {
        struct {
+               u8 _rsv[4];
+
+               __le16 tag;
+               __le16 len;
                __le32 args[3];
-       } req = {
+       } __packed req = {
                .args = {
                        cpu_to_le32(a1),
                        cpu_to_le32(a2),
@@ -347,7 +351,16 @@ int mt7996_mcu_wa_cmd(struct mt7996_dev *dev, int cmd, u32 a1, u32 a2, u32 a3)
                },
        };
 
-       return mt76_mcu_send_msg(&dev->mt76, cmd, &req, sizeof(req), false);
+       if (mt7996_has_wa(dev))
+               return mt76_mcu_send_msg(&dev->mt76, cmd, &req.args,
+                                        sizeof(req.args), false);
+
+       req.tag = cpu_to_le16(cmd == MCU_WA_PARAM_CMD(QUERY) ? UNI_CMD_SDO_QUERY :
+                                                              UNI_CMD_SDO_SET);
+       req.len = cpu_to_le16(sizeof(req) - 4);
+
+       return mt76_mcu_send_msg(&dev->mt76, MCU_WA_UNI_CMD(SDO), &req,
+                                sizeof(req), false);
 }
 
 static void
@@ -3223,13 +3236,15 @@ int mt7996_mcu_init_firmware(struct mt7996_dev *dev)
        if (ret)
                return ret;
 
-       ret = mt7996_mcu_fw_log_2_host(dev, MCU_FW_LOG_WA, 0);
-       if (ret)
-               return ret;
+       if (mt7996_has_wa(dev)) {
+               ret = mt7996_mcu_fw_log_2_host(dev, MCU_FW_LOG_WA, 0);
+               if (ret)
+                       return ret;
 
-       ret = mt7996_mcu_set_mwds(dev, 1);
-       if (ret)
-               return ret;
+               ret = mt7996_mcu_set_mwds(dev, 1);
+               if (ret)
+                       return ret;
+       }
 
        ret = mt7996_mcu_init_rx_airtime(dev);
        if (ret)
@@ -4749,7 +4764,26 @@ int mt7996_mcu_cp_support(struct mt7996_dev *dev, u8 mode)
            mode > mt76_connac_lmac_mapping(IEEE80211_AC_VO))
                return -EINVAL;
 
+       if (!mt7996_has_wa(dev)) {
+               struct {
+                       u8 _rsv[4];
+
+                       __le16 tag;
+                       __le16 len;
+                       u8 cp_mode;
+                       u8 rsv[3];
+               } __packed req = {
+                       .tag = cpu_to_le16(UNI_CMD_SDO_CP_MODE),
+                       .len = cpu_to_le16(sizeof(req) - 4),
+                       .cp_mode = mode,
+               };
+
+               return mt76_mcu_send_msg(&dev->mt76, MCU_WA_UNI_CMD(SDO),
+                                        &req, sizeof(req), false);
+       }
+
        cp_mode = cpu_to_le32(mode);
+
        return mt76_mcu_send_msg(&dev->mt76, MCU_WA_EXT_CMD(CP_SUPPORT),
                                 &cp_mode, sizeof(cp_mode), true);
 }
index 2ab6a53bee869a69d2ee7c0f342e379450c3d6dc..8ef7d4baee906582c8db8645cbfdb8364b68ee22 100644 (file)
@@ -937,6 +937,12 @@ enum {
        UNI_CMD_SER_TRIGGER
 };
 
+enum {
+       UNI_CMD_SDO_SET = 1,
+       UNI_CMD_SDO_QUERY,
+       UNI_CMD_SDO_CP_MODE = 6,
+};
+
 enum {
        MT7996_SEC_MODE_PLAIN,
        MT7996_SEC_MODE_AES,