usb: dwc3: gadget: only resume USB2 PHY in <=HIGHSPEED
authorFelipe Balbi <felipe.balbi@linux.intel.com>
Tue, 17 May 2016 11:55:58 +0000 (14:55 +0300)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Mon, 20 Jun 2016 09:32:37 +0000 (12:32 +0300)
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 <felipe.balbi@linux.intel.com>
drivers/usb/dwc3/gadget.c

index 378c14c45fcbb37993bc3ce5815323bb57568dd7..5e7b2ba8312bf07c3cb2017503ed5db2fe963387 100644 (file)
@@ -258,11 +258,13 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned cmd,
         * 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);
+               }
        }
 
        if (cmd == DWC3_DEPCMD_STARTTRANSFER) {