From f9516d9db115e5067079f823d2c4ad9938bd174e Mon Sep 17 00:00:00 2001 From: William Qiu Date: Mon, 17 Jul 2023 14:45:18 +0800 Subject: mmc: starfive: fix mmc device power-up sequence fix mmc device power-up sequence. Signed-off-by: William Qiu --- drivers/mmc/dw_mmc.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'drivers/mmc') diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c index a6e50366dc..b3b69fabd4 100644 --- a/drivers/mmc/dw_mmc.c +++ b/drivers/mmc/dw_mmc.c @@ -21,6 +21,19 @@ #define PAGE_SIZE 4096 +static inline int __test_and_clear_bit_1(int nr, void *addr) +{ + int mask, retval; + unsigned int *a = (unsigned int *)addr; + + a += nr >> 5; + mask = 1 << (nr & 0x1f); + retval = (mask & *a) != 0; + *a &= ~mask; + + return retval; +} + static int dwmci_wait_reset(struct dwmci_host *host, u32 value) { unsigned long timeout = 1000; @@ -317,6 +330,9 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, if (cmd->resp_type & MMC_RSP_CRC) flags |= DWMCI_CMD_CHECK_CRC; + if (__test_and_clear_bit_1(DW_MMC_CARD_NEED_INIT, &host->flags)) + flags |= DWMCI_CMD_SEND_INIT; + flags |= (cmd->cmdidx | DWMCI_CMD_START | DWMCI_CMD_USE_HOLD_REG); debug("Sending CMD%d\n",cmd->cmdidx); @@ -594,6 +610,8 @@ static int dwmci_init(struct mmc *mmc) return -EIO; } + host->flags = 1 << DW_MMC_CARD_NEED_INIT; + /* Enumerate at 400KHz */ dwmci_setup_bus(host, mmc->cfg->f_min); -- cgit v1.2.3