All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2] usb: musb: Fix unstable init of OTG_INTERFSEL.
@ 2013-11-28  7:51 anaumann
       [not found] ` <1385625105-7348-1-git-send-email-anaumann-ZKHRqZ6+gQUX0D0ZMPkEVw@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: anaumann @ 2013-11-28  7:51 UTC (permalink / raw)
  To: balbi; +Cc: linux-usb, linux-omap, Andreas Naumann

From: Andreas Naumann <anaumann@ultratronik.de>

This is a hard to reproduce problem which leads to non-functional
USB-OTG port in 0.1%-1% of all boots. Tracked it down to commit
e25bec160158abe86c276d7d206264afc3646281, which introduces save/restore
of OTG_INTERFSEL over suspend.
Since the resume function is also called early in driver init, it uses a
non-initialized value (which is 0 and a non-supported setting in DM37xx
for INTERFSEL). Shortly after the correct value is set. Apparently this
works most time, but not always.

The fix is to initialize the value, BEFORE being written in the resume
function.


Signed-off-by: Andreas Naumann <anaumann@ultratronik.de>
---
 drivers/usb/musb/omap2430.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 4315d35..783547c 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -337,7 +337,6 @@ static irqreturn_t omap2430_musb_interrupt(int irq, void *__hci)
 
 static int omap2430_musb_init(struct musb *musb)
 {
-	u32 l;
 	int status = 0;
 	struct device *dev = musb->controller;
 	struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
@@ -366,23 +365,24 @@ static int omap2430_musb_init(struct musb *musb)
 
 	musb->isr = omap2430_musb_interrupt;
 
+	musb->context.otg_interfsel = musb_readl(musb->mregs, OTG_INTERFSEL);
+
+	if (data->interface_type == MUSB_INTERFACE_UTMI) {
+		/* OMAP4 uses Internal PHY GS70 which uses UTMI interface */
+		musb->context.otg_interfsel &= ~ULPI_12PIN;  /* Disable ULPI */
+		musb->context.otg_interfsel |= UTMI_8BIT;    /* Enable UTMI  */
+	} else {
+		musb->context.otg_interfsel |= ULPI_12PIN;
+	}
+
 	status = pm_runtime_get_sync(dev);
 	if (status < 0) {
 		dev_err(dev, "pm_runtime_get_sync FAILED %d\n", status);
 		goto err1;
 	}
 
-	l = musb_readl(musb->mregs, OTG_INTERFSEL);
-
-	if (data->interface_type == MUSB_INTERFACE_UTMI) {
-		/* OMAP4 uses Internal PHY GS70 which uses UTMI interface */
-		l &= ~ULPI_12PIN;       /* Disable ULPI */
-		l |= UTMI_8BIT;         /* Enable UTMI  */
-	} else {
-		l |= ULPI_12PIN;
-	}
 
-	musb_writel(musb->mregs, OTG_INTERFSEL, l);
+	musb_writel(musb->mregs, OTG_INTERFSEL, musb->context.otg_interfsel);
 
 	pr_debug("HS USB OTG: revision 0x%x, sysconfig 0x%02x, "
 			"sysstatus 0x%x, intrfsel 0x%x, simenable  0x%x\n",
-- 
1.8.4.1


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

end of thread, other threads:[~2013-11-29 11:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <EE4E4767751A8B40949306E403F4DDD80322D479@sv03ultra002.ultratronik.de>
2013-11-29  8:34 ` [PATCH V2] usb: musb: Fix unstable init of OTG_INTERFSEL Andreas Naumann
2013-11-29 11:57   ` Grazvydas Ignotas
2013-11-28  7:51 anaumann
     [not found] ` <1385625105-7348-1-git-send-email-anaumann-ZKHRqZ6+gQUX0D0ZMPkEVw@public.gmane.org>
2013-11-28 23:35   ` Grazvydas Ignotas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.