mirror of
https://github.com/apache/nuttx.git
synced 2026-09-28 15:54:57 +08:00
More NAND stuff
This commit is contained in:
@@ -6079,4 +6079,5 @@
|
||||
(2013-11-16).
|
||||
* drivers/mtd/mtd_rawnand.c and include/nuttx/mtd/nand_raw.h: More
|
||||
NAND support (2013-11-17).
|
||||
* drivers/mtd/mtd_nandscheme.c: More NAND support (2013-11-17).
|
||||
|
||||
|
||||
+61
-117
File diff suppressed because it is too large
Load Diff
@@ -67,19 +67,15 @@ extern "C" {
|
||||
* Name: sam_nand_initialize
|
||||
*
|
||||
* Description:
|
||||
* Create and initialize a raw NAND 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).
|
||||
*
|
||||
* This MTD devices implements a RAW NAND interface: No ECC or sparing is
|
||||
* Create and initialize an raw NAND device instance. This driver
|
||||
* implements the RAW NAND interface: No software ECC or sparing is
|
||||
* performed here. Those necessary NAND features are provided by common,
|
||||
* higher level MTD layers found in drivers/mtd.
|
||||
*
|
||||
* higher level NAND MTD layers found in drivers/mtd.
|
||||
*
|
||||
* Input parameters:
|
||||
* cs - Chip select number (in the event that multiple NAND devices
|
||||
* are connected on-board).
|
||||
*
|
||||
*
|
||||
* Returned value.
|
||||
* On success a non-NULL pointer to an MTD device structure is returned;
|
||||
* NULL is returned on a failure.
|
||||
|
||||
@@ -87,6 +87,12 @@ config ARCH_NAND_HWECC
|
||||
|
||||
if MTD_NAND
|
||||
|
||||
config MTD_NAND_BLOCKCHECK
|
||||
bool "Block check"
|
||||
default y
|
||||
---help---
|
||||
Enable support for bad block checking.
|
||||
|
||||
config MTD_NAND_MAXNUMBLOCKS
|
||||
int "Max blocks"
|
||||
default 1024
|
||||
|
||||
@@ -46,7 +46,8 @@ CSRCS += mtd_partition.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_MTD_NAND),y)
|
||||
CSRCS += mtd_nand.c mtd_onfi.c mtd_rawnand.c mtd_nandmodel.c mtd_modeltab.c
|
||||
CSRCS += mtd_nand.c mtd_onfi.c mtd_nandscheme.c mtd_nandraw.c
|
||||
CSRCS += mtd_nandmodel.c mtd_modeltab.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_RAMMTD),y)
|
||||
|
||||
+165
-14
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* drivers/mtd/mtd_rawnand.c
|
||||
* drivers/mtd/mtd_nandraw.c
|
||||
*
|
||||
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -100,26 +100,92 @@
|
||||
#define READ_DATA16(raw) \
|
||||
(*((volatile uint16_t *)raw->dataaddr))
|
||||
|
||||
/* struct nand_raw_s operations */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: NAND_ERASEBLOCK
|
||||
*
|
||||
* Description:
|
||||
* Erases the specified block of the device.
|
||||
*
|
||||
* Input parameters:
|
||||
* raw - Lower-half, raw NAND FLASH interface
|
||||
* block - Number of the physical block to erase.
|
||||
*
|
||||
* Returned value.
|
||||
* OK is returned in succes; a negated errno value is returned on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#define NAND_ERASEBLOCK(r,b) ((r)->eraseblock(r,b))
|
||||
|
||||
/****************************************************************************
|
||||
* Name: NAND_READPAGE
|
||||
*
|
||||
* Description:
|
||||
* Reads the data and/or the spare areas of a page of a NAND FLASH into the
|
||||
* provided buffers.
|
||||
*
|
||||
* Input parameters:
|
||||
* raw - Lower-half, raw NAND FLASH interface
|
||||
* block - Number of the block where the page to read resides.
|
||||
* page - Number of the page to read inside the given block.
|
||||
* data - Buffer where the data area will be stored.
|
||||
* spare - Buffer where the spare area will be stored.
|
||||
*
|
||||
* Returned value.
|
||||
* OK is returned in succes; a negated errno value is returned on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#define NAND_READPAGE(r,b,p,d,s) ((r)->readpage(r,b,p,d,s))
|
||||
|
||||
/****************************************************************************
|
||||
* Name: NAND_WRITEPAGE
|
||||
*
|
||||
* Description:
|
||||
* Writes the data and/or the spare area of a page on a NAND FLASH chip.
|
||||
*
|
||||
* Input parameters:
|
||||
* raw - Lower-half, raw NAND FLASH interface
|
||||
* block - Number of the block where the page to write resides.
|
||||
* page - Number of the page to write inside the given block.
|
||||
* data - Buffer containing the data to be writting
|
||||
* spare - Buffer conatining the spare data to be written.
|
||||
*
|
||||
* Returned value.
|
||||
* OK is returned in succes; a negated errno value is returned on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#define NAND_WRITEPAGE(r,b,p,d,s) ((r)->writepage(r,b,p,d,s))
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/* This type represents the visible portion of the lower-half, raw NAND MTD
|
||||
* device. Rules:
|
||||
*
|
||||
* 1. The struct mtd_dev_s must appear at the beginning of the definition so
|
||||
* that you can freely cast between pointers to struct mtd_dev_s and struct
|
||||
* nand_raw_s.
|
||||
* 2. The lower-half driver may freely append additional information after
|
||||
* this required header information.
|
||||
* device. The lower-half driver may freely append additional information
|
||||
* after this required header information.
|
||||
*/
|
||||
|
||||
struct nand_raw_s
|
||||
{
|
||||
struct mtd_dev_s mtd; /* Externally visible part of the driver */
|
||||
/* NAND data */
|
||||
|
||||
struct nand_model_s model; /* The NAND model storage */
|
||||
uintptr_t cmdaddr; /* NAND command address base */
|
||||
uintptr_t addraddr; /* NAND address address base */
|
||||
uintptr_t dataaddr; /* NAND data address */
|
||||
|
||||
/* NAND operations */
|
||||
|
||||
CODE int (*eraseblock)(FAR struct nand_raw_s *raw, off_t block);
|
||||
CODE int (*readpage)(FAR struct nand_raw_s *raw, off_t block,
|
||||
unsigned int page, FAR void *data, FAR void *spare);
|
||||
CODE int (*writepage)(FAR struct nand_raw_s *raw, off_t block,
|
||||
unsigned int page, FAR const void *data,
|
||||
FAR const void *spare);
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -97,6 +97,152 @@ EXTERN const struct nand_scheme_s g_nand_sparescheme4096;
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nandscheme_readbadblockmarker
|
||||
*
|
||||
* Description:
|
||||
* Reads the bad block marker inside a spare area buffer using the provided
|
||||
* scheme.
|
||||
*
|
||||
* Input Parameters:
|
||||
* scheme Pointer to a nand_scheme_s instance.
|
||||
* spare Spare area buffer.
|
||||
* marker Pointer to the variable to store the bad block marker.
|
||||
*
|
||||
* Returned Values:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void nandscheme_readbadblockmarker(FAR const struct nand_scheme_s *scheme,
|
||||
FAR const uint8_t *spare,
|
||||
FAR uint8_t *marker);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nandscheme_readbadblockmarker
|
||||
*
|
||||
* Description:
|
||||
* Modifies the bad block marker inside a spare area, using the given
|
||||
* scheme.
|
||||
*
|
||||
* Input Parameters:
|
||||
* scheme Pointer to a nand_scheme_s instance.
|
||||
* spare Spare area buffer.
|
||||
* marker Bad block marker to write.
|
||||
*
|
||||
* Returned Values:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void nandscheme_writebadblockmarker(FAR const struct nand_scheme_s *scheme,
|
||||
FAR uint8_t *spare, uint8_t marker);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nandscheme_readecc
|
||||
*
|
||||
* Description:
|
||||
* Reads ECC information from a spare area using the provided scheme.
|
||||
*
|
||||
* Input Parameters:
|
||||
* scheme Pointer to a nand_scheme_s instance.
|
||||
* spare Spare area buffer.
|
||||
* ecc ECC buffer.
|
||||
*
|
||||
* Returned Values:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void nandscheme_readecc(FAR const struct nand_scheme_s *scheme,
|
||||
FAR const uint8_t *spare, FAR uint8_t *ecc);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nandschem_writeecc
|
||||
*
|
||||
* Description:
|
||||
* Writes ECC information in a spare area, using a particular scheme.
|
||||
*
|
||||
* Input Parameters:
|
||||
* scheme Pointer to a nand_scheme_s instance.
|
||||
* spare Spare area buffer.
|
||||
* ecc ECC buffer.
|
||||
*
|
||||
* Returned Values:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void nandscheme_writeecc(FAR const struct nand_scheme_s *scheme,
|
||||
FAR uint8_t *spare, FAR const uint8_t *ecc);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nandscheme_readextra
|
||||
*
|
||||
* Description:
|
||||
* Reads extra bytes of information from a spare area, using the provided
|
||||
* scheme.
|
||||
*
|
||||
* Input Parameters:
|
||||
* scheme Pointer to a nand_scheme_s instance.
|
||||
* spare Spare area buffer.
|
||||
* extra Extra bytes buffer.
|
||||
* size Number of extra bytes to read.
|
||||
* offset Index where to read the first extra byte.
|
||||
*
|
||||
* Returned Values:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void nandscheme_readextra(FAR const struct nand_scheme_s *scheme,
|
||||
FAR const uint8_t *spare, FAR void *extra,
|
||||
unsigned int size, unsigned int offset);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nandscheme_readextra
|
||||
*
|
||||
* Description:
|
||||
* Write extra bytes of information inside a spare area, using the provided
|
||||
* scheme.
|
||||
*
|
||||
* Input Parameters:
|
||||
* scheme Pointer to a nand_scheme_s instance.
|
||||
* spare Spare area buffer.
|
||||
* extra Extra bytes buffer.
|
||||
* size Number of extra bytes to write.
|
||||
* offset Index where to write the first extra byte.
|
||||
*
|
||||
* Returned Values:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void nandscheme_writeextra(FAR const struct nand_scheme_s *scheme,
|
||||
FAR uint8_t *spare, FAR const void *extra,
|
||||
unsigned int size, unsigned int offset);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nandscheme_readextra
|
||||
*
|
||||
* Description:
|
||||
* Build a scheme instance for 4096 page size nand flash
|
||||
*
|
||||
* Input Parameters:
|
||||
* scheme Pointer to a nand_scheme_s instance.
|
||||
* spareSize Size of spare area.
|
||||
* offset Index where to write the first extra byte.
|
||||
* size Number of extra bytes to write.
|
||||
* offset Index where to write the first extra byte.
|
||||
*
|
||||
* Returned Values:
|
||||
* OK on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nandscheme_build4086(FAR struct nand_scheme_s *scheme,
|
||||
unsigned int spareSize, unsigned int eccOffset);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user