stm32:sdio: fix reset of GPIO_SDIO_D0

For the case when the watchdog is triggering a timeout we did not
correctly reset the GPIO_SDIO_D0.

Without this fix, the SD card can become inaccessible.
This commit is contained in:
Julian Oes
2021-06-29 19:02:30 +02:00
committed by Xiang Xiao
parent 665f847760
commit 2a86335055
+18 -8
View File
@@ -662,12 +662,8 @@ static void stm32_configwaitints(struct stm32_dev_s *priv, uint32_t waitmask,
flags = enter_critical_section();
#ifdef CONFIG_MMCSD_SDIOWAIT_WRCOMPLETE
if ((waitmask & SDIOWAIT_WRCOMPLETE) != 0)
if ((waitevents & SDIOWAIT_WRCOMPLETE) != 0)
{
/* Do not use this in STM32_SDIO_MASK register */
waitmask &= ~SDIOWAIT_WRCOMPLETE;
pinset = GPIO_SDIO_D0 & (GPIO_PORT_MASK | GPIO_PIN_MASK);
pinset |= (GPIO_INPUT | GPIO_FLOAT | GPIO_EXTI);
@@ -1242,8 +1238,13 @@ static void stm32_eventtimeout(wdparm_t arg)
{
/* Yes.. wake up any waiting threads */
#ifdef CONFIG_MMCSD_SDIOWAIT_WRCOMPLETE
stm32_endwait(priv, SDIOWAIT_TIMEOUT |
(priv->waitevents & SDIOWAIT_WRCOMPLETE));
#else
stm32_endwait(priv, SDIOWAIT_TIMEOUT);
mcerr("ERROR: Timeout, remaining: %d\n", priv->remaining);
#endif
mcerr("Timeout: remaining: %d\n", priv->remaining);
}
}
@@ -1362,7 +1363,14 @@ static void stm32_endtransfer(struct stm32_dev_s *priv,
static int stm32_rdyinterrupt(int irq, void *context, FAR void *arg)
{
struct stm32_dev_s *priv = (struct stm32_dev_s *)arg;
stm32_endwait(priv, SDIOWAIT_WRCOMPLETE);
/* Avoid noise, check the state */
if (stm32_gpioread(GPIO_SDIO_D0))
{
stm32_endwait(priv, SDIOWAIT_WRCOMPLETE);
}
return OK;
}
#endif
@@ -2474,7 +2482,9 @@ static void stm32_waitenable(FAR struct sdio_dev_s *dev,
#if defined(CONFIG_MMCSD_SDIOWAIT_WRCOMPLETE)
if ((eventset & SDIOWAIT_WRCOMPLETE) != 0)
{
waitmask = SDIOWAIT_WRCOMPLETE;
/* eventset carries this */
waitmask = 0;
}
else
#endif