All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: dwc3: gadget: Check for disabled LPM quirk
@ 2021-04-14  1:36 Thinh Nguyen
  2021-04-14  2:13 ` [PATCH v2 0/2] usb: dwc3: gadget: Add disabling LPM option Thinh Nguyen
  2021-04-14  9:36 ` [PATCH] " Felipe Balbi
  0 siblings, 2 replies; 7+ messages in thread
From: Thinh Nguyen @ 2021-04-14  1:36 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, linux-usb; +Cc: John Youn

If the device doesn't support LPM, make sure to disable the LPM
capability and don't advertise to the host that it supports it.

Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
---
 drivers/usb/dwc3/gadget.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index e1b04c976da5..509f01b1d830 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -3484,6 +3484,7 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc)
 	/* Enable USB2 LPM Capability */
 
 	if (!DWC3_VER_IS_WITHIN(DWC3, ANY, 194A) &&
+	    !dwc->usb2_lpm_disable &&
 	    (speed != DWC3_DSTS_SUPERSPEED) &&
 	    (speed != DWC3_DSTS_SUPERSPEED_PLUS)) {
 		reg = dwc3_readl(dwc->regs, DWC3_DCFG);
@@ -3510,6 +3511,12 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc)
 
 		dwc3_gadget_dctl_write_safe(dwc, reg);
 	} else {
+		if (dwc->usb2_lpm_disable) {
+			reg = dwc3_readl(dwc->regs, DWC3_DCFG);
+			reg &= ~DWC3_DCFG_LPM_CAP;
+			dwc3_writel(dwc->regs, DWC3_DCFG, reg);
+		}
+
 		reg = dwc3_readl(dwc->regs, DWC3_DCTL);
 		reg &= ~DWC3_DCTL_HIRD_THRES_MASK;
 		dwc3_gadget_dctl_write_safe(dwc, reg);
@@ -3958,7 +3965,7 @@ int dwc3_gadget_init(struct dwc3 *dwc)
 	dwc->gadget->ssp_rate		= USB_SSP_GEN_UNKNOWN;
 	dwc->gadget->sg_supported	= true;
 	dwc->gadget->name		= "dwc3-gadget";
-	dwc->gadget->lpm_capable	= true;
+	dwc->gadget->lpm_capable	= !dwc->usb2_lpm_disable;
 
 	/*
 	 * FIXME We might be setting max_speed to <SUPER, however versions

base-commit: 401411bbc4e62bcbcc020c2c458ecb90843140a8
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-04-15 21:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-14  1:36 [PATCH] usb: dwc3: gadget: Check for disabled LPM quirk Thinh Nguyen
2021-04-14  2:13 ` [PATCH v2 0/2] usb: dwc3: gadget: Add disabling LPM option Thinh Nguyen
2021-04-14  2:13   ` [PATCH v2 1/2] dt-bindings: usb: dwc3: Add disabling LPM for gadget Thinh Nguyen
2021-04-15 21:18     ` Rob Herring
2021-04-14  2:13   ` [PATCH v2 2/2] usb: dwc3: gadget: Check for disabled LPM quirk Thinh Nguyen
2021-04-14  9:37     ` Felipe Balbi
2021-04-14  9:36 ` [PATCH] " Felipe Balbi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.