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

usb: common: Parse for USB SSP genXxY

The USB "maximum-speed" property can now take the SSP signaling rate
generation and lane count with these new strings:

"super-speed-plus-gen2x2"
"super-speed-plus-gen2x1"
"super-speed-plus-gen1x2"

Introduce usb_get_maximum_ssp_rate() to parse for the corresponding
usb_ssp_rate enum. The original usb_get_maximum_speed() will return
USB_SPEED_SUPER_PLUS if it matches one of these new strings.

Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Link: https://lore.kernel.org/r/f8ed896313d8cd8e2d2b540fc82db92b3ddf8a47.1611106162.git.Thinh.Nguyen@synopsys.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Thinh Nguyen and committed by
Greg Kroah-Hartman
52c2d157 de4d9ea7

+36 -1
+25 -1
drivers/usb/common/common.c
··· 69 69 [USB_SPEED_SUPER_PLUS] = "super-speed-plus", 70 70 }; 71 71 72 + static const char *const ssp_rate[] = { 73 + [USB_SSP_GEN_UNKNOWN] = "UNKNOWN", 74 + [USB_SSP_GEN_2x1] = "super-speed-plus-gen2x1", 75 + [USB_SSP_GEN_1x2] = "super-speed-plus-gen1x2", 76 + [USB_SSP_GEN_2x2] = "super-speed-plus-gen2x2", 77 + }; 78 + 72 79 const char *usb_speed_string(enum usb_device_speed speed) 73 80 { 74 81 if (speed < 0 || speed >= ARRAY_SIZE(speed_names)) ··· 93 86 if (ret < 0) 94 87 return USB_SPEED_UNKNOWN; 95 88 96 - ret = match_string(speed_names, ARRAY_SIZE(speed_names), maximum_speed); 89 + ret = match_string(ssp_rate, ARRAY_SIZE(ssp_rate), maximum_speed); 90 + if (ret > 0) 91 + return USB_SPEED_SUPER_PLUS; 97 92 93 + ret = match_string(speed_names, ARRAY_SIZE(speed_names), maximum_speed); 98 94 return (ret < 0) ? USB_SPEED_UNKNOWN : ret; 99 95 } 100 96 EXPORT_SYMBOL_GPL(usb_get_maximum_speed); 97 + 98 + enum usb_ssp_rate usb_get_maximum_ssp_rate(struct device *dev) 99 + { 100 + const char *maximum_speed; 101 + int ret; 102 + 103 + ret = device_property_read_string(dev, "maximum-speed", &maximum_speed); 104 + if (ret < 0) 105 + return USB_SSP_GEN_UNKNOWN; 106 + 107 + ret = match_string(ssp_rate, ARRAY_SIZE(ssp_rate), maximum_speed); 108 + return (ret < 0) ? USB_SSP_GEN_UNKNOWN : ret; 109 + } 110 + EXPORT_SYMBOL_GPL(usb_get_maximum_ssp_rate); 101 111 102 112 const char *usb_state_string(enum usb_device_state state) 103 113 {
+11
include/linux/usb/ch9.h
··· 72 72 extern enum usb_device_speed usb_get_maximum_speed(struct device *dev); 73 73 74 74 /** 75 + * usb_get_maximum_ssp_rate - Get the signaling rate generation and lane count 76 + * of a SuperSpeed Plus capable device. 77 + * @dev: Pointer to the given USB controller device 78 + * 79 + * If the string from "maximum-speed" property is super-speed-plus-genXxY where 80 + * 'X' is the generation number and 'Y' is the number of lanes, then this 81 + * function returns the corresponding enum usb_ssp_rate. 82 + */ 83 + extern enum usb_ssp_rate usb_get_maximum_ssp_rate(struct device *dev); 84 + 85 + /** 75 86 * usb_state_string - Returns human readable name for the state. 76 87 * @state: The state to return a human-readable name for. If it's not 77 88 * any of the states devices in usb_device_state_string enum,