From patchwork Mon Sep 9 12:58:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Przemyslaw Marczak X-Patchwork-Id: 273563 X-Patchwork-Delegate: panto@antoniou-consulting.com 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 BEEBA2C00A0 for ; Mon, 9 Sep 2013 22:59:30 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6D7CE4A066; Mon, 9 Sep 2013 14:59:29 +0200 (CEST) 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 93dlyGS1RxrC; Mon, 9 Sep 2013 14:59:29 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 505324A067; Mon, 9 Sep 2013 14:59:24 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E8F754A067 for ; Mon, 9 Sep 2013 14:59:18 +0200 (CEST) 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 4sHf-LpUbVOr for ; Mon, 9 Sep 2013 14:59:12 +0200 (CEST) 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 mailout3.w1.samsung.com (mailout3.w1.samsung.com [210.118.77.13]) by theia.denx.de (Postfix) with ESMTP id 1936E4A066 for ; Mon, 9 Sep 2013 14:59:05 +0200 (CEST) Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout3.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MSV00DVW016QK80@mailout3.w1.samsung.com> for u-boot@lists.denx.de; Mon, 09 Sep 2013 13:58:57 +0100 (BST) X-AuditID: cbfec7f5-b7ef66d00000795a-22-522dc61166c6 Received: from eusync4.samsung.com ( [203.254.199.214]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 3F.BE.31066.116CD225; Mon, 09 Sep 2013 13:58:57 +0100 (BST) Received: from AMDC1186.digital.local ([106.116.147.185]) by eusync4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MSV00JL5026M510@eusync4.samsung.com>; Mon, 09 Sep 2013 13:58:57 +0100 (BST) From: Przemyslaw Marczak To: u-boot@lists.denx.de Date: Mon, 09 Sep 2013 14:58:34 +0200 Message-id: <1378731514-12564-1-git-send-email-p.marczak@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <5229F375.9060805@samsung.com> References: <5229F375.9060805@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrDJMWRmVeSWpSXmKPExsVy+t/xa7qCx3SDDM6uU7O48auN1WLH5Rss FrtuT2axeLu3k92BxWPez4lMHmfv7GD06NuyijGAOYrLJiU1J7MstUjfLoEro/vbMaaCA4IV c5v7mBoYF/J1MXJwSAiYSFzsYexi5AQyxSQu3FvP1sXIxSEksJRR4tDsT4wQTh+TxPxl09hA qtgEDCT2XDrDDGKLCEhI/Oq/CtbNLFAtsfV/DxOILSxgJdHQu5EVxGYRUJW4dK+fBcTmFXCV eDjvJTPEYgWJOZNsQMKcAtoS++79ABsvJKAlMaF/IssERt4FjAyrGEVTS5MLipPSc430ihNz i0vz0vWS83M3MUJC5OsOxqXHrA4xCnAwKvHwSvzXCRJiTSwrrsw9xCjBwawkwit6WDdIiDcl sbIqtSg/vqg0J7X4ECMTB6dUA+P1rGky4UeLqr6FTdzS8/L59VVnDx9QWLRveV/zn86H1tuO S1yS36QvOvXs5L3Lr7sr9+ieTYwP2dhaUNv5+fTHDeU3f5RuOhxySoFVtMsp1+Pf7Utqn/cI TjuYKJN2YO/B/ibBtctse7+2Nkg5uB0Xkfdp/3/a+IH/LOmaaAUVUf9SyZXTZ4sosRRnJBpq MRcVJwIAEfje1u8BAAA= Cc: jh80.chung@samsung.com, Pantelis Antoniou , Przemyslaw Marczak Subject: [U-Boot] [PATCH] mmc:sdhci: Fix card ready status timeout. X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de According to JEDEC eMMC specification, after data transfer (multiple or single block) host must wait for card ready status. This is done by waiting for command and data lines to be at idle state after transfer. JEDEC does not specify maximum timeout. Before this change max timeout was 10 ms but in case of UMS - when system does multiple read/write operations on random card blocks - timeout causes I/O errors. The timeout has been increased to 200ms after data transfer. For other transfers it stays unchanged. Default values are now defined with "if defined" directive so it can be redefined at board config if needed. Tested on Goni and Trats. Signed-off-by: Przemyslaw Marczak Cc: Pantelis Antoniou --- drivers/mmc/sdhci.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c index 4261991..35bdb37 100644 --- a/drivers/mmc/sdhci.c +++ b/drivers/mmc/sdhci.c @@ -110,6 +110,20 @@ static int sdhci_transfer_data(struct sdhci_host *host, struct mmc_data *data, return 0; } +#if !defined(SDHCI_DATA_CMD_TIMEOUT) +#define SDHCI_DATA_CMD_TIMEOUT 10 +#endif +#if !defined(SDHCI_STATUS_CMD_TIMEOUT) +#define SDHCI_STATUS_CMD_TIMEOUT 200 +#endif +/* + * For some commands this function is called with NULL mmc_data + * pointer. One of those is CMD13 - send card status. + * After read/write data transfer or block erase commands - host sends + * CMD13 and is waiting for card ready status with some timeout. + * According to some internal cards operations after those commands + * this time must be increased. + */ int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data) { @@ -121,8 +135,10 @@ int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd, unsigned int timeout, start_addr = 0; unsigned int retry = 10000; - /* Wait max 10 ms */ - timeout = 10; + if (data) + timeout = SDHCI_DATA_CMD_TIMEOUT; /* ms */ + else + timeout = SDHCI_STATUS_CMD_TIMEOUT; sdhci_writel(host, SDHCI_INT_ALL_MASK, SDHCI_INT_STATUS); mask = SDHCI_CMD_INHIBIT | SDHCI_DATA_INHIBIT;