linux/drivers/usb/dwc2
Ziyang Huang 82f5332d3b usb: dwc2: drd: fix inconsistent mode if role-switch-default-mode="host"
Some boards might use USB-A female connector for USB ports, however,
the port could be connected to a dual-mode USB controller, making it
also behaves as a peripheral device if male-to-male cable is connected.

In this case, the dts looks like this:

	&usb0 {
		status = "okay";
		dr_mode = "otg";
		usb-role-switch;
		role-switch-default-mode = "host";
	};

After boot, dwc2_ovr_init() sets GOTGCTL to GOTGCTL_AVALOVAL and call
dwc2_force_mode() with parameter host=false, which causes inconsistent
mode - The hardware is in peripheral mode while the kernel status is
in host mode.

What we can do now is to call dwc2_drd_role_sw_set() to switch to
device mode, and everything should work just fine now, even switching
back to none(default) mode afterwards.

Fixes: e14acb8769 ("usb: dwc2: drd: add role-switch-default-node support")
Cc: stable <stable@kernel.org>
Signed-off-by: Ziyang Huang <hzyitc@outlook.com>
Tested-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Acked-by: Minas Harutyunyan <hminas@synopsys.com>
Reviewed-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
Link: https://lore.kernel.org/r/SG2PR01MB204837BF68EDB0E343D2A375C9A59@SG2PR01MB2048.apcprd01.prod.exchangelabs.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-03-09 15:38:24 +01:00
..
core.c usb: dwc2: Remove redundant license text 2022-09-22 15:52:29 +02:00
core.h usb: dwc2: Remove redundant license text 2022-09-22 15:52:29 +02:00
core_intr.c usb: dwc2: Remove redundant license text 2022-09-22 15:52:29 +02:00
debug.h USB: dwc2: Use the correct style for SPDX License Identifier 2020-05-05 10:58:50 +03:00
debugfs.c usb: dwc2: add otg_rev and otg_caps information for gadget driver 2021-10-25 09:20:26 +02:00
drd.c usb: dwc2: drd: fix inconsistent mode if role-switch-default-mode="host" 2023-03-09 15:38:24 +01:00
gadget.c usb: dwc2: power on/off phy for peripheral mode in dual-role mode 2022-12-08 16:50:56 +01:00
hcd.c usb: dwc2: Remove redundant license text 2022-09-22 15:52:29 +02:00
hcd.h usb: dwc2: Remove redundant license text 2022-09-22 15:52:29 +02:00
hcd_ddma.c usb: dwc2: Remove redundant license text 2022-09-22 15:52:29 +02:00
hcd_intr.c usb: dwc2: Remove redundant license text 2022-09-22 15:52:29 +02:00
hcd_queue.c usb: dwc2: Remove redundant license text 2022-09-22 15:52:29 +02:00
hw.h usb: dwc2: Remove redundant license text 2022-09-22 15:52:29 +02:00
Kconfig usb: dwc2: override PHY input signals with usb role switch support 2020-10-02 13:29:13 +03:00
Makefile usb: dwc2: override PHY input signals with usb role switch support 2020-10-02 13:29:13 +03:00
params.c usb: dwc2: disable lpm feature on Rockchip SoCs 2022-12-08 16:50:56 +01:00
pci.c usb: dwc2: Remove redundant license text 2022-09-22 15:52:29 +02:00
platform.c usb: dwc2: power on/off phy for peripheral mode in dual-role mode 2022-12-08 16:50:56 +01:00