summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2010-04-11 15:32:07 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2010-04-11 15:32:07 +0000
commit9f4e907eee7044467ff13b28230355ed7d85d195 (patch)
treeb2c4a958b3d0cd9f8a7cb3944db111487021cedd
parent1ca794f2728207ce1320b07ed063aa54d2055dc7 (diff)
downloadnuttx-9f4e907eee7044467ff13b28230355ed7d85d195.tar.gz
nuttx-9f4e907eee7044467ff13b28230355ed7d85d195.tar.bz2
nuttx-9f4e907eee7044467ff13b28230355ed7d85d195.zip
Add MCI CD GPIO
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2585 42af7a65-404d-4744-a932-0658087f49c3
-rwxr-xr-xnuttx/arch/arm/src/sam3u/sam3u_dmac.c4
-rwxr-xr-xnuttx/configs/sam3u-ek/src/Makefile3
-rwxr-xr-xnuttx/configs/sam3u-ek/src/sam3uek_internal.h42
-rwxr-xr-xnuttx/configs/sam3u-ek/src/up_boot.c15
-rwxr-xr-xnuttx/configs/sam3u-ek/src/up_mmcsd.c134
-rwxr-xr-xnuttx/configs/sam3u-ek/src/up_nsh.c8
-rwxr-xr-xnuttx/include/nuttx/sdio.h10
7 files changed, 202 insertions, 14 deletions
diff --git a/nuttx/arch/arm/src/sam3u/sam3u_dmac.c b/nuttx/arch/arm/src/sam3u/sam3u_dmac.c
index 510ac7e8a..2084fc678 100755
--- a/nuttx/arch/arm/src/sam3u/sam3u_dmac.c
+++ b/nuttx/arch/arm/src/sam3u/sam3u_dmac.c
@@ -447,7 +447,7 @@ static inline uint32_t sam3u_rxctrlabits(struct sam3u_dma_s *dmach)
uint32_t regval;
unsigned int ndx;
- DEBUGASSERT(dmach && dmasize <= DMACHAN_CTRLA_BTSIZE_MAX);
+ DEBUGASSERT(dmach);
/* Since this is a receive, the source is described by the peripheral
* selections. Set the source width (peripheral width).
@@ -748,7 +748,7 @@ sam3u_allocdesc(struct sam3u_dma_s *dmach, struct dma_linklist_s *prev,
}
else
{
- DEBUGASSERT(dmach->llhead != NULL && dmach->tail == prev);
+ DEBUGASSERT(dmach->llhead != NULL && dmach->lltail == prev);
/* When the second link is added to the list, that is the
* cue that we are going to do the link list transfer.
diff --git a/nuttx/configs/sam3u-ek/src/Makefile b/nuttx/configs/sam3u-ek/src/Makefile
index 714026974..4b842ad57 100755
--- a/nuttx/configs/sam3u-ek/src/Makefile
+++ b/nuttx/configs/sam3u-ek/src/Makefile
@@ -44,6 +44,9 @@ CSRCS = up_boot.c up_leds.c up_buttons.c up_spi.c up_usbdev.c
ifeq ($(CONFIG_EXAMPLES_NSH_ARCHINIT),y)
CSRCS += up_nsh.c
endif
+ifeq ($(CONFIG_SAM3U_HSMCI),y)
+CSRCS += up_mmcsd.c
+endif
ifeq ($(CONFIG_EXAMPLE),usbstorage)
CSRCS += up_usbstrg.c
endif
diff --git a/nuttx/configs/sam3u-ek/src/sam3uek_internal.h b/nuttx/configs/sam3u-ek/src/sam3uek_internal.h
index 61ddb1f18..f092cbb02 100755
--- a/nuttx/configs/sam3u-ek/src/sam3uek_internal.h
+++ b/nuttx/configs/sam3u-ek/src/sam3uek_internal.h
@@ -108,6 +108,48 @@ extern void weak_function sam3u_spiinitialize(void);
extern void weak_function sam3u_usbinitialize(void);
+/****************************************************************************
+ * Name: sam3u_hsmciinit
+ *
+ * Description:
+ * Initialize HSMCI support
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_SAM3U_HSMCI
+extern int weak_function sam3u_hsmciinit(void);
+#else
+# define sam3u_boardmciinit()
+#endif
+
+/****************************************************************************
+ * Name: sam3u_cardinserted
+ *
+ * Description:
+ * Check if a card is inserted into the selected HSMCI slot
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_SAM3U_HSMCI
+extern bool sam3u_cardinserted(unsigned char slot);
+#else
+# define sam3u_cardinserted(slot) (false)
+#endif
+
+/****************************************************************************
+ * Name: sam3u_writeprotected
+ *
+ * Description:
+ * Check if a card is inserted into the selected HSMCI slot
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_SAM3U_HSMCI
+extern bool sam3u_writeprotected(unsigned char slot);
+#else
+# define sam3u_writeprotected(slot) (false)
+#endif
+
#endif /* __ASSEMBLY__ */
#endif /* __CONFIGS_SAM3U_EK_SRC_SAM3UEK_INTERNAL_H */
diff --git a/nuttx/configs/sam3u-ek/src/up_boot.c b/nuttx/configs/sam3u-ek/src/up_boot.c
index 4ae2699ed..36154f905 100755
--- a/nuttx/configs/sam3u-ek/src/up_boot.c
+++ b/nuttx/configs/sam3u-ek/src/up_boot.c
@@ -2,7 +2,7 @@
* configs/sam3u-ek/src/up_boot.c
* arch/arm/src/board/up_boot.c
*
- * Copyright (C) 2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2009-2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -82,7 +82,7 @@ void sam3u_boardinitialize(void)
}
#endif
- /* Initialize USB is 1) USBDEV is selected, 2) the USB controller is not
+ /* Initialize USB if 1) USBDEV is selected, 2) the USB controller is not
* disabled, and 3) the weak function sam3u_usbinitialize() has been brought
* into the build.
*/
@@ -100,9 +100,14 @@ void sam3u_boardinitialize(void)
up_ledinit();
#endif
- /* Setup SD card detection PIO */
+ /* Setup SD card-related PIOs if 1) HSMCI is selected and 2) the weak
+ * function sam3u_hsmciinit() has been brought into the build.
+ */
-#if CONFIG_SAM3U_HSMCI
- sam3u_configgpio(GPIO_MCI_CD);
+#ifdef CONFIG_SAM3U_HSMCI
+ if (sam3u_hsmciinit)
+ {
+ sam3u_hsmciinit();
+ }
#endif
}
diff --git a/nuttx/configs/sam3u-ek/src/up_mmcsd.c b/nuttx/configs/sam3u-ek/src/up_mmcsd.c
new file mode 100755
index 000000000..45762ee28
--- /dev/null
+++ b/nuttx/configs/sam3u-ek/src/up_mmcsd.c
@@ -0,0 +1,134 @@
+/************************************************************************************
+ * configs/sam3u-ek/src/up_mmcsd.c
+ * arch/arm/src/board/up_mmcsd.c
+ *
+ * Copyright (C) 2010 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ************************************************************************************/
+
+/************************************************************************************
+ * Included Files
+ ************************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdbool.h>
+#include <debug.h>
+
+#include "sam3u_internal.h"
+#include "sam3uek_internal.h"
+
+#ifdef CONFIG_SAM3U_HSMCI
+
+/************************************************************************************
+ * Definitions
+ ************************************************************************************/
+
+/* This needs to be extended. The card detect GPIO must be configured as an interrupt.
+ * when the interrupt indicating that a card has been inserted or removed is received,
+ * this function must call sio_mediachange() to handle that event. See
+ * arch/arm/src/sam3u/sam3u_internal.h for more information.
+ */
+
+#ifdef GPIO_MCI_CD
+# warning "Card detect interrupt handling needed"
+#endif
+
+/************************************************************************************
+ * Private Functions
+ ************************************************************************************/
+
+/************************************************************************************
+ * Public Functions
+ ************************************************************************************/
+
+/****************************************************************************
+ * Name: sam3u_hsmciinit
+ *
+ * Description:
+ * Initialize HSMCI support
+ *
+ ****************************************************************************/
+
+int sam3u_hsmciinit(void)
+{
+#if GPIO_MCI_CD
+ sam3u_configgpio(GPIO_MCI_CD);
+#endif
+#if GPIO_MCI_WP
+ sam3u_configgpio(GPIO_MCI_WP);
+#endif
+ return OK;
+}
+
+/****************************************************************************
+ * Name: sam3u_cardinserted
+ *
+ * Description:
+ * Check if a card is inserted into the selected HSMCI slot
+ *
+ ****************************************************************************/
+
+bool sam3u_cardinserted(unsigned char slot)
+{
+ if (slot == 0)
+ {
+#ifdef GPIO_MCI_CD
+ return !sam3u_gpioread(GPIO_MCI_CD);
+#else
+ return true;
+#endif
+ }
+ return false;
+}
+
+/****************************************************************************
+ * Name: sam3u_writeprotected
+ *
+ * Description:
+ * Check if a card is inserted into the selected HSMCI slot
+ *
+ ****************************************************************************/
+
+bool sam3u_writeprotected(unsigned char slot)
+{
+ if (slot == 0)
+ {
+#ifdef GPIO_MCI_WP
+ return sam3u_gpioread(GPIO_MCI_WP);
+#else
+ return false;
+#endif
+ }
+ return false;
+}
+
+#endif /* CONFIG_SAM3U_HSMCI */
diff --git a/nuttx/configs/sam3u-ek/src/up_nsh.c b/nuttx/configs/sam3u-ek/src/up_nsh.c
index c8370369c..ae1ecb673 100755
--- a/nuttx/configs/sam3u-ek/src/up_nsh.c
+++ b/nuttx/configs/sam3u-ek/src/up_nsh.c
@@ -49,6 +49,7 @@
#include <nuttx/mmcsd.h>
#include "sam3u_internal.h"
+#include "sam3uek_internal.h"
#ifdef CONFIG_SAM3U_HSMCI
@@ -154,12 +155,9 @@ int nsh_archinitialize(void)
}
message("nsh_archinitialize: Successfully bound SDIO to the MMC/SD driver\n");
- /* Then let's guess and say that there is a card in the slot. I need to check to
- * see if the SAM3U-EK board supports a GPIO to detect if there is a card in
- * the slot.
- */
+ /* Then inform the HSMCI driver if there is or is not a card in the slot. */
- sdio_mediachange(sdio, true);
+ sdio_mediachange(sdio, sam3u_cardinserted(0));
#endif
return OK;
}
diff --git a/nuttx/include/nuttx/sdio.h b/nuttx/include/nuttx/sdio.h
index 8d4861c24..65d44dbc6 100755
--- a/nuttx/include/nuttx/sdio.h
+++ b/nuttx/include/nuttx/sdio.h
@@ -767,7 +767,10 @@ struct sdio_dev_s
/* Command/Status/Data Transfer */
void (*sendcmd)(FAR struct sdio_dev_s *dev, uint32_t cmd, uint32_t arg);
- void (*blocksetup)(FAR struct sdio_dev_s *dev, unsigned int blocklen, unsigned int nblocks);
+#ifdef CONFIG_SDIO_BLOCKSETUP
+ void (*blocksetup)(FAR struct sdio_dev_s *dev, unsigned int blocklen,
+ unsigned int nblocks);
+#endif
int (*recvsetup)(FAR struct sdio_dev_s *dev, FAR uint8_t *buffer,
size_t nbytes);
int (*sendsetup)(FAR struct sdio_dev_s *dev, FAR const uint8_t *buffer,
@@ -792,7 +795,10 @@ struct sdio_dev_s
int (*registercallback)(FAR struct sdio_dev_s *dev,
worker_t callback, void *arg);
- /* DMA */
+ /* DMA. CONFIG_SDIO_DMA should be set if the driver supports BOTH DMA
+ * and non-DMA transfer modes. If the driver supports only one mode
+ * CONFIG_SDIO_DMA is not required.
+ */
#ifdef CONFIG_SDIO_DMA
bool (*dmasupported)(FAR struct sdio_dev_s *dev);