linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rhyland Klein <rklein@nvidia.com>
To: Andrew Bresticker <abrestic@google.com>
Cc: Peter De Schrijver <pdeschrijver@nvidia.com>,
	Mike Turquette <mturquette@linaro.org>,
	Stephen Warren <swarren@wwwdotorg.org>,
	Stephen Boyd <sboyd@codeaurora.org>,
	Thierry Reding <thierry.reding@gmail.com>,
	Alexandre Courbot <gnurou@gmail.com>, <linux-clk@vger.kernel.org>,
	"linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 12/19] clk: tegra: pll: Add specialized logic for T210
Date: Wed, 29 Apr 2015 17:42:48 -0400	[thread overview]
Message-ID: <55415058.1030306@nvidia.com> (raw)
In-Reply-To: <CAL1qeaEiKdFdhEfbWygFZcEioiGotd7=UDby9T7c_6djaDFxQA@mail.gmail.com>

On 4/29/2015 2:27 PM, Andrew Bresticker wrote:
> Hi Rhyland,
> 
> On Wed, Apr 29, 2015 at 10:21 AM, Rhyland Klein <rklein@nvidia.com> wrote:
>> On Tegra210 SoC's, the logic to enable several of the plls is different
>> from previous generations. Therefore, add registeration functions specific
>> to Tegra210 which will handle them appropriately.
>>
>> Signed-off-by: Rhyland Klein <rklein@nvidia.com>
> 
>> +#if defined(CONFIG_ARCH_TEGRA_210_SOC)
>> +static int clk_plle_tegra210_enable(struct clk_hw *hw)
>> +{
>> +       struct tegra_clk_pll *pll = to_clk_pll(hw);
>> +       struct tegra_clk_pll_freq_table sel;
>> +       u32 val;
>> +       int ret;
>> +       unsigned long flags = 0;
>> +       unsigned long input_rate = clk_get_rate(clk_get_parent(hw->clk));
>> +
>> +       if (_get_table_rate(hw, &sel, pll->params->fixed_rate, input_rate))
>> +               return -EINVAL;
>> +
>> +       if (pll->lock)
>> +               spin_lock_irqsave(pll->lock, flags);
>> +
>> +       val = pll_readl_base(pll);
>> +       val &= ~BIT(29); /* Disable lock override */
> 
> The LOCK_OVERRIDE bit has also moved on Tegra210 - it's now bit 30.

Yep, missed that one. Double checking all registers.
> 
>> +       pll_writel_base(val, pll);
>> +
>> +       val = pll_readl(pll->params->aux_reg, pll);
>> +       val |= PLLE_AUX_ENABLE_SWCTL;
>> +       val &= ~PLLE_AUX_SEQ_ENABLE;
>> +       pll_writel(val, pll->params->aux_reg, pll);
> 
> I'm not sure this bit is necessary - it's not in the TRM and it's not
> present in downstream kernels.

It is in the version of the TRM I am looking at, and present in
downstream kernels (at least the one I am looking at has it).

> 
>> +       udelay(1);
>> +
>> +       val = pll_readl_misc(pll);
>> +       val |= PLLE_MISC_LOCK_ENABLE;
>> +       val |= PLLE_MISC_IDDQ_SW_CTRL;
>> +       val &= ~PLLE_MISC_IDDQ_SW_VALUE;
>> +       val |= PLLE_MISC_PLLE_PTS;
>> +       val |= PLLE_MISC_VREG_BG_CTRL_MASK | PLLE_MISC_VREG_CTRL_MASK;
>> +       pll_writel_misc(val, pll);
>> +       udelay(5);
>> +
>> +       val = pll_readl(PLLE_SS_CTRL, pll);
>> +       val |= PLLE_SS_DISABLE;
>> +       pll_writel(val, PLLE_SS_CTRL, pll);
>> +
>> +       val = pll_readl_base(pll);
>> +       val &= ~(divp_mask_shifted(pll) | divn_mask_shifted(pll) |
>> +                divm_mask_shifted(pll));
>> +       val &= ~(PLLE_BASE_DIVCML_MASK << PLLE_BASE_DIVCML_SHIFT);
>> +       val |= sel.m << divm_shift(pll);
>> +       val |= sel.n << divn_shift(pll);
>> +       val |= sel.cpcon << PLLE_BASE_DIVCML_SHIFT;
>> +       pll_writel_base(val, pll);
>> +       udelay(1);
>> +
>> +       val = pll_readl_base(pll);
>> +       val |= PLLE_BASE_ENABLE;
>> +       pll_writel_base(val, pll);
>> +
>> +       ret = clk_pll_wait_for_lock(pll);
>> +
>> +       if (ret < 0)
>> +               goto out;
>> +
>> +       val = pll_readl(PLLE_SS_CTRL, pll);
>> +       val &= ~(PLLE_SS_CNTL_CENTER | PLLE_SS_CNTL_INVERT);
>> +       val &= ~PLLE_SS_COEFFICIENTS_MASK;
>> +       val |= PLLE_SS_COEFFICIENTS_VAL;
>> +       pll_writel(val, PLLE_SS_CTRL, pll);
>> +       val &= ~(PLLE_SS_CNTL_SSC_BYP | PLLE_SS_CNTL_BYPASS_SS);
>> +       pll_writel(val, PLLE_SS_CTRL, pll);
>> +       udelay(1);
>> +       val &= ~PLLE_SS_CNTL_INTERP_RESET;
>> +       pll_writel(val, PLLE_SS_CTRL, pll);
>> +       udelay(1);
>> +
>> +       /* Enable hw control of xusb brick pll */
>> +       val = pll_readl_misc(pll);
>> +       val &= ~PLLE_MISC_IDDQ_SW_CTRL;
>> +       pll_writel_misc(val, pll);
>> +
>> +       val = pll_readl(pll->params->aux_reg, pll);
>> +       val |= (PLLE_AUX_USE_LOCKDET | PLLE_AUX_SEQ_START_STATE);
> 
> PLLE_AUX_SS_SEQ_INCLUDE (bit 31) should be set here instead of
> PLLE_AUX_SEQ_START_STATE.

Yep good catch.

> 
>> +       val &= ~(PLLE_AUX_ENABLE_SWCTL | PLLE_AUX_SS_SWCTL);
>> +       pll_writel(val, pll->params->aux_reg, pll);
>> +       udelay(1);
>> +       val |= PLLE_AUX_SEQ_ENABLE;
>> +       pll_writel(val, pll->params->aux_reg, pll);
>> +
>> +       val = pll_readl(XUSBIO_PLL_CFG0, pll);
>> +       val |= (XUSBIO_PLL_CFG0_PADPLL_USE_LOCKDET |
>> +               XUSBIO_PLL_CFG0_SEQ_START_STATE);
>> +       val &= ~(XUSBIO_PLL_CFG0_CLK_ENABLE_SWCTL |
>> +                XUSBIO_PLL_CFG0_PADPLL_RESET_SWCTL);
>> +       pll_writel(val, XUSBIO_PLL_CFG0, pll);
>> +       udelay(1);
>> +       val |= XUSBIO_PLL_CFG0_SEQ_ENABLE;
>> +       pll_writel(val, XUSBIO_PLL_CFG0, pll);
>> +
>> +       /* Enable hw control of SATA pll */
>> +       val = pll_readl(SATA_PLL_CFG0, pll);
>> +       val &= ~SATA_PLL_CFG0_PADPLL_RESET_SWCTL;
>> +       val |= SATA_PLL_CFG0_PADPLL_USE_LOCKDET;
>> +       val |= SATA_PLL_CFG0_SEQ_START_STATE;
>> +       pll_writel(val, SATA_PLL_CFG0, pll);
>> +
>> +       udelay(1);
>> +
>> +       val = pll_readl(SATA_PLL_CFG0, pll);
>> +       val |= SATA_PLL_CFG0_SEQ_ENABLE;
>> +       pll_writel(val, SATA_PLL_CFG0, pll);
> 
> The XUSBIO and SATA PLL bits can be removed for Tegra210.  They must
> now be done separately, as part of the UPHY enable sequence.

Will do.

> 
>> +
>> +out:
>> +       if (pll->lock)
>> +               spin_unlock_irqrestore(pll->lock, flags);
>> +
>> +       return ret;
>> +}
> 
>> +struct clk *tegra_clk_register_plle_tegra210(const char *name,
>> +                               const char *parent_name,
>> +                               void __iomem *clk_base, unsigned long flags,
>> +                               struct tegra_clk_pll_params *pll_params,
>> +                               spinlock_t *lock)
>> +{
>> +       struct tegra_clk_pll *pll;
>> +       struct clk *clk;
>> +       u32 val, val_aux;
>> +
>> +       pll = _tegra_init_pll(clk_base, NULL, pll_params, lock);
>> +       if (IS_ERR(pll))
>> +               return ERR_CAST(pll);
>> +
>> +       /* ensure parent is set to pll_re_vco */
> 
> I think this is a typo - we're ensuring that the parent is set to pll_ref here.

Yep.

> 
>> +       val = pll_readl_base(pll);
>> +       val_aux = pll_readl(pll_params->aux_reg, pll);
>> +
>> +       if (val & PLLE_BASE_ENABLE) {
>> +               if ((val_aux & PLLE_AUX_PLLRE_SEL) ||
>> +                       (val_aux & PLLE_AUX_PLLP_SEL))
>> +                       WARN(1, "pll_e enabled with unsupported parent %s\n",
>> +                         (val_aux & PLLE_AUX_PLLP_SEL) ? "pllp_out0" :
>> +                                       "pll_re_vco");
>> +       } else {
>> +               val_aux &= ~(PLLE_AUX_PLLRE_SEL | PLLE_AUX_PLLP_SEL);
>> +               pll_writel(val_aux, pll_params->aux_reg, pll);
>> +       }
>> +
>> +       clk = _tegra_clk_register_pll(pll, name, parent_name, flags,
>> +                                     &tegra_clk_plle_tegra210_ops);
>> +       if (IS_ERR(clk))
>> +               kfree(pll);
>> +
>> +       return clk;
>> +}
> 
> -Andrew
> 

