mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tero Kristo <t-kristo@ti.com>
To: Keerthy <j-keerthy@ti.com>
Cc: <mturquette@baylibre.com>, <sboyd@codeaurora.org>,
	<linux-omap@vger.kernel.org>, <linux-clk@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] clk: ti: divider: Add the table parsing to get the best divider value
Date: Wed, 25 Jan 2017 15:05:08 +0200	[thread overview]
Message-ID: <6e5a0ca7-c994-8e38-8e35-dd2ac10180ca@ti.com> (raw)
In-Reply-To: <98780c76-0ba8-85ec-ca01-392f36fa91ad@ti.com>

On 25/01/17 12:37, Keerthy wrote:
>
>
> On Friday 02 December 2016 02:35 PM, Keerthy wrote:
>> Currently the divider selection logic blindly divides the parent_rate
>> by the clk rate and gives the divider value for the divider clocks
>> which do not have the CLK_SET_RATE_PARENT flag set. Add the clk divider
>> table parsing to get the closest divider available in the table
>> provided via Device tree.
>>
>> The code is pretty much taken from: drivers/clk/clk-divider.c.
>> and used here to fix up the best divider selection logic.
>
> A gentle ping on this patch. This applies cleanly on the next branch as
> on today. Let me know if this needs to be rebased.
>
> - Keerthy
>
>>
>> Signed-off-by: Keerthy <j-keerthy@ti.com>
>> Reported-by: Richard Woodruff <r-woodruff2@ti.com>

Acked-by: Tero Kristo <t-kristo@ti.com>

Stephen / Michael, can you pick this up?

-Tero

>> ---
>>  drivers/clk/ti/divider.c | 31 ++++++++++++++++++++++++++++++-
>>  1 file changed, 30 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/clk/ti/divider.c b/drivers/clk/ti/divider.c
>> index b4e5de1..6bb8778 100644
>> --- a/drivers/clk/ti/divider.c
>> +++ b/drivers/clk/ti/divider.c
>> @@ -140,6 +140,35 @@ static bool _is_valid_div(struct clk_divider
>> *divider, unsigned int div)
>>      return true;
>>  }
>>
>> +static int _div_round_up(const struct clk_div_table *table,
>> +             unsigned long parent_rate, unsigned long rate)
>> +{
>> +    const struct clk_div_table *clkt;
>> +    int up = INT_MAX;
>> +    int div = DIV_ROUND_UP_ULL((u64)parent_rate, rate);
>> +
>> +    for (clkt = table; clkt->div; clkt++) {
>> +        if (clkt->div == div)
>> +            return clkt->div;
>> +        else if (clkt->div < div)
>> +            continue;
>> +
>> +        if ((clkt->div - div) < (up - div))
>> +            up = clkt->div;
>> +    }
>> +
>> +    return up;
>> +}
>> +
>> +static int _div_round(const struct clk_div_table *table,
>> +              unsigned long parent_rate, unsigned long rate)
>> +{
>> +    if (!table)
>> +        return DIV_ROUND_UP(parent_rate, rate);
>> +
>> +    return _div_round_up(table, parent_rate, rate);
>> +}
>> +
>>  static int ti_clk_divider_bestdiv(struct clk_hw *hw, unsigned long rate,
>>                    unsigned long *best_parent_rate)
>>  {
>> @@ -155,7 +184,7 @@ static int ti_clk_divider_bestdiv(struct clk_hw
>> *hw, unsigned long rate,
>>
>>      if (!(clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT)) {
>>          parent_rate = *best_parent_rate;
>> -        bestdiv = DIV_ROUND_UP(parent_rate, rate);
>> +        bestdiv = _div_round(divider->table, parent_rate, rate);
>>          bestdiv = bestdiv == 0 ? 1 : bestdiv;
>>          bestdiv = bestdiv > maxdiv ? maxdiv : bestdiv;
>>          return bestdiv;
>>

  reply	other threads:[~2017-01-25 13:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-02  9:05 Keerthy
2017-01-25 10:37 ` Keerthy
2017-01-25 13:05   ` Tero Kristo [this message]
2017-01-27  0:03 ` Stephen Boyd

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=6e5a0ca7-c994-8e38-8e35-dd2ac10180ca@ti.com \
    --to=t-kristo@ti.com \
    --cc=j-keerthy@ti.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --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

all inboxes | Powered by JetHome®