]> git.karo-electronics.de Git - linux-beck.git/commitdiff
usb: gadget: renesas_usbhs: add usbhs_bus_get_speed()
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tue, 11 Oct 2011 05:01:51 +0000 (22:01 -0700)
committerFelipe Balbi <balbi@ti.com>
Thu, 13 Oct 2011 17:41:38 +0000 (20:41 +0300)
current mod_gadget had got usb speed on
usbhsg_irq_dev_state() which is status change interrupt callback function.
And the usb speed data was included in its parameter.

But this style works for mod_gadget,
but doesn't work for mod_host which
isn't interrupted when device status was changed.

This patch add usbhs_bus_get_speed() to solve this issue.

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
drivers/usb/renesas_usbhs/mod.c
drivers/usb/renesas_usbhs/mod.h
drivers/usb/renesas_usbhs/mod_gadget.c

index 243512d93e588ae320a9cbd0688ec66c2604f453..17abdfe53067b49c729e7d392d7e294cb5a11616 100644 (file)
@@ -159,6 +159,22 @@ void usbhs_bus_send_reset(struct usbhs_priv *priv)
        usbhs_bset(priv, DVSTCTR, (USBRST | UACT), USBRST);
 }
 
+int usbhs_bus_get_speed(struct usbhs_priv *priv)
+{
+       u16 dvstctr = usbhs_read(priv, DVSTCTR);
+
+       switch (RHST & dvstctr) {
+       case RHST_LOW_SPEED:
+               return USB_SPEED_LOW;
+       case RHST_FULL_SPEED:
+               return USB_SPEED_FULL;
+       case RHST_HIGH_SPEED:
+               return USB_SPEED_HIGH;
+       }
+
+       return USB_SPEED_UNKNOWN;
+}
+
 int usbhs_vbus_ctrl(struct usbhs_priv *priv, int enable)
 {
        struct platform_device *pdev = usbhs_priv_to_pdev(priv);
index 54b5924baae7f67719f44523c4cb20f884609df1..a5cef816010785e1f191285e6b07c527a0cdc488 100644 (file)
@@ -264,6 +264,7 @@ void usbhs_sys_function_ctrl(struct usbhs_priv *priv, int enable);
  */
 void usbhs_bus_send_sof_enable(struct usbhs_priv *priv);
 void usbhs_bus_send_reset(struct usbhs_priv *priv);
+int usbhs_bus_get_speed(struct usbhs_priv *priv);
 int usbhs_vbus_ctrl(struct usbhs_priv *priv, int enable);
 
 /*
index 74ef49e7dd5fe1dd041cc44896439decb0a52ee8..ab1203098931cc43e9ab7f1899fbe61c5800b115 100644 (file)
@@ -168,20 +168,6 @@ void usbhs_mod_remove(struct usbhs_priv *priv)
 /*
  *             status functions
  */
-int usbhs_status_get_usb_speed(struct usbhs_irq_state *irq_state)
-{
-       switch (irq_state->dvstctr & RHST) {
-       case RHST_LOW_SPEED:
-               return USB_SPEED_LOW;
-       case RHST_FULL_SPEED:
-               return USB_SPEED_FULL;
-       case RHST_HIGH_SPEED:
-               return USB_SPEED_HIGH;
-       }
-
-       return USB_SPEED_UNKNOWN;
-}
-
 int usbhs_status_get_device_state(struct usbhs_irq_state *irq_state)
 {
        int state = irq_state->intsts0 & DVSQ_MASK;
@@ -221,8 +207,6 @@ static void usbhs_status_get_each_irq(struct usbhs_priv *priv,
        state->intsts0 = usbhs_read(priv, INTSTS0);
        state->intsts1 = usbhs_read(priv, INTSTS1);
 
-       state->dvstctr = usbhs_read(priv, DVSTCTR);
-
        /* mask */
        if (mod) {
                state->brdysts = usbhs_read(priv, BRDYSTS);
index 5c845a28a21ca951be378b4f04425fc3e5ce36c0..93edb1f29eb044efc5c604241b54d7d1111141e1 100644 (file)
@@ -30,7 +30,6 @@ struct usbhs_irq_state {
        u16 brdysts;
        u16 nrdysts;
        u16 bempsts;
-       u16 dvstctr;
 };
 
 struct usbhs_mod {
@@ -99,7 +98,6 @@ void usbhs_mod_autonomy_mode(struct usbhs_priv *priv);
 /*
  *             status functions
  */
-int usbhs_status_get_usb_speed(struct usbhs_irq_state *irq_state);
 int usbhs_status_get_device_state(struct usbhs_irq_state *irq_state);
 int usbhs_status_get_ctrl_stage(struct usbhs_irq_state *irq_state);
 
index babd90c979c1bceafa295495ced0169a094eb3a8..ae7d816c23d9d9ce571588b788514458ccef4656 100644 (file)
@@ -353,7 +353,7 @@ static int usbhsg_irq_dev_state(struct usbhs_priv *priv,
        struct usbhsg_gpriv *gpriv = usbhsg_priv_to_gpriv(priv);
        struct device *dev = usbhsg_gpriv_to_dev(gpriv);
 
-       gpriv->gadget.speed = usbhs_status_get_usb_speed(irq_state);
+       gpriv->gadget.speed = usbhs_bus_get_speed(priv);
 
        dev_dbg(dev, "state = %x : speed : %d\n",
                usbhs_status_get_device_state(irq_state),