Commit dcbce328 authored by Claudiu Beznea's avatar Claudiu Beznea Committed by Ulf Hansson
Browse files

mmc: renesas_sdhi: Add suspend/resume hooks



Add suspend/resume hooks which assert/deassert the reset signals, along
with forcing runtime suspend/resume. This allows using the driver in
scenarios where the resume is done with the help of bootloader and the
bootloader disables the SDHI clocks, resets, IRQs before passing execution
to Linux.

Reviewed-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: default avatarClaudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent 50371ef0
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@
#ifndef RENESAS_SDHI_H
#define RENESAS_SDHI_H

#include <linux/device.h>
#include <linux/dmaengine.h>
#include <linux/platform_device.h>
#include <linux/workqueue.h>
@@ -107,4 +108,6 @@ int renesas_sdhi_probe(struct platform_device *pdev,
		       const struct renesas_sdhi_of_data *of_data,
		       const struct renesas_sdhi_quirks *quirks);
void renesas_sdhi_remove(struct platform_device *pdev);
int renesas_sdhi_suspend(struct device *dev);
int renesas_sdhi_resume(struct device *dev);
#endif
+37 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
#include <linux/platform_data/tmio.h>
#include <linux/platform_device.h>
#include <linux/pm_domain.h>
#include <linux/pm_runtime.h>
#include <linux/regulator/consumer.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/of_regulator.h>
@@ -1317,5 +1318,41 @@ void renesas_sdhi_remove(struct platform_device *pdev)
}
EXPORT_SYMBOL_GPL(renesas_sdhi_remove);

int renesas_sdhi_suspend(struct device *dev)
{
	struct tmio_mmc_host *host = dev_get_drvdata(dev);
	struct renesas_sdhi *priv = host_to_priv(host);
	int ret;

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

	ret = reset_control_assert(priv->rstc);
	if (ret)
		pm_runtime_force_resume(dev);

	return ret;
}
EXPORT_SYMBOL_GPL(renesas_sdhi_suspend);

int renesas_sdhi_resume(struct device *dev)
{
	struct tmio_mmc_host *host = dev_get_drvdata(dev);
	struct renesas_sdhi *priv = host_to_priv(host);
	int ret;

	ret = reset_control_deassert(priv->rstc);
	if (ret)
		return ret;

	ret = pm_runtime_force_resume(dev);
	if (ret)
		reset_control_assert(priv->rstc);

	return ret;
}
EXPORT_SYMBOL_GPL(renesas_sdhi_resume);

MODULE_DESCRIPTION("Renesas SDHI core driver");
MODULE_LICENSE("GPL v2");
+1 −2
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@
#include <linux/pagemap.h>
#include <linux/platform_data/tmio.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/scatterlist.h>
#include <linux/sys_soc.h>

@@ -600,7 +599,7 @@ static int renesas_sdhi_internal_dmac_probe(struct platform_device *pdev)
}

static const struct dev_pm_ops renesas_sdhi_internal_dmac_dev_pm_ops = {
	SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
	SYSTEM_SLEEP_PM_OPS(renesas_sdhi_suspend, renesas_sdhi_resume)
	RUNTIME_PM_OPS(tmio_mmc_host_runtime_suspend,
		       tmio_mmc_host_runtime_resume,
		       NULL)