Skip to content

Commit 92ef98a

Browse files
johnkeepinggregkh
authored andcommitted
usb: dwc2: gadget: initialize max_speed from params
DWC2 may be paired with a full-speed PHY which is not capable of high-speed operation. Report this correctly to the gadget core by setting max_speed from the core parameters. Prior to commit 5324bad ("usb: dwc2: gadget: implement udc_set_speed()") this didn't cause the hardware to be configured incorrectly, although the speed may have been reported incorrectly. But after that commit params.speed is updated based on a value passed in by the gadget core which may set it to a faster speed than is supported by the hardware. Initialising the max_speed parameter ensures the speed passed to dwc2_gadget_set_speed() will be one supported by the hardware. Fixes: 5324bad ("usb: dwc2: gadget: implement udc_set_speed()") Acked-by: Minas Harutyunyan <[email protected]> Signed-off-by: John Keeping <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 34146c6 commit 92ef98a

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

drivers/usb/dwc2/gadget.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4974,7 +4974,18 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg)
49744974
hsotg->params.g_np_tx_fifo_size);
49754975
dev_dbg(dev, "RXFIFO size: %d\n", hsotg->params.g_rx_fifo_size);
49764976

4977-
hsotg->gadget.max_speed = USB_SPEED_HIGH;
4977+
switch (hsotg->params.speed) {
4978+
case DWC2_SPEED_PARAM_LOW:
4979+
hsotg->gadget.max_speed = USB_SPEED_LOW;
4980+
break;
4981+
case DWC2_SPEED_PARAM_FULL:
4982+
hsotg->gadget.max_speed = USB_SPEED_FULL;
4983+
break;
4984+
default:
4985+
hsotg->gadget.max_speed = USB_SPEED_HIGH;
4986+
break;
4987+
}
4988+
49784989
hsotg->gadget.ops = &dwc2_hsotg_gadget_ops;
49794990
hsotg->gadget.name = dev_name(dev);
49804991
hsotg->gadget.otg_caps = &hsotg->params.otg_caps;

0 commit comments

Comments
 (0)