[U-Boot] Timer implementations
Wolfgang Denk
wd at denx.de
Tue Oct 26 18:26:58 CEST 2010
Dear Nishanth Menon,
In message <4CC6F23A.2040608 at ti.com> you wrote:
>
> > No. This code is always wrong. Please fix it as described.
> Apologies on being a dudhead, I suppose you mean the following:
>
> ulong start;
> start = get_timer(0);
> while (!(readl(&mmc_base->stat) & CC_MASK)) {
> if (get_timer(start) > usec2ticks(MAX_RETRY_US)) {
> printf("%s: timedout waiting for cc2!\n", __func__);
> return;
> }
> }
>
> would this be better?
No, not at all, as get_timer() returns milliseconds, not ticks.
You probably want something like:
ulong start = get_timer(0);
while (!(readl(&mmc_base->stat) & CC_MASK)) {
if (get_timer(0) - start >= MAX_RETRY_US/1000) {
printf(...);
return;
}
udelay(100);
}
or such.
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
He had quite a powerful intellect, but it was as powerful like a
locomotive, and ran on rails and was therefore almost impossible to
steer. - Terry Pratchett, _Lords and Ladies_
More information about the U-Boot
mailing list