[U-Boot] Odd value for I2C_TIMEOUT in fsl_i2c.c

Wolfgang Denk
2009-09-04T09:25:02Z

Dear Heiko Schocher,

In message <4AA0BEC5.3010505@denx.de> you wrote:
>
> > 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)?
>
> This seems like a Bug to me.
>
> > I think what we should be doing is this:
> >
> > #define I2C_TIMEOUT 1000
> >
> > Surely, one millisecond is not too long of a timeout?
>
> I think this should be Ok. Can you provide a patch?

There are actually two parts in Timur's mail:

1) First part is the question if the timeout, which is currently set
to 250 us, should be raised to 1,000 us.

I cannot answer this question. I don't even understand why the
i2c_wait4bus() function is needed at all.

2) The second part is if the timeout definition should be changed
from being based on CONFIG_SYS_HZ to a plain numeric constant.
Assuming I2C_TIMEOUT is intended to be a period of time (as the
name suggests), then "(CONFIG_SYS_HZ / 4)" is clearly wrong as
it's a frequency and not a time.

In this case, a comment should be added explainign what
I2C_TIMEOUT means.

Best regards,

Wolfgang Denk

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"If you are afraid of loneliness, don't marry." - Chekhov