All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/3] fsl_i2c: Impl. AN2819, rev 5 to calculate FDR/DFSR
Date: Thu, 17 Sep 2009 10:04:00 +0200	[thread overview]
Message-ID: <4AB1ED70.6050808@denx.de> (raw)
In-Reply-To: <OF0E2B8150.47DDCD99-ONC1257634.0023E2E7-C1257634.002481BA@transmode.se>

Hello Joakim,

Joakim Tjernlund wrote:
> Heiko Schocher <hs@denx.de> wrote on 17/09/2009 08:00:34:
> 
>> Hello Joakim,
> 
> Hi Heiko
> 
>> Joakim Tjernlund wrote:
>>> The latest AN2819 has changed the way FDR/DFSR should be calculated.
>>> Update the driver according to spec. However, Condition 2
>>> is not accounted for as it is not clear how to do so.
>> Thanks for your work, just some minor Codingstyle comments:
>>
>>> Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
>>> ---
>>>  drivers/i2c/fsl_i2c.c |   88 +++++++++++++++++++++++++++++-------------------
>>>  1 files changed, 53 insertions(+), 35 deletions(-)
>>>
>>> diff --git a/drivers/i2c/fsl_i2c.c b/drivers/i2c/fsl_i2c.c
>>> index 0c5f6be..0491a69 100644
>>> --- a/drivers/i2c/fsl_i2c.c
>>> +++ b/drivers/i2c/fsl_i2c.c
>>> @@ -100,29 +100,9 @@ static const struct fsl_i2c *i2c_dev[2] = {
> 
>>>  #ifdef __PPC__
>>> -         u8 dfsr;
>>> +   u8 dfsr, fdr = 0x31; /* Default if no FDR found */
>>> +   unsigned short A, B, Ga, Gb;
>> Please do not use mixed-case variables, thanks.
> 
> A and B are from the AN2819 spec and I used the same names to ease
> identify with the spec. I rather keep them.

I am fine with that, just please do not mix upper and
lower case in one variable name. So please use "ga" and
"gb" ...

>>> +   unsigned long c_div, est_div;
>>> +
>>>  #ifdef CONFIG_FSL_I2C_CUSTOM_DFSR
>>> -         dfsr = CONFIG_FSL_I2C_CUSTOM_DFSR;
>>> +   dfsr = CONFIG_FSL_I2C_CUSTOM_DFSR;
>>>  #else
>>> -         dfsr = fsl_i2c_speed_map[i].dfsr;
>>> -#endif
>>> -         writeb(dfsr, &dev->dfsrr);   /* set default filter */
>>> +   /* Condition 1: dfsr <= 50/T */
>>> +   dfsr = (5*(i2c_clk/1000))/(100000);
>> Please use one space around (on each side of) most binary
>> and ternary operators.
> 
> Like so?
> dfsr = (5 * (i2c_clk / 1000)) / 100000);

Yep.

>>>  #endif
>>>  #ifdef CONFIG_FSL_I2C_CUSTOM_FDR
>>> -         fdr = CONFIG_FSL_I2C_CUSTOM_FDR;
>>> -         speed = i2c_clk / divider; /* Fake something */
>>> +   fdr = CONFIG_FSL_I2C_CUSTOM_FDR;
>>> +   speed = i2c_clk / divider; /* Fake something */
>>>  #else
>>> +   debug("Requested speed:%d, i2c_clk:%d\n", speed, i2c_clk);
>>> +   if (!dfsr)
>>> +      dfsr = 1;
>>> +
>>> +   est_div = ~0;
>>> +   for(Ga=0x4, A=10; A<=30; Ga++, A+=2) {
>> spaces her too.
> Like so?
> for(Ga = 0x4, A = 10; A <= 30; Ga++, A += 2) {

for (Ga = 0x4, A = 10; A <= 30; Ga++, A += 2) {

>>> +      for (Gb=0; Gb<8; Gb++) {
>> and here too. Please check the whole patch.
>>
>>> +         B = 16 << Gb;
>>> +         c_div = B * (A + ((3*dfsr)/B)*2);
>>> +         if (c_div > divider && c_div < est_div) {
>> Can we make
>>
>> if ((c_div > divider) && (c_div < est_div)) {
> 
> Sure.

Thanks!

bye
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

      parent reply	other threads:[~2009-09-17  8:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-16 11:31 [U-Boot] [PATCH 1/3] fsl_i2c: Wait for STOP condition to propagate Joakim Tjernlund
2009-09-16 11:31 ` [U-Boot] [PATCH 2/3] fsl_i2c: Add CONFIG_FSL_I2C_CUSTOM_{DFSR/DFR} Joakim Tjernlund
2009-09-16 11:31   ` [U-Boot] [PATCH 3/3] fsl_i2c: Impl. AN2819, rev 5 to calculate FDR/DFSR Joakim Tjernlund
2009-09-17  6:00     ` Heiko Schocher
2009-09-17  6:38       ` Joakim Tjernlund
2009-09-17  7:56         ` Wolfgang Denk
2009-09-17  8:04         ` Heiko Schocher [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=4AB1ED70.6050808@denx.de \
    --to=hs@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.