All of lore.kernel.org
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: Dong Aisheng <dongas86@gmail.com>
Cc: Dong Aisheng <aisheng.dong@nxp.com>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, sboyd@codeaurora.org,
	vireshk@kernel.org, nm@ti.com, rjw@rjwysocki.net,
	shawnguo@kernel.org, Anson.Huang@nxp.com, ping.bai@nxp.com
Subject: Re: [PATCH 1/7] PM / OPP: Add platform specific set_clk function
Date: Wed, 20 Sep 2017 13:30:33 -0700	[thread overview]
Message-ID: <20170920203033.GD3001@ubuntu> (raw)
In-Reply-To: <20170920070343.GA32187@b29396-OptiPlex-7040>

On 20-09-17, 15:03, Dong Aisheng wrote:
> I've been thinking of that before.
> Actually IMX already does some similar thing for MX5 (no for MX6).
> See: clk_cpu_set_rate() in drivers/clk/imx/clk-cpu.c.
> 
> After some diggings, it seems MX7ULP is a bit more complicated than before
> mainly due to two reasons:
> 1) It requires to switch to different CPU mode accordingly when setting
> clocks rate. That means we need handle this in clock driver as well
> which looks not quite suitable although we could do if really want.
> 
> 2) It uses different clocks for different CPU mode (RUN 416M or
> HSRUN 528M), and those clocks have some dependency.
> e.g. when setting HSRUN clock, we need change RUN clock parent to make sure
> the SPLL_PFD is got disabled before changing rate, as both CPU mode using
> the same parent SPLL_PFD clock. Doing this in clock driver also make things
> a bit more complicated.
> 
> The whole follow would be something like below:
> static int imx7ulp_set_clk(struct device *dev, struct clk *clk,
>                            unsigned long old_freq, unsigned long new_freq)
> {
>         u32 val;
> 
>         /*
>          * Before changing the ARM core PLL, change the ARM clock soure
>          * to FIRC first.
>          */
>         if (new_freq >= HSRUN_FREQ) {
>                 clk_set_parent(clks[RUN_SCS_SEL].clk, clks[FIRC].clk);
> 
>                 /* switch to HSRUN mode */
>                 val = readl_relaxed(smc_base + SMC_PMCTRL);
>                 val |= (0x3 << 8);
>                 writel_relaxed(val, smc_base + SMC_PMCTRL);
> 
>                 /* change the clock rate in HSRUN */
>                 clk_set_rate(clks[SPLL_PFD0].clk, new_freq);
>                 clk_set_parent(clks[HSRUN_SCS_SEL].clk, clks[SPLL_SEL].clk);
>         } else {
>                 /* change the HSRUN clock to firc */
>                 clk_set_parent(clks[HSRUN_SCS_SEL].clk, clks[FIRC].clk);
> 
>                 /* switch to RUN mode */
>                 val = readl_relaxed(smc_base + SMC_PMCTRL);
>                 val &= ~(0x3 << 8);
>                 writel_relaxed(val, smc_base + SMC_PMCTRL);
> 
>                 clk_set_rate(clks[SPLL_PFD0].clk, new_freq);
>                 clk_set_parent(clks[RUN_SCS_SEL].clk, clks[SPLL_SEL].clk);
>         }
> 
>         return 0;
> }

Right and we have the same thing in the cpufreq driver now. It will
stay at some place and we need to find the best one, keeping in mind
that we may or may not want to solve this problem in a generic way.

> That's why i thought if we can make OPP core provide a way to handle such
> complicated things in platform specific cpufreq driver.
> 
> How would you suggest for this issue?

I wouldn't add an API into the OPP framework if I were you. There is
just too much code to add to the core to handle such platform specific
stuff, which you are anyway going to keep somewhere as it is. IMHO,
keeping that in the clock driver is a better thing to do than this.

-- 
viresh

WARNING: multiple messages have this Message-ID (diff)
From: viresh.kumar@linaro.org (Viresh Kumar)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/7] PM / OPP: Add platform specific set_clk function
Date: Wed, 20 Sep 2017 13:30:33 -0700	[thread overview]
Message-ID: <20170920203033.GD3001@ubuntu> (raw)
In-Reply-To: <20170920070343.GA32187@b29396-OptiPlex-7040>

On 20-09-17, 15:03, Dong Aisheng wrote:
> I've been thinking of that before.
> Actually IMX already does some similar thing for MX5 (no for MX6).
> See: clk_cpu_set_rate() in drivers/clk/imx/clk-cpu.c.
> 
> After some diggings, it seems MX7ULP is a bit more complicated than before
> mainly due to two reasons:
> 1) It requires to switch to different CPU mode accordingly when setting
> clocks rate. That means we need handle this in clock driver as well
> which looks not quite suitable although we could do if really want.
> 
> 2) It uses different clocks for different CPU mode (RUN 416M or
> HSRUN 528M), and those clocks have some dependency.
> e.g. when setting HSRUN clock, we need change RUN clock parent to make sure
> the SPLL_PFD is got disabled before changing rate, as both CPU mode using
> the same parent SPLL_PFD clock. Doing this in clock driver also make things
> a bit more complicated.
> 
> The whole follow would be something like below:
> static int imx7ulp_set_clk(struct device *dev, struct clk *clk,
>                            unsigned long old_freq, unsigned long new_freq)
> {
>         u32 val;
> 
>         /*
>          * Before changing the ARM core PLL, change the ARM clock soure
>          * to FIRC first.
>          */
>         if (new_freq >= HSRUN_FREQ) {
>                 clk_set_parent(clks[RUN_SCS_SEL].clk, clks[FIRC].clk);
> 
>                 /* switch to HSRUN mode */
>                 val = readl_relaxed(smc_base + SMC_PMCTRL);
>                 val |= (0x3 << 8);
>                 writel_relaxed(val, smc_base + SMC_PMCTRL);
> 
>                 /* change the clock rate in HSRUN */
>                 clk_set_rate(clks[SPLL_PFD0].clk, new_freq);
>                 clk_set_parent(clks[HSRUN_SCS_SEL].clk, clks[SPLL_SEL].clk);
>         } else {
>                 /* change the HSRUN clock to firc */
>                 clk_set_parent(clks[HSRUN_SCS_SEL].clk, clks[FIRC].clk);
> 
>                 /* switch to RUN mode */
>                 val = readl_relaxed(smc_base + SMC_PMCTRL);
>                 val &= ~(0x3 << 8);
>                 writel_relaxed(val, smc_base + SMC_PMCTRL);
> 
>                 clk_set_rate(clks[SPLL_PFD0].clk, new_freq);
>                 clk_set_parent(clks[RUN_SCS_SEL].clk, clks[SPLL_SEL].clk);
>         }
> 
>         return 0;
> }

