From: Anthony Liu <anthony.liu@mediatek.com>
To: <anthony.liu@mediatek.com>
Cc: <Emery.Hsin@mediatek.com>, <Jb.Tsai@mediatek.com>,
<Leon.Yen@mediatek.com>, <Litien.Chang@mediatek.com>,
<Quan.Zhou@mediatek.com>, <Ryder.Lee@mediatek.com>,
<Sean.Wang@mediatek.com>, <kun.wu@mediatek.com>,
<linux-mediatek@lists.infradead.org>,
<linux-wireless@vger.kernel.org>, <lorenzo@kernel.org>,
<nbd@nbd.name>
Subject: [PATCH v5 2/5] wifi: mt76: refactor chip_cfg commands to be a generic API
Date: Thu, 26 Nov 2026 17:54:52 +0800 [thread overview]
Message-ID: <20261126095455.3280998-3-anthony.liu@mediatek.com> (raw)
In-Reply-To: <20261126095455.3280998-1-anthony.liu@mediatek.com>
New chip_cfg command isn't chip specific but only available to mt7925.
1. Move chip specific mt7925_mcu_chip_config() from mt76/mt7925/mcu.c to
mt76_connac_mcu_uni_chip_config() in mt76/mt76_connac_mcu.c.
2. mt792x_mcu_chip_config() uses mt76_connac_mcu_uni_chip_config() if is
dealing with CONNAC3 FW, and uses mt76_connac_mcu_chip_config()
otherwise.
Signed-off-by: Anthony Liu <anthony.liu@mediatek.com>
Reviewed-by: Felix Fietkau <nbd@nbd.name>
---
.../wireless/mediatek/mt76/mt76_connac_mcu.c | 35 +++++++++++++++++++
.../wireless/mediatek/mt76/mt76_connac_mcu.h | 5 +++
.../wireless/mediatek/mt76/mt7925/debugfs.c | 2 +-
.../net/wireless/mediatek/mt76/mt7925/mcu.c | 6 ++--
.../net/wireless/mediatek/mt76/mt7925/mcu.h | 1 -
drivers/net/wireless/mediatek/mt76/mt792x.h | 1 +
.../net/wireless/mediatek/mt76/mt792x_core.c | 13 +++++++
7 files changed, 58 insertions(+), 5 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
index 0e3f23e52382..01434b1e01f5 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
@@ -2060,6 +2060,41 @@ int mt76_connac_mcu_chip_config(struct mt76_dev *dev, const char *cmd)
}
EXPORT_SYMBOL_GPL(mt76_connac_mcu_chip_config);
+/* Unified-command form of chip_config (connac3, e.g. MT7925/MT7928): the same
+ * CE payload carried as a TLV inside MCU_UNI_CMD_CHIP_CONFIG.
+ */
+int mt76_connac_mcu_uni_chip_config(struct mt76_dev *dev, const char *cmd)
+{
+ ssize_t len;
+
+ struct {
+ u8 rsv[4];
+ __le16 tag;
+ __le16 len;
+ struct mt76_connac_config config;
+ } __packed req = {
+ .tag = cpu_to_le16(UNI_CHIP_CONFIG_CHIP_CFG),
+ .len = cpu_to_le16(sizeof(req) - sizeof(req.rsv)),
+ .config = {
+ .resp_type = 0,
+ .type = 0,
+ },
+ };
+
+ if (!cmd)
+ return -EINVAL;
+
+ len = strscpy(req.config.data, cmd);
+ if (len == -E2BIG)
+ return -E2BIG;
+
+ req.config.data_size = cpu_to_le16(len + 1);
+
+ return mt76_mcu_send_msg(dev, MCU_UNI_CMD(CHIP_CONFIG),
+ &req, sizeof(req), false);
+}
+EXPORT_SYMBOL_GPL(mt76_connac_mcu_uni_chip_config);
+
int mt76_connac_mcu_set_deep_sleep(struct mt76_dev *dev, bool enable)
{
struct mt76_connac_config req = {
diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
index c5fb7e2adab1..0d2670b7b9fb 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
@@ -1467,6 +1467,10 @@ enum UNI_ALL_STA_INFO_TAG {
UNI_ALL_STA_MAX_NUM
};
+enum {
+ UNI_CHIP_CONFIG_CHIP_CFG = 2,
+};
+
enum {
MT_NIC_CAP_TX_RESOURCE,
MT_NIC_CAP_TX_EFUSE_ADDR,
@@ -2123,6 +2127,7 @@ int mt76_connac_sta_state_dp(struct mt76_dev *dev,
enum ieee80211_sta_state old_state,
enum ieee80211_sta_state new_state);
int mt76_connac_mcu_chip_config(struct mt76_dev *dev, const char *cmd);
+int mt76_connac_mcu_uni_chip_config(struct mt76_dev *dev, const char *cmd);
int mt76_connac_mcu_set_deep_sleep(struct mt76_dev *dev, bool enable);
void mt76_connac_mcu_coredump_event(struct mt76_dev *dev, struct sk_buff *skb,
struct mt76_connac_coredump *coredump);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c
index 0c40741273a9..cfe175dbc5f3 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c
@@ -280,7 +280,7 @@ static int mt7925_chip_reset(void *data, u64 val)
default:
/* Collect the core dump before reset wifisys. */
mt792x_mutex_acquire(dev);
- ret = mt7925_mcu_chip_config(dev, "assert");
+ ret = mt792x_mcu_chip_config(dev, "assert");
mt792x_mutex_release(dev);
break;
}
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index d89230fc9687..83f5f02395ec 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -1280,7 +1280,7 @@ int mt7925_mcu_set_deep_sleep(struct mt792x_dev *dev, bool enable)
snprintf(cmd, sizeof(cmd), "KeepFullPwr %d", !enable);
- return mt7925_mcu_chip_config(dev, cmd);
+ return mt792x_mcu_chip_config(dev, cmd);
}
EXPORT_SYMBOL_GPL(mt7925_mcu_set_deep_sleep);
@@ -1291,11 +1291,11 @@ int mt7925_mcu_set_thermal_protect(struct mt792x_dev *dev)
snprintf(cmd, sizeof(cmd), "ThermalProtGband %d %d %d %d %d %d %d %d %d %d",
0, 100, 90, 80, 30, 1, 1, 115, 105, 5);
- ret = mt7925_mcu_chip_config(dev, cmd);
+ ret = mt792x_mcu_chip_config(dev, cmd);
snprintf(cmd, sizeof(cmd), "ThermalProtAband %d %d %d %d %d %d %d %d %d %d",
1, 100, 90, 80, 30, 1, 1, 115, 105, 5);
- ret |= mt7925_mcu_chip_config(dev, cmd);
+ ret |= mt792x_mcu_chip_config(dev, cmd);
return ret;
}
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h
index fe40873e6107..7a9005db9c00 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h
@@ -115,7 +115,6 @@ enum {
};
enum {
- UNI_CHIP_CONFIG_CHIP_CFG = 0x2,
UNI_CHIP_CONFIG_NIC_CAPA = 0x3,
};
diff --git a/drivers/net/wireless/mediatek/mt76/mt792x.h b/drivers/net/wireless/mediatek/mt76/mt792x.h
index 260abdc978f8..79f57736db35 100644
--- a/drivers/net/wireless/mediatek/mt76/mt792x.h
+++ b/drivers/net/wireless/mediatek/mt76/mt792x.h
@@ -669,6 +669,7 @@ void mt792x_mac_link_bss_remove(struct mt792x_dev *dev,
struct mt792x_bss_conf *mconf,
struct mt792x_link_sta *mlink);
void mt792x_config_mac_addr_list(struct mt792x_dev *dev);
+int mt792x_mcu_chip_config(struct mt792x_dev *dev, const char *cmd);
static inline char *mt792x_ram_name(struct mt792x_dev *dev)
{
diff --git a/drivers/net/wireless/mediatek/mt76/mt792x_core.c b/drivers/net/wireless/mediatek/mt76/mt792x_core.c
index 7dddce02d600..a59aedd498b2 100644
--- a/drivers/net/wireless/mediatek/mt76/mt792x_core.c
+++ b/drivers/net/wireless/mediatek/mt76/mt792x_core.c
@@ -1238,6 +1238,19 @@ void mt792x_config_mac_addr_list(struct mt792x_dev *dev)
}
EXPORT_SYMBOL_GPL(mt792x_config_mac_addr_list);
+/* Pick the chip_config command form the running chip's firmware understands:
+ * connac3 (mt7925/mt7928) needs the unified command, connac2 (mt7921/mt7922)
+ * uses the legacy CE command.
+ */
+int mt792x_mcu_chip_config(struct mt792x_dev *dev, const char *cmd)
+{
+ if (is_connac3(&dev->mt76))
+ return mt76_connac_mcu_uni_chip_config(&dev->mt76, cmd);
+
+ return mt76_connac_mcu_chip_config(&dev->mt76, cmd);
+}
+EXPORT_SYMBOL_GPL(mt792x_mcu_chip_config);
+
MODULE_DESCRIPTION("MediaTek MT792x core driver");
MODULE_LICENSE("Dual BSD/GPL");
MODULE_AUTHOR("Lorenzo Bianconi <lorenzo@kernel.org>");
--
2.45.2
next prev parent reply other threads:[~2026-11-26 9:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 7:17 [PATCH v4 5/5] [PATCH v4] [PATCH 05/05] wifi: mt76: mt7922/mt7928: send Tx/Rx statistics to FW for link tuning Anthony Liu (劉良棟)
2026-11-26 9:54 ` [PATCH v5 0/5] wifi: mt76: optimize mt7922/mt7928 T-put per Tx/Rx stats Anthony Liu
2026-11-26 9:54 ` [PATCH v5 1/5] wifi: mt76: refactor chip_config to accept generic commands Anthony Liu
2026-11-26 9:54 ` Anthony Liu [this message]
2026-11-26 9:54 ` [PATCH v5 3/5] wifi: mt76: add ACPI MTFG option for bus configuration Anthony Liu
2026-11-26 9:54 ` [PATCH v5 4/5] wifi: mt76: add PCIe speed tuning for mt7922/mt7928 Anthony Liu
2026-11-26 9:54 ` [PATCH v5 5/5] wifi: mt76: mt7922/mt7928: send Tx/Rx statistics to FW for link tuning Anthony Liu
2026-11-26 16:03 ` [PATCH v5 0/5] wifi: mt76: optimize mt7922/mt7928 T-put per Tx/Rx stats Felix Fietkau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261126095455.3280998-3-anthony.liu@mediatek.com \
--to=anthony.liu@mediatek.com \
--cc=Emery.Hsin@mediatek.com \
--cc=Jb.Tsai@mediatek.com \
--cc=Leon.Yen@mediatek.com \
--cc=Litien.Chang@mediatek.com \
--cc=Quan.Zhou@mediatek.com \
--cc=Ryder.Lee@mediatek.com \
--cc=Sean.Wang@mediatek.com \
--cc=kun.wu@mediatek.com \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-wireless@vger.kernel.org \
--cc=lorenzo@kernel.org \
--cc=nbd@nbd.name \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox