Received: by 2002:a17:90a:b81:0:0:0:0 with SMTP id 1csp1328304pjr; Fri, 16 Aug 2019 12:46:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqzsMbwdWV89un9BVC1u1VSHJJ1YN9DgwNtw9DCrnEP003pXWIfdouyP1qMHWzFobZVEQVQ1 X-Received: by 2002:a63:3281:: with SMTP id y123mr8969255pgy.72.1565984799405; Fri, 16 Aug 2019 12:46:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565984799; cv=none; d=google.com; s=arc-20160816; b=0zc78n842cSjh1nWqPKzvK/2+3ZaYSSWsfN6QaiQKG7M3gttlkEmKHR9ag1qdcRWPE sfmGiLmwi4/Ngm0eEzqph0wosc+NuHkNVnCNYKBkpl1xHDlG8BBXH2wWtd3r2LnBtE9K 5xWwNnCk5hGuzYNBZSnVXt9+mWrNjGLAC3sxnA03rMqpdnHHxjMTkMafyfCE5C1QUov2 6RxxADfsaCJzg+5s/tPHFCIbcnHHEXGIJ4TnY75WrWMb0vu7KDTtG1jDIv3C5FqrgWIU MrI1vo4zOzMsUExd/lLHMA/hc6fGkHjqqzzoxW1I/HHW2jF42WPDfy+8fyDwYhHy1ibt 6ihA== 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=QoM2s3Z1tZw1uxI7Hlj/Yx6/kLMLmgObc14os66PlbU=; b=XMB2WZPIW2R0Q5jKzzlLhkrdEIX5nPfoFswbUbUy7jHxmS0QPiqBvQBM6sF4fTHFBs Uy2o3043RXaKvkIDi1regrbmylwNtytWDlxkYB1eMaWbdAt4PvYZjEI7MiFfOEJBtLx5 eHyQWrMr4xME1xGTHfJuUiZWHlUkWpOW1e5vDYEVJBXsdCRV0zX7++CiM0zDIU5036BY T1zaK8e+JcevAW0WPDSNKZUuR+sIV0f2PW91/s9kf8S1LEvZ/FIGcFmsM8nD1y0fQmrd v/fLl7rIF5JczZaf//B5B+kYM8KSg8ygUb2c7dilQPFC8BWng78lZQZ9rI91qzJE0/U8 V3YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=TnJe88sD; 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 b31si4462594pgb.128.2019.08.16.12.46.24; Fri, 16 Aug 2019 12:46:39 -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=TnJe88sD; 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 S1727700AbfHPTnz (ORCPT + 99 others); Fri, 16 Aug 2019 15:43:55 -0400 Received: from hqemgate15.nvidia.com ([216.228.121.64]:14965 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727651AbfHPTm0 (ORCPT ); Fri, 16 Aug 2019 15:42:26 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Fri, 16 Aug 2019 12:42:37 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Fri, 16 Aug 2019 12:42:25 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Fri, 16 Aug 2019 12:42:25 -0700 Received: from HQMAIL101.nvidia.com (172.20.187.10) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 16 Aug 2019 19:42:25 +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; Fri, 16 Aug 2019 19:42:25 +0000 Received: from skomatineni-linux.nvidia.com (Not Verified[10.2.166.126]) by hqnvemgw01.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Fri, 16 Aug 2019 12:42:25 -0700 From: Sowjanya Komatineni To: , , , , , , , CC: , , , , , , , , , , , , , , , , , , Subject: [PATCH v9 06/22] clk: tegra: Support for OSC context save and restore Date: Fri, 16 Aug 2019 12:41:51 -0700 Message-ID: <1565984527-5272-7-git-send-email-skomatineni@nvidia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1565984527-5272-1-git-send-email-skomatineni@nvidia.com> References: <1565984527-5272-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=1565984557; bh=QoM2s3Z1tZw1uxI7Hlj/Yx6/kLMLmgObc14os66PlbU=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:X-NVConfidentiality:MIME-Version: Content-Type; b=TnJe88sD2ISq9tdmE6CF7y8TkVuXDbUCMumMWWJpCdIl/CAKqvJ0XeuiegcU5UrGb YjCu8T/UM1RnEEWdAOfQWjPTGMcE12+nZljJGk1EMJNcs7tEbbEBRGVhteeJ3V06vs NKthXzydTtViebIMpB98O+rNx0LFeSN3dunuVtCo9/BaVsWayUm1QjV5c2FmQ2x3uB fhtBumP6y8sXNSlUgVT0Ecd9Bda5o2+k66mO+s0UrPAAaBTV/ZbV7BwZjT62G9E1M4 IJWX9vR+Z+dLVaaF8wGlz+grptI3FK8HtenAS0Pg6Q70DPf8IMlvFwanDCQMSw8PWe 4r9TOBqyS3zWw== 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 905bf1096558..cbbca28bf7e4 100644 --- a/drivers/clk/tegra/clk.h +++ b/drivers/clk/tegra/clk.h @@ -829,6 +829,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