]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - drivers/mmc/mmc.c
Merge branch 'rmobile' of git://git.denx.de/u-boot-sh
[karo-tx-uboot.git] / drivers / mmc / mmc.c
index a26f3cec20905fd900e5110128a06716597934f5..8436bc7f5d3c28eaf974efe57da48ae278e867c1 100644 (file)
@@ -594,10 +594,15 @@ int mmc_switch_part(int dev_num, unsigned int part_num)
        ret = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_PART_CONF,
                         (mmc->part_config & ~PART_ACCESS_MASK)
                         | (part_num & PART_ACCESS_MASK));
-       if (ret)
-               return ret;
 
-       return mmc_set_capacity(mmc, part_num);
+       /*
+        * Set the capacity if the switch succeeded or was intended
+        * to return to representing the raw device.
+        */
+       if ((ret == 0) || ((ret == -ENODEV) && (part_num == 0)))
+               ret = mmc_set_capacity(mmc, part_num);
+
+       return ret;
 }
 
 int mmc_getcd(struct mmc *mmc)
@@ -1010,6 +1015,8 @@ static int mmc_startup(struct mmc *mmc)
 
                        if (err)
                                return err;
+                       else
+                               ext_csd[EXT_CSD_ERASE_GROUP_DEF] = 1;
 
                        /* Read out group size from ext_csd */
                        mmc->erase_grp_size =
@@ -1127,10 +1134,11 @@ static int mmc_startup(struct mmc *mmc)
                        mmc_set_bus_width(mmc, widths[idx]);
 
                        err = mmc_send_ext_csd(mmc, test_csd);
+                       /* Only compare read only fields */
                        if (!err && ext_csd[EXT_CSD_PARTITIONING_SUPPORT] \
                                    == test_csd[EXT_CSD_PARTITIONING_SUPPORT]
-                                && ext_csd[EXT_CSD_ERASE_GROUP_DEF] \
-                                   == test_csd[EXT_CSD_ERASE_GROUP_DEF] \
+                                && ext_csd[EXT_CSD_HC_WP_GRP_SIZE] \
+                                   == test_csd[EXT_CSD_HC_WP_GRP_SIZE] \
                                 && ext_csd[EXT_CSD_REV] \
                                    == test_csd[EXT_CSD_REV]
                                 && ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE] \
@@ -1269,6 +1277,11 @@ block_dev_desc_t *mmc_get_dev(int dev)
 }
 #endif
 
+/* board-specific MMC power initializations. */
+__weak void board_mmc_power_init(void)
+{
+}
+
 int mmc_start_init(struct mmc *mmc)
 {
        int err;
@@ -1285,6 +1298,8 @@ int mmc_start_init(struct mmc *mmc)
        if (mmc->has_init)
                return 0;
 
+       board_mmc_power_init();
+
        /* made sure it's not NULL earlier */
        err = mmc->cfg->ops->init(mmc);