mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 16:50:55 +08:00
Initial MMC/SD SDIO STM32 bug fixes
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2272 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -77,7 +77,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_SDIO_PRI
|
||||
# define CONFIG_SDIO_PRI DMA_CCR_PRIMED
|
||||
# define CONFIG_SDIO_PRI NVIC_SYSH_PRIORITY_DEFAULT
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_SDIO_DMAPRIO
|
||||
@@ -1855,7 +1855,10 @@ static void stm32_callbackenable(FAR struct sdio_dev_s *dev,
|
||||
sdio_eventset_t eventset)
|
||||
{
|
||||
struct stm32_dev_s *priv = (struct stm32_dev_s*)dev;
|
||||
|
||||
fvdbg("eventset: %02x\n", eventset);
|
||||
DEBUGASSERT(priv != NULL);
|
||||
|
||||
priv->cbevents = eventset;
|
||||
stm32_callback(priv);
|
||||
}
|
||||
@@ -1889,7 +1892,9 @@ static int stm32_registercallback(FAR struct sdio_dev_s *dev,
|
||||
|
||||
/* Disable callbacks and register this callback and is argument */
|
||||
|
||||
fvdbg("Register %p(%p)\n", callback, arg);
|
||||
DEBUGASSERT(priv != NULL);
|
||||
|
||||
priv->cbevents = 0;
|
||||
priv->cbarg = arg;
|
||||
priv->callback = callback;
|
||||
@@ -2076,11 +2081,14 @@ static void stm32_callback(void *arg)
|
||||
/* Is a callback registered? */
|
||||
|
||||
DEBUGASSERT(priv != NULL);
|
||||
fvdbg("Callback %p(%p) cbevents: %02x cdstatus: %02x\n",
|
||||
priv->callback, priv->cbarg, priv->cbevents, priv->cdstatus);
|
||||
|
||||
if (priv->callback)
|
||||
{
|
||||
/* Yes.. Check for enabled callback events */
|
||||
|
||||
if ((stm32_status(&priv->dev) & SDIO_STATUS_PRESENT) != 0)
|
||||
if ((priv->cdstatus & SDIO_STATUS_PRESENT) != 0)
|
||||
{
|
||||
/* Media is present. Is the media inserted event enabled? */
|
||||
|
||||
@@ -2106,6 +2114,7 @@ static void stm32_callback(void *arg)
|
||||
/* Perform the callback, disabling further callbacks. Of course, the
|
||||
* the callback can (and probably should) re-enable callbacks.
|
||||
*/
|
||||
|
||||
priv->cbevents = 0;
|
||||
|
||||
/* Callbacks cannot be performed in the context of an interrupt handler.
|
||||
@@ -2117,12 +2126,14 @@ static void stm32_callback(void *arg)
|
||||
{
|
||||
/* Yes.. queue it */
|
||||
|
||||
fvdbg("Queuing callback to %p(%p)\n", priv->callback, priv->cbarg);
|
||||
(void)work_queue(&priv->cbwork, (worker_t)priv->callback, priv->cbarg, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* No.. then just call the callback here */
|
||||
|
||||
fvdbg("Callback to %p(%p)\n", priv->callback, priv->cbarg);
|
||||
priv->callback(priv->cbarg);
|
||||
}
|
||||
}
|
||||
@@ -2241,6 +2252,7 @@ void sdio_mediachange(FAR struct sdio_dev_s *dev, boolean cardinslot)
|
||||
{
|
||||
priv->cdstatus &= ~SDIO_STATUS_PRESENT;
|
||||
}
|
||||
fvdbg("cdstatus OLD: %02x NEW: %02x\n", cdstatus, priv->cdstatus);
|
||||
|
||||
/* Perform any requested callback if the status has changed */
|
||||
|
||||
@@ -2283,6 +2295,7 @@ void sdio_wrprotect(FAR struct sdio_dev_s *dev, boolean wrprotect)
|
||||
{
|
||||
priv->cdstatus &= ~SDIO_STATUS_WRPROTECTED;
|
||||
}
|
||||
fvdbg("cdstatus: %02x\n", priv->cdstatus);
|
||||
irqrestore(flags);
|
||||
}
|
||||
#endif /* CONFIG_STM32_SDIO */
|
||||
|
||||
@@ -384,7 +384,7 @@ STM3210E-EVAL-specific Configuration Options
|
||||
|
||||
CONFIG_SDIO_DMA - Support DMA data transfers. Requires CONFIG_STM32_SDIO
|
||||
and CONFIG_STM32_DMA2.
|
||||
CONFIG_SDIO_PRI - Select SDIO interrupt prority. Default: Medium
|
||||
CONFIG_SDIO_PRI - Select SDIO interrupt prority. Default: 128
|
||||
CONFIG_SDIO_DMAPRIO - Select SDIO DMA interrupt priority.
|
||||
Default: Medium
|
||||
|
||||
|
||||
+22
-12
@@ -1943,6 +1943,7 @@ static void mmcsd_mediachange(FAR void *arg)
|
||||
{
|
||||
FAR struct mmcsd_state_s *priv = (FAR struct mmcsd_state_s *)arg;
|
||||
|
||||
fvdbg("arg: %p\n", arg);
|
||||
DEBUGASSERT(priv);
|
||||
|
||||
/* Is there a card present in the slot? */
|
||||
@@ -2303,7 +2304,7 @@ static int mmcsd_cardidentify(FAR struct mmcsd_state_s *priv)
|
||||
* of GPIO sensing.
|
||||
*/
|
||||
|
||||
if (SDIO_PRESENT(priv->dev))
|
||||
if (!SDIO_PRESENT(priv->dev))
|
||||
{
|
||||
fvdbg("No card present\n");
|
||||
return -ENODEV;
|
||||
@@ -2680,7 +2681,7 @@ static int mmcsd_removed(FAR struct mmcsd_state_s *priv)
|
||||
/****************************************************************************
|
||||
* Name: mmcsd_hwinitialize
|
||||
*
|
||||
* Description:
|
||||
* Description:
|
||||
* One-time hardware initialization. Called only from sdio_slotinitialize.
|
||||
*
|
||||
****************************************************************************/
|
||||
@@ -2705,7 +2706,7 @@ static int mmcsd_hwinitialize(FAR struct mmcsd_state_s *priv)
|
||||
fdbg("ERROR: Unable to attach MMC/SD interrupts\n");
|
||||
mmcsd_givesem(priv);
|
||||
return -EBUSY;
|
||||
}
|
||||
}
|
||||
fvdbg("Attached MMC/SD interrupts\n");
|
||||
|
||||
/* Register a callback so that we get informed if media is inserted or
|
||||
@@ -2740,8 +2741,9 @@ static int mmcsd_hwinitialize(FAR struct mmcsd_state_s *priv)
|
||||
fvdbg("Slot not empty, but initialization failed: %d\n", ret);
|
||||
|
||||
/* NOTE: The failure to initialize a card does not mean that
|
||||
* initialization has failed! A card could be installed in the slot
|
||||
* at a later time. ENODEV is return in this case, but should not be
|
||||
* initialization has failed! A card could be installed in the slot
|
||||
* at a later time. ENODEV is return in this case,
|
||||
* sdio_slotinitialize will use this return value to set up the
|
||||
* card inserted callback event.
|
||||
*/
|
||||
|
||||
@@ -2749,11 +2751,10 @@ static int mmcsd_hwinitialize(FAR struct mmcsd_state_s *priv)
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* No... Setup to receive the media inserted event */
|
||||
|
||||
SDIO_CALLBACKENABLE(priv->dev, SDIOMEDIA_INSERTED);
|
||||
|
||||
{
|
||||
/* ENODEV is returned to indicate that no card is inserted in the slot.
|
||||
* sdio_slotinitialize will use this return value to set up the card
|
||||
* inserted callback event.
|
||||
*/
|
||||
|
||||
ret = -ENODEV;
|
||||
@@ -2767,10 +2768,11 @@ static int mmcsd_hwinitialize(FAR struct mmcsd_state_s *priv)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: mmcsd_hwuninitialize
|
||||
*
|
||||
* Description:
|
||||
* Description:
|
||||
* Restore the MMC/SD slot to the uninitialized state. Called only from
|
||||
* sdio_slotinitialize on a failure to initialize.
|
||||
*
|
||||
****************************************************************************/
|
||||
@@ -2848,10 +2850,18 @@ int mmcsd_slotinitialize(int minor, FAR struct sdio_dev_s *dev)
|
||||
*/
|
||||
|
||||
if (ret == -ENODEV)
|
||||
{
|
||||
/* No card in the slot (or if there is, we could not recognize
|
||||
* it).. Setup to receive the media inserted event
|
||||
*/
|
||||
|
||||
SDIO_CALLBACKENABLE(priv->dev, SDIOMEDIA_INSERTED);
|
||||
|
||||
fdbg("MMC/SD slot is empty\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Some other non-recoverable bad thing happened */
|
||||
|
||||
fdbg("ERROR: Failed to initialize MMC/SD slot: %d\n", ret);
|
||||
goto errout_with_alloc;
|
||||
|
||||
@@ -561,7 +561,7 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#define SDIO_CALLBACKENABLE(dev,eventset) ((dev)->waitenable(dev,eventset))
|
||||
#define SDIO_CALLBACKENABLE(dev,eventset) ((dev)->callbackenable(dev,eventset))
|
||||
|
||||
/****************************************************************************
|
||||
* Name: SDIO_REGISTERCALLBACK
|
||||
|
||||
Reference in New Issue
Block a user