usb: dwc2: fix reset logic in dwc2_core_reset
authorPatrick Delaunay <patrick.delaunay@foss.st.com>
Wed, 23 Jul 2025 15:09:16 +0000 (17:09 +0200)
committerMarek Vasut <marek.vasut+usb@mailbox.org>
Sat, 23 Aug 2025 16:20:01 +0000 (18:20 +0200)
commit332714b905923d9e97a2cc7590dfc41e49980d35
tree5338dfac1263041cb17d78a8da8f8c9480edc8aa
parent445aad45f47a19860eff5b09c4c570285265318a
usb: dwc2: fix reset logic in dwc2_core_reset

Use GUSBCFG_FORCEHOSTMODE to detected the HOST forced mode as it is done
in the Linux driver drivers/usb/dwc2/core.c:dwc2_core_reset().

The host polling must be executed only if the current mode is host,
either due to the force HOST mode (which persists after core reset)
or the connector id pin.

The GUSBCFG_FORCEDEVMODE bits is used to force the device mode (for
example used on STM32MP1x platform) and when it is activated the DWC2 reset
failed with the trace:
"dwc2_core_reset: Waiting for GINTSTS_CURMODE_HOST timeout"

Fixes: c5d685b8993c ("usb: dwc2: Unify flush and reset logic with v4.20a support")
Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Reviewed-by: Junhui Liu <junhui.liu@pigmoral.tech>
Tested-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reviewed-by: Marek Vasut <marek.vasut@mailbox.org>
drivers/usb/common/dwc2_core.c