Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp7473385ybh; Thu, 8 Aug 2019 16:48:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqyAeAEnLAI0fd8qYKSDX/JWrvN3Lhiipcs9Ed528t/XV2rGVct6fmo+G1rsBKuZuGdHdizc X-Received: by 2002:a05:6a00:c7:: with SMTP id e7mr18271293pfj.52.1565308089441; Thu, 08 Aug 2019 16:48:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565308089; cv=none; d=google.com; s=arc-20160816; b=wVKTN69CqTBA8CPUsLbcPbSU/Uef2OTL9OZVzUSZJoFy6O84zDs3fElnTEH+qNPkGQ Kr5Ku63WX9WySripV7JB2k2wL3Oa1Gc/eWuqE71cNAoA3NsDmKuyTvbuchiNv7Y1MI33 zvlRo9LDBzwMOrI+gH2xMnyu/+0v6THI+vEVgCiub9Cbv9eduChOdoSa34rzdDTRzmzm 7IViacA44cYPUxh3Z3CVNsGFPJ4+Wqfiqf0bI5bAoSsqKuQ3h3Br6V+ueWYqUzsc8nmu yV0lharTPYj0Ap1sXI0XerK9T0zM4Sxrg1q4zoIIJGJeeMojY9xDSREjfsVN4CeiZHSi CpYw== 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=ZmXQG3uKkfyAQI4tPlaiZSRJU0Jj7WxxNukinw2sjd0=; b=C7I4lGCmzG04rher+i7TzCUVgyM+nKDM4TWa0V9Hue5N+dlw8vENK0slVT9D5fXqmW SHeqWx7hDdQk5MnB01fRReXsJrB+UluW8E5kDtHwuBusG/J7Iwc0X1P/1N4CrWcbc0kx WmIBIpjXul3Q8dsWoOu5hB4LMTsj8p+ZK0T/1Puzhev8C+Y0MJCzAPqbaiPM8lX3x3KM CZj9d633c2vUKygKxtkrTSdWPreEVnD9SqSpC0V78FbqP3bxZo1jpWSNHhjFYkmxNE0C W+mvEOBt5frFo9s5qqJqCwLYyC5VPfYwbtEjl+xPgA6T5RMl05XNXuuQRK+pip8tZ36O xzzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=pN4TEGpT; 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 w2si3064014pjn.29.2019.08.08.16.47.54; Thu, 08 Aug 2019 16:48:09 -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=pN4TEGpT; 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 S2405037AbfHHXrP (ORCPT + 99 others); Thu, 8 Aug 2019 19:47:15 -0400 Received: from hqemgate14.nvidia.com ([216.228.121.143]:12834 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404842AbfHHXrG (ORCPT ); Thu, 8 Aug 2019 19:47:06 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Thu, 08 Aug 2019 16:47:06 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Thu, 08 Aug 2019 16:47:04 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Thu, 08 Aug 2019 16:47:04 -0700 Received: from HQMAIL111.nvidia.com (172.20.187.18) by HQMAIL105.nvidia.com (172.20.187.12) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 8 Aug 2019 23:47:04 +0000 Received: from HQMAIL107.nvidia.com (172.20.187.13) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 8 Aug 2019 23:47:04 +0000 Received: from hqnvemgw01.nvidia.com (172.20.150.20) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Thu, 8 Aug 2019 23:47:04 +0000 Received: from skomatineni-linux.nvidia.com (Not Verified[10.110.103.110]) by hqnvemgw01.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Thu, 08 Aug 2019 16:47:04 -0700 From: Sowjanya Komatineni To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 11/21] clk: tegra: clk-dfll: Add suspend and resume support Date: Thu, 8 Aug 2019 16:46:50 -0700 Message-ID: <1565308020-31952-12-git-send-email-skomatineni@nvidia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1565308020-31952-1-git-send-email-skomatineni@nvidia.com> References: <1565308020-31952-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=1565308026; bh=ZmXQG3uKkfyAQI4tPlaiZSRJU0Jj7WxxNukinw2sjd0=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:X-NVConfidentiality:MIME-Version: Content-Type; b=pN4TEGpT5neEasaIDCorZX7dErxt9ghpNf8CWAusUGoPpSfYMv7ONNcZvaQAcF2TE yjErBWa8fSDKCvZWgA5/6Fh87hb5VaoDNDcSCXpCqJd1XrjaYfBAuxSJQAFjc3eB1o SsbTf6z7iBT4PQK+Q8S02T6ptVxHHnmOD7Cc/dzKvP/nHxb1S7SIUqhWXB8oqg36fi 1ppWVw+R5/ZmH5GmVjpUKoYlSxoxDpTdL3aQt88PKa1xgj7HpyljGXT2ZJqDk/ktYq NUR5dyzamnQtGiLHTe06/8OcuFsL/Oc8UOBQjd2Czm/zx9lpM6Rf/OmWy82nczTG4f TIs5VHT6N1Qjg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch implements DFLL suspend and resume operation. During system suspend entry, CPU clock will switch CPU to safe clock source of PLLP and disables DFLL clock output. DFLL driver suspend confirms DFLL disable state and errors out on being active. DFLL is re-initialized during the DFLL driver resume as it goes through complete reset during suspend entry. Signed-off-by: Sowjanya Komatineni --- drivers/clk/tegra/clk-dfll.c | 56 ++++++++++++++++++++++++++++++ drivers/clk/tegra/clk-dfll.h | 2 ++ drivers/clk/tegra/clk-tegra124-dfll-fcpu.c | 1 + 3 files changed, 59 insertions(+) diff --git a/drivers/clk/tegra/clk-dfll.c b/drivers/clk/tegra/clk-dfll.c index f8688c2ddf1a..eb298a5d7be9 100644 --- a/drivers/clk/tegra/clk-dfll.c +++ b/drivers/clk/tegra/clk-dfll.c @@ -1487,6 +1487,7 @@ static int dfll_init(struct tegra_dfll *td) td->last_unrounded_rate = 0; pm_runtime_enable(td->dev); + pm_runtime_irq_safe(td->dev); pm_runtime_get_sync(td->dev); dfll_set_mode(td, DFLL_DISABLED); @@ -1513,6 +1514,61 @@ static int dfll_init(struct tegra_dfll *td) return ret; } +/** + * tegra_dfll_suspend - check DFLL is disabled + * @dev: DFLL device * + * + * DFLL clock should be disabled by the CPUFreq driver. So, make + * sure it is disabled and disable all clocks needed by the DFLL. + */ +int tegra_dfll_suspend(struct device *dev) +{ + struct tegra_dfll *td = dev_get_drvdata(dev); + + if (dfll_is_running(td)) { + dev_err(td->dev, "dfll is enabled while shouldn't be\n"); + return -EBUSY; + } + + reset_control_assert(td->dvco_rst); + + return 0; +} +EXPORT_SYMBOL(tegra_dfll_suspend); + +/** + * tegra_dfll_resume - reinitialize DFLL on resume + * @dev: DFLL instance + * + * DFLL is disabled and reset during suspend and resume. + * So, reinitialize the DFLL IP block back for use. + * DFLL clock is enabled later in closed loop mode by CPUFreq + * driver before switching its clock source to DFLL output. + */ +int tegra_dfll_resume(struct device *dev) +{ + struct tegra_dfll *td = dev_get_drvdata(dev); + + reset_control_deassert(td->dvco_rst); + + pm_runtime_get_sync(td->dev); + + dfll_set_mode(td, DFLL_DISABLED); + dfll_set_default_params(td); + + if (td->soc->init_clock_trimmers) + td->soc->init_clock_trimmers(); + + dfll_set_open_loop_config(td); + + dfll_init_out_if(td); + + pm_runtime_put_sync(td->dev); + + return 0; +} +EXPORT_SYMBOL(tegra_dfll_resume); + /* * DT data fetch */ diff --git a/drivers/clk/tegra/clk-dfll.h b/drivers/clk/tegra/clk-dfll.h index 1b14ebe7268b..fb209eb5f365 100644 --- a/drivers/clk/tegra/clk-dfll.h +++ b/drivers/clk/tegra/clk-dfll.h @@ -42,5 +42,7 @@ int tegra_dfll_register(struct platform_device *pdev, struct tegra_dfll_soc_data *tegra_dfll_unregister(struct platform_device *pdev); int tegra_dfll_runtime_suspend(struct device *dev); int tegra_dfll_runtime_resume(struct device *dev); +int tegra_dfll_suspend(struct device *dev); +int tegra_dfll_resume(struct device *dev); #endif /* __DRIVERS_CLK_TEGRA_CLK_DFLL_H */ diff --git a/drivers/clk/tegra/clk-tegra124-dfll-fcpu.c b/drivers/clk/tegra/clk-tegra124-dfll-fcpu.c index e84b6d52cbbd..2ac2679d696d 100644 --- a/drivers/clk/tegra/clk-tegra124-dfll-fcpu.c +++ b/drivers/clk/tegra/clk-tegra124-dfll-fcpu.c @@ -631,6 +631,7 @@ static int tegra124_dfll_fcpu_remove(struct platform_device *pdev) static const struct dev_pm_ops tegra124_dfll_pm_ops = { SET_RUNTIME_PM_OPS(tegra_dfll_runtime_suspend, tegra_dfll_runtime_resume, NULL) + SET_SYSTEM_SLEEP_PM_OPS(tegra_dfll_suspend, tegra_dfll_resume) }; static struct platform_driver tegra124_dfll_fcpu_driver = { -- 2.7.4