]> git.karo-electronics.de Git - linux-beck.git/commitdiff
usb: gadget: renesas_usbhs: add usbhs_set_device_speed() support for host
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tue, 11 Oct 2011 05:06:46 +0000 (22:06 -0700)
committerFelipe Balbi <balbi@ti.com>
Thu, 13 Oct 2011 17:41:49 +0000 (20:41 +0300)
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>
drivers/usb/renesas_usbhs/common.c
drivers/usb/renesas_usbhs/common.h

index 895eb44a1a518686513146dbb61cb237732cf8bd..c3aef40fa9e581ba49ccc4f170fef45b541b96b3 100644 (file)
@@ -226,6 +226,48 @@ static void usbhsc_bus_init(struct usbhs_priv *priv)
        usbhs_vbus_ctrl(priv, 0);
 }
 
+/*
+ *             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
  */
index 7822b0b8aeed2483379200876235906ee9357f62..0e867a33a46ed9dac521ab863eae11e61ed61223 100644 (file)
@@ -90,6 +90,17 @@ struct usbhs_priv;
 #define PIPE9TRN       0x00BA
 #define PIPEATRE       0x00BC
 #define PIPEATRN       0x00BE
+#define DEVADD0                0x00D0 /* Device address n configuration */
+#define DEVADD1                0x00D2
+#define DEVADD2                0x00D4
+#define DEVADD3                0x00D6
+#define DEVADD4                0x00D8
+#define DEVADD5                0x00DA
+#define DEVADD6                0x00DC
+#define DEVADD7                0x00DE
+#define DEVADD8                0x00E0
+#define DEVADD9                0x00E2
+#define DEVADDA                0x00E4
 
 /* SYSCFG */
 #define SCKE   (1 << 10)       /* USB Module Clock Enable */
@@ -206,6 +217,14 @@ struct usbhs_priv;
 /* FRMNUM */
 #define FRNM_MASK      (0x7FF)
 
+/* DEVADDn */
+#define UPPHUB(x)      (((x) & 0xF) << 11)     /* HUB Register */
+#define HUBPORT(x)     (((x) & 0x7) << 8)      /* HUB Port for Target Device */
+#define USBSPD(x)      (((x) & 0x3) << 6)      /* Device Transfer Rate */
+#define USBSPD_SPEED_LOW       0x1
+#define USBSPD_SPEED_FULL      0x2
+#define USBSPD_SPEED_HIGH      0x3
+
 /*
  *             struct
  */
@@ -280,6 +299,12 @@ int usbhs_vbus_ctrl(struct usbhs_priv *priv, int enable);
  */
 int usbhs_frame_get_num(struct usbhs_priv *priv);
 
+/*
+ * device config
+ */
+int usbhs_set_device_speed(struct usbhs_priv *priv, int devnum, u16 upphub,
+                          u16 hubport, u16 speed);
+
 /*
  * data
  */