diff options
Diffstat (limited to 'include/linux/mtd/nand.h')
-rw-r--r-- | include/linux/mtd/nand.h | 97 |
1 files changed, 6 insertions, 91 deletions
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index 7a232a9bdd62..ccab9dfc5217 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h | |||
@@ -21,6 +21,8 @@ | |||
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/flashchip.h> | ||
25 | #include <linux/mtd/bbm.h> | ||
24 | 26 | ||
25 | struct mtd_info; | 27 | struct mtd_info; |
26 | /* Scan and identify a NAND device */ | 28 | /* Scan and identify a NAND device */ |
@@ -168,7 +170,6 @@ typedef enum { | |||
168 | /* Chip does not allow subpage writes */ | 170 | /* Chip does not allow subpage writes */ |
169 | #define NAND_NO_SUBPAGE_WRITE 0x00000200 | 171 | #define NAND_NO_SUBPAGE_WRITE 0x00000200 |
170 | 172 | ||
171 | |||
172 | /* Options valid for Samsung large page devices */ | 173 | /* Options valid for Samsung large page devices */ |
173 | #define NAND_SAMSUNG_LP_OPTIONS \ | 174 | #define NAND_SAMSUNG_LP_OPTIONS \ |
174 | (NAND_NO_PADDING | NAND_CACHEPRG | NAND_COPYBACK) | 175 | (NAND_NO_PADDING | NAND_CACHEPRG | NAND_COPYBACK) |
@@ -194,6 +195,9 @@ typedef enum { | |||
194 | /* This option is defined if the board driver allocates its own buffers | 195 | /* This option is defined if the board driver allocates its own buffers |
195 | (e.g. because it needs them DMA-coherent */ | 196 | (e.g. because it needs them DMA-coherent */ |
196 | #define NAND_OWN_BUFFERS 0x00040000 | 197 | #define NAND_OWN_BUFFERS 0x00040000 |
198 | /* Chip may not exist, so silence any errors in scan */ | ||
199 | #define NAND_SCAN_SILENT_NODEV 0x00080000 | ||
200 | |||
197 | /* Options set by nand scan */ | 201 | /* Options set by nand scan */ |
198 | /* Nand scan has allocated controller struct */ | 202 | /* Nand scan has allocated controller struct */ |
199 | #define NAND_CONTROLLER_ALLOC 0x80000000 | 203 | #define NAND_CONTROLLER_ALLOC 0x80000000 |
@@ -202,20 +206,6 @@ typedef enum { | |||
202 | #define NAND_CI_CHIPNR_MSK 0x03 | 206 | #define NAND_CI_CHIPNR_MSK 0x03 |
203 | #define NAND_CI_CELLTYPE_MSK 0x0C | 207 | #define NAND_CI_CELLTYPE_MSK 0x0C |
204 | 208 | ||
205 | /* | ||
206 | * nand_state_t - chip states | ||
207 | * Enumeration for NAND flash chip state | ||
208 | */ | ||
209 | typedef enum { | ||
210 | FL_READY, | ||
211 | FL_READING, | ||
212 | FL_WRITING, | ||
213 | FL_ERASING, | ||
214 | FL_SYNCING, | ||
215 | FL_CACHEDPRG, | ||
216 | FL_PM_SUSPENDED, | ||
217 | } nand_state_t; | ||
218 | |||
219 | /* Keep gcc happy */ | 209 | /* Keep gcc happy */ |
220 | struct nand_chip; | 210 | struct nand_chip; |
221 | 211 | ||
@@ -402,7 +392,7 @@ struct nand_chip { | |||
402 | uint8_t cellinfo; | 392 | uint8_t cellinfo; |
403 | int badblockpos; | 393 | int badblockpos; |
404 | 394 | ||
405 | nand_state_t state; | 395 | flstate_t state; |
406 | 396 | ||
407 | uint8_t *oob_poi; | 397 | uint8_t *oob_poi; |
408 | struct nand_hw_control *controller; | 398 | struct nand_hw_control *controller; |
@@ -470,75 +460,6 @@ struct nand_manufacturers { | |||
470 | extern struct nand_flash_dev nand_flash_ids[]; | 460 | extern struct nand_flash_dev nand_flash_ids[]; |
471 | extern struct nand_manufacturers nand_manuf_ids[]; | 461 | extern struct nand_manufacturers nand_manuf_ids[]; |
472 | 462 | ||
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 | */ | ||
496 | struct 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 | |||
542 | extern int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd); | 463 | extern int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd); |
543 | extern int nand_update_bbt(struct mtd_info *mtd, loff_t offs); | 464 | extern int nand_update_bbt(struct mtd_info *mtd, loff_t offs); |
544 | extern int nand_default_bbt(struct mtd_info *mtd); | 465 | extern int nand_default_bbt(struct mtd_info *mtd); |
@@ -548,12 +469,6 @@ extern int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr, | |||
548 | extern int nand_do_read(struct mtd_info *mtd, loff_t from, size_t len, | 469 | extern int nand_do_read(struct mtd_info *mtd, loff_t from, size_t len, |
549 | size_t * retlen, uint8_t * buf); | 470 | size_t * retlen, uint8_t * buf); |
550 | 471 | ||
551 | /* | ||
552 | * Constants for oob configuration | ||
553 | */ | ||
554 | #define NAND_SMALL_BADBLOCK_POS 5 | ||
555 | #define NAND_LARGE_BADBLOCK_POS 0 | ||
556 | |||
557 | /** | 472 | /** |
558 | * struct platform_nand_chip - chip level device structure | 473 | * struct platform_nand_chip - chip level device structure |
559 | * @nr_chips: max. number of chips to scan for | 474 | * @nr_chips: max. number of chips to scan for |