Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5265432ybi; Tue, 30 Jul 2019 17:24:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqzPObweTVPZkH/BPLx/Fr5v4ugTyUVntg/3KZRAop5So2+JC9Mw09DBH0SBLOEp2z0GqdlV X-Received: by 2002:a65:654d:: with SMTP id a13mr94822202pgw.196.1564532653193; Tue, 30 Jul 2019 17:24:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564532653; cv=none; d=google.com; s=arc-20160816; b=wylfkiQ7Ry3So3ipd07gNtQuLm7sgeHup7euoRBVvpA9CyQStYQnuuGp03Gutf08Nf g8Cmnu0m95JcgEh242k1WuGALmMPIx3tA1ziHwCJQnlXQO4JyHWwR1yfFkVgdpZoQxro MXvmp6MJUrJhJJGKnoozey9qSuaP2/lD1D4K+JCdgB9VsSDxOdW8cStaTb4eJHhNgyfl VCC7K2D+ChFZDgmahcNYKvC+8+43UUMWS0rvGwU9wM0UoxZSe8AK0ZnMwX/T+792JA15 /UBhv+SBmErpOMTuZyluWybBk0klTi/ZQ+/74M8aOITKTvp9rbX6/gvnwTvx7IF3Tqxs P07A== 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=xkj1s2KNWS1ox6olDiffSIxLRDDA825BMM0uyEpGVbk=; b=bgJ1GsuGcEV4VyHMzoidWWXUfkjFt0VcTTb3xrUyD80hx+7m8wa7a6L87BahOzWAKQ 54TbACMELw147856KwX7JmPII8KDCqgnrV9odyVQk/LARdEdK6XNIYA9/C+Dl07KiDdK 12u49Eco7bN3pqApCnVeuRTDs5BP33224Q8tjQv+lft5eor3i0vnU4kmH8UlQt4TusHD Y/cSv8V9HEtyXQJGp8N3ti0BftD3EANEjWt2xn7VKz/QtICxbgUZJ8zl+WEhbUs3x8kR gHvsQTl3P9/gu+eX7Wzti0Sq5BD35a0rpqlm2i7XCWfGFKuXHVfTWIOm5O+buUQAGHKd lIWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=Vuf+5M11; 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 d19si31538696pgm.310.2019.07.30.17.23.58; Tue, 30 Jul 2019 17:24:13 -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=Vuf+5M11; 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 S1728662AbfGaAUc (ORCPT + 99 others); Tue, 30 Jul 2019 20:20:32 -0400 Received: from hqemgate16.nvidia.com ([216.228.121.65]:1866 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728515AbfGaAUa (ORCPT ); Tue, 30 Jul 2019 20:20:30 -0400 Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqemgate16.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Tue, 30 Jul 2019 17:20:29 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Tue, 30 Jul 2019 17:20:29 -0700 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Tue, 30 Jul 2019 17:20:29 -0700 Received: from HQMAIL101.nvidia.com (172.20.187.10) by HQMAIL104.nvidia.com (172.18.146.11) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 31 Jul 2019 00:20:29 +0000 Received: from hqnvemgw01.nvidia.com (172.20.150.20) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Wed, 31 Jul 2019 00:20:29 +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:28 -0700 From: Sowjanya Komatineni To: , , , , , , , CC: , , , , , , , , , , , , , , , Subject: [PATCH v7 06/20] clk: tegra: Support for OSC context save and restore Date: Tue, 30 Jul 2019 17:20:10 -0700 Message-ID: <1564532424-10449-7-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=1564532429; bh=xkj1s2KNWS1ox6olDiffSIxLRDDA825BMM0uyEpGVbk=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:X-NVConfidentiality:MIME-Version: Content-Type; b=Vuf+5M11Wc5aLWfYn12peMF0AYN5NDpCVYhxQCbuv4HLT+MOb8y6/y2GkkCJYwZu9 NM5pc+k/EN6JsCoJ/Jqv/SMd7D+8+lBls6JEjTENlsppi9RC9si7PlgukovAI/CY1m YHv3wGrBN5EGL5tcCp9NC22igkxlUdd2N7Z6SNcN0Tz0TU5B9E3edtc/s6RraCXE68 qoFyt0g0XAE46vPYfJMIQW5thUK6QszdcTgOd84SojCT1UwOxMst64v6Au/JIgb2F8 tKtQgQc857/36gfmBMNF/DUYP3v92hKcosehUqUbkZVrxJi2ihKANOQqk16cMHObKZ qoyi0z2S0iSEg== 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 f1ef6ae8c979..abba6d8a04cd 100644 --- a/drivers/clk/tegra/clk.h +++ b/drivers/clk/tegra/clk.h @@ -842,6 +842,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