investigating usb1 / usb2 power management
Feature: https://source.puri.sm/Librem5/use-cases/issues/75 Related: https://source.puri.sm/Librem5/linux-next/issues/168
so we have the otg1 and otg2 PD and runtime PM at least implemented in dwc3, but disabled (always on) by default by the driver.
if I, in dts, wire up the otg1 PD to the 0.9V "ldo6" regulator and otg2 to the 3.3V ldo7 one (not yet sure if that makes sense, but read on with this assumption in mind): That's the change: martin.kepplinger/linux-next@c6c1c7df
otg1:
/sys/module/dwc3/drivers/platform:dwc3/38100000.usb/power/control
otg2:
/sys/module/dwc3/drivers/platform:dwc3/38200000.usb/power/control
both are set to "on" by dwc3, as mentioned, disabling runtime PM by default. we can enable it in sysfs:
now setting otg1 to "auto" enables the dwc3 runtime PM and really powers down (looking at /sys/kernel/debug/pm_genpd/pm_genpd_summary ) when nothing is connected to USB (or if currently connected, powers off 2 seconds after disconnecting USB):
usb-otg2 on
/devices/platform/soc@0/38200000.usb active
usb-otg1 off-0
/devices/platform/soc@0/38100000.usb suspended
From that time on, tough, 1st: we have no display anymore (ok, so usable when screen is blanked); that's turned off too by ldo6. and 2nd: plugging in a USB cable is not detected anymore.
... until setting otg1 to "on" again (in sysfs). Everythings back to normal then.
BUT: after a few more seconds after otg1 (only) gets disabled (runtime pm in dwc3, the host controller interface dies, and never comes back):
[ 102.335589] xhci-hcd xhci-hcd.4.auto: xHCI host controller not responding, assume dead
[ 102.343553] xhci-hcd xhci-hcd.4.auto: HC died; cleaning up
which means we loose the WWAN modem (at least). modprobe xhci_plat_hcd
brings it back.
BUT: when doing modprobe -r xhci_plat_hcd
before enabling runtime PM, both otg1 and otg2 get suspended:
usb-otg2 off-0
/devices/platform/soc@0/38200000.usb suspended
usb-otg1 off-0
/devices/platform/soc@0/38100000.usb suspended
summary / TL;DR
Currently, we could use it when the screen is off and WWAN is disabled (what else is on the "internal" USB?) with the downside that a USB data cable connected while screen off, will not be detected: This addition to power_key.py works "reliably" for me, of course it shuts down WWAN on screen-blank too (I don't bother reading the WWAN key state): librem5-devkit-tools!129 (e3170385)
What comes to your mind?
thanks, martin