2017-07-25 10:34:37

by Peter De Schrijver

[permalink] [raw]
Subject: [PATCH 00/14] Fixes for Tegra clocks

A number of smaller fixes and simplifications for the Tegra clock
implementation.

Alex Frid (7):
clk: tegra: Fix T210 effective NDIV calculation
clk: tegra: Add TEGRA_PERIPH_ON_APB flag to I2C
clk: tegra: Re-factor T210 PLLX registration
clk: tegra: Update T210 PLLSS (D2/DP) registration
clk: tegra: Fix T210 PLLRE registration
clk: tegra: Correct Tegra210 UTMIPLL poweron delay
clk: tegra: Fix Tegra210 PLLU initialization

Peter De Schrijver (7):
clk: tegra: fix SS control on PLL enable/disable
clk: tegra: Enable PLL_SS for Tegra210
clk: tegra: disable SSC for PLL_D2
clk: tegra210: remove non-existing VFIR clock
clk: tegra: Init cfg structure in _get_pll_mnp
clk: tegra: change post IDDQ release delay to 5us
clk: tegra: don't warn for pll_d2 defaults unnecessarily

drivers/clk/tegra/clk-pll.c | 159 ++++++++-----------------------
drivers/clk/tegra/clk-tegra-periph.c | 3 +-
drivers/clk/tegra/clk-tegra-super-gen4.c | 11 ++-
drivers/clk/tegra/clk-tegra210.c | 32 ++++---
drivers/clk/tegra/clk.h | 6 --
5 files changed, 67 insertions(+), 144 deletions(-)

--
1.9.1


2017-07-25 10:34:39

by Peter De Schrijver

[permalink] [raw]
Subject: [PATCH 04/14] clk: tegra210: remove non-existing VFIR clock

Signed-off-by: Peter De Schrijver <[email protected]>
---
drivers/clk/tegra/clk-tegra210.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/clk/tegra/clk-tegra210.c b/drivers/clk/tegra/clk-tegra210.c
index facd6ee..dc4a813 100644
--- a/drivers/clk/tegra/clk-tegra210.c
+++ b/drivers/clk/tegra/clk-tegra210.c
@@ -2204,7 +2204,6 @@ struct utmi_clk_param {
[tegra_clk_gpu] = { .dt_id = TEGRA210_CLK_GPU, .present = true },
[tegra_clk_pll_g_ref] = { .dt_id = TEGRA210_CLK_PLL_G_REF, .present = true, },
[tegra_clk_uartb_8] = { .dt_id = TEGRA210_CLK_UARTB, .present = true },
- [tegra_clk_vfir] = { .dt_id = TEGRA210_CLK_VFIR, .present = true },
[tegra_clk_spdif_in_8] = { .dt_id = TEGRA210_CLK_SPDIF_IN, .present = true },
[tegra_clk_spdif_out] = { .dt_id = TEGRA210_CLK_SPDIF_OUT, .present = true },
[tegra_clk_vi_10] = { .dt_id = TEGRA210_CLK_VI, .present = true },
--
1.9.1

2017-07-25 10:34:38

by Peter De Schrijver

[permalink] [raw]
Subject: [PATCH 01/14] clk: tegra: fix SS control on PLL enable/disable

PLL SS was only controlled when setting the PLL rate, not when the PLL itself
is enabled or disabled.

Signed-off-by: Peter De Schrijver <[email protected]>
Reviewed-by: Jon Mayo <[email protected]>
---
drivers/clk/tegra/clk-pll.c | 44 ++++++++++++++++++++++++--------------------
1 file changed, 24 insertions(+), 20 deletions(-)

diff --git a/drivers/clk/tegra/clk-pll.c b/drivers/clk/tegra/clk-pll.c
index 159a854..e9bdb16 100644
--- a/drivers/clk/tegra/clk-pll.c
+++ b/drivers/clk/tegra/clk-pll.c
@@ -418,6 +418,26 @@ static void _clk_pll_disable(struct clk_hw *hw)
}
}

