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

Commit 4b47e531 authored by Mayank Rana's avatar Mayank Rana
Browse files

usb: dwc3: Add support to defer suspend after USB LPM



On USB cable disconnect, it is expected to receiv SUSPEND event
followed DISCONNCET event. In both cases, USB is put into LPM
with different power rails turned-off and allowing system suspend
functionality. It is required to defer system suspend till both
events are handled. This change adds support to add configurable
delay for this functionality.

CRs-Fixed: 677740
Change-Id: I0ff3045a3681feb6ddb6b6390e0c1864a17d26c0
Signed-off-by: default avatarMayank Rana <mrana@codeaurora.org>
parent d86deab8
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -59,6 +59,8 @@ Optional properties :
	power collapse when cable is disconencted.
- qcom,por-after-power-collapse: If present, a partial POR sequence will be performed
  when recovering from power collapse.
- qcom,lpm-to-suspend-delay-ms: Indicates timeout (in milliseconds) to release wakeup source
  after USB is kept into LPM.
Sub nodes:
- Sub node for "DWC3- USB3 controller".
  This sub node is required property for device node. The properties of this subnode
@@ -79,6 +81,7 @@ Example MSM USB3.0 controller device node :
		qcom,dwc-usb3-msm-qdss-tx-fifo-size = <16384>;
		qcom,usb-dbm = <&dbm_1p4>;
		qcom,usbin-vadc = <&pm8941_vadc>;
		qcom,lpm-to-suspend-delay-ms = <2>;

		qcom,msm_bus,name = "usb3";
		qcom,msm_bus,num_cases = <2>;
+20 −1
Original line number Diff line number Diff line
@@ -221,6 +221,7 @@ struct dwc3_msm {

	int  pwr_event_irq;
	atomic_t                in_p3;
	unsigned int		lpm_to_suspend_delay;
};

#define USB_HSPHY_3P3_VOL_MIN		3050000 /* uV */
@@ -1702,7 +1703,18 @@ static int dwc3_msm_suspend(struct dwc3_msm *mdwc)
			dev_err(mdwc->dev, "Failed to reset bus bw vote\n");
	}

	/*
	 * release wakeup source with timeout to defer system suspend to
	 * handle case where on USB cable disconnect, SUSPEND and DISCONNECT
	 * event is received.
	 */
	if (mdwc->lpm_to_suspend_delay) {
		dev_dbg(mdwc->dev, "defer suspend with %d(msecs)\n",
					mdwc->lpm_to_suspend_delay);
		pm_wakeup_event(mdwc->dev, mdwc->lpm_to_suspend_delay);
	} else {
		pm_relax(mdwc->dev);
	}

	if (mdwc->hs_phy_irq) {
		/*
@@ -2892,6 +2904,13 @@ static int dwc3_msm_probe(struct platform_device *pdev)
	mdwc->enable_suspend_event = of_property_read_bool(node,
				"qcom,suspend_event_enable");

	ret = of_property_read_u32(node, "qcom,lpm-to-suspend-delay-ms",
				&mdwc->lpm_to_suspend_delay);
	if (ret) {
		dev_dbg(&pdev->dev, "setting lpm_to_suspend_delay to zero.\n");
		mdwc->lpm_to_suspend_delay = 0;
	}

	if (mdwc->power_collapse) {
		/*
		 * If present, the phy_com_reset is used in conjunction