Hi Roger,
Am 10.09.2018 um 09:39 schrieb Roger Quadros rogerq@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...
root@letux:~# cat /sys/kernel/debug/4a030000.dwc3/link_state /sys/kernel/debug/4a030000.dwc3/mode SS.Disabled otg root@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@letux:~# cat /sys/bus/platform/devices/musb-hdrc.0.auto/mode b_peripheral root@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.
BR, Nikolaus