+static void pll_clk_start_ss(struct tegra_clk_pll *pll)
+{
+ if (pll->params->defaults_set && pll->params->ssc_ctrl_reg) {
+ u32 val = pll_readl(pll->params->ssc_ctrl_reg, pll);
+
+ val |= pll->params->ssc_ctrl_en_mask;
+ pll_writel(val, pll->params->ssc_ctrl_reg, pll);
+ }
+}
+
+static void pll_clk_stop_ss(struct tegra_clk_pll *pll)
+{
+ if (pll->params->defaults_set && pll->params->ssc_ctrl_reg) {
+ u32 val = pll_readl(pll->params->ssc_ctrl_reg, pll);
+
+ val &= ~pll->params->ssc_ctrl_en_mask;
+ pll_writel(val, pll->params->ssc_ctrl_reg, pll);
+ }
+}
+
static int clk_pll_enable(struct clk_hw *hw)
{
struct tegra_clk_pll *pll = to_clk_pll(hw);
@@ -431,6 +451,8 @@ static int clk_pll_enable(struct clk_hw *hw)

ret = clk_pll_wait_for_lock(pll);

+ pll_clk_start_ss(pll);
+
if (pll->lock)
spin_unlock_irqrestore(pll->lock, flags);

@@ -445,6 +467,8 @@ static void clk_pll_disable(struct clk_hw *hw)
if (pll->lock)
spin_lock_irqsave(pll->lock, flags);

+ pll_clk_stop_ss(pll);
+
_clk_pll_disable(hw);

if (pll->lock)
@@ -716,26 +740,6 @@ static void _update_pll_cpcon(struct tegra_clk_pll *pll,
pll_writel_misc(val, pll);
}

-static void pll_clk_start_ss(struct tegra_clk_pll *pll)
-{
- if (pll->params->defaults_set && pll->params->ssc_ctrl_reg) {
- u32 val = pll_readl(pll->params->ssc_ctrl_reg, pll);
-
- val |= pll->params->ssc_ctrl_en_mask;
- pll_writel(val, pll->params->ssc_ctrl_reg, pll);
- }
-}
-
-static void pll_clk_stop_ss(struct tegra_clk_pll *pll)
-{
- if (pll->params->defaults_set && pll->params->ssc_ctrl_reg) {
- u32 val = pll_readl(pll->params->ssc_ctrl_reg, pll);
-
- val &= ~pll->params->ssc_ctrl_en_mask;
- pll_writel(val, pll->params->ssc_ctrl_reg, pll);
- }
-}
-
static int _program_pll(struct clk_hw *hw, struct tegra_clk_pll_freq_table *cfg,
unsigned long rate)
{
--
1.9.1

2017-07-25 10:34:36

by Peter De Schrijver

[permalink] [raw]
Subject: [PATCH 02/14] clk: tegra: Enable PLL_SS for Tegra210

Make sure the pll_ss ops are compiled even when only building for Tegra210.

Signed-off-by: Peter De Schrijver <[email protected]>
Reviewed-by: Shreshtha Sahu <[email protected]>
Tested-by: Shreshtha Sahu <[email protected]>
Reviewed-by: Jon Mayo <[email protected]>
---
drivers/clk/tegra/clk-pll.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/tegra/clk-pll.c b/drivers/clk/tegra/clk-pll.c
index e9bdb16..fbd8726 100644
--- a/drivers/clk/tegra/clk-pll.c
+++ b/drivers/clk/tegra/clk-pll.c
@@ -2255,7 +2255,7 @@ struct clk *
}
#endif

-#if defined(CONFIG_ARCH_TEGRA_124_SOC) || defined(CONFIG_ARCH_TEGRA_132_SOC)
+#if defined(CONFIG_ARCH_TEGRA_124_SOC) || defined(CONFIG_ARCH_TEGRA_132_SOC) || defined(CONFIG_ARCH_TEGRA_210_SOC)
static const struct clk_ops tegra_clk_pllss_ops = {
.is_enabled = clk_pll_is_enabled,
.enable = clk_pll_enable,
--
1.9.1

2017-07-25 10:37:19

by Peter De Schrijver

[permalink] [raw]
Subject: [PATCH 09/14] clk: tegra: don't warn for pll_d2 defaults unnecessarily

If the PLL is on, only warn if the defaults are not yet set. Otherwise be
silent.

Signed-off-by: Peter De Schrijver <[email protected]>
Reviewed-by: Timo Alho <[email protected]>
---
drivers/clk/tegra/clk-tegra210.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/tegra/clk-tegra210.c b/drivers/clk/tegra/clk-tegra210.c
index a4d7d94..1e470ca 100644
--- a/drivers/clk/tegra/clk-tegra210.c
+++ b/drivers/clk/tegra/clk-tegra210.c
@@ -718,8 +718,6 @@ static void plldss_defaults(const char *pll_name, struct tegra_clk_pll *plldss,
plldss->params->defaults_set = true;

if (val & PLL_ENABLE) {
- pr_warn("%s already enabled. Postponing set full defaults\n",
- pll_name);

/*
* PLL is ON: check if defaults already set, then set those
@@ -758,6 +756,10 @@ static void plldss_defaults(const char *pll_name, struct tegra_clk_pll *plldss,
(~PLLDSS_MISC1_CFG_EN_SDM));
}

+ if (!plldss->params->defaults_set)
+ pr_warn("%s already enabled. Postponing set full defaults\n",
+ pll_name);
+
/* Enable lock detect */
if (val & PLLDSS_BASE_LOCK_OVERRIDE) {
val &= ~PLLDSS_BASE_LOCK_OVERRIDE;
--
1.9.1

2017-07-25 10:34:35

by Peter De Schrijver

[permalink] [raw]
Subject: [PATCH 03/14] clk: tegra: disable SSC for PLL_D2

PLLD2 is used for HDMI which does not allowe Spread Spectrum clocking.

Signed-off-by: Peter De Schrijver <[email protected]>
---
drivers/clk/tegra/clk-tegra210.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/tegra/clk-tegra210.c b/drivers/clk/tegra/clk-tegra210.c
index 1024e85..facd6ee 100644
--- a/drivers/clk/tegra/clk-tegra210.c
+++ b/drivers/clk/tegra/clk-tegra210.c
@@ -146,7 +146,7 @@
#define PLLD_SDM_EN_MASK BIT(16)

#define PLLD2_SDM_EN_MASK BIT(31)
-#define PLLD2_SSC_EN_MASK BIT(30)
+#define PLLD2_SSC_EN_MASK 0

#define PLLDP_SS_CFG 0x598
#define PLLDP_SDM_EN_MASK BIT(31)
--
1.9.1

2017-07-25 10:37:36

by Peter De Schrijver

[permalink] [raw]
Subject: [PATCH 07/14] clk: tegra: Add TEGRA_PERIPH_ON_APB flag to I2C

From: Alex Frid <[email protected]>

I2C controllers are also on the APB bus and therefor need this flag to handle
resets correctly.

Signed-off-by: Alex Frid <[email protected]>
Reviewed-by: Peter De Schrijver <[email protected]>
---
drivers/clk/tegra/clk-tegra-periph.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/tegra/clk-tegra-periph.c b/drivers/clk/tegra/clk-tegra-periph.c
index 294bfe4..848255c 100644
--- a/drivers/clk/tegra/clk-tegra-periph.c
+++ b/drivers/clk/tegra/clk-tegra-periph.c
@@ -216,7 +216,8 @@
_clk_num, _clk_id) \
TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\
30, MASK(2), 0, 0, 16, 0, TEGRA_DIVIDER_ROUND_UP,\
- _clk_num, 0, _clk_id, _parents##_idx, 0, NULL)
+ _clk_num, TEGRA_PERIPH_ON_APB, _clk_id, \
+ _parents##_idx, 0, NULL)

#define XUSB(_name, _parents, _offset, \
_clk_num, _gate_flags, _clk_id) \
--
1.9.1

2017-07-25 10:38:03

by Peter De Schrijver

[permalink] [raw]
Subject: [PATCH 08/14] clk: tegra: change post IDDQ release delay to 5us

Increase delay after PLL IDDQ release to 5us per PLL specifications.

based on work by Alex Frid <[email protected]>

Signed-off-by: Peter De Schrijver <[email protected]>
---
drivers/clk/tegra/clk-pll.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/tegra/clk-pll.c b/drivers/clk/tegra/clk-pll.c
index 1c36b8a..695ccb4 100644
--- a/drivers/clk/tegra/clk-pll.c
+++ b/drivers/clk/tegra/clk-pll.c
@@ -363,7 +363,7 @@ static void _clk_pll_enable(struct clk_hw *hw)
val = pll_readl(pll->params->iddq_reg, pll);
val &= ~BIT(pll->params->iddq_bit_idx);
pll_writel(val, pll->params->iddq_reg, pll);
- udelay(2);
+ udelay(5);
}

if (pll->params->reset_reg) {
--
1.9.1

2017-07-25 10:38:46

by Peter De Schrijver

[permalink] [raw]
Subject: [PATCH 05/14] clk: tegra: Init cfg structure in _get_pll_mnp

Not all fields are read from the hw depending on the PLL type. Make sure
the other fields are 0 by clearing the structure beforehand to prevent
users such as the rate re-calculation code from using bogus values.

Based on work by Alex Frid <[email protected]>

Signed-off-by: Peter De Schrijver <[email protected]>
---
drivers/clk/tegra/clk-pll.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/clk/tegra/clk-pll.c b/drivers/clk/tegra/clk-pll.c
index fbd8726..1c36b8a 100644
--- a/drivers/clk/tegra/clk-pll.c
+++ b/drivers/clk/tegra/clk-pll.c
@@ -690,6 +690,8 @@ static void _get_pll_mnp(struct tegra_clk_pll *pll,
struct tegra_clk_pll_params *params = pll->params;
struct div_nmp *div_nmp = params->div_nmp;

+ *cfg = (struct tegra_clk_pll_freq_table) { };
+
if ((params->flags & (TEGRA_PLLM | TEGRA_PLLMB)) &&
(pll_override_readl(PMC_PLLP_WB0_OVERRIDE, pll) &
PMC_PLLP_WB0_OVERRIDE_PLLM_OVERRIDE)) {
--
1.9.1

2017-07-25 10:38:45

by Peter De Schrijver

[permalink] [raw]
Subject: [PATCH 06/14] clk: tegra: Fix T210 effective NDIV calculation

From: Alex Frid <[email protected]>

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

Signed-off-by: Alex Frid <[email protected]>
Signed-off-by: Peter De Schrijver <[email protected]>
---
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

2017-07-25 10:40:39

by Peter De Schrijver

[permalink] [raw]
Subject: [PATCH 12/14] clk: tegra: Fix T210 PLLRE registration

From: Alex Frid <[email protected]>

Switched Tegra210 PLLRE registration to common PLL ops instead of special
PLLRE ops used on previous Tegra chips. The latter ops do not follow
chip specific PLL frequency table, and do not apply chip specific rate
calculation method.

Removed unnecessary default rate setting that duplicates h/w reset
state, and is overwritten by clock initialization, anyway.

Signed-off-by: Alex Frid <[email protected]>
Reviewed-by: Peter De Schrijver <[email protected]>
Reviewed-by: Jon Mayo <[email protected]>
---
drivers/clk/tegra/clk-pll.c | 21 +--------------------
1 file changed, 1 insertion(+), 20 deletions(-)

diff --git a/drivers/clk/tegra/clk-pll.c b/drivers/clk/tegra/clk-pll.c
index c6bce4a..7c369e2 100644
--- a/drivers/clk/tegra/clk-pll.c
+++ b/drivers/clk/tegra/clk-pll.c
@@ -2355,7 +2355,6 @@ struct clk *tegra_clk_register_pllre_tegra210(const char *name,
struct tegra_clk_pll_params *pll_params,
spinlock_t *lock, unsigned long parent_rate)
{
- u32 val;
struct tegra_clk_pll *pll;
struct clk *clk;

@@ -2369,26 +2368,8 @@ struct clk *tegra_clk_register_pllre_tegra210(const char *name,
if (IS_ERR(pll))
return ERR_CAST(pll);

- /* program minimum rate by default */
-
- val = pll_readl_base(pll);
- if (val & PLL_BASE_ENABLE)
- WARN_ON(readl_relaxed(clk_base + pll_params->iddq_reg) &
- BIT(pll_params->iddq_bit_idx));
- else {
- val = 0x4 << divm_shift(pll);
- val |= 0x41 << divn_shift(pll);
- pll_writel_base(val, pll);
- }
-
- /* disable lock override */
-
- val = pll_readl_misc(pll);
- val &= ~BIT(29);
- pll_writel_misc(val, pll);
-
clk = _tegra_clk_register_pll(pll, name, parent_name, flags,
- &tegra_clk_pllre_ops);
+ &tegra_clk_pll_ops);
if (IS_ERR(clk))
kfree(pll);

--
1.9.1

2017-07-25 10:40:38

by Peter De Schrijver

[permalink] [raw]
Subject: [PATCH 14/14] clk: tegra: Fix Tegra210 PLLU initialization

From: Alex Frid <[email protected]>

- Added necessary delays in PLLU enable sequence during initialization
- Applied PLLU lock to all secondary gates (PLLU_48M and PLLU_60M were
missing).

Signed-off-by: Alex Frid <[email protected]>
Signed-off-by: Peter De Schrijver <[email protected]>
---
drivers/clk/tegra/clk-tegra210.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/tegra/clk-tegra210.c b/drivers/clk/tegra/clk-tegra210.c
index fd04b0e..6d7a613 100644
--- a/drivers/clk/tegra/clk-tegra210.c
+++ b/drivers/clk/tegra/clk-tegra210.c
@@ -2554,6 +2554,7 @@ static int tegra210_enable_pllu(void)
reg = readl_relaxed(clk_base + pllu.params->ext_misc_reg[0]);
reg &= ~BIT(pllu.params->iddq_bit_idx);
writel_relaxed(reg, clk_base + pllu.params->ext_misc_reg[0]);
+ udelay(5);

reg = readl_relaxed(clk_base + PLLU_BASE);
reg &= ~GENMASK(20, 0);
@@ -2561,6 +2562,7 @@ static int tegra210_enable_pllu(void)
reg |= fentry->n << 8;
reg |= fentry->p << 16;
writel(reg, clk_base + PLLU_BASE);
+ udelay(1);
reg |= PLL_ENABLE;
writel(reg, clk_base + PLLU_BASE);

@@ -2800,14 +2802,14 @@ static void __init tegra210_pll_init(void __iomem *clk_base,
/* PLLU_60M */
clk = clk_register_gate(NULL, "pll_u_60M", "pll_u_out2",
CLK_SET_RATE_PARENT, clk_base + PLLU_BASE,
- 23, 0, NULL);
+ 23, 0, &pll_u_lock);
clk_register_clkdev(clk, "pll_u_60M", NULL);
clks[TEGRA210_CLK_PLL_U_60M] = clk;

/* PLLU_48M */
clk = clk_register_gate(NULL, "pll_u_48M", "pll_u_out1",
CLK_SET_RATE_PARENT, clk_base + PLLU_BASE,
- 25, 0, NULL);
+ 25, 0, &pll_u_lock);
clk_register_clkdev(clk, "pll_u_48M", NULL);
clks[TEGRA210_CLK_PLL_U_48M] = clk;

--
1.9.1

2017-07-25 10:40:37

by Peter De Schrijver

[permalink] [raw]
Subject: [PATCH 10/14] clk: tegra: Re-factor T210 PLLX registration

From: Alex Frid <[email protected]>

Tegra210 PLLX uses the same sequences than then PLLC instances. So there
is no need to have a special registration function and ops struct for it.
Simplify the code by changing all references to the Tegra210 PLLX
registration function to the Tegra210 PLLC registration function and
avoid duplicate functionality.

Based on work by Alex Frid <[email protected]>

Signed-off-by: Peter De Schrijver <[email protected]>
---
drivers/clk/tegra/clk-pll.c | 40 --------------------------------
drivers/clk/tegra/clk-tegra-super-gen4.c | 11 +++++++--
drivers/clk/tegra/clk-tegra210.c | 2 +-
drivers/clk/tegra/clk.h | 6 -----
4 files changed, 10 insertions(+), 49 deletions(-)

diff --git a/drivers/clk/tegra/clk-pll.c b/drivers/clk/tegra/clk-pll.c
index 695ccb4..02f34e6 100644
--- a/drivers/clk/tegra/clk-pll.c
+++ b/drivers/clk/tegra/clk-pll.c
@@ -2610,46 +2610,6 @@ struct clk *tegra_clk_register_pllc_tegra210(const char *name,
return clk;
}

-struct clk *tegra_clk_register_pllxc_tegra210(const char *name,
- const char *parent_name, void __iomem *clk_base,
- void __iomem *pmc, unsigned long flags,
- struct tegra_clk_pll_params *pll_params,
- spinlock_t *lock)
-{
- struct tegra_clk_pll *pll;
- struct clk *clk, *parent;
- unsigned long parent_rate;
-
- parent = __clk_lookup(parent_name);
- if (!parent) {
- WARN(1, "parent clk %s of %s must be registered first\n",
- name, parent_name);
- return ERR_PTR(-EINVAL);
- }
-
- if (!pll_params->pdiv_tohw)
- return ERR_PTR(-EINVAL);
-
- parent_rate = clk_get_rate(parent);
-
- pll_params->vco_min = _clip_vco_min(pll_params->vco_min, parent_rate);
-
- if (pll_params->adjust_vco)
- pll_params->vco_min = pll_params->adjust_vco(pll_params,
- parent_rate);
-
- pll = _tegra_init_pll(clk_base, pmc, pll_params, lock);
- if (IS_ERR(pll))
- return ERR_CAST(pll);
-
- clk = _tegra_clk_register_pll(pll, name, parent_name, flags,
- &tegra_clk_pll_ops);
- if (IS_ERR(clk))
- kfree(pll);
-
- return clk;
-}
-
struct clk *tegra_clk_register_pllss_tegra210(const char *name,
const char *parent_name, void __iomem *clk_base,
unsigned long flags,
diff --git a/drivers/clk/tegra/clk-tegra-super-gen4.c b/drivers/clk/tegra/clk-tegra-super-gen4.c
index 474de0f..4f6fd30 100644
--- a/drivers/clk/tegra/clk-tegra-super-gen4.c
+++ b/drivers/clk/tegra/clk-tegra-super-gen4.c
@@ -232,8 +232,15 @@ static void __init tegra_super_clk_init(void __iomem *clk_base,
if (!dt_clk)
return;

- clk = tegra_clk_register_pllxc("pll_x", "pll_ref", clk_base,
- pmc_base, CLK_IGNORE_UNUSED, params, NULL);
+#if defined(CONFIG_ARCH_TEGRA_210_SOC)
+ if (gen_info->gen == gen5)
+ clk = tegra_clk_register_pllc_tegra210("pll_x", "pll_ref",
+ clk_base, pmc_base, CLK_IGNORE_UNUSED, params, NULL);
+ else
+#endif
+ clk = tegra_clk_register_pllxc("pll_x", "pll_ref", clk_base,
+ pmc_base, CLK_IGNORE_UNUSED, params, NULL);
+
*dt_clk = clk;

/* PLLX_OUT0 */
diff --git a/drivers/clk/tegra/clk-tegra210.c b/drivers/clk/tegra/clk-tegra210.c
index 1e470ca..4fa7ab3 100644
--- a/drivers/clk/tegra/clk-tegra210.c
+++ b/drivers/clk/tegra/clk-tegra210.c
@@ -2701,7 +2701,7 @@ static void __init tegra210_pll_init(void __iomem *clk_base,
struct clk *clk;

/* PLLC */
- clk = tegra_clk_register_pllxc_tegra210("pll_c", "pll_ref", clk_base,
+ clk = tegra_clk_register_pllc_tegra210("pll_c", "pll_ref", clk_base,
pmc, 0, &pll_c_params, NULL);
if (!WARN_ON(IS_ERR(clk)))
clk_register_clkdev(clk, "pll_c", NULL);
diff --git a/drivers/clk/tegra/clk.h b/drivers/clk/tegra/clk.h
index 945b070..872f118 100644
--- a/drivers/clk/tegra/clk.h
+++ b/drivers/clk/tegra/clk.h
@@ -362,12 +362,6 @@ struct clk *tegra_clk_register_pllxc(const char *name, const char *parent_name,
struct tegra_clk_pll_params *pll_params,
spinlock_t *lock);

-struct clk *tegra_clk_register_pllxc_tegra210(const char *name,
- const char *parent_name, void __iomem *clk_base,
- void __iomem *pmc, unsigned long flags,
- struct tegra_clk_pll_params *pll_params,
- spinlock_t *lock);
-
struct clk *tegra_clk_register_pllm(const char *name, const char *parent_name,
void __iomem *clk_base, void __iomem *pmc,
unsigned long flags,
--
1.9.1

2017-07-25 10:40:36

by Peter De Schrijver

[permalink] [raw]
Subject: [PATCH 13/14] clk: tegra: Correct Tegra210 UTMIPLL poweron delay

From: Alex Frid <[email protected]>

Increased Tegra210 UTMIPLL power on delay to 20us (spec maximum is 15us).
Also remove a few empty lines to make it more clear the ACTIVE_DLY_COUNT
and ENABLE_DLY_COUNT fields.

Signed-off-by: Alex Frid <[email protected]>
Reviewed-by: Peter De Schrijver <[email protected]>
Reviewed-by: Jon Mayo <[email protected]>
---
drivers/clk/tegra/clk-tegra210.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/clk/tegra/clk-tegra210.c b/drivers/clk/tegra/clk-tegra210.c
index 4fa7ab3..fd04b0e 100644
--- a/drivers/clk/tegra/clk-tegra210.c
+++ b/drivers/clk/tegra/clk-tegra210.c
@@ -2472,15 +2472,14 @@ static void tegra210_utmi_param_configure(void)
reg |= UTMIP_PLL_CFG2_STABLE_COUNT(utmi_parameters[i].stable_count);

reg &= ~UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(~0);
-
reg |=
UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(utmi_parameters[i].active_delay_count);
writel_relaxed(reg, clk_base + UTMIP_PLL_CFG2);

/* Program UTMIP PLL delay and oscillator frequency counts */
reg = readl_relaxed(clk_base + UTMIP_PLL_CFG1);
- reg &= ~UTMIP_PLL_CFG1_ENABLE_DLY_COUNT(~0);

+ reg &= ~UTMIP_PLL_CFG1_ENABLE_DLY_COUNT(~0);
reg |=
UTMIP_PLL_CFG1_ENABLE_DLY_COUNT(utmi_parameters[i].enable_delay_count);

@@ -2496,7 +2495,8 @@ static void tegra210_utmi_param_configure(void)
reg &= ~UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERDOWN;
reg |= UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERUP;
writel_relaxed(reg, clk_base + UTMIP_PLL_CFG1);
- udelay(1);
+
+ udelay(20);

/* Enable samplers for SNPS, XUSB_HOST, XUSB_DEV */
reg = readl_relaxed(clk_base + UTMIP_PLL_CFG2);
--
1.9.1

2017-07-25 10:40:36

by Peter De Schrijver

[permalink] [raw]
Subject: [PATCH 11/14] clk: tegra: Update T210 PLLSS (D2/DP) registration

From: Alex Frid <[email protected]>

Remove from Tegra210 PLLSS registration code sections that
- attempt to set PLL minimum rate (unnecessary, and dangerous if PLL
is already enabled on boot)
- apply pre-Tegra210 defaults settings
- check IDDQ setting (duplicated with Tegra210 PLLSS check defaults)

Replaced setting of reference clock with check that default oscillator
selection is not changed, and failed registration otherwise as validation
was only done with the oscillator as the reference clock.

Reordered registration, so that PLL initialization is called after
VCOmin adjustment.

Signed-off-by: Alex Frid <[email protected]>
Reviewed-by: Peter De Schrijver <[email protected]>
---
drivers/clk/tegra/clk-pll.c | 48 +++++++++------------------------------------
1 file changed, 9 insertions(+), 39 deletions(-)

diff --git a/drivers/clk/tegra/clk-pll.c b/drivers/clk/tegra/clk-pll.c
index 02f34e6..c6bce4a 100644
--- a/drivers/clk/tegra/clk-pll.c
+++ b/drivers/clk/tegra/clk-pll.c
@@ -2618,10 +2618,8 @@ struct clk *tegra_clk_register_pllss_tegra210(const char *name,
{
struct tegra_clk_pll *pll;
struct clk *clk, *parent;
- struct tegra_clk_pll_freq_table cfg;
unsigned long parent_rate;
u32 val;
- int i;

if (!pll_params->div_nmp)
return ERR_PTR(-EINVAL);
@@ -2633,13 +2631,11 @@ struct clk *tegra_clk_register_pllss_tegra210(const char *name,
return ERR_PTR(-EINVAL);
}

- pll = _tegra_init_pll(clk_base, NULL, pll_params, lock);
- if (IS_ERR(pll))
- return ERR_CAST(pll);
-
- val = pll_readl_base(pll);
- val &= ~PLLSS_REF_SRC_SEL_MASK;
- pll_writel_base(val, pll);
+ val = readl_relaxed(clk_base + pll_params->base_reg);
+ if (val & PLLSS_REF_SRC_SEL_MASK) {
+ WARN(1, "not supported reference clock for %s\n", name);
+ return ERR_PTR(-EINVAL);
+ }

parent_rate = clk_get_rate(parent);

@@ -2649,36 +2645,10 @@ struct clk *tegra_clk_register_pllss_tegra210(const char *name,
pll_params->vco_min = pll_params->adjust_vco(pll_params,
parent_rate);

- /* initialize PLL to minimum rate */
-
- cfg.m = _pll_fixed_mdiv(pll_params, parent_rate);
- cfg.n = cfg.m * pll_params->vco_min / parent_rate;
-
- for (i = 0; pll_params->pdiv_tohw[i].pdiv; i++)
- ;
- if (!i) {
- kfree(pll);
- return ERR_PTR(-EINVAL);
- }
-
- cfg.p = pll_params->pdiv_tohw[i-1].hw_val;
-
- _update_pll_mnp(pll, &cfg);
-
- pll_writel_misc(PLLSS_MISC_DEFAULT, pll);
-
- val = pll_readl_base(pll);
- if (val & PLL_BASE_ENABLE) {
- if (val & BIT(pll_params->iddq_bit_idx)) {
- WARN(1, "%s is on but IDDQ set\n", name);
- kfree(pll);
- return ERR_PTR(-EINVAL);
- }
- } else
- val |= BIT(pll_params->iddq_bit_idx);
-
- val &= ~PLLSS_LOCK_OVERRIDE;
- pll_writel_base(val, pll);
+ pll_params->flags |= TEGRA_PLL_BYPASS;
+ pll = _tegra_init_pll(clk_base, NULL, pll_params, lock);
+ if (IS_ERR(pll))
+ return ERR_CAST(pll);

clk = _tegra_clk_register_pll(pll, name, parent_name, flags,
&tegra_clk_pll_ops);
--
1.9.1

2017-07-26 01:37:55

by Stephen Boyd

[permalink] [raw]
Subject: Re: [PATCH 00/14] Fixes for Tegra clocks

On 07/25, Peter De Schrijver wrote:
> A number of smaller fixes and simplifications for the Tegra clock
> implementation.

Any of these need fixes tags so they can be backported to stable
trees? Also, everyone is on To: line, so not sure who is supposed
to pick these up. Me? That's fine if so.

--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

2017-07-26 08:27:36

by Peter De Schrijver

[permalink] [raw]
Subject: Re: [PATCH 00/14] Fixes for Tegra clocks

On Tue, Jul 25, 2017 at 06:37:46PM -0700, Stephen Boyd wrote:
> On 07/25, Peter De Schrijver wrote:
> > A number of smaller fixes and simplifications for the Tegra clock
> > implementation.
>
> Any of these need fixes tags so they can be backported to stable
> trees? Also, everyone is on To: line, so not sure who is supposed

I will have a look. For some of them a backport might be useful.

> to pick these up. Me? That's fine if so.
>

That would be the easiest I think.

Cheers,

Peter.

> --
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
> a Linux Foundation Collaborative Project
> --
> To unsubscribe from this list: send the line "unsubscribe linux-clk" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html

2017-07-27 18:54:10

by Stephen Boyd

[permalink] [raw]
Subject: Re: [PATCH 00/14] Fixes for Tegra clocks

On 07/26, Peter De Schrijver wrote:
> On Tue, Jul 25, 2017 at 06:37:46PM -0700, Stephen Boyd wrote:
> > On 07/25, Peter De Schrijver wrote:
> > > A number of smaller fixes and simplifications for the Tegra clock
> > > implementation.
> >
> > Any of these need fixes tags so they can be backported to stable
> > trees? Also, everyone is on To: line, so not sure who is supposed
>
> I will have a look. For some of them a backport might be useful.
>
> > to pick these up. Me? That's fine if so.
> >
>
> That would be the easiest I think.
>

Ok. I'll wait for you to reply with tags unless you didn't find
any?

--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

2017-08-17 13:31:53

by Thierry Reding

[permalink] [raw]
Subject: Re: [PATCH 00/14] Fixes for Tegra clocks

On Tue, Jul 25, 2017 at 01:34:01PM +0300, Peter De Schrijver wrote:
> A number of smaller fixes and simplifications for the Tegra clock
> implementation.
>
> Alex Frid (7):
> clk: tegra: Fix T210 effective NDIV calculation
> clk: tegra: Add TEGRA_PERIPH_ON_APB flag to I2C
> clk: tegra: Re-factor T210 PLLX registration
> clk: tegra: Update T210 PLLSS (D2/DP) registration
> clk: tegra: Fix T210 PLLRE registration
> clk: tegra: Correct Tegra210 UTMIPLL poweron delay
> clk: tegra: Fix Tegra210 PLLU initialization
>
> Peter De Schrijver (7):
> clk: tegra: fix SS control on PLL enable/disable
> clk: tegra: Enable PLL_SS for Tegra210
> clk: tegra: disable SSC for PLL_D2
> clk: tegra210: remove non-existing VFIR clock
> clk: tegra: Init cfg structure in _get_pll_mnp
> clk: tegra: change post IDDQ release delay to 5us
> clk: tegra: don't warn for pll_d2 defaults unnecessarily
>
> drivers/clk/tegra/clk-pll.c | 159 ++++++++-----------------------
> drivers/clk/tegra/clk-tegra-periph.c | 3 +-
> drivers/clk/tegra/clk-tegra-super-gen4.c | 11 ++-
> drivers/clk/tegra/clk-tegra210.c | 32 ++++---
> drivers/clk/tegra/clk.h | 6 --
> 5 files changed, 67 insertions(+), 144 deletions(-)

The series:

Tested-by: Thierry Reding <[email protected]>
Acked-by: Thierry Reding <[email protected]>


Attachments:
(No filename) (1.34 kB)
signature.asc (833.00 B)
Download all attachments

2017-08-17 13:48:10

by Thierry Reding

[permalink] [raw]
Subject: Re: [PATCH 00/14] Fixes for Tegra clocks

On Thu, Jul 27, 2017 at 11:54:06AM -0700, Stephen Boyd wrote:
> On 07/26, Peter De Schrijver wrote:
> > On Tue, Jul 25, 2017 at 06:37:46PM -0700, Stephen Boyd wrote:
> > > On 07/25, Peter De Schrijver wrote:
> > > > A number of smaller fixes and simplifications for the Tegra clock
> > > > implementation.
> > >
> > > Any of these need fixes tags so they can be backported to stable
> > > trees? Also, everyone is on To: line, so not sure who is supposed
> >
> > I will have a look. For some of them a backport might be useful.
> >
> > > to pick these up. Me? That's fine if so.
> > >
> >
> > That would be the easiest I think.
> >
>
> Ok. I'll wait for you to reply with tags unless you didn't find
> any?

I'm not aware of any bugs that these would fix, so I think we can apply
these as-is.

Thierry


Attachments:
(No filename) (809.00 B)
signature.asc (833.00 B)
Download all attachments

2017-08-23 23:07:06

by Stephen Boyd

[permalink] [raw]
Subject: Re: [PATCH 00/14] Fixes for Tegra clocks

On 08/17, Thierry Reding wrote:
> On Thu, Jul 27, 2017 at 11:54:06AM -0700, Stephen Boyd wrote:
> > On 07/26, Peter De Schrijver wrote:
> > > On Tue, Jul 25, 2017 at 06:37:46PM -0700, Stephen Boyd wrote:
> > > > On 07/25, Peter De Schrijver wrote:
> > > > > A number of smaller fixes and simplifications for the Tegra clock
> > > > > implementation.
> > > >
> > > > Any of these need fixes tags so they can be backported to stable
> > > > trees? Also, everyone is on To: line, so not sure who is supposed
> > >
> > > I will have a look. For some of them a backport might be useful.
> > >
> > > > to pick these up. Me? That's fine if so.
> > > >
> > >
> > > That would be the easiest I think.
> > >
> >
> > Ok. I'll wait for you to reply with tags unless you didn't find
> > any?
>
> I'm not aware of any bugs that these would fix, so I think we can apply
> these as-is.
>

Ok. Applied them all to clk-next.

--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project