aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc
diff options
context:
space:
mode:
authorDong Aisheng <b29396@freescale.com>2013-11-04 03:38:29 -0500
committerChris Ball <chris@printf.net>2014-01-13 12:48:09 -0500
commit89d7e5c131228a8f0d8b0cb48b459c62152bf620 (patch)
tree99443ecb800636e537b7d0a2cefc42533015dfdc /drivers/mmc
parentce090a4eb9626272bfd2529520f2f16351029640 (diff)
mmc: sdhci-esdhc-imx: add runtime pm support
The root clock will be disabled in runtime pm to save power. Signed-off-by: Dong Aisheng <b29396@freescale.com> Acked-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/host/sdhci-esdhc-imx.c49
1 files changed, 48 insertions, 1 deletions
diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index 0ac4370cd980..fa9c1b26e856 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -27,6 +27,7 @@
27#include <linux/of_gpio.h> 27#include <linux/of_gpio.h>
28#include <linux/pinctrl/consumer.h> 28#include <linux/pinctrl/consumer.h>
29#include <linux/platform_data/mmc-esdhc-imx.h> 29#include <linux/platform_data/mmc-esdhc-imx.h>
30#include <linux/pm_runtime.h>
30#include "sdhci-pltfm.h" 31#include "sdhci-pltfm.h"
31#include "sdhci-esdhc.h" 32#include "sdhci-esdhc.h"
32 33
@@ -1121,6 +1122,12 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
1121 if (err) 1122 if (err)
1122 goto disable_clk; 1123 goto disable_clk;
1123 1124
1125 pm_runtime_set_active(&pdev->dev);
1126 pm_runtime_enable(&pdev->dev);
1127 pm_runtime_set_autosuspend_delay(&pdev->dev, 50);
1128 pm_runtime_use_autosuspend(&pdev->dev);
1129 pm_suspend_ignore_children(&pdev->dev, 1);
1130
1124 return 0; 1131 return 0;
1125 1132
1126disable_clk: 1133disable_clk:
@@ -1141,6 +1148,9 @@ static int sdhci_esdhc_imx_remove(struct platform_device *pdev)
1141 1148
1142 sdhci_remove_host(host, dead); 1149 sdhci_remove_host(host, dead);
1143 1150
1151 pm_runtime_dont_use_autosuspend(&pdev->dev);
1152 pm_runtime_disable(&pdev->dev);
1153
1144 clk_disable_unprepare(imx_data->clk_per); 1154 clk_disable_unprepare(imx_data->clk_per);
1145 clk_disable_unprepare(imx_data->clk_ipg); 1155 clk_disable_unprepare(imx_data->clk_ipg);
1146 clk_disable_unprepare(imx_data->clk_ahb); 1156 clk_disable_unprepare(imx_data->clk_ahb);
@@ -1150,12 +1160,49 @@ static int sdhci_esdhc_imx_remove(struct platform_device *pdev)
1150 return 0; 1160 return 0;
1151} 1161}
1152 1162
1163#ifdef CONFIG_PM_RUNTIME
1164static int sdhci_esdhc_runtime_suspend(struct device *dev)
1165{
1166 struct sdhci_host *host = dev_get_drvdata(dev);
1167 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
1168 struct pltfm_imx_data *imx_data = pltfm_host->priv;
1169 int ret;
1170
1171 ret = sdhci_runtime_suspend_host(host);
1172
1173 clk_disable_unprepare(imx_data->clk_per);
1174 clk_disable_unprepare(imx_data->clk_ipg);
1175 clk_disable_unprepare(imx_data->clk_ahb);
1176
1177 return ret;
1178}
1179
1180static int sdhci_esdhc_runtime_resume(struct device *dev)
1181{
1182 struct sdhci_host *host = dev_get_drvdata(dev);
1183 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
1184 struct pltfm_imx_data *imx_data = pltfm_host->priv;
1185
1186 clk_prepare_enable(imx_data->clk_per);
1187 clk_prepare_enable(imx_data->clk_ipg);
1188 clk_prepare_enable(imx_data->clk_ahb);
1189
1190 return sdhci_runtime_resume_host(host);
1191}
1192#endif
1193
1194static const struct dev_pm_ops sdhci_esdhc_pmops = {
1195 SET_SYSTEM_SLEEP_PM_OPS(sdhci_pltfm_suspend, sdhci_pltfm_resume)
1196 SET_RUNTIME_PM_OPS(sdhci_esdhc_runtime_suspend,
1197 sdhci_esdhc_runtime_resume, NULL)
1198};
1199
1153static struct platform_driver sdhci_esdhc_imx_driver = { 1200static struct platform_driver sdhci_esdhc_imx_driver = {
1154 .driver = { 1201 .driver = {
1155 .name = "sdhci-esdhc-imx", 1202 .name = "sdhci-esdhc-imx",
1156 .owner = THIS_MODULE, 1203 .owner = THIS_MODULE,
1157 .of_match_table = imx_esdhc_dt_ids, 1204 .of_match_table = imx_esdhc_dt_ids,
1158 .pm = SDHCI_PLTFM_PMOPS, 1205 .pm = &sdhci_esdhc_pmops,
1159 }, 1206 },
1160 .id_table = imx_esdhc_devtype, 1207 .id_table = imx_esdhc_devtype,
1161 .probe = sdhci_esdhc_imx_probe, 1208 .probe = sdhci_esdhc_imx_probe,