usb: dwc3: Valid HW capability
Subsystems (2)
Thinh Nguyen
maintainercover usb: dwc3: Valid HW capability
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
Signature · 1 line
2.11.0
Thinh Nguyen
maintainerPATCH 1/2 usb: dwc3: core: Properly default unspecified speed
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.
--- drivers/usb/dwc3/core.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-)
drivers/usb/dwc3/core.c +18 -17
@@ -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 ; } }
Signature · 1 line
2.11.0
Thinh Nguyen
maintainerPATCH 2/2 usb: dwc3: core: Print warning on unsupported speed
In reply to Thinh NguyenThe 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.
--- drivers/usb/dwc3/core.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/usb/dwc3/core.c +9 -0
@@ -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",
Signature · 1 line
2.11.0