usb: dwc3: Check controller type before setting speed
authorThinh Nguyen <Thinh.Nguyen@synopsys.com>
Fri, 16 Mar 2018 22:35:57 +0000 (15:35 -0700)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Thu, 22 Mar 2018 08:49:03 +0000 (10:49 +0200)
DWC_usb3 speed can only be set up to SuperSpeed. Limit the setting to
SuperSpeed only should the value be higher. Otherwise, the controller
will read an invalid speed value and set the device to an incorrect
speed.

Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
drivers/usb/dwc3/gadget.c

index 19cf9c0eef128dfff41f4f7eca930c008a3e0756..550ee952c0d14fb4aca4a5fbd970896c47b4eda7 100644 (file)
@@ -2044,7 +2044,10 @@ static void dwc3_gadget_set_speed(struct usb_gadget *g,
                        reg |= DWC3_DCFG_SUPERSPEED;
                        break;
                case USB_SPEED_SUPER_PLUS:
-                       reg |= DWC3_DCFG_SUPERSPEED_PLUS;
+                       if (dwc3_is_usb31(dwc))
+                               reg |= DWC3_DCFG_SUPERSPEED_PLUS;
+                       else
+                               reg |= DWC3_DCFG_SUPERSPEED;
                        break;
                default:
                        dev_err(dwc->dev, "invalid speed (%d)\n", speed);