UPSTREAM: usb: dwc2: gadget: Corrected interval calculation
authorVardan Mikayelyan <mvardan@synopsys.com>
Thu, 26 May 2016 01:07:07 +0000 (18:07 -0700)
committerHuang, Tao <huangtao@rock-chips.com>
Tue, 3 Jan 2017 10:48:44 +0000 (18:48 +0800)
Calculate the interval according to the USB 2.0 specification section
9.6.6.

Change-Id: I918faedbaa22d0151d48ed45907baf71f000c831
Tested-by: John Keeping <john@metanate.com>
Signed-off-by: Vardan Mikayelyan <mvardan@synopsys.com>
Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit 142bd33fcd185d850178f7f8697ecbeaaa18e257)

drivers/usb/dwc2/core.h
drivers/usb/dwc2/gadget.c

index 6fc9fb7f619a599e953feb704437122f34a1e1b9..035a26c174b5f06f4d7d227b4d7e1356fdbc4bee 100644 (file)
@@ -166,7 +166,7 @@ struct dwc2_hsotg_req;
  *          means that it is sending data to the Host.
  * @index: The index for the endpoint registers.
  * @mc: Multi Count - number of transactions per microframe
- * @interval - Interval for periodic endpoints
+ * @interval - Interval for periodic endpoints, in frames or microframes.
  * @name: The name array passed to the USB core.
  * @halted: Set if the endpoint has been halted.
  * @periodic: Set if this is a periodic ep, such as Interrupt
index b8f3661771f025f5e3e039cdf268e5f830c29268..2cef7a9cb527300478dadc5fbb02d7f46d4ef02e 100644 (file)
@@ -2693,16 +2693,13 @@ static int dwc2_hsotg_ep_enable(struct usb_ep *ep,
        hs_ep->periodic = 0;
        hs_ep->halted = 0;
        hs_ep->interval = desc->bInterval;
-       hs_ep->has_correct_parity = 0;
-
-       if (hs_ep->interval > 1 && hs_ep->mc > 1)
-               dev_err(hsotg->dev, "MC > 1 when interval is not 1\n");
 
        switch (desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) {
        case USB_ENDPOINT_XFER_ISOC:
                epctrl |= DXEPCTL_EPTYPE_ISO;
                epctrl |= DXEPCTL_SETEVENFR;
                hs_ep->isochronous = 1;
+               hs_ep->interval = 1 << (desc->bInterval - 1);
                if (dir_in)
                        hs_ep->periodic = 1;
                break;
@@ -2715,6 +2712,9 @@ static int dwc2_hsotg_ep_enable(struct usb_ep *ep,
                if (dir_in)
                        hs_ep->periodic = 1;
 
+               if (hsotg->gadget.speed == USB_SPEED_HIGH)
+                       hs_ep->interval = 1 << (desc->bInterval - 1);
+
                epctrl |= DXEPCTL_EPTYPE_INTERRUPT;
                break;