Skip to content

Commit d75a2ff

Browse files
P33Mpelwell
authored andcommitted
usb: dwc2: return correct frame counts with high-speed host
The HFNUM register increments on every microframe in HS mode, and USB device drivers expect the returned frame count to relate to the overall frame. Right-shift the returned value by 3 to drop the microframe bits. Signed-off-by: Jonathan Bell <[email protected]>
1 parent 781f2e0 commit d75a2ff

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drivers/usb/dwc2/hcd.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3800,12 +3800,17 @@ static int dwc2_hcd_is_status_changed(struct dwc2_hsotg *hsotg, int port)
38003800
int dwc2_hcd_get_frame_number(struct dwc2_hsotg *hsotg)
38013801
{
38023802
u32 hfnum = dwc2_readl(hsotg, HFNUM);
3803+
u32 hprt0 = dwc2_readl(hsotg, HPRT0);
38033804

38043805
#ifdef DWC2_DEBUG_SOF
38053806
dev_vdbg(hsotg->dev, "DWC OTG HCD GET FRAME NUMBER %d\n",
38063807
(hfnum & HFNUM_FRNUM_MASK) >> HFNUM_FRNUM_SHIFT);
38073808
#endif
3808-
return (hfnum & HFNUM_FRNUM_MASK) >> HFNUM_FRNUM_SHIFT;
3809+
/* HS root port counts microframes, not frames */
3810+
if ((hprt0 & HPRT0_SPD_MASK) >> HPRT0_SPD_SHIFT == HPRT0_SPD_HIGH_SPEED)
3811+
return (hfnum & HFNUM_FRNUM_MASK) >> (3 + HFNUM_FRNUM_SHIFT);
3812+
else
3813+
return (hfnum & HFNUM_FRNUM_MASK) >> HFNUM_FRNUM_SHIFT;
38093814
}
38103815

38113816
int dwc2_hcd_get_future_frame_number(struct dwc2_hsotg *hsotg, int us)

0 commit comments

Comments
 (0)