summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-07-13 16:03:13 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-07-13 16:03:13 +0000
commit7ff1487aeaabd0db47028d3919c37863c1b94258 (patch)
tree26d3878d2b971cb3523134d71701d12867ad23d7
parentf8af550c7d1f860440060e553b36da103c6b759c (diff)
downloadnuttx-7ff1487aeaabd0db47028d3919c37863c1b94258.tar.gz
nuttx-7ff1487aeaabd0db47028d3919c37863c1b94258.tar.bz2
nuttx-7ff1487aeaabd0db47028d3919c37863c1b94258.zip
Implement basic SPIFI block driver for the LPC43xx (doesn't work)
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4938 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r--nuttx/configs/lpc4330-xplorer/README.txt22
-rw-r--r--nuttx/configs/lpc4330-xplorer/nsh/defconfig31
-rw-r--r--nuttx/configs/lpc4330-xplorer/src/up_nsh.c111
-rw-r--r--nuttx/include/nuttx/ramdisk.h27
4 files changed, 177 insertions, 14 deletions
diff --git a/nuttx/configs/lpc4330-xplorer/README.txt b/nuttx/configs/lpc4330-xplorer/README.txt
index b0385592d..e3697f6e7 100644
--- a/nuttx/configs/lpc4330-xplorer/README.txt
+++ b/nuttx/configs/lpc4330-xplorer/README.txt
@@ -867,3 +867,25 @@ Where <subdir> is one of the following:
CONFIG_BOOT_SRAM=y : Executing in SRAM
CONFIG_LPC32_CODEREDW=y : Code Red under Windows
+
+ This configuration has some special options that can be used to
+ create a block device on the SPIFI FLASH:
+
+ CONFIG_SPIFI_BLKDRVR - Enable to create a block driver on the SPFI
+ device.
+ CONFIG_SPIFI_DEVNO - SPIFI minor device number. The SPFI device will
+ be at /dev/ramN, where N is the value of CONFIG_SPIFI_DEVNO.
+ Default: 0.
+ CONFIG_SPIFI_RDONLY - Create a read only device on SPIFI.
+ CONFIG_SPIFI_OFFSET - Offset the beginning of the block driver this
+ many bytes into the device address space. Default 0.
+ CONFIG_SPIFI_BLKSIZE - The size of one block. SPIFI is not block
+ oriented, so most any size of the block used in the SPIFI block
+ device can be used. NOTE: FAT will support only sector sizes of
+ 512, 1024, 2048, or 4096. Default: 512
+ CONFIG_SPIFI_NBLOCKS - The number of blocks in the file system,
+ each of size CONFIG_SPIFI_BLKSIZE. The end of the file system
+ will be at device offset:
+ CONFIG_SPIFI_OFFSET + CONFIG_SPIFI_BLKSIZE*CONFIG_SPIFI_NBLOCKS
+ The must assure that this does offset does not go beyond the end
+ of the FLASH memory.
diff --git a/nuttx/configs/lpc4330-xplorer/nsh/defconfig b/nuttx/configs/lpc4330-xplorer/nsh/defconfig
index a14013152..4bb270bb8 100644
--- a/nuttx/configs/lpc4330-xplorer/nsh/defconfig
+++ b/nuttx/configs/lpc4330-xplorer/nsh/defconfig
@@ -381,6 +381,7 @@ CONFIG_DEBUG=n
CONFIG_DEBUG_VERBOSE=n
CONFIG_DEBUG_SYMBOLS=n
CONFIG_DEBUG_SCHED=n
+CONFIG_DEBUG_FS=n
CONFIG_HAVE_CXX=n
CONFIG_HAVE_CXXINITIALIZE=n
@@ -657,6 +658,35 @@ CONFIG_MMCSD_MMCSUPPORT=n
CONFIG_MMCSD_HAVECARDDETECT=n
#
+# This configuration has some special options that can be used to
+# create a block device on the SPIFI FLASH:
+#
+# CONFIG_SPIFI_BLKDRVR - Enable to create a block driver on the SPFI
+# device.
+# CONFIG_SPIFI_DEVNO - SPIFI minor device number. The SPFI device will
+# be at /dev/rdN, where N is the value of CONFIG_SPIFI_DEVNO.
+# Default: 0.
+# CONFIG_SPIFI_RDONLY - Create a read only device on SPIFI.
+# CONFIG_SPIFI_OFFSET - Offset the beginning of the block driver this
+# many bytes into the device address space. Default 0.
+# CONFIG_SPIFI_BLKSIZE - The size of one block. SPIFI is not block
+# oriented, so most any size of the block used in the SPIFI block
+# device can be used. NOTE: FAT will support only sector sizes of 512,
+# 1024, 2048, or 4096. Default: 512
+# CONFIG_SPIFI_NBLOCKS - The number of blocks in the file system,
+# each of size CONFIG_SPIFI_BLKSIZE. The end of the file system
+# will be at device offset:
+# CONFIG_SPIFI_OFFSET + CONFIG_SPIFI_BLKSIZE*CONFIG_SPIFI_NBLOCKS
+# The must assure that this does offset does not go beyond the end
+# of the FLASH memory.
+#
+CONFIG_SPIFI_BLKDRVR=n
+CONFIG_SPIFI_DEVNO=0
+CONFIG_SPIFI_RDONLY=n
+CONFIG_SPIFI_OFFSET=0
+CONFIG_SPIFI_BLKSIZE=512
+CONFIG_SPIFI_NBLOCKS=(1024*1024/512)
+
# TCP/IP and UDP support via uIP
# CONFIG_NET - Enable or disable all network features
# CONFIG_NET_IPv6 - Build in support for IPv6
@@ -866,6 +896,7 @@ CONFIG_EXAMPLE_UIP_DHCPC=n
#
# Settings for examples/nettest
+#
CONFIG_EXAMPLE_NETTEST_SERVER=n
CONFIG_EXAMPLE_NETTEST_PERFORMANCE=n
CONFIG_EXAMPLE_NETTEST_NOMAC=n
diff --git a/nuttx/configs/lpc4330-xplorer/src/up_nsh.c b/nuttx/configs/lpc4330-xplorer/src/up_nsh.c
index 98387dfe1..c9284ab5b 100644
--- a/nuttx/configs/lpc4330-xplorer/src/up_nsh.c
+++ b/nuttx/configs/lpc4330-xplorer/src/up_nsh.c
@@ -44,14 +44,21 @@
#include <debug.h>
#include <errno.h>
-#include <nuttx/spi.h>
-#include <nuttx/mmcsd.h>
+/* This should be removed someday when we are confident in SPIFI */
+
+#ifdef CONFIG_DEBUG_FS
+# include "up_arch.h"
+# include "chip/lpc43_cgu.h"
+# include "chip/lpc43_ccu.h"
+#endif
+
+#include "chip.h"
+#include <nuttx/ramdisk.h>
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
-
-/* Configuration ************************************************************/
+/* USB Configuration ********************************************************/
/* PORT and SLOT number probably depend on the board configuration */
@@ -68,6 +75,43 @@
# undef CONFIG_NSH_HAVEUSBDEV
#endif
+/* SPIFI Configuration ******************************************************/
+/* CONFIG_SPIFI_BLKDRVR - Enable to create a block driver on the SPFI device.
+ * CONFIG_SPIFI_DEVNO - SPIFI minor device number. The SPFI device will be
+ * at /dev/ramN, where N is the value of CONFIG_SPIFI_DEVNO. Default: 0.
+ * CONFIG_SPIFI_RDONLY - Create a read only device on SPIFI.
+ * CONFIG_SPIFI_OFFSET - Offset the beginning of the block driver this many
+ * bytes into the device address space. Default 0.
+ * CONFIG_SPIFI_BLKSIZE - The size of one block. SPIFI is not block oriented,
+ * so most any size of the block used in the SPIFI block device can be
+ * used. NOTE: FAT will support only sector sizes of 512, 1024, 2048, or
+ * 4096. Default: 512
+ * CONFIG_SPIFI_NBLOCKS - The number of blocks in the file system, each of
+ * size CONFIG_SPIFI_BLKSIZE. The end of the file system will be at
+ * device offset:
+ * CONFIG_SPIFI_OFFSET + CONFIG_SPIFI_BLKSIZE*CONFIG_SPIFI_NBLOCKS
+ * The must assure that this does offset does not go beyond the end of
+ * the FLASH memory.
+ */
+
+#ifdef CONFIG_SPIFI_BLKDRVR
+# ifndef CONFIG_SPIFI_DEVNO
+# define CONFIG_SPIFI_DEVNO 0
+# endif
+# ifndef CONFIG_SPIFI_OFFSET
+# define CONFIG_SPIFI_OFFSET 0
+# endif
+# ifndef CONFIG_SPIFI_BLKSIZE
+# define CONFIG_SPIFI_BLKSIZE 512
+# endif
+# ifndef CONFIG_SPIFI_NBLOCKS
+# error "Need number of SPIFI blocks (CONFIG_SPIFI_NBLOCKS)"
+# endif
+#endif
+
+#define SPIFI_BUFFER \
+ (FAR uint8_t *)(LPC43_LOCSRAM_SPIFI_BASE + CONFIG_SPIFI_OFFSET)
+
/* Debug ********************************************************************/
#ifdef CONFIG_CPP_HAVE_VARARGS
@@ -85,6 +129,61 @@
#endif
/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nsh_spifi_initialize
+ *
+ * Description:
+ * Make the SPIFI (or part of it) into a block driver that can hold a
+ * file system.
+ *
+ * SPIFI AHB register clock:
+ * Base clock = BASE_M4_CLK
+ * Branch clock = CLK_M4_SPIFI
+ * SPIFI serial clock input:
+ * Base clock = BASE_SPIFI_CLK
+ * Branch clock = SPIFI_CLK
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_SPIFI_BLKDRVR
+static int nsh_spifi_initialize(void)
+{
+ /* This should be removed someday when we are confident in SPIFI */
+
+#ifdef CONFIG_DEBUG_FS
+ fdbg("BASE_SPIFI_CLK=%08x\n",
+ getreg32(LPC43_BASE_SPIFI_CLK));
+ fdbg("SPFI CFG=%08x STAT=%08x\n",
+ getreg32(LPC43_CCU1_SPIFI_CFG), getreg32(LPC43_CCU1_SPIFI_STAT));
+ fdbg("M4 SPFI CFG=%08x STAT=%08x\n",
+ getreg32(LPC43_CCU1_M4_SPIFI_CFG), getreg32(LPC43_CCU1_M4_SPIFI_STAT));
+#endif
+
+#ifdef CONFIG_SPIFI_RDONLY
+ /* Register a read-only SPIFI RAM disk at /dev/ramN, where N is the
+ * value of CONFIG_SPIFI_DEVNO.
+ */
+
+ return romdisk_register(CONFIG_SPIFI_DEVNO, SPIFI_BUFFER,
+ CONFIG_SPIFI_NBLOCKS, CONFIG_SPIFI_BLKSIZE);
+#else
+ /* Register a write-able SPIFI RAM disk at /dev/ramN, where N is the
+ * value of CONFIG_SPIFI_DEVNO.
+ */
+
+ return ramdisk_register(CONFIG_SPIFI_DEVNO, SPIFI_BUFFER,
+ CONFIG_SPIFI_NBLOCKS, CONFIG_SPIFI_BLKSIZE,
+ true);
+#endif
+}
+#else
+# define nsh_spifi_initialize() (OK)
+#endif
+
+/****************************************************************************
* Public Functions
****************************************************************************/
@@ -98,5 +197,7 @@
int nsh_archinitialize(void)
{
- return OK;
+ /* Initialize the SPIFI block device */
+
+ return nsh_spifi_initialize();
}
diff --git a/nuttx/include/nuttx/ramdisk.h b/nuttx/include/nuttx/ramdisk.h
index 9ad79afe9..8c93c872a 100644
--- a/nuttx/include/nuttx/ramdisk.h
+++ b/nuttx/include/nuttx/ramdisk.h
@@ -1,8 +1,8 @@
/****************************************************************************
* nuttx/ramdisk.h
*
- * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ * Copyright (C) 2008-2009, 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
@@ -33,8 +33,8 @@
*
****************************************************************************/
-#ifndef __NUTTX_RAMDISK_H
-#define __NUTTX_RAMDISK_H
+#ifndef __INCLUDE_NUTTX_RAMDISK_H
+#define __INCLUDE_NUTTX_RAMDISK_H
/****************************************************************************
* Included Files
@@ -64,21 +64,30 @@ extern "C" {
#define EXTERN extern
#endif
-/* Non-standard function to register a ramdisk or a romdisk
+/****************************************************************************
+ * Name: ramdisk_register or romdisk_register
+ *
+ * Description:
+ * Non-standard function to register a ramdisk or a romdisk
*
+ * Input Parmeters:
* minor: Selects suffix of device named /dev/ramN, N={1,2,3...}
* nsectors: Number of sectors on device
* sectize: The size of one sector
* writeenabled: true: can write to ram disk
* buffer: RAM disk backup memory
- */
+ *
+ * Returned Valued:
+ * Zero on success; a negated errno value on failure.
+ *
+ ****************************************************************************/
#ifdef CONFIG_FS_WRITABLE
-EXTERN int ramdisk_register(int minor, uint8_t *buffer, uint32_t nsectors,
+EXTERN int ramdisk_register(int minor, FAR uint8_t *buffer, uint32_t nsectors,
uint16_t sectize, bool writeenabled);
#define romdisk_register(m,b,n,s) ramdisk_register(m,b,n,s,0)
#else
-EXTERN int romdisk_register(int minor, uint8_t *buffer, uint32_t nsectors,
+EXTERN int romdisk_register(int minor, FAR uint8_t *buffer, uint32_t nsectors,
uint16_t sectize);
#endif
@@ -87,4 +96,4 @@ EXTERN int romdisk_register(int minor, uint8_t *buffer, uint32_t nsectors,
}
#endif
-#endif /* __NUTTX_RAMDISK_H */
+#endif /* __INCLUDE_NUTTX_RAMDISK_H */