public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Stefano Babic <sbabic@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH V7 1/3] MX5: clock: Add clock config interface
Date: Tue, 17 May 2011 13:15:25 +0200	[thread overview]
Message-ID: <4DD258CD.7070102@denx.de> (raw)
In-Reply-To: <BANLkTimZVkZ1cYL9sNvqGmnS5hQpqaGrzA@mail.gmail.com>

On 05/17/2011 08:25 AM, Jason Liu wrote:
> Hi, Stefano,

Hi Jason,

> I use array here just for the case we will have another element in the array
> (currently we only have one) in the future. Currently, we use 24MHz as ref.

Understood, thanks.

>>>  /*
>>> + * Clock config code start here
>>> + */
>>> +
>>> +/* precondition: m>0 and n>0.  Let g=gcd(m,n). */
>>> +static int gcd(int m, int n)
>>> +{
>>> +     int t;
>>> +     while (m > 0) {
>>> +             if (n > m) {
>>> +                     t = m;
>>> +                     m = n;
>>> +                     n = t;
>>> +             } /* swap */
>>> +             m -= n;
>>> +     }
>>> +     return n;
>>> +}
>>
>> This function has nothing to do with MX5 code. This is a general
>> function, and should be add to lib/. I think you have to remove it from
>> here and put it in a separate patch.
> 
> I don't think it should be put to lib since only the mx5 clock code use it here.

This function computes the GCD of two numbers, and has nothing to do
with MX5 and clock. It is a general function, that others can use.

> OK, I will check linux implementation. Do you know does u-boot also has such
> kind of function already, I did not find it?

No, this function is not yet implemented in u-boot. However, it could be
that there is in some drivers an analog function doing the same. For
this reason and to avoid multiple instances of "quite" same code doing
"quite" the same thing, I suggest to move this function from here from
strictly related IMX code to a general lib. Let's see what Wolfgang
whinks about it.

>>> + *      t_clk = 2*ref_freq*(mfi + mfn/(mfd+1))/(pd+1)
>>
>> Where does this formula come from ?
> 
> The comments is not correct, I will fix it, it should be 4*ref_freq
> not 2 * ref_req.
> The reference manual: 12.2.2.3 DPLL Operation Register, elvis user guide,
> Registers DP_OP, DP_MFN, and DP_MFD calculate the output frequency by
> the formula:
> 
> The chapter number will not the same as you, but you still can find it
> in the reference manual.

Ok. I think it is better to add a comment with the chapter title, as to
set a reference number, because this is changing.

I will check in the manual, thanks for hint.

>> Use defines to set registers. Or read-modify-write, as you changed only
>> PERIPH_APM_SEL from the reset value. However, you reset to 0
>> DDR_CLK_SEL.  I see you switch values back at the end of the function,
>> but my doubt is if it is correct to set in this transition DDR_CLK_SEL
>> always to zero. Can it work with all boards or there are configurations
>> where it does not work ?
> 
> I think it should work since DDR_CLK_SEL:00 derive clock from axi a
> is the default value when boot up.

Then I think it is enough you add as comment your explanation, and
mention that the code does not support if the clock is not derived from
axi-a. If someone adds a custom board with this set-up (and I do not
know if it will be a use case), he is at least warned that must adapt
this function.


>>> + *
>>> + * @param ref   pll input reference clock (24MHz)
>>
>> Reference clock is defined as CONFIG_SYS_MX5_HCLK. Is it really possible
>> to pass a parameter to this function different as CONFIG_SYS_MX5_HCLK ?
>> What happens if CONFIG_SYS_MX5_HCLK and the ref parameter in this
>> function have two different values ? It seems to me this is not a use
>> case, and then we must avoid it. If I am right, you should drop the ref
>> parameter and use CONFIG_SYS_MX5_HCLK.
> 
> As the reference manual tell, the pll can have 4 different clock
> source. The most
> common use case is using 24Mhz OSC as the input.

Understood, thanks.

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================

      reply	other threads:[~2011-05-17 11:15 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-11  8:03 [U-Boot] [PATCH V7 1/3] MX5: clock: Add clock config interface Jason Liu
2011-05-11  8:03 ` [U-Boot] [PATCH V7 2/3] PMIC: Add dialog pmic support Jason Liu
2011-05-12  9:19   ` Stefano Babic
2011-05-13  3:08     ` Jason Liu
2011-05-13  6:38       ` Stefano Babic
2011-05-13  8:41         ` Jason Liu
2011-05-13  8:47           ` Stefano Babic
2011-05-13  9:04             ` Jason Hui
2011-05-11  8:03 ` [U-Boot] [PATCH V7 3/3] MX53: support for freescale MX53LOCO board Jason Liu
2011-05-11 12:03   ` Fabio Estevam
2011-05-12  5:31     ` Jason Hui
2011-05-11 12:37   ` Stefano Babic
2011-05-12  5:32     ` Jason Hui
2011-05-12  6:13     ` Jason Liu
2011-05-12  9:03       ` Stefano Babic
2011-05-13  3:13         ` Jason Hui
2011-05-20 18:35   ` Albert ARIBAUD
2011-05-16  9:26 ` [U-Boot] [PATCH V7 1/3] MX5: clock: Add clock config interface Stefano Babic
2011-05-17  6:25   ` Jason Liu
2011-05-17 11:15     ` Stefano Babic [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=4DD258CD.7070102@denx.de \
    --to=sbabic@denx.de \
    --cc=u-boot@lists.denx.de \
    /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