Add driver for Atmel AT45DB161 FLASH

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2940 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2010-09-12 02:22:13 +00:00
parent f7bc561d3b
commit 8a5df19e8b
9 changed files with 868 additions and 49 deletions
+2
View File
@@ -1279,3 +1279,5 @@
* sched/sem_wait.c and sem_waitirq.c - Eliminate a race condition
that can occur when a semaphore wait is interrupt by a signal.
(see email thread: http://tech.groups.yahoo.com/group/nuttx/message/530)
* drivers/mtd/at45db.c - Add a driver for the Atmel AT45DB161D 4Mbit
SPI FLASH part (untested on initial check-in).
+3 -1
View File
@@ -8,7 +8,7 @@
<tr align="center" bgcolor="#e4e4e4">
<td>
<h1><big><font color="#3c34ec"><i>NuttX RTOS</i></font></big></h1>
<p>Last Updated: September 9, 2010</p>
<p>Last Updated: September 11, 2010</p>
</td>
</tr>
</table>
@@ -1974,6 +1974,8 @@ nuttx-5.11 2010-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
* sched/sem_wait.c and sem_waitirq.c - Eliminate a race condition
that can occur when a semaphore wait is interrupt by a signal.
(see email thread: http://tech.groups.yahoo.com/group/nuttx/message/530)
* drivers/mtd/at45db.c - Add a driver for the Atmel AT45DB161D 4Mbit
SPI FLASH part (untested on initial check-in).
pascal-2.1 2010-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
+11 -6
View File
@@ -12,7 +12,7 @@
<h1><big><font color="#3c34ec">
<i>NuttX RTOS Porting Guide</i>
</font></big></h1>
<p>Last Updated: September 10, 2010</p>
<p>Last Updated: September 11, 2010</p>
</td>
</tr>
</table>
@@ -2596,16 +2596,21 @@ build
<li>
<code>CONFIG_PAGING_M25PX</code>:
Use the m25px.c FLASH driver.
If this is selected, then the MTD interface to the M25Px device will be used to support paging.
If this is selected, then the MTD interface to the M25Px device will be used to support paging.
</li>
<li>
<code>CONFIG_PAGING_M25PX_BINOFFSET</code>:
If CONFIG_PAGING_M25PX is defined then CONFIG_PAGING_M25PX_BINOFFSET will be used to specify the offset in bytes into the FLASH device where the NuttX binary image is located.
<code>CONFIG_PAGING_AT45DB</code>:
Use the at45db.c FLASH driver.
If this is selected, then the MTD interface to the Atmel AT45DB device will be used to support paging.
</li>
<li>
<code>CONFIG_PAGING_BINOFFSET</code>:
If CONFIG_PAGING_M25PX or CONFIG_PAGING_AT45DB is defined then CONFIG_PAGING_BINOFFSET will be used to specify the offset in bytes into the FLASH device where the NuttX binary image is located.
Default: 0
</li>
<li>
<code>CONFIG_PAGING_M25PX_SPIPORT</code>:
If CONFIG_PAGING_M25PX is defined and the device has multiple SPI busses (ports), then this configuration should be set to indicate which SPI port the M25Px device is connected.
<code>CONFIG_PAGING_SPIPORT</code>:
If CONFIG_PAGING_M25PX or CONFIG_PAGING_AT45DB is defined and the device has multiple SPI busses (ports), then this configuration should be set to indicate which SPI port the device is connected.
Default: 0
</li>
</ul>
+9 -6
View File
@@ -423,14 +423,17 @@ defconfig -- This is a configuration file similar to the Linux
CONFIG_PAGING_M25PX - Use the m25px.c FLASH driver. If this is selected,
then the MTD interface to the M25Px device will be used to support
paging.
CONFIG_PAGING_M25PX_BINOFFSET - If CONFIG_PAGING_M25PX is defined then
CONFIG_PAGING_M25PX_BINOFFSET will be used to specify the offset
CONFIG_PAGING_AT45DB - Use the at45db.c FLASH driver. If this is selected,
then the MTD interface to the Atmel AT45DB device will be used to support
paging.
CONFIG_PAGING_BINOFFSET - If CONFIG_PAGING_M25PX or is CONFIG_PAGING_AT45DB
defined then CONFIG_PAGING_BINOFFSET will be used to specify the offset
in bytes into the FLASH device where the NuttX binary image is located.
Default: 0
CONFIG_PAGING_M25PX_SPIPORT - If CONFIG_PAGING_M25PX is defined and
the device has multiple SPI busses (ports), then this configuration
should be set to indicate which SPI port the M25Px device is connected.
Default: 0
CONFIG_PAGING_SPIPORT - If CONFIG_PAGING_M25PX CONFIG_PAGING_AT45DB is
defined and the device has multiple SPI busses (ports), then this
configuration should be set to indicate which SPI port the device is
connected. Default: 0
The following can be used to disable categories of APIs supported
by the OS. If the compiler supports weak functions, then it
+12 -8
View File
@@ -427,14 +427,17 @@ CONFIG_SIG_SIGWORK=4
# CONFIG_PAGING_M25PX - Use the m25px.c FLASH driver. If this is selected,
# then the MTD interface to the M25Px device will be used to support
# paging.
# CONFIG_PAGING_M25PX_BINOFFSET - If CONFIG_PAGING_M25PX is defined then
# CONFIG_PAGING_M25PX_BINOFFSET will be used to specify the offset
# CONFIG_PAGING_AT45DB - Use the at45db.c FLASH driver. If this is selected,
# then the MTD interface to the Atmel AT45DB device will be used to support
# paging.
# CONFIG_PAGING_BINOFFSET - If CONFIG_PAGING_M25PX or CONFIG_PAGING_AT45DB
# is defined then CONFIG_PAGING_BINOFFSET will be used to specify the offset
# in bytes into the FLASH device where the NuttX binary image is located.
# Default: 0
# CONFIG_PAGING_M25PX_SPIPORT - If CONFIG_PAGING_M25PX is defined and
# the device has multiple SPI busses (ports), then this configuration
# should be set to indicate which SPI port the M25Px device is connected.
# Default: 0
# CONFIG_PAGING_SPIPORT - If CONFIG_PAGING_M25PX or CONFIG_PAGING_AT45DB
# is defined and the device has multiple SPI busses (ports), then this
# configuration should be set to indicate which SPI port the device is
# connected. Default: 0
#
CONFIG_PAGING=y
CONFIG_PAGING_PAGESIZE=1024
@@ -457,8 +460,9 @@ CONFIG_PAGING_MOUNTPT="/mnt/pgsrc"
CONFIG_PAGING_MINOR=0
CONFIG_PAGING_SDSLOT=0
CONFIG_PAGING_M25PX=n
CONFIG_PAGING_M25PX_BINOFFSET=0
CONFIG_PAGING_M25PX_SPIPORT=0
CONFIG_PAGING_AT45DB=n
CONFIG_PAGING_BINOFFSET=0
CONFIG_PAGING_SPIPORT=0
#
# The following can be used to disable categories of
+37 -25
View File
@@ -62,7 +62,7 @@
# endif
#endif
#ifdef CONFIG_PAGING_M25PX
#if defined(CONFIG_PAGING_M25PX) || defined(CONFIG_PAGING_AT45DB)
# include <sys/ioctl.h>
# include <nuttx/ioctl.h>
# include <nuttx/spi.h>
@@ -94,10 +94,18 @@
/* Sanity check: We can only perform paging using a single source device */
#if defined(CONFIG_PAGING_M25PX) && defined(CONFIG_PAGING_AT45DB)
# error "Both CONFIG_PAGING_M25PX and CONFIG_PAGING_AT45DB are defined"
# undef CONFIG_PAGING_M25PX
#endif
#if defined(CONFIG_PAGING_BINPATH) && defined(CONFIG_PAGING_M25PX)
# error "Both CONFIG_PAGING_BINPATH and CONFIG_PAGING_M25PX are defined"
# undef CONFIG_PAGING_BINPATH
#endif
#if defined(CONFIG_PAGING_BINPATH) && defined(CONFIG_PAGING_AT45DB)
# error "Both CONFIG_PAGING_BINPATH and CONFIG_PAGING_AT45DB are defined"
# undef CONFIG_PAGING_BINPATH
#endif
/* Are we accessing the page source data through a file path? */
@@ -140,7 +148,7 @@
/* Are we accessing the page source data through the M25P* MTD device? */
#ifdef CONFIG_PAGING_M25PX
#if defined(CONFIG_PAGING_M25PX) || defined(CONFIG_PAGING_AT45DB)
/* Verify that SPI support is enabld */
@@ -152,14 +160,14 @@
* of the NuttX binary image.
*/
# ifndef CONFIG_PAGING_M25PX_BINOFFSET
# define CONFIG_PAGING_M25PX_BINOFFSET 0
# ifndef CONFIG_PAGING_BINOFFSET
# define CONFIG_PAGING_BINOFFSET 0
# endif
/* Make sure that some value is defined for the SPI port number */
# ifndef CONFIG_PAGING_M25PX_SPIPORT
# define CONFIG_PAGING_M25PX_SPIPORT 0
# ifndef CONFIG_PAGING_SPIPORT
# define CONFIG_PAGING_SPIPORT 0
# endif
#endif
@@ -179,7 +187,7 @@ struct pg_source_s
/* State structured needd to support paging through the M25P* MTD interface. */
#ifdef CONFIG_PAGING_M25PX
#if defined(CONFIG_PAGING_M25PX) || defined(CONFIG_PAGING_AT45DB)
struct pg_source_s
{
/* If interrupts or DMA are used, then we will have to defer initialization */
@@ -204,7 +212,7 @@ struct pg_source_s
* Private Data
****************************************************************************/
#if defined(CONFIG_PAGING_BINPATH) || defined(CONFIG_PAGING_M25PX)
#if defined(CONFIG_PAGING_BINPATH) || defined(CONFIG_PAGING_M25PX) || defined(CONFIG_PAGING_AT45DB)
static struct pg_source_s g_pgsrc;
#endif
@@ -277,7 +285,7 @@ static inline void lpc313x_initsrc(void)
}
}
#elif defined(CONFIG_PAGING_M25PX)
#elif defined(CONFIG_PAGING_M25PX) || defined(CONFIG_PAGING_AT45DB)
static inline void lpc313x_initsrc(void)
{
#ifdef CONFIG_DEBUG
@@ -295,12 +303,16 @@ static inline void lpc313x_initsrc(void)
/* First get an instance of the SPI device interface */
FAR struct spi_dev_s *spi = up_spiinitialize(CONFIG_PAGING_M25PX_SPIPORT);
FAR struct spi_dev_s *spi = up_spiinitialize(CONFIG_PAGING_SPIPORT);
DEBUGASSERT(spi != NULL);
/* Then bind the SPI interface to the M25Px MTD driver */
/* Then bind the SPI interface to the MTD driver */
#ifdef CONFIG_PAGING_M25PX
g_pgsrc.mtd = m25p_initialize(spi);
#else
g_pgsrc.mtd = at45db_initialize(spi);
#endif
DEBUGASSERT(g_pgsrc.mtd != NULL);
/* Verify that we can use the device */
@@ -315,7 +327,7 @@ static inline void lpc313x_initsrc(void)
DEBUGASSERT(ret >= 0);
capacity = g_pgsrc.geo.erasesize*g_pgsrc.geo.neraseblocks;
pgllvdbg("capacity: %d\n", capacity);
DEBUGASSERT(capacity >= (CONFIG_PAGING_M25PX_BINOFFSET + PG_TEXT_VSIZE));
DEBUGASSERT(capacity >= (CONFIG_PAGING_BINOFFSET + PG_TEXT_VSIZE));
#endif
#if defined(CONFIG_LPC313x_SPI_INTERRUPTS) || defined(CONFIG_LPC313x_SPI_DMA)
@@ -394,7 +406,7 @@ int up_fillpage(FAR _TCB *tcb, FAR void *vpage)
ssize_t nbytes;
off_t offset;
off_t pos;
#elif defined(CONFIG_PAGING_M25PX)
#elif defined(CONFIG_PAGING_M25PX) || defined(CONFIG_PAGING_AT45DB)
ssize_t nbytes;
off_t offset;
#endif
@@ -432,11 +444,11 @@ int up_fillpage(FAR _TCB *tcb, FAR void *vpage)
DEBUGASSERT(nbytes == PAGESIZE);
return OK;
#elif defined(CONFIG_PAGING_M25PX) /* !CONFIG_PAGING_BINPATH */
#elif defined(CONFIG_PAGING_M25PX) || defined(CONFIG_PAGING_AT45DB) /* !CONFIG_PAGING_BINPATH */
/* If CONFIG_PAGING_M25PX is defined, use the m25px.c FLASH driver. If this
* is selected, then the MTD interface to the M25Px device will be used to
* support paging.
/* If CONFIG_PAGING_M25PX or CONFIG_PAGING_AT45DB is defined, use the
* SPI corresponding FLASH driver. If either are selected, then the
* MTD interface to the device will be used to support paging.
*
* If the driver is configured to use interrupts or DMA, then it must be
* initialized in this context.
@@ -450,7 +462,7 @@ int up_fillpage(FAR _TCB *tcb, FAR void *vpage)
* virtual address. File offset 0 corresponds to PG_LOCKED_VBASE.
*/
offset = (off_t)tcb->xcp.far - PG_LOCKED_VBASE + CONFIG_PAGING_M25PX_BINOFFSET;
offset = (off_t)tcb->xcp.far - PG_LOCKED_VBASE + CONFIG_PAGING_BINOFFSET;
/* Read the page at the correct offset into the SPI FLASH device */
@@ -458,12 +470,12 @@ int up_fillpage(FAR _TCB *tcb, FAR void *vpage)
DEBUGASSERT(nbytes == PAGESIZE);
return OK;
#else /* !CONFIG_PAGING_BINPATH && !CONFIG_PAGING_M25PX */
#else /* !CONFIG_PAGING_BINPATH && !CONFIG_PAGING_M25PX && !CONFIG_PAGING_AT45DB */
# warning "Not implemented"
return -ENOSYS;
#endif /* !CONFIG_PAGING_BINPATH && !CONFIG_PAGING_M25PX */
#endif /* !CONFIG_PAGING_BINPATH && !CONFIG_PAGING_M25PX && !CONFIG_PAGING_AT45DB */
}
#else /* CONFIG_PAGING_BLOCKINGFILL */
@@ -477,7 +489,7 @@ int up_fillpage(FAR _TCB *tcb, FAR void *vpage, up_pgcallback_t pg_callback)
#if defined(CONFIG_PAGING_BINPATH)
# error "File system-based paging must always be implemented with blocking calls"
#elif defined(CONFIG_PAGING_M25PX)
#elif defined(CONFIG_PAGING_M25PX) || defined(CONFIG_PAGING_AT45DB)
# error "SPI FLASH paging must always be implemented with blocking calls"
#else
# warning "Not implemented"
@@ -521,11 +533,11 @@ void weak_function lpc313x_pginitialize(void)
* time that up_fillpage() is called.
*/
#elif defined(CONFIG_PAGING_M25PX)
#elif defined(CONFIG_PAGING_M25PX) || defined(CONFIG_PAGING_AT45DB)
/* If CONFIG_PAGING_M25PX is defined, use the m25px.c FLASH driver. If this
* is selected, then the MTD interface to the M25Px device will be used to
* support paging.
/* If CONFIG_PAGING_M25PX or CONFIG_PAGING_AT45DB is defined, use the corresponding
* FLASH driver. If either is selected, then the MTD interface to the device
* will be used to support paging.
*
* If the driver is not configured to use interrupts or DMA, then it is
* probably safe to initialize it in this context.
+2 -2
View File
@@ -1,7 +1,7 @@
############################################################################
# drivers/mtd/Make.defs
#
# Copyright (C) 2009 Gregory Nutt. All rights reserved.
# Copyright (C) 2009-2010 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
#
# Redistribution and use in source and binary forms, with or without
@@ -34,5 +34,5 @@
############################################################################
MTD_ASRCS =
MTD_CSRCS = ftl.c m25px.c
MTD_CSRCS = ftl.c m25px.c at45db.c
File diff suppressed because it is too large Load Diff
+13 -1
View File
@@ -2,7 +2,7 @@
* include/nuttx/mtd.h
* Memory Technology Device (MTD) interface
*
* Copyright (C) 2009 Gregory Nutt. All rights reserved.
* Copyright (C) 2009-2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -154,6 +154,18 @@ EXTERN int ftl_initialize(int minor, uint8_t *buffer, FAR struct mtd_dev_s *mtd)
EXTERN FAR struct mtd_dev_s *m25p_initialize(FAR struct spi_dev_s *dev);
/************************************************************************************
* Name: at45db_initialize
*
* Description:
* Create an initialize MTD device instance. MTD devices are not registered
* in the file system, but are created as instances that can be bound to
* other functions (such as a block or character driver front end).
*
************************************************************************************/
EXTERN FAR struct mtd_dev_s *at45db_initialize(FAR struct spi_dev_s *dev);
#undef EXTERN
#ifdef __cplusplus
}