drivers/disk: sdmmc: stm32: Enable hw fc only after card init
During SDMMC card init, HW_FC is disabled by default, overwriting
driver configuration.
To avoid this, move HW FC configuration after card init.
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
diff --git a/drivers/disk/sdmmc_stm32.c b/drivers/disk/sdmmc_stm32.c
index ca2e3f9..e33d646 100644
--- a/drivers/disk/sdmmc_stm32.c
+++ b/drivers/disk/sdmmc_stm32.c
@@ -51,6 +51,15 @@
} pinctrl;
};
+#ifdef CONFIG_SDMMC_STM32_HWFC
+static void stm32_sdmmc_fc_enable(struct stm32_sdmmc_priv *priv)
+{
+ MMC_TypeDef *sdmmcx = priv->hsd.Instance;
+
+ sdmmcx->CLKCR |= SDMMC_CLKCR_HWFC_EN;
+}
+#endif
+
static void stm32_sdmmc_isr(const struct device *dev)
{
struct stm32_sdmmc_priv *priv = dev->data;
@@ -154,6 +163,10 @@
return -EIO;
}
+#ifdef CONFIG_SDMMC_STM32_HWFC
+ stm32_sdmmc_fc_enable(priv);
+#endif
+
priv->status = DISK_STATUS_OK;
return 0;
}
@@ -287,15 +300,6 @@
.ops = &stm32_sdmmc_ops,
};
-#ifdef CONFIG_SDMMC_STM32_HWFC
-static void stm32_sdmmc_fc_enable(struct stm32_sdmmc_priv *priv)
-{
- MMC_TypeDef *sdmmcx = priv->hsd.Instance;
-
- sdmmcx->CLKCR |= SDMMC_CLKCR_HWFC_EN;
-}
-#endif
-
/*
* Check if the card is present or not. If no card detect gpio is set, assume
* the card is present. If reading the gpio fails for some reason, assume the
@@ -453,10 +457,6 @@
k_sem_init(&priv->thread_lock, 1, 1);
k_sem_init(&priv->sync, 0, 1);
-#ifdef CONFIG_SDMMC_STM32_HWFC
- stm32_sdmmc_fc_enable(priv);
-#endif
-
err = stm32_sdmmc_card_detect_init(priv);
if (err) {
return err;