diff options
author | Thomas Gleixner <tglx@cruncher.tec.linutronix.de> | 2006-05-26 12:52:08 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@cruncher.tec.linutronix.de> | 2006-05-26 12:52:08 -0400 |
commit | f75e5097ef298c5a0aa106faa211d1afdc92dc3d (patch) | |
tree | 0de4534e9ae54cf5d17ea9ef20acefb931167eee /include/linux/mtd | |
parent | e4d222ff18bca6322f032088a21e9c4a4c038b85 (diff) |
[MTD] NAND modularize write function
Modularize the write function and reorganaize the internal buffer
management. Remove obsolete chip options and fixup all affected
users.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'include/linux/mtd')
-rw-r--r-- | include/linux/mtd/nand.h | 71 |
1 files changed, 45 insertions, 26 deletions
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index 00916498ea55..1a749ba6130f 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h | |||
@@ -37,7 +37,7 @@ extern int nand_read_raw (struct mtd_info *mtd, uint8_t *buf, loff_t from, | |||
37 | 37 | ||
38 | 38 | ||
39 | extern int nand_write_raw(struct mtd_info *mtd, loff_t to, size_t len, | 39 | extern int nand_write_raw(struct mtd_info *mtd, loff_t to, size_t len, |
40 | size_t *retlen, uint8_t *buf, uint8_t *oob); | 40 | size_t *retlen, const uint8_t *buf, uint8_t *oob); |
41 | 41 | ||
42 | /* The maximum number of NAND chips in an array */ | 42 | /* The maximum number of NAND chips in an array */ |
43 | #define NAND_MAX_CHIPS 8 | 43 | #define NAND_MAX_CHIPS 8 |
@@ -47,6 +47,7 @@ extern int nand_write_raw(struct mtd_info *mtd, loff_t to, size_t len, | |||
47 | * adjust this accordingly. | 47 | * adjust this accordingly. |
48 | */ | 48 | */ |
49 | #define NAND_MAX_OOBSIZE 64 | 49 | #define NAND_MAX_OOBSIZE 64 |
50 | #define NAND_MAX_PAGESIZE 2048 | ||
50 | 51 | ||
51 | /* | 52 | /* |
52 | * Constants for hardware specific CLE/ALE/NCE function | 53 | * Constants for hardware specific CLE/ALE/NCE function |
@@ -181,20 +182,12 @@ typedef enum { | |||
181 | /* Use a flash based bad block table. This option is passed to the | 182 | /* Use a flash based bad block table. This option is passed to the |
182 | * default bad block table function. */ | 183 | * default bad block table function. */ |
183 | #define NAND_USE_FLASH_BBT 0x00010000 | 184 | #define NAND_USE_FLASH_BBT 0x00010000 |
184 | /* The hw ecc generator provides a syndrome instead a ecc value on read | ||
185 | * This can only work if we have the ecc bytes directly behind the | ||
186 | * data bytes. Applies for DOC and AG-AND Renesas HW Reed Solomon generators */ | ||
187 | #define NAND_HWECC_SYNDROME 0x00020000 | ||
188 | /* This option skips the bbt scan during initialization. */ | 185 | /* This option skips the bbt scan during initialization. */ |
189 | #define NAND_SKIP_BBTSCAN 0x00040000 | 186 | #define NAND_SKIP_BBTSCAN 0x00020000 |
190 | 187 | ||
191 | /* Options set by nand scan */ | 188 | /* Options set by nand scan */ |
192 | /* Nand scan has allocated controller struct */ | 189 | /* Nand scan has allocated controller struct */ |
193 | #define NAND_CONTROLLER_ALLOC 0x20000000 | 190 | #define NAND_CONTROLLER_ALLOC 0x80000000 |
194 | /* Nand scan has allocated oob_buf */ | ||
195 | #define NAND_OOBBUF_ALLOC 0x40000000 | ||
196 | /* Nand scan has allocated data_buf */ | ||
197 | #define NAND_DATABUF_ALLOC 0x80000000 | ||
198 | 191 | ||
199 | 192 | ||
200 | /* | 193 | /* |
@@ -240,6 +233,7 @@ struct nand_hw_control { | |||
240 | * be provided if an hardware ECC is available | 233 | * be provided if an hardware ECC is available |
241 | * @calculate: function for ecc calculation or readback from ecc hardware | 234 | * @calculate: function for ecc calculation or readback from ecc hardware |
242 | * @correct: function for ecc correction, matching to ecc generator (sw/hw) | 235 | * @correct: function for ecc correction, matching to ecc generator (sw/hw) |
236 | * @read_page: function to read a page according to the ecc generator requirements | ||
243 | * @write_page: function to write a page according to the ecc generator requirements | 237 | * @write_page: function to write a page according to the ecc generator requirements |
244 | */ | 238 | */ |
245 | struct nand_ecc_ctrl { | 239 | struct nand_ecc_ctrl { |
@@ -260,9 +254,28 @@ struct nand_ecc_ctrl { | |||
260 | int (*read_page)(struct mtd_info *mtd, | 254 | int (*read_page)(struct mtd_info *mtd, |
261 | struct nand_chip *chip, | 255 | struct nand_chip *chip, |
262 | uint8_t *buf); | 256 | uint8_t *buf); |
263 | int (*write_page)(struct mtd_info *mtd, | 257 | void (*write_page)(struct mtd_info *mtd, |
264 | struct nand_chip *chip, | 258 | struct nand_chip *chip, |
265 | uint8_t *buf, int cached); | 259 | const uint8_t *buf); |
260 | }; | ||
261 | |||
262 | /** | ||
263 | * struct nand_buffers - buffer structure for read/write | ||
264 | * @ecccalc: buffer for calculated ecc | ||
265 | * @ecccode: buffer for ecc read from flash | ||
266 | * @oobwbuf: buffer for write oob data | ||
267 | * @databuf: buffer for data - dynamically sized | ||
268 | * @oobrbuf: buffer to read oob data | ||
269 | * | ||
270 | * Do not change the order of buffers. databuf and oobrbuf must be in | ||
271 | * consecutive order. | ||
272 | */ | ||
273 | struct nand_buffers { | ||
274 | uint8_t ecccalc[NAND_MAX_OOBSIZE]; | ||
275 | uint8_t ecccode[NAND_MAX_OOBSIZE]; | ||
276 | uint8_t oobwbuf[NAND_MAX_OOBSIZE]; | ||
277 | uint8_t databuf[NAND_MAX_PAGESIZE]; | ||
278 | uint8_t oobrbuf[NAND_MAX_OOBSIZE]; | ||
266 | }; | 279 | }; |
267 | 280 | ||
268 | /** | 281 | /** |
@@ -294,8 +307,8 @@ struct nand_ecc_ctrl { | |||
294 | * @phys_erase_shift: [INTERN] number of address bits in a physical eraseblock | 307 | * @phys_erase_shift: [INTERN] number of address bits in a physical eraseblock |
295 | * @bbt_erase_shift: [INTERN] number of address bits in a bbt entry | 308 | * @bbt_erase_shift: [INTERN] number of address bits in a bbt entry |
296 | * @chip_shift: [INTERN] number of address bits in one chip | 309 | * @chip_shift: [INTERN] number of address bits in one chip |
297 | * @data_buf: [INTERN] internal buffer for one page + oob | 310 | * @datbuf: [INTERN] internal buffer for one page + oob |
298 | * @oob_buf: [INTERN] oob buffer for one eraseblock | 311 | * @oobbuf: [INTERN] oob buffer for one eraseblock |
299 | * @oobdirty: [INTERN] indicates that oob_buf must be reinitialized | 312 | * @oobdirty: [INTERN] indicates that oob_buf must be reinitialized |
300 | * @data_poi: [INTERN] pointer to a data buffer | 313 | * @data_poi: [INTERN] pointer to a data buffer |
301 | * @options: [BOARDSPECIFIC] various chip options. They can partly be set to inform nand_scan about | 314 | * @options: [BOARDSPECIFIC] various chip options. They can partly be set to inform nand_scan about |
@@ -336,32 +349,38 @@ struct nand_chip { | |||
336 | int (*waitfunc)(struct mtd_info *mtd, struct nand_chip *this, int state); | 349 | int (*waitfunc)(struct mtd_info *mtd, struct nand_chip *this, int state); |
337 | void (*erase_cmd)(struct mtd_info *mtd, int page); | 350 | void (*erase_cmd)(struct mtd_info *mtd, int page); |
338 | int (*scan_bbt)(struct mtd_info *mtd); | 351 | int (*scan_bbt)(struct mtd_info *mtd); |
339 | struct nand_ecc_ctrl ecc; | 352 | int (*errstat)(struct mtd_info *mtd, struct nand_chip *this, int state, int status, int page); |
353 | |||
340 | int chip_delay; | 354 | int chip_delay; |
341 | wait_queue_head_t wq; | 355 | unsigned int options; |
342 | nand_state_t state; | 356 | |
343 | int page_shift; | 357 | int page_shift; |
344 | int phys_erase_shift; | 358 | int phys_erase_shift; |
345 | int bbt_erase_shift; | 359 | int bbt_erase_shift; |
346 | int chip_shift; | 360 | int chip_shift; |
347 | uint8_t *data_buf; | ||
348 | uint8_t *oob_buf; | ||
349 | int oobdirty; | ||
350 | uint8_t *data_poi; | ||
351 | unsigned int options; | ||
352 | int badblockpos; | ||
353 | int numchips; | 361 | int numchips; |
354 | unsigned long chipsize; | 362 | unsigned long chipsize; |
355 | int pagemask; | 363 | int pagemask; |
356 | int pagebuf; | 364 | int pagebuf; |
365 | int badblockpos; | ||
366 | |||
367 | nand_state_t state; | ||
368 | |||
369 | uint8_t *oob_poi; | ||
370 | struct nand_hw_control *controller; | ||
357 | struct nand_oobinfo *autooob; | 371 | struct nand_oobinfo *autooob; |
372 | |||
373 | struct nand_ecc_ctrl ecc; | ||
374 | struct nand_buffers buffers; | ||
375 | struct nand_hw_control hwcontrol; | ||
376 | |||
358 | uint8_t *bbt; | 377 | uint8_t *bbt; |
359 | struct nand_bbt_descr *bbt_td; | 378 | struct nand_bbt_descr *bbt_td; |
360 | struct nand_bbt_descr *bbt_md; | 379 | struct nand_bbt_descr *bbt_md; |
380 | |||
361 | struct nand_bbt_descr *badblock_pattern; | 381 | struct nand_bbt_descr *badblock_pattern; |
362 | struct nand_hw_control *controller; | 382 | |
363 | void *priv; | 383 | void *priv; |
364 | int (*errstat)(struct mtd_info *mtd, struct nand_chip *this, int state, int status, int page); | ||
365 | }; | 384 | }; |
366 | 385 | ||
367 | /* | 386 | /* |