linux-amlogic.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Neil Armstrong <narmstrong@baylibre.com>
To: Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
	sboyd@codeaurora.org
Cc: khilman@baylibre.com, linux-kernel@vger.kernel.org,
	linux-gpio@vger.kernel.org, linux-amlogic@lists.infradead.org,
	linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	jbrunet@baylibre.com
Subject: Re: [RFC/RFT v3 07/14] clk: meson: g12a: add notifiers to handle cpu clock change
Date: Wed, 3 Jul 2019 13:50:00 +0200	[thread overview]
Message-ID: <369f5e9b-b02a-5f5c-25a7-49803650e9c5@baylibre.com> (raw)
In-Reply-To: <CAFBinCAnKeGYkyCmEMugWuQaSxgBp4DqtHN3b0rLJY6jwOF0QA@mail.gmail.com>

On 03/07/2019 01:28, Martin Blumenstingl wrote:
> Hi Stephen, Hi Neil,
> 
> On Mon, Jul 1, 2019 at 11:13 AM Neil Armstrong <narmstrong@baylibre.com> wrote:
>>
>> In order to implement clock switching for the CLKID_CPU_CLK and
>> CLKID_CPUB_CLK, notifiers are added on specific points of the
>> clock tree :
>>
>> cpu_clk / cpub_clk
>> |   \- cpu_clk_dyn
>> |      |  \- cpu_clk_premux0
>> |      |        |- cpu_clk_postmux0
>> |      |        |    |- cpu_clk_dyn0_div
>> |      |        |    \- xtal/fclk_div2/fclk_div3
>> |      |        \- xtal/fclk_div2/fclk_div3
>> |      \- cpu_clk_premux1
>> |            |- cpu_clk_postmux1
>> |            |    |- cpu_clk_dyn1_div
>> |            |    \- xtal/fclk_div2/fclk_div3
>> |            \- xtal/fclk_div2/fclk_div3
>> \ sys_pll / sys1_pll
>>
>> This for each cluster, a single one for G12A, two for G12B.
>>
>> Each cpu_clk_premux1 tree is marked as read-only and CLK_SET_RATE_NO_REPARENT,
>> to be used as "parking" clock in a safe clock frequency.
> it seems that this is one case where the "coordinated clocks" feature
> would come handy: [0]

We could still migrate over it later on.

