os/linux-2.6-tag--devboard-R2_10-4/drivers/mtd/nand/nand_base.c File Reference

#include <linux/module.h>
#include <linux/delay.h>
#include <linux/errno.h>
#include <linux/err.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/types.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/nand.h>
#include <linux/mtd/nand_ecc.h>
#include <linux/mtd/compatmac.h>
#include <linux/interrupt.h>
#include <linux/bitops.h>
#include <linux/leds.h>
#include <asm/io.h>

Include dependency graph for nand_base.c:

Go to the source code of this file.

Defines

#define NOTALIGNED(x)   (x & (mtd->writesize-1)) != 0
#define BBT_PAGE_MASK   0xffffff3f
#define caller_is_module()   module_text_address((unsigned long)__builtin_return_address(0))

Functions

static int nand_get_device (struct nand_chip *chip, struct mtd_info *mtd, int new_state)
static int nand_do_write_oob (struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops)
 DEFINE_LED_TRIGGER (nand_led_trigger)
static void nand_release_device (struct mtd_info *mtd)
static uint8_t nand_read_byte (struct mtd_info *mtd)
static uint8_t nand_read_byte16 (struct mtd_info *mtd)
static u16 nand_read_word (struct mtd_info *mtd)
static void nand_select_chip (struct mtd_info *mtd, int chipnr)
static void nand_write_buf (struct mtd_info *mtd, const uint8_t *buf, int len)
static void nand_read_buf (struct mtd_info *mtd, uint8_t *buf, int len)
static int nand_verify_buf (struct mtd_info *mtd, const uint8_t *buf, int len)
static void nand_write_buf16 (struct mtd_info *mtd, const uint8_t *buf, int len)
static void nand_read_buf16 (struct mtd_info *mtd, uint8_t *buf, int len)
static int nand_verify_buf16 (struct mtd_info *mtd, const uint8_t *buf, int len)
static int nand_block_bad (struct mtd_info *mtd, loff_t ofs, int getchip)
static int nand_default_block_markbad (struct mtd_info *mtd, loff_t ofs)
static int nand_check_wp (struct mtd_info *mtd)
static int nand_block_checkbad (struct mtd_info *mtd, loff_t ofs, int getchip, int allowbbt)
void nand_wait_ready (struct mtd_info *mtd)
 EXPORT_SYMBOL_GPL (nand_wait_ready)
static void nand_command (struct mtd_info *mtd, unsigned int command, int column, int page_addr)
static void nand_command_lp (struct mtd_info *mtd, unsigned int command, int column, int page_addr)
static int nand_wait (struct mtd_info *mtd, struct nand_chip *chip)
static int nand_read_page_raw (struct mtd_info *mtd, struct nand_chip *chip, uint8_t *buf)
static int nand_read_page_swecc (struct mtd_info *mtd, struct nand_chip *chip, uint8_t *buf)
static int nand_read_page_hwecc (struct mtd_info *mtd, struct nand_chip *chip, uint8_t *buf)
static int nand_read_page_syndrome (struct mtd_info *mtd, struct nand_chip *chip, uint8_t *buf)
static uint8_t * nand_transfer_oob (struct nand_chip *chip, uint8_t *oob, struct mtd_oob_ops *ops)
static int nand_do_read_ops (struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops)
static int nand_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, uint8_t *buf)
static int nand_read_oob_std (struct mtd_info *mtd, struct nand_chip *chip, int page, int sndcmd)
static int nand_read_oob_syndrome (struct mtd_info *mtd, struct nand_chip *chip, int page, int sndcmd)
static int nand_write_oob_std (struct mtd_info *mtd, struct nand_chip *chip, int page)
static int nand_write_oob_syndrome (struct mtd_info *mtd, struct nand_chip *chip, int page)
static int nand_do_read_oob (struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops)
static int nand_read_oob (struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops)
static void nand_write_page_raw (struct mtd_info *mtd, struct nand_chip *chip, const uint8_t *buf)
static void nand_write_page_swecc (struct mtd_info *mtd, struct nand_chip *chip, const uint8_t *buf)
static void nand_write_page_hwecc (struct mtd_info *mtd, struct nand_chip *chip, const uint8_t *buf)
static void nand_write_page_syndrome (struct mtd_info *mtd, struct nand_chip *chip, const uint8_t *buf)
static int nand_write_page (struct mtd_info *mtd, struct nand_chip *chip, const uint8_t *buf, int page, int cached, int raw)
static uint8_t * nand_fill_oob (struct nand_chip *chip, uint8_t *oob, struct mtd_oob_ops *ops)
static int nand_do_write_ops (struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops)
static int nand_write (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const uint8_t *buf)
static int nand_write_oob (struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops)
static void single_erase_cmd (struct mtd_info *mtd, int page)
static void multi_erase_cmd (struct mtd_info *mtd, int page)
static int nand_erase (struct mtd_info *mtd, struct erase_info *instr)
int nand_erase_nand (struct mtd_info *mtd, struct erase_info *instr, int allowbbt)
static void nand_sync (struct mtd_info *mtd)
static int nand_block_isbad (struct mtd_info *mtd, loff_t offs)
static int nand_block_markbad (struct mtd_info *mtd, loff_t ofs)
static int nand_suspend (struct mtd_info *mtd)
static void nand_resume (struct mtd_info *mtd)
static void nand_set_defaults (struct nand_chip *chip, int busw)
static struct nand_flash_devnand_get_flash_type (struct mtd_info *mtd, struct nand_chip *chip, int busw, int *maf_id)
int nand_scan_ident (struct mtd_info *mtd, int maxchips)
int nand_scan_tail (struct mtd_info *mtd)
int nand_scan (struct mtd_info *mtd, int maxchips)
void nand_release (struct mtd_info *mtd)
 EXPORT_SYMBOL_GPL (nand_scan)
 EXPORT_SYMBOL_GPL (nand_scan_ident)
 EXPORT_SYMBOL_GPL (nand_scan_tail)
 EXPORT_SYMBOL_GPL (nand_release)
