From patchwork Tue Oct 22 14:07:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 21214 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f70.google.com (mail-yh0-f70.google.com [209.85.213.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 55A01244B2 for ; Tue, 22 Oct 2013 14:07:51 +0000 (UTC) Received: by mail-yh0-f70.google.com with SMTP id a41sf19663370yho.5 for ; Tue, 22 Oct 2013 07:07:51 -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=VxE4tVPPn6yeZXHVy3OipYaWtK50NZuA3Wna+6QZUC8=; b=TXtSlE0V/wppMNjP6PKV5VdHafIXnHZNG0qHRdGQtZDvYvg2sLf/RqdefJMoHcB0i2 fWqcRZYaDLaCJVV7aWNaBh0t1bXCBr13TgWfclbViq7iK6jkV2SCvPhS1gCletde8/nT LJwDGRvpf6VF+yo9OWqN0wlaxWlwOtgcU6/fOI86qvsBtZGCZhYS+Eb8Cw8zoi0VU6UB TJjPJlGxZjO9HmBmUSmt63OUxl/v2FLLJAOu8B42DaSZKwZ+kdD4nx5Q8JZiIkyPF72u Pd422ArN5oPd9u1SF6yZbLzuizV0x5y1dmUhw53TfYURDB0hKIWYfBsrjD5kfpsxsBUr gIBg== X-Received: by 10.236.20.114 with SMTP id o78mr20538684yho.8.1382450871128; Tue, 22 Oct 2013 07:07:51 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.81.9 with SMTP id v9ls119845qex.99.gmail; Tue, 22 Oct 2013 07:07:51 -0700 (PDT) X-Received: by 10.52.227.6 with SMTP id rw6mr7114317vdc.19.1382450871015; Tue, 22 Oct 2013 07:07:51 -0700 (PDT) Received: from mail-ve0-f177.google.com (mail-ve0-f177.google.com [209.85.128.177]) by mx.google.com with ESMTPS id tj6si5822475vcb.43.2013.10.22.07.07.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 22 Oct 2013 07:07:51 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.177 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.177; Received: by mail-ve0-f177.google.com with SMTP id oz11so4354849veb.22 for ; Tue, 22 Oct 2013 07:07:50 -0700 (PDT) X-Gm-Message-State: ALoCoQl2En2tFVoA3T/tM3loSKJYrhN0gx1VnEb+90i8HBKuFlMkg7OCjTIYAB6aSxM2EGMNOdS1 X-Received: by 10.58.133.77 with SMTP id pa13mr1626625veb.21.1382450870926; Tue, 22 Oct 2013 07:07:50 -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 u4csp233664vcz; Tue, 22 Oct 2013 07:07:50 -0700 (PDT) X-Received: by 10.152.27.67 with SMTP id r3mr1506233lag.50.1382450869741; Tue, 22 Oct 2013 07:07:49 -0700 (PDT) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com [209.85.217.178]) by mx.google.com with ESMTPS id o9si8921148lao.71.2013.10.22.07.07.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 22 Oct 2013 07:07:49 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.217.178 is neither permitted nor denied by best guess record for domain of ulf.hansson@linaro.org) client-ip=209.85.217.178; Received: by mail-lb0-f178.google.com with SMTP id o14so2481254lbi.23 for ; Tue, 22 Oct 2013 07:07:49 -0700 (PDT) X-Received: by 10.112.210.197 with SMTP id mw5mr1827178lbc.42.1382450869010; Tue, 22 Oct 2013 07:07:49 -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 ur6sm15932916lbc.5.2013.10.22.07.07.47 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 22 Oct 2013 07:07:48 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Chris Ball Cc: Ulf Hansson , Guennadi Liakhovetski Subject: [PATCH v2 5/7] mmc: sh_mmcif: Move clock handling into runtime PM callbacks Date: Tue, 22 Oct 2013 16:07:24 +0200 Message-Id: <1382450846-17144-6-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1382450846-17144-1-git-send-email-ulf.hansson@linaro.org> References: <1382450846-17144-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.128.177 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 | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c index f4532dc..a1f421b 100644 --- a/drivers/mmc/host/sh_mmcif.c +++ b/drivers/mmc/host/sh_mmcif.c @@ -1021,7 +1021,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 +1031,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); } @@ -1441,7 +1439,7 @@ static int sh_mmcif_probe(struct platform_device *pdev) goto eofparse; } ret = sh_mmcif_clk_update(host); - if (ret < 0) + if (ret) goto eclkupdate; INIT_DELAYED_WORK(&host->timeout_work, mmcif_timeout_work); @@ -1478,7 +1476,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 +1565,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); + + sh_mmcif_clk_update(host); + return 0; +} +#endif + static const struct of_device_id mmcif_of_match[] = { { .compatible = "renesas,sh-mmcif" }, { } @@ -1576,6 +1591,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 = {