Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

usb: dwc2: Add support for 'maximum-speed' property

The DWC2 IP can be properly integrated in a SoC to work at high-speed
USB speed but some board issues, EMC constraints or any other reasons
can lead to the need to limit this USB speed at board level.

The device-tree 'maximum-speed' property already exists for this purpose
but is not handled by the DWC2 driver.

Fill this lack adding support for 'maximum-speed' property and so allow
to limit the USB speed in device-tree (board description).

Signed-off-by: Herve Codina <herve.codina@bootlin.com>
Link: https://lore.kernel.org/r/20250910160730.585303-1-herve.codina@bootlin.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Herve Codina and committed by
Greg Kroah-Hartman
e77ee1d2 a5d2edb2

+26
+26
drivers/usb/dwc2/params.c
··· 1029 1029 return 0; 1030 1030 } 1031 1031 1032 + static int dwc2_limit_speed(struct dwc2_hsotg *hsotg) 1033 + { 1034 + enum usb_device_speed usb_speed; 1035 + 1036 + usb_speed = usb_get_maximum_speed(hsotg->dev); 1037 + switch (usb_speed) { 1038 + case USB_SPEED_LOW: 1039 + dev_err(hsotg->dev, "Maximum speed cannot be forced to low-speed\n"); 1040 + return -EINVAL; 1041 + case USB_SPEED_FULL: 1042 + if (hsotg->params.speed == DWC2_SPEED_PARAM_LOW) 1043 + break; 1044 + hsotg->params.speed = DWC2_SPEED_PARAM_FULL; 1045 + break; 1046 + default: 1047 + break; 1048 + } 1049 + 1050 + return 0; 1051 + } 1052 + 1032 1053 typedef void (*set_params_cb)(struct dwc2_hsotg *data); 1033 1054 1034 1055 int dwc2_init_params(struct dwc2_hsotg *hsotg) 1035 1056 { 1036 1057 set_params_cb set_params; 1058 + int ret; 1037 1059 1038 1060 dwc2_set_default_params(hsotg); 1039 1061 dwc2_get_device_properties(hsotg); ··· 1072 1050 set_params(hsotg); 1073 1051 } 1074 1052 } 1053 + 1054 + ret = dwc2_limit_speed(hsotg); 1055 + if (ret) 1056 + return ret; 1075 1057 1076 1058 dwc2_check_params(hsotg); 1077 1059