Merge tag 'armsoc-arm64' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
[cascardo/linux.git] / drivers / usb / dwc3 / core.c
index de5e01f..17fd814 100644 (file)
@@ -962,10 +962,6 @@ static int dwc3_probe(struct platform_device *pdev)
                fladj = pdata->fladj_value;
        }
 
-       /* default to superspeed if no maximum_speed passed */
-       if (dwc->maximum_speed == USB_SPEED_UNKNOWN)
-               dwc->maximum_speed = USB_SPEED_SUPER;
-
        dwc->lpm_nyet_threshold = lpm_nyet_threshold;
        dwc->tx_de_emphasis = tx_de_emphasis;
 
@@ -1016,6 +1012,33 @@ static int dwc3_probe(struct platform_device *pdev)
                goto err1;
        }
 
+       /* Check the maximum_speed parameter */
+       switch (dwc->maximum_speed) {
+       case USB_SPEED_LOW:
+       case USB_SPEED_FULL:
+       case USB_SPEED_HIGH:
+       case USB_SPEED_SUPER:
+       case USB_SPEED_SUPER_PLUS:
+               break;
+       default:
+               dev_err(dev, "invalid maximum_speed parameter %d\n",
+                       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_is_usb31(dwc) &&
+                   (DWC3_GHWPARAMS3_SSPHY_IFC(dwc->hwparams.hwparams3) ==
+                    DWC3_GHWPARAMS3_SSPHY_IFC_GEN2))
+                       dwc->maximum_speed = USB_SPEED_SUPER_PLUS;
+
+               break;
+       }
+
        /* Adjust Frame Length */
        dwc3_frame_length_adjustment(dwc, fladj);