aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2023-07-18 20:42:16 -0400
committerTom Rini <trini@konsulko.com>2023-07-18 20:42:16 -0400
commit6f1b951500707e46f2920c0034856ada018aabcb (patch)
tree59c30ba5b1f778f763b3060edc57f1f7849fca41
parent890233ca5569e5787d8407596a12b9fca80952bf (diff)
parent50dee4f3610331cc31f1f02f9d4116b716907011 (diff)
downloadu-boot-6f1b951500707e46f2920c0034856ada018aabcb.zip
u-boot-6f1b951500707e46f2920c0034856ada018aabcb.tar.gz
u-boot-6f1b951500707e46f2920c0034856ada018aabcb.tar.bz2
Merge https://source.denx.de/u-boot/custodians/u-boot-mmcWIP/18Jul2023
-rw-r--r--drivers/mmc/mmc.c26
-rw-r--r--drivers/mmc/renesas-sdhi.c11
-rw-r--r--include/mmc.h2
3 files changed, 35 insertions, 4 deletions
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 72c1076..31cfda2 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -398,6 +398,26 @@ int mmc_send_tuning(struct mmc *mmc, u32 opcode, int *cmd_error)
}
#endif
+int mmc_send_stop_transmission(struct mmc *mmc, bool write)
+{
+ struct mmc_cmd cmd;
+
+ cmd.cmdidx = MMC_CMD_STOP_TRANSMISSION;
+ cmd.cmdarg = 0;
+ /*
+ * JEDEC Standard No. 84-B51 Page 126
+ * CMD12 STOP_TRANSMISSION R1/R1b[3]
+ * NOTE 3 R1 for read cases and R1b for write cases.
+ *
+ * Physical Layer Simplified Specification Version 9.00
+ * 7.3.1.3 Detailed Command Description
+ * CMD12 R1b
+ */
+ cmd.resp_type = (IS_SD(mmc) || write) ? MMC_RSP_R1b : MMC_RSP_R1;
+
+ return mmc_send_cmd(mmc, &cmd, NULL);
+}
+
static int mmc_read_blocks(struct mmc *mmc, void *dst, lbaint_t start,
lbaint_t blkcnt)
{
@@ -425,10 +445,7 @@ static int mmc_read_blocks(struct mmc *mmc, void *dst, lbaint_t start,
return 0;
if (blkcnt > 1) {
- cmd.cmdidx = MMC_CMD_STOP_TRANSMISSION;
- cmd.cmdarg = 0;
- cmd.resp_type = MMC_RSP_R1b;
- if (mmc_send_cmd(mmc, &cmd, NULL)) {
+ if (mmc_send_stop_transmission(mmc, false)) {
#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
pr_err("mmc fail to send stop cmd\n");
#endif
@@ -2223,6 +2240,7 @@ error:
mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_BUS_WIDTH, EXT_CSD_BUS_WIDTH_1);
mmc_select_mode(mmc, MMC_LEGACY);
+ mmc_set_clock(mmc, mmc->legacy_speed, MMC_CLK_ENABLE);
mmc_set_bus_width(mmc, 1);
}
}
diff --git a/drivers/mmc/renesas-sdhi.c b/drivers/mmc/renesas-sdhi.c
index 280d96d..8e716f7 100644
--- a/drivers/mmc/renesas-sdhi.c
+++ b/drivers/mmc/renesas-sdhi.c
@@ -611,6 +611,17 @@ int renesas_sdhi_execute_tuning(struct udevice *dev, uint opcode)
priv->smpcmp |= BIT(i);
mdelay(1);
+
+ /*
+ * eMMC specification specifies that CMD12 can be used to stop a tuning
+ * command, but SD specification does not, so do nothing unless it is
+ * eMMC.
+ */
+ if (ret && (opcode == MMC_CMD_SEND_TUNING_BLOCK_HS200)) {
+ ret = mmc_send_stop_transmission(mmc, false);
+ if (ret < 0)
+ dev_dbg(dev, "Tuning abort fail (%d)\n", ret);
+ }
}
ret = renesas_sdhi_select_tuning(priv, taps);
diff --git a/include/mmc.h b/include/mmc.h
index b8fbff1..1022db3 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -558,6 +558,8 @@ int mmc_deferred_probe(struct mmc *mmc);
int mmc_reinit(struct mmc *mmc);
int mmc_get_b_max(struct mmc *mmc, void *dst, lbaint_t blkcnt);
int mmc_hs400_prepare_ddr(struct mmc *mmc);
+int mmc_send_stop_transmission(struct mmc *mmc, bool write);
+
#else
struct mmc_ops {
int (*send_cmd)(struct mmc *mmc,