Nokia N900: musb is in wrong state after boot

From: Pali RohÃr
Date: Sat Jan 09 2016 - 10:16:58 EST


Hello,

when I boot 4.4.0-rc7+ kernel compiled with g_nokia into zImage on Nokia
N900 into userspace then usb gadget (g_nokia) does not work. Notebook,
connected on other side does not see any usb device... Connecting and
disconnecting cable does not change anything, still not work.

But if I run this command
$ echo peripheral > /sys/bus/platform/devices/musb-hdrc.0.auto/mode

then gadget starts working. Other side see usb device and can use it.
Also connecting and disconnecting usb cable working fine. After
connecting it again, usb device OK.

So it looks like musb is in some wrong state after boot if above command
is not called.

Any idea where is problem? In attachment is output from more musb sysfs
entries (before and after calling that command) which I think could be
useful. If you want to see more logs, let me know what.

Note that host mode on Nokia N900 does not work because of HW design.
For 2.6.28 Nokia's kernel there are special and ugly (!) patches which
enable host mode together with userspace interaction. So it does not
make sense to have other than peripheral mode enabled by default on
Nokia N900...

--
Pali RohÃr
pali.rohar@xxxxxxxxx
Nokia-N900:~# grep "" /sys/bus/platform/devices/musb-hdrc.0.auto/*
/sys/bus/platform/devices/musb-hdrc.0.auto/driver_override:(null)
/sys/bus/platform/devices/musb-hdrc.0.auto/modalias:platform:musb-hdrc
/sys/bus/platform/devices/musb-hdrc.0.auto/mode:b_idle
/sys/bus/platform/devices/musb-hdrc.0.auto/uevent:DRIVER=musb-hdrc
/sys/bus/platform/devices/musb-hdrc.0.auto/uevent:MODALIAS=platform:musb-hdrc
/sys/bus/platform/devices/musb-hdrc.0.auto/vbus:Vbus on, timeout 1100 msec
Nokia-N900:~# grep "" /sys/bus/platform/devices/musb-hdrc.0.auto/musb-hdrc.0.auto/*
/sys/bus/platform/devices/musb-hdrc.0.auto/musb-hdrc.0.auto/a_alt_hnp_support:0
/sys/bus/platform/devices/musb-hdrc.0.auto/musb-hdrc.0.auto/a_hnp_support:0
/sys/bus/platform/devices/musb-hdrc.0.auto/musb-hdrc.0.auto/b_hnp_enable:0
/sys/bus/platform/devices/musb-hdrc.0.auto/musb-hdrc.0.auto/current_speed:UNKNOWN
/sys/bus/platform/devices/musb-hdrc.0.auto/musb-hdrc.0.auto/is_a_peripheral:0
/sys/bus/platform/devices/musb-hdrc.0.auto/musb-hdrc.0.auto/is_otg:1
/sys/bus/platform/devices/musb-hdrc.0.auto/musb-hdrc.0.auto/is_selfpowered:0
/sys/bus/platform/devices/musb-hdrc.0.auto/musb-hdrc.0.auto/maximum_speed:high-speed
grep: /sys/bus/platform/devices/musb-hdrc.0.auto/musb-hdrc.0.auto/soft_connect: Permission denied
grep: /sys/bus/platform/devices/musb-hdrc.0.auto/musb-hdrc.0.auto/srp: Permission denied
/sys/bus/platform/devices/musb-hdrc.0.auto/musb-hdrc.0.auto/state:not attached
Nokia-N900:~# cat /sys/kernel/debug/musb-hdrc.0.auto/regdump
MUSB (M)HDRC Register Dump
FAddr : 00
Power : a0
Frame : 0000
Index : 00
Testmode : 00
TxMaxPp : a000
TxCSRp : 0000
RxMaxPp : 0000
RxCSR : ffff
RxCount : fffe
IntrRxE : fffe
IntrTxE : ffff
IntrUsbE : f7
DevCtl : 98
VControl : 00000000
HWVers : 0000
LinkInfo : 5c
VPLen : 3c
HS_EOF1 : 80
FS_EOF1 : 77
LS_EOF1 : 72
SOFT_RST : 00
DMA_CNTLch0 : 0000
DMA_ADDRch0 : 00000000
DMA_COUNTch0: 00000000
DMA_CNTLch1 : 0000
DMA_ADDRch1 : 00000000
DMA_COUNTch1: 00000000
DMA_CNTLch2 : 0000
DMA_ADDRch2 : 00000000
DMA_COUNTch2: 00000000
DMA_CNTLch3 : 0000
DMA_ADDRch3 : 00000000
DMA_COUNTch3: 00000000
DMA_CNTLch4 : 0000
DMA_ADDRch4 : 00000000
DMA_COUNTch4: 00000000
DMA_CNTLch5 : 0000
DMA_ADDRch5 : 00000000
DMA_COUNTch5: 00000000
DMA_CNTLch6 : 0000
DMA_ADDRch6 : 00000000
DMA_COUNTch6: 00000000
DMA_CNTLch7 : 0000
DMA_ADDRch7 : 00000000
DMA_COUNTch7: 00000000
ConfigData : 00
BabbleCtl : 00
TxFIFOsz : 00
RxFIFOsz : 00
TxFIFOadd : 0000
RxFIFOadd : 0000
EPInfo : ff
RAMInfo : 8c
Nokia-N900:~# cat /sys/kernel/debug/musb-hdrc.0.auto/softconnect
-1
Nokia-N900:~# cat /sys/kernel/debug/musb-hdrc.0.auto/testmode
Nokia-N900:~#
Nokia-N900:~#
Nokia-N900:~# echo peripheral > /sys/bus/platform/devices/musb-hdrc.0.auto/mode
Nokia-N900:~#
Nokia-N900:~#
Nokia-N900:~#
Nokia-N900:~# grep "" /sys/bus/platform/devices/musb-hdrc.0.auto/*
/sys/bus/platform/devices/musb-hdrc.0.auto/driver_override:(null)
/sys/bus/platform/devices/musb-hdrc.0.auto/modalias:platform:musb-hdrc
/sys/bus/platform/devices/musb-hdrc.0.auto/mode:b_peripheral
/sys/bus/platform/devices/musb-hdrc.0.auto/uevent:DRIVER=musb-hdrc
/sys/bus/platform/devices/musb-hdrc.0.auto/uevent:MODALIAS=platform:musb-hdrc
/sys/bus/platform/devices/musb-hdrc.0.auto/vbus:Vbus on, timeout 1100 msec
Nokia-N900:~# grep "" /sys/bus/platform/devices/musb-hdrc.0.auto/musb-hdrc.0.auto/*
/sys/bus/platform/devices/musb-hdrc.0.auto/musb-hdrc.0.auto/a_alt_hnp_support:0
/sys/bus/platform/devices/musb-hdrc.0.auto/musb-hdrc.0.auto/a_hnp_support:0
/sys/bus/platform/devices/musb-hdrc.0.auto/musb-hdrc.0.auto/b_hnp_enable:0
/sys/bus/platform/devices/musb-hdrc.0.auto/musb-hdrc.0.auto/current_speed:high-speed
/sys/bus/platform/devices/musb-hdrc.0.auto/musb-hdrc.0.auto/is_a_peripheral:0
/sys/bus/platform/devices/musb-hdrc.0.auto/musb-hdrc.0.auto/is_otg:1
/sys/bus/platform/devices/musb-hdrc.0.auto/musb-hdrc.0.auto/is_selfpowered:0
/sys/bus/platform/devices/musb-hdrc.0.auto/musb-hdrc.0.auto/maximum_speed:high-speed
grep: /sys/bus/platform/devices/musb-hdrc.0.auto/musb-hdrc.0.auto/soft_connect: Permission denied
grep: /sys/bus/platform/devices/musb-hdrc.0.auto/musb-hdrc.0.auto/srp: Permission denied
/sys/bus/platform/devices/musb-hdrc.0.auto/musb-hdrc.0.auto/state:configured
Nokia-N900:~# cat /sys/kernel/debug/musb-hdrc.0.auto/regdump
MUSB (M)HDRC Register Dump
FAddr : 1f
Power : f0
Frame : 02dd
Index : 00
Testmode : 00
TxMaxPp : f01f
TxCSRp : 0000
RxMaxPp : 0000
RxCSR : ffff
RxCount : fffe
IntrRxE : fffe
IntrTxE : ffff
IntrUsbE : f7
DevCtl : 99
VControl : 00000000
HWVers : 0000
LinkInfo : 5c
VPLen : 3c
HS_EOF1 : 80
FS_EOF1 : 77
LS_EOF1 : 72
SOFT_RST : 00
DMA_CNTLch0 : 0000
DMA_ADDRch0 : 00000000
DMA_COUNTch0: 00000000
DMA_CNTLch1 : 0000
DMA_ADDRch1 : 00000000
DMA_COUNTch1: 00000000
DMA_CNTLch2 : 0000
DMA_ADDRch2 : 00000000
DMA_COUNTch2: 00000000
DMA_CNTLch3 : 0000
DMA_ADDRch3 : 00000000
DMA_COUNTch3: 00000000
DMA_CNTLch4 : 0000
DMA_ADDRch4 : 00000000
DMA_COUNTch4: 00000000
DMA_CNTLch5 : 0000
DMA_ADDRch5 : 00000000
DMA_COUNTch5: 00000000
DMA_CNTLch6 : 0000
DMA_ADDRch6 : 00000000
DMA_COUNTch6: 00000000
DMA_CNTLch7 : 0000
DMA_ADDRch7 : 00000000
DMA_COUNTch7: 00000000
ConfigData : 00
BabbleCtl : 00
TxFIFOsz : 00
RxFIFOsz : 00
TxFIFOadd : 0000
RxFIFOadd : 0000
EPInfo : ff
RAMInfo : 8c
Nokia-N900:~# cat /sys/kernel/debug/musb-hdrc.0.auto/softconnect
-1
Nokia-N900:~# cat /sys/kernel/debug/musb-hdrc.0.auto/testmode
Nokia-N900:~#

Attachment: signature.asc
Description: This is a digitally signed message part.