From patchwork Wed Aug 23 04:15:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 110711 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp3591915qge; Tue, 22 Aug 2017 21:21:43 -0700 (PDT) X-Received: by 10.84.204.136 with SMTP id b8mr1569580ple.306.1503462103633; Tue, 22 Aug 2017 21:21:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503462103; cv=none; d=google.com; s=arc-20160816; b=j9O5EaUaCDckHiCW1tJFuYdz+KYj0xihlBWlFApFSWM/FAhnyDXfOQRM/GnkZwDlgw nK5pW2yTi7u4mOtMRBxAp9YJ/bGEgHzxRn1059IvvuCUVn5aPEqqNGVdao3yfFIhbAi3 Z9uYfuK43bI1bGBos9zagvIypyeiBRmtTNp1wVWvRHZc8qBMytbulUIWWsOh/iD0ywWm oPYLa4DLk14FOx8M/dp4QxijC1Fwk1kZ0dRkq2t07ugLd/Rs9kyPGVvM/qvrwofUYyWk iYrNcAhSBOMCRE9oN4l1+Dz+OnyckqkgkS3aFNmR12i1K1Y3/EQcuPS2psIx/v9pZQlS vN4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=t+BjuvYM4Nit13czLtsErx8yoDRi81bxgTZJYSBZkSA=; b=FLs/XLelSAc2tmwECtr6yLKaAh2q15Unqf81sxwNB1kTFu+BKnM++jcPnSfwaGkHmv KDCuvDUf1oqMzkfJRHnMNev70CRktKJig87qIBa+rVXP7oS9/ht31oGDAd0Q16roLAxS YBixVBNJrnQJVu4QHOQhW8sbPO24t14ITCDSvrYF2Ap09DhLI9lyBKjbNi7RZZ7b2YwO kzxQ5v+RSwPEMUVscLdhYTtGNOXYFQa0u5f+/FcscrPLtWuQJvIYn33zHuIOEQVid+bu UJwZJtUY9r/N20NZUWlnU8Evv3hI9+LJkkvf9FZKA4Iae6qpaJMA0TK3dkXPdE60SmZT ZDpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=2aNqdy5R; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y66si422138pfi.69.2017.08.22.21.21.43; Tue, 22 Aug 2017 21:21:43 -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=@nifty.com header.s=dec2015msa header.b=2aNqdy5R; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751161AbdHWEVm (ORCPT + 6 others); Wed, 23 Aug 2017 00:21:42 -0400 Received: from conuserg-08.nifty.com ([210.131.2.75]:27939 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751140AbdHWEVl (ORCPT ); Wed, 23 Aug 2017 00:21:41 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-08.nifty.com with ESMTP id v7N4F6Rs020925; Wed, 23 Aug 2017 13:15:10 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com v7N4F6Rs020925 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1503461711; bh=OQDbESwAjjjMkG0Ds2aajvrXV+pdm8R25Uag8ned0wA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2aNqdy5Rl2CVbbNTSZKOcAs/6wRSTg1sIZ4w9+HdkGbIgw94mxBm8/prqqvx0Iy62 X60yQ//Yh5bW44jiVtu/h1t5VdOvEQFo/gD6oUc/qjn7ksaIESVloau/YdCLnPwhHn 6rmGBgEDGKNMr5Bq+l/+MFB1OZJJiPOMMx+Mme2qhtVeQ+kwUWKQK1LLqZDPCq19Rb QjwMwo38ODjCuktUZSYWUApm0A29NdkQla6W6hv2oRc+7/vhhYtxPegsSMem45pYYN h2oG88QqwFzJuX6VEqAi6IL0cZrZxYB71Qh+xrYavPmfcSSz4pBKEvYMMjup6DC2C9 gDU81KnDDXjPA== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-mmc@vger.kernel.org Cc: Piotr Sroka , Hu Ziji , Adrian Hunter , Christian Daudt , Scott Branden , Zhangfei Gao , Kevin Hao , Olof Johansson , Masahiro Yamada , Al Cooper , linux-kernel@vger.kernel.org, Brian Norris , bcm-kernel-feedback-list@broadcom.com, Barry Song , Florian Fainelli , Gregory Fong , linux-arm-kernel@lists.infradead.org, Ulf Hansson Subject: [PATCH v4 3/4] mmc: sdhci: enable/disable the clock in sdhci_pltfm_suspend/resume Date: Wed, 23 Aug 2017 13:15:02 +0900 Message-Id: <1503461703-16225-4-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503461703-16225-1-git-send-email-yamada.masahiro@socionext.com> References: <1503461703-16225-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org This commit provides similar cleanups as commit 83eacdfa2529 ("mmc: sdhci: disable the clock in sdhci_pltfm_unregister()") did for unregister hooks. sdhci-brcmstb.c and sdhci-sirf.c implement their own suspend/resume hooks to handle pltfm_host->clk. Move clock handling to sdhci_pltfm.c so that the drivers can reuse sdhci_pltfm_pmops. The following drivers did not previously touch pltfm_host->clk during suspend/resume, but now do: - sdhci-bcm-kona.c - sdhci-dove.c - sdhci-iproc.c - sdhci-pxav2.c - sdhci-tegra.c - sdhci-xenon.c Signed-off-by: Masahiro Yamada --- Changes in v4: - Disable clk when resume fails Changes in v3: None Changes in v2: - Fix build error reported by kbuild test robot drivers/mmc/host/sdhci-brcmstb.c | 37 +------------------------------------ drivers/mmc/host/sdhci-pltfm.c | 22 ++++++++++++++++++++-- drivers/mmc/host/sdhci-sirf.c | 39 +-------------------------------------- 3 files changed, 22 insertions(+), 76 deletions(-) -- 2.7.4 -- 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 Acked-by: Adrian Hunter Acked-by: Al Cooper diff --git a/drivers/mmc/host/sdhci-brcmstb.c b/drivers/mmc/host/sdhci-brcmstb.c index e2f638338e8f..6d461fcdd663 100644 --- a/drivers/mmc/host/sdhci-brcmstb.c +++ b/drivers/mmc/host/sdhci-brcmstb.c @@ -21,41 +21,6 @@ #include "sdhci-pltfm.h" -#ifdef CONFIG_PM_SLEEP - -static int sdhci_brcmstb_suspend(struct device *dev) -{ - struct sdhci_host *host = dev_get_drvdata(dev); - struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); - int res; - - if (host->tuning_mode != SDHCI_TUNING_MODE_3) - mmc_retune_needed(host->mmc); - - res = sdhci_suspend_host(host); - if (res) - return res; - clk_disable_unprepare(pltfm_host->clk); - return res; -} - -static int sdhci_brcmstb_resume(struct device *dev) -{ - struct sdhci_host *host = dev_get_drvdata(dev); - struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); - int err; - - err = clk_prepare_enable(pltfm_host->clk); - if (err) - return err; - return sdhci_resume_host(host); -} - -#endif /* CONFIG_PM_SLEEP */ - -static SIMPLE_DEV_PM_OPS(sdhci_brcmstb_pmops, sdhci_brcmstb_suspend, - sdhci_brcmstb_resume); - static const struct sdhci_ops sdhci_brcmstb_ops = { .set_clock = sdhci_set_clock, .set_bus_width = sdhci_set_bus_width, @@ -131,7 +96,7 @@ MODULE_DEVICE_TABLE(of, sdhci_brcm_of_match); static struct platform_driver sdhci_brcmstb_driver = { .driver = { .name = "sdhci-brcmstb", - .pm = &sdhci_brcmstb_pmops, + .pm = &sdhci_pltfm_pmops, .of_match_table = of_match_ptr(sdhci_brcm_of_match), }, .probe = sdhci_brcmstb_probe, diff --git a/drivers/mmc/host/sdhci-pltfm.c b/drivers/mmc/host/sdhci-pltfm.c index e090d8c42ddb..4c0135e184e9 100644 --- a/drivers/mmc/host/sdhci-pltfm.c +++ b/drivers/mmc/host/sdhci-pltfm.c @@ -212,18 +212,36 @@ EXPORT_SYMBOL_GPL(sdhci_pltfm_unregister); static int sdhci_pltfm_suspend(struct device *dev) { struct sdhci_host *host = dev_get_drvdata(dev); + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + int ret; if (host->tuning_mode != SDHCI_TUNING_MODE_3) mmc_retune_needed(host->mmc); - return sdhci_suspend_host(host); + ret = sdhci_suspend_host(host); + if (ret) + return ret; + + clk_disable_unprepare(pltfm_host->clk); + + return 0; } static int sdhci_pltfm_resume(struct device *dev) { struct sdhci_host *host = dev_get_drvdata(dev); + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + int ret; + + ret = clk_prepare_enable(pltfm_host->clk); + if (ret) + return ret; - return sdhci_resume_host(host); + ret = sdhci_resume_host(host); + if (ret) + clk_disable_unprepare(pltfm_host->clk); + + return ret; } #endif diff --git a/drivers/mmc/host/sdhci-sirf.c b/drivers/mmc/host/sdhci-sirf.c index c251c6c0a112..0c7aa89df4e2 100644 --- a/drivers/mmc/host/sdhci-sirf.c +++ b/drivers/mmc/host/sdhci-sirf.c @@ -230,43 +230,6 @@ static int sdhci_sirf_probe(struct platform_device *pdev) return ret; } -#ifdef CONFIG_PM_SLEEP -static int sdhci_sirf_suspend(struct device *dev) -{ - struct sdhci_host *host = dev_get_drvdata(dev); - struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); - int ret; - - if (host->tuning_mode != SDHCI_TUNING_MODE_3) - mmc_retune_needed(host->mmc); - - ret = sdhci_suspend_host(host); - if (ret) - return ret; - - clk_disable(pltfm_host->clk); - - return 0; -} - -static int sdhci_sirf_resume(struct device *dev) -{ - struct sdhci_host *host = dev_get_drvdata(dev); - struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); - int ret; - - ret = clk_enable(pltfm_host->clk); - if (ret) { - dev_dbg(dev, "Resume: Error enabling clock\n"); - return ret; - } - - return sdhci_resume_host(host); -} -#endif - -static SIMPLE_DEV_PM_OPS(sdhci_sirf_pm_ops, sdhci_sirf_suspend, sdhci_sirf_resume); - static const struct of_device_id sdhci_sirf_of_match[] = { { .compatible = "sirf,prima2-sdhc" }, { } @@ -277,7 +240,7 @@ static struct platform_driver sdhci_sirf_driver = { .driver = { .name = "sdhci-sirf", .of_match_table = sdhci_sirf_of_match, - .pm = &sdhci_sirf_pm_ops, + .pm = &sdhci_pltfm_pmops, }, .probe = sdhci_sirf_probe, .remove = sdhci_pltfm_unregister,