From patchwork Thu Sep 1 06:01:14 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: 3820 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 274E023FB1 for ; Thu, 1 Sep 2011 06:01:31 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id 0A7F2A18A26 for ; Thu, 1 Sep 2011 06:01:31 +0000 (UTC) Received: by fxd18 with SMTP id 18so589184fxd.11 for ; Wed, 31 Aug 2011 23:01:30 -0700 (PDT) Received: by 10.223.76.201 with SMTP id d9mr1128948fak.119.1314856890862; Wed, 31 Aug 2011 23:01:30 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.11.8 with SMTP id m8cs40270lab; Wed, 31 Aug 2011 23:01:30 -0700 (PDT) Received: by 10.68.64.97 with SMTP id n1mr878213pbs.36.1314856889187; Wed, 31 Aug 2011 23:01:29 -0700 (PDT) Received: from mail-pz0-f45.google.com (mail-pz0-f45.google.com [209.85.210.45]) by mx.google.com with ESMTPS id 6si10570185pbc.31.2011.08.31.23.01.28 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 31 Aug 2011 23:01:29 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.210.45 is neither permitted nor denied by best guess record for domain of girish.shivananjappa@linaro.org) client-ip=209.85.210.45; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.45 is neither permitted nor denied by best guess record for domain of girish.shivananjappa@linaro.org) smtp.mail=girish.shivananjappa@linaro.org Received: by pzk33 with SMTP id 33so3009944pzk.32 for ; Wed, 31 Aug 2011 23:01:28 -0700 (PDT) Received: by 10.68.36.136 with SMTP id q8mr1614216pbj.529.1314856887903; Wed, 31 Aug 2011 23:01:27 -0700 (PDT) Received: from girishks ([115.113.119.130]) by mx.google.com with ESMTPS id u2sm1908684pbq.9.2011.08.31.23.01.25 (version=SSLv3 cipher=OTHER); Wed, 31 Aug 2011 23:01:27 -0700 (PDT) From: Girish K S To: linux-mmc@vger.kernel.org Cc: cjb@laptop.org, kgene.kim@samsung.com, patches@linaro.org, linux-samsung-soc@vger.kernel.org, Girish K S Subject: [PATCH V2] mmc: core: eMMC4.5 Add the timeout for switch Date: Thu, 1 Sep 2011 11:31:14 +0530 Message-Id: <1314856874-5385-1-git-send-email-girish.shivananjappa@linaro.org> X-Mailer: git-send-email 1.7.1 V2- The datatype of the cmd6_timeout is changed from u8 to unsigned int, as it can hold a value upto 255*10=2550 and the data assignment in mmc_switch function. 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; + unsigned int 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