Right and we have the same thing in the cpufreq driver now. It will
stay at some place and we need to find the best one, keeping in mind
that we may or may not want to solve this problem in a generic way.

> That's why i thought if we can make OPP core provide a way to handle such
> complicated things in platform specific cpufreq driver.
> 
> How would you suggest for this issue?

I wouldn't add an API into the OPP framework if I were you. There is
just too much code to add to the core to handle such platform specific
stuff, which you are anyway going to keep somewhere as it is. IMHO,
keeping that in the clock driver is a better thing to do than this.

-- 
viresh

  reply	other threads:[~2017-09-20 20:30 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-23 16:10 [PATCH 0/7] PM / OPP: per OPP node clock support and imx7ulp cpufreq driver Dong Aisheng
2017-08-23 16:10 ` Dong Aisheng
2017-08-23 16:10 ` Dong Aisheng
2017-08-23 16:10 ` [PATCH 1/7] PM / OPP: Add platform specific set_clk function Dong Aisheng
2017-08-23 16:10   ` Dong Aisheng
2017-08-23 16:10   ` Dong Aisheng
2017-09-19 22:58   ` Viresh Kumar
2017-09-19 22:58     ` Viresh Kumar
2017-09-20  7:03     ` Dong Aisheng
2017-09-20  7:03       ` Dong Aisheng
2017-09-20 20:30       ` Viresh Kumar [this message]
2017-09-20 20:30         ` Viresh Kumar
2017-09-21  2:17         ` A.s. Dong
2017-09-21  2:17           ` A.s. Dong
2017-09-21  2:17           ` A.s. Dong
2017-08-23 16:10 ` [PATCH 2/7] dt-bindings: PM / OPP: add clocks per OPP node support Dong Aisheng
2017-08-23 16:10   ` Dong Aisheng
2017-08-23 16:10   ` Dong Aisheng
2017-08-31 17:39   ` Rob Herring
2017-08-31 17:39     ` Rob Herring
2017-09-01 13:01     ` Dong Aisheng
2017-09-01 13:01       ` Dong Aisheng
2017-08-23 16:10 ` [PATCH 3/7] PM / OPP: rename opp_table->clk to opp_table->cur_clk Dong Aisheng
2017-08-23 16:10   ` Dong Aisheng
2017-08-23 16:10   ` Dong Aisheng
2017-08-23 16:10 ` [PATCH 4/7] PM / OPP: use OPP node clock to set CPU frequency Dong Aisheng
2017-08-23 16:10   ` Dong Aisheng
2017-08-23 16:10   ` Dong Aisheng
2017-08-23 16:10 ` [PATCH 5/7] PM / OPP: Add dev_pm_opp_get_cur_clk() Dong Aisheng
2017-08-23 16:10   ` Dong Aisheng
2017-08-23 16:10   ` Dong Aisheng
2017-08-23 16:10 ` [PATCH 6/7] cpufreq: make cpufreq_generic_init transition_latency default to CPUFREQ_ETERNAL Dong Aisheng
2017-08-23 16:10   ` Dong Aisheng
2017-08-23 16:10   ` Dong Aisheng
2017-09-19 23:10   ` Viresh Kumar
2017-09-19 23:10     ` Viresh Kumar
2017-09-20  7:04     ` Dong Aisheng
2017-09-20  7:04       ` Dong Aisheng
2017-09-20 14:45       ` Viresh Kumar
2017-09-20 14:45         ` Viresh Kumar
2017-08-23 16:10 ` [PATCH 7/7] cpufreq: add imx7ulp cpufreq driver Dong Aisheng
2017-08-23 16:10   ` Dong Aisheng
2017-08-23 16:10   ` Dong Aisheng
2017-09-11  7:28 ` [PATCH 0/7] PM / OPP: per OPP node clock support and " Dong Aisheng
2017-09-11  7:28   ` Dong Aisheng
2017-09-19 22:54   ` Viresh Kumar
2017-09-19 22:54     ` Viresh Kumar

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=20170920203033.GD3001@ubuntu \
    --to=viresh.kumar@linaro.org \
    --cc=Anson.Huang@nxp.com \
    --cc=aisheng.dong@nxp.com \
    --cc=dongas86@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=nm@ti.com \
    --cc=ping.bai@nxp.com \
    --cc=rjw@rjwysocki.net \
    --cc=sboyd@codeaurora.org \
    --cc=shawnguo@kernel.org \
    --cc=vireshk@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.