Add a driver for SST 25 FLASH

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4868 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2012-06-25 21:21:08 +00:00
parent e2dc5c99bd
commit b426006f96
4 changed files with 146 additions and 8 deletions

View File

@ -163,6 +163,14 @@ CONFIG_PIC32MX_IOPORTA=y
CONFIG_PIC32MX_IOPORTB=y
CONFIG_PIC32MX_IOPORTC=y
#
# Mirtoo Board Settings
#
CONFIG_MTD_SST25=n
#CONFIG_SST25_SPIMODE
#CONFIG_SST25_SPIFREQUENCY
CONFIG_SST25_SECTOR512=n
#
# PIC32MX Configuration Settings
#
@ -346,6 +354,8 @@ CONFIG_DEBUG=n
CONFIG_DEBUG_VERBOSE=n
CONFIG_DEBUG_SYMBOLS=n
CONFIG_DEBUG_SCHED=n
CONFIG_DEBUG_FS=n
CONFIG_DEBUG_SPI=n
CONFIG_HAVE_CXX=n
CONFIG_HAVE_CXXINITIALIZE=n

View File

@ -44,6 +44,10 @@ ifeq ($(CONFIG_PIC32MX_SPI2),y)
CSRCS += up_spi2.c
endif
ifeq ($(CONFIG_NSH_ARCHINIT),y)
CSRCS += up_nsh.c
endif
AOBJS = $(ASRCS:.S=$(OBJEXT))
COBJS = $(CSRCS:.c=$(OBJEXT))
@ -53,8 +57,8 @@ OBJS = $(AOBJS) $(COBJS)
ARCH_SRCDIR = $(TOPDIR)/arch/$(CONFIG_ARCH)/src
ifeq ($(WINTOOL),y)
CFLAGS += -I "${shell cygpath -w $(ARCH_SRCDIR)/chip}" \
-I "${shell cygpath -w $(ARCH_SRCDIR)/common}" \
-I "${shell cygpath -w $(ARCH_SRCDIR)/mips32}"
-I "${shell cygpath -w $(ARCH_SRCDIR)/common}" \
-I "${shell cygpath -w $(ARCH_SRCDIR)/mips32}"
else
CFLAGS += -I$(ARCH_SRCDIR)/chip -I$(ARCH_SRCDIR)/common -I$(ARCH_SRCDIR)/mips32
endif

126
configs/mirtoo/src/up_nsh.c Normal file
View File

@ -0,0 +1,126 @@
/****************************************************************************
* config/mirtoo/src/up_nsh.c
* arch/arm/src/board/up_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 <stdbool.h>
#include <stdio.h>
#include <errno.h>
#include <debug.h>
#ifdef CONFIG_PIC32MX_SPI2
# include <nuttx/spi.h>
# include <nuttx/mtd.h>
#endif
#include "pic32mx-internal.h"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/* Can't support the SST25 device if it SPI2 or SST25 support is not enabled */
#define HAVE_SST25 1
#if !defined(CONFIG_PIC32MX_SPI2) || !defined(CONFIG_MTD_SST25)
# undef HAVE_SST25
#endif
/* Can't support SST25 features if mountpoints are disabled */
#if defined(CONFIG_DISABLE_MOUNTPOINT)
# undef HAVE_SST25
#endif
/* Use minor device number 0 is not is provided */
#ifndef CONFIG_NSH_SST25MINOR
# define CONFIG_NSH_SST25MINOR 0
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nsh_archinitialize
*
* Description:
* Perform architecture specific initialization
*
****************************************************************************/
int nsh_archinitialize(void)
{
#ifdef HAVE_SST25
FAR struct spi_dev_s *spi;
FAR struct mtd_dev_s *mtd;
int ret;
/* Get the SPI port */
spi = up_spiinitialize(2);
if (!spi)
{
fdbg("ERROR: Failed to initialize SPI port 2\n");
return -ENODEV;
}
/* Now bind the SPI interface to the SST 25 SPI FLASH driver */
mtd = sst25_initialize(spi);
if (!mtd)
{
fdbg("ERROR: Failed to bind SPI port 2 to the SST 25 FLASH driver\n");
return -ENODEV;
}
/* And finally, use the FTL layer to wrap the MTD driver as a block driver */
ret = ftl_initialize(CONFIG_NSH_SST25MINOR, mtd);
if (ret < 0)
{
fdbg("ERROR: Initialize the FTL layer\n");
return -ENODEV;
}
#endif
return OK;
}

View File

@ -51,7 +51,7 @@
#include "chip.h"
#include "pic32mx-internal.h"
#include "pic32mx-pps.h"
#include "mirtoo_internal.h"
#include "mirtoo-internal.h"
#ifdef CONFIG_PIC32MX_SPI2
@ -119,8 +119,6 @@
void weak_function pic32mx_spi2initialize(void)
{
uint32_t regval;
/* Make sure that TRIS pins are set correctly. Configure the SPI pins as digital
* inputs and outputs first.
*/
@ -171,7 +169,7 @@ void weak_function pic32mx_spi2initialize(void)
struct spi_dev_s;
enum spi_dev_e;
void pic31mx_spi2select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
void pic32mx_spi2select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
{
spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
@ -185,13 +183,13 @@ void pic31mx_spi2select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool s
}
}
uint8_t pic31mx_spi2status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
uint8_t pic32mx_spi2status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
{
return 0;
}
#ifdef CONFIG_SPI_CMDDATA
int pic31mx_spi2cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
int pic32mx_spi2cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
{
return 0;
}