Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6425536ybi; Wed, 31 Jul 2019 14:14:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqxuTr8mXThkEjPwMADwDzYuatGUh4yCYPeKpIT2NjAkla1ESW4rQ8mt/4tmnFEWra3yE1HL X-Received: by 2002:a17:90a:3544:: with SMTP id q62mr4854061pjb.53.1564607677079; Wed, 31 Jul 2019 14:14:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564607677; cv=none; d=google.com; s=arc-20160816; b=f7h61aq8uXvrY9kJbMxefqHPkcIvQZHeQYMezs575BfgWaO79xLHcL1CSXDCgLrH/G LX58kIp3olWiTxX2mGg3Bvklx4USnkTI2tYJ7tgtGiTZZIQH3a1bDwgeDXpLT+VlMamX l/+Hxr5swqaMEolXuQJk5qwukdui4AArPDHg+Yb93Egw+FdQCHcMpBace57mcaVKYxPZ jNeshGHzaoySk4Gyk1MOVNWAZeI5Ca8rNA869UtBrb0GCYTBDt6XKEJWb0aS5wqPnzLc V/Hk9BMIemqcoelGRlrHSa28TejYQUo6e141zCnfMnAxy/+70grJ4VQmpdu5/EWTEiV9 Kz3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from; bh=DlH5zne7afUgvFVw41nMXdKzqNL2H6Ti9hK3hgmeweE=; b=MWv/FdmyjiSm5k0NgfAgBnygGyuIj582wCplrufyjZCB8xmGD3+zsEa8zSfurKYJu1 4eZrCItDAJx3rTubMPt9P0bw9YhJ7aGq7qAxouDWxoHpIs8rtPY/7kM/iH5HRBQYqv9X eHhfP1QBr23Z+ijlx5uUSZXaDzuUDTe/Dq89+QBGYOFtohd9ilCKKy7pSo3gO+vhpawy MegxpXwQgwt10FPdy+nX3f9U+Omcnw6rjklKY+K6tzqrfvyxmtQDxWL+TI3hrtIvz478 /KskymFwJHleK/BiDaPmKz6q6kpIiJVec7Xsj6vo1RhCjaVkiAcexEy3DIZyZFJUbgUM 92fA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=TpXfYas1; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y14si17380425pfr.82.2019.07.31.14.14.22; Wed, 31 Jul 2019 14:14:37 -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=@nvidia.com header.s=n1 header.b=TpXfYas1; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731032AbfGaVMQ (ORCPT + 99 others); Wed, 31 Jul 2019 17:12:16 -0400 Received: from hqemgate15.nvidia.com ([216.228.121.64]:9198 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730184AbfGaVLK (ORCPT ); Wed, 31 Jul 2019 17:11:10 -0400 Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Wed, 31 Jul 2019 14:11:17 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Wed, 31 Jul 2019 14:11:08 -0700 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Wed, 31 Jul 2019 14:11:08 -0700 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL104.nvidia.com (172.18.146.11) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 31 Jul 2019 21:11:08 +0000 Received: from hqnvemgw01.nvidia.com (172.20.150.20) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Wed, 31 Jul 2019 21:11:08 +0000 Received: from skomatineni-linux.nvidia.com (Not Verified[10.110.102.167]) by hqnvemgw01.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Wed, 31 Jul 2019 14:11:08 -0700 From: Sowjanya Komatineni To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , Subject: [PATCH v7 11/20] cpufreq: tegra124: Add suspend and resume support Date: Wed, 31 Jul 2019 14:10:54 -0700 Message-ID: <1564607463-28802-12-git-send-email-skomatineni@nvidia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1564607463-28802-1-git-send-email-skomatineni@nvidia.com> References: <1564607463-28802-1-git-send-email-skomatineni@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1564607477; bh=DlH5zne7afUgvFVw41nMXdKzqNL2H6Ti9hK3hgmeweE=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:X-NVConfidentiality:MIME-Version: Content-Type; b=TpXfYas1/NZmHok+0jyolcmYnCO/Np11LlxeZJGrjzymjbFR50F1o17o/IaszP5Jq fMm08KqsGMkoA4ZYs0wv758n3eilTy8eXjo5FWHu8ZPzUwQ5iMHWV69nffZ2j+bqXX xSZ6sc4VXFfx1ViZ7keuMafx1QJzFhYCDRAcLBnqAfI93tY+vTZC2VGChsl90pDzl0 q7VXeU3jTdAH/ud/uv29GXdUJFzBJizEZb3eaFt9pJbP3bboqFFUEqKWfwnLXYWbC+ 7RIzyoJEabNfgk/p9HX80MuXv9wcoNSXkMAMUUQVIDK1gpXhhs75w8ZZ+4WusHCTb8 kz7LmmARqC0TA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds suspend and resume pm ops for cpufreq driver. PLLP is the safe clock source for CPU during system suspend and resume as PLLP rate is below the CPU Fmax at Vmin. CPUFreq driver suspend switches the CPU clock source to PLLP and disables the DFLL clock. During system resume, warmboot code powers up the CPU with PLLP clock source. So CPUFreq driver resume enabled DFLL clock and switches CPU back to DFLL clock source. Signed-off-by: Sowjanya Komatineni --- drivers/cpufreq/tegra124-cpufreq.c | 60 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/drivers/cpufreq/tegra124-cpufreq.c b/drivers/cpufreq/tegra124-cpufreq.c index 4f0c637b3b49..e979a3370988 100644 --- a/drivers/cpufreq/tegra124-cpufreq.c +++ b/drivers/cpufreq/tegra124-cpufreq.c @@ -6,6 +6,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include +#include #include #include #include @@ -128,8 +129,67 @@ static int tegra124_cpufreq_probe(struct platform_device *pdev) return ret; } +static int __maybe_unused tegra124_cpufreq_suspend(struct device *dev) +{ + struct tegra124_cpufreq_priv *priv = dev_get_drvdata(dev); + int err; + + /* + * PLLP rate 408Mhz is below the CPU Fmax at Vmin and is safe to + * use during suspend and resume. So, switch the CPU clock source + * to PLLP and disable DFLL. + */ + err = clk_set_parent(priv->cpu_clk, priv->pllp_clk); + if (err < 0) { + dev_err(dev, "failed to reparent to PLLP: %d\n", err); + return err; + } + + /* disable DFLL clock */ + clk_disable_unprepare(priv->dfll_clk); + + return 0; +} + +static int __maybe_unused tegra124_cpufreq_resume(struct device *dev) +{ + struct tegra124_cpufreq_priv *priv = dev_get_drvdata(dev); + int err; + + /* + * Warmboot code powers up the CPU with PLLP clock source. + * Enable DFLL clock and switch CPU clock source back to DFLL. + */ + err = clk_prepare_enable(priv->dfll_clk); + if (err < 0) { + dev_err(dev, "failed to enable DFLL clock for CPU: %d\n", err); + goto disable_cpufreq; + } + + err = clk_set_parent(priv->cpu_clk, priv->dfll_clk); + if (err < 0) { + dev_err(dev, "failed to reparent to DFLL clock: %d\n", err); + goto disable_dfll; + } + + return 0; + +disable_dfll: + clk_disable_unprepare(priv->dfll_clk); +disable_cpufreq: + disable_cpufreq(); + + return err; +} + +static const struct dev_pm_ops tegra124_cpufreq_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(tegra124_cpufreq_suspend, + tegra124_cpufreq_resume) +}; + static struct platform_driver tegra124_cpufreq_platdrv = { .driver.name = "cpufreq-tegra124", + .driver.pm = &tegra124_cpufreq_pm_ops, .probe = tegra124_cpufreq_probe, }; -- 2.7.4