From patchwork Tue Mar 1 10:12:38 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Priyanka Jain X-Patchwork-Id: 84923 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id C8371B710B for ; Tue, 1 Mar 2011 21:28:08 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0B0982810A; Tue, 1 Mar 2011 11:28:04 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XhZzLaVcwpe1; Tue, 1 Mar 2011 11:28:03 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1008E2811B; Tue, 1 Mar 2011 11:28:02 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2829B2811B for ; Tue, 1 Mar 2011 11:27:59 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 20Fo5uYPBICP for ; Tue, 1 Mar 2011 11:27:57 +0100 (CET) X-Greylist: delayed 904 seconds by postgrey-1.27 at theia; Tue, 01 Mar 2011 11:27:55 CET X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from DB3EHSOBE003.bigfish.com (db3ehsobe003.messaging.microsoft.com [213.199.154.141]) by theia.denx.de (Postfix) with ESMTPS id 0729B2810A for ; Tue, 1 Mar 2011 11:27:55 +0100 (CET) Received: from mail52-db3-R.bigfish.com (10.3.81.249) by DB3EHSOBE003.bigfish.com (10.3.84.23) with Microsoft SMTP Server id 14.1.225.8; Tue, 1 Mar 2011 10:12:50 +0000 Received: from mail52-db3 (localhost.localdomain [127.0.0.1]) by mail52-db3-R.bigfish.com (Postfix) with ESMTP id 451CD12101D1; Tue, 1 Mar 2011 10:12:50 +0000 (UTC) X-SpamScore: 0 X-BigFish: VS0(zzzz1202hzz8275bh8275dhz2dh2a8h668h61h) X-Spam-TCS-SCL: 0:0 X-Forefront-Antispam-Report: KIP:(null); UIP:(null); IPVD:NLI; H:de01egw02.freescale.net; RD:de01egw02.freescale.net; EFVD:NLI Received: from mail52-db3 (localhost.localdomain [127.0.0.1]) by mail52-db3 (MessageSwitch) id 1298974368791254_21438; Tue, 1 Mar 2011 10:12:48 +0000 (UTC) Received: from DB3EHSMHS004.bigfish.com (unknown [10.3.81.250]) by mail52-db3.bigfish.com (Postfix) with ESMTP id B474D18E804F; Tue, 1 Mar 2011 10:12:48 +0000 (UTC) Received: from de01egw02.freescale.net (192.88.165.103) by DB3EHSMHS004.bigfish.com (10.3.87.104) with Microsoft SMTP Server (TLS) id 14.1.225.8; Tue, 1 Mar 2011 10:12:46 +0000 Received: from az33smr01.freescale.net (az33smr01.freescale.net [10.64.34.199]) by de01egw02.freescale.net (8.14.3/8.14.3) with ESMTP id p21AChg7024695; Tue, 1 Mar 2011 03:12:44 -0700 (MST) Received: from lc1106.zin33.ap.freescale.net (lc1106.zin33.ap.freescale.net [10.232.3.106]) by az33smr01.freescale.net (8.13.1/8.13.0) with ESMTP id p21ACeOO004934; Tue, 1 Mar 2011 04:12:41 -0600 (CST) Received: by lc1106.zin33.ap.freescale.net (Postfix, from userid 65011109) id 74C4EC06B; Tue, 1 Mar 2011 15:42:39 +0530 (IST) From: Priyanka Jain To: Date: Tue, 1 Mar 2011 15:42:38 +0530 Message-ID: <1298974358-16571-1-git-send-email-Priyanka.Jain@freescale.com> X-Mailer: git-send-email 1.6.5.6 MIME-Version: 1.0 X-OriginatorOrg: freescale.net Cc: Priyanka Jain , Andy Fleming , Kumar Gala Subject: [U-Boot] [PATCH][v2] fsl_esdhc: Correcting esdhc timeout counter calculation X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de - Timeout counter value is set as DTOCV bits in SYSCTL register For counter value set as timeout, Timeout period = (2^(timeout + 13)) SD Clock cycles - As per 4.6.2.2 section of SD Card specification v2.00, host should cofigure timeout period value to minimum 0.25 sec. - Number of SD Clock cycles for 0.25sec should be minimum (SD Clock/sec * 0.25 sec) SD Clock cycles = (mmc->tran_speed * 1/4) SD Clock cycles - Calculating timeout based on (2^(timeout + 13)) >= mmc->tran_speed * 1/4 Taking log2 both the sides and rounding up to next power of 2 => timeout + 13 = log2(mmc->tran_speed/4) + 1 Signed-off-by: Priyanka Jain Signed-off-by: Andy Fleming Signed-off-by: Kumar Gala Acked-by: Mingkai Hu --- Changes for v2: Added proper description as suggested by Wolfgang Denk drivers/mmc/fsl_esdhc.c | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c index 9c69cc7..e8dd9b7 100644 --- a/drivers/mmc/fsl_esdhc.c +++ b/drivers/mmc/fsl_esdhc.c @@ -207,8 +207,19 @@ static int esdhc_setup_data(struct mmc *mmc, struct mmc_data *data) esdhc_write32(®s->blkattr, data->blocks << 16 | data->blocksize); /* Calculate the timeout period for data transactions */ - /* Timeout period = (2^(13+timeout))/mmc->trans_speed - * Timeout period should be minimum 250msec as per SD Card spec + /* + * 1)Timeout period = (2^(timeout+13)) SD Clock cycles + * 2)Timeout period should be minimum 0.250sec as per SD Card spec + * So, Number of SD Clock cycles for 0.25sec should be minimum + * (SD Clock/sec * 0.25 sec) SD Clock cycles + * = (mmc->tran_speed * 1/4) SD Clock cycles + * As 1) >= 2) + * => (2^(timeout+13)) >= mmc->tran_speed * 1/4 + * Taking log2 both the sides + * => timeout + 13 >= log2(mmc->tran_speed/4) + * Rounding up to next power of 2 + * => timeout + 13 = log2(mmc->tran_speed/4) + 1 + * => timeout + 13 = fls(mmc->tran_speed/4) */ timeout = fls(mmc->tran_speed/4); timeout -= 13;