diff mbox

[LEDE-DEV] apm821xx: fix USB LED trigger for WNDR4700

Message ID 20161022092235.5228-1-zajec5@gmail.com
State Superseded
Delegated to: Rafał Miłecki
Headers show

Commit Message

Rafał Miłecki Oct. 22, 2016, 9:22 a.m. UTC
From: Rafał Miłecki <rafal@milecki.pl>

The old usbdev trigger never supported assigning more than 1 USB port.
This code we got was never working as expected. Switch to usbport to
have LED working with both ports.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
 target/linux/apm821xx/base-files/etc/board.d/01_leds | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Christian Lamparter Oct. 22, 2016, 4:10 p.m. UTC | #1
Hello,

On Saturday, October 22, 2016 11:22:35 AM CEST Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal@milecki.pl>
> 
> The old usbdev trigger never supported assigning more than 1 USB port.
> This code we got was never working as expected. Switch to usbport to
> have LED working with both ports.
> 
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>

I was testing this on the wndr4700.

# cat /etc/config/system
config led 'led_usb3'
        option name 'USB3'
        option sysfs 'wndr4700:blue:usb'
        option trigger 'usbport'
        list port 'usb2-port1'
        list port 'usb3-port1'
---

However the LED only lights up if a device (in my case two
usb-sticks one 3.0 and one 2.0) is connected on port 
usb3-port1. No LED activity for usb2-port1 at first.

The next step was to look into the port triggers
# ls -al /sys/class/leds/wndr4700\:blue\:usb/ports/
usb1-port1  usb2-port1  usb2-port2  usb3-port1  usb3-port2

# cat /sys/class/leds/wndr4700\:blue\:usb/ports/*
0
1
0
1
0
---
The triggers are set for usb2-port1 and usb3-port1 but not for any of
the port2. I had to enable the usb2-port2 and usb3-port2 to get it
working. Is there a way to specify sth like "usb2-port[2-Adresslimit]"
and the same for usb3-port?

Regards,
Christian

---

# lsusb -t
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 5000M
    |__ Port 2: Dev 3, If 0, Class=Mass Storage, Driver=usb-storage, 5000M
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 480M
    |__ Port 1: Dev 4, If 0, Class=Mass Storage, Driver=usb-storage, 480M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=dwc2/1p, 480M
    |__ Port 1: Dev 2, If 0, Class=Mass Storage, Driver=usb-storage, 480M


cat /sys/kernel/debug/usb/devices

T:  Bus=03 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=5000 MxCh= 2
B:  Alloc=  0/800 us ( 0%), #Int=  0, #Iso=  0
D:  Ver= 3.00 Cls=09(hub  ) Sub=00 Prot=03 MxPS= 9 #Cfgs=  1
P:  Vendor=1d6b ProdID=0003 Rev= 4.04
S:  Manufacturer=Linux 4.4.26 xhci-hcd
S:  Product=xHCI Host Controller
S:  SerialNumber=0000:45:00.0
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   4 Ivl=256ms

