From 54019a35b817976793903f0030108148631aaace Mon Sep 17 00:00:00 2001 From: Yann Gautier Date: Fri, 12 Jun 2020 14:14:26 +0200 Subject: [PATCH] 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 --- drivers/st/mmc/stm32_sdmmc2.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/st/mmc/stm32_sdmmc2.c b/drivers/st/mmc/stm32_sdmmc2.c index 2a8a4afc6..cff3a344f 100644 --- a/drivers/st/mmc/stm32_sdmmc2.c +++ b/drivers/st/mmc/stm32_sdmmc2.c @@ -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); } -- 2.39.5