From patchwork Thu Aug 11 11:00:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 658460 X-Patchwork-Delegate: jh80.chung@samsung.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 3s9Q5x3lKkz9sBX for ; Fri, 12 Aug 2016 10:01:25 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=dxiEwROD; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2AF88A7697; Fri, 12 Aug 2016 02:01:15 +0200 (CEST) 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 gczn5o8yw4jy; Fri, 12 Aug 2016 02:01:09 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 99A98A76C5; Fri, 12 Aug 2016 00:49:27 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6693E4B801 for ; Thu, 11 Aug 2016 13:02:34 +0200 (CEST) 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 zxkVkDE3XtTC for ; Thu, 11 Aug 2016 13:02:34 +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 mail-pf0-f196.google.com (mail-pf0-f196.google.com [209.85.192.196]) by theia.denx.de (Postfix) with ESMTPS id 2EF534B93F for ; Thu, 11 Aug 2016 13:00:36 +0200 (CEST) Received: by mail-pf0-f196.google.com with SMTP id i6so13995pfe.0 for ; Thu, 11 Aug 2016 04:00:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IAzKOZs7Zy83J8IJvg9km2MFeQGXabv5uGm+iahg64s=; b=dxiEwRODTk9VIfJpOi6+5rH/XzdJnFM+vpey7yxL1snlkH7ReAp4r7cuFWweTW11dg aphRHI+FstE9o7Z5e8xCWAFd1fS04qUNAE7gb89Sln5Oy1iJWW60v+TCpy945vSlkhgc CKI0ly6WRjHm7+8CdubzcVpCdKr3kinXkFlFvDCjagoHYQn8ejhF6LggTVKqxmL4Gskp rEqzJMcJS8te4uXDNyMTF8sscTqquElxMLZUGDs4YFK/vV1VIuX3hZFcI4XVeU91wC7N XKYLvvanNAV3F5P41LV8o50uMUV7Iu7dMfb0YiML5gk4idhIClVDeFwnTJztEcz8gYKL px1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IAzKOZs7Zy83J8IJvg9km2MFeQGXabv5uGm+iahg64s=; b=MP8ehOhPr4vzU8jb4VzO/vY1gRsnW+31jVxuFYq6fhFUtF/bTFzf1UrzWsAFK9eLDq 99jeORyI6QQ3F78qWn5M7A1fxq6BqKBwZAYzRwlOohZilBnUoA8W8OJBpwDmZZgRn5cW GtrBAQJQs0upeH2H/Vx/GPp/Q8+yMda6ouM/SV2yLLKNJIsOscnax8AvNhpX3TXD5FTY 3CYCQsqupGSA0dnsbpHtUvr36GepYE5BN14X34XcKpGE6il9wrY2Odiu5As96jH8RJjq 0FR+dyjN+ldUmTT28Zn47EzAkrnZ0uvkGtKhIhSXZpck79264UA/yGMGfoCIteO34bvE gUvg== X-Gm-Message-State: AEkoouv/zSmE6zJiDArznBrC6MEa+ucCU3wOVfT4wG5D6ZKau6NGexe31V12ChtOTQlQAw== X-Received: by 10.98.30.133 with SMTP id e127mr16097013pfe.104.1470913233744; Thu, 11 Aug 2016 04:00:33 -0700 (PDT) Received: from linux-7smt.suse (gate-zmy3.freescale.com. [192.88.167.1]) by smtp.gmail.com with ESMTPSA id i7sm4414445paf.9.2016.08.11.04.00.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 Aug 2016 04:00:33 -0700 (PDT) From: Peng Fan X-Google-Original-From: Peng Fan To: jh80.chung@samsung.com Date: Thu, 11 Aug 2016 19:00:03 +0800 Message-Id: <1470913205-27891-3-git-send-email-peng.fan@nxp.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1470913205-27891-1-git-send-email-peng.fan@nxp.com> References: <1470913205-27891-1-git-send-email-peng.fan@nxp.com> Cc: Stefan Wahren , Stephen Warren , Clemens Gruber , u-boot@lists.denx.de, elven.wang@nxp.com Subject: [U-Boot] [PATCH 3/5] mmc: sd: add erase timeout support X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Add timeout in mmc_cmd, we can use this in driver code. Add mmc_sd_erase_timeout, this function is modified from linux kernel. Signed-off-by: Peng Fan Cc: Jaehoon Chung Cc: Simon Glass Cc: Bin Meng Cc: Stefan Wahren Cc: Clemens Gruber Cc: Kever Yang Cc: Eric Nelson Cc: Stephen Warren --- drivers/mmc/mmc_write.c | 29 +++++++++++++++++++++++++++++ include/mmc.h | 1 + 2 files changed, 30 insertions(+) diff --git a/drivers/mmc/mmc_write.c b/drivers/mmc/mmc_write.c index 4149f4a..3589f8e 100644 --- a/drivers/mmc/mmc_write.c +++ b/drivers/mmc/mmc_write.c @@ -15,6 +15,33 @@ #include #include "mmc_private.h" +/* + * Modified from from Linux kernel mmc_sd_erase_timeout. + */ +static unsigned int mmc_sd_erase_timeout(struct mmc *mmc, + unsigned int nr) +{ + unsigned int erase_timeout; + + if (mmc->ssr.erase_timeout) { + /* Erase timeout specified in SD Status Register (SSR) */ + erase_timeout = mmc->ssr.erase_timeout * nr + + mmc->ssr.erase_offset; + } else { + /* + * Erase timeout not specified in SD Status Register (SSR) so + * use 250ms per write block. + */ + erase_timeout = 250 * nr; + } + + /* Must not be less than 1 second */ + if (erase_timeout < 1000) + erase_timeout = 1000; + + return erase_timeout; +} + static ulong mmc_erase_t(struct mmc *mmc, ulong start, lbaint_t blkcnt) { struct mmc_cmd cmd = {0}; @@ -54,6 +81,8 @@ static ulong mmc_erase_t(struct mmc *mmc, ulong start, lbaint_t blkcnt) cmd.cmdidx = MMC_CMD_ERASE; cmd.cmdarg = MMC_ERASE_ARG; cmd.resp_type = MMC_RSP_R1b; + if (IS_SD(mmc)) + cmd.timeout = mmc_sd_erase_timeout(mmc, blkcnt); err = mmc_send_cmd(mmc, &cmd, NULL); if (err) diff --git a/include/mmc.h b/include/mmc.h index f09c36f..c72495c 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -303,6 +303,7 @@ struct mmc_cmd { uint resp_type; uint cmdarg; uint response[4]; + int timeout; }; struct mmc_data {