Skip to content

Commit 01ea6bf

Browse files
andredgregkh
authored andcommitted
usb: dwc3: gadget: fix writing NYET threshold
Before writing a new value to the register, the old value needs to be masked out for the new value to be programmed as intended, because at least in some cases the reset value of that field is 0xf (max value). At the moment, the dwc3 core initialises the threshold to the maximum value (0xf), with the option to override it via a DT. No upstream DTs seem to override it, therefore this commit doesn't change behaviour for any upstream platform. Nevertheless, the code should be fixed to have the desired outcome. Do so. Fixes: 80caf7d ("usb: dwc3: add lpm erratum support") Cc: [email protected] # 5.10+ (needs adjustment for 5.4) Signed-off-by: André Draszik <[email protected]> Acked-by: Thinh Nguyen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 4bbf902 commit 01ea6bf

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

drivers/usb/dwc3/core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@
464464
#define DWC3_DCTL_TRGTULST_SS_INACT (DWC3_DCTL_TRGTULST(6))
465465

466466
/* These apply for core versions 1.94a and later */
467+
#define DWC3_DCTL_NYET_THRES_MASK (0xf << 20)
467468
#define DWC3_DCTL_NYET_THRES(n) (((n) & 0xf) << 20)
468469

469470
#define DWC3_DCTL_KEEP_CONNECT BIT(19)

drivers/usb/dwc3/gadget.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4195,8 +4195,10 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc)
41954195
WARN_ONCE(DWC3_VER_IS_PRIOR(DWC3, 240A) && dwc->has_lpm_erratum,
41964196
"LPM Erratum not available on dwc3 revisions < 2.40a\n");
41974197

4198-
if (dwc->has_lpm_erratum && !DWC3_VER_IS_PRIOR(DWC3, 240A))
4198+
if (dwc->has_lpm_erratum && !DWC3_VER_IS_PRIOR(DWC3, 240A)) {
4199+
reg &= ~DWC3_DCTL_NYET_THRES_MASK;
41994200
reg |= DWC3_DCTL_NYET_THRES(dwc->lpm_nyet_threshold);
4201+
}
42004202

42014203
dwc3_gadget_dctl_write_safe(dwc, reg);
42024204
} else {

0 commit comments

Comments
 (0)