[U-Boot] [PATCH] mmc: Implement card detection.

Thierry Reding thierry.reding at avionic-design.de
Thu Nov 17 12:51:27 CET 2011


Check for board-specific card detect each time an MMC/SD device is
initialized. If card detection is not implemented, this code behaves as
before and continues assuming a card is present. If no card is detected,
has_init is reset for the MMC/SD device (to force initialization next
time) and an error is returned.

Signed-off-by: Thierry Reding <thierry.reding at avionic-design.de>
---
 drivers/mmc/mmc.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 37ce6e8..d18c095 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1191,6 +1191,15 @@ block_dev_desc_t *mmc_get_dev(int dev)
 int mmc_init(struct mmc *mmc)
 {
 	int err, retry = 3;
+	u8 card_detect = 0;
+
+	if (board_mmc_getcd(&card_detect, mmc) == 0) {
+		if (!card_detect) {
+			mmc->has_init = 0;
+			printf("MMC: no card present\n");
+			return NO_CARD_ERR;
+		}
+	}
 
 	if (mmc->has_init)
 		return 0;
-- 
1.7.7.3



More information about the U-Boot mailing list