Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions arch/arm/src/stm32f7/stm32_sdmmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,18 @@
# undef CONFIG_CONFIG_STM32F7_SDMMC_XFRDEBUG
#endif

#ifdef CONFIG_SDMMC1_SDIO_PULLUP
# define SDMMC1_SDIO_PULL(g) (((g) & ~GPIO_PUPD_MASK) | GPIO_PULLUP)
#else
# define SDMMC1_SDIO_PULL(g) (((g) & ~GPIO_PUPD_MASK) | GPIO_FLOAT)
#endif

#ifdef CONFIG_SDMMC2_SDIO_PULLUP
# define SDMMC2_SDIO_PULL(g) (((g) & ~GPIO_PUPD_MASK) | GPIO_PULLUP)
#else
# define SDMMC2_SDIO_PULL(g) (((g) & ~GPIO_PUPD_MASK) | GPIO_FLOAT)
#endif

/* Friendly CLKCR bit re-definitions ****************************************/

#define STM32_CLKCR_RISINGEDGE (0)
Expand Down Expand Up @@ -423,7 +435,6 @@ struct stm32_dev_s

/* Misc */

uint32_t pullup; /* GPIO pull-up option */
uint32_t blocksize; /* Current block size */
};

Expand Down Expand Up @@ -640,7 +651,7 @@ struct stm32_dev_s g_sdmmcdev1 =
.base = STM32_SDMMC1_BASE,
.nirq = STM32_IRQ_SDMMC1,
#ifdef CONFIG_MMCSD_SDIOWAIT_WRCOMPLETE
.d0_gpio = GPIO_SDMMC1_D0,
.d0_gpio = SDMMC1_SDIO_PULL(GPIO_SDMMC1_D0),
#endif
#ifdef CONFIG_STM32F7_SDMMC1_DMAPRIO
.dmapri = CONFIG_STM32F7_SDMMC1_DMAPRIO,
Expand All @@ -654,12 +665,6 @@ struct stm32_dev_s g_sdmmcdev1 =
#endif
.do_sdio_card = NULL,
#endif

#ifdef CONFIG_SDMMC1_SDIO_PULLUP
.pullup = GPIO_PULLUP,
#else
.pullup = 0,
#endif
};
#endif

Expand Down Expand Up @@ -708,7 +713,7 @@ struct stm32_dev_s g_sdmmcdev2 =
.base = STM32_SDMMC2_BASE,
.nirq = STM32_IRQ_SDMMC2,
#ifdef CONFIG_MMCSD_SDIOWAIT_WRCOMPLETE
.d0_gpio = GPIO_SDMMC2_D0,
.d0_gpio = SDMMC2_SDIO_PULL(GPIO_SDMMC2_D0),
#endif
#ifdef CONFIG_STM32F7_SDMMC2_DMAPRIO
.dmapri = CONFIG_STM32F7_SDMMC2_DMAPRIO,
Expand All @@ -722,12 +727,6 @@ struct stm32_dev_s g_sdmmcdev2 =
#endif
.do_sdio_card = NULL,
#endif

#ifdef CONFIG_SDMMC2_SDIO_PULLUP
.pullup = GPIO_PULLUP,
#else
.pullup = 0,
#endif
};
#endif
/* Register logging support */
Expand Down Expand Up @@ -899,8 +898,9 @@ static void stm32_configwaitints(struct stm32_dev_s *priv, uint32_t waitmask,

waitmask &= ~SDIOWAIT_WRCOMPLETE;

pinset = priv->d0_gpio & (GPIO_PORT_MASK | GPIO_PIN_MASK);
pinset |= (GPIO_INPUT | GPIO_FLOAT | GPIO_EXTI);
pinset = priv->d0_gpio & (GPIO_PORT_MASK | GPIO_PIN_MASK | \
GPIO_PUPD_MASK);
pinset |= (GPIO_INPUT | GPIO_EXTI);

/* Arm the SDMMC_D Ready and install Isr */

Expand Down Expand Up @@ -3425,14 +3425,14 @@ FAR struct sdio_dev_s *sdio_initialize(int slotno)
*/

# ifndef CONFIG_SDIO_MUXBUS
stm32_configgpio(GPIO_SDMMC1_D0 | priv->pullup);
stm32_configgpio(SDMMC1_SDIO_PULL(GPIO_SDMMC1_D0));
# ifndef CONFIG_SDMMC1_WIDTH_D1_ONLY
stm32_configgpio(GPIO_SDMMC1_D1 | priv->pullup);
stm32_configgpio(GPIO_SDMMC1_D2 | priv->pullup);
stm32_configgpio(GPIO_SDMMC1_D3 | priv->pullup);
stm32_configgpio(SDMMC1_SDIO_PULL(GPIO_SDMMC1_D1));
stm32_configgpio(SDMMC1_SDIO_PULL(GPIO_SDMMC1_D2));
stm32_configgpio(SDMMC1_SDIO_PULL(GPIO_SDMMC1_D3));
# endif
stm32_configgpio(GPIO_SDMMC1_CK);
stm32_configgpio(GPIO_SDMMC1_CMD | priv->pullup);
stm32_configgpio(SDMMC1_SDIO_PULL(GPIO_SDMMC1_CMD));
# endif
}
else
Expand Down Expand Up @@ -3462,14 +3462,14 @@ FAR struct sdio_dev_s *sdio_initialize(int slotno)
*/

# ifndef CONFIG_SDIO_MUXBUS
stm32_configgpio(GPIO_SDMMC2_D0 | priv->pullup);
stm32_configgpio(SDMMC2_SDIO_PULL(GPIO_SDMMC2_D0));
# ifndef CONFIG_SDMMC2_WIDTH_D1_ONLY
stm32_configgpio(GPIO_SDMMC2_D1 | priv->pullup);
stm32_configgpio(GPIO_SDMMC2_D2 | priv->pullup);
stm32_configgpio(GPIO_SDMMC2_D3 | priv->pullup);
stm32_configgpio(SDMMC2_SDIO_PULL(GPIO_SDMMC2_D1));
stm32_configgpio(SDMMC2_SDIO_PULL(GPIO_SDMMC2_D2));
stm32_configgpio(SDMMC2_SDIO_PULL(GPIO_SDMMC2_D3));
# endif
stm32_configgpio(GPIO_SDMMC2_CK);
stm32_configgpio(GPIO_SDMMC2_CMD | priv->pullup);
stm32_configgpio(SDMMC2_SDIO_PULL(GPIO_SDMMC2_CMD));
# endif
}
else
Expand Down
50 changes: 29 additions & 21 deletions arch/arm/src/stm32h7/stm32_sdmmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,18 @@
# undef CONFIG_CONFIG_STM32H7_SDMMC_XFRDEBUG
#endif

#ifdef CONFIG_SDMMC1_SDIO_PULLUP
# define SDMMC1_SDIO_PULL(g) (((g) & ~GPIO_PUPD_MASK) | GPIO_PULLUP)
#else
# define SDMMC1_SDIO_PULL(g) (((g) & ~GPIO_PUPD_MASK) | GPIO_FLOAT)
#endif

#ifdef CONFIG_SDMMC2_SDIO_PULLUP
# define SDMMC2_SDIO_PULL(g) (((g) & ~GPIO_PUPD_MASK) | GPIO_PULLUP)
#else
# define SDMMC2_SDIO_PULL(g) (((g) & ~GPIO_PUPD_MASK) | GPIO_FLOAT)
#endif

/* Define the Hardware FIFO size */

#define FIFO_SIZE_IN_BYTES 64
Expand Down Expand Up @@ -342,7 +354,6 @@ struct stm32_dev_s

/* Misc */

