diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-11-18 17:31:49 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-11-18 17:31:49 +0000 |
commit | bd877246167febc5e567036e54961a87199f2084 (patch) | |
tree | 4e8922bcefd0bae1ba5a9322db45450cd93929ea | |
parent | 698c00fd5eafaab3ddb06203ab3bf71299bf96e9 (diff) | |
download | nuttx-bd877246167febc5e567036e54961a87199f2084.tar.gz nuttx-bd877246167febc5e567036e54961a87199f2084.tar.bz2 nuttx-bd877246167febc5e567036e54961a87199f2084.zip |
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
-rw-r--r-- | nuttx/arch/arm/src/stm32/stm32_sdio.c | 17 | ||||
-rwxr-xr-x | nuttx/configs/stm3210e-eval/README.txt | 2 | ||||
-rw-r--r-- | nuttx/drivers/mmcsd/mmcsd_sdio.c | 34 | ||||
-rwxr-xr-x | nuttx/include/nuttx/sdio.h | 2 |
4 files changed, 39 insertions, 16 deletions
diff --git a/nuttx/arch/arm/src/stm32/stm32_sdio.c b/nuttx/arch/arm/src/stm32/stm32_sdio.c index 01a458834..143243ae6 100644 --- a/nuttx/arch/arm/src/stm32/stm32_sdio.c +++ b/nuttx/arch/arm/src/stm32/stm32_sdio.c @@ -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 */
diff --git a/nuttx/configs/stm3210e-eval/README.txt b/nuttx/configs/stm3210e-eval/README.txt index b6eb981df..6c4b157c1 100755 --- a/nuttx/configs/stm3210e-eval/README.txt +++ b/nuttx/configs/stm3210e-eval/README.txt @@ -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 diff --git a/nuttx/drivers/mmcsd/mmcsd_sdio.c b/nuttx/drivers/mmcsd/mmcsd_sdio.c index 97c2a6dc0..293dcfd14 100644 --- a/nuttx/drivers/mmcsd/mmcsd_sdio.c +++ b/nuttx/drivers/mmcsd/mmcsd_sdio.c @@ -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: - * One-time hardware initialization + * One-time hardware initialization. Called only from sdio_slotinitialize. * ****************************************************************************/ @@ -2705,7 +2706,7 @@ static int mmcsd_hwinitialize(FAR struct mmcsd_state_s *priv) mmcsd_givesem(priv); return -EBUSY; } - fvdbg("Successfully attached MMC/SD interrupts\n"); + fvdbg("Attached MMC/SD interrupts\n"); /* Register a callback so that we get informed if media is inserted or * removed from the slot (Initially all callbacks are disabled). @@ -2740,8 +2741,9 @@ static int mmcsd_hwinitialize(FAR struct mmcsd_state_s *priv) /* 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 - * interpreted as an error. + * 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. */ ret = -ENODEV; @@ -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. */ + /* 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) } /**************************************************************************** - * Name: mmcsd_hwinitialize + * Name: mmcsd_hwuninitialize * * Description: - * Restore the MMC/SD slot to the uninitialized state + * 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; } diff --git a/nuttx/include/nuttx/sdio.h b/nuttx/include/nuttx/sdio.h index dacd6ef47..db0d0c001 100755 --- a/nuttx/include/nuttx/sdio.h +++ b/nuttx/include/nuttx/sdio.h @@ -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 |