]> git.sur5r.net Git - u-boot/blobdiff - drivers/mmc/mmc.c
mmc: Implement card detection.
[u-boot] / drivers / mmc / mmc.c
index 11c6aa67c16bbe812c58c681044929fb1c2410f1..6db37b1fc548a49be870d06f4737e5b799e6db76 100644 (file)
@@ -674,6 +674,18 @@ int mmc_switch_part(int dev_num, unsigned int part_num)
                          | (part_num & PART_ACCESS_MASK));
 }
 
+int mmc_getcd(struct mmc *mmc)
+{
+       int cd;
+
+       cd = board_mmc_getcd(mmc);
+
+       if ((cd < 0) && mmc->getcd)
+               cd = mmc->getcd(mmc);
+
+       return cd;
+}
+
 int sd_switch(struct mmc *mmc, int mode, int group, u8 value, u8 *resp)
 {
        struct mmc_cmd cmd;
@@ -1202,6 +1214,12 @@ int mmc_init(struct mmc *mmc)
 {
        int err;
 
+       if (mmc_getcd(mmc) == 0) {
+               mmc->has_init = 0;
+               printf("MMC: no card present\n");
+               return NO_CARD_ERR;
+       }
+
        if (mmc->has_init)
                return 0;