Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1470444

[RFT PATCH v3 3/3] usb: dwc2: Properly account for the force mode delays

Path csiph.com!news.mixmin.net!news.unit0.net!news.panservice.it!bofh.it!news.nic.it!robomod
From John Youn <johnyoun@synopsys.com>
Newsgroups linux.kernel
Subject [RFT PATCH v3 3/3] usb: dwc2: Properly account for the force mode delays
Date Thu, 25 Aug 2016 23:30:02 +0200
Message-ID <saanM-6sR-47@gated-at.bofh.it> (permalink)
References <saanL-6sR-3@gated-at.bofh.it>
Dkim-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc :cc:date:from:in-reply-to:message-id:references:subject:to :x-sasl-enc:x-sasl-enc; s=smtpout; bh=aft76wLJUvqjqGVpRrStTLbsLJ w=; b=NOzMzk2zhFOLNdHZQYoTESHFatTvILKDgH8vGfmtFh3CWGnTvCXYR/3jCa qY38l6zAZFo1crFWfwYVqJJv+7Y0QBHFusQuWB1SSfo61LJtTkpXr40r9ieUrgZJ 9FYVVMIigKQWkzl+eeDBg8Ggs+oyrqe9D+sxOk8bUhQFmurBY=
X-Sasl-Enc g9DhZePzcAARSH4Zb4M6cideTK11Aua+hgMpRC0/WAoF 1472160405
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 83
Organization linux.* mail to news gateway
X-Original-Cc johnyoun@synopsys.com
X-Original-Cc Stefan Wahren <stefan.wahren@i2se.com>
X-Original-Cc Michael Niewoehner <linux@mniewoehner.de>
X-Original-Cc Felipe Balbi <balbi@kernel.org>
X-Original-Cc Tao Huang <huangtao@rock-chips.com>
X-Original-Cc Julius Werner <jwerner@chromium.org>
X-Original-Cc linux-kernel@vger.kernel.org
X-Original-Cc Caesar Wang <caesar.upstream@gmail.com>
X-Original-Cc Heiko Stuebner <heiko@sntech.de>
X-Original-Cc Remi Pommarel <repk@triplefau.lt>
X-Original-Cc Kever Yang <kever.yang@rock-chips.com>
X-Original-Cc Doug Anderson <dianders@chromium.org>
X-Original-Cc Stephen Warren <swarren@wwwdotorg.org>
X-Original-Cc linux-rpi-kernel@lists.infradead.org
X-Original-Cc linux-arm-kernel@lists.infradead.org
X-Original-Date Thu, 25 Aug 2016 14:26:43 -0700
X-Original-Message-ID <956d56eb750dee544dd4317bdd9cc0bcc325d8a9.1472160194.git.johnyoun@synopsys.com>
X-Original-References <cover.1472160194.git.johnyoun@synopsys.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1470444

Show key headers only | View raw


When a force mode bit is set and the IDDIG debounce filter is enabled,
there is a delay for the forced mode to take effect. This delay is due
to the IDDIG debounce filter and is variable depending on the platform's
PHY clock speed. To account for this delay we can poll for the expected
mode.

On a clear force mode, since we don't know what mode to poll for, delay
for a fixed 50 ms. This is the maximum delay based on the slowest PHY
clock speed.

Signed-off-by: John Youn <johnyoun@synopsys.com>
---
 drivers/usb/dwc2/core.c | 31 ++++++++++++++-----------------
 1 file changed, 14 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index bb903e2..cbd7436 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -397,9 +397,9 @@ int dwc2_core_reset(struct dwc2_hsotg *hsotg)
  * Checks are done in this function to determine whether doing a force
  * would be valid or not.
  *
- * If a force is done, it requires a 25ms delay to take effect.
- *
- * Returns true if the mode was forced.
+ * If a force is done, it requires a IDDIG debounce filter delay if
+ * the filter is configured and enabled. We poll the current mode of
+ * the controller to account for this delay.
  */
 static bool dwc2_force_mode(struct dwc2_hsotg *hsotg, bool host)
 {
@@ -434,12 +434,18 @@ static bool dwc2_force_mode(struct dwc2_hsotg *hsotg, bool host)
 	gusbcfg |= set;
 	dwc2_writel(gusbcfg, hsotg->regs + GUSBCFG);
 
-	msleep(25);
+	dwc2_wait_for_mode(hsotg, host, 50);
 	return true;
 }
 
-/*
- * Clears the force mode bits.
+/**
+ * dwc2_clear_force_mode() - Clears the force mode bits.
+ *
+ * After clearing the bits, wait up to 50 ms to account for any
+ * potential IDDIG filter delay. We can't know if we expect this delay
+ * or not because the value of the connector ID status is affected by
+ * the force mode. We only need to call this once during probe if
+ * dr_mode == OTG.
  */
 static void dwc2_clear_force_mode(struct dwc2_hsotg *hsotg)
 {
@@ -450,11 +456,8 @@ static void dwc2_clear_force_mode(struct dwc2_hsotg *hsotg)
 	gusbcfg &= ~GUSBCFG_FORCEDEVMODE;
 	dwc2_writel(gusbcfg, hsotg->regs + GUSBCFG);
 
-	/*
-	 * NOTE: This long sleep is _very_ important, otherwise the core will
-	 * not stay in host mode after a connector ID change!
-	 */
-	msleep(25);
+	if (dwc2_iddig_filter_enabled(hsotg))
+		msleep(50);
 }
 
 /*
@@ -477,12 +480,6 @@ void dwc2_force_dr_mode(struct dwc2_hsotg *hsotg)
 			 __func__, hsotg->dr_mode);
 		break;
 	}
-
-	/*
-	 * NOTE: This is required for some rockchip soc based
-	 * platforms.
-	 */
-	msleep(50);
 }
 
 /*
-- 
2.9.0

Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

[RFT PATCH v3 0/3] usb: dwc2: Fix core reset and force mode delays John Youn <johnyoun@synopsys.com> - 2016-08-25 23:30 +0200
  [RFT PATCH v3 3/3] usb: dwc2: Properly account for the force mode delays John Youn <johnyoun@synopsys.com> - 2016-08-25 23:30 +0200

csiph-web