summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2013-06-15 10:56:42 -0600
committerGregory Nutt <gnutt@nuttx.org>2013-06-15 10:56:42 -0600
commitd84fcb39c0ef2675298227c08b45f16be13a78cb (patch)
treea9443ab9e2922b8bd4c2024f72095122c5c35b21
parent123f7dc4f8825a277f2e416558bbb49fa19cc2b7 (diff)
downloadnuttx-d84fcb39c0ef2675298227c08b45f16be13a78cb.tar.gz
nuttx-d84fcb39c0ef2675298227c08b45f16be13a78cb.tar.bz2
nuttx-d84fcb39c0ef2675298227c08b45f16be13a78cb.zip
Oops.. files that I forgot to add in the last commit
-rw-r--r--nuttx/configs/sam4l-xplained/src/sam_mmcsd.c126
-rw-r--r--nuttx/configs/sam4l-xplained/src/sam_nsh.c120
2 files changed, 246 insertions, 0 deletions
diff --git a/nuttx/configs/sam4l-xplained/src/sam_mmcsd.c b/nuttx/configs/sam4l-xplained/src/sam_mmcsd.c
new file mode 100644
index 000000000..e922b8f9c
--- /dev/null
+++ b/nuttx/configs/sam4l-xplained/src/sam_mmcsd.c
@@ -0,0 +1,126 @@
+/****************************************************************************
+ * config/shenzhou/src/sam_mmcsd.c
+ *
+ * Copyright (C) 2013 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
+ *
+ * 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 <stdio.h>
+#include <debug.h>
+#include <errno.h>
+
+#include <nuttx/spi.h>
+#include <nuttx/mmcsd.h>
+
+#ifdef CONFIG_SAM4L_XPLAINED_IOMODULE
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+/* Configuration ************************************************************/
+
+#ifdef CONFIG_DISABLE_MOUNTPOINT
+# error Mountpoints are disabled (CONFIG_DISABLE_MOUNTPOINT=y)
+#endif
+
+#ifndef CONFIG_SAM34_SPI
+# error SPI support is required (CONFIG_SAM34_SPI)
+#endif
+
+#ifndef CONFIG_MMCSD
+# error MMC/SD support is required (CONFIG_MMCSD)
+#endif
+
+#define SAM34_MMCSDSPIPORTNO 0 /* Port is SPI (there is only one port) */
+#define SAM34_MMCSDSLOTNO 0 /* There is only one slot */
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: sam_sdinitialize
+ *
+ * Description:
+ * Initialize the SPI-based SD card. Requires
+ * - CONFIG_SAM4L_XPLAINED_IOMODULE=y,
+ * - CONFIG_DISABLE_MOUNTPOINT=n,
+ * - CONFIG_MMCSD=y, and
+ * - CONFIG_SAM34_SPI=y
+ *
+ *****************************************************************************/
+
+int sam_sdinitialize(int minor)
+{
+#ifdef HAVE_MMCSD
+ FAR struct spi_dev_s *spi;
+ int ret;
+
+ /* Get the SPI port */
+
+ fvdbg("Initializing SPI port %d\n", SAM34_MMCSDSPIPORTNO);
+
+ spi = up_spiinitialize(SAM34_MMCSDSPIPORTNO);
+ if (!spi)
+ {
+ fdbg("Failed to initialize SPI port %d\n", SAM34_MMCSDSPIPORTNO);
+ return -ENODEV;
+ }
+
+ fvdbg("Successfully initialized SPI port %d\n", SAM34_MMCSDSPIPORTNO);
+
+ /* Bind the SPI port to the slot */
+
+ fvdbg("Binding SPI port %d to MMC/SD slot %d\n",
+ SAM34_MMCSDSPIPORTNO, SAM34_MMCSDSLOTNO);
+
+ ret = mmcsd_spislotinitialize(minor, SAM34_MMCSDSLOTNO, spi);
+ if (ret < 0)
+ {
+ fdbg("Failed to bind SPI port %d to MMC/SD slot %d: %d\n",
+ SAM34_MMCSDSPIPORTNO, SAM34_MMCSDSLOTNO, ret);
+ return ret;
+ }
+
+ fvdbg("Successfuly bound SPI port %d to MMC/SD slot %d\n",
+ SAM34_MMCSDSPIPORTNO, SAM34_MMCSDSLOTNO);
+#endif
+
+ return OK;
+}
+
+#endif /* CONFIG_SAM4L_XPLAINED_IOMODULE */
diff --git a/nuttx/configs/sam4l-xplained/src/sam_nsh.c b/nuttx/configs/sam4l-xplained/src/sam_nsh.c
new file mode 100644
index 000000000..e5c77a926
--- /dev/null
+++ b/nuttx/configs/sam4l-xplained/src/sam_nsh.c
@@ -0,0 +1,120 @@
+/****************************************************************************
+ * config/shenzhou/src/sam_nsh.c
+ *
+ * Copyright (C) 2012 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
+ *
+ * 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 <stdio.h>
+#include <debug.h>
+
+#include "sam4l-xplained.h"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+#ifdef CONFIG_SAM4L_XPLAINED_IOMODULE
+/* Support for the SD card slot on the I/O1 module */
+/* Verify NSH PORT and SLOT settings */
+
+# define SAM34_MMCSDSPIPORTNO 0 /* Port is SPI (there is only one port) */
+# define SAM34_MMCSDSLOTNO 0 /* There is only one slot */
+
+# if defined(CONFIG_NSH_MMCSDSLOTNO) && CONFIG_NSH_MMCSDSLOTNO != SAM34_MMCSDSLOTNO
+# error Only one MMC/SD slot: Slot 0 (CONFIG_NSH_MMCSDSLOTNO)
+# endif
+
+# if defined(CONFIG_NSH_MMCSDSPIPORTNO) && CONFIG_NSH_MMCSDSPIPORTNO != SAM34_MMCSDSPIPORTNO
+# error Only one MMC/SD port: Port 0 (CONFIG_NSH_MMCSDSPIPORTNO)
+# endif
+
+/* Default MMC/SD minor number */
+
+# ifndef CONFIG_NSH_MMCSDMINOR
+# define CONFIG_NSH_MMCSDMINOR 0
+# endif
+#endif
+
+/* Debug ********************************************************************/
+
+#ifdef CONFIG_CPP_HAVE_VARARGS
+# ifdef CONFIG_DEBUG
+# define message(...) lowsyslog(__VA_ARGS__)
+# else
+# define message(...) printf(__VA_ARGS__)
+# endif
+#else
+# ifdef CONFIG_DEBUG
+# define message lowsyslog
+# else
+# define message printf
+# endif
+#endif
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nsh_archinitialize
+ *
+ * Description:
+ * Perform architecture specific initialization
+ *
+ ****************************************************************************/
+
+int nsh_archinitialize(void)
+{
+#ifdef CONFIG_SAM4L_XPLAINED_IOMODULE
+ int ret;
+#endif
+
+ /* Initialize the SPI-based MMC/SD slot */
+
+#ifdef CONFIG_SAM4L_XPLAINED_IOMODULE
+ ret = sam_sdinitialize(CONFIG_NSH_MMCSDMINOR);
+ if (ret < 0)
+ {
+ message("nsh_archinitialize: Failed to initialize MMC/SD slot: %d\n",
+ ret);
+ return ret;
+ }
+#endif
+
+ return OK;
+}