All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfgang Grandegger <wg@grandegger.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] fsl_i2c: increase I2C timeout values and	make	them	configurable
Date: Tue, 15 Sep 2009 13:53:13 +0200	[thread overview]
Message-ID: <4AAF8029.4000504@grandegger.com> (raw)
In-Reply-To: <OFEE1F603E.EE8F8622-ONC1257631.00560D45-C1257631.00576059@transmode.se>

Joakim Tjernlund wrote:
>> Wolfgang Grandegger wrote:
>>
>>> I did not follow the thread yet, sorry. I implemented AN2819 for Linux
>>> (see http://lxr.linux.no/#linux+v2.6.31/drivers/i2c/busses/i2c-mpc.c)
>>> some time ago using Timur's table approach. But there is no difference
>>> between the table and the algorithm to calculate the value. The table is
>>> actually derived from the same algorithm.
>> The problem with the table is that it does not allow for flexibility in
>> choosing dfsr.  When I implemented the table code, I did not think that this
>> was a problem, but apparently it is.
> 
> Yes, it is a problem for us as our board is out of spec. The rise time is way off
> spec. By trial and error with the DFSR/FDR I managed to get a stable connection.
> What is less funny though is that I need to program FDR/DFSR differently
> in u-boot resp. kernel. to make it work.
> I suspect it is due to kernel being IRQ driven and has longer pause
> between chars, but it is a guess.
> 
> In any case, the revised AN2819 dictates a different algorithm but I feel
> it is a bit incomplete w.r.t Condition 2:
> 
>     ? Condition 2: B ? T ? tI2CRM + 3 ? C ? T.
> Given a suitable value of DFSR, chosen to satisfy Condition 1, this inequality must also be met to guarantee
> that the SCL frequency matches the SCL frequency calculated by the divider equation. It is important to
> note that tI2CRM is the measured rise time of the SCL signal, which is defined as the time for the signal to
> rise from 10% to 70% of VCC.
> 
>                                                       NOTE
>                    Note that the rise time must not exceed 300 nanoseconds and that the above
>                    two conditions must both be satisfied to ensure that the actual SCL
>                    frequency values align with the calculated values. By meeting these
>                    conditions, the measured SCL frequency will match the calculated
>                    frequency to within 5 kHz. Ignoring either of these conditions may result in
>                    larger discrepancies between these frequency values.
> 
> How important is Condition 2 and what to do with rise times > 300 ns? The MAX rise time
> for 100 KHz is 1000 ns so there is a gap here.
> 
> My testing suggests that this is not important. Bigger DFSR, in my case 0x6 or 0x10, is key
> to get a stable I2C bus.
> 
>         Jocke
> PS.
>     Wolfgang, I sent a test program to calculate the new DFSR/FDR values in the thread, you
>     might find it useful if you are going to try out the new AN2819

Where do I find this test program. I just dig out my program to
calculate the table entries for the Linux i2c-mpc.c. It actually
reproduced Timur's (old) U-Boot values. Unfortunately, finding *good*
dfsr/fdr settings is no trivial and takes time. Till recently, the
i2c-mpc driver of Linux did use *fixed* save values as shown here:

  http://lxr.linux.no/#linux+v2.6.29/drivers/i2c/busses/i2c-mpc.c

And also with newer kernels, the table is only used if one of the
following I2C DTS properties is defined:

- fsl,preserve-clocking;
- clock-frequency = <400000>;

See
http://lxr.linux.no/#linux+v2.6.31/Documentation/powerpc/dts-bindings/fsl/i2c.txt

Wolfgang.

  reply	other threads:[~2009-09-15 11:53 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-09  9:19 [U-Boot] fsl_i2c: increase I2C timeout values and make them configurable Joakim Tjernlund
2009-09-09 14:24 ` Timur Tabi
2009-09-09 14:33   ` Joakim Tjernlund
2009-09-10  8:15     ` Joakim Tjernlund
2009-09-10 13:07       ` Timur Tabi
2009-09-10 13:20         ` Joakim Tjernlund
2009-09-10 13:29           ` Timur Tabi
2009-09-10 13:58             ` Joakim Tjernlund
2009-09-10 15:22               ` Timur Tabi
2009-09-10 15:46                 ` Joakim Tjernlund
2009-09-10 15:57                   ` Timur Tabi
2009-09-10 14:57             ` Joakim Tjernlund
2009-09-10 15:26               ` Timur Tabi
2009-09-10 15:53                 ` Joakim Tjernlund
2009-09-10 16:13                   ` Timur Tabi
2009-09-10 16:30                     ` Joakim Tjernlund
2009-09-10 17:13                     ` Joakim Tjernlund
2009-09-11  8:44                       ` Joakim Tjernlund
     [not found]                         ` <4AAA6ACD.9040905@free <4AAE55FA.4070702@freescale.com>
2009-09-11 15:20                         ` Timur Tabi
2009-09-14 13:53                           ` Detlev Zundel
2009-09-14 14:18                             ` Wolfgang Grandegger
2009-09-14 14:40                               ` Timur Tabi
2009-09-14 15:54                                 ` Joakim Tjernlund
2009-09-15 11:53                                   ` Wolfgang Grandegger [this message]
2009-09-15 12:24                                     ` Joakim Tjernlund
2009-09-15 18:53                                       ` Joakim Tjernlund
2009-09-14 16:01                                 ` Wolfgang Grandegger
2009-09-14 16:18                                   ` Joakim Tjernlund

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=4AAF8029.4000504@grandegger.com \
    --to=wg@grandegger.com \
    --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.