diff options
author | Vardan Mikayelyan <mvardan@synopsys.com> | 2016-05-25 21:07:05 -0400 |
---|---|---|
committer | Felipe Balbi <felipe.balbi@linux.intel.com> | 2016-06-21 03:49:21 -0400 |
commit | 92d1635d781ac17fc7d886b0c126838083f3c2b9 (patch) | |
tree | 3ac16508dc525f1eb41fd4114a848ebe350de8c5 /drivers/usb/dwc2 | |
parent | 6b58cb07a850f9b6d348feb2455b2c264a515f4a (diff) |
usb: dwc2: gadget: Add dwc2_gadget_incr_frame_num()
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
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>
Diffstat (limited to 'drivers/usb/dwc2')
-rw-r--r-- | drivers/usb/dwc2/core.h | 5 | ||||
-rw-r--r-- | drivers/usb/dwc2/gadget.c | 19 |
2 files changed, 24 insertions, 0 deletions
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index dec0b21fc626..55160992b181 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h | |||
@@ -177,6 +177,8 @@ struct dwc2_hsotg_req; | |||
177 | * @fifo_load: The amount of data loaded into the FIFO (periodic IN) | 177 | * @fifo_load: The amount of data loaded into the FIFO (periodic IN) |
178 | * @last_load: The offset of data for the last start of request. | 178 | * @last_load: The offset of data for the last start of request. |
179 | * @size_loaded: The last loaded size for DxEPTSIZE for periodic IN | 179 | * @size_loaded: The last loaded size for DxEPTSIZE for periodic IN |
180 | * @target_frame: Targeted frame num to setup next ISOC transfer | ||
181 | * @frame_overrun: Indicates SOF number overrun in DSTS | ||
180 | * | 182 | * |
181 | * This is the driver's state for each registered enpoint, allowing it | 183 | * This is the driver's state for each registered enpoint, allowing it |
182 | * to keep track of transactions that need doing. Each endpoint has a | 184 | * to keep track of transactions that need doing. Each endpoint has a |
@@ -214,6 +216,9 @@ struct dwc2_hsotg_ep { | |||
214 | unsigned int isochronous:1; | 216 | unsigned int isochronous:1; |
215 | unsigned int send_zlp:1; | 217 | unsigned int send_zlp:1; |
216 | unsigned int has_correct_parity:1; | 218 | unsigned int has_correct_parity:1; |
219 | unsigned int target_frame; | ||
220 | #define TARGET_FRAME_INITIAL 0xFFFFFFFF | ||
221 | bool frame_overrun; | ||
217 | 222 | ||
218 | char name[10]; | 223 | char name[10]; |
219 | }; | 224 | }; |
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 54d242b6d2aa..b8f3661771f0 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c | |||
@@ -97,6 +97,25 @@ static inline bool using_dma(struct dwc2_hsotg *hsotg) | |||
97 | } | 97 | } |
98 | 98 | ||
99 | /** | 99 | /** |
100 | * dwc2_gadget_incr_frame_num - Increments the targeted frame number. | ||
101 | * @hs_ep: The endpoint | ||
102 | * @increment: The value to increment by | ||
103 | * | ||
104 | * This function will also check if the frame number overruns DSTS_SOFFN_LIMIT. | ||
105 | * If an overrun occurs it will wrap the value and set the frame_overrun flag. | ||
106 | */ | ||
107 | static inline void dwc2_gadget_incr_frame_num(struct dwc2_hsotg_ep *hs_ep) | ||
108 | { | ||
109 | hs_ep->target_frame += hs_ep->interval; | ||
110 | if (hs_ep->target_frame > DSTS_SOFFN_LIMIT) { | ||
111 | hs_ep->frame_overrun = 1; | ||
112 | hs_ep->target_frame &= DSTS_SOFFN_LIMIT; | ||
113 | } else { | ||
114 | hs_ep->frame_overrun = 0; | ||
115 | } | ||
116 | } | ||
117 | |||
118 | /** | ||
100 | * dwc2_hsotg_en_gsint - enable one or more of the general interrupt | 119 | * dwc2_hsotg_en_gsint - enable one or more of the general interrupt |
101 | * @hsotg: The device state | 120 | * @hsotg: The device state |
102 | * @ints: A bitmask of the interrupts to enable | 121 | * @ints: A bitmask of the interrupts to enable |