public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] usb: musb-new: omap2430: Reset the MUSB controller early
@ 2015-01-18 16:44 Paul Kocialkowski
  2015-01-18 22:51 ` Marek Vasut
  0 siblings, 1 reply; 7+ messages in thread
From: Paul Kocialkowski @ 2015-01-18 16:44 UTC (permalink / raw)
  To: u-boot

When booting from USB peripheral boot, the bootrom will not properly deinit the
MUSB controller, which doesn't clearly indicate an USB disconnection to the host
and leaves U-Boot to deal with the state of the previous USB session.

On some host controller drivers (e.g. xhci_hcd), this ends up in a failure
during set address, caused by the lack of proper disconnection notification.

Resetting the controller early in U-Boot notifies the host of the disconnection
and doesn't hurt other use cases.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
---
 drivers/usb/musb-new/omap2430.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/usb/musb-new/omap2430.c b/drivers/usb/musb-new/omap2430.c
index 98f4830..6b256bb 100644
--- a/drivers/usb/musb-new/omap2430.c
+++ b/drivers/usb/musb-new/omap2430.c
@@ -321,6 +321,7 @@ static int omap2430_musb_init(struct musb *musb)
 {
 	u32 l;
 	int status = 0;
+	int timeout = 10;
 #ifndef __UBOOT__
 	struct device *dev = musb->controller;
 	struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
@@ -331,6 +332,22 @@ static int omap2430_musb_init(struct musb *musb)
 		(struct omap_musb_board_data *)musb->controller;
 #endif
 
+	/* Reset the controller */
+	musb_writel(musb->mregs, OTG_SYSCONFIG, SOFTRST);
+
+	while (timeout--) {
+		l = musb_readl(musb->mregs, OTG_SYSCONFIG);
+
+		if (l & SOFTRST)
+			udelay(1);
+		else
+			break;
+	}
+
+	if (timeout == 0) {
+		dev_err(musb->controller, "MUSB reset is taking too long\n");
+		return -ENODEV;
+	}
 
 #ifndef __UBOOT__
 	/* We require some kind of external transceiver, hooked
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-01-22  7:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-18 16:44 [U-Boot] [PATCH] usb: musb-new: omap2430: Reset the MUSB controller early Paul Kocialkowski
2015-01-18 22:51 ` Marek Vasut
2015-01-19 13:29   ` Paul Kocialkowski
2015-01-19 15:12     ` Marek Vasut
2015-01-19 17:33       ` [U-Boot] [PATCH v2] " Paul Kocialkowski
2015-01-20 15:23         ` Tom Rini
2015-01-22  7:19           ` Marek Vasut

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox