Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6240545ybi; Sun, 21 Jul 2019 12:43:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqxKQpgvexKg9NZH7z2JnprX2OFvONh/dU5ZgakSvS00KMwX6OWD+YX8Fw5rOo4oNdBzvYPS X-Received: by 2002:a63:9e54:: with SMTP id r20mr32891146pgo.64.1563738209038; Sun, 21 Jul 2019 12:43:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563738209; cv=none; d=google.com; s=arc-20160816; b=TGjxTDWfa21j3W0iYGHp7MI8nBz1GRj9RS7FM3nT5EDi7v9XYwvPPD1XTg2d/dE/I8 q6zHCf+xkHeAAcXMFViUE9EC2fwlFihjsaXvR+0UJCngQ/PYmwvnihAQk5UitDp/nT0C FxFhzJ7PCX47y9wvZlCN68MXCnj9zxi8Id/WXtqhM6BFcoO5oKvE4inIY4DZvXbNoTMH z0YaSnLlu+SuptRcYQYdNovo7U46yFmc8v/0vOBt+Am6I8gyEsg7YDWyVd9nwpBwizkI raEa2kwLUdQxF2suyAqHaLDCkpJ6Bdwl6Kcx+nlhe0eUDyAHkbYZG8j+qG0ZzMEFwF/K r06A== 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=ty/oblLyoU2dDxcIw3IkPwD9VcYg2tkFrQMwJuj7d9E=; b=TA+pzNw9N0CdsXGwrGCRxG31B8bT6cr5Du4tFC6OqUH21Y1VU+P23yI0YncSHLokCS kKq0on0MdqtMeyJ8v6UaLbwgiChjyJ4STq6G3Lf/gL+bojF5AWLJrFJlILwFXkN821r0 cujHArRnVYO1buhRk4SSKGNbkHhq53mHvAowpjtNIbM27So4oCn8TDtn1Xu3mfq0F1/8 BJbiBXRCRuSKvoAyP95ZYnSpVRK9gkgsDqtEzm8w8vwLC6yrAIq45qAyNcQ2lkiowV1t 3l41wJDaIBj3z47u6mEXlpAeoTADZ0OfzWFRj9mWkOW1BaYdYu9LIjghntic+qpQBqVN OTkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=QRUf5mkN; 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 26si8072893pgl.309.2019.07.21.12.43.13; Sun, 21 Jul 2019 12:43:29 -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=QRUf5mkN; 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 S1727299AbfGUTmT (ORCPT + 99 others); Sun, 21 Jul 2019 15:42:19 -0400 Received: from hqemgate15.nvidia.com ([216.228.121.64]:15826 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727576AbfGUTlD (ORCPT ); Sun, 21 Jul 2019 15:41:03 -0400 Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Sun, 21 Jul 2019 12:41:09 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Sun, 21 Jul 2019 12:41:02 -0700 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Sun, 21 Jul 2019 12:41:02 -0700 Received: from HQMAIL104.nvidia.com (172.18.146.11) by HQMAIL105.nvidia.com (172.20.187.12) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Sun, 21 Jul 2019 19:41:01 +0000 Received: from hqnvemgw02.nvidia.com (172.16.227.111) by HQMAIL104.nvidia.com (172.18.146.11) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Sun, 21 Jul 2019 19:41:01 +0000 Received: from skomatineni-linux.nvidia.com (Not Verified[10.2.164.85]) by hqnvemgw02.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Sun, 21 Jul 2019 12:41:01 -0700 From: Sowjanya Komatineni To: , , , , , , , CC: , , , , , , , , , , , , , , , Subject: [PATCH V6 07/21] clk: tegra: Support for OSC context save and restore Date: Sun, 21 Jul 2019 12:40:46 -0700 Message-ID: <1563738060-30213-8-git-send-email-skomatineni@nvidia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1563738060-30213-1-git-send-email-skomatineni@nvidia.com> References: <1563738060-30213-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=1563738069; bh=ty/oblLyoU2dDxcIw3IkPwD9VcYg2tkFrQMwJuj7d9E=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:X-NVConfidentiality:MIME-Version: Content-Type; b=QRUf5mkN1/gJRgFKKDVvPZA2cLisqnqd4Hnran5LvXqu1gvBkPaQfc/gkrfY5Kmuf eDiGeES2sbkOeJchX6xJiMWG1CcJj+yPxFGLcNqG7ZKOjMU4f7PfkNEYuzF2WMKdlZ Z7wMgMlv+Z5q8mgE2Vm6hTN3muzBgo+YUSh6y1B+BTVkx5+KK6b21z6NzbQrMaeyJs qjD+sUWK+JHU7MPAdtG6nkeG2zapJNmkQrWwKEhJ+7CwLciNJwR5cvXv5/CkydZVcJ fc0YklqzCQmqxMJZe/AxqZ99Ji8GtVPVhc3EANAhgASxV3nTY4lByB6YN00JZpaYiB urYCROFUyHEEA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-NVConfidentiality: public 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 8532f5150091..3cd003b7512a 100644 --- a/drivers/clk/tegra/clk.h +++ b/drivers/clk/tegra/clk.h @@ -849,6 +849,7 @@ 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_sync_state_pll(struct clk_hw *hw); +void tegra_clk_osc_resume(void __iomem *clk_base); /* Combined read fence with delay */ #define fence_udelay(delay, reg) \ -- 2.7.4