Modify

Opened 4 years ago

Last modified 2 years ago

#17062 reopened defect

LEDs mapped to wrong GPIOs on WRT54GL

Reported by: anonymous Owned by: developers
Priority: normal Milestone: Chaos Calmer 15.05
Component: kernel Version: Trunk
Keywords: wrt54g wrt54gl gpio led leds Cc:

Description

Remember Ticket #16991 "LEDs mapped to wrong GPIOs on WRTSL54GS"? Same stuff again, but this time with a WRT54GL v1.1

In the mentioned ticket I thought it is weird that (before the fix) the WRTSL54GS had the GPIO layout of the WRT54G(S). - I discovered that the entries are indeed switched with each other.
Since WRTSL54GS was already fixed in r41516 , now only the WRT54G* series is affected.

[LED name] - > [Actual toggled LED]
bcm47xx:unk:power - > Power LED (correct)
bcm47xx:unk:dmz -> WLAN LED
bcm47xx:orange:wps -> DMZ LED
bcm47xx:white:wps -> <Nothing>

Story time:
So I flashed my old WRT54GL with a recent trunk version and discovered the LEDs were wrong too (see table above).
I checked "target/linux/brcm47xx/patches-3.10/140-MIPS-BCM47XX-add-button-and-led-configuration-for-so.patch" once again and saw my suspicion confirmed: "wrt54gsv1" and "wrtsl54gs" were both added in this patch, but the GPIOs are switched with each other.
In "target/linux/brcm47xx/patches-3.10/144-MIPS-BCM47XX-Distinguish-WRT54G-series-devices-by-bo.patch", "wrt54gsv1" was renamed to "wrt54g_generic" and the wrong GPIO layout is used for almost all WRT54G* devices since then.

Correct GPIOs for WRT54G*: http://wiki.openwrt.org/oldwiki/port.gpio

Attachments (1)

wrt54g-fix-leds.patch (1.0 KB) - added by anonymous 4 years ago.

Download all attachments as: .zip

Change History (8)

Changed 4 years ago by anonymous

comment:1 Changed 4 years ago by anonymous

Maybe the following patch can be reverted too, because it has the same GPIO layout as the other WRT54G devices - BUT it doesn't define the two SES/WPS leds? I don't know what's up with that.
https://dev.openwrt.org/browser/trunk/target/linux/brcm47xx/patches-3.10/145-MIPS-BCM47XX-Fix-LEDs-on-WRT54GS-V1.0.patch?rev=41486

comment:2 Changed 4 years ago by Zajec

Huh, this report looks really messy for me. Please simply:
1) Provide output of "nvram show | grep board"
2) Confirm that the following config is correct for your device:

BCM47XX_GPIO_LED(0, "green", "wlan", 1, LEDS_GPIO_DEFSTATE_OFF),
BCM47XX_GPIO_LED(1, "green", "power", 0, LEDS_GPIO_DEFSTATE_ON),
BCM47XX_GPIO_LED(2, "white", "wps", 1, LEDS_GPIO_DEFSTATE_OFF),
BCM47XX_GPIO_LED(3, "orange", "wps", 1, LEDS_GPIO_DEFSTATE_OFF),
BCM47XX_GPIO_LED(7, "green", "dmz", 1, LEDS_GPIO_DEFSTATE_OFF),

comment:3 Changed 4 years ago by anonymous

Sorry, I try to do it better next time.

1)

root@OpenWrt:/# nvram show | grep board
boardnum=42
boardflags=0x2558
boardtype=0x0467
boardrev=0x10
boardflags2=0
root@OpenWrt:/# 

2)
That config is correct for my device. (Right now, I re-checked every single GPIO.)

comment:4 Changed 4 years ago by Zajec

Fixed in r41666. Thanks for your report.

comment:5 Changed 4 years ago by nbd

  • Resolution set to fixed
  • Status changed from new to closed

comment:6 Changed 2 years ago by pesco

  • Resolution fixed deleted
  • Status changed from closed to reopened

The fix above is correct for boardtype 0x0467; however, the issue applies to other WRT boards as well. I have a WRT54G v2.2 with boardtype 0x0708 which doesn't work with the pinout currently in the kernel. It should probably use the same as 0x0467 which I believe is actually the "generic" layout.