uint32_t pullup; /* GPIO pull-up option */
uint32_t blocksize; /* Current block size */
uint32_t receivecnt; /* Real count to receive */
#if !defined(CONFIG_STM32H7_SDMMC_IDMA)
Expand Down Expand Up @@ -552,14 +563,11 @@ struct stm32_dev_s g_sdmmcdev1 =
.base = STM32_SDMMC1_BASE,
.nirq = STM32_IRQ_SDMMC1,
#if defined(CONFIG_MMCSD_SDIOWAIT_WRCOMPLETE)
.d0_gpio = GPIO_SDMMC1_D0,
.d0_gpio = SDMMC1_SDIO_PULL(GPIO_SDMMC1_D0),
#endif
#if defined(HAVE_SDMMC_SDIO_MODE) && defined(CONFIG_SDMMC1_SDIO_MODE)
.sdiomode = true,
#endif
#if defined(CONFIG_SDMMC1_SDIO_PULLUP)
.pullup = GPIO_PULLUP,
#endif
};
#endif
#if defined(CONFIG_STM32H7_SDMMC2)
Expand Down Expand Up @@ -607,14 +615,11 @@ struct stm32_dev_s g_sdmmcdev2 =
.base = STM32_SDMMC2_BASE,
.nirq = STM32_IRQ_SDMMC2,
#if defined(CONFIG_MMCSD_SDIOWAIT_WRCOMPLETE)
.d0_gpio = GPIO_SDMMC2_D0,
.d0_gpio = SDMMC2_SDIO_PULL(GPIO_SDMMC2_D0),
#endif
#if defined(HAVE_SDMMC_SDIO_MODE) && defined(CONFIG_SDMMC2_SDIO_MODE)
.sdiomode = true,
#endif
#if defined(CONFIG_SDMMC2_SDIO_PULLUP)
.pullup = GPIO_PULLUP,
#endif
};
#endif
/* Register logging support */
Expand Down Expand Up @@ -775,6 +780,7 @@ static void stm32_configwaitints(struct stm32_dev_s *priv, uint32_t waitmask,
/* Save all of the data and set the new interrupt mask in one, atomic
* operation.
*/

flags = enter_critical_section();

#if defined(CONFIG_MMCSD_SDIOWAIT_WRCOMPLETE)
Expand All @@ -784,8 +790,9 @@ static void stm32_configwaitints(struct stm32_dev_s *priv, uint32_t waitmask,

waitmask &= ~SDIOWAIT_WRCOMPLETE;

pinset = priv->d0_gpio & (GPIO_PORT_MASK | GPIO_PIN_MASK);
pinset |= (GPIO_INPUT | GPIO_FLOAT | GPIO_EXTI);
pinset = priv->d0_gpio & (GPIO_PORT_MASK | GPIO_PIN_MASK | \
GPIO_PUPD_MASK);
pinset |= (GPIO_INPUT | GPIO_EXTI);

/* Arm the SDMMC_D Ready and install Isr */

Expand Down Expand Up @@ -1424,6 +1431,7 @@ static void stm32_endtransfer(struct stm32_dev_s *priv,
* None
*
****************************************************************************/

#if !defined(CONFIG_STM32H7_SDMMC_IDMA)
static void stm32_sdmmc_fifo_monitor(FAR void *arg)
{
Expand Down Expand Up @@ -3295,14 +3303,14 @@ FAR struct sdio_dev_s *sdio_initialize(int slotno)
*/

# ifndef CONFIG_SDIO_MUXBUS
stm32_configgpio(GPIO_SDMMC1_D0 | priv->pullup);
stm32_configgpio(SDMMC1_SDIO_PULL(GPIO_SDMMC1_D0));
# ifndef CONFIG_SDMMC1_WIDTH_D1_ONLY
stm32_configgpio(GPIO_SDMMC1_D1 | priv->pullup);
stm32_configgpio(GPIO_SDMMC1_D2 | priv->pullup);
stm32_configgpio(GPIO_SDMMC1_D3 | priv->pullup);
stm32_configgpio(SDMMC1_SDIO_PULL(GPIO_SDMMC1_D1));
stm32_configgpio(SDMMC1_SDIO_PULL(GPIO_SDMMC1_D2));
stm32_configgpio(SDMMC1_SDIO_PULL(GPIO_SDMMC1_D3));
# endif
stm32_configgpio(GPIO_SDMMC1_CK);
stm32_configgpio(GPIO_SDMMC1_CMD | priv->pullup);
stm32_configgpio(SDMMC1_SDIO_PULL(GPIO_SDMMC1_CMD));
# endif
}
else
Expand All @@ -3328,14 +3336,14 @@ FAR struct sdio_dev_s *sdio_initialize(int slotno)
*/

# ifndef CONFIG_SDIO_MUXBUS
stm32_configgpio(GPIO_SDMMC2_D0 | priv->pullup);
stm32_configgpio(SDMMC2_SDIO_PULL(GPIO_SDMMC2_D0));
# ifndef CONFIG_SDMMC2_WIDTH_D1_ONLY
stm32_configgpio(GPIO_SDMMC2_D1 | priv->pullup);
stm32_configgpio(GPIO_SDMMC2_D2 | priv->pullup);
stm32_configgpio(GPIO_SDMMC2_D3 | priv->pullup);
stm32_configgpio(SDMMC2_SDIO_PULL(GPIO_SDMMC2_D1));
stm32_configgpio(SDMMC2_SDIO_PULL(GPIO_SDMMC2_D2));
stm32_configgpio(SDMMC2_SDIO_PULL(GPIO_SDMMC2_D3));
# endif
stm32_configgpio(GPIO_SDMMC2_CK);
stm32_configgpio(GPIO_SDMMC2_CMD | priv->pullup);
stm32_configgpio(SDMMC2_SDIO_PULL(GPIO_SDMMC2_CMD));
# endif
}
else
Expand Down