static int __init nand_base_init (void)
static void __exit nand_base_exit (void)
 module_init (nand_base_init)
 module_exit (nand_base_exit)
 MODULE_LICENSE ("GPL")
 MODULE_AUTHOR ("Steven J. Hill <sjhill@realitydiluted.com>, Thomas Gleixner <tglx@linutronix.de>")
 MODULE_DESCRIPTION ("Generic NAND flash driver code")

Variables

static struct nand_ecclayout nand_oob_8
static struct nand_ecclayout nand_oob_16
static struct nand_ecclayout nand_oob_64


Define Documentation

#define BBT_PAGE_MASK   0xffffff3f

Definition at line 1855 of file nand_base.c.

Referenced by nand_erase_nand().

 
#define caller_is_module (  )     module_text_address((unsigned long)__builtin_return_address(0))

Definition at line 2525 of file nand_base.c.

Referenced by nand_scan().

#define NOTALIGNED ( x   )     (x & (mtd->writesize-1)) != 0

Definition at line 1584 of file nand_base.c.

Referenced by nand_do_write_ops().


Function Documentation

DEFINE_LED_TRIGGER ( nand_led_trigger   ) 

EXPORT_SYMBOL_GPL ( nand_release   ) 

EXPORT_SYMBOL_GPL ( nand_scan_tail   ) 

EXPORT_SYMBOL_GPL ( nand_scan_ident   ) 

EXPORT_SYMBOL_GPL ( nand_scan   ) 

EXPORT_SYMBOL_GPL ( nand_wait_ready   ) 

MODULE_AUTHOR ( "Steven J. Hill <sjhill@realitydiluted.com>  ,
Thomas Gleixner< tglx @linutronix.de >"   
)

MODULE_DESCRIPTION ( "Generic NAND flash driver code"   ) 

module_exit ( nand_base_exit   ) 

module_init ( nand_base_init   ) 

MODULE_LICENSE ( "GPL"   ) 

static void multi_erase_cmd ( struct mtd_info mtd,
int  page 
) [static]

Definition at line 1832 of file nand_base.c.

References nand_chip::cmdfunc, NAND_CMD_ERASE1, NAND_CMD_ERASE2, and mtd_info::priv.

Referenced by nand_scan().

static void __exit nand_base_exit ( void   )  [static]

Definition at line 2589 of file nand_base.c.

static int __init nand_base_init ( void   )  [static]

Definition at line 2583 of file nand_base.c.

static int nand_block_bad ( struct mtd_info mtd,
loff_t  ofs,
int  getchip 
) [static]

nand_block_bad - [DEFAULT] Read bad block marker from the chip : MTD device structure : offset from device start : 0, if the chip is already selected

Check, if the block is bad.

Definition at line 303 of file nand_base.c.

References nand_chip::badblockpos, nand_chip::chip_shift, nand_chip::cmdfunc, cpu_to_le16, FL_READING, int, NAND_BUSWIDTH_16, NAND_CMD_READOOB, nand_get_device(), nand_release_device(), nand_chip::options, nand_chip::page_shift, nand_chip::pagemask, mtd_info::priv, nand_chip::read_byte, nand_chip::read_word, and nand_chip::select_chip.

Referenced by nand_scan(), and nand_set_defaults().

static int nand_block_checkbad ( struct mtd_info mtd,
loff_t  ofs,
int  getchip,
int  allowbbt 
) [static]

nand_block_checkbad - [GENERIC] Check if a block is marked bad : MTD device structure : offset from device start : 0, if the chip is already selected : 1, if its allowed to access the bbt area

Check, if the block is bad. Either by reading the bad block table or calling of the scan function.

Definition at line 405 of file nand_base.c.

References nand_chip::bbt, nand_chip::block_bad, nand_isbad_bbt(), and mtd_info::priv.

Referenced by nand_block_isbad(), and nand_erase_nand().

static int nand_block_isbad ( struct mtd_info mtd,
loff_t  offs 
) [static]

nand_block_isbad - [MTD Interface] Check if block at offset is bad : MTD device structure : offset relative to mtd start

Definition at line 2057 of file nand_base.c.

References nand_block_checkbad(), and mtd_info::size.

Referenced by nand_block_markbad().

static int nand_block_markbad ( struct mtd_info mtd,
loff_t  ofs 
) [static]

nand_block_markbad - [MTD Interface] Mark block at the given offset as bad : MTD device structure : offset relative to mtd start

Definition at line 2071 of file nand_base.c.

References nand_chip::block_markbad, nand_block_isbad(), and mtd_info::priv.

static int nand_check_wp ( struct mtd_info mtd  )  [static]

nand_check_wp - [GENERIC] check if the chip is write protected : MTD device structure Check, if the device is write protected

The function expects, that the device is already selected

Definition at line 387 of file nand_base.c.

References nand_chip::cmdfunc, NAND_CMD_STATUS, NAND_STATUS_WP, mtd_info::priv, and nand_chip::read_byte.

Referenced by nand_do_write_oob(), nand_do_write_ops(), and nand_erase_nand().

static void nand_command ( struct mtd_info mtd,
unsigned int  command,
int  column,
int  page_addr 
) [static]

nand_command - [DEFAULT] Send command to NAND device : MTD device structure : the command to be sent : the column address for this command, -1 if none : the page address for this command, -1 if none

Send command to NAND device. This function is used for small page devices (256/512 Bytes per page)

Definition at line 447 of file nand_base.c.

