mmc: avoid reading ext_csd several times

Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Change-Id: Iaf952a4721ea74a1fa55da9f1a3eece5cdcd2c0c
This commit is contained in:
Jason Zhu 2020-02-17 11:30:11 +08:00 committed by jason.zhu
parent 1f250d0a05
commit e531136ec7
1 changed files with 11 additions and 0 deletions

View File

@ -30,6 +30,8 @@ static const unsigned int sd_au_size[] = {
SZ_16M / 512, (SZ_16M + SZ_8M) / 512, SZ_32M / 512, SZ_64M / 512,
};
static char mmc_ext_csd[512];
#if CONFIG_IS_ENABLED(MMC_TINY)
static struct mmc mmc_static;
struct mmc *find_mmc_device(int dev_num)
@ -543,10 +545,18 @@ static int mmc_complete_op_cond(struct mmc *mmc)
static int mmc_send_ext_csd(struct mmc *mmc, u8 *ext_csd)
{
static int initialized;
struct mmc_cmd cmd;
struct mmc_data data;
int err;
if (initialized) {
memcpy(ext_csd, mmc_ext_csd, 512);
return 0;
}
initialized = 1;
/* Get the Card Status Register */
cmd.cmdidx = MMC_CMD_SEND_EXT_CSD;
cmd.resp_type = MMC_RSP_R1;
@ -558,6 +568,7 @@ static int mmc_send_ext_csd(struct mmc *mmc, u8 *ext_csd)
data.flags = MMC_DATA_READ;
err = mmc_send_cmd(mmc, &cmd, &data);
memcpy(mmc_ext_csd, ext_csd, 512);
return err;
}