Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 97861781 authored by Vardan Mikayelyan's avatar Vardan Mikayelyan Committed by Felipe Balbi
Browse files

usb: dwc2: Allow entering hibernation from USB_SUSPEND interrupt



Do changes to allow entering hibernated state from USB_SUSPEND
interrupt. All code is added under if conditions and mustn't impact
existing functionality.

Signed-off-by: default avatarVardan Mikayelyan <mvardan@synopsys.com>
Signed-off-by: default avatarJohn Youn <johnyoun@synopsys.com>
Signed-off-by: default avatarGrigor Tovmasyan <tovmasya@synopsys.com>
Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
parent 624815ce
Loading
Loading
Loading
Loading
+32 −20
Original line number Original line Diff line number Diff line
@@ -484,24 +484,27 @@ static void dwc2_handle_usb_suspend_intr(struct dwc2_hsotg *hsotg)
		 * state is active
		 * state is active
		 */
		 */
		dsts = dwc2_readl(hsotg->regs + DSTS);
		dsts = dwc2_readl(hsotg->regs + DSTS);
		dev_dbg(hsotg->dev, "DSTS=0x%0x\n", dsts);
		dev_dbg(hsotg->dev, "%s: DSTS=0x%0x\n", __func__, dsts);
		dev_dbg(hsotg->dev,
		dev_dbg(hsotg->dev,
			"DSTS.Suspend Status=%d HWCFG4.Power Optimize=%d\n",
			"DSTS.Suspend Status=%d HWCFG4.Power Optimize=%d HWCFG4.Hibernation=%d\n",
			!!(dsts & DSTS_SUSPSTS),
			!!(dsts & DSTS_SUSPSTS),
			hsotg->hw_params.power_optimized);
			hsotg->hw_params.power_optimized,
		if ((dsts & DSTS_SUSPSTS) && hsotg->hw_params.power_optimized) {
			hsotg->hw_params.hibernation);

		/* Ignore suspend request before enumeration */
		/* Ignore suspend request before enumeration */
		if (!dwc2_is_device_connected(hsotg)) {
		if (!dwc2_is_device_connected(hsotg)) {
			dev_dbg(hsotg->dev,
			dev_dbg(hsotg->dev,
				"ignore suspend request before enumeration\n");
				"ignore suspend request before enumeration\n");
			return;
			return;
		}
		}

		if (dsts & DSTS_SUSPSTS) {
			if (hsotg->hw_params.power_optimized) {
				ret = dwc2_enter_partial_power_down(hsotg);
				ret = dwc2_enter_partial_power_down(hsotg);
				if (ret) {
				if (ret) {
					if (ret != -ENOTSUPP)
					if (ret != -ENOTSUPP)
						dev_err(hsotg->dev,
						dev_err(hsotg->dev,
						"enter power_down failed\n");
							"%s: enter partial_power_down failed\n",
							__func__);
					goto skip_power_saving;
					goto skip_power_saving;
				}
				}


@@ -510,6 +513,15 @@ static void dwc2_handle_usb_suspend_intr(struct dwc2_hsotg *hsotg)
				/* Ask phy to be suspended */
				/* Ask phy to be suspended */
				if (!IS_ERR_OR_NULL(hsotg->uphy))
				if (!IS_ERR_OR_NULL(hsotg->uphy))
					usb_phy_set_suspend(hsotg->uphy, true);
					usb_phy_set_suspend(hsotg->uphy, true);
			}

			if (hsotg->hw_params.hibernation) {
				ret = dwc2_enter_hibernation(hsotg, 0);
				if (ret && ret != -ENOTSUPP)
					dev_err(hsotg->dev,
						"%s: enter hibernation failed\n",
						__func__);
			}
skip_power_saving:
skip_power_saving:
			/*
			/*
			 * Change to L2 (suspend) state before releasing
			 * Change to L2 (suspend) state before releasing