mmc: st: clear some flags before sending a command

The ICR static flags are cleared before sending a command.
The SDMMC_DCTRLR register is set to 0 if no data is expected on a given
command or on the next command in case of CMD55.

Change-Id: I5ae172a484218f53160e98b3684967c6960475a6
Signed-off-by: Yann Gautier <yann.gautier@st.com>
This commit is contained in:
Yann Gautier 2020-06-12 14:14:26 +02:00
parent 7d8e1218c2
commit 54019a35b8
1 changed files with 12 additions and 0 deletions

View File

@ -258,6 +258,18 @@ static int stm32_sdmmc2_send_cmd_req(struct mmc_cmd *cmd)
break;
}
mmio_write_32(base + SDMMC_ICR, SDMMC_STATIC_FLAGS);
/*
* Clear the SDMMC_DCTRLR if the command does not await data.
* Skip CMD55 as the next command could be data related, and
* the register could have been set in prepare function.
*/
if (((cmd_reg & SDMMC_CMDR_CMDTRANS) == 0U) &&
(cmd->cmd_idx != MMC_CMD(55))) {
mmio_write_32(base + SDMMC_DCTRLR, 0U);
}
if ((cmd->resp_type & MMC_RSP_BUSY) != 0U) {
mmio_write_32(base + SDMMC_DTIMER, UINT32_MAX);
}