diff mbox

[PATCHv2,2/3] MMC: OMAP: HSMMC: add runtime pm support

Message ID 1309282049-23739-3-git-send-email-balajitk@ti.com (mailing list archive)
State Awaiting Upstream
Delegated to: Kevin Hilman
Headers show

Commit Message

Balaji T K June 28, 2011, 5:27 p.m. UTC
add runtime pm support to HSMMC host controller
Use runtime pm API to enable/disable HSMMC clock
Use runtime autosuspend APIs to enable auto suspend delay

Based on OMAP HSMMC runtime implementation by Kevin Hilman, Kishore Kadiyala

Signed-off-by: Balaji T K <balajitk@ti.com>
---
changes since v1
Removed pm_runtime_allow, pm_runtime_forbid, pm_suspend_ignore_children calls.

 drivers/mmc/host/omap_hsmmc.c |  119 +++++++++++++++++++++--------------------
 1 files changed, 60 insertions(+), 59 deletions(-)

Comments

Kevin Hilman June 28, 2011, 11:32 p.m. UTC | #1
+Rajendra

Balaji T K <balajitk@ti.com> writes:

> add runtime pm support to HSMMC host controller
> Use runtime pm API to enable/disable HSMMC clock
> Use runtime autosuspend APIs to enable auto suspend delay
>
> Based on OMAP HSMMC runtime implementation by Kevin Hilman, Kishore Kadiyala
>
> Signed-off-by: Balaji T K <balajitk@ti.com>

I tried to test this series along with Benoit's clkdm/modulemode/hwmod
cleanups and something strange is happening on OMAP4.

First, this series by itself is working as I would expect, but testing
in combination with Benoit's series, it's different...

First, I'm using Benoit's branch:

       git://gitorious.org/omap-pm/linux.git for_3.0.1/7_hwmod_modulemode

in combination with your series.

I've also reverted these two commits:

   OMAP4: PM: TEMP: Prevent l3init from idling/force sleep
   OMAP3+: hwmod data: TEMP: Do not idle MMC1 & MMC2 after boot

which are temporary workarounds for not having MMC runtime PM.

I turned the dev_dbg calls in the runtime PM callbacks into dev_info
callbacks to see exactly when the device is enabled/disabled via runtime
PM.

To my surprise, I didn't see the device being enabled/disabled when
writing do the device.

First, I mounted:

root@foo:~# mount /dev/mmcblk0p2 /media/mmc2
[  730.392944] omap_hsmmc omap_hsmmc.0: host: enabled
[  730.445831] EXT3-fs: barriers not enabled
[  730.453124] kjournald starting.  Commit interval 5 seconds
[  730.459045] EXT3-fs (mmcblk0p2): warning: maximal mount count reached, runnid
[  730.474731] EXT3-fs (mmcblk0p2): using internal journal
[  730.480316] EXT3-fs (mmcblk0p2): mounted filesystem with ordered data mode
[  730.522613] omap_hsmmc omap_hsmmc.0: disabled                                

As expected, the device is enabled for mount, and soon disabled
(presumably after the autosuspend timeout.)

Then, I cd'd to the card:

root@foo:~# cd /media/mmc2/tmp                                                
[  744.350921] omap_hsmmc omap_hsmmc.0: host: enabled                           
[  744.413238] omap_hsmmc omap_hsmmc.0: disabled    

and see a brief enable/disable, probably to get the directory contents.

Now the strange part.  I wrote a chunk of random data to the device,
but didn't see any enable/disable activity until the unmount.  Not even
after I did a sync.

root@foo:/media/mmc2/tmp# dd if=/dev/urandom of=rand.bin bs=1M count=4        
4+0 records in                                                                  
4+0 records out                                                                 
4194304 bytes (4.2 MB) copied, 9.91346 s, 423 kB/s                              
root@foo:/media/mmc2/tmp# sync                                                
root@foo:/media/mmc2/tmp# cd                                                  
root@foo:~# umount /media/mmc2                                                
[ 1026.711578] omap_hsmmc omap_hsmmc.0: host: enabled                           
[ 1026.772918] omap_hsmmc omap_hsmmc.0: disabled                                
root@foo:~# 


Using this series standalone I see a few enable/disable cycles during
the write, presumably as the MMC core buffers and bursts writes.

Any ideas why the same isn't happening when used with Benoit's series?

Kevin

