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 2/4] MMC: SDHCI R1B command handling + MMC_CAP_ERASE.
Date: Mon, 11 Apr 2011 16:13:42 -0500	[thread overview]
Message-ID: <1302556424-21951-2-git-send-email-andreiw@motorola.com> (raw)
In-Reply-To: <BANLkTikA56sD_A6VVPF15SgA-AnKOZ2ZXw@mail.gmail.com>

ERASE command needs R1B response, so fix R1B-type command
handling for SDHCI controller. For non-DAT commands using a busy
reponse, the cmd->cmd_timeout_ms (in ms) field is used for timeout
calculations.

Based on patch by Chuanxiao Dong <chuanxiao.dong@intel.com>
Signed-off-by: Andrei Warkentin <andreiw@motorola.com>
---
 drivers/mmc/host/sdhci.c |   43 +++++++++++++++++++++++++++----------------
 1 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 9e15f41..173e980 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -40,7 +40,6 @@
 
 static unsigned int debug_quirks = 0;
 
-static void sdhci_prepare_data(struct sdhci_host *, struct mmc_data *);
 static void sdhci_finish_data(struct sdhci_host *);
 
 static void sdhci_send_command(struct sdhci_host *, struct mmc_command *);
@@ -591,9 +590,10 @@ static void sdhci_adma_table_post(struct sdhci_host *host,
 		data->sg_len, direction);
 }
 
-static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_data *data)
+static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd)
 {
 	u8 count;
+	struct mmc_data *data = cmd->data;
 	unsigned target_timeout, current_timeout;
 
 	/*
@@ -605,12 +605,16 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_data *data)
 	if (host->quirks & SDHCI_QUIRK_BROKEN_TIMEOUT_VAL)
 		return 0xE;
 
-	/* timeout in us */
-	target_timeout = data->timeout_ns / 1000 +
-		data->timeout_clks / host->clock;
+	/* Unspecified timeout, assume max */
+	if (!data && !cmd->cmd_timeout_ms)
+		return 0xE;
 
-	if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK)
-		host->timeout_clk = host->clock / 1000;
+	/* timeout in us */
+	if (!data)
+		target_timeout = cmd->cmd_timeout_ms * 1000;
+	else
+		target_timeout = data->timeout_ns / 1000 +
+			data->timeout_clks / host->clock;
 
 	/*
 	 * Figure out needed cycles.
@@ -632,8 +636,9 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_data *data)
 	}
 
 	if (count >= 0xF) {
-		printk(KERN_WARNING "%s: Too large timeout requested!\n",
-			mmc_hostname(host->mmc));
+		printk(KERN_WARNING "%s: Too large timeout requested for CMD%d!\n",
+		       mmc_hostname(host->mmc),
+		       cmd->opcode);
 		count = 0xE;
 	}
 
@@ -651,15 +656,21 @@ static void sdhci_set_transfer_irqs(struct sdhci_host *host)
 		sdhci_clear_set_irqs(host, dma_irqs, pio_irqs);
 }
 
-static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data)
+static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_command *cmd)
 {
 	u8 count;
 	u8 ctrl;
+	struct mmc_data *data = cmd->data;
 	int ret;
 
 	WARN_ON(host->data);
 
-	if (data == NULL)
+	if (data || (cmd->flags & MMC_RSP_BUSY)) {
+		count = sdhci_calc_timeout(host, cmd);
+		sdhci_writeb(host, count, SDHCI_TIMEOUT_CONTROL);
+	}
+
+	if (!data)
 		return;
 
 	/* Sanity checks */
@@ -670,9 +681,6 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data)
 	host->data = data;
 	host->data_early = 0;
 
-	count = sdhci_calc_timeout(host, data);
-	sdhci_writeb(host, count, SDHCI_TIMEOUT_CONTROL);
-
 	if (host->flags & (SDHCI_USE_SDMA | SDHCI_USE_ADMA))
 		host->flags |= SDHCI_REQ_USE_DMA;
 
@@ -920,7 +928,7 @@ static void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd)
 
 	host->cmd = cmd;
 
-	sdhci_prepare_data(host, cmd->data);
+	sdhci_prepare_data(host, cmd);
 
 	sdhci_writel(host, cmd->arg, SDHCI_ARGUMENT);
 
@@ -1867,6 +1875,9 @@ int sdhci_add_host(struct sdhci_host *host)
 	if (caps & SDHCI_TIMEOUT_CLK_UNIT)
 		host->timeout_clk *= 1000;
 
+	if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK)
+		host->timeout_clk = host->clock / 1000;
+
 	/*
 	 * Set host parameters.
 	 */
@@ -1879,7 +1890,7 @@ int sdhci_add_host(struct sdhci_host *host)
 		mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_200;
 
 	mmc->f_max = host->max_clk;
-	mmc->caps |= MMC_CAP_SDIO_IRQ;
+	mmc->caps |= MMC_CAP_SDIO_IRQ | MMC_CAP_ERASE;
 
 	/*
 	 * A controller may support 8-bit width, but the board itself
-- 
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                           ` Andrei Warkentin [this message]
2011-04-12  9:06                             ` [patchv3 2/4] MMC: SDHCI R1B command handling + MMC_CAP_ERASE 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                           ` [patchv3 3/4] MMC: Allow setting CMD timeout for CMD6 (SWITCH) Andrei Warkentin
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-2-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).