[U-Boot] [PATCH] fsl_esdhc: Correcting esdhc timeout counter calculation

Wolfgang Denk wd at denx.de
Fri Feb 25 11:19:44 CET 2011


Dear Jain Priyanka-B32167,

In message <470DB7CE2CD0944E9436E7ADEFC02FE3138B4C at 039-SN1MPN1-003.039d.mgd.msft.net> you wrote:
> 
> > > 1) The formula ends up being (2^(13 + timeout))/mmc->trans_speed =3D
> > > (1/4) seconds
> > > --> 2^(13 + timeout) = mmc->trans_speed/4
> > > --> 13 + timeout = log2(mmc->trans_speed/4)
> > > ...etc
> > 
> > Does this not depend on the units used for speed, and thus in the end on
> > CONFIC_SYS_HZ ?
> > 
> We are using absolute figures. So this code is independent of units of speed.

Funny you should say that.

> For standard speed cards, mmc->tran_speed is 25000000.

"Speed" is always some unit per time.  Your 'absolute" number 25000000
here makes no sense if you cannot tell what it means.  Is it bits per
millisecond? Bytes per week? Nibbles per year?

>         /* divide frequency by 10, since the mults are 10x bigger */
>         freq = fbase[(cmd.response[0] & 0x7)];
>         mult = multipliers[((cmd.response[0] >> 3) & 0xf)];
>         mmc->tran_speed = freq * mult;

You don't have any "absolute figures" here. A frequency is defined to
measure events per time, so it is important to give the unit used.
Is frequency in Hz, or in kHz, or in MHz, or what?


It is impossible for the reader to verify the correctness of the code
if you don't provide such information, so please document your code in
a way that makes it possible to check it.

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
"I haven't lost my mind - it's backed up on tape somewhere."


More information about the U-Boot mailing list