From: Josef Schlehofer <pepe.schlehofer@gmail.com>
To: Felix Fietkau <nbd@nbd.name>,
Lorenzo Bianconi <lorenzo@kernel.org>,
Ryder Lee <ryder.lee@mediatek.com>,
Shayne Chen <shayne.chen@mediatek.com>,
Sean Wang <sean.wang@mediatek.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Ming Yen Hsieh <mingyen.hsieh@mediatek.com>,
JB Tsai <jb.tsai@mediatek.com>,
Allan Wang <allan.wang@mediatek.com>,
Quan Zhou <quan.zhou@mediatek.com>,
linux-wireless@vger.kernel.org,
linux-mediatek@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: [PATCH wireless-next 2/2] wifi: mt76: mt7925: add LED support for USB adapters
Date: Tue, 3 Nov 2026 14:35:28 +0100 [thread overview]
Message-ID: <20261103133528.53197-3-pepe.schlehofer@gmail.com> (raw)
In-Reply-To: <20261103133528.53197-1-pepe.schlehofer@gmail.com>
MT7925 USB adapters such as the NETGEAR A9000 have their status LED on
GPIO 8 of the chip. MediaTek's Windows driver asks the firmware to
switch it, but the firmware in linux-firmware does not act on that
request.
Drive the pin from the host instead. Set its level, then switch it from
its default function to a GPIO output through the CBTOP GPIO registers.
The register layout follows the coda headers in MediaTek's gen4m
driver. The LED of the A9000 is active low.
While the adapter is idle, the throughput trigger keeps requesting the
same state every second. Only write the registers when the state
changes, and forget the cached state whenever the firmware is loaded.
Link: https://github.com/morrownr/USB-WiFi/issues/731
Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
---
.../net/wireless/mediatek/mt76/mt7925/init.c | 51 +++++++++++++++++++
.../net/wireless/mediatek/mt76/mt7925/mcu.c | 2 +
.../net/wireless/mediatek/mt76/mt7925/regs.h | 8 +++
drivers/net/wireless/mediatek/mt76/mt792x.h | 2 +
4 files changed, 63 insertions(+)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/init.c b/drivers/net/wireless/mediatek/mt76/mt7925/init.c
index 8c3049b66a85..3dfb4b2d997c 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/init.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/init.c
@@ -187,6 +187,56 @@ static int mt7925_init_nan_cap(struct mt76_dev *mdev)
return 0;
}
+static int mt7925_led_set_brightness(struct led_classdev *led_cdev,
+ enum led_brightness brightness)
+{
+ struct mt76_phy *mphy = container_of(led_cdev, struct mt76_phy,
+ leds.cdev);
+ struct mt792x_dev *dev = container_of(mphy->dev, struct mt792x_dev,
+ mt76);
+ bool on = brightness != LED_OFF;
+ u8 pin = mphy->leds.pin;
+ u32 mask = BIT(pin % 32);
+
+ mt792x_mutex_acquire(dev);
+ if (dev->pm.suspended || dev->led_state == on)
+ goto out;
+
+ if (on ^ mphy->leds.al)
+ mt76_wr(dev, MT_CBTOP_GPIO_DOUT_SET(pin), mask);
+ else
+ mt76_wr(dev, MT_CBTOP_GPIO_DOUT_CLR(pin), mask);
+
+ /* the pin starts in another function, make it a GPIO output */
+ if (dev->led_state < 0) {
+ mt76_wr(dev, MT_CBTOP_GPIO_DIR_SET(pin), mask);
+ mt76_wr(dev, MT_CBTOP_GPIO_MODE_MOD(pin),
+ MT_CBTOP_GPIO_MODE_MOD_EN << ((pin % 8) * 4));
+ }
+
+ dev->led_state = on;
+out:
+ mt792x_mutex_release(dev);
+
+ return 0;
+}
+
+static void mt7925_init_led(struct mt792x_dev *dev)
+{
+ struct mt76_phy *mphy = &dev->mphy;
+
+ if (!IS_ENABLED(CONFIG_MT76_LEDS) || !mt76_is_usb(&dev->mt76) ||
+ !is_mt7925(&dev->mt76))
+ return;
+
+ /* MediaTek's Windows driver uses GPIO 8 on MT7925 USB adapters */
+ mphy->leds.pin = 8;
+ /* the LED of the NETGEAR A9000 is active low */
+ mphy->leds.al = true;
+ mphy->leds.cdev.flags |= LED_HW_PLUGGABLE;
+ mphy->leds.cdev.brightness_set_blocking = mt7925_led_set_brightness;
+}
+
static void mt7925_init_work(struct work_struct *work)
{
struct mt792x_dev *dev = container_of(work, struct mt792x_dev,
@@ -208,6 +258,7 @@ static void mt7925_init_work(struct work_struct *work)
}
dev->mt76.init_wiphy = mt7925_init_nan_cap;
+ mt7925_init_led(dev);
ret = mt76_register_device(&dev->mt76, true, mt76_rates,
ARRAY_SIZE(mt76_rates));
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index 26cdb3f0a98a..91564a2c1d65 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -1191,6 +1191,8 @@ int mt7925_run_firmware(struct mt792x_dev *dev)
{
int err;
+ dev->led_state = -1;
+
err = mt792x_load_firmware(dev);
if (err)
return err;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/regs.h b/drivers/net/wireless/mediatek/mt76/mt7925/regs.h
index e040dff321dd..73bd8c58dd84 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/regs.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/regs.h
@@ -91,6 +91,14 @@
#define MT_WFSYS_SW_RST_B 0x7c000140
+#define MT_CBTOP_GPIO_BASE 0x70005000
+#define MT_CBTOP_GPIO(ofs) (MT_CBTOP_GPIO_BASE + (ofs))
+#define MT_CBTOP_GPIO_DIR_SET(_n) MT_CBTOP_GPIO(0x004 + ((_n) / 32) * 0x10)
+#define MT_CBTOP_GPIO_DOUT_SET(_n) MT_CBTOP_GPIO(0x104 + ((_n) / 32) * 0x10)
+#define MT_CBTOP_GPIO_DOUT_CLR(_n) MT_CBTOP_GPIO(0x108 + ((_n) / 32) * 0x10)
+#define MT_CBTOP_GPIO_MODE_MOD(_n) MT_CBTOP_GPIO(0x30c + ((_n) / 8) * 0x10)
+#define MT_CBTOP_GPIO_MODE_MOD_EN BIT(3)
+
#define MT7925_WTBLON_TOP_WDUCR MT_WTBLON_TOP(0x370)
#define MT7928_WTBLON_TOP_WDUCR MT_WTBLON_TOP(0x400)
#define MT_WTBLON_TOP_WDUCR_GROUP GENMASK(4, 0)
diff --git a/drivers/net/wireless/mediatek/mt76/mt792x.h b/drivers/net/wireless/mediatek/mt76/mt792x.h
index a7d71e007da0..73c23f509b99 100644
--- a/drivers/net/wireless/mediatek/mt76/mt792x.h
+++ b/drivers/net/wireless/mediatek/mt76/mt792x.h
@@ -324,6 +324,8 @@ struct mt792x_dev {
u8 fw_debug;
u8 fw_features;
+ /* LED state last written to the GPIO, -1 if unknown */
+ s8 led_state;
struct mt76_connac_pm pm;
struct mt76_connac_coredump coredump;
--
2.54.0 (Apple Git-157)
prev parent reply other threads:[~2026-11-03 13:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 13:35 [PATCH wireless-next 0/2] wifi: mt76: mt7925: LED support for USB adapters Josef Schlehofer
2026-11-03 13:35 ` [PATCH wireless-next 1/2] wifi: mt76: allow LEDs with only brightness_set_blocking Josef Schlehofer
2026-11-03 13:35 ` Josef Schlehofer [this message]
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=20261103133528.53197-3-pepe.schlehofer@gmail.com \
--to=pepe.schlehofer@gmail.com \
--cc=allan.wang@mediatek.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=jb.tsai@mediatek.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-wireless@vger.kernel.org \
--cc=lorenzo@kernel.org \
--cc=matthias.bgg@gmail.com \
--cc=mingyen.hsieh@mediatek.com \
--cc=nbd@nbd.name \
--cc=quan.zhou@mediatek.com \
--cc=ryder.lee@mediatek.com \
--cc=sean.wang@mediatek.com \
--cc=shayne.chen@mediatek.com \
/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