(I haven't been able to build a custom image to test, yet, but wanted to get this post out anyway.)

Appearently the GPIO definitions for WRT54G vs WRTSL54GS were confused when added to the kernel. This is simply the wrong way around:

http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=96c10de32fde6c50e4f9e5c1f027e670073ea086

diff --git a/arch/mips/bcm47xx/leds.c b/arch/mips/bcm47xx/leds.c
index 647d155..d741175 100644
--- a/arch/mips/bcm47xx/leds.c
+++ b/arch/mips/bcm47xx/leds.c
@@ -292,6 +292,21 @@ bcm47xx_leds_linksys_wrt310nv1[] __initconst = {
 };
 
 static const struct gpio_led
+bcm47xx_leds_linksys_wrt54gsv1[] __initconst = {
+	BCM47XX_GPIO_LED(0, "unk", "dmz", 1, LEDS_GPIO_DEFSTATE_OFF),
+	BCM47XX_GPIO_LED(1, "unk", "power", 0, LEDS_GPIO_DEFSTATE_ON),
+	BCM47XX_GPIO_LED(5, "white", "wps", 1, LEDS_GPIO_DEFSTATE_OFF),
+	BCM47XX_GPIO_LED(7, "orange", "wps", 1, LEDS_GPIO_DEFSTATE_OFF),
+};
+
+ [...]
+
+static const struct gpio_led
 bcm47xx_leds_linksys_wrt610nv1[] __initconst = {
 	BCM47XX_GPIO_LED(0, "unk", "usb",  1, LEDS_GPIO_DEFSTATE_OFF),
 	BCM47XX_GPIO_LED(1, "unk", "power",  0, LEDS_GPIO_DEFSTATE_OFF),
@@ -308,6 +323,15 @@ bcm47xx_leds_linksys_wrt610nv2[] __initconst = {
 	BCM47XX_GPIO_LED(7, "unk", "usb", 0, LEDS_GPIO_DEFSTATE_OFF),
 };
 
+static const struct gpio_led
+bcm47xx_leds_linksys_wrtsl54gs[] __initconst = {
+	BCM47XX_GPIO_LED(0, "unk", "wlan", 1, LEDS_GPIO_DEFSTATE_OFF),
+	BCM47XX_GPIO_LED(1, "unk", "power", 0, LEDS_GPIO_DEFSTATE_ON),
+	BCM47XX_GPIO_LED(2, "white", "wps", 1, LEDS_GPIO_DEFSTATE_OFF),
+	BCM47XX_GPIO_LED(3, "orange", "wps", 1, LEDS_GPIO_DEFSTATE_OFF),
+	BCM47XX_GPIO_LED(7, "unk", "dmz", 1, LEDS_GPIO_DEFSTATE_OFF),
+};
+
 /* Motorola */

See also the original code of broadcom-diag:

http://git.openwrt.org/?p=openwrt.git;a=commitdiff;h=1e1e587817521fc188f20de4e674e02a7ebf6887

       [WRT54G] = {
               .name           = "Linksys WRT54G/GS/GL",
               .buttons        = {
                       { .name = "reset",      .gpio = 1 << 6 },
                       { .name = "ses",        .gpio = 1 << 4 },
               },
               .leds           = {
                       { .name = "power",      .gpio = 1 << 1, .polarity = NORMAL },
                       { .name = "dmz",        .gpio = 1 << 7, .polarity = REVERSE },
                       { .name = "ses_white",  .gpio = 1 << 2, .polarity = REVERSE },
                       { .name = "ses_orange", .gpio = 1 << 3, .polarity = REVERSE },
                       { .name = "wlan",       .gpio = 1 << 0, .polarity = REVERSE },
               },
       },

comment:7 Changed 2 years ago by pesco

PS: Also of interest might be the mailing list thread that led to the inclusion of the boardtype 0x0101 (WRT54GS) case in https://dev.openwrt.org/browser/trunk/target/linux/brcm47xx/patches-3.10/145-MIPS-BCM47XX-Fix-LEDs-on-WRT54GS-V1.0.patch?rev=41486 .

/* Verified on: WRT54GS V1.0 */ 
static const struct gpio_led 
bcm47xx_leds_linksys_wrt54g_type_0101[] __initconst = { 
        BCM47XX_GPIO_LED(0, "green", "wlan", 0, LEDS_GPIO_DEFSTATE_OFF), 
        BCM47XX_GPIO_LED(1, "green", "power", 0, LEDS_GPIO_DEFSTATE_ON), 
        BCM47XX_GPIO_LED(7, "green", "dmz", 1, LEDS_GPIO_DEFSTATE_OFF), 
}; 

Note that this matches the original (broadcom-diag) mapping except it is missing the SES LED lines on GPIO 2 and 3. It seems these were left out for fear of conflicting with some weird nvram settings of the person reporting the bug in that case.

Quote (reporter):

The ADM pins also might be wrong (despite definitions in the nvram
that point to those pins). My switch gets detected but when I do
"swconfig switch0 show" my system reboots.

Note:
[ 12.580000] gpio-keys gpio-keys.0: unable to claim gpio 6, err=-16
[ 12.660000] gpio-keys: probe of gpio-keys.0 failed with error -16
[ 12.900000] leds-gpio: probe of leds-gpio failed with error -16

Quote (developer):

This is because __gpiod_request returned -EBUSY.

Your nvram has following entries:
gpio6=adm_rc
gpio5=adm_eedi
gpio3=adm_eesk
gpio2=adm_eecs

All of the above GPIOs are reserved by adm6996. It means registering
LEDs failed (because GPIOs 2 and 3 were already in use) and
registering buttons failed (because GPIO 6 was already in use).

https://lists.openwrt.org/pipermail/openwrt-devel/2014-June/025865.html

Add Comment

Modify Ticket

Action
as reopened .
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.