Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp7474789ybh; Thu, 8 Aug 2019 16:50:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqygxbj1DbJdX58Kt0E2nAuYrcVjZ90HotDdiZCV0SNjfbXYdMiVHxdSZnCQpqwaKWrAH+lg X-Received: by 2002:a17:90a:cb81:: with SMTP id a1mr6381411pju.81.1565308203219; Thu, 08 Aug 2019 16:50:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565308203; cv=none; d=google.com; s=arc-20160816; b=T9jSpVLYLYYAVOfp4BhbXkgN1jrJsoKn1Z37cNOtitdWgx2LeWpTgcN7ezzK9v9oY4 Zc3QCMPi6lI0OZtxf08+zHejS3umxYuiF8EQ+gvoZFtF1Sm3X67YgUi6dzKJK3qmwpaa S8arQrPtgGkZW3uRBh3+vHZGT8PvXSJ2FLQkqzUSd0zHa4zwhmR26vb8KpAHgS6EYclQ SrIKLiHzOF8UfqUlBqqYNOI/pbhIFUJvQSmE+Fa/STMSbE8odxs6pw+9QFVDtuF8Ee/D 1/xnPaLDUwDSXffLt6QIxjDBe7uGRK+NGkGglXSK5znPXQhkm1Rk79U1/UXF9dejkrHu o3bQ== 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=QMr++geAp7D72q9sJTO0axmoa4NSwhiVEEqRniQwFg8=; b=U2kq2bAiaTKKjHFsdv/0jG36Xo3LdGLFMaZ+49GQI+USiWiGV+sRB0yJndSogZgcE5 vO7ZZwYZOG8QHHJsxzwPBr/BJt63IlQ5a+dAUuUFC2RMJNQ9r9DoJGmRnRmbcpyHDsxq +9iietM7UBT/PGFdcHugMzvX41QBZczDFcXWszg7gL8/expsHVyJFPjmZcDPfdIqAms8 VpxuHaqKXjKG8RidO60qf62a7EvkECjgEOg/J/bbklRE0dR4/TY1xFkx4QR7Zu0jHvtu HKmp7hG7vkdCF4D7If9/FzjOIBbvy7j4bAZJmOSlrvT26vG6k15xIXS6Y7ZsYFTME+zI 8aPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=M+ANrJsm; 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 q15si25056152pgk.537.2019.08.08.16.49.47; Thu, 08 Aug 2019 16:50:03 -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=M+ANrJsm; 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 S2405274AbfHHXsW (ORCPT + 99 others); Thu, 8 Aug 2019 19:48:22 -0400 Received: from hqemgate15.nvidia.com ([216.228.121.64]:12777 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404870AbfHHXrG (ORCPT ); Thu, 8 Aug 2019 19:47:06 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Thu, 08 Aug 2019 16:47:14 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Thu, 08 Aug 2019 16:47:03 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Thu, 08 Aug 2019 16:47:03 -0700 Received: from HQMAIL111.nvidia.com (172.20.187.18) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 8 Aug 2019 23:47:03 +0000 Received: from hqnvemgw01.nvidia.com (172.20.150.20) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Thu, 8 Aug 2019 23:47:03 +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:03 -0700 From: Sowjanya Komatineni To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 06/21] clk: tegra: Support for OSC context save and restore Date: Thu, 8 Aug 2019 16:46:45 -0700 Message-ID: <1565308020-31952-7-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=1565308034; bh=QMr++geAp7D72q9sJTO0axmoa4NSwhiVEEqRniQwFg8=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:X-NVConfidentiality:MIME-Version: Content-Type; b=M+ANrJsmBXYFhyMCby6j8ZrbrqE7ItmmewnCg6mpCkvn3z1B4tc083+3hyE1wAtF7 TeKQHttnm2Jw2NPO4f1nrVw7as8daGSogCAekbst/74KPQB7Qz0Ya2bazZxEXr+rPb MDwsM6LqHwbQWrkm/I/v5Sx/A/1Hb1YQTeCth1CuwmcZYmGi+V0D36WRywRINJp15D ElIIESHyMj5TjKv1IL9MIx0Jo2MnLcqrlw29ppoWdwcvRWPeSvvpEtbj7cdD+iZjFm x3l5dqLA+OacBjA6f4GvcM3HSMbk0poQPKT/YcSpx4caAdS2ML90fkISO0tC81/kmg g44qH7DKpUG5w== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds support for saving OSC clock frequency and the drive-strength during OSC clock init and creates an API to restore OSC control register value from the saved context. This API is invoked by Tegra210 clock driver during system resume to restore the OSC clock settings. Acked-by: Thierry Reding Signed-off-by: Sowjanya Komatineni --- drivers/clk/tegra/clk-tegra-fixed.c | 15 +++++++++++++++ drivers/clk/tegra/clk.h | 1 + 2 files changed, 16 insertions(+) diff --git a/drivers/clk/tegra/clk-tegra-fixed.c b/drivers/clk/tegra/clk-tegra-fixed.c index 8d91b2b191cf..7c6c8abfcde6 100644 --- a/drivers/clk/tegra/clk-tegra-fixed.c +++ b/drivers/clk/tegra/clk-tegra-fixed.c @@ -17,6 +17,10 @@ #define OSC_CTRL 0x50 #define OSC_CTRL_OSC_FREQ_SHIFT 28 #define OSC_CTRL_PLL_REF_DIV_SHIFT 26 +#define OSC_CTRL_MASK (0x3f2 | \ + (0xf << OSC_CTRL_OSC_FREQ_SHIFT)) + +static u32 osc_ctrl_ctx; int __init tegra_osc_clk_init(void __iomem *clk_base, struct tegra_clk *clks, unsigned long *input_freqs, unsigned int num, @@ -29,6 +33,7 @@ int __init tegra_osc_clk_init(void __iomem *clk_base, struct tegra_clk *clks, unsigned osc_idx; val = readl_relaxed(clk_base + OSC_CTRL); + osc_ctrl_ctx = val & OSC_CTRL_MASK; osc_idx = val >> OSC_CTRL_OSC_FREQ_SHIFT; if (osc_idx < num) @@ -96,3 +101,13 @@ void __init tegra_fixed_clk_init(struct tegra_clk *tegra_clks) *dt_clk = clk; } } + +void tegra_clk_osc_resume(void __iomem *clk_base) +{ + u32 val; + + val = readl_relaxed(clk_base + OSC_CTRL) & ~OSC_CTRL_MASK; + val |= osc_ctrl_ctx; + writel_relaxed(val, clk_base + OSC_CTRL); + fence_udelay(2, clk_base); +} diff --git a/drivers/clk/tegra/clk.h b/drivers/clk/tegra/clk.h index dc546292e030..8a9af45b6084 100644 --- a/drivers/clk/tegra/clk.h +++ b/drivers/clk/tegra/clk.h @@ -837,6 +837,7 @@ u16 tegra_pll_get_fixed_mdiv(struct clk_hw *hw, unsigned long input_rate); int tegra_pll_p_div_to_hw(struct tegra_clk_pll *pll, u8 p_div); int div_frac_get(unsigned long rate, unsigned parent_rate, u8 width, u8 frac_width, u8 flags); +void tegra_clk_osc_resume(void __iomem *clk_base); /* Combined read fence with delay */ -- 2.7.4