P.S. note that the debug messages don't quite match.  One says 'host:
enabled' the other says 'disabled' (without the host: prefix.)  making
the prefixes match would be more readable.

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Balaji T K June 29, 2011, 10:22 a.m. UTC | #2
On Wed, Jun 29, 2011 at 5:02 AM, Kevin Hilman <khilman@ti.com> wrote:
> +Rajendra
>
> Balaji T K <balajitk@ti.com> writes:
>
>> add runtime pm support to HSMMC host controller
>> Use runtime pm API to enable/disable HSMMC clock
>> Use runtime autosuspend APIs to enable auto suspend delay
>>
>> Based on OMAP HSMMC runtime implementation by Kevin Hilman, Kishore Kadiyala
>>
>> Signed-off-by: Balaji T K <balajitk@ti.com>
>
> I tried to test this series along with Benoit's clkdm/modulemode/hwmod
> cleanups and something strange is happening on OMAP4.
>
> First, this series by itself is working as I would expect, but testing
> in combination with Benoit's series, it's different...
>
> First, I'm using Benoit's branch:
>
>       git://gitorious.org/omap-pm/linux.git for_3.0.1/7_hwmod_modulemode
>
> in combination with your series.
>
> I've also reverted these two commits:
>
>   OMAP4: PM: TEMP: Prevent l3init from idling/force sleep
>   OMAP3+: hwmod data: TEMP: Do not idle MMC1 & MMC2 after boot
>
> which are temporary workarounds for not having MMC runtime PM.
>
> I turned the dev_dbg calls in the runtime PM callbacks into dev_info
> callbacks to see exactly when the device is enabled/disabled via runtime
> PM.
>
> To my surprise, I didn't see the device being enabled/disabled when
> writing do the device.

I tried for_3.0.1/7_hwmod_modulemode as you mentioned above,
changing dev_dbg to dev_err and I am not observing the delayed write
during umount. Can you let me know if the files are there in MMC after
remounting ?

> Any ideas why the same isn't happening when used with Benoit's series?
>
> Kevin
>
> P.S. note that the debug messages don't quite match.  One says 'host:
> enabled' the other says 'disabled' (without the host: prefix.)  making
> the prefixes match would be more readable.

Ok, Will align dev_dbg prints.
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Kevin Hilman June 29, 2011, 5:56 p.m. UTC | #3
"T Krishnamoorthy, Balaji" <balajitk@ti.com> writes:

> On Wed, Jun 29, 2011 at 5:02 AM, Kevin Hilman <khilman@ti.com> wrote:
>> +Rajendra
>>
>> Balaji T K <balajitk@ti.com> writes:
>>
>>> add runtime pm support to HSMMC host controller
>>> Use runtime pm API to enable/disable HSMMC clock
>>> Use runtime autosuspend APIs to enable auto suspend delay
>>>
>>> Based on OMAP HSMMC runtime implementation by Kevin Hilman, Kishore Kadiyala
>>>
>>> Signed-off-by: Balaji T K <balajitk@ti.com>
>>
>> I tried to test this series along with Benoit's clkdm/modulemode/hwmod
>> cleanups and something strange is happening on OMAP4.
>>
>> First, this series by itself is working as I would expect, but testing
>> in combination with Benoit's series, it's different...
>>
>> First, I'm using Benoit's branch:
>>
>>       git://gitorious.org/omap-pm/linux.git for_3.0.1/7_hwmod_modulemode
>>
>> in combination with your series.
>>
>> I've also reverted these two commits:
>>
>>   OMAP4: PM: TEMP: Prevent l3init from idling/force sleep
>>   OMAP3+: hwmod data: TEMP: Do not idle MMC1 & MMC2 after boot
>>
>> which are temporary workarounds for not having MMC runtime PM.
>>
>> I turned the dev_dbg calls in the runtime PM callbacks into dev_info
>> callbacks to see exactly when the device is enabled/disabled via runtime
>> PM.
>>
>> To my surprise, I didn't see the device being enabled/disabled when
>> writing do the device.
>
> I tried for_3.0.1/7_hwmod_modulemode as you mentioned above,
> changing dev_dbg to dev_err and I am not observing the delayed write
> during umount. Can you let me know if the files are there in MMC after
> remounting ?

Did you also revert the above two commits?

I've pushed a 'tmp/mmc' branch to my git tree[1] which is my PM branch
(including various PM stuff queued for upstream) as well as Benoit's
series with the TEMP patches above reverted and your series on top of
it.  There's one additional patch to convert the dev_dbg into dev_info
to see the transitions.

