Browse Source

usb: dwc3: Check controller type before setting speed

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>
Thinh Nguyen 7 years ago
parent
commit
2f3090c6a8
1 changed files with 4 additions and 1 deletions
  1. 4 1
      drivers/usb/dwc3/gadget.c

+ 4 - 1
drivers/usb/dwc3/gadget.c

@@ -2044,7 +2044,10 @@ static void dwc3_gadget_set_speed(struct usb_gadget *g,
 			reg |= DWC3_DCFG_SUPERSPEED;
 			reg |= DWC3_DCFG_SUPERSPEED;
 			break;
 			break;
 		case USB_SPEED_SUPER_PLUS:
 		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;
 			break;
 		default:
 		default:
 			dev_err(dwc->dev, "invalid speed (%d)\n", speed);
 			dev_err(dwc->dev, "invalid speed (%d)\n", speed);