From: Wolfgang Denk Date: Thu, 24 Feb 2011 10:50:10 +0100 Subject: [U-Boot] [PATCH] fsl_esdhc: Correcting esdhc timeout counter calculation In-Reply-To: <1298537614-20797-1-git-send-email-galak@kernel.crashing.org> References: <1298537614-20797-1-git-send-email-galak@kernel.crashing.org> Message-ID: <20110224095010.1BE16146940@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Kumar Gala, In message <1298537614-20797-1-git-send-email-galak@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. Also, should there not be some checking for valid input data ranges? Nitpick: incorrect multi-line comment style. 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 "There's always been Tower of Babel sort of bickering inside Unix, but this is the most extreme form ever. This means at least several years of confusion." - Bill Gates, founder and chairman of Microsoft, about the Open Systems Foundation