References nand_chip::chip_delay, nand_chip::chipsize, nand_chip::cmd_ctrl, nand_chip::dev_ready, NAND_BUSWIDTH_16, NAND_CMD_ERASE1, NAND_CMD_ERASE2, NAND_CMD_NONE, NAND_CMD_PAGEPROG, NAND_CMD_READ0, NAND_CMD_READ1, NAND_CMD_READOOB, NAND_CMD_RESET, NAND_CMD_SEQIN, NAND_CMD_STATUS, NAND_CTRL_ALE, NAND_CTRL_CHANGE, NAND_CTRL_CLE, NAND_NCE, NAND_STATUS_READY, nand_wait_ready(), ndelay, nand_chip::options, mtd_info::priv, nand_chip::read_byte, and udelay.

Referenced by nand_scan(), and nand_set_defaults().

static void nand_command_lp ( struct mtd_info mtd,
unsigned int  command,
int  column,
int  page_addr 
) [static]

nand_command_lp - [DEFAULT] Send command to NAND large page device : MTD device structure : the command to be sent : the column address for this command, -1 if none : the page address for this command, -1 if none

Send command to NAND device. This is the version for the new large page devices We dont have the separate regions as we have in the small page devices. We must emulate NAND_CMD_READOOB to keep the code compatible.

Definition at line 550 of file nand_base.c.

References nand_chip::chip_delay, nand_chip::chipsize, nand_chip::cmd_ctrl, nand_chip::dev_ready, NAND_ALE, NAND_BUSWIDTH_16, NAND_CLE, NAND_CMD_CACHEDPROG, NAND_CMD_DEPLETE1, NAND_CMD_ERASE1, NAND_CMD_ERASE2, NAND_CMD_NONE, NAND_CMD_PAGEPROG, NAND_CMD_READ0, NAND_CMD_READOOB, NAND_CMD_READSTART, NAND_CMD_RESET, NAND_CMD_RNDIN, NAND_CMD_RNDOUT, NAND_CMD_RNDOUTSTART, NAND_CMD_SEQIN, NAND_CMD_STATUS, NAND_CMD_STATUS_ERROR, NAND_CMD_STATUS_ERROR0, NAND_CMD_STATUS_ERROR1, NAND_CMD_STATUS_ERROR2, NAND_CMD_STATUS_ERROR3, NAND_CTRL_CHANGE, NAND_NCE, NAND_STATUS_READY, nand_wait_ready(), ndelay, nand_chip::options, mtd_info::priv, nand_chip::read_byte, and udelay.

Referenced by nand_scan().

static int nand_default_block_markbad ( struct mtd_info mtd,
loff_t  ofs 
) [static]

nand_default_block_markbad - [DEFAULT] mark a block bad : MTD device structure : offset from device start

This is the default implementation, which can be overridden by a hardware specific driver.

Definition at line 349 of file nand_base.c.

References nand_chip::badblockpos, nand_chip::bbt, nand_chip::bbt_erase_shift, buf, int, nand_do_write_oob(), nand_update_bbt(), NAND_USE_FLASH_BBT, mtd_info::oobsize, nand_chip::ops, nand_chip::options, and mtd_info::priv.

static int nand_do_read_oob ( struct mtd_info mtd,
loff_t  from,
struct mtd_oob_ops *  ops 
) [static]

nand_do_read_oob - [Intern] NAND read out-of-band : MTD device structure : offset to read from : oob operations description structure

NAND read out-of-band data from the spare area

Definition at line 1258 of file nand_base.c.

References buf, nand_chip::buffers, nand_chip::chip_delay, nand_chip::chip_shift, DEBUG, nand_chip::dev_ready, nand_chip::ecc, int, MTD_DEBUG_LEVEL3, NAND_CANAUTOINCR, NAND_NO_READRDY, nand_transfer_oob(), nand_wait_ready(), nand_chip::oob_poi, nand_buffers::oobrbuf, nand_chip::options, nand_chip::page_shift, nand_chip::pagemask, nand_chip::phys_erase_shift, mtd_info::priv, nand_ecc_ctrl::read_oob, nand_chip::select_chip, and udelay.

Referenced by nand_read_oob().

static int nand_do_read_ops ( struct mtd_info mtd,
loff_t  from,
struct mtd_oob_ops *  ops 
) [static]

nand_do_read_ops - [Internal] Read data with ECC

: MTD device structure : offset to read from : oob ops structure

Internal function. Called with chip held.

Definition at line 957 of file nand_base.c.

References buf, nand_chip::buffers, nand_chip::chip_delay, nand_chip::chip_shift, nand_chip::cmdfunc, nand_buffers::databuf, nand_chip::dev_ready, nand_chip::ecc, int, memcpy(), min, NAND_CANAUTOINCR, NAND_CMD_READ0, NAND_NO_READRDY, nand_transfer_oob(), nand_wait_ready(), nand_chip::oob_poi, nand_buffers::oobrbuf, nand_chip::options, nand_chip::page_shift, nand_chip::pagebuf, nand_chip::pagemask, nand_chip::phys_erase_shift, mtd_info::priv, nand_ecc_ctrl::read_page, nand_ecc_ctrl::read_page_raw, nand_chip::select_chip, and udelay.

Referenced by nand_read(), and nand_read_oob().

static int nand_do_write_oob ( struct mtd_info mtd,
loff_t  to,
struct mtd_oob_ops *  ops 
) [static]

nand_do_write_oob - [MTD Interface] NAND write out-of-band : MTD device structure : offset to write to : oob operation description structure

NAND write out-of-band

Definition at line 1714 of file nand_base.c.

References nand_chip::buffers, nand_chip::chip_shift, nand_chip::cmdfunc, DEBUG, nand_chip::ecc, memset(), MTD_DEBUG_LEVEL0, MTD_DEBUG_LEVEL3, nand_check_wp(), NAND_CMD_RESET, nand_fill_oob(), nand_chip::oob_poi, mtd_info::oobsize, nand_buffers::oobwbuf, nand_chip::page_shift, nand_chip::pagebuf, nand_chip::pagemask, mtd_info::priv, nand_chip::select_chip, and nand_ecc_ctrl::write_oob.

Referenced by nand_default_block_markbad(), and nand_write_oob().

static int nand_do_write_ops ( struct mtd_info mtd,
loff_t  to,
struct mtd_oob_ops *  ops 
) [static]

nand_do_write_ops - [Internal] NAND write with ECC : MTD device structure : offset to write to : oob operations description structure

NAND write with ECC

Definition at line 1594 of file nand_base.c.

References buf, nand_chip::buffers, nand_chip::chip_shift, int, KERN_NOTICE, memset(), nand_check_wp(), nand_fill_oob(), NOTALIGNED, nand_chip::oob_poi, mtd_info::oobsize, nand_buffers::oobwbuf, nand_chip::page_shift, nand_chip::pagebuf, nand_chip::pagemask, nand_chip::phys_erase_shift, printk, mtd_info::priv, nand_chip::select_chip, and nand_chip::write_page.

Referenced by nand_write(), and nand_write_oob().

static int nand_erase ( struct mtd_info mtd,
struct erase_info instr 
) [static]

nand_erase - [MTD Interface] erase block(s) : MTD device structure : erase instruction

Erase one ore more blocks

Definition at line 1850 of file nand_base.c.

References nand_erase_nand().

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_chip::options, nand_bbt_descr::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().

static uint8_t* nand_fill_oob ( struct nand_chip chip,
uint8_t *  oob,
struct mtd_oob_ops *  ops 
) [static]

nand_fill_oob - [Internal] Transfer client buffer to oob : nand chip structure : oob data buffer : oob ops structure

Definition at line 1541 of file nand_base.c.

References BUG, nand_chip::ecc, free(), nand_ecc_ctrl::layout, memcpy(), min_t, and nand_chip::oob_poi.

Referenced by nand_do_write_oob(), and nand_do_write_ops().

static int nand_get_device ( struct nand_chip chip,
struct mtd_info mtd,
int  new_state 
) [static]

nand_get_device - [GENERIC] Get chip for selected access : the nand chip descriptor : MTD device structure : the state which is requested

Get the device and lock it for exclusive access

Definition at line 670 of file nand_base.c.

References nand_hw_control::active, add_wait_queue, nand_chip::controller, DECLARE_WAITQUEUE, FL_PM_SUSPENDED, FL_READY, nand_hw_control::lock, remove_wait_queue, schedule, set_current_state, spin_lock, spin_unlock, spinlock_t, nand_chip::state, TASK_UNINTERRUPTIBLE, wait_queue_head_t, nand_hw_control::wq, and nand_chip::wq.

Referenced by nand_block_bad(), nand_do_read_ecc(), nand_erase_nand(), nand_read(), nand_read_oob(), nand_read_raw(), nand_suspend(), nand_sync(), nand_write(), and nand_write_oob().

static struct nand_flash_dev* nand_get_flash_type ( struct mtd_info mtd,
struct nand_chip chip,
int  busw,
int *  maf_id 
) [static]

Definition at line 2159 of file nand_base.c.

References nand_chip::chipsize, nand_chip::cmdfunc, mtd_info::erasesize, nand_chip::full_id, mtd_info::name, nand_flash_dev::name, NAND_BUSWIDTH_16, NAND_CMD_READID, nand_flash_ids, mtd_info::oobsize, nand_chip::read_byte, nand_chip::select_chip, and type.

Referenced by nand_scan_ident().

static int nand_read ( struct mtd_info mtd,
loff_t  from,
size_t  len,
size_t *  retlen,
uint8_t *  buf 
) [static]

nand_read - [MTD Interface] MTD compability function for nand_do_read_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

Get hold of the chip and call nand_do_read

Definition at line 1084 of file nand_base.c.

References FL_READING, nand_do_read_ops(), nand_get_device(), nand_release_device(), nand_chip::ops, mtd_info::priv, and mtd_info::size.

static void nand_read_buf ( struct mtd_info mtd,
uint8_t *  buf,
int  len 
) [static]

nand_read_buf - [DEFAULT] read chip data into buffer : MTD device structure : buffer to store date : number of bytes to read

Default read function for 8bit buswith

Definition at line 203 of file nand_base.c.

References nand_chip::dev_ready, nand_chip::IO_ADDR_R, printk, mtd_info::priv, and readb().

Referenced by nand_scan(), and nand_set_defaults().

static void nand_read_buf16 ( struct mtd_info mtd,
uint8_t *  buf,
int  len 
) [static]

nand_read_buf16 - [DEFAULT] read chip data into buffer : MTD device structure : buffer to store date : number of bytes to read

Default read function for 16bit buswith

Definition at line 262 of file nand_base.c.

References nand_chip::IO_ADDR_R, mtd_info::priv, and readw().

Referenced by nand_scan(), and nand_set_defaults().

static uint8_t nand_read_byte ( struct mtd_info mtd  )  [static]

nand_read_byte - [DEFAULT] read one byte from the chip : MTD device structure

Default read function for 8bit buswith

Definition at line 123 of file nand_base.c.

References nand_chip::IO_ADDR_R, mtd_info::priv, and readb().

Referenced by nand_scan(), and nand_set_defaults().

static uint8_t nand_read_byte16 ( struct mtd_info mtd  )  [static]

nand_read_byte16 - [DEFAULT] read one byte endianess aware from the chip : MTD device structure

Default read function for 16bit buswith with endianess conversion

Definition at line 136 of file nand_base.c.

