[Letux-kernel] Minor annoyances with USB(3) port on Pyra

H. Nikolaus Schaller hns at goldelico.com
Mon Sep 17 10:24:17 CEST 2018


Hi Roger,

> Am 17.09.2018 um 10:01 schrieb Roger Quadros <rogerq at ti.com>:
> 
> Hi Nikolaus,
> 
> On 17/09/18 10:25, H. Nikolaus Schaller wrote:
>> Hi Roger,
>> 
>>> Am 10.09.2018 um 09:39 schrieb Roger Quadros <rogerq at ti.com>:
>>> 
>>>> 
>>>> BTW: is there a /sys node to read the OTG state?
>>> 
>>> The sys node should be something like
>>> /sys/kernel/debug/<addr>.usb
>>> 
>>> However it doesn't have anything to show the current role.
>>> It has a "mode" file which shows the otg mode and allows you to force "host" or "device" modes
>>> if initial mode was "otg".
>> 
>> I have played a little around but configuring and mounting debugfs just to provide
>> some information to the GUI seems to be the wrong way to me...
> 
> I too agree that it is wrong. debugfs is only meant for debugging.
> 
>> 
>> root at letux:~# cat /sys/kernel/debug/4a030000.dwc3/link_state /sys/kernel/debug/4a030000.dwc3/mode 
>> SS.Disabled
>> otg
>> root at letux:~# 
>> 
>>> 
>>> If you need something to show the current role, it needs to be added to debugfs.c
>>> by exporting dwc->current_otg_role if (dwc->dr_mode == USB_DR_MODE_OTG)
>> 
>> On OMAP3 systems with twl4030 I can simply read
>> 
>> /sys/bus/platform/devices/musb-hdrc.0.auto/mode
>> 
>> and it tells all about the interface state: if it is in a or b mode, peripheral, host or idle.
>> and I can translate that into different GUI icons.
>> 
>> root at letux:~# cat /sys/bus/platform/devices/musb-hdrc.0.auto/mode
>> b_peripheral
>> root at letux:~# 
>> 
>> So maybe the debugfs mode should be moved to non-debugfs and report the
>> same as musb-hdrc.0.auto/mode? Or a new sysattr should be added to
>> 
>> /sys/class/udc/4a030000.dwc3/
>> 
>> But strangely, this symlink and /sys/devices/platform/44000000.ocp/4a020000.omap_dwc3/4a030000.dwc3/udc/4a030000.dwc3 disappear when I plug in the OTG cable. They come back on unplugging.
> 
> This is because UDC device goes away when we're in host mode.
> We need to have something in the controller device i.e. /sys/devices/platform/44000000.ocp/4a020000.omap_dwc3/4a030000.dwc3

Ah, I see:

/sys/devices/platform/44000000.ocp/4a020000.omap_dwc3/4a030000.dwc3/xhci-hcd.1.auto/uevent

root at letux:~# ls -l /sys/devices/platform/44000000.ocp/4a020000.omap_dwc3/4a030000.dwc3
total 0
lrwxrwxrwx 1 root root    0 Sep 17 07:05 driver -> ../../../../../bus/platform/drivers/dwc3
-rw-r--r-- 1 root root 4096 Sep 17 08:10 driver_override
drwxr-xr-x 3 root root    0 Sep 17 08:10 gadget
-r--r--r-- 1 root root 4096 Sep 17 08:10 modalias
lrwxrwxrwx 1 root root    0 Sep 17 08:10 of_node -> ../../../../../firmware/devicetree/base/ocp/omap_dwc3 at 4a020000/dwc3 at 4a030000
drwxr-xr-x 2 root root    0 Sep 17 08:10 power
lrwxrwxrwx 1 root root    0 Sep 17 07:05 subsystem -> ../../../../../bus/platform
drwxr-xr-x 3 root root    0 Sep 17 07:13 udc
-rw-r--r-- 1 root root 4096 Sep 17 07:05 uevent
root at letux:~# ls -l /sys/devices/platform/44000000.ocp/4a020000.omap_dwc3/4a030000.dwc3
total 0
lrwxrwxrwx 1 root root    0 Sep 17 08:10 driver -> ../../../../../bus/platform/drivers/dwc3
-rw-r--r-- 1 root root 4096 Sep 17 08:10 driver_override
-r--r--r-- 1 root root 4096 Sep 17 08:10 modalias
lrwxrwxrwx 1 root root    0 Sep 17 08:10 of_node -> ../../../../../firmware/devicetree/base/ocp/omap_dwc3 at 4a020000/dwc3 at 4a030000
-r--r--r-- 1 root root 4096 Sep 17 08:10 pools
drwxr-xr-x 2 root root    0 Sep 17 08:10 power
lrwxrwxrwx 1 root root    0 Sep 17 08:10 subsystem -> ../../../../../bus/platform
-rw-r--r-- 1 root root 4096 Sep 17 08:10 uevent
drwxr-xr-x 6 root root    0 Sep 17 08:10 xhci-hcd.1.auto
root at letux:~#

It swaps the udc vs. xhci subdirectories.

Well, this would be a simple trick to find out if otg is active but it does not directly tell if a device is connected...
So I can write a hack for our GUI based on this.

> 
> Can you please start a discussion about this in lkml with the DWC3 maintainer Felipe? Thanks.

Yes, I'll do.

BR and thanks,
Nikolaus



More information about the Letux-kernel mailing list