static struct list_head mmc_devices;
static int cur_dev_num = -1;
+int __board_mmc_getcd(u8 *cd, struct mmc *mmc) {
+ return -1;
+}
+
+int board_mmc_getcd(u8 *cd, struct mmc *mmc)__attribute__((weak,
+ alias("__board_mmc_getcd")));
+
int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
{
return mmc->send_cmd(mmc, cmd, data);
blklen = mmc->write_bl_len;
+ if ((start + blkcnt) > mmc->block_dev.lba) {
+ printf("MMC: block number 0x%lx exceeds max(0x%lx)",
+ start + blkcnt, mmc->block_dev.lba);
+ return 0;
+ }
err = mmc_set_blocklen(mmc, mmc->write_bl_len);
if (err) {
err = mmc_set_blocklen(mmc, mmc->read_bl_len);
if (err)
- return err;
+ goto free_buffer;
for (i = startblock; i <= endblock; i++) {
int segment_size;
if (!mmc)
return 0;
+ if ((start + blkcnt) > mmc->block_dev.lba) {
+ printf("MMC: block number 0x%lx exceeds max(0x%lx)",
+ start + blkcnt, mmc->block_dev.lba);
+ return 0;
+ }
/* We always do full block reads from the card */
err = mmc_set_blocklen(mmc, mmc->read_bl_len);
uint mult, freq;
u64 cmult, csize;
struct mmc_cmd cmd;
+ char ext_csd[512];
/* Put the Card in Identify Mode */
cmd.cmdidx = MMC_CMD_ALL_SEND_CID;
if (err)
return err;
+ 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)) {
+ mmc->capacity = ext_csd[212] << 0 | ext_csd[213] << 8 |
+ ext_csd[214] << 16 | ext_csd[215] << 24;
+ mmc->capacity *= 512;
+ }
+ }
+
if (IS_SD(mmc))
err = sd_change_freq(mmc);
else