References cpu_to_le16, nand_chip::IO_ADDR_R, mtd_info::priv, and readw().

Referenced by nand_scan(), and nand_set_defaults().

static int nand_read_oob ( struct mtd_info mtd,
loff_t  from,
struct mtd_oob_ops *  ops 
) [static]

nand_read_oob - [MTD Interface] NAND read data and/or out-of-band : MTD device structure : offset to read from : oob operation description structure

NAND read data and/or out-of-band data

Definition at line 1330 of file nand_base.c.

References DEBUG, FL_READING, MTD_DEBUG_LEVEL0, nand_do_read_oob(), nand_do_read_ops(), nand_get_device(), nand_release_device(), mtd_info::priv, and mtd_info::size.

static int nand_read_oob_std ( struct mtd_info mtd,
struct nand_chip chip,
int  page,
int  sndcmd 
) [static]

Definition at line 1118 of file nand_base.c.

References nand_chip::cmdfunc, NAND_CMD_READOOB, nand_chip::oob_poi, mtd_info::oobsize, and nand_chip::read_buf.

Referenced by nand_scan_tail().

static int nand_read_oob_syndrome ( struct mtd_info mtd,
struct nand_chip chip,
int  page,
int  sndcmd 
) [static]

Definition at line 1137 of file nand_base.c.

References buf, nand_ecc_ctrl::bytes, chunk, nand_chip::cmdfunc, nand_chip::ecc, nand_chip::eccsize, length, min_t, NAND_CMD_READ0, NAND_CMD_RNDOUT, nand_chip::oob_poi, mtd_info::oobsize, nand_ecc_ctrl::postpad, nand_ecc_ctrl::prepad, nand_chip::read_buf, nand_ecc_ctrl::size, and nand_ecc_ctrl::steps.

Referenced by nand_scan_tail().

static int nand_read_page_hwecc ( struct mtd_info mtd,
struct nand_chip chip,
uint8_t *  buf 
) [static]

nand_read_page_hwecc - {REPLACABLE] hardware ecc based page read function : mtd info structure : nand chip info structure : buffer to store read data

Not for syndrome calculating ecc controllers which need a special oob layout

Definition at line 809 of file nand_base.c.

References nand_chip::buffers, nand_ecc_ctrl::bytes, nand_ecc_ctrl::calculate, nand_ecc_ctrl::correct, nand_chip::ecc, nand_chip::eccbytes, nand_buffers::ecccalc, nand_buffers::ecccode, nand_chip::eccsize, nand_chip::eccsteps, nand_ecc_ctrl::hwctl, nand_ecc_ctrl::layout, NAND_ECC_READ, nand_chip::oob_poi, mtd_info::oobsize, nand_chip::read_buf, nand_ecc_ctrl::size, nand_ecc_ctrl::steps, and nand_ecc_ctrl::total.

Referenced by nand_scan_tail().

static int nand_read_page_raw ( struct mtd_info mtd,
struct nand_chip chip,
uint8_t *  buf 
) [static]

nand_read_page_raw - [Intern] read raw page data without ecc : mtd info structure : nand chip info structure : buffer to store read data

Definition at line 753 of file nand_base.c.

References nand_chip::oob_poi, mtd_info::oobsize, and nand_chip::read_buf.

Referenced by nand_read_page_swecc(), and nand_scan_tail().

static int nand_read_page_swecc ( struct mtd_info mtd,
struct nand_chip chip,
uint8_t *  buf 
) [static]

nand_read_page_swecc - {REPLACABLE] software ecc based page read function : mtd info structure : nand chip info structure : buffer to store read data

Definition at line 767 of file nand_base.c.

References nand_chip::buffers, nand_ecc_ctrl::bytes, nand_ecc_ctrl::calculate, nand_ecc_ctrl::correct, nand_chip::ecc, nand_chip::eccbytes, nand_buffers::ecccalc, nand_buffers::ecccode, nand_chip::eccsize, nand_chip::eccsteps, nand_ecc_ctrl::layout, nand_read_page_raw(), nand_chip::oob_poi, nand_ecc_ctrl::size, nand_ecc_ctrl::steps, and nand_ecc_ctrl::total.

Referenced by nand_scan_tail().

static int nand_read_page_syndrome ( struct mtd_info mtd,
struct nand_chip chip,
uint8_t *  buf 
) [static]

nand_read_page_syndrome - {REPLACABLE] hardware ecc syndrom based page read : mtd info structure : nand chip info structure : buffer to store read data

The hw generator calculates the error syndrome automatically. Therefor we need a special oob layout and handling.

Definition at line 854 of file nand_base.c.

References nand_ecc_ctrl::bytes, nand_ecc_ctrl::correct, nand_chip::ecc, nand_chip::eccbytes, nand_chip::eccsize, nand_chip::eccsteps, nand_ecc_ctrl::hwctl, NAND_ECC_READ, NAND_ECC_READSYN, nand_chip::oob_poi, mtd_info::oobsize, nand_ecc_ctrl::postpad, nand_ecc_ctrl::prepad, nand_chip::read_buf, nand_ecc_ctrl::size, and nand_ecc_ctrl::steps.

Referenced by nand_scan_tail().

static u16 nand_read_word ( struct mtd_info mtd  )  [static]

nand_read_word - [DEFAULT] read one word from the chip : MTD device structure

Default read function for 16bit buswith without endianess conversion

Definition at line 149 of file nand_base.c.

References nand_chip::IO_ADDR_R, mtd_info::priv, and readw().

Referenced by nand_scan(), and nand_set_defaults().

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.

static void nand_release_device ( struct mtd_info mtd  )  [static]

nand_release_device - [GENERIC] release chip : MTD device structure

Deselect, release chip lock and wake up anyone waiting on the device

Definition at line 102 of file nand_base.c.

References nand_hw_control::active, nand_chip::controller, FL_READY, nand_hw_control::lock, mtd_info::priv, nand_chip::select_chip, spin_lock, spin_unlock, nand_chip::state, wake_up, and nand_hw_control::wq.

Referenced by nand_block_bad(), nand_do_read_ecc(), nand_erase_nand(), nand_read(), nand_read_oob(), nand_read_raw(), nand_resume(), nand_sync(), nand_write(), and nand_write_oob().

static void nand_resume ( struct mtd_info mtd  )  [static]

nand_resume - [MTD Interface] Resume the NAND flash : MTD device structure

Definition at line 2101 of file nand_base.c.

References FL_PM_SUSPENDED, KERN_ERR, nand_release_device(), printk, mtd_info::priv, and nand_chip::state.

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 uninitialized function pointers with the defaults. The flash ID is read and the mtd/chip structures are filled with the appropriate values. The mtd->owner field must be set to the module of the caller

Definition at line 2541 of file nand_base.c.

Referenced by crisv32_nand_flash_probe(), and rflflash_init().

int nand_scan_ident ( struct mtd_info mtd,
int  maxchips 
)

nand_scan_ident - [NAND Interface] Scan for the NAND device : MTD device structure : Number of chips to scan for

This is the first phase of the normal nand_scan() function. It reads the flash ID and sets up MTD fields accordingly.

The mtd->owner field must be set to the module of the caller.

Definition at line 2300 of file nand_base.c.

References nand_chip::chipsize, nand_chip::cmdfunc, KERN_INFO, KERN_WARNING, NAND_BUSWIDTH_16, NAND_CMD_READID, nand_get_flash_type(), nand_set_defaults(), nand_chip::numchips, nand_chip::options, printk, mtd_info::priv, nand_chip::read_byte, nand_chip::select_chip, mtd_info::size, and type.

Referenced by nand_scan().

int nand_scan_tail ( struct mtd_info mtd  ) 

nand_scan_tail - [NAND Interface] Scan for the NAND device : MTD device structure : Number of chips to scan for

This is the second phase of the normal nand_scan() function. It fills out all the uninitialized function pointers with the defaults and scans for a bad block table if appropriate.

Definition at line 2350 of file nand_base.c.

References nand_chip::buffers, BUG, nand_ecc_ctrl::bytes, nand_ecc_ctrl::calculate, nand_ecc_ctrl::correct, nand_chip::ecc, GFP_KERNEL, nand_ecc_ctrl::hwctl, KERN_WARNING, kmalloc, nand_ecc_ctrl::layout, memset(), nand_ecc_ctrl::mode, nand_calculate_ecc(), nand_correct_data(), NAND_ECC_HW, NAND_ECC_HW_SYNDROME, NAND_ECC_NONE, NAND_ECC_SOFT, nand_oob_16, nand_oob_64, nand_oob_8, NAND_OWN_BUFFERS, nand_read_oob_std(), nand_read_oob_syndrome(), nand_read_page_hwecc(), nand_read_page_raw(), nand_read_page_swecc(), nand_read_page_syndrome(), nand_write_oob_std(), nand_write_oob_syndrome(), nand_write_page(), nand_write_page_hwecc(), nand_write_page_raw(), nand_write_page_swecc(), nand_write_page_syndrome(), mtd_info::oobsize, nand_buffers::oobwbuf, nand_chip::options, printk, mtd_info::priv, nand_ecc_ctrl::read_oob, nand_ecc_ctrl::read_page, nand_ecc_ctrl::read_page_raw, nand_ecc_ctrl::size, nand_ecc_ctrl::steps, nand_ecc_ctrl::write_oob, nand_chip::write_page, nand_ecc_ctrl::write_page, and nand_ecc_ctrl::write_page_raw.

Referenced by nand_scan().

static void nand_select_chip ( struct mtd_info mtd,
int  chipnr 
) [static]

nand_select_chip - [DEFAULT] control CE line : MTD device structure : chipnumber to select, -1 for deselect

Default select function for 1 chip devices.

Definition at line 162 of file nand_base.c.

References BUG, nand_chip::cmd_ctrl, NAND_CMD_NONE, NAND_CTRL_CHANGE, and mtd_info::priv.

Referenced by nand_scan(), and nand_set_defaults().

static void nand_set_defaults ( struct nand_chip chip,
int  busw 
) [static]

Definition at line 2115 of file nand_base.c.

References nand_chip::block_bad, nand_chip::block_markbad, nand_chip::chip_delay, nand_chip::cmdfunc, nand_chip::controller, nand_chip::hwcontrol, init_waitqueue_head, nand_hw_control::lock, nand_block_bad(), nand_command(), nand_default_bbt(), nand_default_block_markbad, nand_read_buf(), nand_read_buf16(), nand_read_byte(), nand_read_byte16(), nand_read_word(), nand_select_chip(), nand_verify_buf(), nand_verify_buf16(), nand_wait(), nand_write_buf(), nand_write_buf16(), nand_chip::read_buf, nand_chip::read_byte, nand_chip::read_word, nand_chip::scan_bbt, nand_chip::select_chip, spin_lock_init, nand_chip::verify_buf, nand_chip::waitfunc, nand_hw_control::wq, and nand_chip::write_buf.

Referenced by nand_scan_ident().

static int nand_suspend ( struct mtd_info mtd  )  [static]

nand_suspend - [MTD Interface] Suspend the NAND flash : MTD device structure

Definition at line 2090 of file nand_base.c.

References FL_PM_SUSPENDED, nand_get_device(), and mtd_info::priv.

static void nand_sync ( struct mtd_info mtd  )  [static]

nand_sync - [MTD Interface] sync : MTD device structure

Sync is actually a wait for chip ready function

Definition at line 2040 of file nand_base.c.

References DEBUG, FL_SYNCING, MTD_DEBUG_LEVEL3, nand_get_device(), nand_release_device(), and mtd_info::priv.

static uint8_t* nand_transfer_oob ( struct nand_chip chip,
uint8_t *  oob,
struct mtd_oob_ops *  ops 
) [static]

nand_transfer_oob - [Internal] Transfer oob to client buffer : nand chip structure : oob destination address : oob ops structure

Definition at line 905 of file nand_base.c.

References BUG, nand_chip::ecc, free(), nand_ecc_ctrl::layout, memcpy(), min_t, and nand_chip::oob_poi.

Referenced by nand_do_read_oob(), and nand_do_read_ops().

static int nand_verify_buf ( struct mtd_info mtd,
const uint8_t *  buf,
int  len 
) [static]

nand_verify_buf - [DEFAULT] Verify chip data against buffer : MTD device structure : buffer containing the data to compare : number of bytes to compare

Default verify function for 8bit buswith

Definition at line 222 of file nand_base.c.

References nand_chip::IO_ADDR_R, mtd_info::priv, and readb().

Referenced by nand_scan(), and nand_set_defaults().

static int nand_verify_buf16 ( struct mtd_info mtd,
const uint8_t *  buf,
int  len 
) [static]

nand_verify_buf16 - [DEFAULT] Verify chip data against buffer : MTD device structure : buffer containing the data to compare : number of bytes to compare

Default verify function for 16bit buswith

Definition at line 281 of file nand_base.c.

References nand_chip::IO_ADDR_R, mtd_info::priv, and readw().

Referenced by nand_scan(), and nand_set_defaults().

static int nand_wait ( struct mtd_info mtd,
struct nand_chip chip 
) [static]

nand_wait - [DEFAULT] wait until the command is done : MTD device structure : NAND chip structure

Wait for command done. This applies to erase and program only Erase can take up to 400ms and program up to 20ms according to general NAND and SmartMedia specs

Definition at line 709 of file nand_base.c.

References nand_chip::cmdfunc, cond_resched, nand_chip::dev_ready, FL_ERASING, HZ, int, jiffies, LED_OFF, NAND_CMD_STATUS, NAND_CMD_STATUS_MULTI, NAND_IS_AND, NAND_STATUS_READY, ndelay, nand_chip::options, nand_chip::read_byte, nand_chip::state, state, and time_before.

Referenced by nand_scan(), and nand_set_defaults().

void nand_wait_ready ( struct mtd_info mtd  ) 

Definition at line 421 of file nand_base.c.

References nand_chip::dev_ready, jiffies, LED_OFF, mtd_info::priv, time_before, and touch_softlockup_watchdog.

Referenced by nand_command(), nand_command_lp(), nand_do_read_ecc(), nand_do_read_oob(), nand_do_read_ops(), nand_read_oob(), nand_read_raw(), and nand_wait().

static int nand_write ( struct mtd_info mtd,
loff_t  to,
size_t  len,
size_t *  retlen,
const uint8_t *  buf 
) [static]

nand_write - [MTD Interface] NAND write with ECC : MTD device structure : offset to write to : number of bytes to write : pointer to variable to store the number of written bytes : the data to write

NAND write with ECC

Definition at line 1679 of file nand_base.c.

References FL_WRITING, nand_do_write_ops(), nand_get_device(), nand_release_device(), nand_chip::ops, mtd_info::priv, and mtd_info::size.

static void nand_write_buf ( struct mtd_info mtd,
const uint8_t *  buf,
int  len 
) [static]

nand_write_buf - [DEFAULT] write buffer to chip : MTD device structure : data buffer : number of bytes to write

Default write function for 8bit buswith

Definition at line 186 of file nand_base.c.

References nand_chip::IO_ADDR_W, mtd_info::priv, and writeb().

Referenced by nand_scan(), and nand_set_defaults().

static void nand_write_buf16 ( struct mtd_info mtd,
const uint8_t *  buf,
int  len 
) [static]

nand_write_buf16 - [DEFAULT] write buffer to chip : MTD device structure : data buffer : number of bytes to write

Default write function for 16bit buswith

Definition at line 242 of file nand_base.c.

References nand_chip::IO_ADDR_W, mtd_info::priv, and writew().

Referenced by nand_scan(), and nand_set_defaults().

static int nand_write_oob ( struct mtd_info mtd,
loff_t  to,
struct mtd_oob_ops *  ops 
) [static]

nand_write_oob - [MTD Interface] NAND write data and/or out-of-band : MTD device structure : offset to write to : oob operation description structure

Definition at line 1772 of file nand_base.c.

References DEBUG, FL_WRITING, MTD_DEBUG_LEVEL0, nand_do_write_oob(), nand_do_write_ops(), nand_get_device(), nand_release_device(), mtd_info::priv, and mtd_info::size.

static int nand_write_oob_std ( struct mtd_info mtd,
struct nand_chip chip,
int  page 
) [static]

Definition at line 1174 of file nand_base.c.

References buf, nand_chip::cmdfunc, length, NAND_CMD_PAGEPROG, NAND_CMD_SEQIN, NAND_STATUS_FAIL, nand_chip::oob_poi, mtd_info::oobsize, nand_chip::waitfunc, and nand_chip::write_buf.

Referenced by nand_scan_tail().

static int nand_write_oob_syndrome ( struct mtd_info mtd,
struct nand_chip chip,
int  page 
) [static]

Definition at line 1198 of file nand_base.c.

References nand_ecc_ctrl::bytes, chunk, nand_chip::cmdfunc, nand_chip::ecc, nand_chip::eccsize, length, min_t, NAND_CMD_RNDIN, NAND_CMD_SEQIN, num, nand_chip::oob_poi, mtd_info::oobsize, nand_ecc_ctrl::postpad, nand_ecc_ctrl::prepad, nand_ecc_ctrl::size, nand_ecc_ctrl::steps, and nand_chip::write_buf.

Referenced by nand_scan_tail().

static int nand_write_page ( struct mtd_info mtd,
struct nand_chip chip,
const uint8_t *  buf,
int  page,
int  cached,
int  raw 
) [static]

Definition at line 1488 of file nand_base.c.

References nand_chip::cmdfunc, nand_chip::ecc, nand_chip::errstat, FL_WRITING, NAND_CACHEPRG, NAND_CMD_CACHEDPROG, NAND_CMD_PAGEPROG, NAND_CMD_READ0, NAND_CMD_SEQIN, NAND_STATUS_FAIL, nand_chip::options, nand_chip::verify_buf, nand_chip::waitfunc, nand_ecc_ctrl::write_page, and nand_ecc_ctrl::write_page_raw.

Referenced by nand_scan_tail(), and nand_wait().

static void nand_write_page_hwecc ( struct mtd_info mtd,
struct nand_chip chip,
const uint8_t *  buf 
) [static]

nand_write_page_hwecc - {REPLACABLE] hardware ecc based page write function : mtd info structure : nand chip info structure : data buffer

Definition at line 1413 of file nand_base.c.

References nand_chip::buffers, nand_ecc_ctrl::bytes, nand_ecc_ctrl::calculate, nand_chip::ecc, nand_chip::eccbytes, nand_buffers::ecccalc, nand_chip::eccsize, nand_chip::eccsteps, nand_ecc_ctrl::hwctl, nand_ecc_ctrl::layout, NAND_ECC_WRITE, nand_chip::oob_poi, nand_ecc_ctrl::size, nand_ecc_ctrl::steps, nand_ecc_ctrl::total, and nand_chip::write_buf.

Referenced by nand_scan_tail().

static void nand_write_page_raw ( struct mtd_info mtd,
struct nand_chip chip,
const uint8_t *  buf 
) [static]

nand_write_page_raw - [Intern] raw page write function : mtd info structure : nand chip info structure : data buffer

Definition at line 1374 of file nand_base.c.

References nand_chip::oob_poi, mtd_info::oobsize, and nand_chip::write_buf.

Referenced by nand_scan_tail(), and nand_write_page_swecc().

static void nand_write_page_swecc ( struct mtd_info mtd,
struct nand_chip chip,
const uint8_t *  buf 
) [static]

nand_write_page_swecc - {REPLACABLE] software ecc based page write function : mtd info structure : nand chip info structure : data buffer

Definition at line 1387 of file nand_base.c.

References nand_chip::buffers, nand_ecc_ctrl::bytes, nand_ecc_ctrl::calculate, nand_chip::ecc, nand_chip::eccbytes, nand_buffers::ecccalc, nand_chip::eccsize, nand_chip::eccsteps, nand_ecc_ctrl::layout, nand_write_page_raw(), nand_chip::oob_poi, nand_ecc_ctrl::size, nand_ecc_ctrl::steps, and nand_ecc_ctrl::total.

Referenced by nand_scan_tail().

static void nand_write_page_syndrome ( struct mtd_info mtd,
struct nand_chip chip,
const uint8_t *  buf 
) [static]

nand_write_page_syndrome - {REPLACABLE] hardware ecc syndrom based page write : mtd info structure : nand chip info structure : data buffer

The hw generator calculates the error syndrome automatically. Therefor we need a special oob layout and handling.

Definition at line 1444 of file nand_base.c.

References nand_ecc_ctrl::bytes, nand_ecc_ctrl::calculate, nand_chip::ecc, nand_chip::eccbytes, nand_chip::eccsize, nand_chip::eccsteps, nand_ecc_ctrl::hwctl, NAND_ECC_WRITE, nand_chip::oob_poi, mtd_info::oobsize, nand_ecc_ctrl::postpad, nand_ecc_ctrl::prepad, nand_ecc_ctrl::size, nand_ecc_ctrl::steps, and nand_chip::write_buf.

Referenced by nand_scan_tail().

static void single_erase_cmd ( struct mtd_info mtd,
int  page 
) [static]

Definition at line 1816 of file nand_base.c.

References nand_chip::cmdfunc, NAND_CMD_ERASE1, NAND_CMD_ERASE2, and mtd_info::priv.

Referenced by nand_scan().


Variable Documentation

struct nand_ecclayout nand_oob_16 [static]

Initial value:

 {
        .eccbytes = 6,
        .eccpos = {0, 1, 2, 3, 6, 7},
        .oobfree = {
                {.offset = 8,
                 . length = 8}}
}

Definition at line 65 of file nand_base.c.

Referenced by nand_scan(), and nand_scan_tail().

struct nand_ecclayout nand_oob_64 [static]

Initial value:

 {
        .eccbytes = 24,
        .eccpos = {
                   40, 41, 42, 43, 44, 45, 46, 47,
                   48, 49, 50, 51, 52, 53, 54, 55,
                   56, 57, 58, 59, 60, 61, 62, 63},
        .oobfree = {
                {.offset = 2,
                 .length = 38}}
}

Definition at line 73 of file nand_base.c.

Referenced by nand_scan(), and nand_scan_tail().

struct nand_ecclayout nand_oob_8 [static]

Initial value:

 {
        .eccbytes = 3,
        .eccpos = {0, 1, 2},
        .oobfree = {
                {.offset = 3,
                 .length = 2},
                {.offset = 6,
                 .length = 2}}
}

Definition at line 55 of file nand_base.c.

Referenced by nand_scan(), and nand_scan_tail().


Generated on Fri Nov 28 00:08:21 2008 for elphel by  doxygen 1.5.1