usb: musb: gadget: use platform callback to enable vbus
[pandora-kernel.git] / drivers / usb / musb / musb_gadget.c
index 922148f..9be7c79 100644 (file)
@@ -576,6 +576,15 @@ void musb_g_tx(struct musb *musb, u8 epnum)
 
                if (request->actual == request->length) {
                        musb_g_giveback(musb_ep, request, 0);
+                       /*
+                        * In the giveback function the MUSB lock is
+                        * released and acquired after sometime. During
+                        * this time period the INDEX register could get
+                        * changed by the gadget_queue function especially
+                        * on SMP systems. Reselect the INDEX to be sure
+                        * we are reading/modifying the right registers
+                        */
+                       musb_ep_select(mbase, epnum);
                        req = musb_ep->desc ? next_request(musb_ep) : NULL;
                        if (!req) {
                                dev_dbg(musb->controller, "%s idle now\n",
@@ -985,6 +994,15 @@ void musb_g_rx(struct musb *musb, u8 epnum)
                }
 #endif
                musb_g_giveback(musb_ep, request, 0);
+               /*
+                * In the giveback function the MUSB lock is
+                * released and acquired after sometime. During
+                * this time period the INDEX register could get
+                * changed by the gadget_queue function especially
+                * on SMP systems. Reselect the INDEX to be sure
+                * we are reading/modifying the right registers
+                */
+               musb_ep_select(mbase, epnum);
 
                req = next_request(musb_ep);
                if (!req)
@@ -1216,6 +1234,7 @@ static int musb_gadget_disable(struct usb_ep *ep)
        }
 
        musb_ep->desc = NULL;
+       musb_ep->end_point.desc = NULL;
 
        /* abort all pending DMA and requests */
        nuke(musb_ep, -ESHUTDOWN);
@@ -1946,9 +1965,8 @@ static int musb_gadget_start(struct usb_gadget *g,
                        goto err2;
                }
 
-               if ((musb->xceiv->last_event == USB_EVENT_ID)
-                                       && musb->xceiv->set_vbus)
-                       otg_set_vbus(musb->xceiv, 1);
+               if (musb->xceiv->last_event == USB_EVENT_ID)
+                       musb_platform_set_vbus(musb, 1);
 
                hcd->self.uses_pio_for_control = 1;
        }
@@ -2035,6 +2053,7 @@ static int musb_gadget_stop(struct usb_gadget *g,
        dev_dbg(musb->controller, "unregistering driver %s\n", driver->function);
 
        musb->is_active = 0;
+       musb->gadget_driver = NULL;
        musb_platform_try_idle(musb, 0);
        spin_unlock_irqrestore(&musb->lock, flags);