diff options
Diffstat (limited to 'include/linux/mtd/nand.h')
-rw-r--r-- | include/linux/mtd/nand.h | 121 |
1 files changed, 61 insertions, 60 deletions
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index ef52d9c91459..ab6363443ce8 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h | |||
@@ -86,7 +86,6 @@ extern int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len); | |||
86 | #define NAND_CMD_READOOB 0x50 | 86 | #define NAND_CMD_READOOB 0x50 |
87 | #define NAND_CMD_ERASE1 0x60 | 87 | #define NAND_CMD_ERASE1 0x60 |
88 | #define NAND_CMD_STATUS 0x70 | 88 | #define NAND_CMD_STATUS 0x70 |
89 | #define NAND_CMD_STATUS_MULTI 0x71 | ||
90 | #define NAND_CMD_SEQIN 0x80 | 89 | #define NAND_CMD_SEQIN 0x80 |
91 | #define NAND_CMD_RNDIN 0x85 | 90 | #define NAND_CMD_RNDIN 0x85 |
92 | #define NAND_CMD_READID 0x90 | 91 | #define NAND_CMD_READID 0x90 |
@@ -105,25 +104,6 @@ extern int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len); | |||
105 | #define NAND_CMD_RNDOUTSTART 0xE0 | 104 | #define NAND_CMD_RNDOUTSTART 0xE0 |
106 | #define NAND_CMD_CACHEDPROG 0x15 | 105 | #define NAND_CMD_CACHEDPROG 0x15 |
107 | 106 | ||
108 | /* Extended commands for AG-AND device */ | ||
109 | /* | ||
110 | * Note: the command for NAND_CMD_DEPLETE1 is really 0x00 but | ||
111 | * there is no way to distinguish that from NAND_CMD_READ0 | ||
112 | * until the remaining sequence of commands has been completed | ||
113 | * so add a high order bit and mask it off in the command. | ||
114 | */ | ||
115 | #define NAND_CMD_DEPLETE1 0x100 | ||
116 | #define NAND_CMD_DEPLETE2 0x38 | ||
117 | #define NAND_CMD_STATUS_MULTI 0x71 | ||
118 | #define NAND_CMD_STATUS_ERROR 0x72 | ||
119 | /* multi-bank error status (banks 0-3) */ | ||
120 | #define NAND_CMD_STATUS_ERROR0 0x73 | ||
121 | #define NAND_CMD_STATUS_ERROR1 0x74 | ||
122 | #define NAND_CMD_STATUS_ERROR2 0x75 | ||
123 | #define NAND_CMD_STATUS_ERROR3 0x76 | ||
124 | #define NAND_CMD_STATUS_RESET 0x7f | ||
125 | #define NAND_CMD_STATUS_CLEAR 0xff | ||
126 | |||
127 | #define NAND_CMD_NONE -1 | 107 | #define NAND_CMD_NONE -1 |
128 | 108 | ||
129 | /* Status bits */ | 109 | /* Status bits */ |
@@ -165,28 +145,8 @@ typedef enum { | |||
165 | */ | 145 | */ |
166 | /* Buswidth is 16 bit */ | 146 | /* Buswidth is 16 bit */ |
167 | #define NAND_BUSWIDTH_16 0x00000002 | 147 | #define NAND_BUSWIDTH_16 0x00000002 |
168 | /* Device supports partial programming without padding */ | ||
169 | #define NAND_NO_PADDING 0x00000004 | ||
170 | /* Chip has cache program function */ | 148 | /* Chip has cache program function */ |
171 | #define NAND_CACHEPRG 0x00000008 | 149 | #define NAND_CACHEPRG 0x00000008 |
172 | /* Chip has copy back function */ | ||
173 | #define NAND_COPYBACK 0x00000010 | ||
174 | /* | ||
175 | * AND Chip which has 4 banks and a confusing page / block | ||
176 | * assignment. See Renesas datasheet for further information. | ||
177 | */ | ||
178 | #define NAND_IS_AND 0x00000020 | ||
179 | /* | ||
180 | * Chip has a array of 4 pages which can be read without | ||
181 | * additional ready /busy waits. | ||
182 | */ | ||
183 | #define NAND_4PAGE_ARRAY 0x00000040 | ||
184 | /* | ||
185 | * Chip requires that BBT is periodically rewritten to prevent | ||
186 | * bits from adjacent blocks from 'leaking' in altering data. | ||
187 | * This happens with the Renesas AG-AND chips, possibly others. | ||
188 | */ | ||
189 | #define BBT_AUTO_REFRESH 0x00000080 | ||
190 | /* | 150 | /* |
191 | * Chip requires ready check on read (for auto-incremented sequential read). | 151 | * Chip requires ready check on read (for auto-incremented sequential read). |
192 | * True only for small page devices; large page devices do not support | 152 | * True only for small page devices; large page devices do not support |
@@ -207,13 +167,10 @@ typedef enum { | |||
207 | #define NAND_SUBPAGE_READ 0x00001000 | 167 | #define NAND_SUBPAGE_READ 0x00001000 |
208 | 168 | ||
209 | /* Options valid for Samsung large page devices */ | 169 | /* Options valid for Samsung large page devices */ |
210 | #define NAND_SAMSUNG_LP_OPTIONS \ | 170 | #define NAND_SAMSUNG_LP_OPTIONS NAND_CACHEPRG |
211 | (NAND_NO_PADDING | NAND_CACHEPRG | NAND_COPYBACK) | ||
212 | 171 | ||
213 | /* Macros to identify the above */ | 172 | /* Macros to identify the above */ |
214 | #define NAND_MUST_PAD(chip) (!(chip->options & NAND_NO_PADDING)) | ||
215 | #define NAND_HAS_CACHEPROG(chip) ((chip->options & NAND_CACHEPRG)) | 173 | #define NAND_HAS_CACHEPROG(chip) ((chip->options & NAND_CACHEPRG)) |
216 | #define NAND_HAS_COPYBACK(chip) ((chip->options & NAND_COPYBACK)) | ||
217 | #define NAND_HAS_SUBPAGE_READ(chip) ((chip->options & NAND_SUBPAGE_READ)) | 174 | #define NAND_HAS_SUBPAGE_READ(chip) ((chip->options & NAND_SUBPAGE_READ)) |
218 | 175 | ||
219 | /* Non chip related options */ | 176 | /* Non chip related options */ |
@@ -361,6 +318,7 @@ struct nand_hw_control { | |||
361 | * any single ECC step, 0 if bitflips uncorrectable, -EIO hw error | 318 | * any single ECC step, 0 if bitflips uncorrectable, -EIO hw error |
362 | * @read_subpage: function to read parts of the page covered by ECC; | 319 | * @read_subpage: function to read parts of the page covered by ECC; |
363 | * returns same as read_page() | 320 | * returns same as read_page() |
321 | * @write_subpage: function to write parts of the page covered by ECC. | ||
364 | * @write_page: function to write a page according to the ECC generator | 322 | * @write_page: function to write a page according to the ECC generator |
365 | * requirements. | 323 | * requirements. |
366 | * @write_oob_raw: function to write chip OOB data without ECC | 324 | * @write_oob_raw: function to write chip OOB data without ECC |
@@ -392,6 +350,9 @@ struct nand_ecc_ctrl { | |||
392 | uint8_t *buf, int oob_required, int page); | 350 | uint8_t *buf, int oob_required, int page); |
393 | int (*read_subpage)(struct mtd_info *mtd, struct nand_chip *chip, | 351 | int (*read_subpage)(struct mtd_info *mtd, struct nand_chip *chip, |
394 | uint32_t offs, uint32_t len, uint8_t *buf); | 352 | uint32_t offs, uint32_t len, uint8_t *buf); |
353 | int (*write_subpage)(struct mtd_info *mtd, struct nand_chip *chip, | ||
354 | uint32_t offset, uint32_t data_len, | ||
355 | const uint8_t *data_buf, int oob_required); | ||
395 | int (*write_page)(struct mtd_info *mtd, struct nand_chip *chip, | 356 | int (*write_page)(struct mtd_info *mtd, struct nand_chip *chip, |
396 | const uint8_t *buf, int oob_required); | 357 | const uint8_t *buf, int oob_required); |
397 | int (*write_oob_raw)(struct mtd_info *mtd, struct nand_chip *chip, | 358 | int (*write_oob_raw)(struct mtd_info *mtd, struct nand_chip *chip, |
@@ -527,8 +488,8 @@ struct nand_chip { | |||
527 | int (*errstat)(struct mtd_info *mtd, struct nand_chip *this, int state, | 488 | int (*errstat)(struct mtd_info *mtd, struct nand_chip *this, int state, |
528 | int status, int page); | 489 | int status, int page); |
529 | int (*write_page)(struct mtd_info *mtd, struct nand_chip *chip, | 490 | int (*write_page)(struct mtd_info *mtd, struct nand_chip *chip, |
530 | const uint8_t *buf, int oob_required, int page, | 491 | uint32_t offset, int data_len, const uint8_t *buf, |
531 | int cached, int raw); | 492 | int oob_required, int page, int cached, int raw); |
532 | int (*onfi_set_features)(struct mtd_info *mtd, struct nand_chip *chip, | 493 | int (*onfi_set_features)(struct mtd_info *mtd, struct nand_chip *chip, |
533 | int feature_addr, uint8_t *subfeature_para); | 494 | int feature_addr, uint8_t *subfeature_para); |
534 | int (*onfi_get_features)(struct mtd_info *mtd, struct nand_chip *chip, | 495 | int (*onfi_get_features)(struct mtd_info *mtd, struct nand_chip *chip, |
@@ -589,25 +550,65 @@ struct nand_chip { | |||
589 | #define NAND_MFR_MACRONIX 0xc2 | 550 | #define NAND_MFR_MACRONIX 0xc2 |
590 | #define NAND_MFR_EON 0x92 | 551 | #define NAND_MFR_EON 0x92 |
591 | 552 | ||
553 | /* The maximum expected count of bytes in the NAND ID sequence */ | ||
554 | #define NAND_MAX_ID_LEN 8 | ||
555 | |||
556 | /* | ||
557 | * A helper for defining older NAND chips where the second ID byte fully | ||
558 | * defined the chip, including the geometry (chip size, eraseblock size, page | ||
559 | * size). All these chips have 512 bytes NAND page size. | ||
560 | */ | ||
561 | #define LEGACY_ID_NAND(nm, devid, chipsz, erasesz, opts) \ | ||
562 | { .name = (nm), {{ .dev_id = (devid) }}, .pagesize = 512, \ | ||
563 | .chipsize = (chipsz), .erasesize = (erasesz), .options = (opts) } | ||
564 | |||
565 | /* | ||
566 | * A helper for defining newer chips which report their page size and | ||
567 | * eraseblock size via the extended ID bytes. | ||
568 | * | ||
569 | * The real difference between LEGACY_ID_NAND and EXTENDED_ID_NAND is that with | ||
570 | * EXTENDED_ID_NAND, manufacturers overloaded the same device ID so that the | ||
571 | * device ID now only represented a particular total chip size (and voltage, | ||
572 | * buswidth), and the page size, eraseblock size, and OOB size could vary while | ||
573 | * using the same device ID. | ||
574 | */ | ||
575 | #define EXTENDED_ID_NAND(nm, devid, chipsz, opts) \ | ||
576 | { .name = (nm), {{ .dev_id = (devid) }}, .chipsize = (chipsz), \ | ||
577 | .options = (opts) } | ||
578 | |||
592 | /** | 579 | /** |
593 | * struct nand_flash_dev - NAND Flash Device ID Structure | 580 | * struct nand_flash_dev - NAND Flash Device ID Structure |
594 | * @name: Identify the device type | 581 | * @name: a human-readable name of the NAND chip |
595 | * @id: device ID code | 582 | * @dev_id: the device ID (the second byte of the full chip ID array) |
596 | * @pagesize: Pagesize in bytes. Either 256 or 512 or 0 | 583 | * @mfr_id: manufecturer ID part of the full chip ID array (refers the same |
597 | * If the pagesize is 0, then the real pagesize | 584 | * memory address as @id[0]) |
598 | * and the eraseize are determined from the | 585 | * @dev_id: device ID part of the full chip ID array (refers the same memory |
599 | * extended id bytes in the chip | 586 | * address as @id[1]) |
600 | * @erasesize: Size of an erase block in the flash device. | 587 | * @id: full device ID array |
601 | * @chipsize: Total chipsize in Mega Bytes | 588 | * @pagesize: size of the NAND page in bytes; if 0, then the real page size (as |
602 | * @options: Bitfield to store chip relevant options | 589 | * well as the eraseblock size) is determined from the extended NAND |
590 | * chip ID array) | ||
591 | * @chipsize: total chip size in MiB | ||
592 | * @erasesize: eraseblock size in bytes (determined from the extended ID if 0) | ||
593 | * @options: stores various chip bit options | ||
594 | * @id_len: The valid length of the @id. | ||
595 | * @oobsize: OOB size | ||
603 | */ | 596 | */ |
604 | struct nand_flash_dev { | 597 | struct nand_flash_dev { |
605 | char *name; | 598 | char *name; |
606 | int id; | 599 | union { |
607 | unsigned long pagesize; | 600 | struct { |
608 | unsigned long chipsize; | 601 | uint8_t mfr_id; |
609 | unsigned long erasesize; | 602 | uint8_t dev_id; |
610 | unsigned long options; | 603 | }; |
604 | uint8_t id[NAND_MAX_ID_LEN]; | ||
605 | }; | ||
606 | unsigned int pagesize; | ||
607 | unsigned int chipsize; | ||
608 | unsigned int erasesize; | ||
609 | unsigned int options; | ||
610 | uint16_t id_len; | ||
611 | uint16_t oobsize; | ||
611 | }; | 612 | }; |
612 | 613 | ||
613 | /** | 614 | /** |