public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: marek.belisko@streamunlimited.com (Marek Belisko)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/2] clk: si5351: Powerdown output when clock rate is 0.
Date: Tue, 07 May 2013 12:40:56 +0200	[thread overview]
Message-ID: <5188DA38.9030405@streamunlimited.com> (raw)
In-Reply-To: <5188D26B.6020000@gmail.com>

On 05/07/2013 12:07 PM, Sebastian Hesselbarth wrote:
> On 05/07/2013 10:14 AM, Marek Belisko wrote:
>> When rate is 0 powerdown clock output.
>>
>> Signed-off-by: Marek Belisko<marek.belisko@streamunlimited.com>
>> ---
>>   drivers/clk/clk-si5351.c |   32 +++++++++++++++++++-------------
>>   1 file changed, 19 insertions(+), 13 deletions(-)
>>
>> diff --git a/drivers/clk/clk-si5351.c b/drivers/clk/clk-si5351.c
>> index a8fc0f4..e254e76 100644
>> --- a/drivers/clk/clk-si5351.c
>> +++ b/drivers/clk/clk-si5351.c
>> @@ -1042,20 +1042,22 @@ static int si5351_clkout_set_rate(struct
>> clk_hw *hw, unsigned long rate,
>>       struct si5351_hw_data *hwdata =
>>           container_of(hw, struct si5351_hw_data, hw);
>>       unsigned long new_rate, new_err, err;
>> -    unsigned char rdiv;
>> +    unsigned char rdiv, pdn = 0;
>>
>>       /* round to closed rdiv */
>>       rdiv = SI5351_OUTPUT_CLK_DIV_1;
>> -    new_rate = parent_rate;
>> -    err = abs(new_rate - rate);
>> -    do {
>> -        new_rate>>= 1;
>> -        new_err = abs(new_rate - rate);
>> -        if (new_err>  err || rdiv == SI5351_OUTPUT_CLK_DIV_128)
>> -            break;
>> -        rdiv++;
>> -        err = new_err;
>> -    } while (1);
>> +    if (rate) {
>> +        new_rate = parent_rate;
>
> Marek,
>
> initalizing pdn to SI5351_CLK_POWERDOWN and skip (with goto) to
> powerup/down call on zero rate will save us a level of indention here.
OK will fix and resubmit in v2. Thanks.
>
>> +        err = abs(new_rate - rate);
>> +        do {
>> +            new_rate>>= 1;
>> +            new_err = abs(new_rate - rate);
>> +            if (new_err>  err || rdiv == SI5351_OUTPUT_CLK_DIV_128)
>> +                break;
>> +            rdiv++;
>> +            err = new_err;
>> +        } while (1);
>
> of course, pdn should be set to 0 here.
>
>> +    }
>>
>>       /* write output divider */
>>       switch (hwdata->num) {
>> @@ -1075,9 +1077,13 @@ static int si5351_clkout_set_rate(struct clk_hw
>> *hw, unsigned long rate,
>>                   rdiv<<  SI5351_OUTPUT_CLK_DIV_SHIFT);
>>       }
>>
>> -    /* powerup clkout */
>> +    /* when rate is 0 powerdown output */
>> +    if (rate == 0)
>> +        pdn = SI5351_CLK_POWERDOWN;
>> +
>> +    /* powerup/down clkout */
>>       si5351_set_bits(hwdata->drvdata, SI5351_CLK0_CTRL + hwdata->num,
>> -            SI5351_CLK_POWERDOWN, 0);
>> +            SI5351_CLK_POWERDOWN, pdn);
>>
>>       dev_dbg(&hwdata->drvdata->client->dev,
>>           "%s - %s: rdiv = %u, parent_rate = %lu, rate = %lu\n",
>
>

marek
-- 
Marek Belisko

Software Developer
StreamUnlimited Engineering GmbH
Gutheil Schodergasse 8-12
A-1100 Vienna, Austria

Office: +421 267200087

e-mail: marek.belisko at streamunlimited.com
http://www.streamunlimited.com

Meet us at:

High End - Munich, 09 - 12 May, Hall 4/F05
IFA - Berlin, 6-11 September
CEDIA - Denver, 25-28 September

  reply	other threads:[~2013-05-07 10:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-07  8:14 [PATCH 1/2] clk: si5351: Fix msynth_recalc_rate return value when fOUT is 0 Marek Belisko
2013-05-07  8:14 ` [PATCH 2/2] clk: si5351: Powerdown output when clock rate " Marek Belisko
2013-05-07 10:07   ` Sebastian Hesselbarth
2013-05-07 10:40     ` Marek Belisko [this message]
2013-05-07 10:03 ` [PATCH 1/2] clk: si5351: Fix msynth_recalc_rate return value when fOUT " Sebastian Hesselbarth
2013-05-07 10:17   ` Marek Belisko

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=5188DA38.9030405@streamunlimited.com \
    --to=marek.belisko@streamunlimited.com \
    --cc=linux-arm-kernel@lists.infradead.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