Gadget driver needs to be registered in OTG to perform dynamic role switching. Signed-off-by: Robert Baldyga <r.baldyga@xxxxxxxxxxx> --- drivers/usb/dwc3/gadget.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index b0c1ab5..c5a7cf1 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -32,6 +32,7 @@ #include "debug.h" #include "core.h" +#include "otg.h" #include "gadget.h" #include "io.h" @@ -2783,8 +2784,18 @@ int dwc3_gadget_init(struct dwc3 *dwc) goto err4; } + if (dwc->dotg) { + ret = otg_set_peripheral(&dwc->dotg->otg, &dwc->gadget); + if (ret) { + dev_err(dwc->dev, "failed to set otg peripheral\n"); + goto err5; + } + } + return 0; +err5: + usb_del_gadget_udc(&dwc->gadget); err4: dwc3_gadget_free_endpoints(dwc); dma_free_coherent(dwc->dev, DWC3_EP0_BOUNCE_SIZE, @@ -2809,6 +2820,9 @@ err0: void dwc3_gadget_exit(struct dwc3 *dwc) { + if (dwc->dotg) + otg_set_peripheral(&dwc->dotg->otg, NULL); + usb_del_gadget_udc(&dwc->gadget); dwc3_gadget_free_endpoints(dwc); -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html