T:  Bus=03 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=5000 MxCh= 0
D:  Ver= 3.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 9 #Cfgs=  1
P:  Vendor=0bb4 ProdID=2910 Rev= 1.00
S:  Manufacturer=Intenso
S:  Product=Slim Line
S:  SerialNumber=0710562A29A29647
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=504mA
I:* If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
E:  Ad=81(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms

T:  Bus=02 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480  MxCh= 2
B:  Alloc=  0/800 us ( 0%), #Int=  0, #Iso=  0
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=1d6b ProdID=0002 Rev= 4.04
S:  Manufacturer=Linux 4.4.26 xhci-hcd
S:  Product=xHCI Host Controller
S:  SerialNumber=0000:45:00.0
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   4 Ivl=256ms

T:  Bus=02 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#=  3 Spd=480  MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=090c ProdID=1000 Rev=11.00
S:  Manufacturer=SMI Corporation
S:  Product=USB DISK
S:  SerialNumber=AA04012900007610
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA
I:* If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=31875us

T:  Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480  MxCh= 1
B:  Alloc=  0/800 us ( 0%), #Int=  0, #Iso=  0
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=1d6b ProdID=0002 Rev= 4.04
S:  Manufacturer=Linux 4.4.26 dwc2_hsotg
S:  Product=DWC OTG Controller
S:  SerialNumber=4bff80000.usbotg
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   4 Ivl=256ms

T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=480  MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=05e3 ProdID=0723 Rev=94.54
S:  Manufacturer=Generic
S:  Product=USB Storage
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=500mA
I:* If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
Christian Lamparter Oct. 24, 2016, 5:17 p.m. UTC | #2
I forgot to mention the builtin sdcard reader in the original post.

On Saturday, October 22, 2016 6:10:52 PM CEST Christian Lamparter wrote:
> Hello,
> 
> On Saturday, October 22, 2016 11:22:35 AM CEST Rafał Miłecki wrote:
> > From: Rafał Miłecki <rafal@milecki.pl>
> > 
> > The old usbdev trigger never supported assigning more than 1 USB port.
> > This code we got was never working as expected. Switch to usbport to
> > have LED working with both ports.
> > 
> > Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
> 
> I was testing this on the wndr4700.
> 
> # cat /etc/config/system
> config led 'led_usb3'
>         option name 'USB3'
>         option sysfs 'wndr4700:blue:usb'
>         option trigger 'usbport'
>         list port 'usb2-port1'
>         list port 'usb3-port1'
Note: usb1-port1 is not used there. The usb1 "should always"
be controlled by the dwc2-usb host and not included in this
list. This is because the sd-card reader (the wndr4700 has
one that's user accessible on the right hand side) is wired
directly to it.

Regards,
Christian

[...]

> # lsusb -t
> /:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 5000M
>     |__ Port 2: Dev 3, If 0, Class=Mass Storage, Driver=usb-storage, 5000M
> /:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 480M
>     |__ Port 1: Dev 4, If 0, Class=Mass Storage, Driver=usb-storage, 480M

(ignore the following built-in sd-card reader on the dwc2 controller)
> /:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=dwc2/1p, 480M
>     |__ Port 1: Dev 2, If 0, Class=Mass Storage, Driver=usb-storage, 480M
> 
> 
> cat /sys/kernel/debug/usb/devices
> 
> T:  Bus=03 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=5000 MxCh= 2
> B:  Alloc=  0/800 us ( 0%), #Int=  0, #Iso=  0
> D:  Ver= 3.00 Cls=09(hub  ) Sub=00 Prot=03 MxPS= 9 #Cfgs=  1
> P:  Vendor=1d6b ProdID=0003 Rev= 4.04
> S:  Manufacturer=Linux 4.4.26 xhci-hcd
> S:  Product=xHCI Host Controller
> S:  SerialNumber=0000:45:00.0
> C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
> I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
> E:  Ad=81(I) Atr=03(Int.) MxPS=   4 Ivl=256ms
> 
> T:  Bus=03 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=5000 MxCh= 0
> D:  Ver= 3.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 9 #Cfgs=  1
> P:  Vendor=0bb4 ProdID=2910 Rev= 1.00
> S:  Manufacturer=Intenso
> S:  Product=Slim Line
> S:  SerialNumber=0710562A29A29647
> C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=504mA
> I:* If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
> E:  Ad=81(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
> E:  Ad=02(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
> 
> T:  Bus=02 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480  MxCh= 2
> B:  Alloc=  0/800 us ( 0%), #Int=  0, #Iso=  0
> D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
> P:  Vendor=1d6b ProdID=0002 Rev= 4.04
> S:  Manufacturer=Linux 4.4.26 xhci-hcd
> S:  Product=xHCI Host Controller
> S:  SerialNumber=0000:45:00.0
> C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
> I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
> E:  Ad=81(I) Atr=03(Int.) MxPS=   4 Ivl=256ms
> 
> T:  Bus=02 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#=  3 Spd=480  MxCh= 0
> D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
> P:  Vendor=090c ProdID=1000 Rev=11.00
> S:  Manufacturer=SMI Corporation
> S:  Product=USB DISK
> S:  SerialNumber=AA04012900007610
> C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA
> I:* If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
> E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
> E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=31875us

(the dwc2 controller)
> T:  Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480  MxCh= 1
> B:  Alloc=  0/800 us ( 0%), #Int=  0, #Iso=  0
> D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
> P:  Vendor=1d6b ProdID=0002 Rev= 4.04
> S:  Manufacturer=Linux 4.4.26 dwc2_hsotg
> S:  Product=DWC OTG Controller
> S:  SerialNumber=4bff80000.usbotg
> C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
> I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
> E:  Ad=81(I) Atr=03(Int.) MxPS=   4 Ivl=256ms

(This is the SD-Card reader - it's a GL827L SD/MMC/MS Flash Card Reader
and uses usb-storage class driver)
> T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=480  MxCh= 0
> D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
> P:  Vendor=05e3 ProdID=0723 Rev=94.54
> S:  Manufacturer=Generic
> S:  Product=USB Storage
> C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=500mA
> I:* If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
> E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
> E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
Rafał Miłecki Oct. 28, 2016, 10:35 a.m. UTC | #3
On 22 October 2016 at 18:10, Christian Lamparter
<chunkeey@googlemail.com> wrote:
> On Saturday, October 22, 2016 11:22:35 AM CEST Rafał Miłecki wrote:
>> From: Rafał Miłecki <rafal@milecki.pl>
>>
>> The old usbdev trigger never supported assigning more than 1 USB port.
>> This code we got was never working as expected. Switch to usbport to
>> have LED working with both ports.
>>
>> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
>
> I was testing this on the wndr4700.
>
> # cat /etc/config/system
> config led 'led_usb3'
>         option name 'USB3'
>         option sysfs 'wndr4700:blue:usb'
>         option trigger 'usbport'
>         list port 'usb2-port1'
>         list port 'usb3-port1'
> ---
>
> However the LED only lights up if a device (in my case two
> usb-sticks one 3.0 and one 2.0) is connected on port
> usb3-port1. No LED activity for usb2-port1 at first.
>
> The next step was to look into the port triggers
> # ls -al /sys/class/leds/wndr4700\:blue\:usb/ports/
> usb1-port1  usb2-port1  usb2-port2  usb3-port1  usb3-port2
>
> # cat /sys/class/leds/wndr4700\:blue\:usb/ports/*
> 0
> 1
> 0
> 1
> 0
> ---
> The triggers are set for usb2-port1 and usb3-port1 but not for any of
> the port2. I had to enable the usb2-port2 and usb3-port2 to get it
> working. Is there a way to specify sth like "usb2-port[2-Adresslimit]"
> and the same for usb3-port?

Thanks for the research, I incorrectly assumed info in 01_leds is
correct and complete. There isn't a way to specify range of ports.
diff mbox

Patch

diff --git a/target/linux/apm821xx/base-files/etc/board.d/01_leds b/target/linux/apm821xx/base-files/etc/board.d/01_leds
index a1eeb8f..6566b7f 100755
--- a/target/linux/apm821xx/base-files/etc/board.d/01_leds
+++ b/target/linux/apm821xx/base-files/etc/board.d/01_leds
@@ -23,8 +23,7 @@  mbl)
 wndr4700)
 	ucidef_set_led_ide "sata" "SATA" "wndr4700:green:hd"
 	ucidef_set_led_netdev "wan" "WAN (green)" "wndr4700:green:wan" "eth0.2"
-	ucidef_set_led_usbdev "usb3-1" "USB3-1" "wndr4700:blue:usb" "2-1"
-	ucidef_set_led_usbdev "usb3-2" "USB3-2" "wndr4700:blue:usb" "3-1"
+	ucidef_set_led_usbport "usb3" "USB3" "wndr4700:blue:usb" "usb2-port1" "usb3-port1"
 	ucidef_set_led_wlan "wlan2g" "WLAN2G" "wndr4700:blue:wlan" "phy0tpt"
 	ucidef_set_led_wlan "wlan5g" "WLAN5G" "wndr4700:blue:wlan" "phy1tpt"
 	;;