From patchwork Tue Aug 15 15:45:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 110180 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp5832386qge; Tue, 15 Aug 2017 08:47:00 -0700 (PDT) X-Received: by 10.84.217.93 with SMTP id e29mr31946787plj.472.1502812020545; Tue, 15 Aug 2017 08:47:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502812020; cv=none; d=google.com; s=arc-20160816; b=vBhAZcr5RyA88PVHlWTKLWPNrf8T784uZZoaUVxyjqbQHkhjCCFio33WbjpBQQuJ2G TbJJg/Ys0BeOTZ1XnrCkEakqU1cOVUOLxrIU5tQNluypeZTl85Asl88UE1tIChCFApJP KDVc3W9/nvFpMRTelHnxQWsMhicQ5ZxbshZ4EIZaVtlt6vo87tsBqip4eqz599d8g+oE XEopQ5VhQ02mk/whPQZRBmYK/2TM9V0iy/ow4DYTHKSnSwjULFqyP9CY0OjVe3GJ0VwC bSDdWaEIUfdRY4K9CdiwE6/ilG/VO5yYwJAjpzHC6YFUoXsHYquGP8epvQU5LKX3rI9T GZNQ== 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=p/v/5MvR8/XHd1r6xt6r7VTrgYtooUgYACifvrYxjAw=; b=YXjpnB1p4K3Nxu3o1qt0Zm4Ld8OWpkEKr3VPHVJOugXUWV9pbFCklcxkYopggkqH+x aW34jO6R5GUK/fQG4kpfDGXSFZVS4o+LTeUuzM9OOFuM7rdgPk0j/StqAsWKqB9ZBV6k IsKJE0bX8vUzn1ArOzOVDq2uxGnm5OxqXIhguyjrxQBQgIoySL4aKplopxSVPLHQFfvb l7diYwEYgYVsq09t5RA04fT+iX6+gxO7M/Aes3p0hqt21atU7rPOr3SQKIO33bMVhXE8 TPWD8waMP2mh/IiYxJwvxjDSCv8VQmRq9k3ImV7TJ6vN50T6IAgwo/P+fuApKF5H+1O3 CGyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=Cyjz1Ok4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 i21si5699232pfi.394.2017.08.15.08.47.00; Tue, 15 Aug 2017 08:47:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=Cyjz1Ok4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752799AbdHOPq5 (ORCPT + 25 others); Tue, 15 Aug 2017 11:46:57 -0400 Received: from conuserg-08.nifty.com ([210.131.2.75]:39975 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752483AbdHOPqx (ORCPT ); Tue, 15 Aug 2017 11:46:53 -0400 Received: from grover.sesame (FL1-122-131-185-176.osk.mesh.ad.jp [122.131.185.176]) (authenticated) by conuserg-08.nifty.com with ESMTP id v7FFjk9Y018213; Wed, 16 Aug 2017 00:45:47 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com v7FFjk9Y018213 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1502811948; bh=p/v/5MvR8/XHd1r6xt6r7VTrgYtooUgYACifvrYxjAw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cyjz1Ok4GiY5fr9FuHYp7wxmD/GiLnyGh/fS3vBVsCpfFOX5BT7k5dR7ztSonW8vF pLkoq6GK2XLlc0eej0w7T+WmZKKJOJkjwxbAP1+njUInE3y0xrzHXcRNJenT9CBJYF b/yFXmZqkIML+HDljFLRPGIaZvk61SWo/w6eyQX1UoRo664yhUJIAAB+WwqcLfqy85 p2cjPVW0DjmS262d8rjZGvJKiqb7Bq9gL1mnsN8gxNfsxEYeTXQ6aMxnL1I2AQ0tSa YBWM3YptrIVZrRlkbQSz1fgczcBLTxEI7wcGeln9x5yWxYftW9qAx8GsQhVIt0tUQs mc5HAMpvedb5w== X-Nifty-SrcIP: [122.131.185.176] 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 , linux-kernel@vger.kernel.org, Ulf Hansson Subject: [PATCH v3 1/4] mmc: sdhci-cadence: add suspend / resume support Date: Wed, 16 Aug 2017 00:45:19 +0900 Message-Id: <1502811922-9346-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502811922-9346-1-git-send-email-yamada.masahiro@socionext.com> References: <1502811922-9346-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, the probe function initializes the PHY, but PHY settings are lost during the sleep state. Restore the PHY registers when resuming. To facilitate this, split sdhci_cdns_phy_init() into the DT parse part and PHY update part so that the latter can be invoked from the resume hook. Signed-off-by: Masahiro Yamada --- Changes in v3: - Use #ifdef CONFIG_PM_SLEEP instead of __maybe_unused - Add own sdhci_cdns_suspend implementation to not depend on the core change Changes in v2: None drivers/mmc/host/sdhci-cadence.c | 97 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 88 insertions(+), 9 deletions(-) -- 2.7.4 diff --git a/drivers/mmc/host/sdhci-cadence.c b/drivers/mmc/host/sdhci-cadence.c index 19d5698244b5..751ba706bf03 100644 --- a/drivers/mmc/host/sdhci-cadence.c +++ b/drivers/mmc/host/sdhci-cadence.c @@ -67,9 +67,16 @@ */ #define SDHCI_CDNS_MAX_TUNING_LOOP 40 +struct sdhci_cdns_phy_param { + u8 addr; + u8 data; +}; + struct sdhci_cdns_priv { void __iomem *hrs_addr; bool enhanced_strobe; + unsigned int nr_phy_params; + struct sdhci_cdns_phy_param phy_params[0]; }; struct sdhci_cdns_phy_cfg { @@ -115,9 +122,22 @@ static int sdhci_cdns_write_phy_reg(struct sdhci_cdns_priv *priv, return 0; } -static int sdhci_cdns_phy_init(struct device_node *np, - struct sdhci_cdns_priv *priv) +static unsigned int sdhci_cdns_phy_param_count(struct device_node *np) { + unsigned int count = 0; + int i; + + for (i = 0; i < ARRAY_SIZE(sdhci_cdns_phy_cfgs); i++) + if (of_property_read_bool(np, sdhci_cdns_phy_cfgs[i].property)) + count++; + + return count; +} + +static void sdhci_cdns_phy_param_parse(struct device_node *np, + struct sdhci_cdns_priv *priv) +{ + struct sdhci_cdns_phy_param *p = priv->phy_params; u32 val; int ret, i; @@ -127,9 +147,19 @@ static int sdhci_cdns_phy_init(struct device_node *np, if (ret) continue; - ret = sdhci_cdns_write_phy_reg(priv, - sdhci_cdns_phy_cfgs[i].addr, - val); + p->addr = sdhci_cdns_phy_cfgs[i].addr; + p->data = val; + p++; + } +} + +static int sdhci_cdns_phy_init(struct sdhci_cdns_priv *priv) +{ + int ret, i; + + for (i = 0; i < priv->nr_phy_params; i++) { + ret = sdhci_cdns_write_phy_reg(priv, priv->phy_params[i].addr, + priv->phy_params[i].data); if (ret) return ret; } @@ -302,6 +332,8 @@ static int sdhci_cdns_probe(struct platform_device *pdev) struct sdhci_pltfm_host *pltfm_host; struct sdhci_cdns_priv *priv; struct clk *clk; + size_t priv_size; + unsigned int nr_phy_params; int ret; struct device *dev = &pdev->dev; @@ -313,7 +345,9 @@ static int sdhci_cdns_probe(struct platform_device *pdev) if (ret) return ret; - host = sdhci_pltfm_init(pdev, &sdhci_cdns_pltfm_data, sizeof(*priv)); + nr_phy_params = sdhci_cdns_phy_param_count(dev->of_node); + priv_size = sizeof(*priv) + sizeof(priv->phy_params[0]) * nr_phy_params; + host = sdhci_pltfm_init(pdev, &sdhci_cdns_pltfm_data, priv_size); if (IS_ERR(host)) { ret = PTR_ERR(host); goto disable_clk; @@ -322,7 +356,8 @@ static int sdhci_cdns_probe(struct platform_device *pdev) pltfm_host = sdhci_priv(host); pltfm_host->clk = clk; - priv = sdhci_cdns_priv(host); + priv = sdhci_pltfm_priv(pltfm_host); + priv->nr_phy_params = nr_phy_params; priv->hrs_addr = host->ioaddr; priv->enhanced_strobe = false; host->ioaddr += SDHCI_CDNS_SRS_BASE; @@ -336,7 +371,9 @@ static int sdhci_cdns_probe(struct platform_device *pdev) if (ret) goto free; - ret = sdhci_cdns_phy_init(dev->of_node, priv); + sdhci_cdns_phy_param_parse(dev->of_node, priv); + + ret = sdhci_cdns_phy_init(priv); if (ret) goto free; @@ -353,6 +390,48 @@ static int sdhci_cdns_probe(struct platform_device *pdev) return ret; } +#ifdef CONFIG_PM_SLEEP +static int sdhci_cdns_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_unprepare(pltfm_host->clk); + + return 0; +} + +static int sdhci_cdns_resume(struct device *dev) +{ + struct sdhci_host *host = dev_get_drvdata(dev); + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + struct sdhci_cdns_priv *priv = sdhci_pltfm_priv(pltfm_host); + int ret; + + ret = clk_prepare_enable(pltfm_host->clk); + if (ret) + return ret; + + ret = sdhci_cdns_phy_init(priv); + if (ret) + return ret; + + return sdhci_resume_host(host); +} +#endif + +static const struct dev_pm_ops sdhci_cdns_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(sdhci_cdns_suspend, sdhci_cdns_resume) +}; + static const struct of_device_id sdhci_cdns_match[] = { { .compatible = "socionext,uniphier-sd4hc" }, { .compatible = "cdns,sd4hc" }, @@ -363,7 +442,7 @@ MODULE_DEVICE_TABLE(of, sdhci_cdns_match); static struct platform_driver sdhci_cdns_driver = { .driver = { .name = "sdhci-cdns", - .pm = &sdhci_pltfm_pmops, + .pm = &sdhci_cdns_pm_ops, .of_match_table = sdhci_cdns_match, }, .probe = sdhci_cdns_probe, From patchwork Tue Aug 15 15:45:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 110183 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp5833233qge; Tue, 15 Aug 2017 08:47:50 -0700 (PDT) X-Received: by 10.99.96.202 with SMTP id u193mr27537961pgb.121.1502812070515; Tue, 15 Aug 2017 08:47:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502812070; cv=none; d=google.com; s=arc-20160816; b=bLHWplvlPjxjRiDLRnRT6qGf+3+qM6VsvSZPSYSl6YBVW0m63ujt7dlHCFyveKsvBw DIyX7atEwnhxUacZrs1PL4Y37wtjYcaedZ9q9IYNylh9CJMFYugZI/rR/YntCSuAaXwN YGyAXIMeGhC/I2OO/YgapBhbDj8yqS7cOUmE+6Z2YE1mZoc9FPH4RtGFejJS2lWespQU 5SbGf4DBH1S2G96wRMetCl5tvkl77Vx6KXHHMPDGmIicoXTVGo7gc67lk8I7WQkepnIF D9b+IJ44D9NpUeZx6LRAVKb2tVhrvRB6h4MHttH4OcOUIl2lrKzm4d6ne4KC4DfOKd2S gTaQ== 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=BPydXt0UmfGPYg9t7ztFuuoYkseVbFMkgeoMaqtBc7Q=; b=TuKs9nepxCWkKmrr00OLG/WEgIbzN+GDoEE4SNs8jYWhW+fBp4GI3FPkiMFaXoaoqi CHI/3B8OiB1lTPR7RXimSBSWdU2h+WC2T82ULmlsU0tkh74J4yPJvgH5mVXlMKc6P8ey DINhOfNIzX7NU/hLPQ+kHwu2GuYU2og0f3oYjJEIxTEUBSHdBuXArl2XeIog6VMmmfOo nLWFpA4XmMWv+XTstDSSJu1KBcFiYeB3+nrfCFaByLu/tU/rOrgYoOgrrWRaWiQ4lule 1LaIlUTBg5lBsb+HvPiP5h0q8lqIPv+qYAVMKojLOXBhe0lgPHwsdzErVdBpmir2hNaF L3gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=yGl0EKsW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 75si5673210pfr.248.2017.08.15.08.47.50; Tue, 15 Aug 2017 08:47:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=yGl0EKsW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753104AbdHOPrr (ORCPT + 25 others); Tue, 15 Aug 2017 11:47:47 -0400 Received: from conuserg-08.nifty.com ([210.131.2.75]:40883 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752909AbdHOPrp (ORCPT ); Tue, 15 Aug 2017 11:47:45 -0400 Received: from grover.sesame (FL1-122-131-185-176.osk.mesh.ad.jp [122.131.185.176]) (authenticated) by conuserg-08.nifty.com with ESMTP id v7FFjk9a018213; Wed, 16 Aug 2017 00:45:50 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com v7FFjk9a018213 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1502811951; bh=BPydXt0UmfGPYg9t7ztFuuoYkseVbFMkgeoMaqtBc7Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yGl0EKsWf0GrVVYfytNjhbF7euopDI5VQn7YILVgJt1IM/dDMyLbBG5TLhoMuyeYb d5lFMQIIR3qemk3H7NW/jTkFgnWrKheuTFQPPR/59HrYYWsnwxZcvoAImGjZ2A9c+1 +7yKZaI1DSKS8AIBHJ/r2+vcGiUyfimROhBKsXhWlxoGP4wrUs1NZnZG4QrWyb7KSC 0cQY4kmvm8nAOD27dKcP9D84vr3cSapID2B75zhwd5dTn5EeaBnTLg780f4NgqGca5 zLF0SzUupAyKTY5iKkiox4JYEBBKLiRIcGoKiK5k9o1GgRy/vqci4UOVDImTZnll51 Y5Xgw6WGf8XqA== X-Nifty-SrcIP: [122.131.185.176] 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 v3 3/4] mmc: sdhci: enable/disable the clock in sdhci_pltfm_suspend/resume Date: Wed, 16 Aug 2017 00:45:21 +0900 Message-Id: <1502811922-9346-4-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502811922-9346-1-git-send-email-yamada.masahiro@socionext.com> References: <1502811922-9346-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 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 | 16 +++++++++++++++- drivers/mmc/host/sdhci-sirf.c | 39 +-------------------------------------- 3 files changed, 17 insertions(+), 75 deletions(-) -- 2.7.4 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..be9a79d62e22 100644 --- a/drivers/mmc/host/sdhci-pltfm.c +++ b/drivers/mmc/host/sdhci-pltfm.c @@ -212,16 +212,30 @@ 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); } 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, From patchwork Tue Aug 15 15:45:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 110181 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp5832418qge; Tue, 15 Aug 2017 08:47:02 -0700 (PDT) X-Received: by 10.98.192.205 with SMTP id g74mr28583906pfk.1.1502812022145; Tue, 15 Aug 2017 08:47:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502812022; cv=none; d=google.com; s=arc-20160816; b=MPeIx0+kIGyE+i2IWMCQ6dQaP6aaC6R/cR+xsdpM72tjPey2E+8BQ82g9UkOjjZs7Y Z/u0hGd9D2+lSJe+TDBg/wMh14+paMp0dwBUp1Wg1EIavJIfz8k0Xuguve+lKp3vte3s eN5xwdUnBU9lbpp5uON0wdoc+3aKAjDlUBZv027JA6Arpnv4O9+oOzhk1mebCEs2VA4Y fKp2T0bL1sjeV28K7Za7kOuZ/hW1+wMac3PnemCxrZId3V7biwgsJ44yWcM5q4/nwJZb 1vkQCGiMc+D226/zB7Vg8ogj45S+K8WVs784vc22hmPz2ijDZvk7okYSczZssIyQs48E ACDQ== 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=nAwSf4SAQ17xaXSvdQurZyISL9qAWuUJVBN8Ladcy68=; b=s3biDFbMrB16zaxq3mF18VGULNbhkhCELK3oEn8nHZ/s9FILU0ZcoVhnwsg7Nuseqt Z/Bf6DKZD73R8oWl1ah9paMOaao/QdKgecFJoeyqRnkad3t5d88VIJdCXERQp5gcj/DY jgIdV98RDFNebhcAoHzduBAS+XIsXbFPBQdwmoep8vuOJQqE0gp6ZlMbEwQondxgJ7bR 1Kl+V73LAVcVhKViL7GXwxukvkuG5z/9spz6I6Vr7EKaxTpWSRtWIyelti66BDU6eqIU phtiEbZkCMCh6DsyD8nEKtAUfksGlxx4Xb7SpIN6Zj24o+aaubi8y1s8gAeZ4Ur9tkNt EcjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=jdmiAQ7M; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 o26si5566149pge.34.2017.08.15.08.47.01; Tue, 15 Aug 2017 08:47:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=jdmiAQ7M; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752870AbdHOPq7 (ORCPT + 25 others); Tue, 15 Aug 2017 11:46:59 -0400 Received: from conuserg-08.nifty.com ([210.131.2.75]:39984 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752542AbdHOPqy (ORCPT ); Tue, 15 Aug 2017 11:46:54 -0400 Received: from grover.sesame (FL1-122-131-185-176.osk.mesh.ad.jp [122.131.185.176]) (authenticated) by conuserg-08.nifty.com with ESMTP id v7FFjk9b018213; Wed, 16 Aug 2017 00:45:51 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com v7FFjk9b018213 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1502811952; bh=nAwSf4SAQ17xaXSvdQurZyISL9qAWuUJVBN8Ladcy68=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jdmiAQ7Mb1fHPuF4WWKz80YCWN0axeXzHIPzmhNMHRNnc9Knvp+mIBle4vEPdb09d 4PNsBzr/1JF3vqBtc56ekpF5soRMhmvWGA6MOxvd6LJrhor9Ex2H9yRq4YMdce9mC0 oayXTRjSspvgJLst2R4P7KaJd+U++9hzm124+ObiDJIGSWrlSqKrKsSG8MJ2tbtPOF 1dx4r244DaYMfyTI4UEWDR9RDDr9ow5M79t4HvkUw6931wnReky6eiMXyFYI/h77kF 4Ue3xQexg2upW/TK0jKXWLnqRFwUNQLmjLvVGRBXRv8TJ1SXXdJXZwe8xBHiel3b+S Cn5ciZQ5FUpsw== X-Nifty-SrcIP: [122.131.185.176] 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 , linux-kernel@vger.kernel.org, Ulf Hansson Subject: [PATCH v3 4/4] mmc: sdhci-pltfm: export sdhci_pltfm_suspend/resume Date: Wed, 16 Aug 2017 00:45:22 +0900 Message-Id: <1502811922-9346-5-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502811922-9346-1-git-send-email-yamada.masahiro@socionext.com> References: <1502811922-9346-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This will be useful when drivers want to reuse either suspend or resume callback instead of whole of sdhci_pltfm_pmops. Signed-off-by: Masahiro Yamada --- Changes in v3: None Changes in v2: None drivers/mmc/host/sdhci-cadence.c | 20 +------------------- drivers/mmc/host/sdhci-pltfm.c | 6 ++++-- drivers/mmc/host/sdhci-pltfm.h | 2 ++ 3 files changed, 7 insertions(+), 21 deletions(-) -- 2.7.4 diff --git a/drivers/mmc/host/sdhci-cadence.c b/drivers/mmc/host/sdhci-cadence.c index 751ba706bf03..79ce9053df07 100644 --- a/drivers/mmc/host/sdhci-cadence.c +++ b/drivers/mmc/host/sdhci-cadence.c @@ -391,24 +391,6 @@ static int sdhci_cdns_probe(struct platform_device *pdev) } #ifdef CONFIG_PM_SLEEP -static int sdhci_cdns_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_unprepare(pltfm_host->clk); - - return 0; -} - static int sdhci_cdns_resume(struct device *dev) { struct sdhci_host *host = dev_get_drvdata(dev); @@ -429,7 +411,7 @@ static int sdhci_cdns_resume(struct device *dev) #endif static const struct dev_pm_ops sdhci_cdns_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(sdhci_cdns_suspend, sdhci_cdns_resume) + SET_SYSTEM_SLEEP_PM_OPS(sdhci_pltfm_suspend, sdhci_cdns_resume) }; static const struct of_device_id sdhci_cdns_match[] = { diff --git a/drivers/mmc/host/sdhci-pltfm.c b/drivers/mmc/host/sdhci-pltfm.c index be9a79d62e22..a34eacac612f 100644 --- a/drivers/mmc/host/sdhci-pltfm.c +++ b/drivers/mmc/host/sdhci-pltfm.c @@ -209,7 +209,7 @@ int sdhci_pltfm_unregister(struct platform_device *pdev) EXPORT_SYMBOL_GPL(sdhci_pltfm_unregister); #ifdef CONFIG_PM_SLEEP -static int sdhci_pltfm_suspend(struct device *dev) +int sdhci_pltfm_suspend(struct device *dev) { struct sdhci_host *host = dev_get_drvdata(dev); struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); @@ -226,8 +226,9 @@ static int sdhci_pltfm_suspend(struct device *dev) return 0; } +EXPORT_SYMBOL_GPL(sdhci_pltfm_suspend); -static int sdhci_pltfm_resume(struct device *dev) +int sdhci_pltfm_resume(struct device *dev) { struct sdhci_host *host = dev_get_drvdata(dev); struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); @@ -239,6 +240,7 @@ static int sdhci_pltfm_resume(struct device *dev) return sdhci_resume_host(host); } +EXPORT_SYMBOL_GPL(sdhci_pltfm_resume); #endif const struct dev_pm_ops sdhci_pltfm_pmops = { diff --git a/drivers/mmc/host/sdhci-pltfm.h b/drivers/mmc/host/sdhci-pltfm.h index 957839d0fe37..1e91fb1c020e 100644 --- a/drivers/mmc/host/sdhci-pltfm.h +++ b/drivers/mmc/host/sdhci-pltfm.h @@ -109,6 +109,8 @@ static inline void *sdhci_pltfm_priv(struct sdhci_pltfm_host *host) return host->private; } +int sdhci_pltfm_suspend(struct device *dev); +int sdhci_pltfm_resume(struct device *dev); extern const struct dev_pm_ops sdhci_pltfm_pmops; #endif /* _DRIVERS_MMC_SDHCI_PLTFM_H */