From: Anthony Liu <anthony.liu@mediatek.com>
To: <nbd@nbd.name>, <lorenzo@kernel.org>
Cc: <Sean.Wang@mediatek.com>, <Leon.Yen@mediatek.com>,
<Quan.Zhou@mediatek.com>, <Ryder.lee@mediatek.com>,
<litien.chang@mediatek.com>, <kun.wu@mediatek.com>,
<jb.tsai@mediatek.com>, <emery.hsin@mediatek.com>,
<linux-wireless@vger.kernel.org>,
<linux-mediatek@lists.infradead.org>,
Anthony Liu <anthony.liu@mediatek.com>
Subject: [PATCH v1] [PATCH 02/05] wifi: mt76: refactor chip_cfg commands to be a generic API
Date: Thu, 20 Aug 2026 19:11:59 +0800 [thread overview]
Message-ID: <20260820111202.1935373-2-anthony.liu@mediatek.com> (raw)
In-Reply-To: <20260820111202.1935373-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 F/W, and uses mt76_connac_mcu_chip_config()
otherwise.
Change-Id: I110a76dcfb7398bc69e6ecbbfb96fb6176d73446
CR-Id: WCNCR00542202
Signed-off-by: Anthony Liu <anthony.liu@mediatek.com>
Reviewed-on: https://gerrit.mediatek.inc/c/neptune/oss/nbd168_wireless/+/12378111
AutoUT-Review-Label: srv_neptune_adm <srv_neptune_adm@mediatek.com>
GAI-Code-Review: srv_ai_review001 <srv_ai_review001@mediatek.com>
Reviewed-by: jb.tsai <jb.tsai@mediatek.com>
Code-Review-Course-Train: srv_check_service <srv_check_service@mediatek.com>
Commit-Check: srv_check_service <srv_check_service@mediatek.com>
---
.../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 de83d41ca9c9..015bbd92d458 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
@@ -2057,6 +2057,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 45f77c80e879..d237d56eb1c1 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
@@ -1459,6 +1459,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,
@@ -2099,6 +2103,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 d01ff49de47a..69c545986d61 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c
@@ -276,7 +276,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 fa29c486a455..376cc4833242 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -1166,7 +1166,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);
@@ -1177,11 +1177,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 11f9eac13ffc..c397b435a230 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 9efc251cb745..e7f3d36d5338 100644
--- a/drivers/net/wireless/mediatek/mt76/mt792x.h
+++ b/drivers/net/wireless/mediatek/mt76/mt792x.h
@@ -531,6 +531,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 0ad33f74c228..d676517df902 100644
--- a/drivers/net/wireless/mediatek/mt76/mt792x_core.c
+++ b/drivers/net/wireless/mediatek/mt76/mt792x_core.c
@@ -1167,6 +1167,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-08-20 11:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-20 11:11 [PATCH v1] [PATCH 01/05] wifi: mt76: refactor chip_config to accept generic commands Anthony Liu
2026-08-20 11:11 ` Anthony Liu [this message]
2026-08-20 11:12 ` [PATCH v1] [PATCH 03/05] wifi: mt76: add ACPI MTFG option for bus configuration Anthony Liu
2026-08-20 11:12 ` [PATCH v1] [PATCH 04/05] wifi: mt76: add PCIe speed tuning for mt7922/mt7928 Anthony Liu
2026-08-20 11:12 ` [PATCH v1] [PATCH 05/05] wifi: mt76: add PERF_IND " Anthony Liu
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=20260820111202.1935373-2-anthony.liu@mediatek.com \
--to=anthony.liu@mediatek.com \
--cc=Leon.Yen@mediatek.com \
--cc=Quan.Zhou@mediatek.com \
--cc=Ryder.lee@mediatek.com \
--cc=Sean.Wang@mediatek.com \
--cc=emery.hsin@mediatek.com \
--cc=jb.tsai@mediatek.com \
--cc=kun.wu@mediatek.com \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-wireless@vger.kernel.org \
--cc=litien.chang@mediatek.com \
--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