⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 davincihd_nandflash.h

📁 用于dm6467 开发平台的uboot源码
💻 H
字号:
/*
 *  Copyright 2007 by Spectrum Digital Incorporated.
 *  All rights reserved. Property of Spectrum Digital Incorporated.
 */

/*
 *  NAND Flash header file
 *
 */

#ifndef NANDFLASH_
#define NANDFLASH_

#ifdef __cplusplus
extern "C" {
#endif

#include "davincihd.h"

/* ------------------------------------------------------------------------ *
 *  NAND Flash Control Signals                                              *
 * ------------------------------------------------------------------------ */
/* Control signals */
#define NAND_BASE                   ( EMIF_CS2_BASE )
#define NAND_DATA                   *( volatile Uint8* )( NAND_BASE + 0x00 )
#define NAND_CLE_PTR                *( volatile Uint8* )( NAND_BASE + 0x80000 )
#define NAND_ALE_PTR                *( volatile Uint8* )( NAND_BASE + 0x40000 )
/* Read/Busy signal */
#define NAND_READ_RB                ( EMIFA_NANDFSR & 1 )

/* ------------------------------------------------------------------------ *
 *  NAND Flash Errors                                                       *
 * ------------------------------------------------------------------------ */
#define NAND_ERR_NOERROR            ( 0 )
#define NAND_ERR_TIMEOUT            ( -1 )

/* ------------------------------------------------------------------------ *
 *  NAND Flash Organization                                                 *
 * ------------------------------------------------------------------------ */
typedef struct
{
    /* Read Id info */
    Uint8  mfg_id;
    Uint8  dev_id;
    Uint8  internal;
    Uint8  organization;
    Uint8  plane;

    /* Extracted info */
    Uint32 device_size;
    Uint32 bus_width;
    Uint32 access_time;

    /* Page info */
    Uint32 pages;
    Uint32 page_size;
    Uint32 spare_size;
    Uint32 page_addressing;
    Uint32 page_addr_incr;

    /* Block info */
    Uint32 pages_per_block;
    Uint32 blocks;
    Uint32 block_size;
    Uint32 block_addressing;
    Uint32 block_addr_incr;

    /* Bad pages/blocks */
    Uint32 invalid_pages;
    Uint32 invalid_page_table[80];
    Uint32 invalid_blocks;
    Uint32 invalid_block_table[80];

    /* Command Set */
    Uint8  use_read_confirm;
    Uint8  use_block_unlock;
} NAND_ORGANIZATION;

/* ------------------------------------------------------------------------ *
 *  NAND Flash Command Codes                                                *
 * ------------------------------------------------------------------------ */
/* Reset */
#define CMD_RESET                   0xff

/* Read */
#define CMD_READ                    0x00
#define CMD_READ_HALF               0x01
#define CMD_READ_SPARE              0x50
#define CMD_READ_CONFIRM            0x30
#define CMD_READID                  0x90
#define CMD_POINTER_MAIN            0x00
#define CMD_POINTER_MAIN_HALF       0x01
#define CMD_POINTER_SPARE           0x50

/* Cache Read [NAND01G-B] */
#define CMD_CACHE_READ              0x00
#define CMD_CACHE_READ_CONFIRM      0x31
#define CMD_EXIT_CACHE_READ         0x34

/* Page Write */
#define CMD_PROGRAM                 0x80
#define CMD_PROGRAM_CONFIRM         0x10

/* Random Input */
#define CMD_RANDOM_DATA_INPUT       0x85

/* Copy Back [NAND01G-B] */
#define CMD_COPYBACK                0x00
#define CMD_COPYBACK_CONFIRM1       0x35
#define CMD_COPYBACK_CONFIRM2       0x85
#define CMD_COPYBACK_CONFIRM3       0x10
/* Copy Back */
#define CMD_COPYBACK_CONFIRM        0x8a

/* Erase */
#define CMD_ERASE                   0x60
#define CMD_ERASE_CONFIRM           0xd0

/* Status */
#define CMD_STATUS                  0x70

/* Cache */
#define CMD_CACHE_PROGRAM           0x80
#define CMD_CACHE_PROGRAM_CONFIRM   0x15

/* Block Lock [NAND01G-B] */
#define CMD_BLOCK_LOCK_STATUS       0x7a
#define CMD_BLOCK_UNLOCK            0x23
#define CMD_BLOCK_UNLOCK_CONFIRM    0x24
#define CMD_BLOCK_LOCK              0x2a
#define CMD_BLOCK_LOCK_DOWN         0x2c

/* ------------------------------------------------------------------------ *
 *  CMD_STATUS Field Definitions                                            *
 * ------------------------------------------------------------------------ */
#define CMD_STATUS_SUCCESS                  0xfffe
#define CMD_STATUS_ERROR                    0x0001
#define CMD_STATUS_BUSY                     0xffbf
#define CMD_STATUS_READY                    0x0040
#define CMD_STATUS_WPROTECT                 0xff7f
#define CMD_STATUS_NOWPROTECT               0x0080

/* ------------------------------------------------------------------------ *
 *  Block and Page Organization                                             *
 * ------------------------------------------------------------------------ */
/* Small Page [512/16] */
#define PAGE_ADDR_07_916_1724_2526          1000
#define BLK_ADDR_9_1724_2526                2000

/* Large Page [2048/64] */
#define PAGE_ADDR_07_811_1219_2027          1001
#define BLK_ADDR_1819_2027                  2001

/* ------------------------------------------------------------------------ *
 *  Function Renaming                                                       *
 * ------------------------------------------------------------------------ */
/* BSL Function names */
#define DAVINCIHD_NANDFLASH_init            _NAND_init
#define DAVINCIHD_NANDFLASH_erase           _NAND_eraseBlock
#define DAVINCIHD_NANDFLASH_writePage       _NAND_writePage
#define DAVINCIHD_NANDFLASH_readPage        _NAND_readPage
#define DAVINCIHD_NANDFLASH_getTotalPages   _NAND_pages

/* Legacy */
#define NAND_PAGES                          _NAND_pages( )
#define NAND_PAGESIZE                       _NAND_pagesize( )
#define NAND_SPARESIZE                      _NAND_sparesize( )
#define NAND_PAGES_PER_BLOCK                _NAND_pagesperblock( )

/* ------------------------------------------------------------------------ *
 *  Prototypes                                                              *
 * ------------------------------------------------------------------------ */
Int16 _NAND_init( );
Int16 _NAND_getId( );
Int16 _NAND_eraseBlock( Uint32 start_block, Uint32 block_count );
Int16 _NAND_readPage ( Uint32 start_page, Uint32 rx, Uint32 page_count );
Int16 _NAND_writePage( Uint32 tx, Uint32 start_page, Uint32 page_count );

/* Legacy */
Uint32 _NAND_pagesize( );
Uint32 _NAND_sparesize( );
Uint32 _NAND_pagesperblock( );

#ifdef __cplusplus
}
#endif

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -