[PATCH 2/2] mmc: sdhci: Fix CMD12 and Tuning issues

From: Peter Guo
Date: Tue Sep 24 2013 - 23:38:15 EST


From: "peter.guo" <peter.guo@xxxxxxxxxxxxxx>

- Change tuning_loop_counter check from not zero to less than zero
in function sdhci_execute_tuning; Becasue some host may need 40 times tuning,
but orginal code only think tuning times <= 39 is successfull.

- When Host Capability Reg (0x40) bit[43:40] is zero, retuning timer should be disabled.
But Original code still start the timer.

Signed-off-by: peter.guo <peter.guo@xxxxxxxxxxxxxx>
---
drivers/mmc/host/sdhci.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 7a7fb4f..69413e4 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1050,6 +1050,13 @@ static void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd)
if (cmd->data || cmd->opcode == MMC_SEND_TUNING_BLOCK ||
cmd->opcode == MMC_SEND_TUNING_BLOCK_HS200)
flags |= SDHCI_CMD_DATA;
+ /*
+ * According to SD Host Spec
+ * Command Register offset 0xE bit[7:6] is command type
+ * And Cmd12 should use Abort Type
+ */
+ if (cmd->opcode == MMC_STOP_TRANSMISSION)
+ flags |= SDHCI_CMD_ABORTCMD;

sdhci_writew(host, SDHCI_MAKE_CMD(cmd->opcode, flags), SDHCI_COMMAND);
}
@@ -1978,7 +1985,7 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode)
* The Host Driver has exhausted the maximum number of loops allowed,
* so use fixed sampling frequency.
*/
- if (!tuning_loop_counter || !timeout) {
+ if ((tuning_loop_counter < 0) || (!timeout)) {
ctrl &= ~SDHCI_CTRL_TUNED_CLK;
sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2);
} else {
@@ -2007,7 +2014,8 @@ out:
} else {
host->flags &= ~SDHCI_NEEDS_RETUNING;
/* Reload the new initial value for timer */
- if (host->tuning_mode == SDHCI_TUNING_MODE_1)
+ if ((host->tuning_mode == SDHCI_TUNING_MODE_1) &&
+ (host->tuning_count))
mod_timer(&host->tuning_timer, jiffies +
host->tuning_count * HZ);
}
--
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/