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

Commit 651652aa authored by Grygorii Strashko's avatar Grygorii Strashko Committed by David S. Miller
Browse files

drivers: net: davinci_mdio: add pm runtime callbacks



Add PM runtime .runtime_suspend()/.runtime_resume() callbacks and
perform Davinci MDIO enabling/disabling from these callbacks. This
allows to reuse pm_runtime_force_suspend/resume() APIs during System
suspend and required for further implementation of PM runtime
autosuspend.

Signed-off-by: default avatarGrygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 28f0ccb9
Loading
Loading
Loading
Loading
+27 −4
Original line number Original line Diff line number Diff line
@@ -406,8 +406,8 @@ static int davinci_mdio_remove(struct platform_device *pdev)
	return 0;
	return 0;
}
}


#ifdef CONFIG_PM_SLEEP
#ifdef CONFIG_PM
static int davinci_mdio_suspend(struct device *dev)
static int davinci_mdio_runtime_suspend(struct device *dev)
{
{
	struct davinci_mdio_data *data = dev_get_drvdata(dev);
	struct davinci_mdio_data *data = dev_get_drvdata(dev);
	u32 ctrl;
	u32 ctrl;
@@ -418,6 +418,28 @@ static int davinci_mdio_suspend(struct device *dev)
	__raw_writel(ctrl, &data->regs->control);
	__raw_writel(ctrl, &data->regs->control);
	wait_for_idle(data);
	wait_for_idle(data);


	return 0;
}

static int davinci_mdio_runtime_resume(struct device *dev)
{
	struct davinci_mdio_data *data = dev_get_drvdata(dev);

	davinci_mdio_enable(data);
	return 0;
}
#endif

#ifdef CONFIG_PM_SLEEP
static int davinci_mdio_suspend(struct device *dev)
{
	struct davinci_mdio_data *data = dev_get_drvdata(dev);
	int ret = 0;

	ret = pm_runtime_force_suspend(dev);
	if (ret < 0)
		return ret;

	/* Select sleep pin state */
	/* Select sleep pin state */
	pinctrl_pm_select_sleep_state(dev);
	pinctrl_pm_select_sleep_state(dev);


@@ -431,14 +453,15 @@ static int davinci_mdio_resume(struct device *dev)
	/* Select default pin state */
	/* Select default pin state */
	pinctrl_pm_select_default_state(dev);
	pinctrl_pm_select_default_state(dev);


	/* restart the scan state machine */
	pm_runtime_force_resume(dev);
	davinci_mdio_enable(data);


	return 0;
	return 0;
}
}
#endif
#endif


static const struct dev_pm_ops davinci_mdio_pm_ops = {
static const struct dev_pm_ops davinci_mdio_pm_ops = {
	SET_RUNTIME_PM_OPS(davinci_mdio_runtime_suspend,
			   davinci_mdio_runtime_resume, NULL)
	SET_LATE_SYSTEM_SLEEP_PM_OPS(davinci_mdio_suspend, davinci_mdio_resume)
	SET_LATE_SYSTEM_SLEEP_PM_OPS(davinci_mdio_suspend, davinci_mdio_resume)
};
};