aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/mtd
diff options
context:
space:
mode:
authorAlessandro Rubini <rubini@unipv.it>2009-09-20 17:28:04 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2009-09-24 15:54:59 -0400
commitc62d81bcfe82526cc3da10cf4fc63faad368bc60 (patch)
treecef5216198a22daf60573f986167788f89e05e4c /include/linux/mtd
parentea60658a08f8f3511a70587b27f12cd7e0ac5ae3 (diff)
mtd: use bbm.h in nand.h
This consolidates common code in nand.h and bbm.h. The comments and data structures were the same, this keeps the comment from nand.h as it fits 80 columns, while the one in bbm.h did not. Signed-off-by: Alessandro Rubini <rubini@unipv.it> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'include/linux/mtd')
-rw-r--r--include/linux/mtd/bbm.h35
-rw-r--r--include/linux/mtd/nand.h76
2 files changed, 19 insertions, 92 deletions
diff --git a/include/linux/mtd/bbm.h b/include/linux/mtd/bbm.h
index fff8c53e5434..9c3757c5759d 100644
--- a/include/linux/mtd/bbm.h
+++ b/include/linux/mtd/bbm.h
@@ -19,22 +19,21 @@
19 19
20/** 20/**
21 * struct nand_bbt_descr - bad block table descriptor 21 * struct nand_bbt_descr - bad block table descriptor
22 * @options: options for this descriptor 22 * @options: options for this descriptor
23 * @pages: the page(s) where we find the bbt, used with 23 * @pages: the page(s) where we find the bbt, used with option BBT_ABSPAGE
24 * option BBT_ABSPAGE when bbt is searched, 24 * when bbt is searched, then we store the found bbts pages here.
25 * then we store the found bbts pages here. 25 * Its an array and supports up to 8 chips now
26 * Its an array and supports up to 8 chips now 26 * @offs: offset of the pattern in the oob area of the page
27 * @offs: offset of the pattern in the oob area of the page 27 * @veroffs: offset of the bbt version counter in the oob are of the page
28 * @veroffs: offset of the bbt version counter in the oob area of the page 28 * @version: version read from the bbt page during scan
29 * @version: version read from the bbt page during scan 29 * @len: length of the pattern, if 0 no pattern check is performed
30 * @len: length of the pattern, if 0 no pattern check is performed 30 * @maxblocks: maximum number of blocks to search for a bbt. This number of
31 * @maxblocks: maximum number of blocks to search for a bbt. This 31 * blocks is reserved at the end of the device where the tables are
32 * number of blocks is reserved at the end of the device 32 * written.
33 * where the tables are written. 33 * @reserved_block_code: if non-0, this pattern denotes a reserved (rather than
34 * @reserved_block_code: if non-0, this pattern denotes a reserved 34 * bad) block in the stored bbt
35 * (rather than bad) block in the stored bbt 35 * @pattern: pattern to identify bad block table or factory marked good /
36 * @pattern: pattern to identify bad block table or factory marked 36 * bad blocks, can be NULL, if len = 0
37 * good / bad blocks, can be NULL, if len = 0
38 * 37 *
39 * Descriptor for the bad block table marker and the descriptor for the 38 * Descriptor for the bad block table marker and the descriptor for the
40 * pattern which identifies good and bad blocks. The assumption is made 39 * pattern which identifies good and bad blocks. The assumption is made
@@ -90,7 +89,9 @@ struct nand_bbt_descr {
90/* 89/*
91 * Constants for oob configuration 90 * Constants for oob configuration
92 */ 91 */
93#define ONENAND_BADBLOCK_POS 0 92#define NAND_SMALL_BADBLOCK_POS 5
93#define NAND_LARGE_BADBLOCK_POS 0
94#define ONENAND_BADBLOCK_POS 0
94 95
95/* 96/*
96 * Bad block scanning errors 97 * Bad block scanning errors
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 7a232a9bdd62..d87ada538d17 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -21,6 +21,7 @@
21#include <linux/wait.h> 21#include <linux/wait.h>
22#include <linux/spinlock.h> 22#include <linux/spinlock.h>
23#include <linux/mtd/mtd.h> 23#include <linux/mtd/mtd.h>
24#include <linux/mtd/bbm.h>
24 25
25struct mtd_info; 26struct mtd_info;
26/* Scan and identify a NAND device */ 27/* Scan and identify a NAND device */
@@ -470,75 +471,6 @@ struct nand_manufacturers {
470extern struct nand_flash_dev nand_flash_ids[]; 471extern struct nand_flash_dev nand_flash_ids[];
471extern struct nand_manufacturers nand_manuf_ids[]; 472extern struct nand_manufacturers nand_manuf_ids[];
472 473
473/**
474 * struct nand_bbt_descr - bad block table descriptor
475 * @options: options for this descriptor
476 * @pages: the page(s) where we find the bbt, used with option BBT_ABSPAGE
477 * when bbt is searched, then we store the found bbts pages here.
478 * Its an array and supports up to 8 chips now
479 * @offs: offset of the pattern in the oob area of the page
480 * @veroffs: offset of the bbt version counter in the oob are of the page
481 * @version: version read from the bbt page during scan
482 * @len: length of the pattern, if 0 no pattern check is performed
483 * @maxblocks: maximum number of blocks to search for a bbt. This number of
484 * blocks is reserved at the end of the device where the tables are
485 * written.
486 * @reserved_block_code: if non-0, this pattern denotes a reserved (rather than
487 * bad) block in the stored bbt
488 * @pattern: pattern to identify bad block table or factory marked good /
489 * bad blocks, can be NULL, if len = 0
490 *
491 * Descriptor for the bad block table marker and the descriptor for the
492 * pattern which identifies good and bad blocks. The assumption is made
493 * that the pattern and the version count are always located in the oob area
494 * of the first block.
495 */
496struct nand_bbt_descr {
497 int options;
498 int pages[NAND_MAX_CHIPS];
499 int offs;
500 int veroffs;
501 uint8_t version[NAND_MAX_CHIPS];
502 int len;
503 int maxblocks;
504 int reserved_block_code;
505 uint8_t *pattern;
506};
507
508/* Options for the bad block table descriptors */
509
510/* The number of bits used per block in the bbt on the device */
511#define NAND_BBT_NRBITS_MSK 0x0000000F
512#define NAND_BBT_1BIT 0x00000001
513#define NAND_BBT_2BIT 0x00000002
514#define NAND_BBT_4BIT 0x00000004
515#define NAND_BBT_8BIT 0x00000008
516/* The bad block table is in the last good block of the device */
517#define NAND_BBT_LASTBLOCK 0x00000010
518/* The bbt is at the given page, else we must scan for the bbt */
519#define NAND_BBT_ABSPAGE 0x00000020
520/* The bbt is at the given page, else we must scan for the bbt */
521#define NAND_BBT_SEARCH 0x00000040
522/* bbt is stored per chip on multichip devices */
523#define NAND_BBT_PERCHIP 0x00000080
524/* bbt has a version counter at offset veroffs */
525#define NAND_BBT_VERSION 0x00000100
526/* Create a bbt if none axists */
527#define NAND_BBT_CREATE 0x00000200
528/* Search good / bad pattern through all pages of a block */
529#define NAND_BBT_SCANALLPAGES 0x00000400
530/* Scan block empty during good / bad block scan */
531#define NAND_BBT_SCANEMPTY 0x00000800
532/* Write bbt if neccecary */
533#define NAND_BBT_WRITE 0x00001000
534/* Read and write back block contents when writing bbt */
535#define NAND_BBT_SAVECONTENT 0x00002000
536/* Search good / bad pattern on the first and the second page */
537#define NAND_BBT_SCAN2NDPAGE 0x00004000
538
539/* The maximum number of blocks to scan for a bbt */
540#define NAND_BBT_SCAN_MAXBLOCKS 4
541
542extern int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd); 474extern int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd);
543extern int nand_update_bbt(struct mtd_info *mtd, loff_t offs); 475extern int nand_update_bbt(struct mtd_info *mtd, loff_t offs);
544extern int nand_default_bbt(struct mtd_info *mtd); 476extern int nand_default_bbt(struct mtd_info *mtd);
@@ -548,12 +480,6 @@ extern int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr,
548extern int nand_do_read(struct mtd_info *mtd, loff_t from, size_t len, 480extern int nand_do_read(struct mtd_info *mtd, loff_t from, size_t len,
549 size_t * retlen, uint8_t * buf); 481 size_t * retlen, uint8_t * buf);
550 482
551/*
552* Constants for oob configuration
553*/
554#define NAND_SMALL_BADBLOCK_POS 5
555#define NAND_LARGE_BADBLOCK_POS 0
556
557/** 483/**
558 * struct platform_nand_chip - chip level device structure 484 * struct platform_nand_chip - chip level device structure
559 * @nr_chips: max. number of chips to scan for 485 * @nr_chips: max. number of chips to scan for