linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrei Warkentin <andreiw@motorola.com>
To: linux-mmc@vger.kernel.org
Cc: arnd@arndb.de, cjb@laptop.org, Andrei Warkentin <andreiw@motorola.com>
Subject: [patchv3 3/4] MMC: Allow setting CMD timeout for CMD6 (SWITCH).
Date: Mon, 11 Apr 2011 16:13:43 -0500	[thread overview]
Message-ID: <1302556424-21951-3-git-send-email-andreiw@motorola.com> (raw)
In-Reply-To: <BANLkTikA56sD_A6VVPF15SgA-AnKOZ2ZXw@mail.gmail.com>

CMD6 is R1B-type command, where DAT is used as busy. Depending
on register written using CMD6, timeout value can be different
as per spec.

Signed-off-by: Andrei Warkentin <andreiw@motorola.com>
---
 drivers/mmc/core/mmc.c     |   14 ++++++++------
 drivers/mmc/core/mmc_ops.c |   17 ++++++++++++++++-
 drivers/mmc/core/mmc_ops.h |    1 -
 include/linux/mmc/core.h   |    1 +
 4 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index caba751..a5cf423 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -548,7 +548,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
 	 */
 	if (card->ext_csd.enhanced_area_en) {
 		err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
-				EXT_CSD_ERASE_GROUP_DEF, 1);
+				 EXT_CSD_ERASE_GROUP_DEF, 1, 0);
 
 		if (err && err != -EBADMSG)
 			goto free_card;
@@ -579,7 +579,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
 	if (card->ext_csd.bootconfig & 0x7) {
 		card->ext_csd.bootconfig &= ~0x7;
 		mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BOOT_CONFIG,
-			   card->ext_csd.bootconfig);
+			   card->ext_csd.bootconfig, 0);
 	}
 
 	/*
@@ -588,7 +588,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
 	if ((card->ext_csd.hs_max_dtr != 0) &&
 		(host->caps & MMC_CAP_MMC_HIGHSPEED)) {
 		err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
-			EXT_CSD_HS_TIMING, 1);
+				 EXT_CSD_HS_TIMING, 1, 0);
 		if (err && err != -EBADMSG)
 			goto free_card;
 
@@ -655,7 +655,8 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
 				ddr = 0; /* no DDR for 1-bit width */
 			err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
 					 EXT_CSD_BUS_WIDTH,
-					 ext_csd_bits[idx][0]);
+					 ext_csd_bits[idx][0],
+					 0);
 			if (!err) {
 				mmc_set_bus_width_ddr(card->host,
 						      bus_width, MMC_SDR_MODE);
@@ -674,8 +675,9 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
 
 		if (!err && ddr) {
 			err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
-					EXT_CSD_BUS_WIDTH,
-					ext_csd_bits[idx][1]);
+					 EXT_CSD_BUS_WIDTH,
+					 ext_csd_bits[idx][1],
+					 0);
 		}
 		if (err) {
 			printk(KERN_WARNING "%s: switch to bus width %d ddr %d "
diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
index 60842f8..586f9b4 100644
--- a/drivers/mmc/core/mmc_ops.c
+++ b/drivers/mmc/core/mmc_ops.c
@@ -387,7 +387,19 @@ int mmc_spi_set_crc(struct mmc_host *host, int use_crc)
 	return err;
 }
 
-int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value)
+/**
+ *	mmc_switch - modify EXT_CSD register
+ *	@card: the MMC card associated with the data transfer
+ *	@set: cmd set values
+ *	@index: EXT_CSD register index
+ *	@value: value to program into EXT_CSD register
+ *	@timeout_ms: timeout (ms) for operation performed by register write,
+ *                   timeout of zero implies maximum possible timeout
+ *
+ *	Modifies the EXT_CSD register for selected card.
+ */
+int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
+	unsigned int timeout_ms)
 {
 	int err;
 	struct mmc_command cmd;
@@ -404,6 +416,7 @@ int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value)
 		  (value << 8) |
 		  set;
 	cmd.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC;
+	cmd.cmd_timeout_ms = timeout_ms;
 
 	err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES);
 	if (err)
@@ -434,6 +447,8 @@ int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value)
 	return 0;
 }
 
+EXPORT_SYMBOL(mmc_switch);
+
 int mmc_send_status(struct mmc_card *card, u32 *status)
 {
 	int err;
diff --git a/drivers/mmc/core/mmc_ops.h b/drivers/mmc/core/mmc_ops.h
index e6d44b8..9276946 100644
--- a/drivers/mmc/core/mmc_ops.h
+++ b/drivers/mmc/core/mmc_ops.h
@@ -20,7 +20,6 @@ int mmc_all_send_cid(struct mmc_host *host, u32 *cid);
 int mmc_set_relative_addr(struct mmc_card *card);
 int mmc_send_csd(struct mmc_card *card, u32 *csd);
 int mmc_send_ext_csd(struct mmc_card *card, u8 *ext_csd);
-int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value);
 int mmc_send_status(struct mmc_card *card, u32 *status);
 int mmc_send_cid(struct mmc_host *host, u32 *cid);
 int mmc_spi_read_ocr(struct mmc_host *host, int highcap, u32 *ocrp);
