Message ID | 1b784826dfee46adaa65c42d33934339d0c1f2a7.1618364095.git.Thinh.Nguyen@synopsys.com |
---|---|
State | New |
Headers | show |
Series | usb: dwc3: gadget: Check for disabled LPM quirk | expand |
Add a new option to disable LPM for gadget side. Some device may need to disable this capability. Changes in v2: - Add cover letter - Add new DT property for disabling LPM for gadget Thinh Nguyen (2): dt-bindings: usb: dwc3: Add disabling LPM for gadget usb: dwc3: gadget: Check for disabled LPM quirk Documentation/devicetree/bindings/usb/snps,dwc3.yaml | 8 +++++++- drivers/usb/dwc3/core.c | 2 ++ drivers/usb/dwc3/core.h | 4 +++- drivers/usb/dwc3/gadget.c | 9 ++++++++- 4 files changed, 20 insertions(+), 3 deletions(-) base-commit: 401411bbc4e62bcbcc020c2c458ecb90843140a8
Thinh Nguyen <Thinh.Nguyen@synopsys.com> writes: > 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> Acked-by: Felipe Balbi <balbi@kernel.org>
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
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(-) base-commit: 401411bbc4e62bcbcc020c2c458ecb90843140a8