aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoger Quadros <rogerq@ti.com>2014-02-22 10:53:41 -0500
committerTejun Heo <tj@kernel.org>2014-02-22 15:35:43 -0500
commite708e46edac8ab2f31e7ee991aa3c5b87638e658 (patch)
tree8b9de353a09e14993f2daf2a4f05864236eaca9a
parent21b5faeec229d4f70a7f60a7b0b065c98198f491 (diff)
ata: ahci_platform: runtime resume the device before use
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>
-rw-r--r--drivers/ata/ahci.h1
-rw-r--r--drivers/ata/ahci_platform.c15
2 files changed, 16 insertions, 0 deletions
diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h
index 3ab7ac9bb6a7..51af275b3388 100644
--- a/drivers/ata/ahci.h
+++ b/drivers/ata/ahci.h
@@ -324,6 +324,7 @@ struct ahci_host_priv {
324 u32 em_loc; /* enclosure management location */ 324 u32 em_loc; /* enclosure management location */
325 u32 em_buf_sz; /* EM buffer size in byte */ 325 u32 em_buf_sz; /* EM buffer size in byte */
326 u32 em_msg_type; /* EM message type */ 326 u32 em_msg_type; /* EM message type */
327 bool got_runtime_pm; /* Did we do pm_runtime_get? */
327 struct clk *clks[AHCI_MAX_CLKS]; /* Optional */ 328 struct clk *clks[AHCI_MAX_CLKS]; /* Optional */
328 struct regulator *target_pwr; /* Optional */ 329 struct regulator *target_pwr; /* Optional */
329 struct phy *phy; /* If platform uses phy */ 330 struct phy *phy; /* If platform uses phy */
diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c
index 243dde36cd98..fc32863d6a5a 100644
--- a/drivers/ata/ahci_platform.c
+++ b/drivers/ata/ahci_platform.c
@@ -23,6 +23,7 @@
23#include <linux/libata.h> 23#include <linux/libata.h>
24#include <linux/ahci_platform.h> 24#include <linux/ahci_platform.h>
25#include <linux/phy/phy.h> 25#include <linux/phy/phy.h>
26#include <linux/pm_runtime.h>
26#include "ahci.h" 27#include "ahci.h"
27 28
28static void ahci_host_stop(struct ata_host *host); 29static void ahci_host_stop(struct ata_host *host);
@@ -216,6 +217,11 @@ static void ahci_platform_put_resources(struct device *dev, void *res)
216 struct ahci_host_priv *hpriv = res; 217 struct ahci_host_priv *hpriv = res;
217 int c; 218 int c;
218 219
220 if (hpriv->got_runtime_pm) {
221 pm_runtime_put_sync(dev);
222 pm_runtime_disable(dev);
223 }
224
219 for (c = 0; c < AHCI_MAX_CLKS && hpriv->clks[c]; c++) 225 for (c = 0; c < AHCI_MAX_CLKS && hpriv->clks[c]; c++)
220 clk_put(hpriv->clks[c]); 226 clk_put(hpriv->clks[c]);
221} 227}
@@ -309,6 +315,10 @@ struct ahci_host_priv *ahci_platform_get_resources(
309 } 315 }
310 } 316 }
311 317
318 pm_runtime_enable(dev);
319 pm_runtime_get_sync(dev);
320 hpriv->got_runtime_pm = true;
321
312 devres_remove_group(dev, NULL); 322 devres_remove_group(dev, NULL);
313 return hpriv; 323 return hpriv;
314 324
@@ -603,6 +613,11 @@ int ahci_platform_resume(struct device *dev)
603 if (rc) 613 if (rc)
604 goto disable_resources; 614 goto disable_resources;
605 615
616 /* We resumed so update PM runtime state */
617 pm_runtime_disable(dev);
618 pm_runtime_set_active(dev);
619 pm_runtime_enable(dev);
620
606 return 0; 621 return 0;
607 622
608disable_resources: 623disable_resources: