#include "mtd.h"
Include dependency graph for nand.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Data Structures | |
struct | nand_hw_control |
struct | nand_chip |
struct | nand_flash_dev |
struct | nand_manufacturers |
struct | nand_bbt_descr |
: Manufacturer name | |
struct nand_manufacturers - NAND Flash Manufacturer ID Structure
: manufacturer ID code of device. | |
#define | NAND_BBT_NRBITS_MSK 0x0000000F |
#define | NAND_BBT_1BIT 0x00000001 |
#define | NAND_BBT_2BIT 0x00000002 |
#define | NAND_BBT_4BIT 0x00000004 |
#define | NAND_BBT_8BIT 0x00000008 |
#define | NAND_BBT_LASTBLOCK 0x00000010 |
#define | NAND_BBT_ABSPAGE 0x00000020 |
#define | NAND_BBT_SEARCH 0x00000040 |
#define | NAND_BBT_PERCHIP 0x00000080 |
#define | NAND_BBT_VERSION 0x00000100 |
#define | NAND_BBT_CREATE 0x00000200 |
#define | NAND_BBT_SCANALLPAGES 0x00000400 |
#define | NAND_BBT_SCANEMPTY 0x00000800 |
#define | NAND_BBT_WRITE 0x00001000 |
#define | NAND_BBT_SAVECONTENT 0x00002000 |
#define | NAND_BBT_SCAN2NDPAGE 0x00004000 |
#define | NAND_BBT_SCAN_MAXBLOCKS 4 |
#define | NAND_SMALL_BADBLOCK_POS 5 |
#define | NAND_LARGE_BADBLOCK_POS 0 |
nand_flash_dev | nand_flash_ids [] |
nand_manufacturers | nand_manuf_ids [] |
int | nand_scan_bbt (struct mtd_info *mtd, struct nand_bbt_descr *bd) |
int | nand_update_bbt (struct mtd_info *mtd, loff_t offs) |
int | nand_default_bbt (struct mtd_info *mtd) |
int | nand_isbad_bbt (struct mtd_info *mtd, loff_t offs, int allowbbt) |
int | nand_erase_nand (struct mtd_info *mtd, struct erase_info *instr, int allowbbt) |
int | nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf, u_char *oob_buf, struct nand_oobinfo *oobsel, int flags) |
Defines | |
#define | NAND_MAX_CHIPS 8 |
#define | NAND_MAX_OOBSIZE 64 |
#define | NAND_CTL_SETNCE 1 |
#define | NAND_CTL_CLRNCE 2 |
#define | NAND_CTL_SETCLE 3 |
#define | NAND_CTL_CLRCLE 4 |
#define | NAND_CTL_SETALE 5 |
#define | NAND_CTL_CLRALE 6 |
#define | NAND_CTL_SETWP 7 |
#define | NAND_CTL_CLRWP 8 |
#define | NAND_CMD_READ0 0 |
#define | NAND_CMD_READ1 1 |
#define | NAND_CMD_PAGEPROG 0x10 |
#define | NAND_CMD_READOOB 0x50 |
#define | NAND_CMD_ERASE1 0x60 |
#define | NAND_CMD_STATUS 0x70 |
#define | NAND_CMD_STATUS_MULTI 0x71 |
#define | NAND_CMD_SEQIN 0x80 |
#define | NAND_CMD_READID 0x90 |
#define | NAND_CMD_ERASE2 0xd0 |
#define | NAND_CMD_RESET 0xff |
#define | NAND_CMD_READSTART 0x30 |
#define | NAND_CMD_CACHEDPROG 0x15 |
#define | NAND_CMD_DEPLETE1 0x100 |
#define | NAND_CMD_DEPLETE2 0x38 |
#define | NAND_CMD_STATUS_MULTI 0x71 |
#define | NAND_CMD_STATUS_ERROR 0x72 |
#define | NAND_CMD_STATUS_ERROR0 0x73 |
#define | NAND_CMD_STATUS_ERROR1 0x74 |
#define | NAND_CMD_STATUS_ERROR2 0x75 |
#define | NAND_CMD_STATUS_ERROR3 0x76 |
#define | NAND_CMD_STATUS_RESET 0x7f |
#define | NAND_CMD_STATUS_CLEAR 0xff |
#define | NAND_STATUS_FAIL 0x01 |
#define | NAND_STATUS_FAIL_N1 0x02 |
#define | NAND_STATUS_TRUE_READY 0x20 |
#define | NAND_STATUS_READY 0x40 |
#define | NAND_STATUS_WP 0x80 |
#define | NAND_ECC_NONE 0 |
#define | NAND_ECC_SOFT 1 |
#define | NAND_ECC_HW3_256 2 |
#define | NAND_ECC_HW3_512 3 |
#define | NAND_ECC_HW6_512 4 |
#define | NAND_ECC_HW8_512 6 |
#define | NAND_ECC_HW12_2048 7 |
#define | NAND_ECC_READ 0 |
#define | NAND_ECC_WRITE 1 |
#define | NAND_ECC_READSYN 2 |
#define | NAND_GET_DEVICE 0x80 |
#define | NAND_NO_AUTOINCR 0x00000001 |
#define | NAND_BUSWIDTH_16 0x00000002 |
#define | NAND_NO_PADDING 0x00000004 |
#define | NAND_CACHEPRG 0x00000008 |
#define | NAND_COPYBACK 0x00000010 |
#define | NAND_IS_AND 0x00000020 |
#define | NAND_4PAGE_ARRAY 0x00000040 |
#define | BBT_AUTO_REFRESH 0x00000080 |
#define | NAND_SAMSUNG_LP_OPTIONS (NAND_NO_PADDING | NAND_CACHEPRG | NAND_COPYBACK) |
#define | NAND_CANAUTOINCR(chip) (!(chip->options & NAND_NO_AUTOINCR)) |
#define | NAND_MUST_PAD(chip) (!(chip->options & NAND_NO_PADDING)) |
#define | NAND_HAS_CACHEPROG(chip) ((chip->options & NAND_CACHEPRG)) |
#define | NAND_HAS_COPYBACK(chip) ((chip->options & NAND_COPYBACK)) |
#define | NAND_CHIPOPTIONS_MSK (0x0000ffff & ~NAND_NO_AUTOINCR) |
#define | NAND_USE_FLASH_BBT 0x00010000 |
#define | NAND_HWECC_SYNDROME 0x00020000 |
#define | NAND_SKIP_BBTSCAN 0x00040000 |
#define | NAND_OOBBUF_ALLOC 0x40000000 |
#define | NAND_DATABUF_ALLOC 0x80000000 |
#define | NAND_MFR_TOSHIBA 0x98 |
#define | NAND_MFR_SAMSUNG 0xec |
#define | NAND_MFR_FUJITSU 0x04 |
#define | NAND_MFR_NATIONAL 0x8f |
#define | NAND_MFR_RENESAS 0x07 |
#define | NAND_MFR_STMICRO 0x20 |
#define | NAND_MFR_HYNIX 0xad |
Enumerations | |
enum | nand_state_t { FL_READY, FL_READING, FL_WRITING, FL_ERASING, FL_SYNCING, FL_CACHEDPRG, FL_PM_SUSPENDED, FL_READY, FL_READING, FL_WRITING, FL_ERASING, FL_SYNCING, FL_CACHEDPRG, FL_PM_SUSPENDED } |
Functions | |
int | nand_scan (struct mtd_info *mtd, int max_chips) |
void | nand_release (struct mtd_info *mtd) |
int | nand_read_raw (struct mtd_info *mtd, uint8_t *buf, loff_t from, size_t len, size_t ooblen) |
#define NAND_CANAUTOINCR | ( | chip | ) | (!(chip->options & NAND_NO_AUTOINCR)) |
#define NAND_CHIPOPTIONS_MSK (0x0000ffff & ~NAND_NO_AUTOINCR) |
#define NAND_CTL_CLRALE 6 |
Definition at line 105 of file nand.h.
Referenced by crisv32_hwcontrol(), nand_command(), nand_command_lp(), and nand_hwcontrol().
#define NAND_CTL_CLRCLE 4 |
Definition at line 101 of file nand.h.
Referenced by crisv32_hwcontrol(), nand_command(), nand_command_lp(), and nand_hwcontrol().
#define NAND_CTL_CLRNCE 2 |
Definition at line 97 of file nand.h.
Referenced by crisv32_hwcontrol(), nand_hwcontrol(), and nand_select_chip().
#define NAND_CTL_SETALE 5 |
Definition at line 103 of file nand.h.
Referenced by crisv32_hwcontrol(), nand_command(), nand_command_lp(), and nand_hwcontrol().
#define NAND_CTL_SETCLE 3 |
Definition at line 99 of file nand.h.
Referenced by crisv32_hwcontrol(), nand_command(), nand_command_lp(), and nand_hwcontrol().
#define NAND_CTL_SETNCE 1 |
Definition at line 95 of file nand.h.
Referenced by crisv32_hwcontrol(), nand_hwcontrol(), and nand_select_chip().
#define NAND_DATABUF_ALLOC 0x80000000 |
#define NAND_ECC_HW12_2048 7 |
#define NAND_ECC_NONE 0 |
Definition at line 161 of file nand.h.
Referenced by nand_do_read_ecc(), nand_scan_tail(), and nand_wait().
#define NAND_ECC_SOFT 1 |
Definition at line 163 of file nand.h.
Referenced by crisv32_nand_flash_probe(), nand_do_read_ecc(), nand_scan(), nand_scan_tail(), nand_wait(), and rflflash_init().
#define NAND_HAS_CACHEPROG | ( | chip | ) | ((chip->options & NAND_CACHEPRG)) |
#define NAND_HAS_COPYBACK | ( | chip | ) | ((chip->options & NAND_COPYBACK)) |
#define NAND_HWECC_SYNDROME 0x00020000 |
#define NAND_MUST_PAD | ( | chip | ) | (!(chip->options & NAND_NO_PADDING)) |
#define NAND_OOBBUF_ALLOC 0x40000000 |
#define NAND_SAMSUNG_LP_OPTIONS (NAND_NO_PADDING | NAND_CACHEPRG | NAND_COPYBACK) |
enum nand_state_t |
int nand_default_bbt | ( | struct mtd_info * | mtd | ) |
nand_default_bbt - [NAND Interface] Select a default bad block table for the device : MTD device structure
This function selects the default bad block table support for the device and calls the nand_scan_bbt function
Definition at line 1152 of file nand_bbt.c.
References agand_flashbased, nand_chip::badblock_pattern, bbt_main_descr, nand_chip::bbt_md, bbt_mirror_descr, nand_chip::bbt_td, largepage_flashbased, largepage_memorybased, NAND_IS_AND, nand_scan_bbt(), NAND_USE_FLASH_BBT, mtd_info::oobblock, nand_chip::options, mtd_info::priv, smallpage_flashbased, and smallpage_memorybased.
int nand_do_read_ecc | ( | struct mtd_info * | mtd, | |
loff_t | from, | |||
size_t | len, | |||
size_t * | retlen, | |||
u_char * | buf, | |||
u_char * | oob_buf, | |||
struct nand_oobinfo * | oobsel, | |||
int | flags | |||
) |
nand_do_read_ecc - [MTD Interface] Read data with ECC : MTD device structure : offset to read from : number of bytes to read : pointer to variable to store the number of read bytes : the databuffer to put data : filesystem supplied oob data buffer (can be NULL) : oob selection structure : flag to indicate if nand_get_device/nand_release_device should be preformed and how many corrected error bits are acceptable: bits 0..7 - number of tolerable errors bit 8 - 0 == do not get/release chip, 1 == get/release chip
NAND read with ECC
Definition at line 1148 of file nand_base.c.
References nand_chip::autooob, nand_chip::calculate_ecc, nand_chip::cmdfunc, nand_chip::correct_data, D, data_buf, nand_chip::data_poi, DEBUG, nand_chip::ecc, nand_chip::eccbytes, nand_oobinfo::eccbytes, nand_chip::eccmode, nand_oobinfo::eccpos, nand_chip::eccsize, nand_chip::eccsteps, nand_chip::enable_hwecc, FL_READING, HZ, jiffies, memcpy(), MTD_DEBUG_LEVEL0, MTD_DEBUG_LEVEL3, MTD_NANDECC_AUTOPL_USR, MTD_NANDECC_AUTOPLACE, MTD_NANDECC_PLACE, NAND_CANAUTOINCR, NAND_CMD_READ0, NAND_ECC_NONE, NAND_ECC_READ, NAND_ECC_READSYN, NAND_ECC_SOFT, NAND_GET_DEVICE, nand_get_device(), NAND_HWECC_SYNDROME, nand_release_device(), nand_wait_ready(), num, mtd_info::oobblock, nand_oobinfo::oobfree, mtd_info::oobsize, nand_chip::page_shift, nand_chip::pagebuf, nand_chip::pagemask, nand_chip::phys_erase_shift, printk, mtd_info::priv, read, nand_chip::read_buf, nand_chip::select_chip, mtd_info::size, udelay, and nand_oobinfo::useecc.
Referenced by nand_read(), and nand_read_ecc().
int nand_erase_nand | ( | struct mtd_info * | mtd, | |
struct erase_info * | instr, | |||
int | allowbbt | |||
) |
nand_erase_nand - [Internal] erase block(s) : MTD device structure : erase instruction : allow erasing the bbt area
Erase one ore more blocks
Definition at line 1864 of file nand_base.c.
References erase_info::addr, BBT_AUTO_REFRESH, BBT_PAGE_MASK, nand_chip::bbt_td, nand_chip::chip_shift, DEBUG, nand_chip::erase_cmd, nand_chip::errstat, erase_info::fail_addr, FL_ERASING, KERN_WARNING, erase_info::len, MTD_DEBUG_LEVEL0, MTD_DEBUG_LEVEL3, mtd_erase_callback(), MTD_ERASE_DONE, MTD_ERASE_FAILED, MTD_ERASING, NAND_BBT_PERCHIP, nand_block_checkbad(), nand_check_wp(), nand_get_device(), NAND_MAX_CHIPS, nand_release_device(), NAND_STATUS_FAIL, nand_update_bbt(), nand_chip::numchips, nand_bbt_descr::options, nand_chip::options, nand_chip::page_shift, nand_chip::pagebuf, nand_chip::pagemask, nand_bbt_descr::pages, nand_chip::phys_erase_shift, printk, mtd_info::priv, nand_chip::select_chip, mtd_info::size, erase_info::state, and nand_chip::waitfunc.
Referenced by nand_erase().
int nand_isbad_bbt | ( | struct mtd_info * | mtd, | |
loff_t | offs, | |||
int | allowbbt | |||
) |
nand_isbad_bbt - [NAND Interface] Check if a block is bad : MTD device structure : offset in the device : allow access to bad block table region
Definition at line 1201 of file nand_bbt.c.
References nand_chip::bbt, DEBUG, int, MTD_DEBUG_LEVEL2, and mtd_info::priv.
int nand_read_raw | ( | struct mtd_info * | mtd, | |
uint8_t * | buf, | |||
loff_t | from, | |||
size_t | len, | |||
size_t | ooblen | |||
) |
nand_read_raw - [GENERIC] Read raw data including oob into buffer : MTD device structure : temporary buffer : offset to read from : number of bytes to read : number of oob data bytes to read
Read raw data including oob into buffer
Definition at line 1507 of file nand_base.c.
References nand_chip::chip_delay, nand_chip::chip_shift, nand_chip::cmdfunc, DEBUG, nand_chip::dev_ready, dprintf, FL_READING, int, MTD_DEBUG_LEVEL0, NAND_CANAUTOINCR, NAND_CMD_READ0, nand_get_device(), nand_release_device(), nand_wait_ready(), mtd_info::oobblock, mtd_info::oobsize, nand_chip::page_shift, nand_chip::pagemask, nand_chip::phys_erase_shift, mtd_info::priv, nand_chip::read_buf, nand_chip::select_chip, mtd_info::size, and udelay.
Referenced by read_abs_bbts(), and search_bbt().
void nand_release | ( | struct mtd_info * | mtd | ) |
nand_release - [NAND Interface] Free resources held by the NAND device : MTD device structure
Definition at line 2561 of file nand_base.c.
References nand_chip::bbt, nand_chip::buffers, nand_chip::data_buf, del_mtd_device(), kfree, NAND_DATABUF_ALLOC, NAND_OOBBUF_ALLOC, NAND_OWN_BUFFERS, nand_chip::oob_buf, nand_chip::options, and mtd_info::priv.
int nand_scan | ( | struct mtd_info * | mtd, | |
int | maxchips | |||
) |
nand_scan - [NAND Interface] Scan for the NAND device : MTD device structure : Number of chips to scan for
This fills out all the not initialized function pointers with the defaults. The flash ID is read and the mtd/chip structures are filled with the appropriate values. Buffers are allocated if they are not provided by the board driver
Definition at line 2541 of file nand_base.c.
References nand_chip::autooob, nand_chip::badblockpos, nand_chip::bbt_erase_shift, nand_chip::block_bad, nand_chip::block_markbad, BUG, nand_chip::calculate_ecc, caller_is_module, nand_chip::chip_delay, nand_chip::chip_shift, nand_chip::chipsize, nand_flash_dev::chipsize, nand_chip::cmdfunc, nand_chip::correct_data, D, data_buf, dprintf, nand_chip::eccbytes, nand_chip::eccmode, nand_chip::eccsize, nand_chip::erase_cmd, mtd_info::erasesize, nand_flash_dev::erasesize, free(), nand_manufacturers::id, malloc(), memset(), multi_erase_cmd(), name, NAND_4PAGE_ARRAY, nand_block_bad(), NAND_BUSWIDTH_16, nand_calculate_ecc(), NAND_CHIPOPTIONS_MSK, NAND_CMD_READID, nand_command(), nand_command_lp(), nand_correct_data(), NAND_DATABUF_ALLOC, nand_default_bbt(), nand_default_block_markbad, NAND_ECC_HW12_2048, NAND_ECC_SOFT, nand_flash_ids, NAND_HWECC_SUPPORT, NAND_LARGE_BADBLOCK_POS, nand_manuf_ids, NAND_MFR_SAMSUNG, NAND_NO_AUTOINCR, nand_oob_16, nand_oob_64, nand_oob_8, NAND_OOBBUF_ALLOC, nand_read_buf(), nand_read_buf16(), nand_read_byte(), nand_read_byte16(), nand_read_word(), NAND_SAMSUNG_LP_OPTIONS, nand_scan_ident(), nand_scan_tail(), nand_select_chip(), NAND_SMALL_BADBLOCK_POS, nand_verify_buf(), nand_verify_buf16(), nand_wait(), nand_write_buf(), nand_write_buf16(), nand_write_byte(), nand_write_byte16(), nand_write_word(), nand_chip::numchips, nand_chip::oob_buf, mtd_info::oobavail, mtd_info::oobblock, nand_oobinfo::oobfree, mtd_info::oobsize, nand_chip::options, nand_flash_dev::options, mtd_info::owner, nand_chip::page_shift, nand_flash_dev::pagesize, nand_chip::phys_erase_shift, printk, mtd_info::priv, nand_chip::read_buf, nand_chip::read_byte, nand_chip::read_word, nand_chip::scan_bbt, nand_chip::select_chip, single_erase_cmd(), mtd_info::size, nand_chip::verify_buf, nand_chip::waitfunc, nand_chip::write_buf, nand_chip::write_byte, and nand_chip::write_word.
int nand_scan_bbt | ( | struct mtd_info * | mtd, | |
struct nand_bbt_descr * | bd | |||
) |
nand_scan_bbt - [NAND Interface] scan, find, read and maybe create bad block table(s) : MTD device structure : descriptor for the good/bad block search pattern
The function checks, if a bad block table(s) is/are already available. If not it scans the device for manufacturer marked good / bad blocks and writes the bad block table(s) to the selected place.
The bad block table memory is allocated here. It must be freed by calling the nand_free_bbt function.
Definition at line 955 of file nand_bbt.c.
References bbt_b_1, bbt_b_2, BBT_LEN_1, BBT_LEN_2, buf, check_create(), GFP_KERNEL, KERN_ERR, kfree, kmalloc, mark_bbt_region(), memset(), NAND_BBT_ABSPAGE, nand_memory_bbt(), mtd_info::oobsize, nand_bbt_descr::options, printk, mtd_info::priv, read_abs_bbts(), search_read_bbts(), and mtd_info::size.
int nand_update_bbt | ( | struct mtd_info * | mtd, | |
loff_t | offs | |||
) |
nand_update_bbt - [NAND Interface] update bad block table(s) : MTD device structure : the offset of the newly marked block
The function updates the bad block table(s)
Definition at line 1023 of file nand_bbt.c.
References bbt_b_2, BBT_LEN_2, buf, int, KERN_ERR, NAND_BBT_PERCHIP, NAND_BBT_WRITE, mtd_info::oobsize, nand_bbt_descr::options, printk, mtd_info::priv, mtd_info::size, nand_bbt_descr::version, and write_bbt().
struct nand_flash_dev nand_flash_ids[] |
Definition at line 35 of file nand_ids.c.
struct nand_manufacturers nand_manuf_ids[] |
Definition at line 130 of file nand_ids.c.