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

Commit 8182accd authored by Vamsi Krishna Samavedam's avatar Vamsi Krishna Samavedam
Browse files

usb: dwc3: Powerdown the SS PHY while connected to HS device



SNPS controller can wakeup both HS PHY and SS PHY (for UTMI clock and
PIPE clock) for any xhci command or doorbell rings. This might result
in additional power consumption when only HS device is connected to
root port. To avoid additional power consumption when operating in
high-speed only mode, power down SS PHY.

Change-Id: I35195934c617d7c581976e34da73777bfa13fe6f
Signed-off-by: default avatarVamsi Krishna Samavedam <vskrishn@codeaurora.org>
parent 753e04cd
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -3709,6 +3709,14 @@ static int dwc3_msm_host_notifier(struct notifier_block *nb,
			udev->dev.parent->parent == &dwc->xhci->dev) {
		if (event == USB_DEVICE_ADD && udev->actconfig) {
			if (!dwc3_msm_is_ss_rhport_connected(mdwc)) {
				/*
				 * controller may wakeup ss phy during hs data
				 * transfers or doorbell rings. Power down the
				 * ss phy to avoid turning on pipe clock during
				 * these wake-ups.
				 */
				usb_phy_powerdown(mdwc->ss_phy);

				/*
				 * Core clock rate can be reduced only if root
				 * hub SS port is not enabled/connected.
@@ -3724,6 +3732,7 @@ static int dwc3_msm_host_notifier(struct notifier_block *nb,
				mdwc->max_rh_port_speed = USB_SPEED_SUPER;
			}
		} else {
			usb_phy_powerup(mdwc->ss_phy);
			/* set rate back to default core clk rate */
			clk_set_rate(mdwc->core_clk, mdwc->core_clk_rate);
			dev_dbg(mdwc->dev, "set core clk rate %ld\n",
+18 −0
Original line number Diff line number Diff line
@@ -782,6 +782,23 @@ static int msm_ssphy_qmp_notify_disconnect(struct usb_phy *uphy,
	return 0;
}

static int msm_ssphy_qmp_powerup(struct usb_phy *uphy, bool powerup)
{
	struct msm_ssphy_qmp *phy = container_of(uphy, struct msm_ssphy_qmp,
					phy);
	u8 reg = powerup ? 1 : 0;
	u8 temp;

	writel_relaxed(reg,
			phy->base + phy->phy_reg[USB3_PHY_POWER_DOWN_CONTROL]);
	temp = readl_relaxed(phy->base +
			phy->phy_reg[USB3_PHY_POWER_DOWN_CONTROL]);

	dev_dbg(uphy->dev, "P3 powerup:%x\n", temp);

	return 0;
}

static int msm_ssphy_qmp_get_clks(struct msm_ssphy_qmp *phy, struct device *dev)
{
	int ret = 0;
@@ -1083,6 +1100,7 @@ static int msm_ssphy_qmp_probe(struct platform_device *pdev)
	phy->phy.set_suspend		= msm_ssphy_qmp_set_suspend;
	phy->phy.notify_connect		= msm_ssphy_qmp_notify_connect;
	phy->phy.notify_disconnect	= msm_ssphy_qmp_notify_disconnect;
	phy->phy.powerup		= msm_ssphy_qmp_powerup;

	if (of_property_read_bool(dev->of_node, "qcom,link-training-reset"))
		phy->phy.link_training	= msm_ssphy_qmp_link_training;
+19 −0
Original line number Diff line number Diff line
@@ -164,6 +164,7 @@ struct usb_phy {
	int	(*notify_disconnect)(struct usb_phy *x,
			enum usb_device_speed speed);
	int	(*link_training)(struct usb_phy *x, bool start);
	int	(*powerup)(struct usb_phy *x, bool start);

	/*
	 * Charger detection method can be implemented if you need to
@@ -406,6 +407,24 @@ usb_phy_stop_link_training(struct usb_phy *x)
		return 0;
}

static inline int
usb_phy_powerup(struct usb_phy *x)
{
	if (x && x->powerup)
		return x->powerup(x, true);
	else
		return 0;
}

static inline int
usb_phy_powerdown(struct usb_phy *x)
{
	if (x && x->powerup)
		return x->powerup(x, false);
	else
		return 0;
}

static inline int
usb_phy_notify_disconnect(struct usb_phy *x, enum usb_device_speed speed)
{