public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] mmc: Implement card detection.
@ 2011-11-17 11:51 Thierry Reding
  2011-11-22 18:13 ` Thierry Reding
  2011-11-26  0:40 ` Andy Fleming
  0 siblings, 2 replies; 8+ messages in thread
From: Thierry Reding @ 2011-11-17 11:51 UTC (permalink / raw)
  To: u-boot

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@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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-11-29 13:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-17 11:51 [U-Boot] [PATCH] mmc: Implement card detection Thierry Reding
2011-11-22 18:13 ` Thierry Reding
2011-11-26  0:40 ` Andy Fleming
2011-11-28 17:47   ` Thierry Reding
2011-11-28 19:20     ` Andy Fleming
2011-11-29  7:02       ` Thierry Reding
2011-11-29 13:39         ` Andy Fleming
2011-11-29 13:42           ` Thierry Reding

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox