summaryrefslogtreecommitdiffstats
path: root/drivers/usb/core
diff options
context:
space:
mode:
authorNikita Yushchenko <nikita.yoush@cogentembedded.com>2018-06-22 19:46:57 +0300
committerSascha Hauer <s.hauer@pengutronix.de>2018-06-26 06:56:40 +0200
commit9d7d333c33e5a932b66cc0f5f3ed7fa28a651819 (patch)
treeae43bac20589eb14e68a08fbd76c3e1b85a46a8c /drivers/usb/core
parent782dd520ad67bf5d85fefd3f08149969f00c86f7 (diff)
downloadbarebox-9d7d333c33e5a932b66cc0f5f3ed7fa28a651819.tar.gz
barebox-9d7d333c33e5a932b66cc0f5f3ed7fa28a651819.tar.xz
usb: imx: implement support for limiting host to full speed
This is needed when host is known to not work properly in high speed mode. In linux, chipidea driver supports 'maximum-speed' device tree property. When that is set to "full-speed", driver sets PFSC bit in PORTSC register, which disallows use of high speed mode. This patch implements same support for barebox. Important technical detail is that PFSC bit is cleared by port reset, thus setting it has to be done in ehci->init() callback which is called after ehci_reset(). Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/usb/core')
-rw-r--r--drivers/usb/core/common.c12
-rw-r--r--drivers/usb/core/of.c24
2 files changed, 36 insertions, 0 deletions
diff --git a/drivers/usb/core/common.c b/drivers/usb/core/common.c
index 690d5a39ea..bcbe3a155d 100644
--- a/drivers/usb/core/common.c
+++ b/drivers/usb/core/common.c
@@ -17,3 +17,15 @@ const char *usb_speed_string(enum usb_device_speed speed)
return speed_names[speed];
}
EXPORT_SYMBOL_GPL(usb_speed_string);
+
+enum usb_device_speed usb_speed_by_string(const char *string)
+{
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(speed_names); i++)
+ if (!strcmp(string, speed_names[i]))
+ return i;
+
+ return USB_SPEED_UNKNOWN;
+}
+EXPORT_SYMBOL_GPL(usb_speed_by_string);
diff --git a/drivers/usb/core/of.c b/drivers/usb/core/of.c
index fd20368424..979088ef4e 100644
--- a/drivers/usb/core/of.c
+++ b/drivers/usb/core/of.c
@@ -90,3 +90,27 @@ enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np,
return USBPHY_INTERFACE_MODE_UNKNOWN;
}
EXPORT_SYMBOL_GPL(of_usb_get_phy_mode);
+
+/**
+ * of_usb_get_maximum_speed - Get maximum speed for given device_node
+ * @np: Pointer to the given device_node
+ *
+ * The function gets maximum speed string from property 'maximum-speed',
+ * and returns the correspondig enum usb_device_speed
+ */
+enum usb_device_speed of_usb_get_maximum_speed(struct device_node *np,
+ const char *propname)
+{
+ const char *maximum_speed;
+ int err;
+
+ if (!propname)
+ propname = "maximum-speed";
+
+ err = of_property_read_string(np, propname, &maximum_speed);
+ if (err < 0)
+ return USB_SPEED_UNKNOWN;
+
+ return usb_speed_by_string(maximum_speed);
+}
+EXPORT_SYMBOL_GPL(of_usb_get_maximum_speed);