This module supports for NAND flash memory devices that conform to the "Open NAND Flash Interface" (ONFI) Specification. This modules implements basic flash operations like read, write and erase.
MODIFICATION HISTORY:
Ver Who Date Changes ----- ---- ---------- ----------------------------------------------- 1.00a nm 12/10/2010 First release 1.01a nm 28/02/2012 Fixed 16-bit issue with ONFI commands like read, write and read status command. The config structure width is updated after ONFI query with the parameter page width. 1.02a nm 20/09/2012 Removed setting of set_cycles and set_opmode register values as it is now done in FSBL using the PCW generated files. CR#678949. 1.03a nm 10/22/2012 Fixed CR# 673348. 1.04a nm 04/15/2013 Fixed CR# 704401. Removed warnings when compiled with -Wall and -Wextra option in bsp. 04/25/2013 Implemented PR# 699544. Added page cache read and program support. Added API's XNandPs_ReadCache and XNandPs_WriteCache for page cache support. Added ECC handling functions XNandPs_EccSetCfg, XNandPs_EccSetMemCmd1...etc, to support better usage of ECC block for page cache commands. Modified Read/Write API's so that there is common code for normal read/write and page cache commands. Disabling/Re-enabling ECC block in read/write API's of spare bytes since we don't calculate ECC for spare bytes.
#include "xnandps.h"
#include "xnandps_bbm.h"
#include "xnandps_onfi.h"
Functions | |
void | XNandPs_SendCommand (XNandPs *InstancePtr, XNandPs_CommandFormat *Command, int Page, int Column) |
void | XNandPs_InitBbtDesc (XNandPs *InstancePtr) |
int | XNandPs_ScanBbt (XNandPs *InstancePtr) |
u8 | Onfi_CmdReadStatus (XNandPs *InstancePtr) |
int | Onfi_NandInit (XNandPs *InstancePtr) |
int | XNandPs_CfgInitialize (XNandPs *InstancePtr, XNandPs_Config *ConfigPtr, u32 SmcBaseAddr, u32 FlashBaseAddr) |
int | XNandPs_Read (XNandPs *InstancePtr, u64 Offset, u32 Length, void *DestPtr, u8 *UserSparePtr) |
int | XNandPs_ReadCache (XNandPs *InstancePtr, u64 Offset, u32 Length, void *DestPtr, u8 *UserSparePtr) |
int | XNandPs_Write (XNandPs *InstancePtr, u64 Offset, u32 Length, void *SrcPtr, u8 *UserSparePtr) |
int | XNandPs_WriteCache (XNandPs *InstancePtr, u64 Offset, u32 Length, void *SrcPtr, u8 *UserSparePtr) |
int | XNandPs_ReadSpareBytes (XNandPs *InstancePtr, u32 Page, u8 *Buf) |
int | XNandPs_WriteSpareBytes (XNandPs *InstancePtr, u32 Page, u8 *Buf) |
int | XNandPs_EraseBlock (XNandPs *InstancePtr, u32 BlockNum) |
Variables | |
u32 | NandOob16 [] = {13, 14, 15} |
u32 | NandOob32 [] = {26, 27, 28, 29, 30, 31} |
u32 | NandOob64 [] |
XNandPs_CommandFormat | OnfiCommands [] |
|
This function sends read status command to the flash device.
|
|
This function initializes the NAND flash and gets the geometry information.
|
|
This function initializes a specific XNandPs device/instance. This function must be called prior to using the flash device to read or write any data.
|
|
This function erases a specific block in the NAND device.
|
|
This function initializes the Bad Block Table(BBT) descriptors with a predefined pattern for searching Bad Block Table(BBT) in flash.
|
|
This function reads the data from the Flash device and copies it into the specified user buffer. It doesn't check for the bad blocks while reading the flash pages that cross block boundary. User must take care of handling bad blocks.
|
|
This function reads the data from the Flash device using read page cache command and copies it into the specified user buffer. It doesn't check for the bad blocks while reading the flash pages that cross block boundary. User must take care of handling bad blocks.
|
|
This function reads the spare area of a page.
|
|
This function reads the Bad Block Table(BBT) if present in flash. If not it scans the flash for detecting factory marked bad blocks and creates a bad block table and write the Bad Block Table(BBT) into the flash.
|
|
This function sends a NAND command to the flash device.
|
|
This function programs the flash device(s) with data specified in the user buffer. The source and destination address must be aligned to the width of the flash's data bus. It doesn't check for the bad blocks while writing to the flash pages that cross block boundary. User must take care of handling bad blocks.
|
|
This function programs the flash device(s) with data specified in the user buffer using program cache command. The source and destination address must be aligned to the width of the flash's data bus. It doesn't check for the bad blocks while writing to the flash pages that cross block boundary. User must take care of handling bad blocks.
|
|
This function write to the spare area of a page.
|
|
Ecc position for 16 bytes spare area |
|
Ecc position for 32 bytes spare area |
|
Initial value: {52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63} |
|
This structure defines the onfi command format sent to the flash. |