Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3455863ybi; Tue, 18 Jun 2019 00:47:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqwswWIjxDnHkzR8Px5XOAcKzdMfmAzLgbcE4UlmZywssuIDnyFttbZPIe4K3iwYOunE7/OU X-Received: by 2002:a63:dd53:: with SMTP id g19mr1366435pgj.3.1560844061792; Tue, 18 Jun 2019 00:47:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560844061; cv=none; d=google.com; s=arc-20160816; b=w2n/+NdzRR0Akwk5Nchk/w6mfBHvfQa70uCukzSoPPWa2kTEyjHqWmb4KeDqorO/aK 01Hj4vRfgnLq3TnoLcXh1YcEOMTarY3LTHBXH+8KwA9Rp4GJ2VA2JcFm6zsTA2/TTZl/ rp80+/zetvgnFiJoWpT9F3zzfP07+b2MwBwXNzw8Wwpg5Hi7nIOwmz2LhAeb2EtrywNc pbc2//Vd2eCp1WOSOV5Lxlhk/pGAIAkv7iEbl2dG2vNzq45kcqyUZW32FfHh7u6CNqjb 0M2w9OYtkYkwkY2qUZjaC4YaHDtremaPxsmodwsV0IC77+nQuLVPmtSmuBhVjZ5j46eE C04A== 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=qGPf8GeJzYp5l1LLIt//TFC/PvM/mcxGGf78pbIwi5s=; b=Q8xGIsflk6Y9rTY3LOHl/9P6APN6i6zkNqocyxCnqQeOgwr7SLHeMnYXoe8LHgoQ/3 Lyaxq6iAmJ7lrBTsDehaL8/iQIzWwwRsz5B9L1wY2LrC9M4c8j0dauiwP9ipkfefOdBI 0EdCegi70NDobBtY0Q/OpRM0j+vrGCOvSZ+dz8aRef6feifGkSIwFgDtLeikFInCtoWI C0FRtjFQPse1KYlkN9Y/4u+3hMhKeY4uS/gZ35xeNz+VzK2ZHstfsGMO4gmA51xxSZrz 9SzRRtqohc0pezpjIe6l2fw6Ub4tUKZgS1sHxYyZ+XeTfC254PF1y687BknYGasR4v34 LVGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=IR6FHF69; 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 q15si12983249pgi.575.2019.06.18.00.47.26; Tue, 18 Jun 2019 00:47:41 -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=IR6FHF69; 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 S1729147AbfFRHrF (ORCPT + 99 others); Tue, 18 Jun 2019 03:47:05 -0400 Received: from hqemgate16.nvidia.com ([216.228.121.65]:14145 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729110AbfFRHrD (ORCPT ); Tue, 18 Jun 2019 03:47:03 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate16.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Tue, 18 Jun 2019 00:47:02 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Tue, 18 Jun 2019 00:47:02 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Tue, 18 Jun 2019 00:47:02 -0700 Received: from HQMAIL112.nvidia.com (172.18.146.18) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 18 Jun 2019 07:47:02 +0000 Received: from HQMAIL101.nvidia.com (172.20.187.10) by HQMAIL112.nvidia.com (172.18.146.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 18 Jun 2019 07:47:01 +0000 Received: from hqnvemgw02.nvidia.com (172.16.227.111) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Tue, 18 Jun 2019 07:47:01 +0000 Received: from skomatineni-linux.nvidia.com (Not Verified[10.2.168.217]) by hqnvemgw02.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Tue, 18 Jun 2019 00:47:01 -0700 From: Sowjanya Komatineni To: , , , , , , , CC: , , , , , , , , , , , , , , , Subject: [PATCH V3 10/17] clk: tegra: add suspend resume support for DFLL Date: Tue, 18 Jun 2019 00:46:24 -0700 Message-ID: <1560843991-24123-11-git-send-email-skomatineni@nvidia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560843991-24123-1-git-send-email-skomatineni@nvidia.com> References: <1560843991-24123-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=1560844022; bh=qGPf8GeJzYp5l1LLIt//TFC/PvM/mcxGGf78pbIwi5s=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:X-NVConfidentiality:MIME-Version: Content-Type; b=IR6FHF692X/4x2AJEoqn/f6pleTP9fwnEp5824cbV7rxFrPGCg6y0CyMKp+MmV8Fr WVp5wM99/LvkHNw6cdo1+DpGiTR2lLhTBzMZ5+BF6DCToXAz1ot4cIUSW8mKTqZSCv Q8pR4oZHDaD1sKN9X9DG7aT+IRZJQ8RMR0+4o6PDSgCwnH9m2a3Wgn6Tyr9V4nojdm GzsZQGW62CxGYzAIz0FJVTwl01DgHpfpydPtkdVbimcbVdcZBcQQikKVtDetx1Ffl6 MZ30jgx67vqwxZYPlVAD/7lCGpYb2H4EBsdMpB8XDjprBHFMjRfJ0Prca9kSjcD/Gl Usj0xr0jKTNSQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch creates APIs for supporting Tegra210 clock driver to perform DFLL suspend and resume operation. During suspend, DFLL mode is saved and on resume Tegra210 clock driver invokes DFLL resume API to re-initialize DFLL to enable target device clock in open loop mode or closed loop mode. Signed-off-by: Sowjanya Komatineni --- drivers/clk/tegra/clk-dfll.c | 78 ++++++++++++++++++++++++++++++++++++++++++++ drivers/clk/tegra/clk-dfll.h | 2 ++ 2 files changed, 80 insertions(+) diff --git a/drivers/clk/tegra/clk-dfll.c b/drivers/clk/tegra/clk-dfll.c index f8688c2ddf1a..a1f37cf99b00 100644 --- a/drivers/clk/tegra/clk-dfll.c +++ b/drivers/clk/tegra/clk-dfll.c @@ -277,6 +277,7 @@ struct tegra_dfll { unsigned long dvco_rate_min; enum dfll_ctrl_mode mode; + enum dfll_ctrl_mode resume_mode; enum dfll_tune_range tune_range; struct dentry *debugfs_dir; struct clk_hw dfll_clk_hw; @@ -1864,6 +1865,83 @@ static int dfll_fetch_common_params(struct tegra_dfll *td) } /* + * tegra_dfll_suspend + * @pdev: DFLL instance + * + * dfll controls clock/voltage to other devices, including CPU. Therefore, + * dfll driver pm suspend callback does not stop cl-dvfs operations. + */ +void tegra_dfll_suspend(struct platform_device *pdev) +{ + struct tegra_dfll *td = dev_get_drvdata(&pdev->dev); + + if (!td) + return; + + if (td->mode <= DFLL_DISABLED) + return; + + td->resume_mode = td->mode; + switch (td->mode) { + case DFLL_CLOSED_LOOP: + dfll_set_mode(td, DFLL_CLOSED_LOOP); + dfll_set_frequency_request(td, &td->last_req); + + dfll_unlock(td); + break; + default: + break; + } +} + +/** + * tegra_dfll_resume - reprogram the DFLL after context-loss + * @pdev: DFLL instance + * + * Re-initialize and enable target device clock in open loop mode. Called + * directly from SoC clock resume syscore operation. Closed loop will be + * re-entered in platform syscore ops as well after CPU clock source is + * switched to DFLL in open loop. + */ +void tegra_dfll_resume(struct platform_device *pdev, bool on_dfll) +{ + struct tegra_dfll *td = dev_get_drvdata(&pdev->dev); + + if (!td) + return; + + if (on_dfll) { + if (td->resume_mode == DFLL_CLOSED_LOOP) + dfll_lock(td); + td->resume_mode = DFLL_DISABLED; + return; + } + + reset_control_deassert(td->dvco_rst); + + pm_runtime_get(td->dev); + + /* Re-init DFLL */ + dfll_init_out_if(td); + dfll_set_default_params(td); + dfll_set_open_loop_config(td); + + pm_runtime_put(td->dev); + + /* Restore last request and mode up to open loop */ + switch (td->resume_mode) { + case DFLL_CLOSED_LOOP: + case DFLL_OPEN_LOOP: + dfll_set_mode(td, DFLL_OPEN_LOOP); + if (td->pmu_if == TEGRA_DFLL_PMU_I2C) + dfll_i2c_set_output_enabled(td, false); + break; + default: + break; + } +} + +/* * API exported to per-SoC platform drivers */ diff --git a/drivers/clk/tegra/clk-dfll.h b/drivers/clk/tegra/clk-dfll.h index 1b14ebe7268b..c21fc2061a20 100644 --- a/drivers/clk/tegra/clk-dfll.h +++ b/drivers/clk/tegra/clk-dfll.h @@ -40,6 +40,8 @@ struct tegra_dfll_soc_data { int tegra_dfll_register(struct platform_device *pdev, struct tegra_dfll_soc_data *soc); struct tegra_dfll_soc_data *tegra_dfll_unregister(struct platform_device *pdev); +void tegra_dfll_suspend(struct platform_device *pdev); +void tegra_dfll_resume(struct platform_device *pdev, bool on_dfll); int tegra_dfll_runtime_suspend(struct device *dev); int tegra_dfll_runtime_resume(struct device *dev); -- 2.7.4