STM32F7 and STM32H7 SDMMC internal pull up usage fixed
Code was flawed in that the Pins are defined with the
pullups in the definition. Since there are no alterntes pins
there is no way to remove them. So not enabling the CONFIG
pull up did nothing as did enabling them.
Code also ignored the use of D0 for ready detection causing
3X+ the chatter.
This is now a compile time feature as there was no reason for
it to be a run time. It wasted both flash and ram.
This commit is contained in:
parent
8dd4b27973
commit
eba8eec74b
2 changed files with 56 additions and 48 deletions
|
|
@ -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)
|
||||
|
|
@ -423,7 +435,6 @@ struct stm32_dev_s
|
|||
|
||||
/* Misc */
|
||||
|
||||
uint32_t pullup; /* GPIO pull-up option */
|
||||
uint32_t blocksize; /* Current block size */
|
||||
};
|
||||
|
||||
|
|
@ -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,
|
||||
|
|
@ -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
|
||||
|
||||
|
|
@ -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,
|
||||
|
|
@ -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 */
|
||||
|
|
@ -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 */
|
||||
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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)
|
||||
|
|
@ -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)
|
||||
|
|
@ -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 */
|
||||
|
|
@ -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)
|
||||
|
|
@ -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 */
|
||||
|
||||
|
|
@ -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)
|
||||
{
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue