]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ata: ahci_platform: runtime resume the device before use
authorRoger Quadros <rogerq@ti.com>
Sat, 22 Feb 2014 15:53:41 +0000 (16:53 +0100)
committerNitin Garg <nitin.garg@freescale.com>
Fri, 16 Jan 2015 03:17:18 +0000 (21:17 -0600)
On OMAP platforms the device needs to be runtime resumed before it can
be accessed. The OMAP HWMOD framework takes care of enabling the
module and its resources based on the device's runtime PM state.

In this patch we runtime resume during .probe() and runtime suspend
after .remove().

We also update the runtime PM state during .resume().

CC: Balaji T K <balajitk@ti.com>
Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
(cherry picked from commit e708e46edac8ab2f31e7ee991aa3c5b87638e658)

drivers/ata/ahci.h
drivers/ata/ahci_platform.c

index 4ae91674e05477e02f1e8297824d0dcb8a55e32b..b5eb886da22635c3c76775bc0ef6374af3464b98 100644 (file)
@@ -325,6 +325,7 @@ struct ahci_host_priv {
        u32                     em_loc; /* enclosure management location */
        u32                     em_buf_sz;      /* EM buffer size in byte */
        u32                     em_msg_type;    /* EM message type */
+       bool                    got_runtime_pm; /* Did we do pm_runtime_get? */
        struct clk              *clks[AHCI_MAX_CLKS]; /* Optional */
        struct regulator        *target_pwr;    /* Optional */
        struct phy              *phy;           /* If platform uses phy */
index c209d93bce3218651b56f89e5e54dc64d94d5401..d58f1b5223d6ef160facc4ad1643d23981b9ee07 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/libata.h>
 #include <linux/ahci_platform.h>
 #include <linux/phy/phy.h>
+#include <linux/pm_runtime.h>
 #include "ahci.h"
 
 static void ahci_host_stop(struct ata_host *host);
@@ -217,6 +218,11 @@ static void ahci_platform_put_resources(struct device *dev, void *res)
        struct ahci_host_priv *hpriv = res;
        int c;
 
+       if (hpriv->got_runtime_pm) {
+               pm_runtime_put_sync(dev);
+               pm_runtime_disable(dev);
+       }
+
        for (c = 0; c < AHCI_MAX_CLKS && hpriv->clks[c]; c++)
                clk_put(hpriv->clks[c]);
 }
@@ -310,6 +316,10 @@ struct ahci_host_priv *ahci_platform_get_resources(
                }
        }
 
+       pm_runtime_enable(dev);
+       pm_runtime_get_sync(dev);
+       hpriv->got_runtime_pm = true;
+
        devres_remove_group(dev, NULL);
        return hpriv;
 
@@ -604,6 +614,11 @@ int ahci_platform_resume(struct device *dev)
        if (rc)
                goto disable_resources;
 
+       /* We resumed so update PM runtime state */
+       pm_runtime_disable(dev);
+       pm_runtime_set_active(dev);
+       pm_runtime_enable(dev);
+
        return 0;
 
 disable_resources: