From: Felipe Balbi Date: Fri, 12 Apr 2024 20:26:03 +0000 (+0200) Subject: usb: dwc3: gadget: only resume USB2 PHY in <=HIGHSPEED X-Git-Url: http://git.dujemihanovic.xyz/img/static/git-logo.png?a=commitdiff_plain;h=d107a5319e20d5e5be3bd8fa298aeca9ef4990a0;p=u-boot.git usb: dwc3: gadget: only resume USB2 PHY in <=HIGHSPEED Upstream Linux commit ab2a92e7a608. As a micro-power optimization, let's only resume the USB2 PHY if we're working on <=HIGHSPEED. If we're gonna work on SUPERSPEED or SUPERSPEED+, there's no point in resuming the USB2 PHY. Fixes: 2b0f11df84bb ("usb: dwc3: gadget: clear SUSPHY bit before ep cmds") Signed-off-by: Felipe Balbi Signed-off-by: Alexander Sverdlin Reviewed-by: Mattijs Korpershoek Link: https://lore.kernel.org/r/20240412202611.3565052-4-alexander.sverdlin@siemens.com Signed-off-by: Mattijs Korpershoek --- diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 06a29ed864..bcd55a7d27 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -313,11 +313,13 @@ int dwc3_send_gadget_ep_cmd(struct dwc3 *dwc, unsigned ep, * We will also set SUSPHY bit to what it was before returning as stated * by the same section on Synopsys databook. */ - reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)); - if (unlikely(reg & DWC3_GUSB2PHYCFG_SUSPHY)) { - susphy = true; - reg &= ~DWC3_GUSB2PHYCFG_SUSPHY; - dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); + if (dwc->gadget.speed <= USB_SPEED_HIGH) { + reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)); + if (unlikely(reg & DWC3_GUSB2PHYCFG_SUSPHY)) { + susphy = true; + reg &= ~DWC3_GUSB2PHYCFG_SUSPHY; + dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); + } } dwc3_writel(dwc->regs, DWC3_DEPCMDPAR0(ep), params->param0);