aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2016-12-02 08:14:23 -0500
committerUlf Hansson <ulf.hansson@linaro.org>2016-12-05 08:16:22 -0500
commite711f0309109701cb422aab44ace4ea0dccb89ea (patch)
tree43032d7231d650cca2d35bcd90afeadcdff0a61c
parent0760c355525c08dd598e86edb2a310688ac8af4c (diff)
mmc: mmc: Introduce mmc_abort_tuning()
If a tuning command times out, the card could still be processing it, which will cause problems for recovery. The eMMC specification says that CMD12 can be used to stop CMD21, so add a function that does that. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-rw-r--r--drivers/mmc/core/mmc_ops.c25
-rw-r--r--include/linux/mmc/core.h1
2 files changed, 26 insertions, 0 deletions
diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
index 81ce63bb0773..b11c3455b040 100644
--- a/drivers/mmc/core/mmc_ops.c
+++ b/drivers/mmc/core/mmc_ops.c
@@ -678,6 +678,31 @@ out:
678} 678}
679EXPORT_SYMBOL_GPL(mmc_send_tuning); 679EXPORT_SYMBOL_GPL(mmc_send_tuning);
680 680
681int mmc_abort_tuning(struct mmc_host *host, u32 opcode)
682{
683 struct mmc_command cmd = {0};
684
685 /*
686 * eMMC specification specifies that CMD12 can be used to stop a tuning
687 * command, but SD specification does not, so do nothing unless it is
688 * eMMC.
689 */
690 if (opcode != MMC_SEND_TUNING_BLOCK_HS200)
691 return 0;
692
693 cmd.opcode = MMC_STOP_TRANSMISSION;
694 cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC;
695
696 /*
697 * For drivers that override R1 to R1b, set an arbitrary timeout based
698 * on the tuning timeout i.e. 150ms.
699 */
700 cmd.busy_timeout = 150;
701
702 return mmc_wait_for_cmd(host, &cmd, 0);
703}
704EXPORT_SYMBOL_GPL(mmc_abort_tuning);
705
681static int 706static int
682mmc_send_bus_test(struct mmc_card *card, struct mmc_host *host, u8 opcode, 707mmc_send_bus_test(struct mmc_card *card, struct mmc_host *host, u8 opcode,
683 u8 len) 708 u8 len)
diff --git a/include/linux/mmc/core.h b/include/linux/mmc/core.h
index 0ce928b3ce90..e33cc748dcfe 100644
--- a/include/linux/mmc/core.h
+++ b/include/linux/mmc/core.h
@@ -176,6 +176,7 @@ extern int mmc_wait_for_app_cmd(struct mmc_host *, struct mmc_card *,
176extern void mmc_start_bkops(struct mmc_card *card, bool from_exception); 176extern void mmc_start_bkops(struct mmc_card *card, bool from_exception);
177extern int mmc_switch(struct mmc_card *, u8, u8, u8, unsigned int); 177extern int mmc_switch(struct mmc_card *, u8, u8, u8, unsigned int);
178extern int mmc_send_tuning(struct mmc_host *host, u32 opcode, int *cmd_error); 178extern int mmc_send_tuning(struct mmc_host *host, u32 opcode, int *cmd_error);
179extern int mmc_abort_tuning(struct mmc_host *host, u32 opcode);
179extern int mmc_get_ext_csd(struct mmc_card *card, u8 **new_ext_csd); 180extern int mmc_get_ext_csd(struct mmc_card *card, u8 **new_ext_csd);
180 181
181#define MMC_ERASE_ARG 0x00000000 182#define MMC_ERASE_ARG 0x00000000