mmc.c (7382e691ca528785d9d3ca8b74c4811b4f0bfe07) | mmc.c (35f9e196f9573af4091076c19aaa6d5afeb91338) |
---|---|
1/* 2 * Copyright 2008, Freescale Semiconductor, Inc 3 * Andy Fleming 4 * 5 * Based vaguely on the Linux code 6 * 7 * SPDX-License-Identifier: GPL-2.0+ 8 */ --- 135 unchanged lines hidden (view full) --- 144{ 145 int status; 146 147 status = (cmd->response[0] & MMC_STATUS_CURR_STATE) >> 9; 148 printf("CURR STATE:%d\n", status); 149} 150#endif 151 | 1/* 2 * Copyright 2008, Freescale Semiconductor, Inc 3 * Andy Fleming 4 * 5 * Based vaguely on the Linux code 6 * 7 * SPDX-License-Identifier: GPL-2.0+ 8 */ --- 135 unchanged lines hidden (view full) --- 144{ 145 int status; 146 147 status = (cmd->response[0] & MMC_STATUS_CURR_STATE) >> 9; 148 printf("CURR STATE:%d\n", status); 149} 150#endif 151 |
152#if CONFIG_IS_ENABLED(MMC_VERBOSE) || defined(DEBUG) 153const char *mmc_mode_name(enum bus_mode mode) 154{ 155 static const char *const names[] = { 156 [MMC_LEGACY] = "MMC legacy", 157 [SD_LEGACY] = "SD Legacy", 158 [MMC_HS] = "MMC High Speed (26MHz)", 159 [SD_HS] = "SD High Speed (50MHz)", 160 [UHS_SDR12] = "UHS SDR12 (25MHz)", 161 [UHS_SDR25] = "UHS SDR25 (50MHz)", 162 [UHS_SDR50] = "UHS SDR50 (100MHz)", 163 [UHS_SDR104] = "UHS SDR104 (208MHz)", 164 [UHS_DDR50] = "UHS DDR50 (50MHz)", 165 [MMC_HS_52] = "MMC High Speed (52MHz)", 166 [MMC_DDR_52] = "MMC DDR52 (52MHz)", 167 [MMC_HS_200] = "HS200 (200MHz)", 168 }; 169 170 if (mode >= MMC_MODES_END) 171 return "Unknown mode"; 172 else 173 return names[mode]; 174} 175#endif 176 177static int mmc_select_mode(struct mmc *mmc, enum bus_mode mode) 178{ 179 mmc->selected_mode = mode; 180 debug("selecting mode %s (freq : %d MHz)\n", mmc_mode_name(mode), 181 mmc->tran_speed / 1000000); 182 return 0; 183} 184 |
|
152#if !CONFIG_IS_ENABLED(DM_MMC) 153int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data) 154{ 155 int ret; 156 157 mmmc_trace_before_send(mmc, cmd); 158 ret = mmc->cfg->ops->send_cmd(mmc, cmd, data); 159 mmmc_trace_after_send(mmc, cmd, ret); --- 973 unchanged lines hidden (view full) --- 1133 1134 mmc_set_bus_width(mmc, 4); 1135 } 1136 1137 err = sd_read_ssr(mmc); 1138 if (err) 1139 return err; 1140 | 185#if !CONFIG_IS_ENABLED(DM_MMC) 186int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data) 187{ 188 int ret; 189 190 mmmc_trace_before_send(mmc, cmd); 191 ret = mmc->cfg->ops->send_cmd(mmc, cmd, data); 192 mmmc_trace_after_send(mmc, cmd, ret); --- 973 unchanged lines hidden (view full) --- 1166 1167 mmc_set_bus_width(mmc, 4); 1168 } 1169 1170 err = sd_read_ssr(mmc); 1171 if (err) 1172 return err; 1173 |
1141 if (mmc->card_caps & MMC_MODE_HS) | 1174 if (mmc->card_caps & MMC_MODE_HS) { 1175 mmc_select_mode(mmc, SD_HS); |
1142 mmc->tran_speed = 50000000; | 1176 mmc->tran_speed = 50000000; |
1143 else | 1177 } else { 1178 mmc_select_mode(mmc, SD_LEGACY); |
1144 mmc->tran_speed = 25000000; | 1179 mmc->tran_speed = 25000000; |
1180 } |
|
1145 1146 return 0; 1147} 1148 1149/* 1150 * read the compare the part of ext csd that is constant. 1151 * This can be used to check that the transfer is working 1152 * as expected. --- 100 unchanged lines hidden (view full) --- 1253 err = mmc_read_and_compare_ext_csd(mmc); 1254 if (!err) 1255 break; 1256 } 1257 1258 if (err) 1259 return err; 1260 | 1181 1182 return 0; 1183} 1184 1185/* 1186 * read the compare the part of ext csd that is constant. 1187 * This can be used to check that the transfer is working 1188 * as expected. --- 100 unchanged lines hidden (view full) --- 1289 err = mmc_read_and_compare_ext_csd(mmc); 1290 if (!err) 1291 break; 1292 } 1293 1294 if (err) 1295 return err; 1296 |
1261 if (mmc->card_caps & MMC_MODE_HS) { 1262 if (mmc->card_caps & MMC_MODE_HS_52MHz) 1263 mmc->tran_speed = 52000000; | 1297 if (mmc->card_caps & MMC_MODE_HS_52MHz) { 1298 if (mmc->ddr_mode) 1299 mmc_select_mode(mmc, MMC_DDR_52); |
1264 else | 1300 else |
1265 mmc->tran_speed = 26000000; | 1301 mmc_select_mode(mmc, MMC_HS_52); 1302 mmc->tran_speed = 52000000; 1303 } else if (mmc->card_caps & MMC_MODE_HS) { 1304 mmc_select_mode(mmc, MMC_HS); 1305 mmc->tran_speed = 26000000; |
1266 } 1267 1268 return err; 1269} 1270 1271static int mmc_startup_v4(struct mmc *mmc) 1272{ 1273 int err, i; --- 255 unchanged lines hidden (view full) --- 1529 break; 1530 } 1531 } 1532 1533 /* divide frequency by 10, since the mults are 10x bigger */ 1534 freq = fbase[(cmd.response[0] & 0x7)]; 1535 mult = multipliers[((cmd.response[0] >> 3) & 0xf)]; 1536 | 1306 } 1307 1308 return err; 1309} 1310 1311static int mmc_startup_v4(struct mmc *mmc) 1312{ 1313 int err, i; --- 255 unchanged lines hidden (view full) --- 1569 break; 1570 } 1571 } 1572 1573 /* divide frequency by 10, since the mults are 10x bigger */ 1574 freq = fbase[(cmd.response[0] & 0x7)]; 1575 mult = multipliers[((cmd.response[0] >> 3) & 0xf)]; 1576 |
1537 mmc->tran_speed = freq * mult; | 1577 mmc->legacy_speed = freq * mult; 1578 mmc->tran_speed = mmc->legacy_speed; 1579 mmc_select_mode(mmc, MMC_LEGACY); |
1538 1539 mmc->dsr_imp = ((cmd.response[1] >> 12) & 0x1); 1540 mmc->read_bl_len = 1 << ((cmd.response[1] >> 16) & 0xf); 1541 1542 if (IS_SD(mmc)) 1543 mmc->write_bl_len = mmc->read_bl_len; 1544 else 1545 mmc->write_bl_len = 1 << ((cmd.response[3] >> 22) & 0xf); --- 409 unchanged lines hidden --- | 1580 1581 mmc->dsr_imp = ((cmd.response[1] >> 12) & 0x1); 1582 mmc->read_bl_len = 1 << ((cmd.response[1] >> 16) & 0xf); 1583 1584 if (IS_SD(mmc)) 1585 mmc->write_bl_len = mmc->read_bl_len; 1586 else 1587 mmc->write_bl_len = 1 << ((cmd.response[3] >> 22) & 0xf); --- 409 unchanged lines hidden --- |