ARM:LPC313X:Fixing USB Gadget zero driver test failure
authorBangaragiri G <bangaragiri.g@nxp.com>
Thu, 3 Mar 2011 03:56:35 +0000 (08:56 +0530)
committerBangaragiri G <bangaragiri.g@nxp.com>
Thu, 3 Mar 2011 03:56:35 +0000 (08:56 +0530)
This patch fixes the Linux USB Tests using Gadget zero driver.
The BULK OUT transfers, Control transfers and Halt tests are
failing. This patch fixes these issues.

Signed-off-by: Bangaragiri G <bangaragiri.g@nxp.com>

drivers/usb/gadget/fsl_udc_core.c

index aad424b..9b2547c 100644 (file)
@@ -441,9 +441,9 @@ static void ep0_setup(struct fsl_udc *udc)
        /* the intialization of an ep includes: fields in QH, Regs,
         * fsl_ep struct */
        struct_ep_qh_setup(udc, 0, USB_RECV, USB_ENDPOINT_XFER_CONTROL,
-                       USB_MAX_CTRL_PAYLOAD, 0, 0);
+                       USB_MAX_CTRL_PAYLOAD, 1, 0);
        struct_ep_qh_setup(udc, 0, USB_SEND, USB_ENDPOINT_XFER_CONTROL,
-                       USB_MAX_CTRL_PAYLOAD, 0, 0);
+                       USB_MAX_CTRL_PAYLOAD, 1, 0);
        dr_ep_setup(0, USB_RECV, USB_ENDPOINT_XFER_CONTROL);
        dr_ep_setup(0, USB_SEND, USB_ENDPOINT_XFER_CONTROL);
 
@@ -470,6 +470,7 @@ static int fsl_ep_enable(struct usb_ep *_ep,
        unsigned char mult = 0, zlt;
        int retval = -EINVAL;
        unsigned long flags = 0;
+       unsigned char dir = 0;
 
        ep = container_of(_ep, struct fsl_ep, ep);
 
@@ -521,17 +522,20 @@ static int fsl_ep_enable(struct usb_ep *_ep,
        /* Controller related setup */
        /* Init EPx Queue Head (Ep Capabilites field in QH
         * according to max, zlt, mult) */
-       struct_ep_qh_setup(udc, (unsigned char) ep_index(ep),
-                       (unsigned char) ((desc->bEndpointAddress & USB_DIR_IN)
-                                       ?  USB_SEND : USB_RECV),
+       dir = (unsigned char) ((desc->bEndpointAddress & USB_DIR_IN)
+                                 ? USB_SEND : USB_RECV);
+       struct_ep_qh_setup(udc, (unsigned char) ep_index(ep), dir,
                        (unsigned char) (desc->bmAttributes
                                        & USB_ENDPOINT_XFERTYPE_MASK),
                        max, zlt, mult);
 
+       /* Clear endpoint stall if set */
+       if(dr_ep_get_stall((unsigned char) ep_index(ep), dir)) {
+               dr_ep_change_stall((unsigned char) ep_index(ep), dir, 0);
+       }
+
        /* Init endpoint ctrl register */
-       dr_ep_setup((unsigned char) ep_index(ep),
-                       (unsigned char) ((desc->bEndpointAddress & USB_DIR_IN)
-                                       ? USB_SEND : USB_RECV),
+       dr_ep_setup((unsigned char) ep_index(ep), dir,
                        (unsigned char) (desc->bmAttributes
                                        & USB_ENDPOINT_XFERTYPE_MASK));
 
@@ -1308,15 +1312,20 @@ static void setup_received_irq(struct fsl_udc *udc,
                                == (USB_RECIP_ENDPOINT | USB_TYPE_STANDARD)) {
                        int pipe = get_pipe_by_windex(wIndex);
                        struct fsl_ep *ep;
+                       unsigned long flags = 0;
 
                        if (wValue != 0 || wLength != 0 || pipe > udc->max_ep)
                                break;
                        ep = get_ep_by_pipe(udc, pipe);
 
                        spin_unlock(&udc->lock);
-                       rc = fsl_ep_set_halt(&ep->ep,
-                                       (setup->bRequest == USB_REQ_SET_FEATURE)
-                                               ? 1 : 0);
+                       spin_lock_irqsave(&ep->udc->lock, flags);
+                       dr_ep_change_stall((unsigned char)(ep_index(ep)),
+                                       (ep_is_in(ep) ? USB_SEND : USB_RECV),
+                                       ((setup->bRequest == USB_REQ_SET_FEATURE)
+                                                    ? 1 : 0));
+                       rc = 0;
+                       spin_unlock_irqrestore(&ep->udc->lock, flags);
                        spin_lock(&udc->lock);
 
                } else if ((setup->bRequestType & (USB_RECIP_MASK