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

Commit a45bd342 authored by Hemant Kumar's avatar Hemant Kumar
Browse files

usb: phy-msm-snps: Implement msm_hsphy_set_suspend API



API gets called upon host and device bus suspend/resume and
usb cable connect/disconnect. Currently ref clk remains on upon
bus suspend and LDOs remain on upon cable disconnect. This
prevents XOSD and VDD min. Turn off ref clk upon bus suspend
and turn off LDOs and ref clk upon cable disconnect.

Change-Id: Ic14abf494105c296a4f4a66d9475c45cc3eae2c4
Signed-off-by: default avatarHemant Kumar <hemantk@codeaurora.org>
parent c95d89c3
Loading
Loading
Loading
Loading
+23 −1
Original line number Diff line number Diff line
/*
 * Copyright (c) 2017, The Linux Foundation. All rights reserved.
 * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -422,6 +422,28 @@ static int msm_hsphy_init(struct usb_phy *uphy)

static int msm_hsphy_set_suspend(struct usb_phy *uphy, int suspend)
{
	struct msm_hsphy *phy = container_of(uphy, struct msm_hsphy, phy);

	if (phy->suspended && suspend) {
		dev_dbg(uphy->dev, "%s: USB PHY is already suspended\n",
			__func__);
		return 0;
	}

	if (suspend) { /* Bus suspend */
		if (phy->cable_connected ||
			(phy->phy.flags & PHY_HOST_MODE)) {
			msm_hsphy_enable_clocks(phy, false);
		} else {/* Cable disconnect */
			msm_hsphy_enable_clocks(phy, false);
			msm_hsphy_enable_power(phy, false);
		}
		phy->suspended = true;
	} else { /* Bus resume and cable connect */
			msm_hsphy_enable_clocks(phy, true);
			phy->suspended = false;
		}

	return 0;
}