diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 541781328a..de3f569da1 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,19 +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; - /* - * 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) ? MMC_RSP_R1b : MMC_RSP_R1; - 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 diff --git a/include/mmc.h b/include/mmc.h index b8fbff150d..1022db3ffa 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,