From mboxrd@z Thu Jan 1 00:00:00 1970 From: hdegoede@redhat.com (Hans de Goede) Date: Sat, 22 Feb 2014 16:53:41 +0100 Subject: [PATCH v7 12/15] ata: ahci_platform: runtime resume the device before use In-Reply-To: <1393084424-31099-1-git-send-email-hdegoede@redhat.com> References: <1393084424-31099-1-git-send-email-hdegoede@redhat.com> Message-ID: <1393084424-31099-13-git-send-email-hdegoede@redhat.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org From: Roger Quadros 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 Signed-off-by: Roger Quadros Signed-off-by: Hans de Goede --- drivers/ata/ahci.h | 1 + drivers/ata/ahci_platform.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h index 3ab7ac9..51af275 100644 --- a/drivers/ata/ahci.h +++ b/drivers/ata/ahci.h @@ -324,6 +324,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 */ diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c index 99d38c1..75698a4 100644 --- a/drivers/ata/ahci_platform.c +++ b/drivers/ata/ahci_platform.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "ahci.h" static void ahci_host_stop(struct ata_host *host); @@ -229,6 +230,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]); } @@ -326,6 +332,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; @@ -635,6 +645,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: -- 1.9.0