diff mbox

[U-Boot,v2] usb: musb-new: omap2430: Reset the MUSB controller early

Message ID 1421688823-12733-1-git-send-email-contact@paulk.fr
State Accepted
Delegated to: Marek Vasut
Headers show

Commit Message

Paul Kocialkowski Jan. 19, 2015, 5:33 p.m. UTC
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 | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Tom Rini Jan. 20, 2015, 3:23 p.m. UTC | #1
On Mon, Jan 19, 2015 at 06:33:43PM +0100, Paul Kocialkowski wrote:

> 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>

Reviewed-by: Tom Rini <trini@ti.com>
Marek Vasut Jan. 22, 2015, 7:19 a.m. UTC | #2
On Tuesday, January 20, 2015 at 04:23:10 PM, Tom Rini wrote:
> On Mon, Jan 19, 2015 at 06:33:43PM +0100, Paul Kocialkowski wrote:
> > 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>
> 
> Reviewed-by: Tom Rini <trini@ti.com>

Applied, thanks!

Best regards,
Marek Vasut
diff mbox

Patch

diff --git a/drivers/usb/musb-new/omap2430.c b/drivers/usb/musb-new/omap2430.c
index 98f4830..31a280e 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;
+	unsigned long int start;
 #ifndef __UBOOT__
 	struct device *dev = musb->controller;
 	struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
@@ -331,6 +332,21 @@  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);
+
+	start = get_timer(0);
+
+	while (1) {
+		l = musb_readl(musb->mregs, OTG_SYSCONFIG);
+		if ((l & SOFTRST) == 0)
+			break;
+
+		if (get_timer(start) > (CONFIG_SYS_HZ / 1000)) {
+			dev_err(musb->controller, "MUSB reset is taking too long\n");
+			return -ENODEV;
+		}
+	}
 
 #ifndef __UBOOT__
 	/* We require some kind of external transceiver, hooked