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

Commit caa465c2 authored by Ajay Agarwal's avatar Ajay Agarwal
Browse files

phy: msm: ssusb: Add support for cable_connected flag



Currently the phy-msm-ssusb driver sets the POWERDOWN bit and
turns off the clocks and regulators as a part of suspend
irrespective of whether cable is connected or not.
Add a new flag cable_connected and set the POWERDOWN flag and
turn off the regulators only if cable is disconnected.

Change-Id: I179db4116d2b5b271916ea4e97534a5cd36fb0a1
Signed-off-by: default avatarAjay Agarwal <ajaya@codeaurora.org>
parent e7ffd910
Loading
Loading
Loading
Loading
+23 −10
Original line number Diff line number Diff line
/*
 * Copyright (c) 2012-2014,2017-2019 The Linux Foundation. All rights reserved.
 * Copyright (c) 2012-2014,2017-2020, 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
@@ -63,6 +63,7 @@ struct msm_ssphy {
	struct clk		*cfg_ahb_clk;
	struct clk		*pipe_clk;
	bool			clocks_enabled;
	bool			cable_connected;

	struct reset_control	*phy_com_reset;
	struct reset_control	*phy_reset;
@@ -353,23 +354,33 @@ static int msm_ssphy_set_suspend(struct usb_phy *uphy, int suspend)

		msm_usb_write_readback(phy->base, SS_PHY_CTRL2,
					REF_SS_PHY_EN, 0);
		msm_usb_write_readback(phy->base, SS_PHY_CTRL4,
					REF_USE_PAD, 0);
		if (!phy->cable_connected)
			msm_usb_write_readback(phy->base, SS_PHY_CTRL4,
						TEST_POWERDOWN, TEST_POWERDOWN);

		msm_ssusb_disable_clocks(phy);
		if (!phy->cable_connected) {
			msm_ssusb_ldo_enable(phy, 0);
			msm_ssusb_config_vdd(phy, 0);
		}
		phy->suspended = true;
	} else {

		if (!phy->cable_connected) {
			rc = msm_ssusb_config_vdd(phy, 1);
			if (rc)
				return rc;
			msm_ssusb_ldo_enable(phy, 1);
		}
		msm_ssusb_enable_clocks(phy);

		msm_usb_write_readback(phy->base, SS_PHY_CTRL4,
					REF_USE_PAD, REF_USE_PAD);
		msm_usb_write_readback(phy->base, SS_PHY_CTRL2,
					REF_SS_PHY_EN, REF_SS_PHY_EN);
		if (!phy->cable_connected)
			msm_usb_write_readback(phy->base, SS_PHY_CTRL4,
						TEST_POWERDOWN, 0);

@@ -384,6 +395,7 @@ static int msm_ssphy_notify_connect(struct usb_phy *uphy,
{
	struct msm_ssphy *phy = container_of(uphy, struct msm_ssphy, phy);

	phy->cable_connected = true;
	if (uphy->flags & PHY_HOST_MODE)
		return 0;

@@ -400,6 +412,7 @@ static int msm_ssphy_notify_disconnect(struct usb_phy *uphy,
{
	struct msm_ssphy *phy = container_of(uphy, struct msm_ssphy, phy);

	phy->cable_connected = false;
	if (uphy->flags & PHY_HOST_MODE)
		return 0;