Testing this on my OMAP4430 ES2.2 EMU device, I still see the above
behavior.

Can you try out this branch on your board using the default
omap2plus_defconfig?

Thanks,

Kevin

[1] git://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-omap-pm.git
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Balaji T K June 30, 2011, 4:31 a.m. UTC | #4
On Wed, Jun 29, 2011 at 11:26 PM, Kevin Hilman <khilman@ti.com> wrote:
> "T Krishnamoorthy, Balaji" <balajitk@ti.com> writes:
>
>> On Wed, Jun 29, 2011 at 5:02 AM, Kevin Hilman <khilman@ti.com> wrote:
>>> +Rajendra
>>>
>>> Balaji T K <balajitk@ti.com> writes:
>>>
>>>> add runtime pm support to HSMMC host controller
>>>> Use runtime pm API to enable/disable HSMMC clock
>>>> Use runtime autosuspend APIs to enable auto suspend delay
>>>>
>>>> Based on OMAP HSMMC runtime implementation by Kevin Hilman, Kishore Kadiyala
>>>>
>>>> Signed-off-by: Balaji T K <balajitk@ti.com>
>>>
>>> I tried to test this series along with Benoit's clkdm/modulemode/hwmod
>>> cleanups and something strange is happening on OMAP4.
>>>
>>> First, this series by itself is working as I would expect, but testing
>>> in combination with Benoit's series, it's different...
>>>
>>> First, I'm using Benoit's branch:
>>>
>>>       git://gitorious.org/omap-pm/linux.git for_3.0.1/7_hwmod_modulemode
>>>
>>> in combination with your series.
>>>
>>> I've also reverted these two commits:
>>>
>>>   OMAP4: PM: TEMP: Prevent l3init from idling/force sleep
>>>   OMAP3+: hwmod data: TEMP: Do not idle MMC1 & MMC2 after boot
>>>
>>> which are temporary workarounds for not having MMC runtime PM.
>>>
>>> I turned the dev_dbg calls in the runtime PM callbacks into dev_info
>>> callbacks to see exactly when the device is enabled/disabled via runtime
>>> PM.
>>>
>>> To my surprise, I didn't see the device being enabled/disabled when
>>> writing do the device.
>>
>> I tried for_3.0.1/7_hwmod_modulemode as you mentioned above,
>> changing dev_dbg to dev_err and I am not observing the delayed write
>> during umount. Can you let me know if the files are there in MMC after
>> remounting ?
>
> Did you also revert the above two commits?

yes

>
> I've pushed a 'tmp/mmc' branch to my git tree[1] which is my PM branch
> (including various PM stuff queued for upstream) as well as Benoit's
> series with the TEMP patches above reverted and your series on top of
> it.  There's one additional patch to convert the dev_dbg into dev_info
> to see the transitions.
>
> Testing this on my OMAP4430 ES2.2 EMU device, I still see the above
> behavior.

I used OMAP4430 ES2.1 GP

>
> Can you try out this branch on your board using the default
> omap2plus_defconfig?

Ok, I will retry on EMU device.

