summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2013-08-07 11:31:31 -0600
committerGregory Nutt <gnutt@nuttx.org>2013-08-07 11:31:31 -0600
commit7848ded204d5ba4607f9fff39eba86a67b6dab42 (patch)
treef814f1947e41758dc25e7d8fb5c32f0b5e42cba3
parent2ba66ac0d2d6d7aa2ab16a8da4d65aa35522314a (diff)
downloadnuttx-7848ded204d5ba4607f9fff39eba86a67b6dab42.tar.gz
nuttx-7848ded204d5ba4607f9fff39eba86a67b6dab42.tar.bz2
nuttx-7848ded204d5ba4607f9fff39eba86a67b6dab42.zip
Change setup logic to hand MTD minor numbers for AT24, HSMCI0, and HSMCI1
-rw-r--r--nuttx/Documentation/NuttX.html2
-rw-r--r--nuttx/configs/sama5d3x-ek/src/sam_at25.c37
-rw-r--r--nuttx/configs/sama5d3x-ek/src/sam_hsmci.c65
-rw-r--r--nuttx/configs/sama5d3x-ek/src/sam_nsh.c53
-rw-r--r--nuttx/configs/sama5d3x-ek/src/sama5d3x-ek.h63
5 files changed, 70 insertions, 150 deletions
diff --git a/nuttx/Documentation/NuttX.html b/nuttx/Documentation/NuttX.html
index 246fdef3c..b7d752cce 100644
--- a/nuttx/Documentation/NuttX.html
+++ b/nuttx/Documentation/NuttX.html
@@ -1998,7 +1998,7 @@
(1) An OS test configuration that verifies the correct port of NuttX to the part and
(2) a NuttShell (<a href="NuttShell.html">NSH</a>) configuration that might be the basis for further application development.
Develop continues.
- Drivers for DMA, SPI, AT25 Serial Flash, and HSMCI memory cards included in NuttX-6.30.
+ Support of DMA and PIO interrupts and drivers for SPI, AT25 Serial Flash, and HSMCI memory cards included in NuttX-6.30.
More device drivers are needed to make this a more complete port, particularly USB and networking.
Refer to the NuttX board <a href="http://sourceforge.net/p/nuttx/git/ci/master/tree/nuttx/configs/sama5d3x-ek/README.txt">README</a> file for further information.
</p>
diff --git a/nuttx/configs/sama5d3x-ek/src/sam_at25.c b/nuttx/configs/sama5d3x-ek/src/sam_at25.c
index 4f4d19cf0..637603ea2 100644
--- a/nuttx/configs/sama5d3x-ek/src/sam_at25.c
+++ b/nuttx/configs/sama5d3x-ek/src/sam_at25.c
@@ -56,40 +56,12 @@
#include "sama5d3x-ek.h"
+#ifdef CONFIG_MTD_AT25
+
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
-/* Configuration ************************************************************/
-/* Can't support the AT25 device if it SPI0 or AT25 support are not enabled */
-
-#define HAVE_AT25 1
-#if !defined(CONFIG_SAMA5_SPI0) || !defined(CONFIG_MTD_AT25)
-# undef HAVE_AT25
-#endif
-
-/* Can't support AT25 features if mountpoints are disabled or if we were not
- * asked to mount the AT25 part
- */
-
-#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_SAMA5_AT25_AUTOMOUNT)
-# undef HAVE_AT25
-#endif
-
-/* If we are going to mount the AT25, then they user must also have told
- * us what to do with it by setting one of these.
- */
-
-#if !defined(CONFIG_SAMA5_AT25_FTL) && !defined(CONFIG_SAMA5_AT25_NXFFS)
-# undef HAVE_AT25
-#endif
-
-#if defined(CONFIG_SAMA5_AT25_FTL) && defined(CONFIG_SAMA5_AT25_NXFFS)
-# warning Both CONFIG_SAMA5_AT25_FTL and CONFIG_SAMA5_AT25_NXFFS are set
-# warning Ignoring CONFIG_SAMA5_AT25_NXFFS
-# undef CONFIG_SAMA5_AT25_NXFFS
-#endif
-
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -102,10 +74,8 @@
*
****************************************************************************/
-#ifdef CONFIG_MTD_AT25
int sam_at25_initialize(int minor)
{
-#ifdef HAVE_AT25
FAR struct spi_dev_s *spi;
FAR struct mtd_dev_s *mtd;
int ret;
@@ -158,9 +128,8 @@ int sam_at25_initialize(int minor)
}
#endif
-#endif
return OK;
}
-#endif
+#endif /* HAVE_AT25_MTD */
diff --git a/nuttx/configs/sama5d3x-ek/src/sam_hsmci.c b/nuttx/configs/sama5d3x-ek/src/sam_hsmci.c
index 42b9ef521..d8d37bc76 100644
--- a/nuttx/configs/sama5d3x-ek/src/sam_hsmci.c
+++ b/nuttx/configs/sama5d3x-ek/src/sam_hsmci.c
@@ -84,50 +84,11 @@
#include "sama5d3x-ek.h"
+#ifdef HAVE_HSMCI_MTD
+
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
-/* Configuration ************************************************************/
-
-#define HAVE_MMCSD 1
-
-/* Can't support MMC/SD if the card interface(s) are not enable */
-
-#if !defined(CONFIG_SAMA5_HSMCI0) && !defined(CONFIG_SAMA5_HSMCI1)
-# undef HAVE_MMCSD
-#endif
-
-/* Can't support MMC/SD features if mountpoints are disabled */
-
-#if defined(HAVE_MMCSD) && defined(CONFIG_DISABLE_MOUNTPOINT)
-# warning Mountpoints disabled. No MMC/SD support
-# undef HAVE_MMCSD
-#endif
-
-/* We need PIO interrupts on PIOD to support card detect interrupts */
-
-#if defined(HAVE_MMCSD) && !defined(CONFIG_SAMA5_PIOD_IRQ)
-# warning PIOD interrupts not enabled. No MMC/SD support.
-# undef HAVE_MMCSD
-#endif
-
-/* The NSH slot and minor numbers are useless for us because we have
- * multiple HSMCI devices.
- */
-
-#ifdef HAVE_MMCSD
-# if defined(CONFIG_NSH_MMCSDSLOTNO) && CONFIG_NSH_MMCSDSLOTNO != 0
-# undef CONFIG_NSH_MMCSDSLOTNO
-# endif
-
-# ifndef CONFIG_NSH_MMCSDMINOR
-# define CONFIG_NSH_MMCSDMINOR 0
-# endif
-
-# ifndef CONFIG_NSH_MMCSDSLOTNO
-# define CONFIG_NSH_MMCSDSLOTNO 0
-# endif
-#endif
/****************************************************************************
* Private Types
@@ -148,7 +109,6 @@ struct sam_hsmci_info_s
/* Retained HSMCI driver handles for use by interrupt handlers */
-#ifdef HAVE_MMCSD
#ifdef CONFIG_SAMA5_HSMCI0
static struct sdio_dev_s *g_hsmci0;
#endif
@@ -175,7 +135,6 @@ static const struct sam_hsmci_info_s g_hsmci1_info =
PIO_MCI1_CD, IRQ_MCI1_CD, sam_hsmci1_cardetect, &g_hsmci1
};
#endif
-#endif
/****************************************************************************
* Private Functions
@@ -189,7 +148,6 @@ static const struct sam_hsmci_info_s g_hsmci1_info =
*
****************************************************************************/
-#ifdef HAVE_MMCSD
#ifdef CONFIG_SAMA5_HSMCI0
static int sam_hsmci0_cardetect(int irq, void *regs)
{
@@ -205,7 +163,6 @@ static int sam_hsmci1_cardetect(int irq, void *regs)
return OK;
}
#endif
-#endif
/****************************************************************************
* Name: sam_hsmci_info
@@ -215,7 +172,6 @@ static int sam_hsmci1_cardetect(int irq, void *regs)
*
****************************************************************************/
-#ifdef HAVE_MMCSD
static const struct sam_hsmci_info_s *sam_hsmci_info(int slotno)
{
const struct sam_hsmci_info_s *info = NULL;
@@ -240,7 +196,6 @@ static const struct sam_hsmci_info_s *sam_hsmci_info(int slotno)
return info;
}
-#endif
/****************************************************************************
* Public Functions
@@ -254,10 +209,8 @@ static const struct sam_hsmci_info_s *sam_hsmci_info(int slotno)
*
****************************************************************************/
-#if defined(CONFIG_SAMA5_HSMCI0) || defined(CONFIG_SAMA5_HSMCI1)
int sam_hsmci_initialize(int slotno, int minor)
{
-#ifdef HAVE_MMCSD
const struct sam_hsmci_info_s *info;
int ret;
@@ -302,7 +255,6 @@ int sam_hsmci_initialize(int slotno, int minor)
/* Then inform the HSMCI driver if there is or is not a card in the slot. */
sdio_mediachange(*info->hsmci, sam_cardinserted(slotno));
-#endif
return OK;
}
@@ -315,10 +267,8 @@ int sam_hsmci_initialize(int slotno, int minor)
*
****************************************************************************/
-#if defined(CONFIG_SAMA5_HSMCI0) || defined(CONFIG_SAMA5_HSMCI1)
bool sam_cardinserted(int slotno)
{
-#ifdef HAVE_MMCSD
const struct sam_hsmci_info_s *info;
bool inserted;
@@ -336,14 +286,7 @@ bool sam_cardinserted(int slotno)
inserted = sam_pioread(info->pincfg);
fvdbg("Slot %d inserted: %s\n", slotno, inserted ? "NO" : "YES");
return !inserted;
-
-#else /* HAVE_MMCSD */
-
- return false;
-
-#endif /* HAVE_MMCSD */
}
-#endif /* CONFIG_SAMA5_HSMCIO || CONFIG_SAMA5_HSMCI1 */
/****************************************************************************
* Name: sam_writeprotected
@@ -353,13 +296,11 @@ bool sam_cardinserted(int slotno)
*
****************************************************************************/
-#if defined(CONFIG_SAMA5_HSMCI0) || defined(CONFIG_SAMA5_HSMCI1)
bool sam_writeprotected(int slotno)
{
/* There are no write protect pins */
return false;
}
-#endif
-#endif /* CONFIG_SAMA5_HSMCI0 || CONFIG_SAMA5_HSMCI1 */
+#endif /* HAVE_HSMCI_MTD */
diff --git a/nuttx/configs/sama5d3x-ek/src/sam_nsh.c b/nuttx/configs/sama5d3x-ek/src/sam_nsh.c
index 3ffe32788..2fb783a5d 100644
--- a/nuttx/configs/sama5d3x-ek/src/sam_nsh.c
+++ b/nuttx/configs/sama5d3x-ek/src/sam_nsh.c
@@ -62,49 +62,6 @@
/* Configuration ************************************************************/
-#define HAVE_AT25 1
-#define HAVE_MMCSD 1
-
-/* Can't support the AT25 device if it SPI0 or AT25 support are not enabled */
-
-#if !defined(CONFIG_SAMA5_SPI0) || !defined(CONFIG_MTD_AT25)
-# undef HAVE_AT25
-#endif
-
-/* Can't support AT25 features if mountpoints are disabled or if we were not
- * asked to mount the AT25 part
- */
-
-#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_SAMA5_AT25_AUTOMOUNT)
-# undef HAVE_AT25
-#endif
-
-/* If we are going to mount the AT25, then they user must also have told
- * us what to do with it by setting one of these.
- */
-
-#if !defined(CONFIG_SAMA5_AT25_FTL) && !defined(CONFIG_SAMA5_AT25_NXFFS)
-# undef HAVE_AT25
-#endif
-
-/* Use minor device number 0 is not is provided */
-
-#ifndef CONFIG_NSH_MMCSDMINOR
-# define CONFIG_NSH_MMCSDMINOR 0
-#endif
-
-/* Can't support MMC/SD if the card interface(s) are not enable */
-
-#if !defined(CONFIG_SAMA5_HSMCI0) && !defined(CONFIG_SAMA5_HSMCI0)
-# undef HAVE_MMCSD
-#endif
-
-/* Can't support MMC/SD features if mountpoints are disabled */
-
-#if defined(CONFIG_DISABLE_MOUNTPOINT)
-# undef HAVE_MMCSD
-#endif
-
/* Assign minor device numbers. We basically ignore more of the NSH
* configuration here (NSH SLOTNO ignored completely; NSH minor extended
* to handle more devices.
@@ -114,7 +71,7 @@
# define CONFIG_NSH_MMCSDMINOR 0
#endif
-#ifdef HAVE_MMCSD
+#ifdef HAVE_HSMCI_MTD
# define HSMCI0_SLOTNO 0
# define HSMCI1_SLOTNO 1
@@ -145,13 +102,13 @@
int nsh_archinitialize(void)
{
-#if defined(HAVE_AT25) || defined(HAVE_MMCSD)
+#if defined(HAVE_AT25_MTD) || defined(HAVE_HSMCI_MTD)
int ret;
#endif
/* Initialize the AT25 driver */
-#ifdef HAVE_AT25
+#ifdef HAVE_AT25_MTD
ret = sam_at25_initialize(AT25_MINOR);
if (ret < 0)
{
@@ -159,7 +116,7 @@ int nsh_archinitialize(void)
return ret;
#endif
-#ifdef HAVE_MMCSD
+#ifdef HAVE_HSMCI_MTD
#ifdef CONFIG_SAMA5_HSMCI0
ret = sam_hsmci_initialize(HSMCI0_SLOTNO, HSMCI0_MINOR);
if (ret < 0)
@@ -170,7 +127,7 @@ int nsh_archinitialize(void)
}
#endif
-#ifdef CONFIG_SAMA5_HSMCI0
+#ifdef CONFIG_SAMA5_HSMCI1
ret = sam_hsmci_initialize(HSMCI1_SLOTNO, HSMCI1_MINOR);
if (ret < 0)
{
diff --git a/nuttx/configs/sama5d3x-ek/src/sama5d3x-ek.h b/nuttx/configs/sama5d3x-ek/src/sama5d3x-ek.h
index 8c20ab537..c568001f7 100644
--- a/nuttx/configs/sama5d3x-ek/src/sama5d3x-ek.h
+++ b/nuttx/configs/sama5d3x-ek/src/sama5d3x-ek.h
@@ -53,6 +53,59 @@
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
+/* Configuration ************************************************************/
+
+#define HAVE_HSMCI_MTD 1
+#define HAVE_AT25_MTD 1
+
+/* Can't support MMC/SD if the card interface(s) are not enable */
+
+#if !defined(CONFIG_SAMA5_HSMCI0) && !defined(CONFIG_SAMA5_HSMCI1)
+# undef HAVE_HSMCI_MTD
+#endif
+
+/* Can't support MMC/SD features if mountpoints are disabled */
+
+#if defined(HAVE_HSMCI_MTD) && defined(CONFIG_DISABLE_MOUNTPOINT)
+# warning Mountpoints disabled. No MMC/SD support
+# undef HAVE_HSMCI_MTD
+#endif
+
+/* We need PIO interrupts on PIOD to support card detect interrupts */
+
+#if defined(HAVE_HSMCI_MTD) && !defined(CONFIG_SAMA5_PIOD_IRQ)
+# warning PIOD interrupts not enabled. No MMC/SD support.
+# undef HAVE_HSMCI_MTD
+#endif
+
+/* Can't support the AT25 device if it SPI0 or AT25 support are not enabled */
+
+#if !defined(CONFIG_SAMA5_SPI0) || !defined(CONFIG_MTD_AT25)
+# undef HAVE_AT25_MTD
+#endif
+
+/* Can't support AT25 features if mountpoints are disabled or if we were not
+ * asked to mount the AT25 part
+ */
+
+#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_SAMA5_AT25_AUTOMOUNT)
+# undef HAVE_AT25_MTD
+#endif
+
+/* If we are going to mount the AT25, then they user must also have told
+ * us what to do with it by setting one of these.
+ */
+
+#if !defined(CONFIG_SAMA5_AT25_FTL) && !defined(CONFIG_SAMA5_AT25_NXFFS)
+# undef HAVE_AT25_MTD
+#endif
+
+#if defined(CONFIG_SAMA5_AT25_FTL) && defined(CONFIG_SAMA5_AT25_NXFFS)
+# warning Both CONFIG_SAMA5_AT25_FTL and CONFIG_SAMA5_AT25_NXFFS are set
+# warning Ignoring CONFIG_SAMA5_AT25_NXFFS
+# undef CONFIG_SAMA5_AT25_NXFFS
+#endif
+
/* LEDs *****************************************************************************/
/* There are two LEDs on the SAMA5D3 series-CM board that can be controlled
* by software. A blue LED is controlled via PIO pins. A red LED normally
@@ -229,7 +282,7 @@ void sam_sdram_config(void);
*
****************************************************************************/
-#ifdef CONFIG_MTD_AT25
+#ifdef HAVE_AT25_MTD
int sam_at25_initialize(int minor);
#endif
@@ -241,7 +294,7 @@ int sam_at25_initialize(int minor);
*
****************************************************************************/
-#if defined(CONFIG_SAMA5_HSMCI0) || defined(CONFIG_SAMA5_HSMCI1)
+#ifdef HAVE_HSMCI_MTD
int sam_hsmci_initialize(int slotno, int minor);
#endif
@@ -253,7 +306,7 @@ int sam_hsmci_initialize(int slotno, int minor);
*
************************************************************************************/
-#if defined(CONFIG_SAMA5_HSMCI0) || defined(CONFIG_SAMA5_HSMCI1)
+#ifdef HAVE_HSMCI_MTD
bool sam_cardinserted(int slotno);
#endif
@@ -261,11 +314,11 @@ bool sam_cardinserted(int slotno);
* Name: sam_writeprotected
*
* Description:
- * Check if a card is inserted into the selected HSMCI slot
+ * Check if the card in the MMCSD slot is write protected
*
************************************************************************************/
-#ifdef HAVE_MMCSD
+#ifdef HAVE_HSMCI_MTD
bool sam_writeprotected(int slotno);
#endif