linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sowjanya Komatineni <skomatineni@nvidia.com>
To: Stephen Boyd <sboyd@kernel.org>, <jason@lakedaemon.net>,
	<jonathanh@nvidia.com>, <linus.walleij@linaro.org>,
	<marc.zyngier@arm.com>, <mark.rutland@arm.com>, <stefan@agner.ch>,
	<tglx@linutronix.de>, <thierry.reding@gmail.com>
Cc: <pdeschrijver@nvidia.com>, <pgaikwad@nvidia.com>,
	<linux-clk@vger.kernel.org>, <linux-gpio@vger.kernel.org>,
	<jckuo@nvidia.com>, <josephl@nvidia.com>, <talho@nvidia.com>,
	<linux-tegra@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<mperttunen@nvidia.com>, <spatra@nvidia.com>,
	<robh+dt@kernel.org>, <devicetree@vger.kernel.org>
Subject: Re: [PATCH V2 07/12] clk: tegra: support for Tegra210 clocks suspend-resume
Date: Thu, 6 Jun 2019 12:13:18 -0700	[thread overview]
Message-ID: <08e34220-4cec-377e-40eb-107d2c505dd7@nvidia.com> (raw)
In-Reply-To: <20190606181711.744502083D@mail.kernel.org>


On 6/6/19 11:17 AM, Stephen Boyd wrote:
> Quoting Sowjanya Komatineni (2019-05-28 16:08:51)
>> @@ -3381,6 +3398,367 @@ static struct tegra_clk_init_table init_table[] __initdata = {
>>          { TEGRA210_CLK_CLK_MAX, TEGRA210_CLK_CLK_MAX, 0, 0 },
>>   };
>>   
>> +#ifdef CONFIG_PM_SLEEP
>> +static unsigned long pll_c_rate, pll_c2_rate, pll_c3_rate, pll_x_rate;
>> +static unsigned long pll_c4_rate, pll_d2_rate, pll_dp_rate;
>> +static unsigned long pll_re_vco_rate, pll_d_rate, pll_a_rate, pll_a1_rate;
>> +static unsigned long pll_c_out1_rate;
>> +static unsigned long pll_a_out0_rate, pll_c4_out3_rate;
>> +static unsigned long pll_p_out_rate[5];
>> +static unsigned long pll_u_out1_rate, pll_u_out2_rate;
>> +static unsigned long pll_mb_rate;
>> +static u32 pll_m_v;
>> +static u32 pll_p_outa, pll_p_outb;
>> +static u32 pll_re_out_div, pll_re_out_1;
>> +static u32 cpu_softrst_ctx[3];
>> +static u32 cclkg_burst_policy_ctx[2];
>> +static u32 cclklp_burst_policy_ctx[2];
>> +static u32 sclk_burst_policy_ctx[3];
>> +static u32 sclk_ctx, spare_ctx, misc_clk_enb_ctx, clk_arm_ctx;
> This is a lot of state to maintain globally. Can it go into a container
> struct so we can get docs and understand what's going on a little
> better?
>
Will revisit and change in next version along with using clk driver 
save_context and restore_context callbacks.
>> +
>> +static struct platform_device *dfll_pdev;
>> +#define car_readl(_base, _off) \
>> +       readl_relaxed(clk_base + (_base) + ((_off) * 4))
>> +#define car_writel(_val, _base, _off) \
>> +       writel_relaxed(_val, clk_base + (_base) + ((_off) * 4))
>> +
>> +static u32 *periph_clk_src_ctx;
>> +struct periph_source_bank {
>> +       u32 start;
>> +       u32 end;
> Do these need to be u32 or could they be u16?
WIll update in next version of this patch
>> +};
>> +
>> +static struct periph_source_bank periph_srcs[] = {
> Can this be const?
WIll update in next version of this patch
>
>> +       [0] = {
>> +               .start = 0x100,
>> +               .end = 0x198,
>> +       },
>> +       [1] = {
>> +               .start = 0x1a0,
>> +               .end = 0x1f8,
>> +       },
>> +       [2] = {
>> +               .start = 0x3b4,
>> +               .end = 0x42c,
>> +       },
>> +       [3] = {
>> +               .start = 0x49c,
>> +               .end = 0x4b4,
>> +       },
>> +       [4] = {
>> +               .start = 0x560,
>> +               .end = 0x564,
>> +       },
>> +       [5] = {
>> +               .start = 0x600,
>> +               .end = 0x678,
>> +       },
>> +       [6] = {
>> +               .start = 0x694,
>> +               .end = 0x6a0,
>> +       },
>> +       [7] = {
>> +               .start = 0x6b8,
>> +               .end = 0x718,
>> +       },
>> +};
>> +
>> +/* This array lists the valid clocks for each periph clk bank */
>> +static u32 periph_clks_on[] = {
> const?
WIll update in next version of this patch
>> +       0xdcd7dff9,
>> +       0x87d1f3e7,
>> +       0xf3fed3fa,
>> +       0xffc18cfb,
>> +       0x793fb7ff,
>> +       0x3fe66fff,
>> +       0xfc1fc7ff,
> What are these magic numbers?

These are the hard coded values for peripheral clock enable register 
where it enables all clocks before restoring clock sources to proper rate.


>> +};
>> +
>> +static inline unsigned long clk_get_rate_nolock(struct clk *clk)
>> +{
>> +       if (IS_ERR_OR_NULL(clk)) {
> NULL is a valid clk pointer. Typically usage of IS_ERR_OR_NULL() is
> wrong.
>
>> +               WARN_ON(1);
>> +               return 0;
>> +       }
>> +
>> +       return clk_hw_get_rate(__clk_get_hw(clk));
>> +}
>> +
>> +static inline struct clk *pll_p_clk(unsigned int x)
>> +{
>> +       if (x < 4) {
> What is magic value 4?

PLLP outs OUT1 through OUT4 are defined sequential in tegra210-car.h and 
OUT5  is not so retrieving value from clks using sequential indexing for 
up to OUT4.

Will update in next version to use define

>> +               return clks[TEGRA210_CLK_PLL_P_OUT1 + x];
>> +       } else if (x != 4) {
>> +               WARN_ON(1);
>> +               return NULL;
>> +       } else {
>> +               return clks[TEGRA210_CLK_PLL_P_OUT5];
>> +       }
>> +}
>> +
> [..]
>> +
>> +static void tegra210_clk_resume(void)
>> +{
> [..]
>> +       fence_udelay(2, clk_base);
>> +       for (i = 0; i < BURST_POLICY_REG_SIZE; i++) {
>> +               car_writel(cclklp_burst_policy_ctx[i], CCLKLP_BURST_POLICY, i);
>> +               car_writel(sclk_burst_policy_ctx[i], SCLK_BURST_POLICY, i);
>> +       }
>> +       car_writel(sclk_burst_policy_ctx[i], SYS_CLK_DIV, 0);
>> +
>> +       car_writel(sclk_ctx, SYSTEM_CLK_RATE, 0);
>> +       car_writel(spare_ctx, SPARE_REG0, 0);
>> +       car_writel(misc_clk_enb_ctx, MISC_CLK_ENB, 0);
>> +       car_writel(clk_arm_ctx, CLK_MASK_ARM, 0);
>> +
>> +       /* enable all clocks before configuring clock sources */
>> +       tegra_clk_periph_force_on(periph_clks_on, ARRAY_SIZE(periph_clks_on),
>> +                                 clk_base);
>> +
>> +       wmb();
> Please add a comment before barriers so we know what they're for.
Will do in next version of this patch.
>> +       fence_udelay(2, clk_base);
>> +

  reply	other threads:[~2019-06-06 19:13 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-28 23:08 [PATCH V2 00/12] LP0 entry and exit support for Tegra210 Sowjanya Komatineni
2019-05-28 23:08 ` [PATCH V2 01/12] irqchip: tegra: do not disable COP IRQ during suspend Sowjanya Komatineni
2019-05-29 14:21   ` Thierry Reding
2019-05-28 23:08 ` [PATCH V2 02/12] pinctrl: tegra: add suspend and resume support Sowjanya Komatineni
2019-05-29 15:29   ` Dmitry Osipenko
2019-05-29 18:14     ` Sowjanya Komatineni
2019-05-29 19:32       ` Dmitry Osipenko
2019-05-29 20:11         ` Sowjanya Komatineni
2019-05-29 20:47           ` Dmitry Osipenko
2019-05-29 20:56             ` Sowjanya Komatineni
2019-05-29 21:07               ` Sowjanya Komatineni
2019-05-29 21:25               ` Dmitry Osipenko
2019-05-29 21:27                 ` Sowjanya Komatineni
2019-05-29 21:33                   ` Dmitry Osipenko
2019-05-28 23:08 ` [PATCH V2 03/12] clk: tegra: save and restore PLLs state for system Sowjanya Komatineni
2019-05-29 23:28   ` Stephen Boyd
2019-05-31 19:52     ` Sowjanya Komatineni
2019-06-05 23:31       ` Stephen Boyd
2019-05-28 23:08 ` [PATCH V2 04/12] clk: tegra: add support for peripheral clock suspend and resume Sowjanya Komatineni
2019-05-29 23:30   ` Stephen Boyd
2019-05-31 19:55     ` Sowjanya Komatineni
2019-05-28 23:08 ` [PATCH V2 05/12] clk: tegra: add support for OSC clock resume Sowjanya Komatineni
2019-05-28 23:08 ` [PATCH V2 06/12] clk: tegra: add suspend resume support for DFLL clock Sowjanya Komatineni
2019-06-04 12:41   ` Peter De Schrijver
2019-05-28 23:08 ` [PATCH V2 07/12] clk: tegra: support for Tegra210 clocks suspend-resume Sowjanya Komatineni
2019-06-06 18:17   ` Stephen Boyd
2019-06-06 19:13     ` Sowjanya Komatineni [this message]
2019-05-28 23:08 ` [PATCH V2 08/12] soc/tegra: pmc: allow support for more tegra wake models Sowjanya Komatineni
2019-05-29 14:30   ` Thierry Reding
2019-05-28 23:08 ` [PATCH V2 09/12] soc/tegra: pmc: add pmc wake support for tegra210 Sowjanya Komatineni
2019-05-29  5:42   ` JC Kuo
2019-05-29 13:52   ` Thierry Reding
2019-05-28 23:08 ` [PATCH V2 10/12] gpio: tegra: implement wake event support for Tegra210 and prior GPIO Sowjanya Komatineni
2019-05-29 14:03   ` Thierry Reding
2019-06-01  8:28     ` Sowjanya Komatineni
2019-05-28 23:08 ` [PATCH V2 11/12] arm64: tegra: enable wake from deep sleep on RTC alarm Sowjanya Komatineni
2019-05-28 23:08 ` [PATCH V2 12/12] soc/tegra: pmc: configure tegra deep sleep control settings Sowjanya Komatineni
2019-05-29 14:05   ` Thierry Reding
2019-05-29 14:12 ` [PATCH V2 00/12] LP0 entry and exit support for Tegra210 Thierry Reding
2019-06-04 13:47 ` Peter De Schrijver

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=08e34220-4cec-377e-40eb-107d2c505dd7@nvidia.com \
    --to=skomatineni@nvidia.com \
    --cc=devicetree@vger.kernel.org \
    --cc=jason@lakedaemon.net \
    --cc=jckuo@nvidia.com \
    --cc=jonathanh@nvidia.com \
    --cc=josephl@nvidia.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=marc.zyngier@arm.com \
    --cc=mark.rutland@arm.com \
    --cc=mperttunen@nvidia.com \
    --cc=pdeschrijver@nvidia.com \
    --cc=pgaikwad@nvidia.com \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@kernel.org \
    --cc=spatra@nvidia.com \
    --cc=stefan@agner.ch \
    --cc=talho@nvidia.com \
    --cc=tglx@linutronix.de \
    --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).