public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
From: Felipe Balbi <felipebalbi@users.sourceforge.net>
To: linux-omap-open-source@linux.omap.com
Subject: [PATCH] musb_hdrc: Implement workaround for tusb3.0 wbus bug rev2
Date: Tue, 29 May 2007 15:02:33 +0300	[thread overview]
Message-ID: <11804401662563-git-send-email-felipebalbi@users.sourceforge.net> (raw)
In-Reply-To: <11804401651954-git-send-email-felipebalbi@users.sourceforge.net>

From: Tony Lindgren <tony@atomide.com>

Without this workaround tusb3.0 will wake-up spontaneously
on USB suspend.

Patch also moves revision functions to the top of the file.

Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Felipe Balbi <felipe.lima@indt.org.br>
---

Index: linux-omap-2.6/drivers/usb/musb/tusb6010.c
===================================================================
--- linux-omap-2.6.orig/drivers/usb/musb/tusb6010.c	2007-05-25 14:12:31.000000000 +0300
+++ linux-omap-2.6/drivers/usb/musb/tusb6010.c	2007-05-25 14:12:34.000000000 +0300
@@ -25,6 +25,67 @@
 
 #include "musbdefs.h"
 
+/*
+ * Checks the revision. We need to use the DMA register as 3.0 does not
+ * have correct versions for TUSB_PRCM_REV or TUSB_INT_CTRL_REV.
+ */
+static u8 tusb_get_revision(struct musb *musb)
+{
+	void __iomem	*base = musb->ctrl_base;
+
+	return musb_readl(base, TUSB_DMA_CTRL_REV) & 0xff;
+}
+
+#define TUSB_REV_MAJOR(reg_val)		((reg_val >> 4) & 0xf)
+#define TUSB_REV_MINOR(reg_val)		(reg_val & 0xf)
+
+static int __init tusb_print_revision(struct musb *musb)
+{
+	void __iomem	*base = musb->ctrl_base;
+
+	pr_info("tusb: Revisions: %s%i.%i %s%i.%i %s%i.%i %s%i.%i\n",
+		"prcm",
+		TUSB_REV_MAJOR(musb_readl(base, TUSB_PRCM_REV)),
+		TUSB_REV_MINOR(musb_readl(base, TUSB_PRCM_REV)),
+		"int",
+		TUSB_REV_MAJOR(musb_readl(base, TUSB_INT_CTRL_REV)),
+		TUSB_REV_MINOR(musb_readl(base, TUSB_INT_CTRL_REV)),
+		"gpio",
+		TUSB_REV_MAJOR(musb_readl(base, TUSB_GPIO_REV)),
+		TUSB_REV_MINOR(musb_readl(base, TUSB_GPIO_REV)),
+		"dma",
+		TUSB_REV_MAJOR(musb_readl(base, TUSB_DMA_CTRL_REV)),
+		TUSB_REV_MINOR(musb_readl(base, TUSB_DMA_CTRL_REV)));
+
+	return TUSB_REV_MAJOR(musb_readl(base, TUSB_INT_CTRL_REV));
+}
+
+static void tusb_wbus_quirk(struct musb *musb, int enabled)
+{
+	void __iomem	*base = musb->ctrl_base;
+	static u32	phy_otg_ctrl = 0;
+
+	if (enabled) {
+		DBG(2, "Enabling tusb wbus quirk\n");
+		musb_writel(base, TUSB_PHY_OTG_CTRL_ENABLE,
+				TUSB_PHY_OTG_CTRL_WRPROTECT |
+				TUSB_PHY_OTG_CTRL_TESTM2 |
+				TUSB_PHY_OTG_CTRL_TESTM1 |
+				TUSB_PHY_OTG_CTRL_TESTM0);
+		phy_otg_ctrl = musb_readl(base, TUSB_PHY_OTG_CTRL);
+		musb_writel(base, TUSB_PHY_OTG_CTRL,
+				TUSB_PHY_OTG_CTRL_WRPROTECT |
+				TUSB_PHY_OTG_CTRL_TESTM2);
+	} else if (musb_readl(base, TUSB_PHY_OTG_CTRL_ENABLE)
+			& TUSB_PHY_OTG_CTRL_TESTM2) {
+		DBG(3, "Disabling tusb wbus quirk\n");
+		musb_writel(base, TUSB_PHY_OTG_CTRL,
+			TUSB_PHY_OTG_CTRL_WRPROTECT | phy_otg_ctrl);
+		musb_writel(base, TUSB_PHY_OTG_CTRL_ENABLE,
+			TUSB_PHY_OTG_CTRL_WRPROTECT);
+		phy_otg_ctrl = 0;
+	}
+}
 
 /*
  * TUSB 6010 may use a parallel bus that doesn't support byte ops;
@@ -253,6 +314,11 @@
 	void __iomem	*base = musb->ctrl_base;
 	u32		reg;
 
+	if ((wakeup_enables & TUSB_PRCM_WBUS)
+			&& musb_platform_get_vbus_status(musb)
+			&& (tusb_get_revision(musb) == TUSB_REV_30))
+		tusb_wbus_quirk(musb, 1);
+
 	tusb_set_clock_source(musb, 0);
 
 	wakeup_enables |= TUSB_PRCM_WNORCS;
@@ -302,7 +368,7 @@
 		musb_writel(base, TUSB_PRCM_MNGMT, prcm_mngmt);
 	}
 
-	if (otg_stat & TUSB_DEV_OTG_STAT_VBUS_SENSE)
+	if (otg_stat & TUSB_DEV_OTG_STAT_VBUS_VALID)
 		ret = 1;
 
 	return ret;
@@ -651,6 +717,9 @@
 		u32	reg;
 		u32	i;
 
+		if (tusb_get_revision(musb) == TUSB_REV_30)
+			tusb_wbus_quirk(musb, 0);
+
 		/* there are issues re-locking the PLL on wakeup ... */
 
 		/* work around issue 8 */
