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


Groups > linux.kernel > #1470437 > unrolled thread

[RFT PATCH v3 0/3] usb: dwc2: Fix core reset and force mode delays

Started byJohn Youn <johnyoun@synopsys.com>
First post2016-08-25 23:30 +0200
Last post2016-08-25 23:30 +0200
Articles 2 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [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

#1470437 — [RFT PATCH v3 0/3] usb: dwc2: Fix core reset and force mode delays

FromJohn Youn <johnyoun@synopsys.com>
Date2016-08-25 23:30 +0200
Subject[RFT PATCH v3 0/3] usb: dwc2: Fix core reset and force mode delays
Message-ID<saanL-6sR-3@gated-at.bofh.it>
This series tries to account for a delay from the IDDIG debounce
filter when switching modes. This delay is a function of the PHY clock
speed and can range from 5-50 ms. This delay must be taken into
account on core reset and force modes. A full explanation is provided
in the patch commit log and code comments.

Patch 1 is a prerequisite to this fix.

Patch 2 implements the delay for core reset.

Patch 3 implements the delay for set/clear force modes.

Appreciate any testing, especially on RK3188 and RPi platforms.

Patch 1-2 can probably be merged right now as they shouldn't break
anything.

Patch 3 should solve RPi issues, but has problems in RK3188 that need
to be debugged.

v3:
* Added tested-bys for patch 1-2
* Fixed an issue where a function was not returning a value
* Dropped patch 4

v2:
* Broke up the last patch of the original series

Regards,
John

John Youn (3):
  usb: dwc2: gadget: Only initialize device if in device mode
  usb: dwc2: Add delay to core soft reset
  usb: dwc2: Properly account for the force mode delays

 drivers/usb/dwc2/core.c   | 128 ++++++++++++++++++++++++++++++++++++++++------
 drivers/usb/dwc2/core.h   |   1 +
 drivers/usb/dwc2/gadget.c |   7 ++-
 drivers/usb/dwc2/hw.h     |   1 +
 4 files changed, 118 insertions(+), 19 deletions(-)

-- 
2.9.0

[toc] | [next] | [standalone]


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

FromJohn Youn <johnyoun@synopsys.com>
Date2016-08-25 23:30 +0200
Subject[RFT PATCH v3 3/3] usb: dwc2: Properly account for the force mode delays
Message-ID<saanM-6sR-47@gated-at.bofh.it>
In reply to#1470437
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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web