Skip to contentSkip to conversation

mmc: do HW reset if eMMC card occurs timeout error

PATCH In review Chuanxiao Dong 1 participant 1 message Dec 27, 2010 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

PATCH v6 2/3 mmc: do HW reset if eMMC card occurs timeout error

Two new callbacks were added in mmc_bus_ops to implement this.
hwreset_emmc: trigger a RST_n signal for host to reset card.
reinit_emmc: reinitialize eMMC card after hardware reset occurs.

MMC core layer will check whether occurs a timeout error in the new added function mmc_handle_timeout_error.

---
 drivers/mmc/card/block.c |   10 +++++++++
 drivers/mmc/core/core.c  |   48 ++++++++++++++++++++++++++++++++++++++++++++++
 drivers/mmc/core/core.h  |   26 ++++++++++++++++++++++++
 include/linux/mmc/core.h |    1 +
 4 files changed, 85 insertions(+), 0 deletions(-)
drivers/mmc/card/block.c +10 -0
index 217f820..ba9614d 100644
@@ -424,6 +424,16 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *req)
 
 		mmc_wait_for_req(card->host, &brq.mrq);
 
+		/* Check if need to do HW reset */
+		if (brq.cmd.error)
+			mmc_handle_timeout_error(card->host, brq.cmd.error);
+
+		if (brq.data.error)
+			mmc_handle_timeout_error(card->host, brq.data.error);
+
+		if (brq.stop.error)
+			mmc_handle_timeout_error(card->host, brq.stop.error);
+
 		mmc_queue_bounce_post(mq);
 
 		/*
drivers/mmc/core/core.c +48 -0

60 lines not on this page · raw message

drivers/mmc/core/core.h +26 -0
index 026c975..09b6c54 100644
@@ -24,6 +24,32 @@ struct mmc_bus_ops {
 	int (*resume)(struct mmc_host *);
 	int (*power_save)(struct mmc_host *);
 	int (*power_restore)(struct mmc_host *);
+	/*
+	 * New added callback
+	 * This function is used to reinitialize eMMC card after eMMC card been
+	 * reset.
+	 *
+	 * Note 1: before calling this, mmc_claim_host is needed. After finish
+	 * this calling, mmc_release_host is needed.
+	 *
+	 * return value:
+	 * 0 - successfully reinit card
+	 * other - failed to reinit
+	 */
+	int (*reinit_emmc)(struct mmc_host *);
+	/*
+	 * New added callback
+	 * This function is used to trigger RST_n signal to reset eMMC card as
+	 * eMMC4.4 spec recommended.
+	 *
+	 * Note 1: this function may sleep since delay is needed when pull
+	 * up/down GPIO line.
+	 *
+	 * return value:
+	 * 0 - successfully reset eMMC card
+	 * other - failed to reset eMMC card
+	 */
+	int (*hwreset_emmc)(struct mmc_host *);
 };
 
 void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops);
include/linux/mmc/core.h +1 -0
index 64e013f..115d589 100644
@@ -131,6 +131,7 @@ struct mmc_request {
 struct mmc_host;
 struct mmc_card;
 
+extern void mmc_handle_timeout_error(struct mmc_host *, int);
 extern void mmc_wait_for_req(struct mmc_host *, struct mmc_request *);
 extern int mmc_wait_for_cmd(struct mmc_host *, struct mmc_command *, int);
 extern int mmc_wait_for_app_cmd(struct mmc_host *, struct mmc_card *,
Signature · 1 line
1.6.6.1