nand.h
来自「SMDK2440 boot code, base on vivi」· C头文件 代码 · 共 302 行
H
302 行
/* * linux/include/linux/mtd/nand.h * * Copyright (c) 2000 David Woodhouse <dwmw2@mvhi.com> * Steven J. Hill <sjhill@realitydiluted.com> * Thomas Gleixner <tglx@linutronix.de> * * $Id: nand.h,v 1.3 2004/05/03 07:46:59 nandy Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * Info: * Contains standard defines and IDs for NAND flash devices * * Changelog: * 01-31-2000 DMW Created * 09-18-2000 SJH Moved structure out of the Disk-On-Chip drivers * so it can be used by other NAND flash device * drivers. I also changed the copyright since none * of the original contents of this file are specific * to DoC devices. David can whack me with a baseball * bat later if I did something naughty. * 10-11-2000 SJH Added private NAND flash structure for driver * 10-24-2000 SJH Added prototype for 'nand_scan' function * 10-29-2001 TG changed nand_chip structure to support * hardwarespecific function for accessing control lines * 02-21-2002 TG added support for different read/write adress and * ready/busy line access function * 02-26-2002 TG added chip_delay to nand_chip structure to optimize * command delay times for different chips * 04-28-2002 TG OOB config defines moved from nand.c to avoid duplicate * defines in jffs2/wbuf.c * 08-07-2002 TG forced bad block location to byte 5 of OOB, even if * CONFIG_MTD_NAND_ECC_JFFS2 is not set * 08-10-2002 TG extensions to nand_chip structure to support HW-ECC * * 08-29-2002 tglx nand_chip structure: data_poi for selecting * internal / fs-driver buffer * support for 6byte/512byte hardware ECC * read_ecc, write_ecc extended for different oob-layout * oob layout selections: NAND_NONE_OOB, NAND_JFFS2_OOB, * NAND_YAFFS_OOB * 11-25-2002 tglx Added Manufacturer code FUJITSU, NATIONAL * Split manufacturer and device ID structures * * 02-08-2004 tglx added option field to nand structure for chip anomalities */#ifndef __LINUX_MTD_NAND_H#define __LINUX_MTD_NAND_H#include <config.h>struct mtd_info;/* * Searches for a NAND device */extern int nand_scan (struct mtd_info *mtd, int max_chips);/* This constant declares the max. oobsize / page, which * is supported now. If you add a chip with bigger oobsize/page * adjust this accordingly. */#define NAND_MAX_OOBSIZE 64/* * Constants for hardware specific CLE/ALE/NCE function*/#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/* * Standard NAND flash commands */#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_SEQIN 0x80#define NAND_CMD_READID 0x90#define NAND_CMD_ERASE2 0xd0#define NAND_CMD_RESET 0xff/* Extended commands for large page devices */#define NAND_CMD_READSTART 0x30#define NAND_CMD_CACHEDPROG 0x15/* Status bits */#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/* * Constants for ECC_MODES * * NONE: No ECC * SOFT: Software ECC 3 byte ECC per 256 Byte data * HW3_256: Hardware ECC 3 byte ECC per 256 Byte data * HW3_512: Hardware ECC 3 byte ECC per 512 Byte data * **/#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_DISKONCHIP 5/* * Constants for Hardware ECC*/#define NAND_ECC_READ 0#define NAND_ECC_WRITE 1/* Option constants for bizarre disfunctionality and real* features*//* Chip can not auto increment pages */#define NAND_NO_AUTOINCR 0x00000001/* Buswitdh is 16 bit */#define NAND_BUSWIDTH_16 0x00000002/* Device supports partial programming without padding */#define NAND_NO_PADDING 0x00000004/* Chip has cache program function */#define NAND_CACHEPRG 0x00000008/* Chip has copy back function */#define NAND_COPYBACK 0x00000010/* Options valid for Samsung large page devices */#define NAND_SAMSUNG_LP_OPTIONS \ (NAND_NO_PADDING | NAND_CACHEPRG | NAND_COPYBACK)/* Macros to identify the above */#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))/* * Enumeration for NAND flash chip state */typedef enum { FL_READY, FL_READING, FL_WRITING, FL_ERASING, FL_SYNCING, FL_CACHEDPRG,} nand_state_t;/* * NAND Private Flash Chip Data * * Structure overview: * * IO_ADDR_R - address to read the 8 I/O lines of the flash device * * IO_ADDR_W - address to write the 8 I/O lines of the flash device * * hwcontrol - hardwarespecific function for accesing control-lines * * dev_ready - hardwarespecific function for accesing device ready/busy line * * waitfunc - hardwarespecific function for wait on ready * * calculate_ecc - function for ecc calculation or readback from ecc hardware * * correct_data - function for ecc correction, matching to ecc generator (sw/hw) * * enable_hwecc - function to enable (reset) hardware ecc generator * * eccmod - mode of ecc: see constants * * eccsize - databytes used per ecc-calculation * * chip_delay - chip dependent delay for transfering data from array to read regs (tR) * * chip_lock - spinlock used to protect access to this structure * * wq - wait queue to sleep on if a NAND operation is in progress * * state - give the current state of the NAND device * * page_shift - number of address bits in a page (column address bits) * * data_buf - data buffer passed to/from MTD user modules * * data_cache - data cache for redundant page access and shadow for * ECC failure * * cache_page - number of last valid page in page_cache */struct nand_chip { unsigned long IO_ADDR_R; unsigned long IO_ADDR_W; u_char (*read_byte)(struct mtd_info *mtd); void (*write_byte)(struct mtd_info *mtd, u_char byte); u16 (*read_word)(struct mtd_info *mtd); void (*write_word)(struct mtd_info *mtd, u16 word); void (*write_buf)(struct mtd_info *mtd, const u_char *buf, int len); void (*read_buf)(struct mtd_info *mtd, u_char *buf, int len); int (*verify_buf)(struct mtd_info *mtd, const u_char *buf, int len); void (*select_chip)(struct mtd_info *mtd, int chip); int (*block_bad)(struct mtd_info *mtd, loff_t ofs, int getchip); int (*block_markbad)(struct mtd_info *mtd, loff_t ofs); void (*hwcontrol)(struct mtd_info *mtd, int cmd); int (*dev_ready)(struct mtd_info *mtd); void (*cmdfunc)(struct mtd_info *mtd, unsigned command, int column, int page_addr); int (*waitfunc)(struct mtd_info *mtd, struct nand_chip *this, int state); void (*calculate_ecc)(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code); int (*correct_data)(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_char *calc_ecc); void (*enable_hwecc)(struct mtd_info *mtd, int mode); int eccmode; int eccsize; int eccsteps; int chip_delay; //spinlock_t chip_lock; //wait_queue_head_t wq; nand_state_t state; int page_shift; u_char *data_buf; u_char *oob_buf; int oobdirty; u_char *data_poi; unsigned int options; int badblockpos; int numchips; unsigned long chipsize; int pagemask; int pagebuf; struct nand_oobinfo *autooob; void *priv;};/* * NAND Flash Manufacturer ID Codes */#define NAND_MFR_TOSHIBA 0x98#define NAND_MFR_SAMSUNG 0xec#define NAND_MFR_FUJITSU 0x04#define NAND_MFR_NATIONAL 0x8f/* * NAND Flash Device ID Structure * * Structure overview: * * name Identify the device type * id device ID code * pagesize Pagesize in bytes. Either 256 or 512 or 0 * If the pagesize is 0, then the real pagesize * and the eraseize are determined from the * extended id bytes in the chip * erasesize Size of an erase block in the flash device. * chipsize Total chipsize in Mega Bytes * options Bitfield to store chip relevant options */struct nand_flash_dev { char *name; int id; unsigned long pagesize; unsigned long chipsize; unsigned long erasesize; unsigned long options;};/* * NAND Flash Manufacturer ID Structure * name - Manufacturer name * id - manufacturer ID code of device.*/struct nand_manufacturers { int id; char * name;};extern struct nand_flash_dev nand_flash_ids[];extern struct nand_manufacturers nand_manuf_ids[];/** Constants for oob configuration*/#define NAND_SMALL_BADBLOCK_POS 5#define NAND_LARGE_BADBLOCK_POS 0#endif /* __LINUX_MTD_NAND_H */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?