@@ -92,6 +92,32 @@ enum usb_device_speed usb_get_maximum_speed(struct device *dev)
}
EXPORT_SYMBOL_GPL(usb_get_maximum_speed);
+u8 usb_get_num_lanes(struct device *dev)
+{
+ u8 num_lanes;
+ int ret;
+
+ ret = device_property_read_u8(dev, "num-lanes", &num_lanes);
+ if (ret < 0)
+ return 0;
+
+ return num_lanes;
+}
+EXPORT_SYMBOL_GPL(usb_get_num_lanes);
+
+u16 usb_get_lsm(struct device *dev)
+{
+ u16 lsm;
+ int ret;
+
+ ret = device_property_read_u16(dev, "lane-speed-mantissa-gbps", &lsm);
+ if (ret < 0)
+ return 0;
+
+ return lsm;
+}
+EXPORT_SYMBOL_GPL(usb_get_lsm);
+
const char *usb_state_string(enum usb_device_state state)
{
static const char *const names[] = {
@@ -105,6 +105,25 @@ extern const char *usb_speed_string(enum usb_device_speed speed);
*/
extern enum usb_device_speed usb_get_maximum_speed(struct device *dev);
+/**
+ * usb_get_num_lanes - Get maximum number of requested lanes for a given USB
+ * controller.
+ * @dev: Pointer to the given USB controller device
+ *
+ * The function returns the number of requested lanes from the property
+ * "num-lanes".
+ */
+extern u8 usb_get_num_lanes(struct device *dev);
+
+/**
+ * usb_get_lsm - Get requested lane speed mantissa for a given USB controller.
+ * @dev: Pointer to the given USB controller device
+ *
+ * The function returns the requested symmetric lane speed mantissa in Gbps from
+ * the property "lane-speed-mantissa-gbps".
+ */
+extern u16 usb_get_lsm(struct device *dev);
+
/**
* usb_state_string - Returns human readable name for the state.
* @state: The state to return a human-readable name for. If it's not
Add common functions to get the requested number of lanes and lane speed mantissa from device properties. Signed-off-by: Thinh Nguyen <thinhn@synopsys.com> --- Changes in v2: - New commit drivers/usb/common/common.c | 26 ++++++++++++++++++++++++++ include/linux/usb/ch9.h | 19 +++++++++++++++++++ 2 files changed, 45 insertions(+)