Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5266438ybi; Tue, 30 Jul 2019 17:25:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqzMM1OLNC7OYPbMwhu/qG2vr9ePlxVEaydffQZtHD4Y2Dc3xTgb5P2tweCd7M5Lx47nSt7N X-Received: by 2002:a62:79c2:: with SMTP id u185mr45225076pfc.237.1564532732712; Tue, 30 Jul 2019 17:25:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564532732; cv=none; d=google.com; s=arc-20160816; b=Dz0f0Iv6WRezz83VMWaNNAVqJkl1pnwAjxT864Y5jAUgWQCE8NBCeSxMheRWvjJ1Y0 jFPbi2rNJCSvvPyfAfj3mFNem/naU1S4qvhxeAFshZmFKRKOhmLOtaLS0kgqBD/M/2Rf 7s32MhDtgWSZbUkOIp5eHqyamJ3zmnnfSGoYEfqFpdO1+js8pAOEKNFplO+vdMM/rDMu 98OcohGVfzmwIq5jR/D6PUz3m07rmRoaowxzxC9b8gN/obJoHZEgEhsGmzwQzXiUUEGI EE2wZun0p0qnCiqsGbNZAS7sfQAfGfhoprIfF6/4mJvP2xwAfLVJV8MYgOWL5rbwRHBP gYzQ== 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=CKWu+dh0N7zZVAF1SmEoY/8T6Dc2SXAhrV5SEgHcimJdUh18Wo2bEns96Z13XbFUn4 Dh2hB8R8NtrSeSdXMuDB/nHbLb57c6+c2odnlMvrfxxSpXOt5N8gYa6uXsbUMmfxqo89 k4FXrHNVuZA5Y6HSHW9AaeFRJPkwrLIEkmfd7vxOpv+0aKZsfHyD3YbTHrKO4RI64Pj4 +Jmjldor4GNLzpfdG7MeNVAN/dZB1ae/RLI2W+fz3T3OtgFz5kUwBjK/nw8V64Pchpox WYWYQFtuzk3G/Xe863ersEIw6FYWsiujlSqrzI9BbCwlRyphxP66Fo0vmbL+4Dpqos5n z6qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=nSETtT03; 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 72si27994712plb.177.2019.07.30.17.25.17; Tue, 30 Jul 2019 17:25:32 -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=nSETtT03; 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 S1728713AbfGaAUd (ORCPT + 99 others); Tue, 30 Jul 2019 20:20:33 -0400 Received: from hqemgate15.nvidia.com ([216.228.121.64]:7251 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728591AbfGaAUc (ORCPT ); Tue, 30 Jul 2019 20:20:32 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Tue, 30 Jul 2019 17:20:40 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Tue, 30 Jul 2019 17:20:31 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Tue, 30 Jul 2019 17:20:31 -0700 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL106.nvidia.com (172.18.146.12) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 31 Jul 2019 00:20:30 +0000 Received: from HQMAIL105.nvidia.com (172.20.187.12) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 31 Jul 2019 00:20:30 +0000 Received: from hqnvemgw01.nvidia.com (172.20.150.20) by HQMAIL105.nvidia.com (172.20.187.12) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Wed, 31 Jul 2019 00:20:30 +0000 Received: from skomatineni-linux.nvidia.com (Not Verified[10.110.103.107]) by hqnvemgw01.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Tue, 30 Jul 2019 17:20:30 -0700 From: Sowjanya Komatineni To: , , , , , , , CC: , , , , , , , , , , , , , , , Subject: [PATCH v7 11/20] cpufreq: tegra124: Add suspend and resume support Date: Tue, 30 Jul 2019 17:20:15 -0700 Message-ID: <1564532424-10449-12-git-send-email-skomatineni@nvidia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1564532424-10449-1-git-send-email-skomatineni@nvidia.com> References: <1564532424-10449-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=1564532440; 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=nSETtT033PikKcTDRhwMZS1WLUBBoHVG2e7xK411mUtUo3fH3G2cGU8qsbZ92Uumg Is19O1RY2R66iE7JYuMxiTc5ypWUw8BGSQyioVRqDOKXw+DBtf70SdKUVs9NtD9VN0 WNdyI7KzCbw2/dMCpCKFUkArPrEq5la7pj4RJRfg/SAddbyLKOSbon2HLbjSStQLIo Psno2BNpOkv8YhHKhMRurl8ZeBo7GhNQMdNUZShzhpOtflhFqvBHT+WaKg8K1hDMha kNlwzktNJ8HPknlF60AR/QnQmh48F1LpL04pDdUzr5Zz120V1/3jTDpuVumN2ogo5k 0Wk5flH3ng8vA== 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