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
This commit is contained in:
patacongo 2012-07-13 16:03:13 +00:00
parent 4b77a153c4
commit 0db083917a
3 changed files with 159 additions and 5 deletions

View File

@ -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.

View File

@ -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

View File

@ -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
@ -84,6 +128,61 @@
# endif
#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();
}