Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5267260ybi; Tue, 30 Jul 2019 17:26:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqy8xG3eyWzycMSeL3q/vYeGyTpME/YLAibySqgupz2+YdY4vAKgNOLPFH+W9zTn6r0TF6cL X-Received: by 2002:a63:784c:: with SMTP id t73mr114510935pgc.268.1564532803267; Tue, 30 Jul 2019 17:26:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564532803; cv=none; d=google.com; s=arc-20160816; b=mLgLLYO//AbUTiCgOj8ObJdx6N3YnHDH2cOH5T9OhjbBOgpKoPnw1QA3NIk5kujruq Z6nJ5KBg+5yGry9tSKrJc0Q90U332KpJOpB98NkdRDHJq68TUXa7hYYno7AIeQWO1Je6 Cydp+tZTDaSXXvF8tYzEgJiZdo40BkKk7SmpV23F/4knY5SErNqG0x9KJRAAVkf/4zKS zlV2qMrpohIC+zllaKfR1wnEHB3RLy51vHwylcZvvjvOLNh3JJzenCKZcrJWjQYZXNfm 6/qkhA1srPzZUpz/GxJO28BrtHotSQ1wsNSt9+fOClwmSakl7kVsBufDaQVVj5drBgrz J1oQ== 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=gmpyRLDLg2IvNU52Z9/8lv6Z/RyFHiSrtLLnefPSW+c=; b=rhyIGov69sjPKYe6Xjy2dEbDOOyttfOZF+4PTmrYBVPxtOcSHGeZHPoGHXyQRxFtKt 0J/Z5RUrpAw0lXemFSFi3w8JswTA6kclPlj3xc8LdEKvl2BASIIAhZTx+85gUHDgdIC5 o9HlbjhL0koDdPmW3VJ2N3MpBAgkl4VGU4/A2Nub+86GZh9myMeIlIU+Ed057A729GaZ vz6ZTcHTVZbi3qFRkMHwHYRkil6u0d8PLhAgMbWYIBTig/9szt57dVxlC2PftvYTbfnz XbyE8oH7ERe5Adjqrh2NujgNNqxRL+fNnfir9U6Qb9U3DNkOa8LZ5B7VLgAhssFRYaYw QSSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=aQLLoj+x; 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 l35si28663817plb.186.2019.07.30.17.26.27; Tue, 30 Jul 2019 17:26:43 -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=aQLLoj+x; 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 S1728988AbfGaAV4 (ORCPT + 99 others); Tue, 30 Jul 2019 20:21:56 -0400 Received: from hqemgate14.nvidia.com ([216.228.121.143]:9226 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728455AbfGaAUb (ORCPT ); Tue, 30 Jul 2019 20:20:31 -0400 Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Tue, 30 Jul 2019 17:20:30 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Tue, 30 Jul 2019 17:20:28 -0700 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Tue, 30 Jul 2019 17:20:28 -0700 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL105.nvidia.com (172.20.187.12) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 31 Jul 2019 00:20:28 +0000 Received: from hqnvemgw01.nvidia.com (172.20.150.20) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Wed, 31 Jul 2019 00:20:28 +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 04/20] clk: tegra: pllout: Save and restore pllout context Date: Tue, 30 Jul 2019 17:20:08 -0700 Message-ID: <1564532424-10449-5-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=1564532430; bh=gmpyRLDLg2IvNU52Z9/8lv6Z/RyFHiSrtLLnefPSW+c=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:X-NVConfidentiality:MIME-Version: Content-Type; b=aQLLoj+xEA4e8MPsjXtIyP751MYjTf3ouJV94CZUIWEQFD/nY+Y6NQD4S8cLv9G6w k9fO+zCLPm8EXo6SNamAknpMDjN6o7mLl1pqMStIh0oeTpvDfIqfr8ID6/5bVXtkLa RqaqeWfWBOaViv4EEHuoprOD1V2cmGRAikR7IOKO1XAMR/iCudSRfOqNtdSwHPM3my WwnSsw8GjTfxOFJOriaoLITZbR1zJwifsTPGtCOm+vkbRO7rEMgJ7bGoQjcR3KcKlz og/m2KaYNJAcSOudWxXbQtrozRMjGdHbbo3vDcBLGVOkbsrTwJpEXDRCOwFllTyFiN ioFsIGy7JEkGA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch implements save and restore of pllout context. During system suspend, core power goes off and looses the settings of the Tegra CAR controller registers. So during suspend entry the state of pllout is saved and on resume it is restored back to have pllout in same state as before suspend. pllout rate is saved and restore in clock divider so it will be at same rate as before suspend when pllout state is restored. Acked-by: Thierry Reding Signed-off-by: Sowjanya Komatineni --- drivers/clk/tegra/clk-pll-out.c | 26 ++++++++++++++++++++++++++ drivers/clk/tegra/clk-tegra210.c | 3 ++- drivers/clk/tegra/clk.h | 9 +++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/drivers/clk/tegra/clk-pll-out.c b/drivers/clk/tegra/clk-pll-out.c index 35f2bf00e1e6..312a3e8ef398 100644 --- a/drivers/clk/tegra/clk-pll-out.c +++ b/drivers/clk/tegra/clk-pll-out.c @@ -69,10 +69,36 @@ static void clk_pll_out_disable(struct clk_hw *hw) spin_unlock_irqrestore(pll_out->lock, flags); } +static int tegra_clk_pll_out_save_context(struct clk_hw *hw) +{ + struct tegra_clk_pll_out *pll_out = to_clk_pll_out(hw); + + if (pll_out->flags & TEGRA_PLLRE_OUT) + pll_out->pllout_ctx = readl_relaxed(pll_out->reg); + + return 0; +} + +static void tegra_clk_pll_out_restore_context(struct clk_hw *hw) +{ + struct tegra_clk_pll_out *pll_out = to_clk_pll_out(hw); + + if (pll_out->flags & TEGRA_PLLRE_OUT) { + writel_relaxed(pll_out->pllout_ctx, pll_out->reg); + } else { + if (!__clk_get_enable_count(hw->clk)) + clk_pll_out_disable(hw); + else + clk_pll_out_enable(hw); + } +} + const struct clk_ops tegra_clk_pll_out_ops = { .is_enabled = clk_pll_out_is_enabled, .enable = clk_pll_out_enable, .disable = clk_pll_out_disable, + .save_context = tegra_clk_pll_out_save_context, + .restore_context = tegra_clk_pll_out_restore_context, }; struct clk *tegra_clk_register_pll_out(const char *name, diff --git a/drivers/clk/tegra/clk-tegra210.c b/drivers/clk/tegra/clk-tegra210.c index df172d5772d7..4721ee030d1c 100644 --- a/drivers/clk/tegra/clk-tegra210.c +++ b/drivers/clk/tegra/clk-tegra210.c @@ -3200,7 +3200,8 @@ static void __init tegra210_pll_init(void __iomem *clk_base, 8, 8, 1, NULL); clk = tegra_clk_register_pll_out("pll_re_out1", "pll_re_out1_div", clk_base + PLLRE_OUT1, 1, 0, - CLK_SET_RATE_PARENT, 0, NULL); + CLK_SET_RATE_PARENT, TEGRA_PLLRE_OUT, + NULL); clks[TEGRA210_CLK_PLL_RE_OUT1] = clk; /* PLLE */ diff --git a/drivers/clk/tegra/clk.h b/drivers/clk/tegra/clk.h index 905bf1096558..230c05d8eef0 100644 --- a/drivers/clk/tegra/clk.h +++ b/drivers/clk/tegra/clk.h @@ -437,6 +437,12 @@ struct clk *tegra_clk_register_pllu_tegra210(const char *name, * @rst_bit_idx: bit to reset PLL divider * @lock: register lock * @flags: hardware-specific flags + * @pllout_ctx: pllout context to save and restore during suspend + * and resume + * + * Flags: + * TEGRA_PLLRE_OUT - This flag indicates that it is PLLRE_OUT and is used to + * identify PLLRE_OUT during clk_pll_out save and restore. */ struct tegra_clk_pll_out { struct clk_hw hw; @@ -445,8 +451,11 @@ struct tegra_clk_pll_out { u8 rst_bit_idx; spinlock_t *lock; u8 flags; + u32 pllout_ctx; }; +#define TEGRA_PLLRE_OUT BIT(0) + #define to_clk_pll_out(_hw) container_of(_hw, struct tegra_clk_pll_out, hw) extern const struct clk_ops tegra_clk_pll_out_ops; -- 2.7.4