All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] usb: dwc3: Valid HW capability
@ 2020-07-24 21:00 Thinh Nguyen
  2020-07-24 21:01 ` [PATCH 1/2] usb: dwc3: core: Properly default unspecified speed Thinh Nguyen
  2020-07-24 21:01 ` [PATCH 2/2] usb: dwc3: core: Print warning on unsupported speed Thinh Nguyen
  0 siblings, 2 replies; 3+ messages in thread
From: Thinh Nguyen @ 2020-07-24 21:00 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Thinh Nguyen, linux-usb, Chunfeng Yun
  Cc: John Youn

The field dwc->maximum_speed captures the device "maximum-speed" property. If
the property is not set, then default the field to the maximum speed the HW
supports.

This series makes sure that the user input takes precedence and only prints
warning if the user specifies a maximum-speed higher than what the HW shows.


Thinh Nguyen (2):
  usb: dwc3: core: Properly default unspecified speed
  usb: dwc3: core: Print warning on unsupported speed

 drivers/usb/dwc3/core.c | 44 +++++++++++++++++++++++++++-----------------
 1 file changed, 27 insertions(+), 17 deletions(-)


base-commit: a95fcda246dc3e9f5d00222c9a8f0a76aa0bb950
-- 
2.11.0


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

* [PATCH 1/2] usb: dwc3: core: Properly default unspecified speed
  2020-07-24 21:00 [PATCH 0/2] usb: dwc3: Valid HW capability Thinh Nguyen
@ 2020-07-24 21:01 ` Thinh Nguyen
  2020-07-24 21:01 ` [PATCH 2/2] usb: dwc3: core: Print warning on unsupported speed Thinh Nguyen
  1 sibling, 0 replies; 3+ messages in thread
From: Thinh Nguyen @ 2020-07-24 21:01 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Thinh Nguyen, linux-usb, Chunfeng Yun
  Cc: John Youn

If the maximum_speed is not specified, default the device speed base on
its HW capability. Don't prematurely check HW capability before
validating the maximum_speed device property. The device property takes
precedence in dwc->maximum_speed.

Fixes: 0e1e5c47f7a9 ("usb: dwc3: add support for USB 2.0-only core configuration")
Reported-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
---
 drivers/usb/dwc3/core.c | 35 ++++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 422aea24afcd..7f6f5567b118 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -930,13 +930,6 @@ static int dwc3_core_init(struct dwc3 *dwc)
 	 */
 	dwc3_writel(dwc->regs, DWC3_GUID, LINUX_VERSION_CODE);
 
-	/* Handle USB2.0-only core configuration */
-	if (DWC3_GHWPARAMS3_SSPHY_IFC(dwc->hwparams.hwparams3) ==
-			DWC3_GHWPARAMS3_SSPHY_IFC_DIS) {
-		if (dwc->maximum_speed == USB_SPEED_SUPER)
-			dwc->maximum_speed = USB_SPEED_HIGH;
-	}
-
 	ret = dwc3_phy_setup(dwc);
 	if (ret)
 		goto err0;
@@ -1382,6 +1375,8 @@ bool dwc3_has_imod(struct dwc3 *dwc)
 static void dwc3_check_params(struct dwc3 *dwc)
 {
 	struct device *dev = dwc->dev;
+	unsigned int hwparam_gen =
+		DWC3_GHWPARAMS3_SSPHY_IFC(dwc->hwparams.hwparams3);
 
 	/* Check for proper value of imod_interval */
 	if (dwc->imod_interval && !dwc3_has_imod(dwc)) {
@@ -1413,17 +1408,23 @@ static void dwc3_check_params(struct dwc3 *dwc)
 			dwc->maximum_speed);
 		/* fall through */
 	case USB_SPEED_UNKNOWN:
-		/* default to superspeed */
-		dwc->maximum_speed = USB_SPEED_SUPER;
-
-		/*
-		 * default to superspeed plus if we are capable.
-		 */
-		if ((DWC3_IP_IS(DWC31) || DWC3_IP_IS(DWC32)) &&
-		    (DWC3_GHWPARAMS3_SSPHY_IFC(dwc->hwparams.hwparams3) ==
-		     DWC3_GHWPARAMS3_SSPHY_IFC_GEN2))
+		switch (hwparam_gen) {
+		case DWC3_GHWPARAMS3_SSPHY_IFC_GEN2:
 			dwc->maximum_speed = USB_SPEED_SUPER_PLUS;
-
+			break;
+		case DWC3_GHWPARAMS3_SSPHY_IFC_GEN1:
+			if (DWC3_IP_IS(DWC32))
+				dwc->maximum_speed = USB_SPEED_SUPER_PLUS;
+			else
+				dwc->maximum_speed = USB_SPEED_SUPER;
+			break;
+		case DWC3_GHWPARAMS3_SSPHY_IFC_DIS:
+			dwc->maximum_speed = USB_SPEED_HIGH;
+			break;
+		default:
+			dwc->maximum_speed = USB_SPEED_SUPER;
+			break;
+		}
 		break;
 	}
 }
-- 
2.11.0


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

* [PATCH 2/2] usb: dwc3: core: Print warning on unsupported speed
  2020-07-24 21:00 [PATCH 0/2] usb: dwc3: Valid HW capability Thinh Nguyen
  2020-07-24 21:01 ` [PATCH 1/2] usb: dwc3: core: Properly default unspecified speed Thinh Nguyen
@ 2020-07-24 21:01 ` Thinh Nguyen
  1 sibling, 0 replies; 3+ messages in thread
From: Thinh Nguyen @ 2020-07-24 21:01 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Thinh Nguyen, linux-usb; +Cc: John Youn

The user may have more information to override the HW parameter to
specify the maximum_speed. However, if the user specifies a
maximum_speed that the controller doesn't support, print out a warning.

Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
---
 drivers/usb/dwc3/core.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 7f6f5567b118..b2ea96d2db04 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1400,8 +1400,17 @@ static void dwc3_check_params(struct dwc3 *dwc)
 	case USB_SPEED_LOW:
 	case USB_SPEED_FULL:
 	case USB_SPEED_HIGH:
+		break;
 	case USB_SPEED_SUPER:
+		if (hwparam_gen == DWC3_GHWPARAMS3_SSPHY_IFC_DIS)
+			dev_warn(dev, "UDC doesn't support Gen 1\n");
+		break;
 	case USB_SPEED_SUPER_PLUS:
+		if ((DWC3_IP_IS(DWC32) &&
+		     hwparam_gen == DWC3_GHWPARAMS3_SSPHY_IFC_DIS) ||
+		    (!DWC3_IP_IS(DWC32) &&
+		     hwparam_gen != DWC3_GHWPARAMS3_SSPHY_IFC_GEN2))
+			dev_warn(dev, "UDC doesn't support SSP\n");
 		break;
 	default:
 		dev_err(dev, "invalid maximum_speed parameter %d\n",
-- 
2.11.0


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

end of thread, other threads:[~2020-07-24 21:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-24 21:00 [PATCH 0/2] usb: dwc3: Valid HW capability Thinh Nguyen
2020-07-24 21:01 ` [PATCH 1/2] usb: dwc3: core: Properly default unspecified speed Thinh Nguyen
2020-07-24 21:01 ` [PATCH 2/2] usb: dwc3: core: Print warning on unsupported speed Thinh Nguyen

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.