diff --git a/include/linux/mmc/core.h b/include/linux/mmc/core.h
index 811e96e..f8e4bcb 100644
--- a/include/linux/mmc/core.h
+++ b/include/linux/mmc/core.h
@@ -135,6 +135,7 @@ extern void mmc_wait_for_req(struct mmc_host *, struct mmc_request *);
 extern int mmc_wait_for_cmd(struct mmc_host *, struct mmc_command *, int);
 extern int mmc_wait_for_app_cmd(struct mmc_host *, struct mmc_card *,
 	struct mmc_command *, int);
+extern int mmc_switch(struct mmc_card *, u8, u8, u8, unsigned int);
 
 #define MMC_ERASE_ARG		0x00000000
 #define MMC_SECURE_ERASE_ARG	0x80000000
-- 
1.7.0.4


  parent reply	other threads:[~2011-04-11 20:34 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-19 11:18 MMC/eMMC partitioning support Andrei Warkentin
2011-03-19 11:18 ` [RFC] MMC: MMC boot partitions support Andrei Warkentin
2011-03-19 12:13   ` Andrei Warkentin
2011-03-21 14:19   ` [PATCH] " Andrei Warkentin
2011-03-22  3:54   ` [PATCHv3] " Andrei Warkentin
2011-03-22 21:11   ` MMC partitions support (4th revision) Andrei Warkentin
2011-03-22 21:11   ` [PATCHv4] MMC: MMC boot partitions support Andrei Warkentin
2011-03-29 22:45     ` Andrei Warkentin
2011-03-30 12:03       ` Arnd Bergmann
2011-03-30 20:07         ` Andrei Warkentin
2011-03-30 22:43           ` Chris Ball
2011-03-30 22:46             ` Chris Ball
2011-03-30 23:18               ` Andrei Warkentin
2011-03-30 23:34                 ` Chris Ball
2011-03-31  6:57                   ` Andrei Warkentin
2011-03-31 11:01                     ` Arnd Bergmann
2011-03-31 19:17                       ` Andrei Warkentin
2011-03-31 19:37                         ` Chris Ball
2011-03-31 20:01                           ` Andrei Warkentin
2011-03-31 20:03                           ` Chris Ball
2011-03-31 20:01                             ` Andrei Warkentin
2011-04-01  9:23                               ` Arnd Bergmann
2011-04-01 14:52                                 ` Chris Ball
2011-04-01  9:21                         ` Arnd Bergmann
2011-03-31 11:17           ` Arnd Bergmann
2011-03-31 19:29             ` Andrei Warkentin
2011-04-01 10:38               ` Arnd Bergmann
2011-04-01 18:42                 ` Andrei Warkentin
2011-04-01 19:25                   ` Arnd Bergmann
2011-04-01 19:42                     ` Andrei Warkentin
2011-04-04 12:22                       ` [PATCH] " Andrei Warkentin
2011-04-04 11:52                         ` Andrei Warkentin
2011-04-11 21:13                           ` [patchv3 1/4] MMC: Rename erase_timeout to cmd_timeout_ms Andrei Warkentin
2011-04-11 21:13                           ` [patchv3 2/4] MMC: SDHCI R1B command handling + MMC_CAP_ERASE Andrei Warkentin
2011-04-12  9:06                             ` Dong, Chuanxiao
2011-04-12 18:05                               ` Andrei Warkentin
2011-04-13  1:59                                 ` Dong, Chuanxiao
2011-04-13  5:44                                   ` Andrei Warkentin
2011-04-15 21:34                                     ` Cyril Hrubis
2011-08-10 13:30                             ` Chris Ball
2011-04-11 21:13                           ` Andrei Warkentin [this message]
2011-04-11 21:13                           ` [patchv3 4/4] MMC: MMC boot partitions support Andrei Warkentin
2011-04-11 22:00                             ` Chris Ball
2011-04-11 22:10                               ` Andrei Warkentin
2011-04-11 22:22                                 ` Chris Ball
2011-04-11 22:18                                   ` Andrei Warkentin
2011-04-11 23:10                                     ` [patchv4 1/2] MMC: block.c cleanup for host claim/release Andrei Warkentin
2011-04-11 23:10                                     ` [patchv4 2/2] MMC: MMC boot partitions support Andrei Warkentin
2011-04-11 23:20                                     ` [patchv3 4/4] " Chris Ball
2011-04-11 23:24                                       ` Andrei Warkentin
2011-04-21  1:13                             ` Chris Ball
2011-04-21  1:30                               ` Chris Ball
2011-04-21  5:09                                 ` Philip Rakity
2011-04-21  5:22                                   ` Chris Ball
2011-04-21  5:31                                     ` Andrei Warkentin
2011-04-21  6:07                                       ` [RFC] MMC: Block: Ensure hardware partitions don't mess with mmcblk device naming Andrei Warkentin
2011-04-21  8:17                                         ` Andrei Warkentin
2011-04-21 14:44                                           ` Chris Ball
2011-04-22  0:20                                         ` Chris Ball
2011-04-22  3:46                                           ` [PATCH] " Andrei Warkentin
2011-04-22  3:50                                             ` Andrei Warkentin
2011-04-22 22:34                                             ` Chris Ball
2011-04-21  4:31                               ` [patchv3 4/4] MMC: MMC boot partitions support Jaehoon Chung

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1302556424-21951-3-git-send-email-andreiw@motorola.com \
    --to=andreiw@motorola.com \
    --cc=arnd@arndb.de \
    --cc=cjb@laptop.org \
    --cc=linux-mmc@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).