diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-08-19 16:51:04 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-08-19 16:51:04 +0000 |
commit | aae0c1e888d173b7a850a3e0023b8c352f657f62 (patch) | |
tree | 4e52eff7f4adf0570b819f68b3a4351987266ec8 /nuttx/drivers/mmcsd | |
parent | ba6253aecb0d018c0deb40b233d76cb2f9a67bb0 (diff) | |
download | px4-nuttx-aae0c1e888d173b7a850a3e0023b8c352f657f62.tar.gz px4-nuttx-aae0c1e888d173b7a850a3e0023b8c352f657f62.tar.bz2 px4-nuttx-aae0c1e888d173b7a850a3e0023b8c352f657f62.zip |
Add support for multiplexed SDIO pins from Uros
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3898 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/drivers/mmcsd')
-rw-r--r-- | nuttx/drivers/mmcsd/mmcsd_sdio.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/nuttx/drivers/mmcsd/mmcsd_sdio.c b/nuttx/drivers/mmcsd/mmcsd_sdio.c index 1434c440c..27232983e 100644 --- a/nuttx/drivers/mmcsd/mmcsd_sdio.c +++ b/nuttx/drivers/mmcsd/mmcsd_sdio.c @@ -148,7 +148,10 @@ struct mmcsd_state_s /* Misc Helpers *************************************************************/ static void mmcsd_takesem(FAR struct mmcsd_state_s *priv); -#define mmcsd_givesem(p) sem_post(&priv->sem); + +#ifndef CONFIG_SDIO_MUXBUS +# define mmcsd_givesem(p) sem_post(&priv->sem); +#endif /* Command/response helpers *************************************************/ @@ -261,18 +264,41 @@ static const struct block_operations g_bops = static void mmcsd_takesem(FAR struct mmcsd_state_s *priv) { - /* Take the semaphore (perhaps waiting) */ + /* Take the semaphore, giving exclusive access to the driver (perhaps + * waiting) + */ while (sem_wait(&priv->sem) != 0) { - /* The only case that an error should occr here is if the wait was + /* The only case that an error should occur here is if the wait was * awakened by a signal. */ ASSERT(errno == EINTR); } + + /* Lock the bus if mutually exclusive access to the SDIO bus is required + * on this platform. + */ + +#ifdef CONFIG_SDIO_MUXBUS + SDIO_LOCK(priv->dev, TRUE); +#endif } +#ifdef CONFIG_SDIO_MUXBUS +static void mmcsd_givesem(FAR struct mmcsd_state_s *priv) +{ + /* Release the SDIO bus lock, then the MMC/SD driver semaphore in the + * opposite order that they were taken to assure that no deadlock + * conditions will arise. + */ + + SDIO_LOCK(priv->dev, FALSE); + sem_post(&priv->sem); +} +#endif + /**************************************************************************** * Command/Response Helpers ****************************************************************************/ |