mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter De Schrijver <pdeschrijver@nvidia.com>
To: Peter De Schrijver <pdeschrijver@nvidia.com>,
	Prashant Gaikwad <pgaikwad@nvidia.com>,
	Michael Turquette <mturquette@baylibre.com>,
	"Stephen Boyd" <sboyd@codeaurora.org>,
	Thierry Reding <thierry.reding@gmail.com>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	<linux-clk@vger.kernel.org>, <linux-tegra@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Cc: Alex Frid <afrid@nvidia.com>
Subject: [PATCH 06/14] clk: tegra: Fix T210 effective NDIV calculation
Date: Tue, 25 Jul 2017 13:34:07 +0300	[thread overview]
Message-ID: <1500978856-5981-7-git-send-email-pdeschrijver@nvidia.com> (raw)
In-Reply-To: <1500978856-5981-1-git-send-email-pdeschrijver@nvidia.com>

From: Alex Frid <afrid@nvidia.com>

Don't take the fractional part into account to calculate the effective
NDIV if fractional ndiv is not enabled.

Signed-off-by: Alex Frid <afrid@nvidia.com>
Signed-off-by: Peter De Schrijver <pdeschrijver@nvidia.com>
---
 drivers/clk/tegra/clk-tegra210.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/tegra/clk-tegra210.c b/drivers/clk/tegra/clk-tegra210.c
index dc4a813..a4d7d94 100644
--- a/drivers/clk/tegra/clk-tegra210.c
+++ b/drivers/clk/tegra/clk-tegra210.c
@@ -241,6 +241,9 @@
 #define PLL_SDM_COEFF BIT(13)
 #define sdin_din_to_data(din)	((u16)((din) ? : 0xFFFFU))
 #define sdin_data_to_din(dat)	(((dat) == 0xFFFFU) ? 0 : (s16)dat)
+/* This macro returns ndiv effective scaled to SDM range */
+#define sdin_get_n_eff(cfg)	((cfg)->n * PLL_SDM_COEFF + ((cfg)->sdm_data ? \
+		(PLL_SDM_COEFF/2 + sdin_data_to_din((cfg)->sdm_data)) : 0))
 
 /* Tegra CPU clock and reset control regs */
 #define CLK_RST_CONTROLLER_CPU_CMPLX_STATUS	0x470
@@ -1288,8 +1291,7 @@ static int tegra210_pll_fixed_mdiv_cfg(struct clk_hw *hw,
 			s -= PLL_SDM_COEFF / 2;
 			cfg->sdm_data = sdin_din_to_data(s);
 		}
-		cfg->output_rate *= cfg->n * PLL_SDM_COEFF + PLL_SDM_COEFF/2 +
-					sdin_data_to_din(cfg->sdm_data);
+		cfg->output_rate *= sdin_get_n_eff(cfg);
 		cfg->output_rate /= p * cfg->m * PLL_SDM_COEFF;
 	} else {
 		cfg->output_rate *= cfg->n;
@@ -1314,8 +1316,7 @@ static int tegra210_pll_fixed_mdiv_cfg(struct clk_hw *hw,
  */
 static void tegra210_clk_pll_set_gain(struct tegra_clk_pll_freq_table *cfg)
 {
-	cfg->n = cfg->n * PLL_SDM_COEFF + PLL_SDM_COEFF/2 +
-			sdin_data_to_din(cfg->sdm_data);
+	cfg->n = sdin_get_n_eff(cfg);
 	cfg->m *= PLL_SDM_COEFF;
 }
 
-- 
1.9.1

  parent reply	other threads:[~2017-07-25 10:38 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-25 10:34 [PATCH 00/14] Fixes for Tegra clocks Peter De Schrijver
2017-07-25 10:34 ` [PATCH 01/14] clk: tegra: fix SS control on PLL enable/disable Peter De Schrijver
2017-07-25 10:34 ` [PATCH 02/14] clk: tegra: Enable PLL_SS for Tegra210 Peter De Schrijver
2017-07-25 10:34 ` [PATCH 03/14] clk: tegra: disable SSC for PLL_D2 Peter De Schrijver
2017-07-25 10:34 ` [PATCH 04/14] clk: tegra210: remove non-existing VFIR clock Peter De Schrijver
2017-07-25 10:34 ` [PATCH 05/14] clk: tegra: Init cfg structure in _get_pll_mnp Peter De Schrijver
2017-07-25 10:34 ` Peter De Schrijver [this message]
2017-07-25 10:34 ` [PATCH 07/14] clk: tegra: Add TEGRA_PERIPH_ON_APB flag to I2C Peter De Schrijver
2017-07-25 10:34 ` [PATCH 08/14] clk: tegra: change post IDDQ release delay to 5us Peter De Schrijver
2017-07-25 10:34 ` [PATCH 09/14] clk: tegra: don't warn for pll_d2 defaults unnecessarily Peter De Schrijver
2017-07-25 10:34 ` [PATCH 10/14] clk: tegra: Re-factor T210 PLLX registration Peter De Schrijver
2017-07-25 10:34 ` [PATCH 11/14] clk: tegra: Update T210 PLLSS (D2/DP) registration Peter De Schrijver
2017-07-25 10:34 ` [PATCH 12/14] clk: tegra: Fix T210 PLLRE registration Peter De Schrijver
2017-07-25 10:34 ` [PATCH 13/14] clk: tegra: Correct Tegra210 UTMIPLL poweron delay Peter De Schrijver
2017-07-25 10:34 ` [PATCH 14/14] clk: tegra: Fix Tegra210 PLLU initialization Peter De Schrijver
2017-07-26  1:37 ` [PATCH 00/14] Fixes for Tegra clocks Stephen Boyd
2017-07-26  8:27   ` Peter De Schrijver
2017-07-27 18:54     ` Stephen Boyd
2017-08-17 13:48       ` Thierry Reding
2017-08-23 23:07         ` Stephen Boyd
2017-08-17 13:31 ` Thierry Reding

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1500978856-5981-7-git-send-email-pdeschrijver@nvidia.com \
    --to=pdeschrijver@nvidia.com \
    --cc=afrid@nvidia.com \
    --cc=jonathanh@nvidia.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=pgaikwad@nvidia.com \
    --cc=sboyd@codeaurora.org \
    --cc=thierry.reding@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®