From 34a50e313d36ef04d083313aa1a7fdeaea4205dd Mon Sep 17 00:00:00 2001 From: Erwan Gouriou Date: Wed, 3 Nov 2021 11:26:24 +0100 Subject: [PATCH] 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 --- drivers/disk/sdmmc_stm32.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/disk/sdmmc_stm32.c b/drivers/disk/sdmmc_stm32.c index ca2e3f966a2..e33d6464df6 100644 --- a/drivers/disk/sdmmc_stm32.c +++ b/drivers/disk/sdmmc_stm32.c @@ -51,6 +51,15 @@ struct stm32_sdmmc_priv { } 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 @@ static int stm32_sdmmc_access_init(struct disk_info *disk) return -EIO; } +#ifdef CONFIG_SDMMC_STM32_HWFC + stm32_sdmmc_fc_enable(priv); +#endif + priv->status = DISK_STATUS_OK; return 0; } @@ -287,15 +300,6 @@ static struct disk_info stm32_sdmmc_info = { .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 @@ static int disk_stm32_sdmmc_init(const struct device *dev) 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;