From: matt@grid-net.com (Matt Burtch)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/1] ARM iMX28: incorrect frac/div calculation
Date: Fri, 23 Mar 2012 11:38:58 -0700 [thread overview]
Message-ID: <4F6CC342.4010609@grid-net.com> (raw)
In-Reply-To: <20332.8856.841320.610752@ipc1.ka-ro>
On 03/23/2012 12:13 AM, Lothar Wa?mann wrote:
> Hi,
>
> Matt Burtch writes:
>> The frac and div values in _CLK_SET_RATE are calculated incorrectly
>> for some clock rates ie. CPU clk of 454.73MHz, 392.72MHz, 261.81Mhz,
>> etc.
>>
>> Now the frac and div values which result in the closest actual clock
>> rate to that requested is selected. Also there are no limitations
>> on what frac values can be used, as long as they fall in the valid
>> (18< frac< 35) range.
>>
>> Tested on custom iMX28 board.
>>
>> Signed-off-by: Matt Burtch<matt@grid-net.com>
>> ---
>> arch/arm/mach-mxs/clock-mx28.c | 8 ++------
>> 1 files changed, 2 insertions(+), 6 deletions(-)
>>
>> diff --git a/arch/arm/mach-mxs/clock-mx28.c b/arch/arm/mach-mxs/clock-mx28.c
>> index 5d68e41..a058b99 100644
>> --- a/arch/arm/mach-mxs/clock-mx28.c
>> +++ b/arch/arm/mach-mxs/clock-mx28.c
>> @@ -354,19 +354,15 @@ static int name##_set_rate(struct clk *clk, unsigned long rate) \
>> } \
>> for (d = 1; d<= div_max; d++) { \
>> f = parent_rate * 18 / d / rate; \
>> - if ((parent_rate * 18 / d) % rate) \
>> - f++; \
>> if (f< 18 || f> 35) \
>> continue; \
>> \
>> calc_rate = parent_rate * 18 / f / d; \
>> - if (calc_rate> rate) \
>> - continue; \
>> \
>> - if (rate - calc_rate< diff) { \
>> + if (abs(rate - calc_rate)< diff) { \
> Shouldn't this actually be '<=' (also in the original code)?
Hi Lothar,
It shouldn't make a difference. If it was '<=' it would result in a
different frac and higher div value but the difference between the
requested rate and actual would be the same.
Thanks,
Matt Burtch
> Lothar Wa?mann
prev parent reply other threads:[~2012-03-23 18:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-22 23:05 [PATCH 1/1] ARM iMX28: incorrect frac/div calculation Matt Burtch
2012-03-23 2:52 ` Shawn Guo
2012-03-23 18:38 ` Matt Burtch
2012-03-23 7:13 ` Lothar Waßmann
2012-03-23 18:38 ` Matt Burtch [this message]
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=4F6CC342.4010609@grid-net.com \
--to=matt@grid-net.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;
as well as URLs for NNTP newsgroup(s).