Closed frank-w closed 1 year ago
Can you help to test these changes? Just built pass without testing.
https://pastebin.mozilla.org/LWUeUWzH/raw https://pastebin.mozilla.org/mU59hqee/raw
Hi,wrote with lorenzo yesterday gave me similar patches on mt76-next: https://github.com/LorenzoBianconi/wireless-drivers-next/commits/mt76-devel
These also converting dev-leds to phy-leds,but can try yours too...which base do yours have?
ah you can use his series. I can send mt7986 part based on his change if that works.
with the patches from lorenzo both leds go on when interface goes active, and i see sysfs-entry for both phy-leds...so far as expected. but they don't go off when i put interface to down, stop hostapd or "poweroff" the board...similar to my sysfs-test with phy0 before (can switch on, but not off). so this bug is not introduced by lorenzos patches
maybe anyone here has an idea why this happens
with the patches from lorenzo both leds go on when interface goes active,
and i see sysfs-entry for both phy-leds...so far as expected. but they don't go off when i put interface to down, stop hostapd or "poweroff" the board...similar to my sysfs-test with phy0 before (can switch on, but not off). so this bug is not introduced by lorenzos patches
maybe anyone here has an idea why this happens
— Reply to this email directly, view it on GitHub https://github.com/openwrt/mt76/issues/714#issuecomment-1339646666, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOA2CO2TOSUBEITVV6ARY3WL5TN7ANCNFSM6AAAAAASTMWSFM . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Hi Frank and Ryder,
I updated my led series according to the patches shared by Ryder (the code is available here [0]). wlan2g led is working properly now (it is blinking according to mac80211 configuration). wlan5g is not working yet (it is blinking steady).
@ryder: can you please take a look at mt7915 patch [1]?
Regards, Lorenzo
[0] https://github.com/LorenzoBianconi/wireless-drivers-next/tree/mt76-devel [1] https://github.com/LorenzoBianconi/wireless-drivers-next/commit/069932639ccfb26f55a81fc4df01a3298fbb773d
-- UNIX is Sexy: who | grep -i blonde | talk; cd ~; wine; talk; touch; unzip; touch; strip; gasp; finger; gasp; mount; fsck; more; yes; gasp; umount; make clean; sleep
hi lorenzo and ryder,
tested latest version on mt7986:
both leds stay on when interface goes down and hostapd is killed, also if i try to shut it off via sysfs or "poweroff" (also not expected, but same before the phy-leds-patches...with 2g4 led)
echo 0 > /sys/class/leds/mt76-phy1/brightness
seems to be ignored
@frank-w Can you test this?
--- a/drivers/net/wireless/mediatek/mt76/mt7915/regs.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/regs.h
@@ -1055,6 +1055,7 @@ enum offs_rev {
#define MT_LED_CTRL(_n) MT_LED_PHYS(0x00 + ((_n) * 4))
#define MT_LED_CTRL_KICK BIT(7)
+#define MT_LED_CTRL_BAND BIT(4)
#define MT_LED_CTRL_BLINK_MODE BIT(2)
#define MT_LED_CTRL_POLARITY BIT(1)
#define MT_LED_TX_BLINK(_n) MT_LED_PHYS(0x10 + ((_n) * 4))
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/init.c b/drivers/net/wireless/mediatek/mt76/mt7996/init.c
index 37ed32b9974c..18265465348b 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/init.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/init.c
@@ -67,6 +67,8 @@ static void mt7915_led_set_config(struct led_classdev *led_cdev,
val = MT_LED_CTRL_BLINK_MODE | MT_LED_CTRL_KICK;
if (mphy->led.al)
val |= MT_LED_CTRL_POLARITY;
+ if (mphy->band_idx)
+ val |= MT_LED_CTRL_BAND;
mt76_wr(dev, MT_LED_CTRL(mphy->band_idx), val);
mt76_clear(dev, MT_LED_CTRL(mphy->band_idx), MT_LED_CTRL_KICK)
with patch above traffic indication for 5g works too :)
so we only have the missing off-state-issue left
@frank-w https://github.com/frank-w Can you test this?
--- a/drivers/net/wireless/mediatek/mt76/mt7915/regs.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/regs.h @@ -1055,6 +1055,7 @@ enum offs_rev {
define MT_LED_CTRL(_n) MT_LED_PHYS(0x00 + ((_n) * 4))
define MT_LED_CTRL_KICK BIT(7)
define MT_LED_CTRL_BLINK_MODE BIT(2)
+#define MT_LED_CTRL_BAND BIT(4)
define MT_LED_CTRL_POLARITY BIT(1)
define MT_LED_TX_BLINK(_n) MT_LED_PHYS(0x10 + ((_n) * 4))
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/init.c b/drivers/net/wireless/mediatek/mt76/mt7996/init.c index 37ed32b9974c..18265465348b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7996/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7996/init.c @@ -67,6 +67,8 @@ static void mt7996_led_set_config(struct led_classdev *led_cdev, val = MT_LED_CTRL_BLINK_MODE | MT_LED_CTRL_KICK; if (mphy->led.al) val |= MT_LED_CTRL_POLARITY;
-
if (mphy->band_idx)
-
val |= MT_LED_CTRL_BAND; mt76_wr(dev, MT_LED_CTRL(mphy->band_idx), val); mt76_clear(dev, MT_LED_CTRL(mphy->band_idx), MT_LED_CTRL_KICK)
— Reply to this email directly, view it on GitHub https://github.com/openwrt/mt76/issues/714#issuecomment-1339860223, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOA2COXINOOPVJCY6UXM53WL6GWJANCNFSM6AAAAAASTMWSFM . You are receiving this because you commented.Message ID: @.***>
I can confirm both leds work for me applying this patch. This is my updated branch: https://github.com/LorenzoBianconi/wireless-drivers-next/tree/mt76-devel
@Frank: can you please confirm it? @Ryder: I can fold mt7996 support in my series if you share the code.
Regards, Lorenzo
-- UNIX is Sexy: who | grep -i blonde | talk; cd ~; wine; talk; touch; unzip; touch; strip; gasp; finger; gasp; mount; fsck; more; yes; gasp; umount; make clean; sleep
Have already tested ryders patch on top of your last version...works except led-off (interface down,hostapd/connection terminated,poweroff/sysfs). Would be nice if we can fix this too.
Have already tested ryders patch on top of your last version...works except led-off (interface down,hostapd/connection terminated,poweroff/sysfs). Would be nice if we can fix this too.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>
I think the mac is controlling the led according to the transmitted packet (register MT_TMAC_TCR0, mask MT_TMAC_TCR0_TX_BLINK). @ryder: is it possible to overwrite/avoid this behaviour?
Regards, Lorenzo
-- UNIX is Sexy: who | grep -i blonde | talk; cd ~; wine; talk; touch; unzip; touch; strip; gasp; finger; gasp; mount; fsck; more; yes; gasp; umount; make clean; sleep
I'm thinking switching blink mode to pwm mode (need more tests) as there's no way to turn LED off under blink mode.
@LorenzoBianconi @frank-w Can you test this change? I think we can go with / PWM mode / for all scenarios and get rid off "blink mode" configuration.
define MT_LED_CTRL_POLARITY BIT(1)
#define MT_LED_CTRL_REPLAY BIT(0)
#define MT_LED_STATUS_0(_n) MT_LED_PHYS(0x20 + ((_n) * 8))
#define MT_LED_STATUS_1(_n) MT_LED_PHYS(0x24 + ((_n) * 8))
#define MT_LED_STATUS_OFF GENMASK(31, 24)
#define MT_LED_STATUS_ON GENMASK(23, 16)
#define MT_LED_STATUS_DURATION GENMASK(15, 0)
static void mt7915_led_set_config(struct led_classdev *led_cdev,
u8 delay_on, u8 delay_off)
{
struct mt7915_dev *dev;
struct mt76_phy *mphy;
u32 val;
mphy = container_of(led_cdev, struct mt76_phy, led.cdev);
dev = container_of(mphy, struct mt7915_dev, mphy);
/* select TX blink mode, 2: only data frames */
if (delay_on || (delay_off != 0xff)) /* blink mode */
mt76_rmw_field(dev, MT_TMAC_TCR0(mphy->band_idx), MT_TMAC_TCR0_TX_BLINK, 2);
/* enable LED */
mt76_wr(dev, MT_LED_EN(mphy->band_idx), 1);
if (!delay_on && delay_off == 0xff) {
/* set PWM mode */
val = FIELD_PREP(MT_LED_STATUS_DURATION, 0xffff) |
FIELD_PREP(MT_LED_STATUS_OFF, delay_off) |
FIELD_PREP(MT_LED_STATUS_ON, delay_on);
mt76_wr(dev, MT_LED_STATUS_0(mphy->band_idx), val);
mt76_wr(dev, MT_LED_STATUS_1(mphy->band_idx), val);
} else { /* blink mode */
/* set LED Tx blink on/off time */
val = FIELD_PREP(MT_LED_TX_BLINK_ON_MASK, delay_on) |
FIELD_PREP(MT_LED_TX_BLINK_OFF_MASK, delay_off);
mt76_wr(dev, MT_LED_TX_BLINK(mphy->band_idx), val);
}
/* control LED */
val = MT_LED_CTRL_KICK;
if (mphy->led.al)
val |= MT_LED_CTRL_POLARITY;
if (mphy->band_idx)
val |= MT_LED_CTRL_BAND;
if (delay_on && (delay_off != 0xff)) /* blink mode */
val |= MT_LED_CTRL_BLINK_MODE;
else /* PWM mode */
val |= MT_LED_CTRL_REPLAY;
mt76_wr(dev, MT_LED_CTRL(mphy->band_idx), val);
mt76_clear(dev, MT_LED_CTRL(mphy->band_idx), MT_LED_CTRL_KICK);
}
@LorenzoBianconi I think you missed MT_LED_CTRL_BAND (bit4) of mt7615 as well https://github.com/LorenzoBianconi/wireless-drivers-next/commit/d178262a6a97c00a6d766f9dfd3788be7ead2fa8
do we want to use led or leds? imho led makes more sense as we drive only one led at this position, so i have changed leds struct in mt76_phy (mt76.h) to "led", but need to change other occurences too, before able to test. or i change it in the mt7915_led_set_config here to first test and then we refactore it afterwards
You can use leds as his series does. This is just my local version.
I'm thinking switching blink mode to pwm mode as there's no way to turn LED off under blink mode.
ack, I agree, I tested it and it seems to be working fine (all modes).
@Frank can you please test my latest mt76-devl branch?
@Ryder: do you want to add mt7996 too?
Regards, Lorenzo
@LorenzoBianconi @frank-w Can you test this change? I think we can go with / set PWM mode / for all scenario and get rid off all "blink settings" ( that is, drop if (delay_on/ delay_off) check )
define MT_LED_STATUS_0(_n) MT_LED_PHYS(0x20 + ((_n) * 8))
define MT_LED_STATUS_1(_n) MT_LED_PHYS(0x24 + ((_n) * 8))
define MT_LED_STATUS_OFF GENMASK(31, 24)
define MT_LED_STATUS_ON GENMASK(23, 16)
define MT_LED_STATUS_DURATION GENMASK(15, 0)
static void mt7915_led_set_config(struct led_classdev led_cdev, u8 delay_on, u8 delay_off) { struct mt7915_dev dev; struct mt76_phy *mphy; u32 val;
mphy = container_of(led_cdev, struct mt76_phy, led.cdev); dev = container_of(mphy, struct mt7915_dev, mphy);
/ select TX blink mode, 2: only data frames / if (delay_on && (delay_off != 0xff)) mt76_rmw_field(dev, MT_TMAC_TCR0(mphy->band_idx), MT_TMAC_TCR0_TX_BLINK, 2);
/ enable LED / mt76_wr(dev, MT_LED_EN(mphy->band_idx), 1);
if (!delay_on && delay_off == 0xff) { / set PWM mode / val = FIELD_PREP(MT_LED_STATUS_DURATION, 0xffff) | FIELD_PREP(MT_LED_STATUS_OFF, delay_off) | FIELD_PREP(MT_LED_STATUS_ON, delay_on); mt76_wr(dev, MT_LED_STATUS_0(mphy->band_idx), val); mt76_wr(dev, MT_LED_STATUS_1(mphy->band_idx), val); } else { / set LED Tx blink on/off time / val = FIELD_PREP(MT_LED_TX_BLINK_ON_MASK, delay_on) | FIELD_PREP(MT_LED_TX_BLINK_OFF_MASK, delay_off); mt76_wr(dev, MT_LED_TX_BLINK(mphy->band_idx), val); }
/ control LED / val = MT_LED_CTRL_KICK; if (mphy->led.al) val |= MT_LED_CTRL_POLARITY;
if (delay_on && (delay_off != 0xff)) val |= MT_LED_CTRL_BLINK_MODE;
mt76_wr(dev, MT_LED_CTRL(mphy->band_idx), val); mt76_clear(dev, MT_LED_CTRL(mphy->band_idx), MT_LED_CTRL_KICK); }
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
-- UNIX is Sexy: who | grep -i blonde | talk; cd ~; wine; talk; touch; unzip; touch; strip; gasp; finger; gasp; mount; fsck; more; yes; gasp; umount; make clean; sleep
i have added ryders patch directly, everytime i use your branch i need to many other patches to get my board itself working again and there is no simple rebase possible.
i have pushed my current state (last change not yet tested, but compiled and on card - ready to test when i'm finished wih work)
https://github.com/frank-w/BPI-R2-4.14/commits/6.1-r3-mt76devel2
if you have not added other changes we should have same state in mt76
also splitted out mt7996 changes so that i can apply changes to 6.1 (where this chip is not there yet)
Il giorno mer 7 dic 2022 alle ore 10:42 Frank Wunderlich @.***> ha scritto:
i have added ryders patch directly, everytime i use your branch i need to many other patches to get my board itself working again and there is no simple rebase possible.
i have pushed my current state (last change not yet tested, but compiled and on card - ready to test when i'm finished wih work)
https://github.com/frank-w/BPI-R2-4.14/commits/6.1-r3-mt76devel2
if you have not added other changes we should have same state in mt76
actually we can get rid of tx blink mode and just rely on pwm mode. Can you please try this version? It works fine for me.
We just need to set active low in dts (but this is not related to the patch).
Regards, Lorenzo
also splitted out mt7996 changes so that i can apply changes to 6.1 (where this chip is not there yet)
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
-- UNIX is Sexy: who | grep -i blonde | talk; cd ~; wine; talk; touch; unzip; touch; strip; gasp; finger; gasp; mount; fsck; more; yes; gasp; umount; make clean; sleep
I'm thinking switching blink mode to pwm mode as there's no way to turn LED off under blink mode. ack, I agree, I tested it and it seems to be working fine (all modes). @frank can you please test my latest mt76-devl branch? @ryder: do you want to add mt7996 too? Regards, Lorenzo
I am not the frank you're looking for
@LorenzoBianconi can you point me to necessary dts-changes? in my dts i have only a group defined which is handled by pinctrl driver
wf_led_pins: wf-led-pins {
mux {
function = "led";
groups = "wifi_led";
};
};
made again rebase with my patches on your last state
https://github.com/frank-w/BPI-R2-4.14/commits/6.1-r3-mt76devel3
my dts is arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts there
@LorenzoBianconi can you point me to necessary dts-changes? in my dts i have only a group defined which is handled by pinctrl driver
wf_led_pins: wf-led-pins { mux { function = "led"; groups = "wifi_led"; }; };
made again rebase with my patches on your last state
does it work properly?
https://github.com/frank-w/BPI-R2-4.14/commits/6.1-r3-mt76devel3
my dts is arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts there
I think you would need to add something like in mt7986a-bananapi-bpi-r3.dts
`
&wmac { ...
led {
led-active-low;
};
}; `
but you can even enable it through debugfs.. echo 1 > /sys/kernel/debug/ieee80211/phy0/mt76/led_active_low
i see leds blinking, but they are not on by starting interface which i guess came from not low_active.
sysfs does not work for me
root@bpi-r3:~# echo 1 > /sys/kernel/debug/ieee80211/phy0/mt76/led_active_low
-bash: /sys/kernel/debug/ieee80211/phy0/mt76/led_active_low: Permission denied
root@bpi-r3:~# ls /sys/kernel/debug/ieee80211/phy0/mt76/
eeprom fw_util_wm muru_stats rx-queues xmit-queues
fw_debug_bin hw-queues napi_threaded sys_recovery
fw_debug_wa implicit_txbf regidx twt_stats
fw_debug_wm led_pin regval tx_stats
fw_util_wa muru_debug rf_regval txpower_sku
@ryderlee1110 can you tell me exact syntax to define mt76leds as low-active?
on poweroff they go to static on
i see leds blinking, but they are not on by starting interface which i guess came from not low_active.
sysfs does not work for me
root@bpi-r3:~# echo 1 > /sys/kernel/debug/ieee80211/phy0/mt76/led_active_low -bash: /sys/kernel/debug/ieee80211/phy0/mt76/led_active_low: Permission denied root@bpi-r3:~# ls /sys/kernel/debug/ieee80211/phy0/mt76/ eeprom fw_util_wm muru_stats rx-queues xmit-queues fw_debug_bin hw-queues napi_threaded sys_recovery fw_debug_wa implicit_txbf regidx twt_stats fw_debug_wm led_pin regval tx_stats fw_util_wa muru_debug rf_regval txpower_sku
@ryderlee1110 can you tell me exact syntax to define mt76leds as low-active?
on poweroff they go to static on
@frank-w can you please try to add this patch? Doing so polarity is fine for me.
tried this, seems only working for 2g-led...5g is blinking but with base state off like it looks
on poweroff 2g-led stays on, and 5g off
tried this, seems only working for 2g-led...5g is blinking but with base state off like it looks
on poweroff 2g-led stays on, and 5g off
ack, right. Can you please try to add this simple patch?
thanks now it looks great...on when interface active/hostapd running, blinking on traffic of the right phy, off when interface goes down and also on poweroff :)
good job +1
"backported" (basicly remove mt7996 from first 2 patches) to 6.1:
we can close this ticket.
Any chance to add this support for Asus rt-ax53u
Any chance to add this support for Asus rt-ax53u
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
I think it is running mt7915, so it should be already supported.
Besides lan leds and power led 2 wlan leds and usb led are not supported AFAIK
Besides lan leds and power led 2 wlan leds and usb led are not supported AFAIK
— Reply to this email directly, view it on GitHub https://github.com/openwrt/mt76/issues/714#issuecomment-1345614895, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOA2COG6EKAN6RARHLSRILWMYHL5ANCNFSM6AAAAAASTMWSFM . You are receiving this because you were mentioned.Message ID: @.***>
What is the mt76 version you are running? You need to run the latest version (nbd updated the OpenWrt package Makefile yesterday I think) and enable mt76 leds afair.
Have you defined the led pinctrl in your dts?
Working Example from my r3:
https://elixir.bootlin.com/linux/v6.0.11/source/drivers/pinctrl/mediatek/pinctrl-mt7986.c#L749
https://elixir.bootlin.com/linux/v6.0.11/source/drivers/pinctrl/mediatek/pinctrl-mt7986.c#L641
I'm on SNAPSHOT r21438-8327e0fb72, which files shoud I change to make it work after install? is this that file: kmod-mt7915e | 5.10.156+2022-12-09-7fae1de1-5
Besides lan leds and power led 2 wlan leds and usb led are not supported AFAIK
All leds supported https://github.com/openwrt/openwrt/pull/10400 except two WiFi leds.
Have you got it working for your device? Have not found technical information which Wifi chip is used on this device.
Btw. you have to enable mac80211_leds too.
AX53U has an MT7915e chip. This was the change required: https://github.com/openwrt/openwrt/issues/11068#issuecomment-1358143040
Hi,
i have a mt7986a board (Bananapi-R3) which has 2 wifi-phys (2g4,5g). and leds connected to the responding pins
shematic: https://drive.google.com/file/d/1mxKb8CBbnzfNSd_4esmcX_NovxaXjEb8/view
lower part of first page...WF2G_LED (GPIO1) / WF5G_LED (GPIO2)
both phys are registered, but only 1 led is visible in sysfs (mt76_phy0). this can be set to on, but not to off (brightness 0)
init: https://elixir.bootlin.com/linux/v6.0.11/source/drivers/net/wireless/mediatek/mt76/mt7915/init.c#L1099 init seems to be done only for phy 0 (tried to replace 0 by dev->phy.band_idx in mt7915_led_set_config) https://elixir.bootlin.com/linux/v6.0.11/source/drivers/net/wireless/mediatek/mt76/mt7915/init.c#L207
and added some debug-prints, but it seems the function is not called at all :(
one problem (not for the missing missing call, but multi-led-support itself) seems to be data-structure allow only 1 led https://elixir.bootlin.com/linux/v6.0.11/source/drivers/net/wireless/mediatek/mt76/mt76.h#L786
led initialization itself (which creates the sysfs entry i see) seems to happen in mac80211.c mt76_led_init...but of course only for 1 led.
maybe you can help here to drive multiple leds, so i can see which phy is active. when should led lighten up? in normal setup (both phy in AP-Mode with hostapd running) does not bring the led(s) up (maybe traffic related? maybe additional options needed?). tried generating some traffic (downloading file without antennas ~160kbit/s) over 2g interface, but no led blinks (maybe needs a specific throughput?)
also tried to set gpio manually and got this
because i have mapped the gpio already in my dts...but how to use it if mt76 driver does not take care of it?
https://github.com/frank-w/BPI-R2-4.14/blob/6.1-r3/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts#L347 https://elixir.bootlin.com/linux/v6.0.11/source/drivers/pinctrl/mediatek/pinctrl-mt7986.c#L749 https://elixir.bootlin.com/linux/v6.0.11/source/drivers/pinctrl/mediatek/pinctrl-mt7986.c#L428
regards Frank