summaryrefslogtreecommitdiffstats
path: root/drivers/usb/renesas_usbhs/common.c
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2011-10-10 22:06:46 -0700
committerFelipe Balbi <balbi@ti.com>2011-10-13 20:41:49 +0300
commiteb05191f6a9aba8344a0d5f28642b5ecf44d49a4 (patch)
treed86743fd474d71d7dfd1bf0af827cb404b3ed7e4 /drivers/usb/renesas_usbhs/common.c
parenta9be4a45627c0eaa5f3f16987243530f4df6b514 (diff)
downloadblackbird-op-linux-eb05191f6a9aba8344a0d5f28642b5ecf44d49a4.tar.gz
blackbird-op-linux-eb05191f6a9aba8344a0d5f28642b5ecf44d49a4.zip
usb: gadget: renesas_usbhs: add usbhs_set_device_speed() support for host
mod_host needs device speed setup function Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/renesas_usbhs/common.c')
-rw-r--r--drivers/usb/renesas_usbhs/common.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c
index 895eb44a1a51..c3aef40fa9e5 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -227,6 +227,48 @@ static void usbhsc_bus_init(struct usbhs_priv *priv)
}
/*
+ * device configuration
+ */
+int usbhs_set_device_speed(struct usbhs_priv *priv, int devnum,
+ u16 upphub, u16 hubport, u16 speed)
+{
+ struct device *dev = usbhs_priv_to_dev(priv);
+ u16 usbspd = 0;
+ u32 reg = DEVADD0 + (2 * devnum);
+
+ if (devnum > 10) {
+ dev_err(dev, "cannot set speed to unknown device %d\n", devnum);
+ return -EIO;
+ }
+
+ if (upphub > 0xA) {
+ dev_err(dev, "unsupported hub number %d\n", upphub);
+ return -EIO;
+ }
+
+ switch (speed) {
+ case USB_SPEED_LOW:
+ usbspd = USBSPD_SPEED_LOW;
+ break;
+ case USB_SPEED_FULL:
+ usbspd = USBSPD_SPEED_FULL;
+ break;
+ case USB_SPEED_HIGH:
+ usbspd = USBSPD_SPEED_HIGH;
+ break;
+ default:
+ dev_err(dev, "unsupported speed %d\n", speed);
+ return -EIO;
+ }
+
+ usbhs_write(priv, reg, UPPHUB(upphub) |
+ HUBPORT(hubport)|
+ USBSPD(usbspd));
+
+ return 0;
+}
+
+/*
* local functions
*/
static void usbhsc_set_buswait(struct usbhs_priv *priv)
OpenPOWER on IntegriCloud