>
> Thanks,
>
> Kevin
>
> [1] git://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-omap-pm.git
>
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Balaji T K June 30, 2011, 2:13 p.m. UTC | #5
On Thu, Jun 30, 2011 at 10:01 AM, T Krishnamoorthy, Balaji
<balajitk@ti.com> wrote:
> On Wed, Jun 29, 2011 at 11:26 PM, Kevin Hilman <khilman@ti.com> wrote:
>> "T Krishnamoorthy, Balaji" <balajitk@ti.com> writes:
>>
>>> On Wed, Jun 29, 2011 at 5:02 AM, Kevin Hilman <khilman@ti.com> wrote:
>>>> +Rajendra
>>>>
>>>> Balaji T K <balajitk@ti.com> writes:
>>>>
>>>>> add runtime pm support to HSMMC host controller
>>>>> Use runtime pm API to enable/disable HSMMC clock
>>>>> Use runtime autosuspend APIs to enable auto suspend delay
>>>>>
>>>>> Based on OMAP HSMMC runtime implementation by Kevin Hilman, Kishore Kadiyala
>>>>>
>>>>> Signed-off-by: Balaji T K <balajitk@ti.com>
>>>>
>>>> I tried to test this series along with Benoit's clkdm/modulemode/hwmod
>>>> cleanups and something strange is happening on OMAP4.
>>>>
>>>> First, this series by itself is working as I would expect, but testing
>>>> in combination with Benoit's series, it's different...
>>>>
>>>> First, I'm using Benoit's branch:
>>>>
>>>>       git://gitorious.org/omap-pm/linux.git for_3.0.1/7_hwmod_modulemode
>>>>
>>>> in combination with your series.
>>>>
>>>> I've also reverted these two commits:
>>>>
>>>>   OMAP4: PM: TEMP: Prevent l3init from idling/force sleep
>>>>   OMAP3+: hwmod data: TEMP: Do not idle MMC1 & MMC2 after boot
>>>>
>>>> which are temporary workarounds for not having MMC runtime PM.
>>>>
>>>> I turned the dev_dbg calls in the runtime PM callbacks into dev_info
>>>> callbacks to see exactly when the device is enabled/disabled via runtime
>>>> PM.
>>>>
>>>> To my surprise, I didn't see the device being enabled/disabled when
>>>> writing do the device.
>>>
>>> I tried for_3.0.1/7_hwmod_modulemode as you mentioned above,
>>> changing dev_dbg to dev_err and I am not observing the delayed write
>>> during umount. Can you let me know if the files are there in MMC after
>>> remounting ?
>>
>> Did you also revert the above two commits?
>
> yes
>
>>
>> I've pushed a 'tmp/mmc' branch to my git tree[1] which is my PM branch
>> (including various PM stuff queued for upstream) as well as Benoit's
>> series with the TEMP patches above reverted and your series on top of
>> it.  There's one additional patch to convert the dev_dbg into dev_info
>> to see the transitions.
>>
>> Testing this on my OMAP4430 ES2.2 EMU device, I still see the above
>> behavior.
>
> I used OMAP4430 ES2.1 GP
>
>>
>> Can you try out this branch on your board using the default
>> omap2plus_defconfig?
>
> Ok, I will retry on EMU device.
Tried on ES2.1 EMU, log shared at http://pastebin.com/Umg2zF2J

Can you share your complete log?

>
>>
>> Thanks,
>>
>> Kevin
>>
>> [1] git://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-omap-pm.git
>>
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 0c3d0a4..85fd228 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -33,6 +33,7 @@ 
 #include <linux/semaphore.h>
 #include <linux/gpio.h>
 #include <linux/regulator/consumer.h>
+#include <linux/pm_runtime.h>
 #include <plat/dma.h>
 #include <mach/hardware.h>
 #include <plat/board.h>
@@ -116,6 +117,7 @@ 
 #define OMAP_MMC4_DEVID		3
 #define OMAP_MMC5_DEVID		4
 
+#define MMC_AUTOSUSPEND_DELAY	50
 #define MMC_TIMEOUT_MS		20
 #define OMAP_MMC_MASTER_CLOCK	96000000
 #define DRIVER_NAME		"omap_hsmmc"
@@ -1150,8 +1152,7 @@  static int omap_hsmmc_switch_opcond(struct omap_hsmmc_host *host, int vdd)
 	int ret;
 
 	/* Disable the clocks */
-	clk_disable(host->fclk);
-	clk_disable(host->iclk);
+	pm_runtime_put_sync(host->dev);
 	if (host->got_dbclk)
 		clk_disable(host->dbclk);
 
@@ -1162,8 +1163,7 @@  static int omap_hsmmc_switch_opcond(struct omap_hsmmc_host *host, int vdd)
 	if (!ret)
 		ret = mmc_slot(host).set_power(host->dev, host->slot_id, 1,
 					       vdd);
-	clk_enable(host->iclk);
-	clk_enable(host->fclk);
+	pm_runtime_get_sync(host->dev);
 	if (host->got_dbclk)
 		clk_enable(host->dbclk);
 
@@ -1529,7 +1529,7 @@  static void omap_hsmmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 	u32 con;
 	int do_send_init_stream = 0;
 
-	mmc_host_enable(host->mmc);
+	pm_runtime_get_sync(host->dev);
 
 	if (ios->power_mode != host->power_mode) {
 		switch (ios->power_mode) {
@@ -1624,8 +1624,7 @@  static void omap_hsmmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 	else
 		OMAP_HSMMC_WRITE(host->base, CON, con & ~OD);
 
-	if (host->power_mode == MMC_POWER_OFF)
-		mmc_host_disable(host->mmc);
+	pm_runtime_put_autosuspend(host->dev);
 }
 
 static int omap_hsmmc_get_cd(struct mmc_host *mmc)
@@ -1681,32 +1680,28 @@  static void omap_hsmmc_conf_bus_power(struct omap_hsmmc_host *host)
 	set_sd_bus_power(host);
 }
 
