The OTG profile could not see USB devices in host mode. On a board with a UVC webcam on the USB tail, `lsusb` showed only the two root hubs, while the same board running a plain lite image enumerated the webcam normally. The controller was in the host role and the host controller was running -- mode file "host", xhci-hcd bound, USBCMD 0x5, PORTSC1 port-power set -- and the port still never reported a connect (PORTSC1 0x00000280, CCS clear). dr_mode = "otg" makes dwc3_core_init() program GCTL.PRTCAPDIR = OTG(3), and dwc3_core_init_mode() registers xhci-hcd on top of that. This 4.9 dwc3 has no working OTG role-detection block, so xHCI probes, resets the controller and brings up its root hubs while the core is in a role it cannot drive. The port is then dead for the life of that probe. S72usbmode's `usb-mode host` did not repair it and could not: writing the debugfs mode file reaches dwc3_set_mode(), which flips GCTL.PRTCAPDIR and nothing else, leaving the already-probed xHCI with the port state machine it built in OTG. It also skipped the bind, because xhci-hcd was already bound. Fix it where the ordering is: patch dwc3_core_init() to program PRTCAPDIR = HOST for the OTG case, so xHCI probes into a role the core can drive. dwc3_gadget_init() only registers a UDC and does not care, and `usb-mode device` re-aims the controller itself when it takes the port. usb-mode's host path also learns to re-probe an xHCI that was bound in some other role, which is what makes a newer rootfs recover on an older kernel.
35 lines
967 B
Bash
Executable File
35 lines
967 B
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# Force a concrete USB role at boot.
|
|
#
|
|
# The device tree sets dr_mode = "otg" so that dwc3 registers both an xHCI host
|
|
# and a UDC, which is what makes runtime role switching possible. The role
|
|
# itself is settled in the kernel: all-patches 0018 programs
|
|
# GCTL.PRTCAPDIR = HOST before the xHCI host is registered, because a host that
|
|
# probes while the core is still in OTG(3) comes up unable to drive the port --
|
|
# it runs, powers the port, and never reports a connect. So the board boots as
|
|
# a host, and this script exists to apply a persisted "device" choice on top.
|
|
#
|
|
# Runs after S70vendor so the vendor modules are up first.
|
|
|
|
case "$1" in
|
|
start)
|
|
mode=host
|
|
[ -r /etc/usbmode ] && read -r mode < /etc/usbmode
|
|
case "$mode" in
|
|
host|device) ;;
|
|
*) mode=host ;;
|
|
esac
|
|
echo "Setting USB role to $mode..."
|
|
/usr/bin/usb-mode "$mode" || echo "usb-mode $mode failed"
|
|
;;
|
|
|
|
stop)
|
|
;;
|
|
|
|
*)
|
|
echo "Usage: $0 {start|stop}"
|
|
exit 1
|
|
;;
|
|
esac
|