public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Timur Tabi <timur@freescale.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] i2c_init - is this a bug?
Date: Wed, 20 Dec 2006 10:36:50 -0600	[thread overview]
Message-ID: <458966A2.7030506@freescale.com> (raw)
In-Reply-To: <1ea6be8e0612200046m2a3bd7cfnef9c6047053630a0@mail.gmail.com>

Michael wrote:
> Hi, guys.
> Here is something suspicious about i2c_init(int speed, int slaveadd),
> in i2c.c and fsl_i2c.c -
> the speed parameter passed to it is never used, instead the value is hard-coded.
> 
> /* set clock */
> writeb(0x3f, &I2C->fdr);
> 
> Sets the speed.
> Shouldn't it be writeb(speed, &I2C->fdr); , with speed being the divider value?

Yes, the code is currently wrong, but no, 'speed' should not be the divider value.

I have code which calculates the correct value for the FDR based on the real 
speed, the bus clock rate, and a CPU-specific table lookup.  I just haven't 
gotten around to cleaning it up and submitting it yet.  It's on my to-do list 
for next month.

3F is a conservative value for the bus speed that (so far) works for all 
Freescale boards.  The only drawback is that I2C operations are not as fast as 
they could be.  However, the difference is practically imperceptible, at least 
in U-Boot.  If you were doing heavy I2C I/O in Linux, then you might notice 
something.

-- 
Timur Tabi
Linux Kernel Developer @ Freescale

      reply	other threads:[~2006-12-20 16:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-20  8:46 [U-Boot-Users] i2c_init - is this a bug? Michael
2006-12-20 16:36 ` Timur Tabi [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=458966A2.7030506@freescale.com \
    --to=timur@freescale.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox