On 8/12/2025 11:25 AM, Krishna Kurapati wrote:
Currently on QC targets, the conndone/disconnect events in device mode are
generated by controller when software writes to QSCRATCH registers in qcom
glue layer rather than the vbus line being routed to dwc3 core IP for it
to recognize and generate these events. We need to set UTMI_OTG_VBUS_VALID
bit of QSCRATCH_HS_PHY_CTRL register to generate a connection done event
and clear it to generate a disconnect event during cable removal or mode
switch is done
When the disconnect is not generated upon cable removal, the "connected"
flag of dwc3 is left marked as "true" and it blocks suspend routines and
for that to happen upon cable removal, the cable disconnect notification
from usb_role_switch to DWC3 core driver needs to reach DWC3 Qualcomm glue
driver for it generate the event.
Currently, the way DWC3 core and Qualcomm glue driver is designed, there
is no mechanism through which the DWC3 core can notify the Qualcomm glue
layer of any role changes which it receives from usb_role_switch. To
register these glue callbacks at probe time, for enabling core to notify
glue layer, the legacy Qualcomm driver has no way to find out when the
child driver probe was successful since it does not check for the same
during of_platform_populate.
For flattened implementation of the glue driver, register callbacks for
core to invoke and notify glue layer of role switch notifications.
Set-Role and Run_stop notifier callbacks have been added to inform glue
of changes in role and any modifications UDC might be performing on the
controller. These callbacks allow us to modify qscratch accordingly and
generate disconnect/connect events to facilitate suspend entry and proper
enumeration.
The series only allows autosuspend to be used but still relies on user
enabling it from userspace (echo auto > a600000.usb/power/control).
[...]
Hi Greg,
The first two patches of this series are Acked and are independent of
the third patch. The first two patches include glue callbacks and
suspend resume for device mode for QC SoCs. The third patch is to enable
auto-suspend for xhci plat and hence independent of dwc3 patches.
If it is fine, can you take in the first two patches and I will resend
the third one if necessary after receiving review comments from Mathias.
Regards,
Krishna,
Changes in v4:
Fixed function names in comments in core.h (Thinh).
Fixed nitpicks in dwc3-qcom mentioned by Konrad.
Link to v3:
https://lore.kernel.org/all/20250806095828.1582917-1-krishna.kurapati@xxxxxxxxxxxxxxxx/
Changes in v3:
Removal of extcon functionality has been moved out of this series.
Addressed coding style comments from Thinh.
Instead of adding notifier and enabling autosuspend for xhci, it has been
done in xhci-plat.c
Link to v2:
https://lore.kernel.org/all/20250610091357.2983085-1-krishna.kurapati@xxxxxxxxxxxxxxxx/
Changes in v2:
Rebased on top of usb-next.
Removed glue's extcon handling and made use of in-core handling.
Link to v1:
https://lore.kernel.org/all/20231017131851.8299-1-quic_kriskura@xxxxxxxxxxx/
Krishna Kurapati (3):
usb: dwc3: core: Introduce glue callbacks for flattened
implementations
usb: dwc3: qcom: Implement glue callbacks to facilitate runtime
suspend
usb: xhci: plat: Facilitate using autosuspend for xhci plat devices
drivers/usb/dwc3/core.c | 1 +
drivers/usb/dwc3/core.h | 26 ++++++++++++
drivers/usb/dwc3/drd.c | 1 +
drivers/usb/dwc3/dwc3-qcom.c | 78 +++++++++++++++++++++++++++++++-----
drivers/usb/dwc3/gadget.c | 1 +
drivers/usb/host/xhci-plat.c | 1 +
6 files changed, 98 insertions(+), 10 deletions(-)