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] Odd value for I2C_TIMEOUT in fsl_i2c.c
Date: Thu, 03 Sep 2009 10:22:06 -0500	[thread overview]
Message-ID: <4A9FDF1E.4090908@freescale.com> (raw)

Currently we define I2C_TIMEOUT like this:

#define I2C_TIMEOUT	(CONFIG_SYS_HZ / 4)

I'm seeing some I2C instability on a new board I'm working on, especially with SPD.  If I change the above to 

#define I2C_TIMEOUT	(CONFIG_SYS_HZ / 2)

The problems go away (or at least, so far appear to).  Can someone tell me why we choose (CONFIG_SYS_HZ / 4) to begin with?  The way we use I2C_TIMEOUT is confusing:

	while (readb(&i2c_dev[i2c_bus_num]->sr) & I2C_SR_MBB) {
		if ((get_ticks() - timeval) > usec2ticks(I2C_TIMEOUT))
			return -1;
	}

CONFIG_HZ is 1000, so I2C_TIMEOUT is equal to 250.  However, the way it's used, 250 isn't the number of ticks per second, it's used as number of microseconds.  If CONFIG_HZ is changed to 100, does that mean that we want to call usec2ticks(25)?

I think what we should be doing is this:

#define I2C_TIMEOUT	1000

Surely, one millisecond is not too long of a timeout?

-- 
Timur Tabi
Linux kernel developer at Freescale

             reply	other threads:[~2009-09-03 15:22 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-03 15:22 Timur Tabi [this message]
2009-09-04  7:16 ` [U-Boot] Odd value for I2C_TIMEOUT in fsl_i2c.c Heiko Schocher
2009-09-04  9:25   ` Wolfgang Denk
2009-09-04 14:09     ` Timur Tabi
2009-09-04 15:01       ` Wolfgang Denk
2009-09-04 15:12         ` Timur Tabi
2009-09-04 15:28           ` Peter Tyser
2009-09-04 15:30             ` Timur Tabi
2009-09-04 16:04               ` Peter Tyser
2009-09-04 18:30               ` Wolfgang Denk
2009-09-04 18:39                 ` Timur Tabi
2009-09-04 19:28                   ` Wolfgang Denk
2009-09-04 18:28             ` Wolfgang Denk
2009-09-04 15:29           ` Wolfgang Denk
2009-09-04 18:34             ` Scott Wood
2009-09-04 19:23               ` Wolfgang Denk
2009-09-04 19:28                 ` Scott Wood
2009-09-04  8:31 ` Wolfgang Denk
2009-09-04 18:36   ` Scott Wood
2009-09-04 19:27     ` Wolfgang Denk

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=4A9FDF1E.4090908@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