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

Andy Fleming afleming at gmail.com
Fri Feb 25 01:14:12 CET 2011


On Thu, Feb 24, 2011 at 3:50 AM, Wolfgang Denk <wd at denx.de> wrote:
> Dear Kumar Gala,
>
> In message <1298537614-20797-1-git-send-email-galak at kernel.crashing.org> you wrote:
>>
>> - Timeout counter value is set as DTOCV bits in SYSCTL register
>>   For counter value set as x,
>>   Timeout period = (2^(13+x))/SD_CLOCK
>>
>> - As per 4.6.2.2 section of SD Card specification v2.00, host should
>>   cofigure timeout period value to minimum 250 msec.
>>
>> - SD_CLOCK = mmc->trans_speed
>>
>> - Calculating x based on
>>   250 msec = (2^(13+x))/mmc->trans_speed
>
> OK, here the theory is given...
>
>> +     /* Timeout period = (2^(13+timeout))/mmc->trans_speed
>> +      * Timeout period should be minimum 250msec as per SD Card spec
>> +      */
>> +     timeout = fls(mmc->tran_speed/4);
>>       timeout -= 13;
>
> But how does this translate intothis formula?  I think there must be
> missing something.

Yeah, that took me a while, too.  Maybe we should update it to make clear:

1) The formula ends up being (2^(13 + timeout))/mmc->trans_speed = (1/4) seconds
--> 2^(13 + timeout) = mmc->trans_speed/4
--> 13 + timeout = log2(mmc->trans_speed/4)
...etc

2) We are effectively rounding up to the next highest power of 2 to
make sure the timeout is *at least* 250ms

Andy


More information about the U-Boot mailing list