diff options
Diffstat (limited to 'include/linux/mtd')
-rw-r--r-- | include/linux/mtd/bbm.h | 35 | ||||
-rw-r--r-- | include/linux/mtd/cfi.h | 9 | ||||
-rw-r--r-- | include/linux/mtd/flashchip.h | 9 | ||||
-rw-r--r-- | include/linux/mtd/nand.h | 97 | ||||
-rw-r--r-- | include/linux/mtd/nand_ecc.h | 10 | ||||
-rw-r--r-- | include/linux/mtd/onenand.h | 23 | ||||
-rw-r--r-- | include/linux/mtd/onenand_regs.h | 2 |
7 files changed, 53 insertions, 132 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/cfi.h b/include/linux/mtd/cfi.h index 88d3d8fbf9f2..df89f4275232 100644 --- a/include/linux/mtd/cfi.h +++ b/include/linux/mtd/cfi.h | |||
@@ -518,10 +518,11 @@ struct cfi_fixup { | |||
518 | #define CFI_MFR_ANY 0xffff | 518 | #define CFI_MFR_ANY 0xffff |
519 | #define CFI_ID_ANY 0xffff | 519 | #define CFI_ID_ANY 0xffff |
520 | 520 | ||
521 | #define CFI_MFR_AMD 0x0001 | 521 | #define CFI_MFR_AMD 0x0001 |
522 | #define CFI_MFR_ATMEL 0x001F | 522 | #define CFI_MFR_INTEL 0x0089 |
523 | #define CFI_MFR_SAMSUNG 0x00EC | 523 | #define CFI_MFR_ATMEL 0x001F |
524 | #define CFI_MFR_ST 0x0020 /* STMicroelectronics */ | 524 | #define CFI_MFR_SAMSUNG 0x00EC |
525 | #define CFI_MFR_ST 0x0020 /* STMicroelectronics */ | ||
525 | 526 | ||
526 | void cfi_fixup(struct mtd_info *mtd, struct cfi_fixup* fixups); | 527 | void cfi_fixup(struct mtd_info *mtd, struct cfi_fixup* fixups); |
527 | 528 | ||
diff --git a/include/linux/mtd/flashchip.h b/include/linux/mtd/flashchip.h index d4f38c5fd44e..d0bf422ae374 100644 --- a/include/linux/mtd/flashchip.h +++ b/include/linux/mtd/flashchip.h | |||
@@ -38,6 +38,15 @@ typedef enum { | |||
38 | FL_XIP_WHILE_ERASING, | 38 | FL_XIP_WHILE_ERASING, |
39 | FL_XIP_WHILE_WRITING, | 39 | FL_XIP_WHILE_WRITING, |
40 | FL_SHUTDOWN, | 40 | FL_SHUTDOWN, |
41 | /* These 2 come from nand_state_t, which has been unified here */ | ||
42 | FL_READING, | ||
43 | FL_CACHEDPRG, | ||
44 | /* These 4 come from onenand_state_t, which has been unified here */ | ||
45 | FL_RESETING, | ||
46 | FL_OTPING, | ||
47 | FL_PREPARING_ERASE, | ||
48 | FL_VERIFYING_ERASE, | ||
49 | |||
41 | FL_UNKNOWN | 50 | FL_UNKNOWN |
42 | } flstate_t; | 51 | } flstate_t; |
43 | 52 | ||
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 |
diff --git a/include/linux/mtd/nand_ecc.h b/include/linux/mtd/nand_ecc.h index 052ea8ca2434..41bc013571d0 100644 --- a/include/linux/mtd/nand_ecc.h +++ b/include/linux/mtd/nand_ecc.h | |||
@@ -16,7 +16,13 @@ | |||
16 | struct mtd_info; | 16 | struct mtd_info; |
17 | 17 | ||
18 | /* | 18 | /* |
19 | * Calculate 3 byte ECC code for 256 byte block | 19 | * Calculate 3 byte ECC code for eccsize byte block |
20 | */ | ||
21 | void __nand_calculate_ecc(const u_char *dat, unsigned int eccsize, | ||
22 | u_char *ecc_code); | ||
23 | |||
24 | /* | ||
25 | * Calculate 3 byte ECC code for 256/512 byte block | ||
20 | */ | 26 | */ |
21 | int nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code); | 27 | int nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code); |
22 | 28 | ||
@@ -27,7 +33,7 @@ int __nand_correct_data(u_char *dat, u_char *read_ecc, u_char *calc_ecc, | |||
27 | unsigned int eccsize); | 33 | unsigned int eccsize); |
28 | 34 | ||
29 | /* | 35 | /* |
30 | * Detect and correct a 1 bit error for 256 byte block | 36 | * Detect and correct a 1 bit error for 256/512 byte block |
31 | */ | 37 | */ |
32 | int nand_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_char *calc_ecc); | 38 | int nand_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_char *calc_ecc); |
33 | 39 | ||
diff --git a/include/linux/mtd/onenand.h b/include/linux/mtd/onenand.h index 4e49f3350678..5509eb06b326 100644 --- a/include/linux/mtd/onenand.h +++ b/include/linux/mtd/onenand.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * linux/include/linux/mtd/onenand.h | 2 | * linux/include/linux/mtd/onenand.h |
3 | * | 3 | * |
4 | * Copyright (C) 2005-2007 Samsung Electronics | 4 | * Copyright © 2005-2009 Samsung Electronics |
5 | * Kyungmin Park <kyungmin.park@samsung.com> | 5 | * Kyungmin Park <kyungmin.park@samsung.com> |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
@@ -14,6 +14,7 @@ | |||
14 | 14 | ||
15 | #include <linux/spinlock.h> | 15 | #include <linux/spinlock.h> |
16 | #include <linux/completion.h> | 16 | #include <linux/completion.h> |
17 | #include <linux/mtd/flashchip.h> | ||
17 | #include <linux/mtd/onenand_regs.h> | 18 | #include <linux/mtd/onenand_regs.h> |
18 | #include <linux/mtd/bbm.h> | 19 | #include <linux/mtd/bbm.h> |
19 | 20 | ||
@@ -25,22 +26,6 @@ extern int onenand_scan(struct mtd_info *mtd, int max_chips); | |||
25 | /* Free resources held by the OneNAND device */ | 26 | /* Free resources held by the OneNAND device */ |
26 | extern void onenand_release(struct mtd_info *mtd); | 27 | extern void onenand_release(struct mtd_info *mtd); |
27 | 28 | ||
28 | /* | ||
29 | * onenand_state_t - chip states | ||
30 | * Enumeration for OneNAND flash chip state | ||
31 | */ | ||
32 | typedef enum { | ||
33 | FL_READY, | ||
34 | FL_READING, | ||
35 | FL_WRITING, | ||
36 | FL_ERASING, | ||
37 | FL_SYNCING, | ||
38 | FL_LOCKING, | ||
39 | FL_RESETING, | ||
40 | FL_OTPING, | ||
41 | FL_PM_SUSPENDED, | ||
42 | } onenand_state_t; | ||
43 | |||
44 | /** | 29 | /** |
45 | * struct onenand_bufferram - OneNAND BufferRAM Data | 30 | * struct onenand_bufferram - OneNAND BufferRAM Data |
46 | * @blockpage: block & page address in BufferRAM | 31 | * @blockpage: block & page address in BufferRAM |
@@ -137,7 +122,7 @@ struct onenand_chip { | |||
137 | 122 | ||
138 | spinlock_t chip_lock; | 123 | spinlock_t chip_lock; |
139 | wait_queue_head_t wq; | 124 | wait_queue_head_t wq; |
140 | onenand_state_t state; | 125 | flstate_t state; |
141 | unsigned char *page_buf; | 126 | unsigned char *page_buf; |
142 | unsigned char *oob_buf; | 127 | unsigned char *oob_buf; |
143 | 128 | ||
@@ -152,6 +137,8 @@ struct onenand_chip { | |||
152 | /* | 137 | /* |
153 | * Helper macros | 138 | * Helper macros |
154 | */ | 139 | */ |
140 | #define ONENAND_PAGES_PER_BLOCK (1<<6) | ||
141 | |||
155 | #define ONENAND_CURRENT_BUFFERRAM(this) (this->bufferram_index) | 142 | #define ONENAND_CURRENT_BUFFERRAM(this) (this->bufferram_index) |
156 | #define ONENAND_NEXT_BUFFERRAM(this) (this->bufferram_index ^ 1) | 143 | #define ONENAND_NEXT_BUFFERRAM(this) (this->bufferram_index ^ 1) |
157 | #define ONENAND_SET_NEXT_BUFFERRAM(this) (this->bufferram_index ^= 1) | 144 | #define ONENAND_SET_NEXT_BUFFERRAM(this) (this->bufferram_index ^= 1) |
diff --git a/include/linux/mtd/onenand_regs.h b/include/linux/mtd/onenand_regs.h index acadbf53a69f..cd6f3b431195 100644 --- a/include/linux/mtd/onenand_regs.h +++ b/include/linux/mtd/onenand_regs.h | |||
@@ -131,6 +131,8 @@ | |||
131 | #define ONENAND_CMD_LOCK_TIGHT (0x2C) | 131 | #define ONENAND_CMD_LOCK_TIGHT (0x2C) |
132 | #define ONENAND_CMD_UNLOCK_ALL (0x27) | 132 | #define ONENAND_CMD_UNLOCK_ALL (0x27) |
133 | #define ONENAND_CMD_ERASE (0x94) | 133 | #define ONENAND_CMD_ERASE (0x94) |
134 | #define ONENAND_CMD_MULTIBLOCK_ERASE (0x95) | ||
135 | #define ONENAND_CMD_ERASE_VERIFY (0x71) | ||
134 | #define ONENAND_CMD_RESET (0xF0) | 136 | #define ONENAND_CMD_RESET (0xF0) |
135 | #define ONENAND_CMD_OTP_ACCESS (0x65) | 137 | #define ONENAND_CMD_OTP_ACCESS (0x65) |
136 | #define ONENAND_CMD_READID (0x90) | 138 | #define ONENAND_CMD_READID (0x90) |