-static int omap_hsmmc_enable_fclk(struct mmc_host *mmc)
+static int omap_hsmmc_enable(struct mmc_host *mmc)
 {
 	struct omap_hsmmc_host *host = mmc_priv(mmc);
-	int err;
 
-	err = clk_enable(host->fclk);
-	if (err)
-		return err;
-	dev_dbg(mmc_dev(host->mmc), "mmc_fclk: enabled\n");
-	omap_hsmmc_context_restore(host);
+	pm_runtime_get_sync(host->dev);
+
 	return 0;
 }
 
-static int omap_hsmmc_disable_fclk(struct mmc_host *mmc, int lazy)
+static int omap_hsmmc_disable(struct mmc_host *mmc, int lazy)
 {
 	struct omap_hsmmc_host *host = mmc_priv(mmc);
 
-	omap_hsmmc_context_save(host);
-	clk_disable(host->fclk);
-	dev_dbg(mmc_dev(host->mmc), "mmc_fclk: disabled\n");
+	pm_runtime_mark_last_busy(host->dev);
+	pm_runtime_put_autosuspend(host->dev);
+
 	return 0;
 }
 
 static const struct mmc_host_ops omap_hsmmc_ops = {
-	.enable = omap_hsmmc_enable_fclk,
-	.disable = omap_hsmmc_disable_fclk,
+	.enable = omap_hsmmc_enable,
+	.disable = omap_hsmmc_disable,
 	.request = omap_hsmmc_request,
 	.set_ios = omap_hsmmc_set_ios,
 	.get_cd = omap_hsmmc_get_cd,
@@ -1741,10 +1736,7 @@  static int omap_hsmmc_regs_show(struct seq_file *s, void *data)
 		return 0;
 	}
 
-	if (clk_enable(host->fclk) != 0) {
-		seq_printf(s, "can't read the regs\n");
-		return 0;
-	}
+	pm_runtime_get_sync(host->dev);
 
 	seq_printf(s, "SYSCONFIG:\t0x%08x\n",
 			OMAP_HSMMC_READ(host->base, SYSCONFIG));
@@ -1761,7 +1753,8 @@  static int omap_hsmmc_regs_show(struct seq_file *s, void *data)
 	seq_printf(s, "CAPA:\t\t0x%08x\n",
 			OMAP_HSMMC_READ(host->base, CAPA));
 
-	clk_disable(host->fclk);
+	pm_runtime_mark_last_busy(host->dev);
+	pm_runtime_put_autosuspend(host->dev);
 
 	return 0;
 }
@@ -1881,18 +1874,10 @@  static int __init omap_hsmmc_probe(struct platform_device *pdev)
 
 	mmc->caps |= MMC_CAP_DISABLE;
 
-	if (clk_enable(host->iclk) != 0) {
-		clk_put(host->iclk);
-		clk_put(host->fclk);
-		goto err1;
-	}
-
-	if (mmc_host_enable(host->mmc) != 0) {
-		clk_disable(host->iclk);
-		clk_put(host->iclk);
-		clk_put(host->fclk);
-		goto err1;
-	}
+	pm_runtime_enable(host->dev);
+	pm_runtime_get_sync(host->dev);
+	pm_runtime_set_autosuspend_delay(host->dev, MMC_AUTOSUSPEND_DELAY);
+	pm_runtime_use_autosuspend(host->dev);
 
 	if (cpu_is_omap2430()) {
 		host->dbclk = clk_get(&pdev->dev, "mmchsdb_fck");
@@ -2019,6 +2004,8 @@  static int __init omap_hsmmc_probe(struct platform_device *pdev)
 	}
 
 	omap_hsmmc_debugfs(mmc);
+	pm_runtime_mark_last_busy(host->dev);
+	pm_runtime_put_autosuspend(host->dev);
 
 	return 0;
 
@@ -2034,8 +2021,8 @@  err_reg:
 err_irq_cd_init:
 	free_irq(host->irq, host);
 err_irq:
