From patchwork Thu Jun 16 12:35:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pramod Gurav X-Patchwork-Id: 70184 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp237687qgy; Thu, 16 Jun 2016 05:35:49 -0700 (PDT) X-Received: by 10.36.204.139 with SMTP id x133mr7615540itf.12.1466080549800; Thu, 16 Jun 2016 05:35:49 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bx9si10344806pad.41.2016.06.16.05.35.49; Thu, 16 Jun 2016 05:35:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754313AbcFPMf1 (ORCPT + 3 others); Thu, 16 Jun 2016 08:35:27 -0400 Received: from mail-pf0-f170.google.com ([209.85.192.170]:35520 "EHLO mail-pf0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754282AbcFPMfV (ORCPT ); Thu, 16 Jun 2016 08:35:21 -0400 Received: by mail-pf0-f170.google.com with SMTP id c2so19817918pfa.2 for ; Thu, 16 Jun 2016 05:35:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=5nH6Ewat8f1+wZhFjGDTM28+kp5eO4QrcIougV8CYUw=; b=G/ZuQwa5GrQj/3ZkiJFzonh+Xfna5YOfEbnumuHQdUjOI2ajjh+uirCRUN9wbJhDQ7 3hvTD7lN9Drf2qiBQ2jyLdUBKr6pSxvSInHCf9glHrFuqp28VNfRsSGJNiei4lHiX+rB /dwanuy9vzqWX3BD8lesGThGR8/n9Q5Lbb+kU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=5nH6Ewat8f1+wZhFjGDTM28+kp5eO4QrcIougV8CYUw=; b=IoJwNuiOjkaHKJLrFZ7iWbZXSHm0Sf6TV/w2XGw/+hDwS3FYcwkumK1c+kpZjXomL8 9v7llFFYHRRzHqbuR461p0VoLWnW3VU2o1UL9LHwF1edD3VCOZczqzcHqLH4OcklZasU 9IWFvg3kLqOsnoXf8SFDz92B01+WoGCOCGoPKiyPWh+AnI8w684aibvyxhQhEhuvteWM TKLfU29Q8d9Y2bEBQ3goE5pz+oX7KXvDCYNKzt7F9ornD6v+FHE2g4NCdlAe80HPeG03 6mhSzaA8TX5ASS8cbxhDRgqXBO5JcIkYz1XGPXnGiJfnGnjQVphmMsSSg9F8KeS4Jd1p y1oQ== X-Gm-Message-State: ALyK8tLbUJB9AnZQghciY6LcYFiZVfdBzcmCuS3ieCVfSrl3VheZOCxxBEzPoJak7c8+XBYD X-Received: by 10.98.52.65 with SMTP id b62mr4981062pfa.40.1466080520692; Thu, 16 Jun 2016 05:35:20 -0700 (PDT) Received: from blr-ubuntu-56.ap.qualcomm.com ([202.46.23.61]) by smtp.gmail.com with ESMTPSA id tb7sm60681038pab.21.2016.06.16.05.35.18 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Jun 2016 05:35:20 -0700 (PDT) From: Pramod Gurav To: adrian.hunter@intel.com, ulf.hansson@linaro.org Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Pramod Gurav Subject: [PATCH] mmc: sdhci-msm: Add pm_runtime and system PM support Date: Thu, 16 Jun 2016 18:05:09 +0530 Message-Id: <1466080509-24015-1-git-send-email-pramod.gurav@linaro.org> X-Mailer: git-send-email 1.8.2.1 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Provides runtime PM callbacks to enable and disable clock resources when idle. Also support system PM callbacks to be called during system suspend and resume. Signed-off-by: Pramod Gurav --- drivers/mmc/host/sdhci-msm.c | 57 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) -- 1.8.2.1 -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c index 0653fe7..f4394c8 100644 --- a/drivers/mmc/host/sdhci-msm.c +++ b/drivers/mmc/host/sdhci-msm.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include "sdhci-pltfm.h" @@ -549,6 +550,11 @@ static int sdhci_msm_probe(struct platform_device *pdev) if (ret) goto clk_disable; + platform_set_drvdata(pdev, msm_host); + + pm_runtime_set_active(&pdev->dev); + pm_runtime_enable(&pdev->dev); + return 0; clk_disable: @@ -580,12 +586,63 @@ static int sdhci_msm_remove(struct platform_device *pdev) return 0; } +static int sdhci_msm_runtime_suspend(struct device *dev) +{ + struct sdhci_msm_host *msm_host = dev_get_drvdata(dev); + + clk_disable_unprepare(msm_host->clk); + clk_disable_unprepare(msm_host->pclk); + + return 0; +} + +static int sdhci_msm_runtime_resume(struct device *dev) +{ + struct sdhci_msm_host *msm_host = dev_get_drvdata(dev); + int ret; + + ret = clk_prepare_enable(msm_host->clk); + if (ret) { + dev_err(dev, "clk_enable failed: %d\n", ret); + return ret; + } + ret = clk_prepare_enable(msm_host->pclk); + if (ret) { + dev_err(dev, "clk_enable failed: %d\n", ret); + clk_disable_unprepare(msm_host->clk); + return ret; + } + + return 0; +} + +static int sdhci_msm_suspend(struct device *dev) +{ + pm_runtime_force_suspend(dev); + + return 0; +} + +static int sdhci_msm_resume(struct device *dev) +{ + pm_runtime_force_resume(dev); + + return 0; +} + +static const struct dev_pm_ops sdhci_msm_pm_ops = { + SET_LATE_SYSTEM_SLEEP_PM_OPS(sdhci_msm_suspend, sdhci_msm_resume) + SET_RUNTIME_PM_OPS(sdhci_msm_runtime_suspend, sdhci_msm_runtime_resume, + NULL) +}; + static struct platform_driver sdhci_msm_driver = { .probe = sdhci_msm_probe, .remove = sdhci_msm_remove, .driver = { .name = "sdhci_msm", .of_match_table = sdhci_msm_dt_match, + .pm = &sdhci_msm_pm_ops, }, };