[PATCH] usb: musb: Support gadget mode when the port is set to dual role

From: Paul Kocialkowski
Date: Wed Mar 28 2018 - 17:52:43 EST


This allows dual-role ports to be reported as having gadget mode by the
musb_has_gadget helper. This is required to enable MUSB at all with MUSB
glue layers that set the port mode to MUSB_PORT_MODE_DUAL_ROLE at init.

Most notably, this allows calling musb_start when needed in the virtual
MUSB root HUB, regardless of whether the current mode should be gadget
or host.

This fixes USB OTG on Allwinner devices that I could test it with,
mainly A20 devices.

Signed-off-by: Paul Kocialkowski <contact@xxxxxxxx>
---
drivers/usb/musb/musb_virthub.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
index 5165d2b07ade..8fd5c5f86e82 100644
--- a/drivers/usb/musb/musb_virthub.c
+++ b/drivers/usb/musb/musb_virthub.c
@@ -249,7 +249,8 @@ static int musb_has_gadget(struct musb *musb)
#ifdef CONFIG_USB_MUSB_HOST
return 1;
#else
- return musb->port_mode == MUSB_PORT_MODE_HOST;
+ return musb->port_mode == MUSB_PORT_MODE_HOST ||
+ musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE;
#endif
}

--
2.16.2