From patchwork Tue Aug 30 10:22:50 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Girish K S X-Patchwork-Id: 1112662 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p7UANE0r031134 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 30 Aug 2011 10:23:35 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QyLTF-0004dn-27; Tue, 30 Aug 2011 10:23:05 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QyLTE-0000Sk-Jv; Tue, 30 Aug 2011 10:23:04 +0000 Received: from mail-gy0-f177.google.com ([209.85.160.177]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QyLTA-0000SR-QO for linux-arm-kernel@lists.infradead.org; Tue, 30 Aug 2011 10:23:01 +0000 Received: by gyh20 with SMTP id 20so6026363gyh.36 for ; Tue, 30 Aug 2011 03:22:57 -0700 (PDT) Received: by 10.142.180.5 with SMTP id c5mr1452950wff.213.1314699776532; Tue, 30 Aug 2011 03:22:56 -0700 (PDT) Received: from girishks ([115.113.119.130]) by mx.google.com with ESMTPS id m16sm335439wfd.0.2011.08.30.03.22.53 (version=SSLv3 cipher=OTHER); Tue, 30 Aug 2011 03:22:55 -0700 (PDT) From: Girish K S To: linux-mmc@vger.kernel.org Subject: [PATCH] mmc: core: eMMC4.5 Add the timeout for switch Date: Tue, 30 Aug 2011 15:52:50 +0530 Message-Id: <1314699770-17120-1-git-send-email-girish.shivananjappa@linaro.org> X-Mailer: git-send-email 1.7.1 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110830_062300_995267_E52F8F62 X-CRM114-Status: GOOD ( 17.60 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.160.177 listed in list.dnswl.org] Cc: kgene.kim@samsung.com, patches@linaro.org, linux-samsung-soc@vger.kernel.org, Girish K S , cjb@laptop.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Tue, 30 Aug 2011 10:23:35 +0000 (UTC) This patch adds the code to handle the default timeout for switch command. For eMMC 4.5 devices if timeout is not specified for the switch command while accessing a specific field,then the default timeout shall be used to timeout. Specification says there is no timeout defined while accessing BKOPS_START, SANITIZE_START, FLUSH_CACHE field(so these fields are excluded). Signed-off-by: Girish K S --- drivers/mmc/core/mmc.c | 5 +++++ drivers/mmc/core/mmc_ops.c | 8 ++++++++ include/linux/mmc/card.h | 1 + include/linux/mmc/mmc.h | 4 ++++ 4 files changed, 18 insertions(+), 0 deletions(-) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 5700b1c..5b9fb6a 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -405,6 +405,11 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd) if (card->ext_csd.rev >= 5) card->ext_csd.rel_param = ext_csd[EXT_CSD_WR_REL_PARAM]; + if (card->ext_csd.rev > 5) { + /* (eMMC 4.5)timeout is expressed in units of 10 ms*/ + card->ext_csd.cmd6_timeout = ext_csd[EXT_CSD_CMD6_TIME]*10; + } + if (ext_csd[EXT_CSD_ERASED_MEM_CONT]) card->erased_byte = 0xFF; else diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index 770c3d0..c4d82f4 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c @@ -394,6 +394,14 @@ int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, cmd.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC; cmd.cmd_timeout_ms = timeout_ms; + /* timeout is not defined for below command indexes (eMMC 4.5) */ + if ((timeout_ms == 0) && + (card->ext_csd->rev > 5) && + (index != EXT_CSD_BKOPS_START) && + (index != EXT_CSD_SANITIZE_START) && + (index != EXT_CSD_FLUSH_CACHE)) + cmd.cmd_timeout_ms = card->ext_csd->cmd6_timeout; + err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES); if (err) return err; diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h index b460fc2..ef88412 100644 --- a/include/linux/mmc/card.h +++ b/include/linux/mmc/card.h @@ -50,6 +50,7 @@ struct mmc_ext_csd { u8 rel_sectors; u8 rel_param; u8 part_config; + u8 cmd6_timeout; /* timeout in ms */ unsigned int part_time; /* Units: ms */ unsigned int sa_timeout; /* Units: 100ns */ unsigned int hs_max_dtr; diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h index 5a794cb..a23f836 100644 --- a/include/linux/mmc/mmc.h +++ b/include/linux/mmc/mmc.h @@ -270,8 +270,11 @@ struct _mmc_csd { * EXT_CSD fields */ +#define EXT_CSD_FLUSH_CACHE 32 /* R/W */ #define EXT_CSD_PARTITION_ATTRIBUTE 156 /* R/W */ #define EXT_CSD_PARTITION_SUPPORT 160 /* RO */ +#define EXT_CSD_BKOPS_START 164 /* R/W */ +#define EXT_CSD_SANITIZE_START 165 /* R/W */ #define EXT_CSD_WR_REL_PARAM 166 /* RO */ #define EXT_CSD_ERASE_GROUP_DEF 175 /* R/W */ #define EXT_CSD_PART_CONFIG 179 /* R/W */ @@ -293,6 +296,7 @@ struct _mmc_csd { #define EXT_CSD_SEC_ERASE_MULT 230 /* RO */ #define EXT_CSD_SEC_FEATURE_SUPPORT 231 /* RO */ #define EXT_CSD_TRIM_MULT 232 /* RO */ +#define EXT_CSD_CMD6_TIME 248 /* RO */ /* * EXT_CSD field definitions