linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chen-Yu Tsai <wens@csie.org>
To: Chen-Yu Tsai <wens@csie.org>
Cc: Maxime Ripard <maxime.ripard@free-electrons.com>,
	Mike Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@codeaurora.org>,
	linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	linux-clk <linux-clk@vger.kernel.org>
Subject: Re: [PATCH 2/10] clk: sunxi-ng: nkm: Deal with fixed post dividers
Date: Sun, 13 Nov 2016 11:49:30 +0800	[thread overview]
Message-ID: <CAGb2v65tX5C89bYYkcrd0kHp1eCAwMihspbdtJwVi8kWgCPL4Q@mail.gmail.com> (raw)
In-Reply-To: <CAGb2v64YW+7Grr4NvjuhsDNM2bF_fuhTkdW6Hs1=MXK2LFne0g@mail.gmail.com>

On Sun, Nov 13, 2016 at 11:48 AM, Chen-Yu Tsai <wens@csie.org> wrote:
> On Wed, Nov 9, 2016 at 1:23 AM, Maxime Ripard
> <maxime.ripard@free-electrons.com> wrote:
>
> It'd be better if you mentioned what clock needs this.
>
>> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
>> ---
>>  drivers/clk/sunxi-ng/ccu_nkm.c | 17 ++++++++++++++---
>>  drivers/clk/sunxi-ng/ccu_nkm.h |  2 ++
>>  2 files changed, 16 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/clk/sunxi-ng/ccu_nkm.c b/drivers/clk/sunxi-ng/ccu_nkm.c
>> index 9b840a47a94d..fd3c6a9d987c 100644
>> --- a/drivers/clk/sunxi-ng/ccu_nkm.c
>> +++ b/drivers/clk/sunxi-ng/ccu_nkm.c
>> @@ -75,7 +75,7 @@ static unsigned long ccu_nkm_recalc_rate(struct clk_hw *hw,
>>                                         unsigned long parent_rate)
>>  {
>>         struct ccu_nkm *nkm = hw_to_ccu_nkm(hw);
>> -       unsigned long n, m, k;
>> +       unsigned long rate, n, m, k;
>>         u32 reg;
>>
>>         reg = readl(nkm->common.base + nkm->common.reg);
>> @@ -89,7 +89,11 @@ static unsigned long ccu_nkm_recalc_rate(struct clk_hw *hw,
>>         m = reg >> nkm->m.shift;
>>         m &= (1 << nkm->m.width) - 1;
>>
>> -       return parent_rate * (n + 1) * (k + 1) / (m + 1);
>> +       rate = parent_rate * (n + 1) * (k + 1) / (m + 1);
>> +       if (nkm->common.features & CCU_FEATURE_FIXED_POSTDIV)
>> +               rate /= nkm->fixed_post_div;
>> +
>> +       return rate;
>>  }
>>
>>  static unsigned long ccu_nkm_round_rate(struct ccu_mux_internal *mux,
>> @@ -100,6 +104,9 @@ static unsigned long ccu_nkm_round_rate(struct ccu_mux_internal *mux,
>>         struct ccu_nkm *nkm = data;
>>         struct _ccu_nkm _nkm;
>>
>> +       if (nkm->common.features & CCU_FEATURE_FIXED_POSTDIV)
>> +               rate *= nkm->fixed_post_div;
>> +
>>         _nkm.min_n = nkm->n.min;
>>         _nkm.max_n = 1 << nkm->n.width;
>>         _nkm.min_k = nkm->k.min;
>> @@ -109,7 +116,11 @@ static unsigned long ccu_nkm_round_rate(struct ccu_mux_internal *mux,
>>
>>         ccu_nkm_find_best(parent_rate, rate, &_nkm);
>>
>> -       return parent_rate * _nkm.n * _nkm.k / _nkm.m;
>> +       rate = parent_rate * _nkm.n * _nkm.k / _nkm.m;
>> +       if (nkm->common.features & CCU_FEATURE_FIXED_POSTDIV)
>> +               rate = rate / nkm->fixed_post_div;
>> +
>> +       return rate;
>>  }
>>
>
> You also need to handle this in the set_rate callback. You might need
> to read back
> the parent index value to determine if the post divider applies, as
> this clock supports
> a mux. Or don't support mux + post-div, and leave a TODO note.

Was thinking pre-dividers... sorry. Please ignore the second parent
index part.

ChenYu

>
> ChenYu
>
>>  static int ccu_nkm_determine_rate(struct clk_hw *hw,
>> diff --git a/drivers/clk/sunxi-ng/ccu_nkm.h b/drivers/clk/sunxi-ng/ccu_nkm.h
>> index 34580894f4d1..0f1dbca25719 100644
>> --- a/drivers/clk/sunxi-ng/ccu_nkm.h
>> +++ b/drivers/clk/sunxi-ng/ccu_nkm.h
>> @@ -32,6 +32,8 @@ struct ccu_nkm {
>>         struct ccu_mult_internal        n;
>>         struct ccu_mult_internal        k;
>>         struct ccu_div_internal         m;
>> +
>> +       unsigned int            fixed_post_div;
>>         struct ccu_mux_internal mux;
>>
>>         struct ccu_common       common;
>> --
>> git-series 0.8.11

  reply	other threads:[~2016-11-13  3:49 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-08 17:23 [PATCH 0/10] ARM: sun5i: Convert sun5i SoCs to sunxi-ng Maxime Ripard
2016-11-08 17:23 ` [PATCH 1/10] clk: sunxi-ng: multiplier: Add fractionnal support Maxime Ripard
2016-11-10  6:18   ` Chen-Yu Tsai
2016-11-08 17:23 ` [PATCH 2/10] clk: sunxi-ng: nkm: Deal with fixed post dividers Maxime Ripard
2016-11-13  3:48   ` Chen-Yu Tsai
2016-11-13  3:49     ` Chen-Yu Tsai [this message]
2016-11-08 17:23 ` [PATCH 3/10] clk: sunxi-ng: Implement multiplier offsets Maxime Ripard
2016-11-13  4:18   ` Chen-Yu Tsai
2016-11-08 17:23 ` [PATCH 4/10] clk: sunxi-ng: Add clocks and resets indices for sun5i Maxime Ripard
2016-11-13  4:29   ` Chen-Yu Tsai
2016-11-08 17:23 ` [PATCH 5/10] clk: sunxi-ng: Implement multiplier maximum Maxime Ripard
2016-11-13  4:30   ` Chen-Yu Tsai
2016-11-08 17:23 ` [PATCH 6/10] clk: sunxi-ng: Add A10s CCU driver Maxime Ripard
2016-11-13  9:34   ` Chen-Yu Tsai
2016-11-21 21:45     ` Maxime Ripard
2016-11-08 17:23 ` [PATCH 7/10] clk: sunxi-ng: Add A13 " Maxime Ripard
2016-11-13  9:55   ` Chen-Yu Tsai
2016-11-08 17:23 ` [PATCH 8/10] clk: sunxi-ng: Add GR8 driver Maxime Ripard
2016-11-08 17:23 ` [PATCH 9/10] ARM: sun5i: Convert to CCU Maxime Ripard
2016-11-13 15:01   ` Chen-Yu Tsai
2016-11-21 22:04     ` Maxime Ripard
2016-11-08 17:23 ` [PATCH 10/10] ARM: gr8: " Maxime Ripard
2016-11-12 23:51   ` kbuild test robot

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=CAGb2v65tX5C89bYYkcrd0kHp1eCAwMihspbdtJwVi8kWgCPL4Q@mail.gmail.com \
    --to=wens@csie.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maxime.ripard@free-electrons.com \
    --cc=mturquette@baylibre.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).