USB: dwc3_otg: Set peripheral mode before re-initializing core

Moving from host to peripheral mode requires performing hardware
reset and re-initializing core. DWC3 core mode must be changed to
peripheral before DEVICE specific initialization, otherwise,
EP0 initialization would fail due to mode set to HOST and USB
wouldn't enumerate in peripheral mode.

Change-Id: I615442f885e602560d07e2278876d60744b6bd87
CRs-fixed: 469608
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
diff --git a/drivers/usb/dwc3/dwc3_otg.c b/drivers/usb/dwc3/dwc3_otg.c
index ca1f817..1d67cee 100644
--- a/drivers/usb/dwc3/dwc3_otg.c
+++ b/drivers/usb/dwc3/dwc3_otg.c
@@ -216,6 +216,8 @@
 						ext_xceiv->ext_block_reset)
 			ext_xceiv->ext_block_reset(true);
 
+		dwc3_otg_set_peripheral_regs(dotg);
+
 		/* re-init core and OTG registers as block reset clears these */
 		dwc3_post_host_reset_core_init(dwc);
 		if (ext_xceiv && !ext_xceiv->otg_capability)