summaryrefslogtreecommitdiff
path: root/nuttx/drivers/mmcsd
diff options
context:
space:
mode:
Diffstat (limited to 'nuttx/drivers/mmcsd')
-rwxr-xr-x[-rw-r--r--]nuttx/drivers/mmcsd/Kconfig26
-rwxr-xr-x[-rw-r--r--]nuttx/drivers/mmcsd/mmcsd_sdio.c20
2 files changed, 41 insertions, 5 deletions
diff --git a/nuttx/drivers/mmcsd/Kconfig b/nuttx/drivers/mmcsd/Kconfig
index 720bbf20a..6d3933897 100644..100755
--- a/nuttx/drivers/mmcsd/Kconfig
+++ b/nuttx/drivers/mmcsd/Kconfig
@@ -32,11 +32,27 @@ config MMCSD_MMCSUPPORT
Enable support for MMC cards
config MMCSD_HAVECARDDETECT
- bool "MMC/SD card detection"
- default y
- ---help---
- SDIO driver card detection is
- 100% accurate
+ bool "MMC/SD card detection"
+ default y
+ ---help---
+ SDIO driver card detection is
+ 100% accurate
+
+config MMCSD_HAVE_SDIOWAIT_WRCOMPLETE
+ bool "Use SDIO_D Busy to detect Write Complete"
+ default n
+ ---help---
+ SDIO driver will use SDIO_D Busy signaling to detect Write Complete.
+ This option when selected, will enable the MMCSD driver to use the
+ underlying (stm32_sdio only) drivers implementation of the SD specs
+ SDIO_D Busy signaling to detect Write Complete. This will avoid
+ potentially very long (600Ms+) busy waiting in the MMCSD driver.
+ To implement SDIO_D Busy signaling, the underlying driver must
+ be capable of switching the GPIO_SDIO_D0 to be a rising edge sensitive
+ interrupt pin. It must then, condition that pin to detect the rising edge
+ on recipet of SDWAIT_WRCOMPLETE in the SDIO_WAITENABLE call and
+ return it back to regular SDIO mode, when either the ISR fires or pin is
+ found to be high in the SDIO_EVENTWAIT call.
config MMCSD_SPI
bool "MMC/SD SPI transfer support"
diff --git a/nuttx/drivers/mmcsd/mmcsd_sdio.c b/nuttx/drivers/mmcsd/mmcsd_sdio.c
index 3afed2a93..cd3890850 100644..100755
--- a/nuttx/drivers/mmcsd/mmcsd_sdio.c
+++ b/nuttx/drivers/mmcsd/mmcsd_sdio.c
@@ -71,6 +71,9 @@
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
+#if !defined(MMCSD_BLOCK_WDATADELAY)
+# define MMCSD_BLOCK_WDATADELAY 200
+#endif
/* The maximum number of references on the driver (because a uint8_t is used.
* Use a larger type if more references are needed.
@@ -1142,6 +1145,15 @@ static int mmcsd_transferready(FAR struct mmcsd_state_s *priv)
* the TRANSFER state when the card completes the WRITE operation.
*/
+#if defined(CONFIG_MMCSD_HAVE_SDIOWAIT_WRCOMPLETE)
+ ret = mmcsd_eventwait(priv, SDIOWAIT_TIMEOUT|SDIOWAIT_ERROR, MMCSD_BLOCK_WDATADELAY);
+
+ if (ret != OK)
+ {
+ fdbg("ERROR: mmcsd_eventwait for transferready failed: %d\n", ret);
+ }
+#endif
+
starttime = clock_systimer();
do
{
@@ -1707,6 +1719,14 @@ static ssize_t mmcsd_writesingle(FAR struct mmcsd_state_s *priv,
return ret;
}
+#if defined(CONFIG_MMCSD_HAVE_SDIOWAIT_WRCOMPLETE)
+
+ /* Arm the write complete detection with timeout */
+
+ SDIO_WAITENABLE(priv->dev, SDIOWAIT_WRCOMPLETE|SDIOWAIT_TIMEOUT);
+
+#endif
+
/* On success, return the number of blocks written */
return 1;