]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mmc: renesas_sdhi: Add suspend/resume hooks
authorClaudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Mon, 17 Nov 2025 10:12:42 +0000 (12:12 +0200)
committerUlf Hansson <ulf.hansson@linaro.org>
Tue, 18 Nov 2025 15:28:54 +0000 (16:28 +0100)
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: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/renesas_sdhi.h
drivers/mmc/host/renesas_sdhi_core.c
drivers/mmc/host/renesas_sdhi_internal_dmac.c

index 084964cecf9d8e5b20e51a01f3177bf4ff49f6fa..afc36a407c2c109fa230d73d77867c33993c4633 100644 (file)
@@ -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
index c4aaf534868c229fce3488696a9e088babbb1a53..2a310a1457855bddbdeb641693a71ac57fccbb15 100644 (file)
@@ -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");
index ef06c3a60ae8900e719f7ecded01e2b93faac7c8..f6ebb7bc7ede1f4d69260d09d9d85fdf0606a034 100644 (file)
@@ -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)