[PATCH v2 3/3] mmc: renesas-sdhi: Send stop when MMC tuning command fails

Marek Vasut marek.vasut+renesas at mailbox.org
Wed Jun 14 15:42:37 CEST 2023


From: Hai Pham <hai.pham.ud at renesas.com>

When tuning command (CMD21) fails with command error, call
mmc_send_stop_transmission() to send stop command (CMD12).

Reviewed-by: Takeshi Kihara <takeshi.kihara.df at renesas.com>
Reviewed-by: Marek Vasut <marek.vasut+renesas at mailbox.org>
Signed-off-by: Hai Pham <hai.pham.ud at renesas.com>
Signed-off-by: Marek Vasut <marek.vasut+renesas at mailbox.org>
[Marek: Add dev_dbg() message in case tuning abort fails
        Move tuning opcode check from mmc_abort_tuning()]
---
V2: Update on previous patch changes
---
Cc: "Ying-Chun Liu (PaulLiu)" <paul.liu at linaro.org>
Cc: Hai Pham <hai.pham.ud at renesas.com>
Cc: Jaehoon Chung <jh80.chung at samsung.com>
Cc: Loic Poulain <loic.poulain at linaro.org>
Cc: Peng Fan <peng.fan at nxp.com>
Cc: Simon Glass <sjg at chromium.org>
Cc: Takeshi Kihara <takeshi.kihara.df at renesas.com>
---
 drivers/mmc/renesas-sdhi.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/mmc/renesas-sdhi.c b/drivers/mmc/renesas-sdhi.c
index 280d96dbc2d..484712b919e 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, true);
+			if (ret < 0)
+				dev_dbg(dev, "Tuning abort fail (%d)\n", ret);
+		}
 	}
 
 	ret = renesas_sdhi_select_tuning(priv, taps);
-- 
2.39.2



More information about the U-Boot mailing list