@@ -829,30 +898,6 @@
 	musb_writel(base, TUSB_WAIT_COUNT, 1);
 }
 
-#define TUSB_REV_MAJOR(reg_val)		((reg_val >> 4) & 0xf)
-#define TUSB_REV_MINOR(reg_val)		(reg_val & 0xf)
-
-static int __init tusb_print_revision(struct musb *musb)
-{
-	void __iomem	*base = musb->ctrl_base;
-
-	pr_info("tusb: Revisions: %s%i.%i %s%i.%i %s%i.%i %s%i.%i\n",
-		"prcm",
-		TUSB_REV_MAJOR(musb_readl(base, TUSB_PRCM_REV)),
-		TUSB_REV_MINOR(musb_readl(base, TUSB_PRCM_REV)),
-		"int",
-		TUSB_REV_MAJOR(musb_readl(base, TUSB_INT_CTRL_REV)),
-		TUSB_REV_MINOR(musb_readl(base, TUSB_INT_CTRL_REV)),
-		"gpio",
-		TUSB_REV_MAJOR(musb_readl(base, TUSB_GPIO_REV)),
-		TUSB_REV_MINOR(musb_readl(base, TUSB_GPIO_REV)),
-		"dma",
-		TUSB_REV_MAJOR(musb_readl(base, TUSB_DMA_CTRL_REV)),
-		TUSB_REV_MINOR(musb_readl(base, TUSB_DMA_CTRL_REV)));
-
-	return TUSB_REV_MAJOR(musb_readl(base, TUSB_INT_CTRL_REV));
-}
-
 static int __init tusb_start(struct musb *musb)
 {
 	void __iomem	*base = musb->ctrl_base;
Index: linux-omap-2.6/drivers/usb/musb/tusb6010.h
===================================================================
--- linux-omap-2.6.orig/drivers/usb/musb/tusb6010.h	2007-05-25 14:12:31.000000000 +0300
+++ linux-omap-2.6/drivers/usb/musb/tusb6010.h	2007-05-25 14:12:34.000000000 +0300
@@ -216,6 +216,10 @@
 #define TUSB_PROD_TEST_RESET_VAL		0xa596
 #define TUSB_EP_FIFO(ep)			(TUSB_FIFO_BASE + (ep) * 0x20)
 
+#define TUSB_REV_1	0x10
+#define TUSB_REV_2	0x20
+#define TUSB_REV_30	0x30
+
 /*----------------------------------------------------------------------------*/
 
 #ifdef CONFIG_USB_TUSB6010

  reply	other threads:[~2007-05-29 12:02 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-29 12:02 RFC PATCH Felipe Balbi
2007-05-29 12:02 ` [PATCH] USB: Disable file_storage USB_CONFIG_ATT_WAKEUP Felipe Balbi
2007-05-29 12:02   ` Felipe Balbi [this message]
2007-05-29 12:02     ` [PATCH] musb_hdrc: Add SRP Interface and control it through sysfs Felipe Balbi
2007-05-29 12:02       ` [PATCH] Add Sysfs Interface to Control Vbus states Felipe Balbi
2007-05-29 12:02         ` [PATCH] Add more Test Modes Felipe Balbi
2007-05-29 12:02           ` [PATCH] musb_hdrc: Make HNP work Felipe Balbi
2007-05-29 12:02             ` [PATCH] USB: Fix OTG HNP for hub.c Felipe Balbi
2007-05-29 12:02               ` [PATCH] HSET tool for the MUSB Controler Felipe Balbi
2007-05-29 12:02                 ` [PATCH] Leave GPIO[7:6] pullups enabled Felipe Balbi
     [not found]                   ` <11804401803413-git-send-email-felipebalbi@users.sourceforge.net>
2007-05-29 12:02                     ` [PATCH] Make SRP passes in all Electrical Tests Felipe Balbi
2007-05-29 14:39                       ` Dirk Behme
2007-06-05 11:02                   ` [PATCH] Leave GPIO[7:6] pullups enabled Tony Lindgren
2007-05-29 19:21               ` [PATCH] USB: Fix OTG HNP for hub.c David Brownell
2007-05-29 19:24                 ` Felipe Balbi
2007-05-29 20:34                   ` Tony Lindgren
2007-05-29 21:11                     ` David Brownell
2007-05-29 21:26                       ` Tony Lindgren
2007-05-29 17:16           ` [PATCH] Add more Test Modes David Brownell
2007-05-29 17:07       ` [PATCH] musb_hdrc: Add SRP Interface and control it through sysfs David Brownell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11804401662563-git-send-email-felipebalbi@users.sourceforge.net \
    --to=felipebalbi@users.sourceforge.net \
    --cc=linux-omap-open-source@linux.omap.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox