From 7ca3aec97eed6b27e76df7fa6bd4e173b2a21863 Mon Sep 17 00:00:00 2001 From: Daniel DeGrasse Date: Mon, 15 Aug 2022 15:03:37 -0500 Subject: [PATCH] drivers: sdhc: imx_usdhc: Initialize card clock with CMD0 Use CMD0 to detect card initialization, rather than using card power on. Signed-off-by: Daniel DeGrasse --- drivers/sdhc/imx_usdhc.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/sdhc/imx_usdhc.c b/drivers/sdhc/imx_usdhc.c index 186072fab6b..8ae8fa9741f 100644 --- a/drivers/sdhc/imx_usdhc.c +++ b/drivers/sdhc/imx_usdhc.c @@ -386,16 +386,10 @@ static int imx_usdhc_set_io(const struct device *dev, struct sdhc_io *ios) /* Set card power */ if ((host_io->power_mode != ios->power_mode) && (cfg->pwr_gpio.port)) { - if (host_io->power_mode == SDHC_POWER_ON) { - /* Send 74 clock cycles if SD card is just powering on */ - USDHC_SetCardActive(cfg->base, 0xFFFF); - } - if (cfg->pwr_gpio.port) { - if (ios->power_mode == SDHC_POWER_OFF) { - gpio_pin_set_dt(&cfg->pwr_gpio, 0); - } else if (ios->power_mode == SDHC_POWER_ON) { - gpio_pin_set_dt(&cfg->pwr_gpio, 1); - } + if (ios->power_mode == SDHC_POWER_OFF) { + gpio_pin_set_dt(&cfg->pwr_gpio, 0); + } else if (ios->power_mode == SDHC_POWER_ON) { + gpio_pin_set_dt(&cfg->pwr_gpio, 1); } host_io->power_mode = ios->power_mode; } @@ -646,6 +640,10 @@ static int imx_usdhc_request(const struct device *dev, struct sdhc_command *cmd, int ret = 0; int retries = (int)cmd->retries; + if (cmd->opcode == SD_GO_IDLE_STATE) { + USDHC_SetCardActive(cfg->base, 0xFFFF); + } + host_cmd.index = cmd->opcode; host_cmd.argument = cmd->arg; /* Mask out part of response type field used for SPI commands */