From patchwork Wed Oct 2 08:30:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 20744 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f71.google.com (mail-vb0-f71.google.com [209.85.212.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7E37025E05 for ; Wed, 2 Oct 2013 08:31:13 +0000 (UTC) Received: by mail-vb0-f71.google.com with SMTP id g17sf995117vbg.6 for ; Wed, 02 Oct 2013 01:31:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=bQE0hSnYdC3lvLX1cVsCAKD5plSKlnwfIRe/tl29WLs=; b=XWmSmE4okO9vMp/bOtFGsDCF4xjVMA1QS1EXp7b7nAGzuVbJ/uzf/JWqWMmAITLbSv n7gMSDIYs21ShI1S0AWx/Vg5pUuOCB1OqP230tJm53QUDz9XUrwoP0ZgUPXRqsGuC8d2 471o4sey2AZih8+hDAW3J4tC6DMNkuCX8uBraf3JdpdPT7yA9sWMtQh6xlbKfkB4xuCL fnxePd2W0J0/aKPUC0WYNIALdD4STXgP1XQY63F5Z0bqsN912Ws6vVvGJQPpTaL4Qgz1 JDQ5wW6Aq5j//cWLteIhVsh2DYZOVm2ZR4zDk5fTrKb40UjrcK3z+onYmPrCWxPWlvJV estw== X-Received: by 10.236.73.164 with SMTP id v24mr1019740yhd.24.1380702671981; Wed, 02 Oct 2013 01:31:11 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.83.7 with SMTP id m7ls405595qey.0.gmail; Wed, 02 Oct 2013 01:31:11 -0700 (PDT) X-Received: by 10.52.75.228 with SMTP id f4mr747123vdw.6.1380702671864; Wed, 02 Oct 2013 01:31:11 -0700 (PDT) Received: from mail-vc0-f174.google.com (mail-vc0-f174.google.com [209.85.220.174]) by mx.google.com with ESMTPS id th8si101089veb.20.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 02 Oct 2013 01:31:11 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.174; Received: by mail-vc0-f174.google.com with SMTP id gd11so279543vcb.19 for ; Wed, 02 Oct 2013 01:31:11 -0700 (PDT) X-Gm-Message-State: ALoCoQnk/nRU3aDOON9jXcGQlD3DJgYqxmdq5Z4o+UPg75KaEiLGP5/Z5M6Rv9AigynwOkajZS1/ X-Received: by 10.220.13.20 with SMTP id z20mr934270vcz.0.1380702671775; Wed, 02 Oct 2013 01:31:11 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp79372vcz; Wed, 2 Oct 2013 01:31:11 -0700 (PDT) X-Received: by 10.152.26.72 with SMTP id j8mr954676lag.19.1380702670354; Wed, 02 Oct 2013 01:31:10 -0700 (PDT) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com [209.85.217.173]) by mx.google.com with ESMTPS id l7si653566lbd.50.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 02 Oct 2013 01:31:10 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.217.173 is neither permitted nor denied by best guess record for domain of ulf.hansson@linaro.org) client-ip=209.85.217.173; Received: by mail-lb0-f173.google.com with SMTP id o14so460341lbi.4 for ; Wed, 02 Oct 2013 01:31:09 -0700 (PDT) X-Received: by 10.152.28.105 with SMTP id a9mr475083lah.41.1380702669710; Wed, 02 Oct 2013 01:31:09 -0700 (PDT) Received: from linaro-ulf.lan (90-231-160-185-no158.tbcn.telia.com. [90.231.160.185]) by mx.google.com with ESMTPSA id e4sm890041lba.15.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 02 Oct 2013 01:31:08 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Chris Ball Cc: Ulf Hansson , Guennadi Liakhovetski Subject: [PATCH 5/7] mmc: sd_mmcif: Move clock handling into runtime PM callbacks Date: Wed, 2 Oct 2013 10:30:49 +0200 Message-Id: <1380702651-13389-6-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1380702651-13389-1-git-send-email-ulf.hansson@linaro.org> References: <1380702651-13389-1-git-send-email-ulf.hansson@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ulf.hansson@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Implement callbacks for runtime suspend|resume and leave the clock to be handled from there. The .set_ios function is still capable of using the interal registers to gate the clock when the frequency is zero, but the operations needed towards the clk API is now handled from the runtime callbacks. >From now on, CONFIG_PM_RUNTIME is required handle power save with full clock gating at request inactivity. Cc: Guennadi Liakhovetski Signed-off-by: Ulf Hansson --- drivers/mmc/host/sh_mmcif.c | 47 ++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c index f4532dc..e234856 100644 --- a/drivers/mmc/host/sh_mmcif.c +++ b/drivers/mmc/host/sh_mmcif.c @@ -964,19 +964,6 @@ static void sh_mmcif_request(struct mmc_host *mmc, struct mmc_request *mrq) sh_mmcif_start_cmd(host, mrq); } -static int sh_mmcif_clk_update(struct sh_mmcif_host *host) -{ - int ret = clk_prepare_enable(host->hclk); - - if (!ret) { - host->clk = clk_get_rate(host->hclk); - host->mmc->f_max = host->clk / 2; - host->mmc->f_min = host->clk / 512; - } - - return ret; -} - static void sh_mmcif_set_power(struct sh_mmcif_host *host, struct mmc_ios *ios) { struct mmc_host *mmc = host->mmc; @@ -1021,7 +1008,6 @@ static void sh_mmcif_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) } } if (host->power) { - clk_disable_unprepare(host->hclk); host->power = false; if (ios->power_mode == MMC_POWER_OFF) sh_mmcif_set_power(host, ios); @@ -1032,7 +1018,6 @@ static void sh_mmcif_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) if (ios->clock) { if (!host->power) { - sh_mmcif_clk_update(host); host->power = true; sh_mmcif_sync_reset(host); } @@ -1440,9 +1425,16 @@ static int sh_mmcif_probe(struct platform_device *pdev) dev_err(&pdev->dev, "cannot get clock: %d\n", ret); goto eofparse; } - ret = sh_mmcif_clk_update(host); - if (ret < 0) + + ret = clk_prepare_enable(host->hclk); + if (ret) { + dev_err(&pdev->dev, "cannot enable clock: %d\n", ret); goto eclkupdate; + } + + host->clk = clk_get_rate(host->hclk); + host->mmc->f_max = host->clk / 2; + host->mmc->f_min = host->clk / 512; INIT_DELAYED_WORK(&host->timeout_work, mmcif_timeout_work); @@ -1478,7 +1470,6 @@ static int sh_mmcif_probe(struct platform_device *pdev) pm_runtime_set_active(&pdev->dev); pm_runtime_enable(&pdev->dev); - clk_disable_unprepare(host->hclk); ret = mmc_add_host(mmc); if (ret < 0) goto emmcaddh; @@ -1568,6 +1559,24 @@ static int sh_mmcif_resume(struct device *dev) } #endif +#ifdef CONFIG_PM_RUNTIME +static int sh_mmcif_runtime_suspend(struct device *dev) +{ + struct sh_mmcif_host *host = dev_get_drvdata(dev); + + clk_disable_unprepare(host->hclk); + return 0; +} + +static int sh_mmcif_runtime_resume(struct device *dev) +{ + struct sh_mmcif_host *host = dev_get_drvdata(dev); + + clk_prepare_enable(host->hclk); + return 0; +} +#endif + static const struct of_device_id mmcif_of_match[] = { { .compatible = "renesas,sh-mmcif" }, { } @@ -1576,6 +1585,8 @@ MODULE_DEVICE_TABLE(of, mmcif_of_match); static const struct dev_pm_ops sh_mmcif_dev_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(sh_mmcif_suspend, sh_mmcif_resume) + SET_RUNTIME_PM_OPS(sh_mmcif_runtime_suspend, sh_mmcif_runtime_resume, + NULL) }; static struct platform_driver sh_mmcif_driver = {