Thanks for the review. I'll double check the registers again and post v3
tomorrow.

-rhyland


-- 
nvpublic

  reply	other threads:[~2015-04-29 21:42 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-29 17:21 [PATCH v2 00/19] Tegra210 Clock Support Rhyland Klein
2015-04-29 17:21 ` [PATCH v2 01/19] clk: tegra: Modify tegra_audio_clk_init to accept more plls Rhyland Klein
2015-04-29 17:21 ` [PATCH v2 02/19] clk: tegra: periph: add new periph clks and muxes for Tegra210 Rhyland Klein
2015-04-29 17:21 ` [PATCH v2 03/19] clk: tegra: pll: add tegra_pll_wait_for_lock to clk header Rhyland Klein
2015-04-29 17:21 ` [PATCH v2 04/19] clk: tegra: pll: simplify clk_enable_path Rhyland Klein
2015-04-29 17:21 ` [PATCH v2 05/19] clk: tegra: pll: update warning msg Rhyland Klein
2015-04-29 17:21 ` [PATCH v2 06/19] clk: tegra: pll-params: change misc_reg count from 3 -> 6 Rhyland Klein
2015-04-29 17:21 ` [PATCH v2 07/19] clk: tegra: pll: Don't unconditionally set LOCK flags Rhyland Klein
2015-04-29 17:21 ` [PATCH v2 08/19] clk: tegra: pll: Add logic for handling SDM data Rhyland Klein
2015-04-29 17:21 ` [PATCH v2 09/19] clk: tegra: pll: Add logic for SS Rhyland Klein
2015-04-29 17:21 ` [PATCH v2 10/19] clk: tegra: pll: Add logic for out-of-table rates for T210 Rhyland Klein
2015-04-29 17:21 ` [PATCH v2 11/19] clk: tegra: pll: Add code to handle if resets are supported by PLL Rhyland Klein
2015-04-29 17:21 ` [PATCH v2 12/19] clk: tegra: pll: Add specialized logic for T210 Rhyland Klein
2015-04-29 18:27   ` Andrew Bresticker
2015-04-29 21:42     ` Rhyland Klein [this message]
2015-04-29 17:21 ` [PATCH v2 13/19] clk: tegra: pll: Add support for PLLMB " Rhyland Klein
2015-04-30 10:11   ` Peter De Schrijver
2015-04-29 17:21 ` [PATCH v2 14/19] clk: tegra: pll: Adjust vco_min if SDM present Rhyland Klein
2015-04-29 17:21 ` [PATCH v2 15/19] clk: tegra: pll: Add dyn_ramp callback Rhyland Klein
2015-04-29 17:21 ` [PATCH v2 16/19] clk: tegra: pll: Add Set_default logic Rhyland Klein
2015-04-30 10:12   ` Peter De Schrijver
2015-04-30 15:31     ` Rhyland Klein
2015-05-11 11:50       ` Peter De Schrijver
2015-05-11 15:07         ` Rhyland Klein
2015-04-29 17:21 ` [PATCH v2 17/19] clk: tegra: pll: Fix _pll_ramp_calc_pll logic and _calc_dynamic_ramp_rate Rhyland Klein
2015-04-29 17:21 ` [PATCH v2 18/19] clk: tegra: Add Super Gen5 Logic Rhyland Klein
2015-04-29 17:21 ` [PATCH v2 19/19] clk: tegra210: add support for Tegra210 clocks Rhyland Klein
2015-04-30 20:43   ` Andrew Bresticker
2015-04-30 20:57     ` Rhyland Klein

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=55415058.1030306@nvidia.com \
    --to=rklein@nvidia.com \
    --cc=abrestic@google.com \
    --cc=gnurou@gmail.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mturquette@linaro.org \
    --cc=pdeschrijver@nvidia.com \
    --cc=sboyd@codeaurora.org \
    --cc=swarren@wwwdotorg.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;
as well as URLs for NNTP newsgroup(s).