diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2005-11-07 06:15:49 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@mtd.linutronix.de> | 2005-11-07 09:10:37 -0500 |
commit | 61b03bd7c3b55498c6180d43bf71b7bf49114b64 (patch) | |
tree | 5a7d7df4653d2032bca0d2b13a26828c8925dd60 /drivers/mtd/nand/nand_base.c | |
parent | e5580fbe8a950131b9ccccce0f962811dfb9ef43 (diff) |
[MTD] NAND: Clean up trailing white spaces
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'drivers/mtd/nand/nand_base.c')
-rw-r--r-- | drivers/mtd/nand/nand_base.c | 478 |
1 files changed, 239 insertions, 239 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index c18ea76ed408..4673ba79309b 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c | |||
@@ -5,14 +5,14 @@ | |||
5 | * This is the generic MTD driver for NAND flash devices. It should be | 5 | * This is the generic MTD driver for NAND flash devices. It should be |
6 | * capable of working with almost all NAND chips currently available. | 6 | * capable of working with almost all NAND chips currently available. |
7 | * Basic support for AG-AND chips is provided. | 7 | * Basic support for AG-AND chips is provided. |
8 | * | 8 | * |
9 | * Additional technical information is available on | 9 | * Additional technical information is available on |
10 | * http://www.linux-mtd.infradead.org/tech/nand.html | 10 | * http://www.linux-mtd.infradead.org/tech/nand.html |
11 | * | 11 | * |
12 | * Copyright (C) 2000 Steven J. Hill (sjhill@realitydiluted.com) | 12 | * Copyright (C) 2000 Steven J. Hill (sjhill@realitydiluted.com) |
13 | * 2002 Thomas Gleixner (tglx@linutronix.de) | 13 | * 2002 Thomas Gleixner (tglx@linutronix.de) |
14 | * | 14 | * |
15 | * 02-08-2004 tglx: support for strange chips, which cannot auto increment | 15 | * 02-08-2004 tglx: support for strange chips, which cannot auto increment |
16 | * pages on read / read_oob | 16 | * pages on read / read_oob |
17 | * | 17 | * |
18 | * 03-17-2004 tglx: Check ready before auto increment check. Simon Bayes | 18 | * 03-17-2004 tglx: Check ready before auto increment check. Simon Bayes |
@@ -21,7 +21,7 @@ | |||
21 | * Make reads over block boundaries work too | 21 | * Make reads over block boundaries work too |
22 | * | 22 | * |
23 | * 04-14-2004 tglx: first working version for 2k page size chips | 23 | * 04-14-2004 tglx: first working version for 2k page size chips |
24 | * | 24 | * |
25 | * 05-19-2004 tglx: Basic support for Renesas AG-AND chips | 25 | * 05-19-2004 tglx: Basic support for Renesas AG-AND chips |
26 | * | 26 | * |
27 | * 09-24-2004 tglx: add support for hardware controllers (e.g. ECC) shared | 27 | * 09-24-2004 tglx: add support for hardware controllers (e.g. ECC) shared |
@@ -30,27 +30,27 @@ | |||
30 | * | 30 | * |
31 | * 12-05-2004 dmarlin: add workaround for Renesas AG-AND chips "disturb" issue. | 31 | * 12-05-2004 dmarlin: add workaround for Renesas AG-AND chips "disturb" issue. |
32 | * Basically, any block not rewritten may lose data when surrounding blocks | 32 | * Basically, any block not rewritten may lose data when surrounding blocks |
33 | * are rewritten many times. JFFS2 ensures this doesn't happen for blocks | 33 | * are rewritten many times. JFFS2 ensures this doesn't happen for blocks |
34 | * it uses, but the Bad Block Table(s) may not be rewritten. To ensure they | 34 | * it uses, but the Bad Block Table(s) may not be rewritten. To ensure they |
35 | * do not lose data, force them to be rewritten when some of the surrounding | 35 | * do not lose data, force them to be rewritten when some of the surrounding |
36 | * blocks are erased. Rather than tracking a specific nearby block (which | 36 | * blocks are erased. Rather than tracking a specific nearby block (which |
37 | * could itself go bad), use a page address 'mask' to select several blocks | 37 | * could itself go bad), use a page address 'mask' to select several blocks |
38 | * in the same area, and rewrite the BBT when any of them are erased. | 38 | * in the same area, and rewrite the BBT when any of them are erased. |
39 | * | 39 | * |
40 | * 01-03-2005 dmarlin: added support for the device recovery command sequence for Renesas | 40 | * 01-03-2005 dmarlin: added support for the device recovery command sequence for Renesas |
41 | * AG-AND chips. If there was a sudden loss of power during an erase operation, | 41 | * AG-AND chips. If there was a sudden loss of power during an erase operation, |
42 | * a "device recovery" operation must be performed when power is restored | 42 | * a "device recovery" operation must be performed when power is restored |
43 | * to ensure correct operation. | 43 | * to ensure correct operation. |
44 | * | 44 | * |
45 | * 01-20-2005 dmarlin: added support for optional hardware specific callback routine to | 45 | * 01-20-2005 dmarlin: added support for optional hardware specific callback routine to |
46 | * perform extra error status checks on erase and write failures. This required | 46 | * perform extra error status checks on erase and write failures. This required |
47 | * adding a wrapper function for nand_read_ecc. | 47 | * adding a wrapper function for nand_read_ecc. |
48 | * | 48 | * |
49 | * 08-20-2005 vwool: suspend/resume added | 49 | * 08-20-2005 vwool: suspend/resume added |
50 | * | 50 | * |
51 | * Credits: | 51 | * Credits: |
52 | * David Woodhouse for adding multichip support | 52 | * David Woodhouse for adding multichip support |
53 | * | 53 | * |
54 | * Aleph One Ltd. and Toby Churchill Ltd. for supporting the | 54 | * Aleph One Ltd. and Toby Churchill Ltd. for supporting the |
55 | * rework for 2K page size chips | 55 | * rework for 2K page size chips |
56 | * | 56 | * |
@@ -105,8 +105,8 @@ static struct nand_oobinfo nand_oob_64 = { | |||
105 | .useecc = MTD_NANDECC_AUTOPLACE, | 105 | .useecc = MTD_NANDECC_AUTOPLACE, |
106 | .eccbytes = 24, | 106 | .eccbytes = 24, |
107 | .eccpos = { | 107 | .eccpos = { |
108 | 40, 41, 42, 43, 44, 45, 46, 47, | 108 | 40, 41, 42, 43, 44, 45, 46, 47, |
109 | 48, 49, 50, 51, 52, 53, 54, 55, | 109 | 48, 49, 50, 51, 52, 53, 54, 55, |
110 | 56, 57, 58, 59, 60, 61, 62, 63}, | 110 | 56, 57, 58, 59, 60, 61, 62, 63}, |
111 | .oobfree = { {2, 38} } | 111 | .oobfree = { {2, 38} } |
112 | }; | 112 | }; |
@@ -149,19 +149,19 @@ static void nand_sync (struct mtd_info *mtd); | |||
149 | static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int page, u_char *oob_buf, | 149 | static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int page, u_char *oob_buf, |
150 | struct nand_oobinfo *oobsel, int mode); | 150 | struct nand_oobinfo *oobsel, int mode); |
151 | #ifdef CONFIG_MTD_NAND_VERIFY_WRITE | 151 | #ifdef CONFIG_MTD_NAND_VERIFY_WRITE |
152 | static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int page, int numpages, | 152 | static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int page, int numpages, |
153 | u_char *oob_buf, struct nand_oobinfo *oobsel, int chipnr, int oobmode); | 153 | u_char *oob_buf, struct nand_oobinfo *oobsel, int chipnr, int oobmode); |
154 | #else | 154 | #else |
155 | #define nand_verify_pages(...) (0) | 155 | #define nand_verify_pages(...) (0) |
156 | #endif | 156 | #endif |
157 | 157 | ||
158 | static int nand_get_device (struct nand_chip *this, struct mtd_info *mtd, int new_state); | 158 | static int nand_get_device (struct nand_chip *this, struct mtd_info *mtd, int new_state); |
159 | 159 | ||
160 | /** | 160 | /** |
161 | * nand_release_device - [GENERIC] release chip | 161 | * nand_release_device - [GENERIC] release chip |
162 | * @mtd: MTD device structure | 162 | * @mtd: MTD device structure |
163 | * | 163 | * |
164 | * Deselect, release chip lock and wake up anyone waiting on the device | 164 | * Deselect, release chip lock and wake up anyone waiting on the device |
165 | */ | 165 | */ |
166 | static void nand_release_device (struct mtd_info *mtd) | 166 | static void nand_release_device (struct mtd_info *mtd) |
167 | { | 167 | { |
@@ -215,7 +215,7 @@ static void nand_write_byte(struct mtd_info *mtd, u_char byte) | |||
215 | * nand_read_byte16 - [DEFAULT] read one byte endianess aware from the chip | 215 | * nand_read_byte16 - [DEFAULT] read one byte endianess aware from the chip |
216 | * @mtd: MTD device structure | 216 | * @mtd: MTD device structure |
217 | * | 217 | * |
218 | * Default read function for 16bit buswith with | 218 | * Default read function for 16bit buswith with |
219 | * endianess conversion | 219 | * endianess conversion |
220 | */ | 220 | */ |
221 | static u_char nand_read_byte16(struct mtd_info *mtd) | 221 | static u_char nand_read_byte16(struct mtd_info *mtd) |
@@ -242,7 +242,7 @@ static void nand_write_byte16(struct mtd_info *mtd, u_char byte) | |||
242 | * nand_read_word - [DEFAULT] read one word from the chip | 242 | * nand_read_word - [DEFAULT] read one word from the chip |
243 | * @mtd: MTD device structure | 243 | * @mtd: MTD device structure |
244 | * | 244 | * |
245 | * Default read function for 16bit buswith without | 245 | * Default read function for 16bit buswith without |
246 | * endianess conversion | 246 | * endianess conversion |
247 | */ | 247 | */ |
248 | static u16 nand_read_word(struct mtd_info *mtd) | 248 | static u16 nand_read_word(struct mtd_info *mtd) |
@@ -256,7 +256,7 @@ static u16 nand_read_word(struct mtd_info *mtd) | |||
256 | * @mtd: MTD device structure | 256 | * @mtd: MTD device structure |
257 | * @word: data word to write | 257 | * @word: data word to write |
258 | * | 258 | * |
259 | * Default write function for 16bit buswith without | 259 | * Default write function for 16bit buswith without |
260 | * endianess conversion | 260 | * endianess conversion |
261 | */ | 261 | */ |
262 | static void nand_write_word(struct mtd_info *mtd, u16 word) | 262 | static void nand_write_word(struct mtd_info *mtd, u16 word) |
@@ -277,7 +277,7 @@ static void nand_select_chip(struct mtd_info *mtd, int chip) | |||
277 | struct nand_chip *this = mtd->priv; | 277 | struct nand_chip *this = mtd->priv; |
278 | switch(chip) { | 278 | switch(chip) { |
279 | case -1: | 279 | case -1: |
280 | this->hwcontrol(mtd, NAND_CTL_CLRNCE); | 280 | this->hwcontrol(mtd, NAND_CTL_CLRNCE); |
281 | break; | 281 | break; |
282 | case 0: | 282 | case 0: |
283 | this->hwcontrol(mtd, NAND_CTL_SETNCE); | 283 | this->hwcontrol(mtd, NAND_CTL_SETNCE); |
@@ -306,7 +306,7 @@ static void nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len) | |||
306 | } | 306 | } |
307 | 307 | ||
308 | /** | 308 | /** |
309 | * nand_read_buf - [DEFAULT] read chip data into buffer | 309 | * nand_read_buf - [DEFAULT] read chip data into buffer |
310 | * @mtd: MTD device structure | 310 | * @mtd: MTD device structure |
311 | * @buf: buffer to store date | 311 | * @buf: buffer to store date |
312 | * @len: number of bytes to read | 312 | * @len: number of bytes to read |
@@ -323,7 +323,7 @@ static void nand_read_buf(struct mtd_info *mtd, u_char *buf, int len) | |||
323 | } | 323 | } |
324 | 324 | ||
325 | /** | 325 | /** |
326 | * nand_verify_buf - [DEFAULT] Verify chip data against buffer | 326 | * nand_verify_buf - [DEFAULT] Verify chip data against buffer |
327 | * @mtd: MTD device structure | 327 | * @mtd: MTD device structure |
328 | * @buf: buffer containing the data to compare | 328 | * @buf: buffer containing the data to compare |
329 | * @len: number of bytes to compare | 329 | * @len: number of bytes to compare |
@@ -356,14 +356,14 @@ static void nand_write_buf16(struct mtd_info *mtd, const u_char *buf, int len) | |||
356 | struct nand_chip *this = mtd->priv; | 356 | struct nand_chip *this = mtd->priv; |
357 | u16 *p = (u16 *) buf; | 357 | u16 *p = (u16 *) buf; |
358 | len >>= 1; | 358 | len >>= 1; |
359 | 359 | ||
360 | for (i=0; i<len; i++) | 360 | for (i=0; i<len; i++) |
361 | writew(p[i], this->IO_ADDR_W); | 361 | writew(p[i], this->IO_ADDR_W); |
362 | 362 | ||
363 | } | 363 | } |
364 | 364 | ||
365 | /** | 365 | /** |
366 | * nand_read_buf16 - [DEFAULT] read chip data into buffer | 366 | * nand_read_buf16 - [DEFAULT] read chip data into buffer |
367 | * @mtd: MTD device structure | 367 | * @mtd: MTD device structure |
368 | * @buf: buffer to store date | 368 | * @buf: buffer to store date |
369 | * @len: number of bytes to read | 369 | * @len: number of bytes to read |
@@ -382,7 +382,7 @@ static void nand_read_buf16(struct mtd_info *mtd, u_char *buf, int len) | |||
382 | } | 382 | } |
383 | 383 | ||
384 | /** | 384 | /** |
385 | * nand_verify_buf16 - [DEFAULT] Verify chip data against buffer | 385 | * nand_verify_buf16 - [DEFAULT] Verify chip data against buffer |
386 | * @mtd: MTD device structure | 386 | * @mtd: MTD device structure |
387 | * @buf: buffer containing the data to compare | 387 | * @buf: buffer containing the data to compare |
388 | * @len: number of bytes to compare | 388 | * @len: number of bytes to compare |
@@ -409,7 +409,7 @@ static int nand_verify_buf16(struct mtd_info *mtd, const u_char *buf, int len) | |||
409 | * @ofs: offset from device start | 409 | * @ofs: offset from device start |
410 | * @getchip: 0, if the chip is already selected | 410 | * @getchip: 0, if the chip is already selected |
411 | * | 411 | * |
412 | * Check, if the block is bad. | 412 | * Check, if the block is bad. |
413 | */ | 413 | */ |
414 | static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip) | 414 | static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip) |
415 | { | 415 | { |
@@ -426,8 +426,8 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip) | |||
426 | 426 | ||
427 | /* Select the NAND device */ | 427 | /* Select the NAND device */ |
428 | this->select_chip(mtd, chipnr); | 428 | this->select_chip(mtd, chipnr); |
429 | } else | 429 | } else |
430 | page = (int) ofs; | 430 | page = (int) ofs; |
431 | 431 | ||
432 | if (this->options & NAND_BUSWIDTH_16) { | 432 | if (this->options & NAND_BUSWIDTH_16) { |
433 | this->cmdfunc (mtd, NAND_CMD_READOOB, this->badblockpos & 0xFE, page & this->pagemask); | 433 | this->cmdfunc (mtd, NAND_CMD_READOOB, this->badblockpos & 0xFE, page & this->pagemask); |
@@ -441,12 +441,12 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip) | |||
441 | if (this->read_byte(mtd) != 0xff) | 441 | if (this->read_byte(mtd) != 0xff) |
442 | res = 1; | 442 | res = 1; |
443 | } | 443 | } |
444 | 444 | ||
445 | if (getchip) { | 445 | if (getchip) { |
446 | /* Deselect and wake up anyone waiting on the device */ | 446 | /* Deselect and wake up anyone waiting on the device */ |
447 | nand_release_device(mtd); | 447 | nand_release_device(mtd); |
448 | } | 448 | } |
449 | 449 | ||
450 | return res; | 450 | return res; |
451 | } | 451 | } |
452 | 452 | ||
@@ -464,7 +464,7 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs) | |||
464 | u_char buf[2] = {0, 0}; | 464 | u_char buf[2] = {0, 0}; |
465 | size_t retlen; | 465 | size_t retlen; |
466 | int block; | 466 | int block; |
467 | 467 | ||
468 | /* Get block number */ | 468 | /* Get block number */ |
469 | block = ((int) ofs) >> this->bbt_erase_shift; | 469 | block = ((int) ofs) >> this->bbt_erase_shift; |
470 | if (this->bbt) | 470 | if (this->bbt) |
@@ -473,25 +473,25 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs) | |||
473 | /* Do we have a flash based bad block table ? */ | 473 | /* Do we have a flash based bad block table ? */ |
474 | if (this->options & NAND_USE_FLASH_BBT) | 474 | if (this->options & NAND_USE_FLASH_BBT) |
475 | return nand_update_bbt (mtd, ofs); | 475 | return nand_update_bbt (mtd, ofs); |
476 | 476 | ||
477 | /* We write two bytes, so we dont have to mess with 16 bit access */ | 477 | /* We write two bytes, so we dont have to mess with 16 bit access */ |
478 | ofs += mtd->oobsize + (this->badblockpos & ~0x01); | 478 | ofs += mtd->oobsize + (this->badblockpos & ~0x01); |
479 | return nand_write_oob (mtd, ofs , 2, &retlen, buf); | 479 | return nand_write_oob (mtd, ofs , 2, &retlen, buf); |
480 | } | 480 | } |
481 | 481 | ||
482 | /** | 482 | /** |
483 | * nand_check_wp - [GENERIC] check if the chip is write protected | 483 | * nand_check_wp - [GENERIC] check if the chip is write protected |
484 | * @mtd: MTD device structure | 484 | * @mtd: MTD device structure |
485 | * Check, if the device is write protected | 485 | * Check, if the device is write protected |
486 | * | 486 | * |
487 | * The function expects, that the device is already selected | 487 | * The function expects, that the device is already selected |
488 | */ | 488 | */ |
489 | static int nand_check_wp (struct mtd_info *mtd) | 489 | static int nand_check_wp (struct mtd_info *mtd) |
490 | { | 490 | { |
491 | struct nand_chip *this = mtd->priv; | 491 | struct nand_chip *this = mtd->priv; |
492 | /* Check the WP bit */ | 492 | /* Check the WP bit */ |
493 | this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1); | 493 | this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1); |
494 | return (this->read_byte(mtd) & NAND_STATUS_WP) ? 0 : 1; | 494 | return (this->read_byte(mtd) & NAND_STATUS_WP) ? 0 : 1; |
495 | } | 495 | } |
496 | 496 | ||
497 | /** | 497 | /** |
@@ -507,15 +507,15 @@ static int nand_check_wp (struct mtd_info *mtd) | |||
507 | static int nand_block_checkbad (struct mtd_info *mtd, loff_t ofs, int getchip, int allowbbt) | 507 | static int nand_block_checkbad (struct mtd_info *mtd, loff_t ofs, int getchip, int allowbbt) |
508 | { | 508 | { |
509 | struct nand_chip *this = mtd->priv; | 509 | struct nand_chip *this = mtd->priv; |
510 | 510 | ||
511 | if (!this->bbt) | 511 | if (!this->bbt) |
512 | return this->block_bad(mtd, ofs, getchip); | 512 | return this->block_bad(mtd, ofs, getchip); |
513 | 513 | ||
514 | /* Return info from the table */ | 514 | /* Return info from the table */ |
515 | return nand_isbad_bbt (mtd, ofs, allowbbt); | 515 | return nand_isbad_bbt (mtd, ofs, allowbbt); |
516 | } | 516 | } |
517 | 517 | ||
518 | /* | 518 | /* |
519 | * Wait for the ready pin, after a command | 519 | * Wait for the ready pin, after a command |
520 | * The timeout is catched later. | 520 | * The timeout is catched later. |
521 | */ | 521 | */ |
@@ -529,7 +529,7 @@ static void nand_wait_ready(struct mtd_info *mtd) | |||
529 | if (this->dev_ready(mtd)) | 529 | if (this->dev_ready(mtd)) |
530 | return; | 530 | return; |
531 | touch_softlockup_watchdog(); | 531 | touch_softlockup_watchdog(); |
532 | } while (time_before(jiffies, timeo)); | 532 | } while (time_before(jiffies, timeo)); |
533 | } | 533 | } |
534 | 534 | ||
535 | /** | 535 | /** |
@@ -592,13 +592,13 @@ static void nand_command (struct mtd_info *mtd, unsigned command, int column, in | |||
592 | /* Latch in address */ | 592 | /* Latch in address */ |
593 | this->hwcontrol(mtd, NAND_CTL_CLRALE); | 593 | this->hwcontrol(mtd, NAND_CTL_CLRALE); |
594 | } | 594 | } |
595 | 595 | ||
596 | /* | 596 | /* |
597 | * program and erase have their own busy handlers | 597 | * program and erase have their own busy handlers |
598 | * status and sequential in needs no delay | 598 | * status and sequential in needs no delay |
599 | */ | 599 | */ |
600 | switch (command) { | 600 | switch (command) { |
601 | 601 | ||
602 | case NAND_CMD_PAGEPROG: | 602 | case NAND_CMD_PAGEPROG: |
603 | case NAND_CMD_ERASE1: | 603 | case NAND_CMD_ERASE1: |
604 | case NAND_CMD_ERASE2: | 604 | case NAND_CMD_ERASE2: |
@@ -607,7 +607,7 @@ static void nand_command (struct mtd_info *mtd, unsigned command, int column, in | |||
607 | return; | 607 | return; |
608 | 608 | ||
609 | case NAND_CMD_RESET: | 609 | case NAND_CMD_RESET: |
610 | if (this->dev_ready) | 610 | if (this->dev_ready) |
611 | break; | 611 | break; |
612 | udelay(this->chip_delay); | 612 | udelay(this->chip_delay); |
613 | this->hwcontrol(mtd, NAND_CTL_SETCLE); | 613 | this->hwcontrol(mtd, NAND_CTL_SETCLE); |
@@ -616,16 +616,16 @@ static void nand_command (struct mtd_info *mtd, unsigned command, int column, in | |||
616 | while ( !(this->read_byte(mtd) & NAND_STATUS_READY)); | 616 | while ( !(this->read_byte(mtd) & NAND_STATUS_READY)); |
617 | return; | 617 | return; |
618 | 618 | ||
619 | /* This applies to read commands */ | 619 | /* This applies to read commands */ |
620 | default: | 620 | default: |
621 | /* | 621 | /* |
622 | * If we don't have access to the busy pin, we apply the given | 622 | * If we don't have access to the busy pin, we apply the given |
623 | * command delay | 623 | * command delay |
624 | */ | 624 | */ |
625 | if (!this->dev_ready) { | 625 | if (!this->dev_ready) { |
626 | udelay (this->chip_delay); | 626 | udelay (this->chip_delay); |
627 | return; | 627 | return; |
628 | } | 628 | } |
629 | } | 629 | } |
630 | /* Apply this short delay always to ensure that we do wait tWB in | 630 | /* Apply this short delay always to ensure that we do wait tWB in |
631 | * any case on any machine. */ | 631 | * any case on any machine. */ |
@@ -655,8 +655,8 @@ static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column, | |||
655 | column += mtd->oobblock; | 655 | column += mtd->oobblock; |
656 | command = NAND_CMD_READ0; | 656 | command = NAND_CMD_READ0; |
657 | } | 657 | } |
658 | 658 | ||
659 | 659 | ||
660 | /* Begin command latch cycle */ | 660 | /* Begin command latch cycle */ |
661 | this->hwcontrol(mtd, NAND_CTL_SETCLE); | 661 | this->hwcontrol(mtd, NAND_CTL_SETCLE); |
662 | /* Write out the command to the device. */ | 662 | /* Write out the command to the device. */ |
@@ -674,7 +674,7 @@ static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column, | |||
674 | column >>= 1; | 674 | column >>= 1; |
675 | this->write_byte(mtd, column & 0xff); | 675 | this->write_byte(mtd, column & 0xff); |
676 | this->write_byte(mtd, column >> 8); | 676 | this->write_byte(mtd, column >> 8); |
677 | } | 677 | } |
678 | if (page_addr != -1) { | 678 | if (page_addr != -1) { |
679 | this->write_byte(mtd, (unsigned char) (page_addr & 0xff)); | 679 | this->write_byte(mtd, (unsigned char) (page_addr & 0xff)); |
680 | this->write_byte(mtd, (unsigned char) ((page_addr >> 8) & 0xff)); | 680 | this->write_byte(mtd, (unsigned char) ((page_addr >> 8) & 0xff)); |
@@ -685,13 +685,13 @@ static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column, | |||
685 | /* Latch in address */ | 685 | /* Latch in address */ |
686 | this->hwcontrol(mtd, NAND_CTL_CLRALE); | 686 | this->hwcontrol(mtd, NAND_CTL_CLRALE); |
687 | } | 687 | } |
688 | 688 | ||
689 | /* | 689 | /* |
690 | * program and erase have their own busy handlers | 690 | * program and erase have their own busy handlers |
691 | * status, sequential in, and deplete1 need no delay | 691 | * status, sequential in, and deplete1 need no delay |
692 | */ | 692 | */ |
693 | switch (command) { | 693 | switch (command) { |
694 | 694 | ||
695 | case NAND_CMD_CACHEDPROG: | 695 | case NAND_CMD_CACHEDPROG: |
696 | case NAND_CMD_PAGEPROG: | 696 | case NAND_CMD_PAGEPROG: |
697 | case NAND_CMD_ERASE1: | 697 | case NAND_CMD_ERASE1: |
@@ -701,7 +701,7 @@ static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column, | |||
701 | case NAND_CMD_DEPLETE1: | 701 | case NAND_CMD_DEPLETE1: |
702 | return; | 702 | return; |
703 | 703 | ||
704 | /* | 704 | /* |
705 | * read error status commands require only a short delay | 705 | * read error status commands require only a short delay |
706 | */ | 706 | */ |
707 | case NAND_CMD_STATUS_ERROR: | 707 | case NAND_CMD_STATUS_ERROR: |
@@ -713,7 +713,7 @@ static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column, | |||
713 | return; | 713 | return; |
714 | 714 | ||
715 | case NAND_CMD_RESET: | 715 | case NAND_CMD_RESET: |
716 | if (this->dev_ready) | 716 | if (this->dev_ready) |
717 | break; | 717 | break; |
718 | udelay(this->chip_delay); | 718 | udelay(this->chip_delay); |
719 | this->hwcontrol(mtd, NAND_CTL_SETCLE); | 719 | this->hwcontrol(mtd, NAND_CTL_SETCLE); |
@@ -730,17 +730,17 @@ static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column, | |||
730 | /* End command latch cycle */ | 730 | /* End command latch cycle */ |
731 | this->hwcontrol(mtd, NAND_CTL_CLRCLE); | 731 | this->hwcontrol(mtd, NAND_CTL_CLRCLE); |
732 | /* Fall through into ready check */ | 732 | /* Fall through into ready check */ |
733 | 733 | ||
734 | /* This applies to read commands */ | 734 | /* This applies to read commands */ |
735 | default: | 735 | default: |
736 | /* | 736 | /* |
737 | * If we don't have access to the busy pin, we apply the given | 737 | * If we don't have access to the busy pin, we apply the given |
738 | * command delay | 738 | * command delay |
739 | */ | 739 | */ |
740 | if (!this->dev_ready) { | 740 | if (!this->dev_ready) { |
741 | udelay (this->chip_delay); | 741 | udelay (this->chip_delay); |
742 | return; | 742 | return; |
743 | } | 743 | } |
744 | } | 744 | } |
745 | 745 | ||
746 | /* Apply this short delay always to ensure that we do wait tWB in | 746 | /* Apply this short delay always to ensure that we do wait tWB in |
@@ -754,7 +754,7 @@ static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column, | |||
754 | * nand_get_device - [GENERIC] Get chip for selected access | 754 | * nand_get_device - [GENERIC] Get chip for selected access |
755 | * @this: the nand chip descriptor | 755 | * @this: the nand chip descriptor |
756 | * @mtd: MTD device structure | 756 | * @mtd: MTD device structure |
757 | * @new_state: the state which is requested | 757 | * @new_state: the state which is requested |
758 | * | 758 | * |
759 | * Get the device and lock it for exclusive access | 759 | * Get the device and lock it for exclusive access |
760 | */ | 760 | */ |
@@ -802,7 +802,7 @@ retry: | |||
802 | * @state: state to select the max. timeout value | 802 | * @state: state to select the max. timeout value |
803 | * | 803 | * |
804 | * Wait for command done. This applies to erase and program only | 804 | * Wait for command done. This applies to erase and program only |
805 | * Erase can take up to 400ms and program up to 20ms according to | 805 | * Erase can take up to 400ms and program up to 20ms according to |
806 | * general NAND and SmartMedia specs | 806 | * general NAND and SmartMedia specs |
807 | * | 807 | * |
808 | */ | 808 | */ |
@@ -811,7 +811,7 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *this, int state) | |||
811 | 811 | ||
812 | unsigned long timeo = jiffies; | 812 | unsigned long timeo = jiffies; |
813 | int status; | 813 | int status; |
814 | 814 | ||
815 | if (state == FL_ERASING) | 815 | if (state == FL_ERASING) |
816 | timeo += (HZ * 400) / 1000; | 816 | timeo += (HZ * 400) / 1000; |
817 | else | 817 | else |
@@ -823,17 +823,17 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *this, int state) | |||
823 | 823 | ||
824 | if ((state == FL_ERASING) && (this->options & NAND_IS_AND)) | 824 | if ((state == FL_ERASING) && (this->options & NAND_IS_AND)) |
825 | this->cmdfunc (mtd, NAND_CMD_STATUS_MULTI, -1, -1); | 825 | this->cmdfunc (mtd, NAND_CMD_STATUS_MULTI, -1, -1); |
826 | else | 826 | else |
827 | this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1); | 827 | this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1); |
828 | 828 | ||
829 | while (time_before(jiffies, timeo)) { | 829 | while (time_before(jiffies, timeo)) { |
830 | /* Check, if we were interrupted */ | 830 | /* Check, if we were interrupted */ |
831 | if (this->state != state) | 831 | if (this->state != state) |
832 | return 0; | 832 | return 0; |
833 | 833 | ||
834 | if (this->dev_ready) { | 834 | if (this->dev_ready) { |
835 | if (this->dev_ready(mtd)) | 835 | if (this->dev_ready(mtd)) |
836 | break; | 836 | break; |
837 | } else { | 837 | } else { |
838 | if (this->read_byte(mtd) & NAND_STATUS_READY) | 838 | if (this->read_byte(mtd) & NAND_STATUS_READY) |
839 | break; | 839 | break; |
@@ -859,7 +859,7 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *this, int state) | |||
859 | * | 859 | * |
860 | * Cached programming is not supported yet. | 860 | * Cached programming is not supported yet. |
861 | */ | 861 | */ |
862 | static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int page, | 862 | static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int page, |
863 | u_char *oob_buf, struct nand_oobinfo *oobsel, int cached) | 863 | u_char *oob_buf, struct nand_oobinfo *oobsel, int cached) |
864 | { | 864 | { |
865 | int i, status; | 865 | int i, status; |
@@ -868,10 +868,10 @@ static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int pa | |||
868 | int *oob_config = oobsel->eccpos; | 868 | int *oob_config = oobsel->eccpos; |
869 | int datidx = 0, eccidx = 0, eccsteps = this->eccsteps; | 869 | int datidx = 0, eccidx = 0, eccsteps = this->eccsteps; |
870 | int eccbytes = 0; | 870 | int eccbytes = 0; |
871 | 871 | ||
872 | /* FIXME: Enable cached programming */ | 872 | /* FIXME: Enable cached programming */ |
873 | cached = 0; | 873 | cached = 0; |
874 | 874 | ||
875 | /* Send command to begin auto page programming */ | 875 | /* Send command to begin auto page programming */ |
876 | this->cmdfunc (mtd, NAND_CMD_SEQIN, 0x00, page); | 876 | this->cmdfunc (mtd, NAND_CMD_SEQIN, 0x00, page); |
877 | 877 | ||
@@ -882,7 +882,7 @@ static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int pa | |||
882 | printk (KERN_WARNING "Writing data without ECC to NAND-FLASH is not recommended\n"); | 882 | printk (KERN_WARNING "Writing data without ECC to NAND-FLASH is not recommended\n"); |
883 | this->write_buf(mtd, this->data_poi, mtd->oobblock); | 883 | this->write_buf(mtd, this->data_poi, mtd->oobblock); |
884 | break; | 884 | break; |
885 | 885 | ||
886 | /* Software ecc 3/256, write all */ | 886 | /* Software ecc 3/256, write all */ |
887 | case NAND_ECC_SOFT: | 887 | case NAND_ECC_SOFT: |
888 | for (; eccsteps; eccsteps--) { | 888 | for (; eccsteps; eccsteps--) { |
@@ -911,11 +911,11 @@ static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int pa | |||
911 | } | 911 | } |
912 | break; | 912 | break; |
913 | } | 913 | } |
914 | 914 | ||
915 | /* Write out OOB data */ | 915 | /* Write out OOB data */ |
916 | if (this->options & NAND_HWECC_SYNDROME) | 916 | if (this->options & NAND_HWECC_SYNDROME) |
917 | this->write_buf(mtd, &oob_buf[oobsel->eccbytes], mtd->oobsize - oobsel->eccbytes); | 917 | this->write_buf(mtd, &oob_buf[oobsel->eccbytes], mtd->oobsize - oobsel->eccbytes); |
918 | else | 918 | else |
919 | this->write_buf(mtd, oob_buf, mtd->oobsize); | 919 | this->write_buf(mtd, oob_buf, mtd->oobsize); |
920 | 920 | ||
921 | /* Send command to actually program the data */ | 921 | /* Send command to actually program the data */ |
@@ -940,7 +940,7 @@ static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int pa | |||
940 | /* wait until cache is ready*/ | 940 | /* wait until cache is ready*/ |
941 | // status = this->waitfunc (mtd, this, FL_CACHEDRPG); | 941 | // status = this->waitfunc (mtd, this, FL_CACHEDRPG); |
942 | } | 942 | } |
943 | return 0; | 943 | return 0; |
944 | } | 944 | } |
945 | 945 | ||
946 | #ifdef CONFIG_MTD_NAND_VERIFY_WRITE | 946 | #ifdef CONFIG_MTD_NAND_VERIFY_WRITE |
@@ -956,19 +956,19 @@ static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int pa | |||
956 | * @oobmode: 1 = full buffer verify, 0 = ecc only | 956 | * @oobmode: 1 = full buffer verify, 0 = ecc only |
957 | * | 957 | * |
958 | * The NAND device assumes that it is always writing to a cleanly erased page. | 958 | * The NAND device assumes that it is always writing to a cleanly erased page. |
959 | * Hence, it performs its internal write verification only on bits that | 959 | * Hence, it performs its internal write verification only on bits that |
960 | * transitioned from 1 to 0. The device does NOT verify the whole page on a | 960 | * transitioned from 1 to 0. The device does NOT verify the whole page on a |
961 | * byte by byte basis. It is possible that the page was not completely erased | 961 | * byte by byte basis. It is possible that the page was not completely erased |
962 | * or the page is becoming unusable due to wear. The read with ECC would catch | 962 | * or the page is becoming unusable due to wear. The read with ECC would catch |
963 | * the error later when the ECC page check fails, but we would rather catch | 963 | * the error later when the ECC page check fails, but we would rather catch |
964 | * it early in the page write stage. Better to write no data than invalid data. | 964 | * it early in the page write stage. Better to write no data than invalid data. |
965 | */ | 965 | */ |
966 | static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int page, int numpages, | 966 | static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int page, int numpages, |
967 | u_char *oob_buf, struct nand_oobinfo *oobsel, int chipnr, int oobmode) | 967 | u_char *oob_buf, struct nand_oobinfo *oobsel, int chipnr, int oobmode) |
968 | { | 968 | { |
969 | int i, j, datidx = 0, oobofs = 0, res = -EIO; | 969 | int i, j, datidx = 0, oobofs = 0, res = -EIO; |
970 | int eccsteps = this->eccsteps; | 970 | int eccsteps = this->eccsteps; |
971 | int hweccbytes; | 971 | int hweccbytes; |
972 | u_char oobdata[64]; | 972 | u_char oobdata[64]; |
973 | 973 | ||
974 | hweccbytes = (this->options & NAND_HWECC_SYNDROME) ? (oobsel->eccbytes / eccsteps) : 0; | 974 | hweccbytes = (this->options & NAND_HWECC_SYNDROME) ? (oobsel->eccbytes / eccsteps) : 0; |
@@ -1008,7 +1008,7 @@ static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int | |||
1008 | 1008 | ||
1009 | if (oobsel->useecc != MTD_NANDECC_OFF && !hweccbytes) { | 1009 | if (oobsel->useecc != MTD_NANDECC_OFF && !hweccbytes) { |
1010 | int ecccnt = oobsel->eccbytes; | 1010 | int ecccnt = oobsel->eccbytes; |
1011 | 1011 | ||
1012 | for (i = 0; i < ecccnt; i++) { | 1012 | for (i = 0; i < ecccnt; i++) { |
1013 | int idx = oobsel->eccpos[i]; | 1013 | int idx = oobsel->eccpos[i]; |
1014 | if (oobdata[idx] != oob_buf[oobofs + idx] ) { | 1014 | if (oobdata[idx] != oob_buf[oobofs + idx] ) { |
@@ -1018,20 +1018,20 @@ static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int | |||
1018 | goto out; | 1018 | goto out; |
1019 | } | 1019 | } |
1020 | } | 1020 | } |
1021 | } | 1021 | } |
1022 | } | 1022 | } |
1023 | oobofs += mtd->oobsize - hweccbytes * eccsteps; | 1023 | oobofs += mtd->oobsize - hweccbytes * eccsteps; |
1024 | page++; | 1024 | page++; |
1025 | numpages--; | 1025 | numpages--; |
1026 | 1026 | ||
1027 | /* Apply delay or wait for ready/busy pin | 1027 | /* Apply delay or wait for ready/busy pin |
1028 | * Do this before the AUTOINCR check, so no problems | 1028 | * Do this before the AUTOINCR check, so no problems |
1029 | * arise if a chip which does auto increment | 1029 | * arise if a chip which does auto increment |
1030 | * is marked as NOAUTOINCR by the board driver. | 1030 | * is marked as NOAUTOINCR by the board driver. |
1031 | * Do this also before returning, so the chip is | 1031 | * Do this also before returning, so the chip is |
1032 | * ready for the next command. | 1032 | * ready for the next command. |
1033 | */ | 1033 | */ |
1034 | if (!this->dev_ready) | 1034 | if (!this->dev_ready) |
1035 | udelay (this->chip_delay); | 1035 | udelay (this->chip_delay); |
1036 | else | 1036 | else |
1037 | nand_wait_ready(mtd); | 1037 | nand_wait_ready(mtd); |
@@ -1039,17 +1039,17 @@ static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int | |||
1039 | /* All done, return happy */ | 1039 | /* All done, return happy */ |
1040 | if (!numpages) | 1040 | if (!numpages) |
1041 | return 0; | 1041 | return 0; |
1042 | 1042 | ||
1043 | 1043 | ||
1044 | /* Check, if the chip supports auto page increment */ | 1044 | /* Check, if the chip supports auto page increment */ |
1045 | if (!NAND_CANAUTOINCR(this)) | 1045 | if (!NAND_CANAUTOINCR(this)) |
1046 | this->cmdfunc (mtd, NAND_CMD_READ0, 0x00, page); | 1046 | this->cmdfunc (mtd, NAND_CMD_READ0, 0x00, page); |
1047 | } | 1047 | } |
1048 | /* | 1048 | /* |
1049 | * Terminate the read command. We come here in case of an error | 1049 | * Terminate the read command. We come here in case of an error |
1050 | * So we must issue a reset command. | 1050 | * So we must issue a reset command. |
1051 | */ | 1051 | */ |
1052 | out: | 1052 | out: |
1053 | this->cmdfunc (mtd, NAND_CMD_RESET, -1, -1); | 1053 | this->cmdfunc (mtd, NAND_CMD_RESET, -1, -1); |
1054 | return res; | 1054 | return res; |
1055 | } | 1055 | } |
@@ -1111,7 +1111,7 @@ static int nand_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1111 | * NAND read with ECC | 1111 | * NAND read with ECC |
1112 | */ | 1112 | */ |
1113 | int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | 1113 | int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, |
1114 | size_t * retlen, u_char * buf, u_char * oob_buf, | 1114 | size_t * retlen, u_char * buf, u_char * oob_buf, |
1115 | struct nand_oobinfo *oobsel, int flags) | 1115 | struct nand_oobinfo *oobsel, int flags) |
1116 | { | 1116 | { |
1117 | 1117 | ||
@@ -1145,7 +1145,7 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1145 | /* Autoplace of oob data ? Use the default placement scheme */ | 1145 | /* Autoplace of oob data ? Use the default placement scheme */ |
1146 | if (oobsel->useecc == MTD_NANDECC_AUTOPLACE) | 1146 | if (oobsel->useecc == MTD_NANDECC_AUTOPLACE) |
1147 | oobsel = this->autooob; | 1147 | oobsel = this->autooob; |
1148 | 1148 | ||
1149 | eccmode = oobsel->useecc ? this->eccmode : NAND_ECC_NONE; | 1149 | eccmode = oobsel->useecc ? this->eccmode : NAND_ECC_NONE; |
1150 | oob_config = oobsel->eccpos; | 1150 | oob_config = oobsel->eccpos; |
1151 | 1151 | ||
@@ -1163,28 +1163,28 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1163 | end = mtd->oobblock; | 1163 | end = mtd->oobblock; |
1164 | ecc = this->eccsize; | 1164 | ecc = this->eccsize; |
1165 | eccbytes = this->eccbytes; | 1165 | eccbytes = this->eccbytes; |
1166 | 1166 | ||
1167 | if ((eccmode == NAND_ECC_NONE) || (this->options & NAND_HWECC_SYNDROME)) | 1167 | if ((eccmode == NAND_ECC_NONE) || (this->options & NAND_HWECC_SYNDROME)) |
1168 | compareecc = 0; | 1168 | compareecc = 0; |
1169 | 1169 | ||
1170 | oobreadlen = mtd->oobsize; | 1170 | oobreadlen = mtd->oobsize; |
1171 | if (this->options & NAND_HWECC_SYNDROME) | 1171 | if (this->options & NAND_HWECC_SYNDROME) |
1172 | oobreadlen -= oobsel->eccbytes; | 1172 | oobreadlen -= oobsel->eccbytes; |
1173 | 1173 | ||
1174 | /* Loop until all data read */ | 1174 | /* Loop until all data read */ |
1175 | while (read < len) { | 1175 | while (read < len) { |
1176 | 1176 | ||
1177 | int aligned = (!col && (len - read) >= end); | 1177 | int aligned = (!col && (len - read) >= end); |
1178 | /* | 1178 | /* |
1179 | * If the read is not page aligned, we have to read into data buffer | 1179 | * If the read is not page aligned, we have to read into data buffer |
1180 | * due to ecc, else we read into return buffer direct | 1180 | * due to ecc, else we read into return buffer direct |
1181 | */ | 1181 | */ |
1182 | if (aligned) | 1182 | if (aligned) |
1183 | data_poi = &buf[read]; | 1183 | data_poi = &buf[read]; |
1184 | else | 1184 | else |
1185 | data_poi = this->data_buf; | 1185 | data_poi = this->data_buf; |
1186 | 1186 | ||
1187 | /* Check, if we have this page in the buffer | 1187 | /* Check, if we have this page in the buffer |
1188 | * | 1188 | * |
1189 | * FIXME: Make it work when we must provide oob data too, | 1189 | * FIXME: Make it work when we must provide oob data too, |
1190 | * check the usage of data_buf oob field | 1190 | * check the usage of data_buf oob field |
@@ -1200,7 +1200,7 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1200 | if (sndcmd) { | 1200 | if (sndcmd) { |
1201 | this->cmdfunc (mtd, NAND_CMD_READ0, 0x00, page); | 1201 | this->cmdfunc (mtd, NAND_CMD_READ0, 0x00, page); |
1202 | sndcmd = 0; | 1202 | sndcmd = 0; |
1203 | } | 1203 | } |
1204 | 1204 | ||
1205 | /* get oob area, if we have no oob buffer from fs-driver */ | 1205 | /* get oob area, if we have no oob buffer from fs-driver */ |
1206 | if (!oob_buf || oobsel->useecc == MTD_NANDECC_AUTOPLACE || | 1206 | if (!oob_buf || oobsel->useecc == MTD_NANDECC_AUTOPLACE || |
@@ -1208,7 +1208,7 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1208 | oob_data = &this->data_buf[end]; | 1208 | oob_data = &this->data_buf[end]; |
1209 | 1209 | ||
1210 | eccsteps = this->eccsteps; | 1210 | eccsteps = this->eccsteps; |
1211 | 1211 | ||
1212 | switch (eccmode) { | 1212 | switch (eccmode) { |
1213 | case NAND_ECC_NONE: { /* No ECC, Read in a page */ | 1213 | case NAND_ECC_NONE: { /* No ECC, Read in a page */ |
1214 | static unsigned long lastwhinge = 0; | 1214 | static unsigned long lastwhinge = 0; |
@@ -1219,12 +1219,12 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1219 | this->read_buf(mtd, data_poi, end); | 1219 | this->read_buf(mtd, data_poi, end); |
1220 | break; | 1220 | break; |
1221 | } | 1221 | } |
1222 | 1222 | ||
1223 | case NAND_ECC_SOFT: /* Software ECC 3/256: Read in a page + oob data */ | 1223 | case NAND_ECC_SOFT: /* Software ECC 3/256: Read in a page + oob data */ |
1224 | this->read_buf(mtd, data_poi, end); | 1224 | this->read_buf(mtd, data_poi, end); |
1225 | for (i = 0, datidx = 0; eccsteps; eccsteps--, i+=3, datidx += ecc) | 1225 | for (i = 0, datidx = 0; eccsteps; eccsteps--, i+=3, datidx += ecc) |
1226 | this->calculate_ecc(mtd, &data_poi[datidx], &ecc_calc[i]); | 1226 | this->calculate_ecc(mtd, &data_poi[datidx], &ecc_calc[i]); |
1227 | break; | 1227 | break; |
1228 | 1228 | ||
1229 | default: | 1229 | default: |
1230 | for (i = 0, datidx = 0; eccsteps; eccsteps--, i+=eccbytes, datidx += ecc) { | 1230 | for (i = 0, datidx = 0; eccsteps; eccsteps--, i+=eccbytes, datidx += ecc) { |
@@ -1243,15 +1243,15 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1243 | * does the error correction on the fly */ | 1243 | * does the error correction on the fly */ |
1244 | ecc_status = this->correct_data(mtd, &data_poi[datidx], &oob_data[i], &ecc_code[i]); | 1244 | ecc_status = this->correct_data(mtd, &data_poi[datidx], &oob_data[i], &ecc_code[i]); |
1245 | if ((ecc_status == -1) || (ecc_status > (flags && 0xff))) { | 1245 | if ((ecc_status == -1) || (ecc_status > (flags && 0xff))) { |
1246 | DEBUG (MTD_DEBUG_LEVEL0, "nand_read_ecc: " | 1246 | DEBUG (MTD_DEBUG_LEVEL0, "nand_read_ecc: " |
1247 | "Failed ECC read, page 0x%08x on chip %d\n", page, chipnr); | 1247 | "Failed ECC read, page 0x%08x on chip %d\n", page, chipnr); |
1248 | ecc_failed++; | 1248 | ecc_failed++; |
1249 | } | 1249 | } |
1250 | } else { | 1250 | } else { |
1251 | this->calculate_ecc(mtd, &data_poi[datidx], &ecc_calc[i]); | 1251 | this->calculate_ecc(mtd, &data_poi[datidx], &ecc_calc[i]); |
1252 | } | 1252 | } |
1253 | } | 1253 | } |
1254 | break; | 1254 | break; |
1255 | } | 1255 | } |
1256 | 1256 | ||
1257 | /* read oobdata */ | 1257 | /* read oobdata */ |
@@ -1259,8 +1259,8 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1259 | 1259 | ||
1260 | /* Skip ECC check, if not requested (ECC_NONE or HW_ECC with syndromes) */ | 1260 | /* Skip ECC check, if not requested (ECC_NONE or HW_ECC with syndromes) */ |
1261 | if (!compareecc) | 1261 | if (!compareecc) |
1262 | goto readoob; | 1262 | goto readoob; |
1263 | 1263 | ||
1264 | /* Pick the ECC bytes out of the oob data */ | 1264 | /* Pick the ECC bytes out of the oob data */ |
1265 | for (j = 0; j < oobsel->eccbytes; j++) | 1265 | for (j = 0; j < oobsel->eccbytes; j++) |
1266 | ecc_code[j] = oob_data[oob_config[j]]; | 1266 | ecc_code[j] = oob_data[oob_config[j]]; |
@@ -1268,24 +1268,24 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1268 | /* correct data, if neccecary */ | 1268 | /* correct data, if neccecary */ |
1269 | for (i = 0, j = 0, datidx = 0; i < this->eccsteps; i++, datidx += ecc) { | 1269 | for (i = 0, j = 0, datidx = 0; i < this->eccsteps; i++, datidx += ecc) { |
1270 | ecc_status = this->correct_data(mtd, &data_poi[datidx], &ecc_code[j], &ecc_calc[j]); | 1270 | ecc_status = this->correct_data(mtd, &data_poi[datidx], &ecc_code[j], &ecc_calc[j]); |
1271 | 1271 | ||
1272 | /* Get next chunk of ecc bytes */ | 1272 | /* Get next chunk of ecc bytes */ |
1273 | j += eccbytes; | 1273 | j += eccbytes; |
1274 | 1274 | ||
1275 | /* Check, if we have a fs supplied oob-buffer, | 1275 | /* Check, if we have a fs supplied oob-buffer, |
1276 | * This is the legacy mode. Used by YAFFS1 | 1276 | * This is the legacy mode. Used by YAFFS1 |
1277 | * Should go away some day | 1277 | * Should go away some day |
1278 | */ | 1278 | */ |
1279 | if (oob_buf && oobsel->useecc == MTD_NANDECC_PLACE) { | 1279 | if (oob_buf && oobsel->useecc == MTD_NANDECC_PLACE) { |
1280 | int *p = (int *)(&oob_data[mtd->oobsize]); | 1280 | int *p = (int *)(&oob_data[mtd->oobsize]); |
1281 | p[i] = ecc_status; | 1281 | p[i] = ecc_status; |
1282 | } | 1282 | } |
1283 | 1283 | ||
1284 | if ((ecc_status == -1) || (ecc_status > (flags && 0xff))) { | 1284 | if ((ecc_status == -1) || (ecc_status > (flags && 0xff))) { |
1285 | DEBUG (MTD_DEBUG_LEVEL0, "nand_read_ecc: " "Failed ECC read, page 0x%08x\n", page); | 1285 | DEBUG (MTD_DEBUG_LEVEL0, "nand_read_ecc: " "Failed ECC read, page 0x%08x\n", page); |
1286 | ecc_failed++; | 1286 | ecc_failed++; |
1287 | } | 1287 | } |
1288 | } | 1288 | } |
1289 | 1289 | ||
1290 | readoob: | 1290 | readoob: |
1291 | /* check, if we have a fs supplied oob-buffer */ | 1291 | /* check, if we have a fs supplied oob-buffer */ |
@@ -1311,25 +1311,25 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1311 | } | 1311 | } |
1312 | readdata: | 1312 | readdata: |
1313 | /* Partial page read, transfer data into fs buffer */ | 1313 | /* Partial page read, transfer data into fs buffer */ |
1314 | if (!aligned) { | 1314 | if (!aligned) { |
1315 | for (j = col; j < end && read < len; j++) | 1315 | for (j = col; j < end && read < len; j++) |
1316 | buf[read++] = data_poi[j]; | 1316 | buf[read++] = data_poi[j]; |
1317 | this->pagebuf = realpage; | 1317 | this->pagebuf = realpage; |
1318 | } else | 1318 | } else |
1319 | read += mtd->oobblock; | 1319 | read += mtd->oobblock; |
1320 | 1320 | ||
1321 | /* Apply delay or wait for ready/busy pin | 1321 | /* Apply delay or wait for ready/busy pin |
1322 | * Do this before the AUTOINCR check, so no problems | 1322 | * Do this before the AUTOINCR check, so no problems |
1323 | * arise if a chip which does auto increment | 1323 | * arise if a chip which does auto increment |
1324 | * is marked as NOAUTOINCR by the board driver. | 1324 | * is marked as NOAUTOINCR by the board driver. |
1325 | */ | 1325 | */ |
1326 | if (!this->dev_ready) | 1326 | if (!this->dev_ready) |
1327 | udelay (this->chip_delay); | 1327 | udelay (this->chip_delay); |
1328 | else | 1328 | else |
1329 | nand_wait_ready(mtd); | 1329 | nand_wait_ready(mtd); |
1330 | 1330 | ||
1331 | if (read == len) | 1331 | if (read == len) |
1332 | break; | 1332 | break; |
1333 | 1333 | ||
1334 | /* For subsequent reads align to page boundary. */ | 1334 | /* For subsequent reads align to page boundary. */ |
1335 | col = 0; | 1335 | col = 0; |
@@ -1343,11 +1343,11 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1343 | this->select_chip(mtd, -1); | 1343 | this->select_chip(mtd, -1); |
1344 | this->select_chip(mtd, chipnr); | 1344 | this->select_chip(mtd, chipnr); |
1345 | } | 1345 | } |
1346 | /* Check, if the chip supports auto page increment | 1346 | /* Check, if the chip supports auto page increment |
1347 | * or if we have hit a block boundary. | 1347 | * or if we have hit a block boundary. |
1348 | */ | 1348 | */ |
1349 | if (!NAND_CANAUTOINCR(this) || !(page & blockcheck)) | 1349 | if (!NAND_CANAUTOINCR(this) || !(page & blockcheck)) |
1350 | sndcmd = 1; | 1350 | sndcmd = 1; |
1351 | } | 1351 | } |
1352 | 1352 | ||
1353 | /* Deselect and wake up anyone waiting on the device */ | 1353 | /* Deselect and wake up anyone waiting on the device */ |
@@ -1384,7 +1384,7 @@ static int nand_read_oob (struct mtd_info *mtd, loff_t from, size_t len, size_t | |||
1384 | /* Shift to get page */ | 1384 | /* Shift to get page */ |
1385 | page = (int)(from >> this->page_shift); | 1385 | page = (int)(from >> this->page_shift); |
1386 | chipnr = (int)(from >> this->chip_shift); | 1386 | chipnr = (int)(from >> this->chip_shift); |
1387 | 1387 | ||
1388 | /* Mask to get column */ | 1388 | /* Mask to get column */ |
1389 | col = from & (mtd->oobsize - 1); | 1389 | col = from & (mtd->oobsize - 1); |
1390 | 1390 | ||
@@ -1406,7 +1406,7 @@ static int nand_read_oob (struct mtd_info *mtd, loff_t from, size_t len, size_t | |||
1406 | 1406 | ||
1407 | /* Send the read command */ | 1407 | /* Send the read command */ |
1408 | this->cmdfunc (mtd, NAND_CMD_READOOB, col, page & this->pagemask); | 1408 | this->cmdfunc (mtd, NAND_CMD_READOOB, col, page & this->pagemask); |
1409 | /* | 1409 | /* |
1410 | * Read the data, if we read more than one page | 1410 | * Read the data, if we read more than one page |
1411 | * oob data, let the device transfer the data ! | 1411 | * oob data, let the device transfer the data ! |
1412 | */ | 1412 | */ |
@@ -1428,20 +1428,20 @@ static int nand_read_oob (struct mtd_info *mtd, loff_t from, size_t len, size_t | |||
1428 | this->select_chip(mtd, -1); | 1428 | this->select_chip(mtd, -1); |
1429 | this->select_chip(mtd, chipnr); | 1429 | this->select_chip(mtd, chipnr); |
1430 | } | 1430 | } |
1431 | 1431 | ||
1432 | /* Apply delay or wait for ready/busy pin | 1432 | /* Apply delay or wait for ready/busy pin |
1433 | * Do this before the AUTOINCR check, so no problems | 1433 | * Do this before the AUTOINCR check, so no problems |
1434 | * arise if a chip which does auto increment | 1434 | * arise if a chip which does auto increment |
1435 | * is marked as NOAUTOINCR by the board driver. | 1435 | * is marked as NOAUTOINCR by the board driver. |
1436 | */ | 1436 | */ |
1437 | if (!this->dev_ready) | 1437 | if (!this->dev_ready) |
1438 | udelay (this->chip_delay); | 1438 | udelay (this->chip_delay); |
1439 | else | 1439 | else |
1440 | nand_wait_ready(mtd); | 1440 | nand_wait_ready(mtd); |
1441 | 1441 | ||
1442 | /* Check, if the chip supports auto page increment | 1442 | /* Check, if the chip supports auto page increment |
1443 | * or if we have hit a block boundary. | 1443 | * or if we have hit a block boundary. |
1444 | */ | 1444 | */ |
1445 | if (!NAND_CANAUTOINCR(this) || !(page & blockcheck)) { | 1445 | if (!NAND_CANAUTOINCR(this) || !(page & blockcheck)) { |
1446 | /* For subsequent page reads set offset to 0 */ | 1446 | /* For subsequent page reads set offset to 0 */ |
1447 | this->cmdfunc (mtd, NAND_CMD_READOOB, 0x0, page & this->pagemask); | 1447 | this->cmdfunc (mtd, NAND_CMD_READOOB, 0x0, page & this->pagemask); |
@@ -1487,27 +1487,27 @@ int nand_read_raw (struct mtd_info *mtd, uint8_t *buf, loff_t from, size_t len, | |||
1487 | nand_get_device (this, mtd , FL_READING); | 1487 | nand_get_device (this, mtd , FL_READING); |
1488 | 1488 | ||
1489 | this->select_chip (mtd, chip); | 1489 | this->select_chip (mtd, chip); |
1490 | 1490 | ||
1491 | /* Add requested oob length */ | 1491 | /* Add requested oob length */ |
1492 | len += ooblen; | 1492 | len += ooblen; |
1493 | 1493 | ||
1494 | while (len) { | 1494 | while (len) { |
1495 | if (sndcmd) | 1495 | if (sndcmd) |
1496 | this->cmdfunc (mtd, NAND_CMD_READ0, 0, page & this->pagemask); | 1496 | this->cmdfunc (mtd, NAND_CMD_READ0, 0, page & this->pagemask); |
1497 | sndcmd = 0; | 1497 | sndcmd = 0; |
1498 | 1498 | ||
1499 | this->read_buf (mtd, &buf[cnt], pagesize); | 1499 | this->read_buf (mtd, &buf[cnt], pagesize); |
1500 | 1500 | ||
1501 | len -= pagesize; | 1501 | len -= pagesize; |
1502 | cnt += pagesize; | 1502 | cnt += pagesize; |
1503 | page++; | 1503 | page++; |
1504 | 1504 | ||
1505 | if (!this->dev_ready) | 1505 | if (!this->dev_ready) |
1506 | udelay (this->chip_delay); | 1506 | udelay (this->chip_delay); |
1507 | else | 1507 | else |
1508 | nand_wait_ready(mtd); | 1508 | nand_wait_ready(mtd); |
1509 | 1509 | ||
1510 | /* Check, if the chip supports auto page increment */ | 1510 | /* Check, if the chip supports auto page increment */ |
1511 | if (!NAND_CANAUTOINCR(this) || !(page & blockcheck)) | 1511 | if (!NAND_CANAUTOINCR(this) || !(page & blockcheck)) |
1512 | sndcmd = 1; | 1512 | sndcmd = 1; |
1513 | } | 1513 | } |
@@ -1518,8 +1518,8 @@ int nand_read_raw (struct mtd_info *mtd, uint8_t *buf, loff_t from, size_t len, | |||
1518 | } | 1518 | } |
1519 | 1519 | ||
1520 | 1520 | ||
1521 | /** | 1521 | /** |
1522 | * nand_prepare_oobbuf - [GENERIC] Prepare the out of band buffer | 1522 | * nand_prepare_oobbuf - [GENERIC] Prepare the out of band buffer |
1523 | * @mtd: MTD device structure | 1523 | * @mtd: MTD device structure |
1524 | * @fsbuf: buffer given by fs driver | 1524 | * @fsbuf: buffer given by fs driver |
1525 | * @oobsel: out of band selection structre | 1525 | * @oobsel: out of band selection structre |
@@ -1548,20 +1548,20 @@ static u_char * nand_prepare_oobbuf (struct mtd_info *mtd, u_char *fsbuf, struct | |||
1548 | int i, len, ofs; | 1548 | int i, len, ofs; |
1549 | 1549 | ||
1550 | /* Zero copy fs supplied buffer */ | 1550 | /* Zero copy fs supplied buffer */ |
1551 | if (fsbuf && !autoplace) | 1551 | if (fsbuf && !autoplace) |
1552 | return fsbuf; | 1552 | return fsbuf; |
1553 | 1553 | ||
1554 | /* Check, if the buffer must be filled with ff again */ | 1554 | /* Check, if the buffer must be filled with ff again */ |
1555 | if (this->oobdirty) { | 1555 | if (this->oobdirty) { |
1556 | memset (this->oob_buf, 0xff, | 1556 | memset (this->oob_buf, 0xff, |
1557 | mtd->oobsize << (this->phys_erase_shift - this->page_shift)); | 1557 | mtd->oobsize << (this->phys_erase_shift - this->page_shift)); |
1558 | this->oobdirty = 0; | 1558 | this->oobdirty = 0; |
1559 | } | 1559 | } |
1560 | 1560 | ||
1561 | /* If we have no autoplacement or no fs buffer use the internal one */ | 1561 | /* If we have no autoplacement or no fs buffer use the internal one */ |
1562 | if (!autoplace || !fsbuf) | 1562 | if (!autoplace || !fsbuf) |
1563 | return this->oob_buf; | 1563 | return this->oob_buf; |
1564 | 1564 | ||
1565 | /* Walk through the pages and place the data */ | 1565 | /* Walk through the pages and place the data */ |
1566 | this->oobdirty = 1; | 1566 | this->oobdirty = 1; |
1567 | ofs = 0; | 1567 | ofs = 0; |
@@ -1595,7 +1595,7 @@ static int nand_write (struct mtd_info *mtd, loff_t to, size_t len, size_t * ret | |||
1595 | { | 1595 | { |
1596 | return (nand_write_ecc (mtd, to, len, retlen, buf, NULL, NULL)); | 1596 | return (nand_write_ecc (mtd, to, len, retlen, buf, NULL, NULL)); |
1597 | } | 1597 | } |
1598 | 1598 | ||
1599 | /** | 1599 | /** |
1600 | * nand_write_ecc - [MTD Interface] NAND write with ECC | 1600 | * nand_write_ecc - [MTD Interface] NAND write with ECC |
1601 | * @mtd: MTD device structure | 1601 | * @mtd: MTD device structure |
@@ -1628,7 +1628,7 @@ static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len, | |||
1628 | return -EINVAL; | 1628 | return -EINVAL; |
1629 | } | 1629 | } |
1630 | 1630 | ||
1631 | /* reject writes, which are not page aligned */ | 1631 | /* reject writes, which are not page aligned */ |
1632 | if (NOTALIGNED (to) || NOTALIGNED(len)) { | 1632 | if (NOTALIGNED (to) || NOTALIGNED(len)) { |
1633 | printk (KERN_NOTICE "nand_write_ecc: Attempt to write not page aligned data\n"); | 1633 | printk (KERN_NOTICE "nand_write_ecc: Attempt to write not page aligned data\n"); |
1634 | return -EINVAL; | 1634 | return -EINVAL; |
@@ -1647,14 +1647,14 @@ static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len, | |||
1647 | goto out; | 1647 | goto out; |
1648 | 1648 | ||
1649 | /* if oobsel is NULL, use chip defaults */ | 1649 | /* if oobsel is NULL, use chip defaults */ |
1650 | if (oobsel == NULL) | 1650 | if (oobsel == NULL) |
1651 | oobsel = &mtd->oobinfo; | 1651 | oobsel = &mtd->oobinfo; |
1652 | 1652 | ||
1653 | /* Autoplace of oob data ? Use the default placement scheme */ | 1653 | /* Autoplace of oob data ? Use the default placement scheme */ |
1654 | if (oobsel->useecc == MTD_NANDECC_AUTOPLACE) { | 1654 | if (oobsel->useecc == MTD_NANDECC_AUTOPLACE) { |
1655 | oobsel = this->autooob; | 1655 | oobsel = this->autooob; |
1656 | autoplace = 1; | 1656 | autoplace = 1; |
1657 | } | 1657 | } |
1658 | if (oobsel->useecc == MTD_NANDECC_AUTOPL_USR) | 1658 | if (oobsel->useecc == MTD_NANDECC_AUTOPL_USR) |
1659 | autoplace = 1; | 1659 | autoplace = 1; |
1660 | 1660 | ||
@@ -1662,9 +1662,9 @@ static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len, | |||
1662 | totalpages = len >> this->page_shift; | 1662 | totalpages = len >> this->page_shift; |
1663 | page = (int) (to >> this->page_shift); | 1663 | page = (int) (to >> this->page_shift); |
1664 | /* Invalidate the page cache, if we write to the cached page */ | 1664 | /* Invalidate the page cache, if we write to the cached page */ |
1665 | if (page <= this->pagebuf && this->pagebuf < (page + totalpages)) | 1665 | if (page <= this->pagebuf && this->pagebuf < (page + totalpages)) |
1666 | this->pagebuf = -1; | 1666 | this->pagebuf = -1; |
1667 | 1667 | ||
1668 | /* Set it relative to chip */ | 1668 | /* Set it relative to chip */ |
1669 | page &= this->pagemask; | 1669 | page &= this->pagemask; |
1670 | startpage = page; | 1670 | startpage = page; |
@@ -1686,14 +1686,14 @@ static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len, | |||
1686 | if (ret) { | 1686 | if (ret) { |
1687 | DEBUG (MTD_DEBUG_LEVEL0, "nand_write_ecc: write_page failed %d\n", ret); | 1687 | DEBUG (MTD_DEBUG_LEVEL0, "nand_write_ecc: write_page failed %d\n", ret); |
1688 | goto out; | 1688 | goto out; |
1689 | } | 1689 | } |
1690 | /* Next oob page */ | 1690 | /* Next oob page */ |
1691 | oob += mtd->oobsize; | 1691 | oob += mtd->oobsize; |
1692 | /* Update written bytes count */ | 1692 | /* Update written bytes count */ |
1693 | written += mtd->oobblock; | 1693 | written += mtd->oobblock; |
1694 | if (written == len) | 1694 | if (written == len) |
1695 | goto cmp; | 1695 | goto cmp; |
1696 | 1696 | ||
1697 | /* Increment page address */ | 1697 | /* Increment page address */ |
1698 | page++; | 1698 | page++; |
1699 | 1699 | ||
@@ -1704,13 +1704,13 @@ static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len, | |||
1704 | if (!(page & (ppblock - 1))){ | 1704 | if (!(page & (ppblock - 1))){ |
1705 | int ofs; | 1705 | int ofs; |
1706 | this->data_poi = bufstart; | 1706 | this->data_poi = bufstart; |
1707 | ret = nand_verify_pages (mtd, this, startpage, | 1707 | ret = nand_verify_pages (mtd, this, startpage, |
1708 | page - startpage, | 1708 | page - startpage, |
1709 | oobbuf, oobsel, chipnr, (eccbuf != NULL)); | 1709 | oobbuf, oobsel, chipnr, (eccbuf != NULL)); |
1710 | if (ret) { | 1710 | if (ret) { |
1711 | DEBUG (MTD_DEBUG_LEVEL0, "nand_write_ecc: verify_pages failed %d\n", ret); | 1711 | DEBUG (MTD_DEBUG_LEVEL0, "nand_write_ecc: verify_pages failed %d\n", ret); |
1712 | goto out; | 1712 | goto out; |
1713 | } | 1713 | } |
1714 | *retlen = written; | 1714 | *retlen = written; |
1715 | 1715 | ||
1716 | ofs = autoplace ? mtd->oobavail : mtd->oobsize; | 1716 | ofs = autoplace ? mtd->oobavail : mtd->oobsize; |
@@ -1720,7 +1720,7 @@ static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len, | |||
1720 | numpages = min (totalpages, ppblock); | 1720 | numpages = min (totalpages, ppblock); |
1721 | page &= this->pagemask; | 1721 | page &= this->pagemask; |
1722 | startpage = page; | 1722 | startpage = page; |
1723 | oobbuf = nand_prepare_oobbuf (mtd, eccbuf, oobsel, | 1723 | oobbuf = nand_prepare_oobbuf (mtd, eccbuf, oobsel, |
1724 | autoplace, numpages); | 1724 | autoplace, numpages); |
1725 | oob = 0; | 1725 | oob = 0; |
1726 | /* Check, if we cross a chip boundary */ | 1726 | /* Check, if we cross a chip boundary */ |
@@ -1738,7 +1738,7 @@ cmp: | |||
1738 | oobbuf, oobsel, chipnr, (eccbuf != NULL)); | 1738 | oobbuf, oobsel, chipnr, (eccbuf != NULL)); |
1739 | if (!ret) | 1739 | if (!ret) |
1740 | *retlen = written; | 1740 | *retlen = written; |
1741 | else | 1741 | else |
1742 | DEBUG (MTD_DEBUG_LEVEL0, "nand_write_ecc: verify_pages failed %d\n", ret); | 1742 | DEBUG (MTD_DEBUG_LEVEL0, "nand_write_ecc: verify_pages failed %d\n", ret); |
1743 | 1743 | ||
1744 | out: | 1744 | out: |
@@ -1798,7 +1798,7 @@ static int nand_write_oob (struct mtd_info *mtd, loff_t to, size_t len, size_t * | |||
1798 | /* Check, if it is write protected */ | 1798 | /* Check, if it is write protected */ |
1799 | if (nand_check_wp(mtd)) | 1799 | if (nand_check_wp(mtd)) |
1800 | goto out; | 1800 | goto out; |
1801 | 1801 | ||
1802 | /* Invalidate the page cache, if we write to the cached page */ | 1802 | /* Invalidate the page cache, if we write to the cached page */ |
1803 | if (page == this->pagebuf) | 1803 | if (page == this->pagebuf) |
1804 | this->pagebuf = -1; | 1804 | this->pagebuf = -1; |
@@ -1861,10 +1861,10 @@ out: | |||
1861 | * | 1861 | * |
1862 | * NAND write with kvec. This just calls the ecc function | 1862 | * NAND write with kvec. This just calls the ecc function |
1863 | */ | 1863 | */ |
1864 | static int nand_writev (struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, | 1864 | static int nand_writev (struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, |
1865 | loff_t to, size_t * retlen) | 1865 | loff_t to, size_t * retlen) |
1866 | { | 1866 | { |
1867 | return (nand_writev_ecc (mtd, vecs, count, to, retlen, NULL, NULL)); | 1867 | return (nand_writev_ecc (mtd, vecs, count, to, retlen, NULL, NULL)); |
1868 | } | 1868 | } |
1869 | 1869 | ||
1870 | /** | 1870 | /** |
@@ -1879,7 +1879,7 @@ static int nand_writev (struct mtd_info *mtd, const struct kvec *vecs, unsigned | |||
1879 | * | 1879 | * |
1880 | * NAND write with iovec with ecc | 1880 | * NAND write with iovec with ecc |
1881 | */ | 1881 | */ |
1882 | static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, | 1882 | static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, |
1883 | loff_t to, size_t * retlen, u_char *eccbuf, struct nand_oobinfo *oobsel) | 1883 | loff_t to, size_t * retlen, u_char *eccbuf, struct nand_oobinfo *oobsel) |
1884 | { | 1884 | { |
1885 | int i, page, len, total_len, ret = -EIO, written = 0, chipnr; | 1885 | int i, page, len, total_len, ret = -EIO, written = 0, chipnr; |
@@ -1905,7 +1905,7 @@ static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsig | |||
1905 | return -EINVAL; | 1905 | return -EINVAL; |
1906 | } | 1906 | } |
1907 | 1907 | ||
1908 | /* reject writes, which are not page aligned */ | 1908 | /* reject writes, which are not page aligned */ |
1909 | if (NOTALIGNED (to) || NOTALIGNED(total_len)) { | 1909 | if (NOTALIGNED (to) || NOTALIGNED(total_len)) { |
1910 | printk (KERN_NOTICE "nand_write_ecc: Attempt to write not page aligned data\n"); | 1910 | printk (KERN_NOTICE "nand_write_ecc: Attempt to write not page aligned data\n"); |
1911 | return -EINVAL; | 1911 | return -EINVAL; |
@@ -1924,21 +1924,21 @@ static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsig | |||
1924 | goto out; | 1924 | goto out; |
1925 | 1925 | ||
1926 | /* if oobsel is NULL, use chip defaults */ | 1926 | /* if oobsel is NULL, use chip defaults */ |
1927 | if (oobsel == NULL) | 1927 | if (oobsel == NULL) |
1928 | oobsel = &mtd->oobinfo; | 1928 | oobsel = &mtd->oobinfo; |
1929 | 1929 | ||
1930 | /* Autoplace of oob data ? Use the default placement scheme */ | 1930 | /* Autoplace of oob data ? Use the default placement scheme */ |
1931 | if (oobsel->useecc == MTD_NANDECC_AUTOPLACE) { | 1931 | if (oobsel->useecc == MTD_NANDECC_AUTOPLACE) { |
1932 | oobsel = this->autooob; | 1932 | oobsel = this->autooob; |
1933 | autoplace = 1; | 1933 | autoplace = 1; |
1934 | } | 1934 | } |
1935 | if (oobsel->useecc == MTD_NANDECC_AUTOPL_USR) | 1935 | if (oobsel->useecc == MTD_NANDECC_AUTOPL_USR) |
1936 | autoplace = 1; | 1936 | autoplace = 1; |
1937 | 1937 | ||
1938 | /* Setup start page */ | 1938 | /* Setup start page */ |
1939 | page = (int) (to >> this->page_shift); | 1939 | page = (int) (to >> this->page_shift); |
1940 | /* Invalidate the page cache, if we write to the cached page */ | 1940 | /* Invalidate the page cache, if we write to the cached page */ |
1941 | if (page <= this->pagebuf && this->pagebuf < ((to + total_len) >> this->page_shift)) | 1941 | if (page <= this->pagebuf && this->pagebuf < ((to + total_len) >> this->page_shift)) |
1942 | this->pagebuf = -1; | 1942 | this->pagebuf = -1; |
1943 | 1943 | ||
1944 | startpage = page & this->pagemask; | 1944 | startpage = page & this->pagemask; |
@@ -1962,10 +1962,10 @@ static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsig | |||
1962 | oob = 0; | 1962 | oob = 0; |
1963 | for (i = 1; i <= numpages; i++) { | 1963 | for (i = 1; i <= numpages; i++) { |
1964 | /* Write one page. If this is the last page to write | 1964 | /* Write one page. If this is the last page to write |
1965 | * then use the real pageprogram command, else select | 1965 | * then use the real pageprogram command, else select |
1966 | * cached programming if supported by the chip. | 1966 | * cached programming if supported by the chip. |
1967 | */ | 1967 | */ |
1968 | ret = nand_write_page (mtd, this, page & this->pagemask, | 1968 | ret = nand_write_page (mtd, this, page & this->pagemask, |
1969 | &oobbuf[oob], oobsel, i != numpages); | 1969 | &oobbuf[oob], oobsel, i != numpages); |
1970 | if (ret) | 1970 | if (ret) |
1971 | goto out; | 1971 | goto out; |
@@ -1981,12 +1981,12 @@ static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsig | |||
1981 | count--; | 1981 | count--; |
1982 | } | 1982 | } |
1983 | } else { | 1983 | } else { |
1984 | /* We must use the internal buffer, read data out of each | 1984 | /* We must use the internal buffer, read data out of each |
1985 | * tuple until we have a full page to write | 1985 | * tuple until we have a full page to write |
1986 | */ | 1986 | */ |
1987 | int cnt = 0; | 1987 | int cnt = 0; |
1988 | while (cnt < mtd->oobblock) { | 1988 | while (cnt < mtd->oobblock) { |
1989 | if (vecs->iov_base != NULL && vecs->iov_len) | 1989 | if (vecs->iov_base != NULL && vecs->iov_len) |
1990 | this->data_buf[cnt++] = ((u_char *) vecs->iov_base)[len++]; | 1990 | this->data_buf[cnt++] = ((u_char *) vecs->iov_base)[len++]; |
1991 | /* Check, if we have to switch to the next tuple */ | 1991 | /* Check, if we have to switch to the next tuple */ |
1992 | if (len >= (int) vecs->iov_len) { | 1992 | if (len >= (int) vecs->iov_len) { |
@@ -1995,10 +1995,10 @@ static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsig | |||
1995 | count--; | 1995 | count--; |
1996 | } | 1996 | } |
1997 | } | 1997 | } |
1998 | this->pagebuf = page; | 1998 | this->pagebuf = page; |
1999 | this->data_poi = this->data_buf; | 1999 | this->data_poi = this->data_buf; |
2000 | bufstart = this->data_poi; | 2000 | bufstart = this->data_poi; |
2001 | numpages = 1; | 2001 | numpages = 1; |
2002 | oobbuf = nand_prepare_oobbuf (mtd, NULL, oobsel, autoplace, numpages); | 2002 | oobbuf = nand_prepare_oobbuf (mtd, NULL, oobsel, autoplace, numpages); |
2003 | ret = nand_write_page (mtd, this, page & this->pagemask, | 2003 | ret = nand_write_page (mtd, this, page & this->pagemask, |
2004 | oobbuf, oobsel, 0); | 2004 | oobbuf, oobsel, 0); |
@@ -2011,7 +2011,7 @@ static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsig | |||
2011 | ret = nand_verify_pages (mtd, this, startpage, numpages, oobbuf, oobsel, chipnr, 0); | 2011 | ret = nand_verify_pages (mtd, this, startpage, numpages, oobbuf, oobsel, chipnr, 0); |
2012 | if (ret) | 2012 | if (ret) |
2013 | goto out; | 2013 | goto out; |
2014 | 2014 | ||
2015 | written += mtd->oobblock * numpages; | 2015 | written += mtd->oobblock * numpages; |
2016 | /* All done ? */ | 2016 | /* All done ? */ |
2017 | if (!count) | 2017 | if (!count) |
@@ -2079,7 +2079,7 @@ static int nand_erase (struct mtd_info *mtd, struct erase_info *instr) | |||
2079 | { | 2079 | { |
2080 | return nand_erase_nand (mtd, instr, 0); | 2080 | return nand_erase_nand (mtd, instr, 0); |
2081 | } | 2081 | } |
2082 | 2082 | ||
2083 | #define BBT_PAGE_MASK 0xffffff3f | 2083 | #define BBT_PAGE_MASK 0xffffff3f |
2084 | /** | 2084 | /** |
2085 | * nand_erase_intern - [NAND Interface] erase block(s) | 2085 | * nand_erase_intern - [NAND Interface] erase block(s) |
@@ -2161,14 +2161,14 @@ int nand_erase_nand (struct mtd_info *mtd, struct erase_info *instr, int allowbb | |||
2161 | instr->state = MTD_ERASE_FAILED; | 2161 | instr->state = MTD_ERASE_FAILED; |
2162 | goto erase_exit; | 2162 | goto erase_exit; |
2163 | } | 2163 | } |
2164 | 2164 | ||
2165 | /* Invalidate the page cache, if we erase the block which contains | 2165 | /* Invalidate the page cache, if we erase the block which contains |
2166 | the current cached page */ | 2166 | the current cached page */ |
2167 | if (page <= this->pagebuf && this->pagebuf < (page + pages_per_block)) | 2167 | if (page <= this->pagebuf && this->pagebuf < (page + pages_per_block)) |
2168 | this->pagebuf = -1; | 2168 | this->pagebuf = -1; |
2169 | 2169 | ||
2170 | this->erase_cmd (mtd, page & this->pagemask); | 2170 | this->erase_cmd (mtd, page & this->pagemask); |
2171 | 2171 | ||
2172 | status = this->waitfunc (mtd, this, FL_ERASING); | 2172 | status = this->waitfunc (mtd, this, FL_ERASING); |
2173 | 2173 | ||
2174 | /* See if operation failed and additional status checks are available */ | 2174 | /* See if operation failed and additional status checks are available */ |
@@ -2186,12 +2186,12 @@ int nand_erase_nand (struct mtd_info *mtd, struct erase_info *instr, int allowbb | |||
2186 | 2186 | ||
2187 | /* if BBT requires refresh, set the BBT rewrite flag to the page being erased */ | 2187 | /* if BBT requires refresh, set the BBT rewrite flag to the page being erased */ |
2188 | if (this->options & BBT_AUTO_REFRESH) { | 2188 | if (this->options & BBT_AUTO_REFRESH) { |
2189 | if (((page & BBT_PAGE_MASK) == bbt_masked_page) && | 2189 | if (((page & BBT_PAGE_MASK) == bbt_masked_page) && |
2190 | (page != this->bbt_td->pages[chipnr])) { | 2190 | (page != this->bbt_td->pages[chipnr])) { |
2191 | rewrite_bbt[chipnr] = (page << this->page_shift); | 2191 | rewrite_bbt[chipnr] = (page << this->page_shift); |
2192 | } | 2192 | } |
2193 | } | 2193 | } |
2194 | 2194 | ||
2195 | /* Increment page address and decrement length */ | 2195 | /* Increment page address and decrement length */ |
2196 | len -= (1 << this->phys_erase_shift); | 2196 | len -= (1 << this->phys_erase_shift); |
2197 | page += pages_per_block; | 2197 | page += pages_per_block; |
@@ -2202,7 +2202,7 @@ int nand_erase_nand (struct mtd_info *mtd, struct erase_info *instr, int allowbb | |||
2202 | this->select_chip(mtd, -1); | 2202 | this->select_chip(mtd, -1); |
2203 | this->select_chip(mtd, chipnr); | 2203 | this->select_chip(mtd, chipnr); |
2204 | 2204 | ||
2205 | /* if BBT requires refresh and BBT-PERCHIP, | 2205 | /* if BBT requires refresh and BBT-PERCHIP, |
2206 | * set the BBT page mask to see if this BBT should be rewritten */ | 2206 | * set the BBT page mask to see if this BBT should be rewritten */ |
2207 | if ((this->options & BBT_AUTO_REFRESH) && (this->bbt_td->options & NAND_BBT_PERCHIP)) { | 2207 | if ((this->options & BBT_AUTO_REFRESH) && (this->bbt_td->options & NAND_BBT_PERCHIP)) { |
2208 | bbt_masked_page = this->bbt_td->pages[chipnr] & BBT_PAGE_MASK; | 2208 | bbt_masked_page = this->bbt_td->pages[chipnr] & BBT_PAGE_MASK; |
@@ -2227,7 +2227,7 @@ erase_exit: | |||
2227 | for (chipnr = 0; chipnr < this->numchips; chipnr++) { | 2227 | for (chipnr = 0; chipnr < this->numchips; chipnr++) { |
2228 | if (rewrite_bbt[chipnr]) { | 2228 | if (rewrite_bbt[chipnr]) { |
2229 | /* update the BBT for chip */ | 2229 | /* update the BBT for chip */ |
2230 | DEBUG (MTD_DEBUG_LEVEL0, "nand_erase_nand: nand_update_bbt (%d:0x%0x 0x%0x)\n", | 2230 | DEBUG (MTD_DEBUG_LEVEL0, "nand_erase_nand: nand_update_bbt (%d:0x%0x 0x%0x)\n", |
2231 | chipnr, rewrite_bbt[chipnr], this->bbt_td->pages[chipnr]); | 2231 | chipnr, rewrite_bbt[chipnr], this->bbt_td->pages[chipnr]); |
2232 | nand_update_bbt (mtd, rewrite_bbt[chipnr]); | 2232 | nand_update_bbt (mtd, rewrite_bbt[chipnr]); |
2233 | } | 2233 | } |
@@ -2265,9 +2265,9 @@ static void nand_sync (struct mtd_info *mtd) | |||
2265 | static int nand_block_isbad (struct mtd_info *mtd, loff_t ofs) | 2265 | static int nand_block_isbad (struct mtd_info *mtd, loff_t ofs) |
2266 | { | 2266 | { |
2267 | /* Check for invalid offset */ | 2267 | /* Check for invalid offset */ |
2268 | if (ofs > mtd->size) | 2268 | if (ofs > mtd->size) |
2269 | return -EINVAL; | 2269 | return -EINVAL; |
2270 | 2270 | ||
2271 | return nand_block_checkbad (mtd, ofs, 1, 0); | 2271 | return nand_block_checkbad (mtd, ofs, 1, 0); |
2272 | } | 2272 | } |
2273 | 2273 | ||
@@ -2386,13 +2386,13 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2386 | 2386 | ||
2387 | /* Print and store flash device information */ | 2387 | /* Print and store flash device information */ |
2388 | for (i = 0; nand_flash_ids[i].name != NULL; i++) { | 2388 | for (i = 0; nand_flash_ids[i].name != NULL; i++) { |
2389 | 2389 | ||
2390 | if (nand_dev_id != nand_flash_ids[i].id) | 2390 | if (nand_dev_id != nand_flash_ids[i].id) |
2391 | continue; | 2391 | continue; |
2392 | 2392 | ||
2393 | if (!mtd->name) mtd->name = nand_flash_ids[i].name; | 2393 | if (!mtd->name) mtd->name = nand_flash_ids[i].name; |
2394 | this->chipsize = nand_flash_ids[i].chipsize << 20; | 2394 | this->chipsize = nand_flash_ids[i].chipsize << 20; |
2395 | 2395 | ||
2396 | /* New devices have all the information in additional id bytes */ | 2396 | /* New devices have all the information in additional id bytes */ |
2397 | if (!nand_flash_ids[i].pagesize) { | 2397 | if (!nand_flash_ids[i].pagesize) { |
2398 | int extid; | 2398 | int extid; |
@@ -2411,7 +2411,7 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2411 | extid >>= 2; | 2411 | extid >>= 2; |
2412 | /* Get buswidth information */ | 2412 | /* Get buswidth information */ |
2413 | busw = (extid & 0x01) ? NAND_BUSWIDTH_16 : 0; | 2413 | busw = (extid & 0x01) ? NAND_BUSWIDTH_16 : 0; |
2414 | 2414 | ||
2415 | } else { | 2415 | } else { |
2416 | /* Old devices have this data hardcoded in the | 2416 | /* Old devices have this data hardcoded in the |
2417 | * device id table */ | 2417 | * device id table */ |
@@ -2431,23 +2431,23 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2431 | * this correct ! */ | 2431 | * this correct ! */ |
2432 | if (busw != (this->options & NAND_BUSWIDTH_16)) { | 2432 | if (busw != (this->options & NAND_BUSWIDTH_16)) { |
2433 | printk (KERN_INFO "NAND device: Manufacturer ID:" | 2433 | printk (KERN_INFO "NAND device: Manufacturer ID:" |
2434 | " 0x%02x, Chip ID: 0x%02x (%s %s)\n", nand_maf_id, nand_dev_id, | 2434 | " 0x%02x, Chip ID: 0x%02x (%s %s)\n", nand_maf_id, nand_dev_id, |
2435 | nand_manuf_ids[maf_id].name , mtd->name); | 2435 | nand_manuf_ids[maf_id].name , mtd->name); |
2436 | printk (KERN_WARNING | 2436 | printk (KERN_WARNING |
2437 | "NAND bus width %d instead %d bit\n", | 2437 | "NAND bus width %d instead %d bit\n", |
2438 | (this->options & NAND_BUSWIDTH_16) ? 16 : 8, | 2438 | (this->options & NAND_BUSWIDTH_16) ? 16 : 8, |
2439 | busw ? 16 : 8); | 2439 | busw ? 16 : 8); |
2440 | this->select_chip(mtd, -1); | 2440 | this->select_chip(mtd, -1); |
2441 | return 1; | 2441 | return 1; |
2442 | } | 2442 | } |
2443 | 2443 | ||
2444 | /* Calculate the address shift from the page size */ | 2444 | /* Calculate the address shift from the page size */ |
2445 | this->page_shift = ffs(mtd->oobblock) - 1; | 2445 | this->page_shift = ffs(mtd->oobblock) - 1; |
2446 | this->bbt_erase_shift = this->phys_erase_shift = ffs(mtd->erasesize) - 1; | 2446 | this->bbt_erase_shift = this->phys_erase_shift = ffs(mtd->erasesize) - 1; |
2447 | this->chip_shift = ffs(this->chipsize) - 1; | 2447 | this->chip_shift = ffs(this->chipsize) - 1; |
2448 | 2448 | ||
2449 | /* Set the bad block position */ | 2449 | /* Set the bad block position */ |
2450 | this->badblockpos = mtd->oobblock > 512 ? | 2450 | this->badblockpos = mtd->oobblock > 512 ? |
2451 | NAND_LARGE_BADBLOCK_POS : NAND_SMALL_BADBLOCK_POS; | 2451 | NAND_LARGE_BADBLOCK_POS : NAND_SMALL_BADBLOCK_POS; |
2452 | 2452 | ||
2453 | /* Get chip options, preserve non chip based options */ | 2453 | /* Get chip options, preserve non chip based options */ |
@@ -2457,10 +2457,10 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2457 | this->options |= NAND_NO_AUTOINCR; | 2457 | this->options |= NAND_NO_AUTOINCR; |
2458 | /* Check if this is a not a samsung device. Do not clear the options | 2458 | /* Check if this is a not a samsung device. Do not clear the options |
2459 | * for chips which are not having an extended id. | 2459 | * for chips which are not having an extended id. |
2460 | */ | 2460 | */ |
2461 | if (nand_maf_id != NAND_MFR_SAMSUNG && !nand_flash_ids[i].pagesize) | 2461 | if (nand_maf_id != NAND_MFR_SAMSUNG && !nand_flash_ids[i].pagesize) |
2462 | this->options &= ~NAND_SAMSUNG_LP_OPTIONS; | 2462 | this->options &= ~NAND_SAMSUNG_LP_OPTIONS; |
2463 | 2463 | ||
2464 | /* Check for AND chips with 4 page planes */ | 2464 | /* Check for AND chips with 4 page planes */ |
2465 | if (this->options & NAND_4PAGE_ARRAY) | 2465 | if (this->options & NAND_4PAGE_ARRAY) |
2466 | this->erase_cmd = multi_erase_cmd; | 2466 | this->erase_cmd = multi_erase_cmd; |
@@ -2470,9 +2470,9 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2470 | /* Do not replace user supplied command function ! */ | 2470 | /* Do not replace user supplied command function ! */ |
2471 | if (mtd->oobblock > 512 && this->cmdfunc == nand_command) | 2471 | if (mtd->oobblock > 512 && this->cmdfunc == nand_command) |
2472 | this->cmdfunc = nand_command_lp; | 2472 | this->cmdfunc = nand_command_lp; |
2473 | 2473 | ||
2474 | printk (KERN_INFO "NAND device: Manufacturer ID:" | 2474 | printk (KERN_INFO "NAND device: Manufacturer ID:" |
2475 | " 0x%02x, Chip ID: 0x%02x (%s %s)\n", nand_maf_id, nand_dev_id, | 2475 | " 0x%02x, Chip ID: 0x%02x (%s %s)\n", nand_maf_id, nand_dev_id, |
2476 | nand_manuf_ids[maf_id].name , nand_flash_ids[i].name); | 2476 | nand_manuf_ids[maf_id].name , nand_flash_ids[i].name); |
2477 | break; | 2477 | break; |
2478 | } | 2478 | } |
@@ -2496,7 +2496,7 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2496 | } | 2496 | } |
2497 | if (i > 1) | 2497 | if (i > 1) |
2498 | printk(KERN_INFO "%d NAND chips detected\n", i); | 2498 | printk(KERN_INFO "%d NAND chips detected\n", i); |
2499 | 2499 | ||
2500 | /* Allocate buffers, if neccecary */ | 2500 | /* Allocate buffers, if neccecary */ |
2501 | if (!this->oob_buf) { | 2501 | if (!this->oob_buf) { |
2502 | size_t len; | 2502 | size_t len; |
@@ -2508,7 +2508,7 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2508 | } | 2508 | } |
2509 | this->options |= NAND_OOBBUF_ALLOC; | 2509 | this->options |= NAND_OOBBUF_ALLOC; |
2510 | } | 2510 | } |
2511 | 2511 | ||
2512 | if (!this->data_buf) { | 2512 | if (!this->data_buf) { |
2513 | size_t len; | 2513 | size_t len; |
2514 | len = mtd->oobblock + mtd->oobsize; | 2514 | len = mtd->oobblock + mtd->oobsize; |
@@ -2535,7 +2535,7 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2535 | if (!this->autooob) { | 2535 | if (!this->autooob) { |
2536 | /* Select the appropriate default oob placement scheme for | 2536 | /* Select the appropriate default oob placement scheme for |
2537 | * placement agnostic filesystems */ | 2537 | * placement agnostic filesystems */ |
2538 | switch (mtd->oobsize) { | 2538 | switch (mtd->oobsize) { |
2539 | case 8: | 2539 | case 8: |
2540 | this->autooob = &nand_oob_8; | 2540 | this->autooob = &nand_oob_8; |
2541 | break; | 2541 | break; |
@@ -2551,19 +2551,19 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2551 | BUG(); | 2551 | BUG(); |
2552 | } | 2552 | } |
2553 | } | 2553 | } |
2554 | 2554 | ||
2555 | /* The number of bytes available for the filesystem to place fs dependend | 2555 | /* The number of bytes available for the filesystem to place fs dependend |
2556 | * oob data */ | 2556 | * oob data */ |
2557 | mtd->oobavail = 0; | 2557 | mtd->oobavail = 0; |
2558 | for (i = 0; this->autooob->oobfree[i][1]; i++) | 2558 | for (i = 0; this->autooob->oobfree[i][1]; i++) |
2559 | mtd->oobavail += this->autooob->oobfree[i][1]; | 2559 | mtd->oobavail += this->autooob->oobfree[i][1]; |
2560 | 2560 | ||
2561 | /* | 2561 | /* |
2562 | * check ECC mode, default to software | 2562 | * check ECC mode, default to software |
2563 | * if 3byte/512byte hardware ECC is selected and we have 256 byte pagesize | 2563 | * if 3byte/512byte hardware ECC is selected and we have 256 byte pagesize |
2564 | * fallback to software ECC | 2564 | * fallback to software ECC |
2565 | */ | 2565 | */ |
2566 | this->eccsize = 256; /* set default eccsize */ | 2566 | this->eccsize = 256; /* set default eccsize */ |
2567 | this->eccbytes = 3; | 2567 | this->eccbytes = 3; |
2568 | 2568 | ||
2569 | switch (this->eccmode) { | 2569 | switch (this->eccmode) { |
@@ -2578,56 +2578,56 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2578 | this->eccsize = 2048; | 2578 | this->eccsize = 2048; |
2579 | break; | 2579 | break; |
2580 | 2580 | ||
2581 | case NAND_ECC_HW3_512: | 2581 | case NAND_ECC_HW3_512: |
2582 | case NAND_ECC_HW6_512: | 2582 | case NAND_ECC_HW6_512: |
2583 | case NAND_ECC_HW8_512: | 2583 | case NAND_ECC_HW8_512: |
2584 | if (mtd->oobblock == 256) { | 2584 | if (mtd->oobblock == 256) { |
2585 | printk (KERN_WARNING "512 byte HW ECC not possible on 256 Byte pagesize, fallback to SW ECC \n"); | 2585 | printk (KERN_WARNING "512 byte HW ECC not possible on 256 Byte pagesize, fallback to SW ECC \n"); |
2586 | this->eccmode = NAND_ECC_SOFT; | 2586 | this->eccmode = NAND_ECC_SOFT; |
2587 | this->calculate_ecc = nand_calculate_ecc; | 2587 | this->calculate_ecc = nand_calculate_ecc; |
2588 | this->correct_data = nand_correct_data; | 2588 | this->correct_data = nand_correct_data; |
2589 | } else | 2589 | } else |
2590 | this->eccsize = 512; /* set eccsize to 512 */ | 2590 | this->eccsize = 512; /* set eccsize to 512 */ |
2591 | break; | 2591 | break; |
2592 | 2592 | ||
2593 | case NAND_ECC_HW3_256: | 2593 | case NAND_ECC_HW3_256: |
2594 | break; | 2594 | break; |
2595 | 2595 | ||
2596 | case NAND_ECC_NONE: | 2596 | case NAND_ECC_NONE: |
2597 | printk (KERN_WARNING "NAND_ECC_NONE selected by board driver. This is not recommended !!\n"); | 2597 | printk (KERN_WARNING "NAND_ECC_NONE selected by board driver. This is not recommended !!\n"); |
2598 | this->eccmode = NAND_ECC_NONE; | 2598 | this->eccmode = NAND_ECC_NONE; |
2599 | break; | 2599 | break; |
2600 | 2600 | ||
2601 | case NAND_ECC_SOFT: | 2601 | case NAND_ECC_SOFT: |
2602 | this->calculate_ecc = nand_calculate_ecc; | 2602 | this->calculate_ecc = nand_calculate_ecc; |
2603 | this->correct_data = nand_correct_data; | 2603 | this->correct_data = nand_correct_data; |
2604 | break; | 2604 | break; |
2605 | 2605 | ||
2606 | default: | 2606 | default: |
2607 | printk (KERN_WARNING "Invalid NAND_ECC_MODE %d\n", this->eccmode); | 2607 | printk (KERN_WARNING "Invalid NAND_ECC_MODE %d\n", this->eccmode); |
2608 | BUG(); | 2608 | BUG(); |
2609 | } | 2609 | } |
2610 | 2610 | ||
2611 | /* Check hardware ecc function availability and adjust number of ecc bytes per | 2611 | /* Check hardware ecc function availability and adjust number of ecc bytes per |
2612 | * calculation step | 2612 | * calculation step |
2613 | */ | 2613 | */ |
2614 | switch (this->eccmode) { | 2614 | switch (this->eccmode) { |
2615 | case NAND_ECC_HW12_2048: | 2615 | case NAND_ECC_HW12_2048: |
2616 | this->eccbytes += 4; | 2616 | this->eccbytes += 4; |
2617 | case NAND_ECC_HW8_512: | 2617 | case NAND_ECC_HW8_512: |
2618 | this->eccbytes += 2; | 2618 | this->eccbytes += 2; |
2619 | case NAND_ECC_HW6_512: | 2619 | case NAND_ECC_HW6_512: |
2620 | this->eccbytes += 3; | 2620 | this->eccbytes += 3; |
2621 | case NAND_ECC_HW3_512: | 2621 | case NAND_ECC_HW3_512: |
2622 | case NAND_ECC_HW3_256: | 2622 | case NAND_ECC_HW3_256: |
2623 | if (this->calculate_ecc && this->correct_data && this->enable_hwecc) | 2623 | if (this->calculate_ecc && this->correct_data && this->enable_hwecc) |
2624 | break; | 2624 | break; |
2625 | printk (KERN_WARNING "No ECC functions supplied, Hardware ECC not possible\n"); | 2625 | printk (KERN_WARNING "No ECC functions supplied, Hardware ECC not possible\n"); |
2626 | BUG(); | 2626 | BUG(); |
2627 | } | 2627 | } |
2628 | 2628 | ||
2629 | mtd->eccsize = this->eccsize; | 2629 | mtd->eccsize = this->eccsize; |
2630 | 2630 | ||
2631 | /* Set the number of read / write steps for one page to ensure ECC generation */ | 2631 | /* Set the number of read / write steps for one page to ensure ECC generation */ |
2632 | switch (this->eccmode) { | 2632 | switch (this->eccmode) { |
2633 | case NAND_ECC_HW12_2048: | 2633 | case NAND_ECC_HW12_2048: |
@@ -2639,15 +2639,15 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2639 | this->eccsteps = mtd->oobblock / 512; | 2639 | this->eccsteps = mtd->oobblock / 512; |
2640 | break; | 2640 | break; |
2641 | case NAND_ECC_HW3_256: | 2641 | case NAND_ECC_HW3_256: |
2642 | case NAND_ECC_SOFT: | 2642 | case NAND_ECC_SOFT: |
2643 | this->eccsteps = mtd->oobblock / 256; | 2643 | this->eccsteps = mtd->oobblock / 256; |
2644 | break; | 2644 | break; |
2645 | 2645 | ||
2646 | case NAND_ECC_NONE: | 2646 | case NAND_ECC_NONE: |
2647 | this->eccsteps = 1; | 2647 | this->eccsteps = 1; |
2648 | break; | 2648 | break; |
2649 | } | 2649 | } |
2650 | 2650 | ||
2651 | /* Initialize state, waitqueue and spinlock */ | 2651 | /* Initialize state, waitqueue and spinlock */ |
2652 | this->state = FL_READY; | 2652 | this->state = FL_READY; |
2653 | init_waitqueue_head (&this->wq); | 2653 | init_waitqueue_head (&this->wq); |
@@ -2687,7 +2687,7 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2687 | memcpy(&mtd->oobinfo, this->autooob, sizeof(mtd->oobinfo)); | 2687 | memcpy(&mtd->oobinfo, this->autooob, sizeof(mtd->oobinfo)); |
2688 | 2688 | ||
2689 | mtd->owner = THIS_MODULE; | 2689 | mtd->owner = THIS_MODULE; |
2690 | 2690 | ||
2691 | /* Check, if we should skip the bad block table scan */ | 2691 | /* Check, if we should skip the bad block table scan */ |
2692 | if (this->options & NAND_SKIP_BBTSCAN) | 2692 | if (this->options & NAND_SKIP_BBTSCAN) |
2693 | return 0; | 2693 | return 0; |
@@ -2697,7 +2697,7 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2697 | } | 2697 | } |
2698 | 2698 | ||
2699 | /** | 2699 | /** |
2700 | * nand_release - [NAND Interface] Free resources held by the NAND device | 2700 | * nand_release - [NAND Interface] Free resources held by the NAND device |
2701 | * @mtd: MTD device structure | 2701 | * @mtd: MTD device structure |
2702 | */ | 2702 | */ |
2703 | void nand_release (struct mtd_info *mtd) | 2703 | void nand_release (struct mtd_info *mtd) |