All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrei Warkentin <andreiw@motorola.com>
To: linux-mmc@vger.kernel.org
Cc: cjb@laptop.org, Andrei Warkentin <andreiw@motorola.com>,
	arindam.nath@amd.com, arnd@arndb.de, malchev@google.com
Subject: [v6 3/5] MMC: Implement MMC_CAP_CMD23 for SDHCI.
Date: Mon, 23 May 2011 15:06:37 -0500	[thread overview]
Message-ID: <1306181199-13915-4-git-send-email-andreiw@motorola.com> (raw)
In-Reply-To: <1305841590-26963-1-git-send-email-andreiw@motorola.com>

Implements support for multiblock transfers bounded
by SET_BLOCK_COUNT (CMD23).

Cc: arindam.nath@amd.com
Cc: cjb@laptop.org
Cc: arnd@arndb.de
Cc: malchev@google.com
Signed-off-by: Andrei Warkentin <andreiw@motorola.com>
---
 drivers/mmc/host/sdhci.c  |   66 ++++++++++++++++++++++++++++++++++-----------
 drivers/mmc/host/sdhci.h  |    2 +-
 include/linux/mmc/sdhci.h |    1 +
 3 files changed, 52 insertions(+), 17 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index cc63f5e..3a53512 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -838,9 +838,10 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_command *cmd)
 }
 
 static void sdhci_set_transfer_mode(struct sdhci_host *host,
-	struct mmc_data *data)
+	struct mmc_command *cmd)
 {
 	u16 mode;
+	struct mmc_data *data = cmd->data;
 
 	if (data == NULL)
 		return;
@@ -848,11 +849,17 @@ static void sdhci_set_transfer_mode(struct sdhci_host *host,
 	WARN_ON(!host->data);
 
 	mode = SDHCI_TRNS_BLK_CNT_EN;
-	if (data->blocks > 1) {
-		if (host->quirks & SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12)
-			mode |= SDHCI_TRNS_MULTI | SDHCI_TRNS_ACMD12;
-		else
-			mode |= SDHCI_TRNS_MULTI;
+	if (mmc_op_multi(cmd->opcode) ||
+	    data->blocks > 1) {
+		mode |= SDHCI_TRNS_MULTI;
+
+		/*
+		 * If we are sending CMD23, CMD12 never gets sent
+		 * on successful completion (so no Auto-CMD12).
+		 */
+		if (!host->mrq->sbc &&
+		    host->flags & SDHCI_AUTO_CMD12)
+			mode |= SDHCI_TRNS_AUTO_CMD12;
 	}
 	if (data->flags & MMC_DATA_READ)
 		mode |= SDHCI_TRNS_READ;
@@ -893,7 +900,15 @@ static void sdhci_finish_data(struct sdhci_host *host)
 	else
 		data->bytes_xfered = data->blksz * data->blocks;
 
-	if (data->stop) {
+	/*
+	 * Need to send CMD12 if -
+	 * a) open-ended multiblock transfer (no CMD23)
+	 * b) error in multiblock transfer
+	 */
+	if (data->stop &&
+	    (data->error ||
+	     !host->mrq->sbc)) {
+
 		/*
 		 * The controller needs a reset of internal state machines
 		 * upon error conditions.
@@ -949,7 +964,7 @@ static void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd)
 
 	sdhci_writel(host, cmd->arg, SDHCI_ARGUMENT);
 
-	sdhci_set_transfer_mode(host, cmd->data);
+	sdhci_set_transfer_mode(host, cmd);
 
 	if ((cmd->flags & MMC_RSP_136) && (cmd->flags & MMC_RSP_BUSY)) {
 		printk(KERN_ERR "%s: Unsupported response type!\n",
@@ -1004,13 +1019,21 @@ static void sdhci_finish_command(struct sdhci_host *host)
 
 	host->cmd->error = 0;
 
-	if (host->data && host->data_early)
-		sdhci_finish_data(host);
+	/* Finished CMD23, now send actual command. */
+	if (host->cmd == host->mrq->sbc) {
+		host->cmd = NULL;
+		sdhci_send_command(host, host->mrq->cmd);
+	} else {
 
-	if (!host->cmd->data)
-		tasklet_schedule(&host->finish_tasklet);
+		/* Processed actual command. */
+		if (host->data && host->data_early)
+			sdhci_finish_data(host);
 
-	host->cmd = NULL;
+		if (!host->cmd->data)
+			tasklet_schedule(&host->finish_tasklet);
+
+		host->cmd = NULL;
+	}
 }
 
 static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
@@ -1189,7 +1212,12 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
 #ifndef SDHCI_USE_LEDS_CLASS
 	sdhci_activate_led(host);
 #endif
-	if (host->quirks & SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12) {
+
+	/*
+	 * Ensure we don't send the STOP for non-SET_BLOCK_COUNTED
+	 * requests if Auto-CMD12 is enabled.
+	 */
+	if (!mrq->sbc && (host->flags & SDHCI_AUTO_CMD12)) {
 		if (mrq->stop) {
 			mrq->data->stop = NULL;
 			mrq->stop = NULL;
@@ -1227,7 +1255,10 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
 			host->mrq = mrq;
 		}
 
-		sdhci_send_command(host, mrq->cmd);
+		if (mrq->sbc)
+			sdhci_send_command(host, mrq->sbc);
+		else
+			sdhci_send_command(host, mrq->cmd);
 	}
 
 	mmiowb();
@@ -2455,7 +2486,10 @@ int sdhci_add_host(struct sdhci_host *host)
 	} else
 		mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_200;
 
-	mmc->caps |= MMC_CAP_SDIO_IRQ | MMC_CAP_ERASE;
+	mmc->caps |= MMC_CAP_SDIO_IRQ | MMC_CAP_ERASE | MMC_CAP_CMD23;
+
+	if (host->quirks & SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12)
+		host->flags |= SDHCI_AUTO_CMD12;
 
 	/*
 	 * A controller may support 8-bit width, but the board itself
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 7e28eec..2c3fbc5 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -36,7 +36,7 @@
 #define SDHCI_TRANSFER_MODE	0x0C
 #define  SDHCI_TRNS_DMA		0x01
 #define  SDHCI_TRNS_BLK_CNT_EN	0x02
-#define  SDHCI_TRNS_ACMD12	0x04
+#define  SDHCI_TRNS_AUTO_CMD12	0x04
 #define  SDHCI_TRNS_READ	0x10
 #define  SDHCI_TRNS_MULTI	0x20
 
diff --git a/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h
index e902618..73e27ba 100644
--- a/include/linux/mmc/sdhci.h
+++ b/include/linux/mmc/sdhci.h
@@ -113,6 +113,7 @@ struct sdhci_host {
 #define SDHCI_DEVICE_DEAD	(1<<3)	/* Device unresponsive */
 #define SDHCI_SDR50_NEEDS_TUNING (1<<4)	/* SDR50 needs tuning */
 #define SDHCI_NEEDS_RETUNING	(1<<5)	/* Host needs retuning */
+#define SDHCI_AUTO_CMD12	(1<<6)	/* Auto CMD12 support */
 
 	unsigned int version;	/* SDHCI spec. version */
 
-- 
1.7.0.4


  parent reply	other threads:[~2011-05-23 19:33 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-14  0:38 SET_BLOCK_COUNT-bounded multiblock transfers Andrei Warkentin
2011-04-14  0:03 ` Andrei Warkentin
2011-04-14  9:05   ` Gao, Yunpeng
2011-04-14 22:58     ` Andrei Warkentin
2011-04-14 23:18       ` Chris Ball
2011-04-15  7:10         ` Andrei Warkentin
2011-04-15 17:29           ` Andrei Warkentin
2011-04-14  0:38 ` [RFC 1/3] MMC: use CMD23 for multiblock transfers when we can Andrei Warkentin
2011-04-14  0:38 ` [RFC 2/3] MMC: Implement MMC_CAP_CMD23 for SDHCI Andrei Warkentin
2011-04-14  0:38 ` [RFC 3/3] MMC: Block CMD23 support for UHS104/SDXC cards Andrei Warkentin
2011-04-15 23:51 ` [patchv2 1/3] MMC: Use CMD23 for multiblock transfers when we can Andrei Warkentin
2011-04-15 23:51 ` [patchv2 2/3] MMC: Implement MMC_CAP_CMD23 for SDHCI Andrei Warkentin
2011-04-15 23:51 ` [patchv2 3/3] MMC: Block CMD23 support for UHS104/SDXC cards Andrei Warkentin
2011-04-16 10:40 ` CMD23 plumbing and support patchset Andrei Warkentin
2011-04-21  1:44   ` Chris Ball
2011-04-21  6:29     ` Andrei Warkentin
2011-04-21  6:30       ` Andrei Warkentin
2011-04-22  3:53         ` Andrei Warkentin
2011-04-23  2:51           ` Chris Ball
2011-04-26 23:30             ` Andrei Warkentin
2011-04-27  2:10   ` CMD23 plumbing patchset Andrei Warkentin
2011-04-27  2:10     ` [[v4] 1/5] MMC: Add/remove quirks conditional support Andrei Warkentin
2011-04-27  2:10       ` [[v4] 2/5] MMC: Use CMD23 for multiblock transfers when we can Andrei Warkentin
2011-04-27  2:10         ` [[v4] 3/5] MMC: Implement MMC_CAP_CMD23 for SDHCI Andrei Warkentin
2011-04-27  2:10           ` [[v4] 4/5] MMC: Block CMD23 support for UHS104/SDXC cards Andrei Warkentin
2011-04-27  2:10             ` [[v4] 5/5] MMC: SDHCI AutoCMD23 support Andrei Warkentin
2011-04-27  5:49               ` Nath, Arindam
2011-04-27  5:59                 ` Andrei Warkentin
2011-04-27  6:02                   ` Nath, Arindam
2011-04-27  6:05                     ` Andrei Warkentin
2011-04-28  8:34                       ` Nath, Arindam
2011-04-28 19:09                         ` Andrei Warkentin
2011-04-29  5:34                           ` Nath, Arindam
2011-05-19  2:37         ` [[v4] 2/5] MMC: Use CMD23 for multiblock transfers when we can Jaehoon Chung
2011-05-19 17:01           ` Andrei Warkentin
2011-05-20  4:38             ` Jaehoon Chung
     [not found]               ` <BANLkTik72KgftDWz6aNn=zGDqj1uMpwnYw@mail.gmail.com>
2011-05-20  6:54                 ` Andrei Warkentin
2011-05-20  9:05                   ` Jaehoon Chung
2011-05-23 12:40                   ` Jaehoon Chung
2011-05-23 19:25                     ` Andrei Warkentin
2011-05-23 19:33                       ` Andrei Warkentin
2011-05-23 19:34                     ` Andrei Warkentin
2011-05-23 20:45                       ` Andrei Warkentin
2011-05-24  0:07                       ` Jaehoon Chung
2011-04-29 23:25     ` CMD23 plumbing patchset Andrei Warkentin
2011-05-19 21:46     ` Andrei Warkentin
2011-05-23 20:06       ` Andrei Warkentin
2011-05-25  2:51         ` Chris Ball
2011-05-23 20:06       ` [v6 1/5] MMC: Add/remove quirks conditional support Andrei Warkentin
2011-05-23 20:06       ` [v6 2/5] MMC: Use CMD23 for multiblock transfers when we can Andrei Warkentin
2011-05-23 20:06       ` Andrei Warkentin [this message]
2011-05-23 20:06       ` [v6 4/5] MMC: Block CMD23 support for UHS104/SDXC cards Andrei Warkentin
2011-05-24  6:01         ` Nath, Arindam
2011-05-23 20:06       ` [v6 5/5] MMC: SDHCI AutoCMD23 support Andrei Warkentin
2011-05-24 23:27         ` Chris Ball
2011-05-25  0:37           ` Andrei Warkentin
2011-05-19 21:46     ` [v5 1/5] MMC: Add/remove quirks conditional support Andrei Warkentin
2011-05-19 21:46     ` [v5 2/5] MMC: Use CMD23 for multiblock transfers when we can Andrei Warkentin
2011-05-20 10:29       ` Jaehoon Chung
2011-05-20 18:12         ` Andrei Warkentin
2011-05-19 21:46     ` [v5 3/5] MMC: Implement MMC_CAP_CMD23 for SDHCI Andrei Warkentin
2011-05-19 21:46     ` [v5 4/5] MMC: Block CMD23 support for UHS104/SDXC cards Andrei Warkentin
2011-05-20 10:38       ` Nath, Arindam
2011-05-20 18:09         ` Andrei Warkentin
2011-05-19 21:46     ` [v5 5/5] MMC: SDHCI AutoCMD23 support Andrei Warkentin
2011-05-20 10:46       ` Nath, Arindam
2011-05-20 18:08         ` Andrei Warkentin
2011-04-16 10:40 ` [patchv3 1/5] MMC: Add/remove quirks conditional support Andrei Warkentin
2011-04-16 10:40 ` [patchv3 2/5] MMC: Use CMD23 for multiblock transfers when we can Andrei Warkentin
2011-04-17 17:23   ` Arnd Bergmann
2011-04-17 19:27     ` Andrei Warkentin
2011-04-19  3:44     ` Andrei Warkentin
2011-04-19  7:39       ` Arnd Bergmann
2011-04-19 15:18         ` Andrei Warkentin
2011-04-16 10:40 ` [patchv3 3/5] MMC: Implement MMC_CAP_CMD23 for SDHCI Andrei Warkentin
2011-04-16 10:40 ` [patchv3 4/5] MMC: Block CMD23 support for UHS104/SDXC cards Andrei Warkentin
2011-04-16 16:19   ` Nath, Arindam
2011-04-16 23:00     ` Andrei Warkentin
2011-04-16 23:38   ` [PATCH] " Andrei Warkentin
2011-04-16 10:40 ` [patchv3 5/5] MMC: SDHCI AutoCMD23 support Andrei Warkentin
2011-04-17 17:25   ` Arnd Bergmann
2011-04-17 19:31     ` Andrei Warkentin
2011-04-19  3:05       ` Andrei Warkentin
2011-04-19  3:19         ` Nath, Arindam
2011-04-19  3:32           ` Andrei Warkentin

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=1306181199-13915-4-git-send-email-andreiw@motorola.com \
    --to=andreiw@motorola.com \
    --cc=arindam.nath@amd.com \
    --cc=arnd@arndb.de \
    --cc=cjb@laptop.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=malchev@google.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.