> Stephen, do you know if those patches stopped in March or if there's
> still some ongoing effort to get them ready?
> 
> [...]
>> -/*
>> - * Internal sys pll emulation configuration parameters
>> - */
>> -static const struct reg_sequence g12a_sys_init_regs[] = {
>> -       { .reg = HHI_SYS_PLL_CNTL1,     .def = 0x00000000 },
>> -       { .reg = HHI_SYS_PLL_CNTL2,     .def = 0x00000000 },
>> -       { .reg = HHI_SYS_PLL_CNTL3,     .def = 0x48681c00 },
>> -       { .reg = HHI_SYS_PLL_CNTL4,     .def = 0x88770290 },
>> -       { .reg = HHI_SYS_PLL_CNTL5,     .def = 0x39272000 },
>> -       { .reg = HHI_SYS_PLL_CNTL6,     .def = 0x56540000 },
>> +static const struct pll_mult_range g12a_sys_pll_mult_range = {
>> +       .min = 128,
>> +       .max = 250,
>>  };
>>
>>  static struct clk_regmap g12a_sys_pll_dco = {
>> @@ -124,14 +118,15 @@ static struct clk_regmap g12a_sys_pll_dco = {
>>                         .shift   = 29,
>>                         .width   = 1,
>>                 },
>> -               .init_regs = g12a_sys_init_regs,
>> -               .init_count = ARRAY_SIZE(g12a_sys_init_regs),
>> +               .range = &g12a_sys_pll_mult_range,
> Neil, I believe that this should be a separate patch with a
> description which explains why we don't need the "init regs" anymore

Sure

> 
>>         },
>>         .hw.init = &(struct clk_init_data){
>>                 .name = "sys_pll_dco",
>> -               .ops = &meson_clk_pll_ro_ops,
>> +               .ops = &meson_clk_pll_ops,
>>                 .parent_names = (const char *[]){ IN_PREFIX "xtal" },
>>                 .num_parents = 1,
>> +               /* This clock feeds the CPU, avoid disabling it */
>> +               .flags = CLK_IS_CRITICAL,
> maybe we should have a separate patch for making the CPU clock tree
> mutable as well

Indeed

> 
> [...]
>> +/* This divider uses bit 26 to take change in account */
>> +static int g12b_cpub_clk_mux0_div_set_rate(struct clk_hw *hw,
>> +                                          unsigned long rate,
>> +                                          unsigned long parent_rate)
>> +{
>> +       struct clk_regmap *clk = to_clk_regmap(hw);
>> +       struct clk_regmap_div_data *div = clk_get_regmap_div_data(clk);
>> +       unsigned int val;
>> +       int ret;
>> +
>> +       ret = divider_get_val(rate, parent_rate, div->table, div->width,
>> +                             div->flags);
>> +       if (ret < 0)
>> +               return ret;
>> +
>> +       val = (unsigned int)ret << div->shift;
>> +
>> +       regmap_update_bits(clk->map, HHI_SYS_CPUB_CLK_CNTL,
>> +                          SYS_CPU_DYN_ENABLE, SYS_CPU_DYN_ENABLE);
>> +
>> +       return regmap_update_bits(clk->map, div->offset,
>> +                                 clk_div_mask(div->width) << div->shift |
>> +                                 SYS_CPU_DYN_ENABLE, val);
>> +};
> the public S922X datasheet doesn't mention bit 26
> do I understand the semantics correctly?:
> - set SYS_CPU_DYN_ENABLE
> - update the divider
> - unset SYS_CPU_DYN_ENABLE

Exact, it's how Amlogic uses it, seems the HW takes the divider value
only on the "falling edge" of this bit !

> 
> too bad it's not a gate which we could model with
> CLK_SET_RATE_GATE/CLK_SET_RATE_UNGATE

Yep, but it only works when I write the new divider value *and* I remove the bit.
It must be a glitch-free divider mechanism.

Neil

> 
> 
> Martin
> 
> [0] https://patchwork.kernel.org/patch/10838949/
> 


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

  reply	other threads:[~2019-07-03 11:50 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-01  9:12 [RFC/RFT v3 00/14] arm64: g12a: add support for DVFS Neil Armstrong
2019-07-01  9:12 ` [RFC/RFT v3 01/14] pinctrl: meson-g12a: add pwm_a on GPIOE_2 pinmux Neil Armstrong
2019-07-02 22:56   ` Martin Blumenstingl
2019-07-01  9:12 ` [RFC/RFT v3 02/14] clk: core: introduce clk_hw_set_parent() Neil Armstrong
2019-07-02 23:05   ` Martin Blumenstingl
2019-07-01  9:12 ` [RFC/RFT v3 03/14] clk: meson: regmap: export regmap_div ops functions Neil Armstrong
2019-07-01  9:12 ` [RFC/RFT v3 04/14] clk: meson: eeclk: add setup callback Neil Armstrong
2019-07-02 23:16   ` Martin Blumenstingl
2019-07-03 11:45     ` Neil Armstrong
2019-07-03 12:40       ` Jerome Brunet
2019-07-03 12:57         ` Martin Blumenstingl
2019-07-03 14:17   ` Jerome Brunet
2019-07-26 14:50     ` Neil Armstrong
2019-07-29  7:42       ` Jerome Brunet
2019-07-01  9:12 ` [RFC/RFT v3 05/14] soc: amlogic: meson-clk-measure: protect measure with a mutex Neil Armstrong
2019-07-02 23:01   ` Martin Blumenstingl
2019-07-01  9:12 ` [RFC/RFT v3 06/14] soc: amlogic: meson-clk-measure: add G12B second cluster cpu clk Neil Armstrong
2019-07-02 22:58   ` Martin Blumenstingl
2019-07-01  9:12 ` [RFC/RFT v3 07/14] clk: meson: g12a: add notifiers to handle cpu clock change Neil Armstrong
2019-07-02 23:28   ` Martin Blumenstingl
2019-07-03 11:50     ` Neil Armstrong [this message]
2019-08-08  4:43     ` Stephen Boyd
2019-07-01  9:12 ` [RFC/RFT v3 08/14] clk: meson: g12a: expose CPUB clock ID for G12B Neil Armstrong
2019-07-02 23:03   ` Martin Blumenstingl
2019-07-01  9:12 ` [RFC/RFT v3 09/14] arm64: dts: move common G12A & G12B modes to meson-g12-common.dtsi Neil Armstrong
2019-07-02 23:54   ` Martin Blumenstingl
2019-07-03 11:51     ` Neil Armstrong
2019-07-03 12:48       ` Jerome Brunet
2019-07-01  9:12 ` [RFC/RFT v3 10/14] arm64: dts: meson-g12-common: add pwm_a on GPIOE_2 pinmux Neil Armstrong
2019-07-02 23:11   ` Martin Blumenstingl
2019-07-01  9:12 ` [RFC/RFT v3 11/14] arm64: dts: meson-g12a: add cpus OPP table Neil Armstrong
2019-07-02 23:47   ` Martin Blumenstingl
2019-07-03 11:53     ` Neil Armstrong
2019-07-03 12:12       ` Martin Blumenstingl
2019-07-01  9:12 ` [RFC/RFT v3 12/14] arm64: dts: meson-g12a: enable DVFS on G12A boards Neil Armstrong
2019-07-02 23:43   ` Martin Blumenstingl
2019-07-01  9:12 ` [RFC/RFT v3 13/14] arm64: dts: meson-g12b: add cpus OPP tables Neil Armstrong
2019-07-01  9:12 ` [RFC/RFT v3 14/14] arm64: dts: meson-g12b-odroid-n2: enable DVFS Neil Armstrong
2019-07-02 23:45   ` Martin Blumenstingl
2019-07-03 11:54     ` Neil Armstrong

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=369f5e9b-b02a-5f5c-25a7-49803650e9c5@baylibre.com \
    --to=narmstrong@baylibre.com \
    --cc=jbrunet@baylibre.com \
    --cc=khilman@baylibre.com \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=sboyd@codeaurora.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 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).