-	mmc_host_disable(host->mmc);
-	clk_disable(host->iclk);
+	pm_runtime_mark_last_busy(host->dev);
+	pm_runtime_put_autosuspend(host->dev);
 	clk_put(host->fclk);
 	clk_put(host->iclk);
 	if (host->got_dbclk) {
@@ -2059,7 +2046,7 @@  static int omap_hsmmc_remove(struct platform_device *pdev)
 	struct resource *res;
 
 	if (host) {
-		mmc_host_enable(host->mmc);
+		pm_runtime_get_sync(host->dev);
 		mmc_remove_host(host->mmc);
 		if (host->use_reg)
 			omap_hsmmc_reg_put(host);
@@ -2070,8 +2057,8 @@  static int omap_hsmmc_remove(struct platform_device *pdev)
 			free_irq(mmc_slot(host).card_detect_irq, host);
 		flush_work_sync(&host->mmc_carddetect_work);
 
-		mmc_host_disable(host->mmc);
-		clk_disable(host->iclk);
+		pm_runtime_put_sync(host->dev);
+		pm_runtime_disable(host->dev);
 		clk_put(host->fclk);
 		clk_put(host->iclk);
 		if (host->got_dbclk) {
@@ -2103,6 +2090,7 @@  static int omap_hsmmc_suspend(struct device *dev)
 		return 0;
 
 	if (host) {
+		pm_runtime_get_sync(host->dev);
 		host->suspended = 1;
 		if (host->pdata->suspend) {
 			ret = host->pdata->suspend(&pdev->dev,
@@ -2117,13 +2105,11 @@  static int omap_hsmmc_suspend(struct device *dev)
 		}
 		cancel_work_sync(&host->mmc_carddetect_work);
 		ret = mmc_suspend_host(host->mmc);
-		mmc_host_enable(host->mmc);
+
 		if (ret == 0) {
 			omap_hsmmc_disable_irq(host);
 			OMAP_HSMMC_WRITE(host->base, HCTL,
 				OMAP_HSMMC_READ(host->base, HCTL) & ~SDBP);
-			mmc_host_disable(host->mmc);
-			clk_disable(host->iclk);
 			if (host->got_dbclk)
 				clk_disable(host->dbclk);
 		} else {
@@ -2135,9 +2121,8 @@  static int omap_hsmmc_suspend(struct device *dev)
 					dev_dbg(mmc_dev(host->mmc),
 						"Unmask interrupt failed\n");
 			}
-			mmc_host_disable(host->mmc);
 		}
-
+		pm_runtime_put_sync(host->dev);
 	}
 	return ret;
 }
@@ -2153,14 +2138,7 @@  static int omap_hsmmc_resume(struct device *dev)
 		return 0;
 
 	if (host) {
-		ret = clk_enable(host->iclk);
-		if (ret)
-			goto clk_en_err;
-
-		if (mmc_host_enable(host->mmc) != 0) {
-			clk_disable(host->iclk);
-			goto clk_en_err;
-		}
+		pm_runtime_get_sync(host->dev);
 
 		if (host->got_dbclk)
 			clk_enable(host->dbclk);
@@ -2180,14 +2158,13 @@  static int omap_hsmmc_resume(struct device *dev)
 		ret = mmc_resume_host(host->mmc);
 		if (ret == 0)
 			host->suspended = 0;
+
+		pm_runtime_mark_last_busy(host->dev);
+		pm_runtime_put_autosuspend(host->dev);
 	}
 
 	return ret;
 
-clk_en_err:
-	dev_dbg(mmc_dev(host->mmc),
-		"Failed to enable MMC clocks during resume\n");
-	return ret;
 }
 
 #else
@@ -2195,9 +2172,33 @@  clk_en_err:
 #define omap_hsmmc_resume		NULL
 #endif
 
+static int omap_hsmmc_runtime_suspend(struct device *dev)
+{
+	struct omap_hsmmc_host *host;
+
+	host = platform_get_drvdata(to_platform_device(dev));
+	omap_hsmmc_context_save(host);
+	dev_dbg(mmc_dev(host->mmc), "disabled\n");
+
+	return 0;
+}
+
+static int omap_hsmmc_runtime_resume(struct device *dev)
+{
+	struct omap_hsmmc_host *host;
+
+	host = platform_get_drvdata(to_platform_device(dev));
+	omap_hsmmc_context_restore(host);
+	dev_dbg(mmc_dev(host->mmc), "host: enabled\n");
+
+	return 0;
+}
+
 static struct dev_pm_ops omap_hsmmc_dev_pm_ops = {
 	.suspend	= omap_hsmmc_suspend,
 	.resume		= omap_hsmmc_resume,
+	.runtime_suspend = omap_hsmmc_runtime_suspend,
+	.runtime_resume = omap_hsmmc_runtime_resume,
 };
 
 static struct platform_driver omap_hsmmc_driver = {