public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] Odd value for I2C_TIMEOUT in fsl_i2c.c
@ 2009-09-03 15:22 Timur Tabi
  2009-09-04  7:16 ` Heiko Schocher
  2009-09-04  8:31 ` Wolfgang Denk
  0 siblings, 2 replies; 20+ messages in thread
From: Timur Tabi @ 2009-09-03 15:22 UTC (permalink / raw)
  To: u-boot

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

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2009-09-04 19:28 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-03 15:22 [U-Boot] Odd value for I2C_TIMEOUT in fsl_i2c.c Timur Tabi
2009-09-04  7:16 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox