UPSTREAM: usb: dwc2: gadget: Add dwc2_gadget_incr_frame_num()
authorVardan Mikayelyan <mvardan@synopsys.com>
Thu, 26 May 2016 01:07:05 +0000 (18:07 -0700)
committerHuang, Tao <huangtao@rock-chips.com>
Tue, 3 Jan 2017 10:48:43 +0000 (18:48 +0800)
Increases and checks targeted frame number of current ep
if overrun happened, sets flag and masks with DSTS_SOFFN_LIMIT

Added following fields to struct dwc2_hsotg_ep
-target_frame: Targeted frame num to setup next ISOC transfer
-frame_overrun: Indicates SOF number overrun in DSTS

Change-Id: I80c0bc7bfe18e4e88b051795486c1cfccaa95b42
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 92d1635d781ac17fc7d886b0c126838083f3c2b9)

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

index 348a11d45b5a178399bce5c4483900cb1b4d0be5..6fc9fb7f619a599e953feb704437122f34a1e1b9 100644 (file)
@@ -177,6 +177,8 @@ struct dwc2_hsotg_req;
  * @fifo_load: The amount of data loaded into the FIFO (periodic IN)
  * @last_load: The offset of data for the last start of request.
  * @size_loaded: The last loaded size for DxEPTSIZE for periodic IN
+ * @target_frame: Targeted frame num to setup next ISOC transfer
+ * @frame_overrun: Indicates SOF number overrun in DSTS
  *
  * This is the driver's state for each registered enpoint, allowing it
  * to keep track of transactions that need doing. Each endpoint has a
@@ -214,6 +216,9 @@ struct dwc2_hsotg_ep {
        unsigned int            isochronous:1;
        unsigned int            send_zlp:1;
        unsigned int            has_correct_parity:1;
+       unsigned int            target_frame;
+#define TARGET_FRAME_INITIAL   0xFFFFFFFF
+       bool                    frame_overrun;
 
        char                    name[10];
 };
index 54d242b6d2aa6728bf001e2da668e7d8a995468e..b8f3661771f025f5e3e039cdf268e5f830c29268 100644 (file)
@@ -96,6 +96,25 @@ static inline bool using_dma(struct dwc2_hsotg *hsotg)
        return hsotg->g_using_dma;
 }
 
+/**
+ * dwc2_gadget_incr_frame_num - Increments the targeted frame number.
+ * @hs_ep: The endpoint
+ * @increment: The value to increment by
+ *
+ * This function will also check if the frame number overruns DSTS_SOFFN_LIMIT.
+ * If an overrun occurs it will wrap the value and set the frame_overrun flag.
+ */
+static inline void dwc2_gadget_incr_frame_num(struct dwc2_hsotg_ep *hs_ep)
+{
+       hs_ep->target_frame += hs_ep->interval;
+       if (hs_ep->target_frame > DSTS_SOFFN_LIMIT) {
+               hs_ep->frame_overrun = 1;
+               hs_ep->target_frame &= DSTS_SOFFN_LIMIT;
+       } else {
+               hs_ep->frame_overrun = 0;
+       }
+}
+
 /**
  * dwc2_hsotg_en_gsint - enable one or more of the general interrupt
  * @hsotg: The device state