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

Commit bad8e335 authored by Tony Lindgren's avatar Tony Lindgren Committed by Kishon Vijay Abraham I
Browse files

usb: phy: twl4030-usb: Move code from twl4030_phy_power to the runtime PM calls



We don't need twl4030_phy_power() any longer now that we have
the runtime PM calls. Let's get rid of it as it's confusing.
No functional changes, just move the code and use res instead
of ret as we are not returning that value.

Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
Signed-off-by: default avatarKishon Vijay Abraham I <kishon@ti.com>
parent 62dc5769
Loading
Loading
Loading
Loading
+31 −41
Original line number Diff line number Diff line
@@ -383,17 +383,38 @@ static void __twl4030_phy_power(struct twl4030_usb *twl, int on)
	WARN_ON(twl4030_usb_write_verify(twl, PHY_PWR_CTRL, pwr) < 0);
}

static void twl4030_phy_power(struct twl4030_usb *twl, int on)
static int twl4030_usb_runtime_suspend(struct device *dev)
{
	int ret;
	struct twl4030_usb *twl = dev_get_drvdata(dev);

	if (on) {
		ret = regulator_enable(twl->usb3v1);
		if (ret)
	dev_dbg(twl->dev, "%s\n", __func__);
	if (twl->asleep)
		return 0;

	__twl4030_phy_power(twl, 0);
	regulator_disable(twl->usb1v5);
	regulator_disable(twl->usb1v8);
	regulator_disable(twl->usb3v1);
	twl->asleep = 1;

	return 0;
}

static int twl4030_usb_runtime_resume(struct device *dev)
{
	struct twl4030_usb *twl = dev_get_drvdata(dev);
	int res;

	dev_dbg(twl->dev, "%s\n", __func__);
	if (!twl->asleep)
		return 0;

	res = regulator_enable(twl->usb3v1);
	if (res)
		dev_err(twl->dev, "Failed to enable usb3v1\n");

		ret = regulator_enable(twl->usb1v8);
		if (ret)
	res = regulator_enable(twl->usb1v8);
	if (res)
		dev_err(twl->dev, "Failed to enable usb1v8\n");

	/*
@@ -405,8 +426,8 @@ static void twl4030_phy_power(struct twl4030_usb *twl, int on)
	 */
	twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB_DEDICATED2);

		ret = regulator_enable(twl->usb1v5);
		if (ret)
	res = regulator_enable(twl->usb1v5);
	if (res)
		dev_err(twl->dev, "Failed to enable usb1v5\n");

	__twl4030_phy_power(twl, 1);
@@ -414,37 +435,6 @@ static void twl4030_phy_power(struct twl4030_usb *twl, int on)
			  twl4030_usb_read(twl, PHY_CLK_CTRL) |
			  (PHY_CLK_CTRL_CLOCKGATING_EN |
			   PHY_CLK_CTRL_CLK32K_EN));
	} else {
		__twl4030_phy_power(twl, 0);
		regulator_disable(twl->usb1v5);
		regulator_disable(twl->usb1v8);
		regulator_disable(twl->usb3v1);
	}
}

static int twl4030_usb_runtime_suspend(struct device *dev)
{
	struct twl4030_usb *twl = dev_get_drvdata(dev);

	dev_dbg(twl->dev, "%s\n", __func__);
	if (twl->asleep)
		return 0;

	twl4030_phy_power(twl, 0);
	twl->asleep = 1;

	return 0;
}

static int twl4030_usb_runtime_resume(struct device *dev)
{
	struct twl4030_usb *twl = dev_get_drvdata(dev);

	dev_dbg(twl->dev, "%s\n", __func__);
	if (!twl->asleep)
		return 0;

	twl4030_phy_power(twl, 1);
	twl->asleep = 0;

	return 0;