]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
mmc: change magic number to macro define
authorLei Wen <leiwen@marvell.com>
Mon, 3 Oct 2011 20:35:10 +0000 (20:35 +0000)
committerAndy Fleming <afleming@freescale.com>
Thu, 3 Nov 2011 07:14:58 +0000 (02:14 -0500)
Previous magic number is hard to parse its meaning, change it to
respective macro definition

Signed-off-by: Lei Wen <leiwen@marvell.com>
Acked-by: WOlfgang Denk <wd@denx.de>
drivers/mmc/mmc.c
include/mmc.h

index 3f596875360ed1e7b42d06473d8e193647062c21..ac26db1d5bb2849bd0f26d9d1b7fbe4e9ccd6d91 100644 (file)
@@ -638,7 +638,7 @@ int mmc_change_freq(struct mmc *mmc)
        if (err)
                return err;
 
-       cardtype = ext_csd[196] & 0xf;
+       cardtype = ext_csd[EXT_CSD_CARD_TYPE] & 0xf;
 
        err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING, 1);
 
@@ -652,7 +652,7 @@ int mmc_change_freq(struct mmc *mmc)
                return err;
 
        /* No high-speed support */
-       if (!ext_csd[185])
+       if (!ext_csd[EXT_CSD_HS_TIMING])
                return 0;
 
        /* High Speed is set, there are two types: 52MHz and 26MHz */
@@ -1006,14 +1006,16 @@ int mmc_startup(struct mmc *mmc)
        if (!IS_SD(mmc) && (mmc->version >= MMC_VERSION_4)) {
                /* check  ext_csd version and capacity */
                err = mmc_send_ext_csd(mmc, ext_csd);
-               if (!err & (ext_csd[192] >= 2)) {
+               if (!err & (ext_csd[EXT_CSD_REV] >= 2)) {
                        /*
                         * According to the JEDEC Standard, the value of
                         * ext_csd's capacity is valid if the value is more
                         * than 2GB
                         */
-                       capacity = ext_csd[212] << 0 | ext_csd[213] << 8 |
-                                  ext_csd[214] << 16 | ext_csd[215] << 24;
+                       capacity = ext_csd[EXT_CSD_SEC_CNT] << 0
+                                       | ext_csd[EXT_CSD_SEC_CNT + 1] << 8
+                                       | ext_csd[EXT_CSD_SEC_CNT + 2] << 16
+                                       | ext_csd[EXT_CSD_SEC_CNT + 3] << 24;
                        capacity *= 512;
                        if ((capacity >> 20) > 2 * 1024)
                                mmc->capacity = capacity;
@@ -1024,8 +1026,9 @@ int mmc_startup(struct mmc *mmc)
                 * group size from ext_csd directly, or calculate
                 * the group size from the csd value.
                 */
-               if (ext_csd[175])
-                       mmc->erase_grp_size = ext_csd[224] * 512 * 1024;
+               if (ext_csd[EXT_CSD_ERASE_GROUP_DEF])
+                       mmc->erase_grp_size =
+                             ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE] * 512 * 1024;
                else {
                        int erase_gsz, erase_gmul;
                        erase_gsz = (mmc->csd[2] & 0x00007c00) >> 10;
@@ -1035,8 +1038,8 @@ int mmc_startup(struct mmc *mmc)
                }
 
                /* store the partition info of emmc */
-               if (ext_csd[160] & PART_SUPPORT)
-                       mmc->part_config = ext_csd[179];
+               if (ext_csd[EXT_CSD_PARTITIONING_SUPPORT] & PART_SUPPORT)
+                       mmc->part_config = ext_csd[EXT_CSD_PART_CONF];
        }
 
        if (IS_SD(mmc))
index 53aff9b4b485005006254c3c6eeee127da93a230..015a7f36ae91d04da9bcc66ab8029b0deeaf781d 100644 (file)
 /*
  * EXT_CSD fields
  */
-
-#define EXT_CSD_PART_CONF      179     /* R/W */
-#define EXT_CSD_BUS_WIDTH      183     /* R/W */
-#define EXT_CSD_HS_TIMING      185     /* R/W */
-#define EXT_CSD_CARD_TYPE      196     /* RO */
-#define EXT_CSD_REV            192     /* RO */
-#define EXT_CSD_SEC_CNT                212     /* RO, 4 bytes */
+#define EXT_CSD_PARTITIONING_SUPPORT   160     /* RO */
+#define EXT_CSD_ERASE_GROUP_DEF                175     /* R/W */
+#define EXT_CSD_PART_CONF              179     /* R/W */
+#define EXT_CSD_BUS_WIDTH              183     /* R/W */
+#define EXT_CSD_HS_TIMING              185     /* R/W */
+#define EXT_CSD_REV                    192     /* RO */
+#define EXT_CSD_CARD_TYPE              196     /* RO */
+#define EXT_CSD_SEC_CNT                        212     /* RO, 4 bytes */
+#define EXT_CSD_HC_ERASE_GRP_SIZE      224     /* RO */
 
 /*
  * EXT_CSD field definitions