linux_dsm_epyc7002/drivers/usb/dwc3
Yu Chen fce7bbcd07 usb: dwc3: core: Do core softreset when switch mode
commit f88359e1588b85cf0e8209ab7d6620085f3441d9 upstream.

From: John Stultz <john.stultz@linaro.org>

According to the programming guide, to switch mode for DRD controller,
the driver needs to do the following.

To switch from device to host:
1. Reset controller with GCTL.CoreSoftReset
2. Set GCTL.PrtCapDir(host mode)
3. Reset the host with USBCMD.HCRESET
4. Then follow up with the initializing host registers sequence

To switch from host to device:
1. Reset controller with GCTL.CoreSoftReset
2. Set GCTL.PrtCapDir(device mode)
3. Reset the device with DCTL.CSftRst
4. Then follow up with the initializing registers sequence

Currently we're missing step 1) to do GCTL.CoreSoftReset and step 3) of
switching from host to device. John Stult reported a lockup issue seen
with HiKey960 platform without these steps[1]. Similar issue is observed
with Ferry's testing platform[2].

So, apply the required steps along with some fixes to Yu Chen's and John
Stultz's version. The main fixes to their versions are the missing wait
for clocks synchronization before clearing GCTL.CoreSoftReset and only
apply DCTL.CSftRst when switching from host to device.

[1] https://lore.kernel.org/linux-usb/20210108015115.27920-1-john.stultz@linaro.org/
[2] https://lore.kernel.org/linux-usb/0ba7a6ba-e6a7-9cd4-0695-64fc927e01f1@gmail.com/

Fixes: 41ce1456e1 ("usb: dwc3: core: make dwc3_set_mode() work properly")
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Ferry Toth <fntoth@gmail.com>
Cc: Wesley Cheng <wcheng@codeaurora.org>
Cc: <stable@vger.kernel.org>
Tested-by: John Stultz <john.stultz@linaro.org>
Tested-by: Wesley Cheng <wcheng@codeaurora.org>
Signed-off-by: Yu Chen <chenyu56@huawei.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Link: https://lore.kernel.org/r/374440f8dcd4f06c02c2caf4b1efde86774e02d9.1618521663.git.Thinh.Nguyen@synopsys.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-05-11 14:47:39 +02:00
..
core.c usb: dwc3: core: Do core softreset when switch mode 2021-05-11 14:47:39 +02:00
core.h usb: dwc3: core: Do core softreset when switch mode 2021-05-11 14:47:39 +02:00
debug.h usb: dwc3: debug: fix checkpatch warning 2020-10-02 09:43:35 +03:00
debugfs.c usb: dwc3: debugfs: do not queue work if try to change mode on non-drd 2020-10-02 09:57:42 +03:00
drd.c usb: dwc3: Replace HTTP links with HTTPS ones 2020-07-15 16:33:51 +02:00
dwc3-exynos.c Revert "usb: dwc3: exynos: Add support for Exynos5422 suspend clk" 2020-06-24 09:52:23 +03:00
dwc3-haps.c usb: dwc3: dwc3-haps: Function headers are not suitable for kerneldoc 2020-07-03 10:18:40 +02:00
dwc3-keystone.c usb: dwc3: Replace HTTP links with HTTPS ones 2020-07-15 16:33:51 +02:00
dwc3-meson-g12a.c usb: dwc3: meson-g12a: disable clk on error handling path in probe 2021-01-12 20:18:18 +01:00
dwc3-of-simple.c usb: dwc3: of-simple: Add compatible string for Intel Keem Bay platform 2020-10-02 13:29:13 +03:00
dwc3-omap.c usb: dwc3: Replace HTTP links with HTTPS ones 2020-07-15 16:33:51 +02:00
dwc3-pci.c usb: dwc3: pci: Enable dis_uX_susphy_quirk for Intel Merrifield 2021-04-07 15:00:11 +02:00
dwc3-qcom.c usb: dwc3: qcom: skip interconnect init for ACPI probe 2021-04-07 15:00:13 +02:00
dwc3-st.c usb: dwc3: convert to devm_platform_ioremap_resource_byname 2020-07-29 16:49:37 +02:00
ep0.c usb: dwc3: ep0: Fix delay status handling 2020-10-27 11:33:53 +02:00
gadget.c usb: dwc3: gadget: Fix START_TRANSFER link state check 2021-05-11 14:47:39 +02:00
gadget.h usb: dwc3: allocate gadget structure dynamically 2020-10-02 09:57:42 +03:00
host.c usb: dwc3: Replace HTTP links with HTTPS ones 2020-07-15 16:33:51 +02:00
io.h usb: dwc3: Replace HTTP links with HTTPS ones 2020-07-15 16:33:51 +02:00
Kconfig usb: dwc3: select USB_ROLE_SWITCH 2020-05-09 11:05:09 +03:00
Makefile usb: dwc3: Add Amlogic G12A DWC3 glue 2019-05-03 09:13:47 +03:00
trace.c usb: dwc3: Replace HTTP links with HTTPS ones 2020-07-15 16:33:51 +02:00
trace.h usb: dwc3: trace: fix checkpatch warnings 2020-10-02 09:43:35 +03:00
ulpi.c usb: dwc3: ulpi: Fix USB2.0 HS/FS/LS PHY suspend regression 2021-01-12 20:18:19 +01:00