27
27
#include <linux/of_gpio.h>
28
28
#include <linux/pinctrl/consumer.h>
29
29
#include <linux/platform_data/mmc-esdhc-imx.h>
30
+ #include <linux/pm_runtime.h>
30
31
#include "sdhci-pltfm.h"
31
32
#include "sdhci-esdhc.h"
32
33
@@ -1121,6 +1122,12 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
1121
1122
if (err )
1122
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
1131
return 0 ;
1125
1132
1126
1133
disable_clk :
@@ -1141,6 +1148,9 @@ static int sdhci_esdhc_imx_remove(struct platform_device *pdev)
1141
1148
1142
1149
sdhci_remove_host (host , dead );
1143
1150
1151
+ pm_runtime_dont_use_autosuspend (& pdev -> dev );
1152
+ pm_runtime_disable (& pdev -> dev );
1153
+
1144
1154
clk_disable_unprepare (imx_data -> clk_per );
1145
1155
clk_disable_unprepare (imx_data -> clk_ipg );
1146
1156
clk_disable_unprepare (imx_data -> clk_ahb );
@@ -1150,12 +1160,49 @@ static int sdhci_esdhc_imx_remove(struct platform_device *pdev)
1150
1160
return 0 ;
1151
1161
}
1152
1162
1163
+ #ifdef CONFIG_PM_RUNTIME
1164
+ static 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
+
1180
+ static 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
+
1194
+ static 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
+
1153
1200
static struct platform_driver sdhci_esdhc_imx_driver = {
1154
1201
.driver = {
1155
1202
.name = "sdhci-esdhc-imx" ,
1156
1203
.owner = THIS_MODULE ,
1157
1204
.of_match_table = imx_esdhc_dt_ids ,
1158
- .pm = SDHCI_PLTFM_PMOPS ,
1205
+ .pm = & sdhci_esdhc_pmops ,
1159
1206
},
1160
1207
.id_table = imx_esdhc_devtype ,
1161
1208
.probe = sdhci_esdhc_imx_probe ,
0 commit comments