From patchwork Thu Jul 13 08:04:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Schulz X-Patchwork-Id: 107570 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1895408qge; Thu, 13 Jul 2017 01:04:55 -0700 (PDT) X-Received: by 10.99.97.5 with SMTP id v5mr7777507pgb.77.1499933095476; Thu, 13 Jul 2017 01:04:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499933095; cv=none; d=google.com; s=arc-20160816; b=UTMMZmrKS/VfaEPl241/51TTYcP36l4Sn3UtuvkMXMsGvG/XhOyHicleSX1No2xZF0 2TbZjb9bsGMov12NAKFHrogYLyObOHrBFbeWKU+Zo0M/ANzgRaXea1hwSGPQhPYkN2LG dzx3XTEDWjVB/XZwJUylxgJkyejlk7su30quv3iAbxNw9l2itGfof8G511nTy9/SU0s6 A1R4s41Z1x2H3a2QGVwjazQoFZwogTtsTZmHTY4XsPAFJ3kTeJkFJBgpMhWcAG7uN2o+ St1fuqsY0bMRqsuyurCuWOM8BPheY4ytkCuZFaDiXL8Dhc/afZ6WtYc3Rbygt5OFUpt/ cKvQ== 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:arc-authentication-results; bh=qJ5xxYJSVxH7Cr2G8rEX7E01XFChgOpvPJwkYEg0iZ0=; b=s3TnnY2LXrhQJ+zO4TSl7ZKo/sCH0Y2hMgA7m3NBXlClqrNQmhn9u3xUSZFLu1X46/ mI6t4k7G8paL6bbBzCAjPDxVDSY8AokCvRhfxH36sFMMKSJ1j31wVS0oGqT/Yiu2gq7s fq3Itze48blZD6aFtrA6y/iPYpy+PPOD91DzjiSwBVoWXCq+a0O/JGh+EVt0y2nvY85r K0Xm9So9MaNkcNbN75goAJ9xRTh0XaLHu/J1rMOq0RNMmR3Jewq8Q+xA1fimYIv7H26+ jvHCfip1uVDD1zLUOP8fBwI/wWhIAhM6ubuPKMw5XWlEEHv02yygGMRKEYQXLSM4vHup 7stA== ARC-Authentication-Results: i=1; mx.google.com; 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 x4si3722536pgc.451.2017.07.13.01.04.55; Thu, 13 Jul 2017 01:04:55 -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; 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 S1751150AbdGMIEx (ORCPT + 6 others); Thu, 13 Jul 2017 04:04:53 -0400 Received: from mail.free-electrons.com ([62.4.15.54]:49243 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751018AbdGMIEw (ORCPT ); Thu, 13 Jul 2017 04:04:52 -0400 Received: by mail.free-electrons.com (Postfix, from userid 110) id EE87B2087D; Thu, 13 Jul 2017 10:04:48 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost.localdomain (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 10C192200C; Thu, 13 Jul 2017 10:04:31 +0200 (CEST) From: Quentin Schulz To: adrian.hunter@intel.com, ludovic.desroches@microchip.com, ulf.hansson@linaro.org Cc: Quentin Schulz , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@free-electrons.com, alexandre.belloni@free-electrons.com, nicolas.ferre@microchip.com, cyrille.pitchen@wedev4u.fr Subject: [PATCH v3 2/2] mmc: sdhci-of-at91: set clocks and presets after resume from deepest PM Date: Thu, 13 Jul 2017 10:04:18 +0200 Message-Id: <20170713080418.12048-2-quentin.schulz@free-electrons.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170713080418.12048-1-quentin.schulz@free-electrons.com> References: <20170713080418.12048-1-quentin.schulz@free-electrons.com> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org This adds deepest (Backup+Self-Refresh) PM support to the ATMEL SAMA5D2 SoC's SDHCI controller. When resuming from deepest state, it is required to restore preset registers as the registers are lost since VDD core has been shut down when entering deepest state on the SAMA5D2. The clocks need to be reconfigured as well. The other registers and init process are taken care of by the SDHCI core. Signed-off-by: Quentin Schulz Acked-by: Ludovic Desroches --- v3: - pm_runtime_force_suspend before setting restore_needed flag, v2: - use runtime_resume as system_resume, - set a flag to tell when restoring presets is needed, - use a flag to tell runtime_resume to restore presets, - surround sdhci_at91_suspend with ifdef CONFIG_PM_SLEEP instead of CONFIG_PM, drivers/mmc/host/sdhci-of-at91.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) -- 2.11.0 -- 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-of-at91.c b/drivers/mmc/host/sdhci-of-at91.c index fb8c6011f13d..88e9b5f35a62 100644 --- a/drivers/mmc/host/sdhci-of-at91.c +++ b/drivers/mmc/host/sdhci-of-at91.c @@ -41,6 +41,7 @@ struct sdhci_at91_priv { struct clk *hclock; struct clk *gck; struct clk *mainck; + bool restore_needed; }; static void sdhci_at91_set_clock(struct sdhci_host *host, unsigned int clock) @@ -206,6 +207,22 @@ static int sdhci_at91_set_clks_presets(struct device *dev) return 0; } +#ifdef CONFIG_PM_SLEEP +static int sdhci_at91_suspend(struct device *dev) +{ + struct sdhci_host *host = dev_get_drvdata(dev); + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + struct sdhci_at91_priv *priv = sdhci_pltfm_priv(pltfm_host); + int ret; + + ret = pm_runtime_force_suspend(dev); + + priv->restore_needed = true; + + return ret; +} +#endif /* CONFIG_PM_SLEEP */ + #ifdef CONFIG_PM static int sdhci_at91_runtime_suspend(struct device *dev) { @@ -233,6 +250,15 @@ static int sdhci_at91_runtime_resume(struct device *dev) struct sdhci_at91_priv *priv = sdhci_pltfm_priv(pltfm_host); int ret; + if (priv->restore_needed) { + ret = sdhci_at91_set_clks_presets(dev); + if (ret) + return ret; + + priv->restore_needed = false; + goto out; + } + ret = clk_prepare_enable(priv->mainck); if (ret) { dev_err(dev, "can't enable mainck\n"); @@ -251,13 +277,13 @@ static int sdhci_at91_runtime_resume(struct device *dev) return ret; } +out: return sdhci_runtime_resume_host(host); } #endif /* CONFIG_PM */ static const struct dev_pm_ops sdhci_at91_dev_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, - pm_runtime_force_resume) + SET_SYSTEM_SLEEP_PM_OPS(sdhci_at91_suspend, pm_runtime_force_resume) SET_RUNTIME_PM_OPS(sdhci_at91_runtime_suspend, sdhci_at91_runtime_resume, NULL) @@ -306,6 +332,8 @@ static int sdhci_at91_probe(struct platform_device *pdev) if (ret) goto sdhci_pltfm_free; + priv->restore_needed = false; + ret = mmc_of_parse(host->mmc); if (ret) goto clocks_disable_unprepare;