Commit 0560db18ecd5b6f15f8bc655868d7d2316eba261

Authored by Lei Wen
Committed by Andy Fleming
1 parent 02d3ad3e19

mmc: change magic number to macro define

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>

Showing 2 changed files with 21 additions and 16 deletions Side-by-side Diff

... ... @@ -638,7 +638,7 @@
638 638 if (err)
639 639 return err;
640 640  
641   - cardtype = ext_csd[196] & 0xf;
  641 + cardtype = ext_csd[EXT_CSD_CARD_TYPE] & 0xf;
642 642  
643 643 err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING, 1);
644 644  
... ... @@ -652,7 +652,7 @@
652 652 return err;
653 653  
654 654 /* No high-speed support */
655   - if (!ext_csd[185])
  655 + if (!ext_csd[EXT_CSD_HS_TIMING])
656 656 return 0;
657 657  
658 658 /* High Speed is set, there are two types: 52MHz and 26MHz */
659 659  
... ... @@ -1006,14 +1006,16 @@
1006 1006 if (!IS_SD(mmc) && (mmc->version >= MMC_VERSION_4)) {
1007 1007 /* check ext_csd version and capacity */
1008 1008 err = mmc_send_ext_csd(mmc, ext_csd);
1009   - if (!err & (ext_csd[192] >= 2)) {
  1009 + if (!err & (ext_csd[EXT_CSD_REV] >= 2)) {
1010 1010 /*
1011 1011 * According to the JEDEC Standard, the value of
1012 1012 * ext_csd's capacity is valid if the value is more
1013 1013 * than 2GB
1014 1014 */
1015   - capacity = ext_csd[212] << 0 | ext_csd[213] << 8 |
1016   - ext_csd[214] << 16 | ext_csd[215] << 24;
  1015 + capacity = ext_csd[EXT_CSD_SEC_CNT] << 0
  1016 + | ext_csd[EXT_CSD_SEC_CNT + 1] << 8
  1017 + | ext_csd[EXT_CSD_SEC_CNT + 2] << 16
  1018 + | ext_csd[EXT_CSD_SEC_CNT + 3] << 24;
1017 1019 capacity *= 512;
1018 1020 if ((capacity >> 20) > 2 * 1024)
1019 1021 mmc->capacity = capacity;
... ... @@ -1024,8 +1026,9 @@
1024 1026 * group size from ext_csd directly, or calculate
1025 1027 * the group size from the csd value.
1026 1028 */
1027   - if (ext_csd[175])
1028   - mmc->erase_grp_size = ext_csd[224] * 512 * 1024;
  1029 + if (ext_csd[EXT_CSD_ERASE_GROUP_DEF])
  1030 + mmc->erase_grp_size =
  1031 + ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE] * 512 * 1024;
1029 1032 else {
1030 1033 int erase_gsz, erase_gmul;
1031 1034 erase_gsz = (mmc->csd[2] & 0x00007c00) >> 10;
... ... @@ -1035,8 +1038,8 @@
1035 1038 }
1036 1039  
1037 1040 /* store the partition info of emmc */
1038   - if (ext_csd[160] & PART_SUPPORT)
1039   - mmc->part_config = ext_csd[179];
  1041 + if (ext_csd[EXT_CSD_PARTITIONING_SUPPORT] & PART_SUPPORT)
  1042 + mmc->part_config = ext_csd[EXT_CSD_PART_CONF];
1040 1043 }
1041 1044  
1042 1045 if (IS_SD(mmc))
... ... @@ -145,13 +145,15 @@
145 145 /*
146 146 * EXT_CSD fields
147 147 */
148   -
149   -#define EXT_CSD_PART_CONF 179 /* R/W */
150   -#define EXT_CSD_BUS_WIDTH 183 /* R/W */
151   -#define EXT_CSD_HS_TIMING 185 /* R/W */
152   -#define EXT_CSD_CARD_TYPE 196 /* RO */
153   -#define EXT_CSD_REV 192 /* RO */
154   -#define EXT_CSD_SEC_CNT 212 /* RO, 4 bytes */
  148 +#define EXT_CSD_PARTITIONING_SUPPORT 160 /* RO */
  149 +#define EXT_CSD_ERASE_GROUP_DEF 175 /* R/W */
  150 +#define EXT_CSD_PART_CONF 179 /* R/W */
  151 +#define EXT_CSD_BUS_WIDTH 183 /* R/W */
  152 +#define EXT_CSD_HS_TIMING 185 /* R/W */
  153 +#define EXT_CSD_REV 192 /* RO */
  154 +#define EXT_CSD_CARD_TYPE 196 /* RO */
  155 +#define EXT_CSD_SEC_CNT 212 /* RO, 4 bytes */
  156 +#define EXT_CSD_HC_ERASE_GRP_SIZE 224 /* RO */
155 157  
156 158 /*
157 159 * EXT_CSD field definitions