usb: musb: mediatek: reset EP during init

Signed-off-by: Fabien Parent <fparent@baylibre.com>
diff --git a/drivers/usb/musb/mediatek.c b/drivers/usb/musb/mediatek.c
index 6b88c2f..839875e 100644
--- a/drivers/usb/musb/mediatek.c
+++ b/drivers/usb/musb/mediatek.c
@@ -21,6 +21,9 @@
 #define USB_L1INTM		0x00a4
 #define MTK_MUSB_TXFUNCADDR	0x0480
 
+#define BUSPERF3		0x74
+#define BUSPERF3_EP_SWRST	BIT(1)
+
 /* MediaTek controller toggle enable and status reg */
 #define MUSB_RXTOG		0x80
 #define MUSB_RXTOGEN		0x82
@@ -298,6 +301,7 @@
 	struct device *dev = musb->controller;
 	struct mtk_glue *glue = dev_get_drvdata(dev->parent);
 	int ret;
+	u16 busperf3;
 
 	glue->musb = musb;
 	musb->phy = glue->phy;
@@ -305,6 +309,10 @@
 	musb->is_host = false;
 	musb->isr = mtk_musb_interrupt;
 
+	/* Reset USB MAC settings */
+	busperf3 = musb_readw(musb->mregs, BUSPERF3);
+	musb_writew(musb->mregs, BUSPERF3, busperf3 | BUSPERF3_EP_SWRST);
+
 	/* Set TX/RX toggle enable */
 	musb_writew(musb->mregs, MUSB_TXTOGEN, MTK_TOGGLE_EN);
 	musb_writew(musb->mregs, MUSB_RXTOGEN, MTK_TOGGLE_EN);