From 3cfb3001c68d449f0b59586bca112bf5a2e226fa Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 8 Jan 2015 06:23:42 -0600 Subject: MMCSD SDIO: Add support for a new SDWAIT_WRCOMPLETE condition. The previous logic used a busy-wait loop to pool the card R1 start to determine when the card was ready for the next transfer. That busy-wait can be quite long -- hundreds of milliseconds. And alternative is to look the the SD D0 pin which will change state when the card is no longer busy. This logic implements a change the avoids the busy-wait poll by reconfiguring the SD D0 pin as a GPIO interrupt, then waiting for the card to becom ready without taking up CPU cycles. This change is conditioned on CONFIG_MMCSD_SDIOWATI_WRCOMPLETE and is currenlty only implemented for the STM32 SDIO driver. From David Sidrane --- nuttx/include/nuttx/sdio.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) mode change 100644 => 100755 nuttx/include/nuttx/sdio.h (limited to 'nuttx/include') diff --git a/nuttx/include/nuttx/sdio.h b/nuttx/include/nuttx/sdio.h old mode 100644 new mode 100755 index 5bd80329c..258fe14c8 --- a/nuttx/include/nuttx/sdio.h +++ b/nuttx/include/nuttx/sdio.h @@ -63,7 +63,27 @@ #define SDIOWAIT_TIMEOUT (1 << 3) /* Bit 3: Timeout */ #define SDIOWAIT_ERROR (1 << 4) /* Bit 4: Some other error occurred */ -#define SDIOWAIT_ALLEVENTS 0x1f +/* SDIOWAIT_WRCOMPLETE (optional) : SDIO driver will use SDIO_D Busy + * signalling 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 signalling to detect Write + * Complete. This will avoid potentially very long (600Ms+) busy waiting + * in the MMCSD driver. + * + * To implement SDIO_D Busy signalling, 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 receipt 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. + */ + +#if defined(CONFIG_MMCSD_SDIOWAIT_WRCOMPLETE) +# define SDIOWAIT_WRCOMPLETE (1 << 5) /* Bit 5: Hardware Write Completion */ +# define SDIOWAIT_ALLEVENTS 0x3f +#else +# define SDIOWAIT_ALLEVENTS 0x1f +#endif /* Media events are used for enable/disable registered event callbacks */ -- cgit v1.2.3