diff options
Diffstat (limited to 'drivers/mtd/nand/cafe_nand.c')
| -rw-r--r-- | drivers/mtd/nand/cafe_nand.c | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/drivers/mtd/nand/cafe_nand.c b/drivers/mtd/nand/cafe_nand.c index 2a96e1a12062..41371ba1a811 100644 --- a/drivers/mtd/nand/cafe_nand.c +++ b/drivers/mtd/nand/cafe_nand.c | |||
| @@ -364,25 +364,27 @@ static int cafe_nand_write_oob(struct mtd_info *mtd, | |||
| 364 | 364 | ||
| 365 | /* Don't use -- use nand_read_oob_std for now */ | 365 | /* Don't use -- use nand_read_oob_std for now */ |
| 366 | static int cafe_nand_read_oob(struct mtd_info *mtd, struct nand_chip *chip, | 366 | static int cafe_nand_read_oob(struct mtd_info *mtd, struct nand_chip *chip, |
| 367 | int page, int sndcmd) | 367 | int page) |
| 368 | { | 368 | { |
| 369 | chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page); | 369 | chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page); |
| 370 | chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); | 370 | chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); |
| 371 | return 1; | 371 | return 0; |
| 372 | } | 372 | } |
| 373 | /** | 373 | /** |
| 374 | * cafe_nand_read_page_syndrome - [REPLACEABLE] hardware ecc syndrome based page read | 374 | * cafe_nand_read_page_syndrome - [REPLACEABLE] hardware ecc syndrome based page read |
| 375 | * @mtd: mtd info structure | 375 | * @mtd: mtd info structure |
| 376 | * @chip: nand chip info structure | 376 | * @chip: nand chip info structure |
| 377 | * @buf: buffer to store read data | 377 | * @buf: buffer to store read data |
| 378 | * @oob_required: caller expects OOB data read to chip->oob_poi | ||
| 378 | * | 379 | * |
| 379 | * The hw generator calculates the error syndrome automatically. Therefor | 380 | * The hw generator calculates the error syndrome automatically. Therefor |
| 380 | * we need a special oob layout and handling. | 381 | * we need a special oob layout and handling. |
| 381 | */ | 382 | */ |
| 382 | static int cafe_nand_read_page(struct mtd_info *mtd, struct nand_chip *chip, | 383 | static int cafe_nand_read_page(struct mtd_info *mtd, struct nand_chip *chip, |
| 383 | uint8_t *buf, int page) | 384 | uint8_t *buf, int oob_required, int page) |
| 384 | { | 385 | { |
| 385 | struct cafe_priv *cafe = mtd->priv; | 386 | struct cafe_priv *cafe = mtd->priv; |
| 387 | unsigned int max_bitflips = 0; | ||
| 386 | 388 | ||
| 387 | cafe_dev_dbg(&cafe->pdev->dev, "ECC result %08x SYN1,2 %08x\n", | 389 | cafe_dev_dbg(&cafe->pdev->dev, "ECC result %08x SYN1,2 %08x\n", |
| 388 | cafe_readl(cafe, NAND_ECC_RESULT), | 390 | cafe_readl(cafe, NAND_ECC_RESULT), |
| @@ -449,10 +451,11 @@ static int cafe_nand_read_page(struct mtd_info *mtd, struct nand_chip *chip, | |||
| 449 | } else { | 451 | } else { |
| 450 | dev_dbg(&cafe->pdev->dev, "Corrected %d symbol errors\n", n); | 452 | dev_dbg(&cafe->pdev->dev, "Corrected %d symbol errors\n", n); |
| 451 | mtd->ecc_stats.corrected += n; | 453 | mtd->ecc_stats.corrected += n; |
| 454 | max_bitflips = max_t(unsigned int, max_bitflips, n); | ||
| 452 | } | 455 | } |
| 453 | } | 456 | } |
| 454 | 457 | ||
| 455 | return 0; | 458 | return max_bitflips; |
| 456 | } | 459 | } |
| 457 | 460 | ||
| 458 | static struct nand_ecclayout cafe_oobinfo_2048 = { | 461 | static struct nand_ecclayout cafe_oobinfo_2048 = { |
| @@ -518,7 +521,8 @@ static struct nand_bbt_descr cafe_bbt_mirror_descr_512 = { | |||
| 518 | 521 | ||
| 519 | 522 | ||
| 520 | static void cafe_nand_write_page_lowlevel(struct mtd_info *mtd, | 523 | static void cafe_nand_write_page_lowlevel(struct mtd_info *mtd, |
| 521 | struct nand_chip *chip, const uint8_t *buf) | 524 | struct nand_chip *chip, |
| 525 | const uint8_t *buf, int oob_required) | ||
| 522 | { | 526 | { |
| 523 | struct cafe_priv *cafe = mtd->priv; | 527 | struct cafe_priv *cafe = mtd->priv; |
| 524 | 528 | ||
| @@ -530,16 +534,17 @@ static void cafe_nand_write_page_lowlevel(struct mtd_info *mtd, | |||
| 530 | } | 534 | } |
| 531 | 535 | ||
| 532 | static int cafe_nand_write_page(struct mtd_info *mtd, struct nand_chip *chip, | 536 | static int cafe_nand_write_page(struct mtd_info *mtd, struct nand_chip *chip, |
| 533 | const uint8_t *buf, int page, int cached, int raw) | 537 | const uint8_t *buf, int oob_required, int page, |
| 538 | int cached, int raw) | ||
| 534 | { | 539 | { |
| 535 | int status; | 540 | int status; |
| 536 | 541 | ||
| 537 | chip->cmdfunc(mtd, NAND_CMD_SEQIN, 0x00, page); | 542 | chip->cmdfunc(mtd, NAND_CMD_SEQIN, 0x00, page); |
| 538 | 543 | ||
| 539 | if (unlikely(raw)) | 544 | if (unlikely(raw)) |
| 540 | chip->ecc.write_page_raw(mtd, chip, buf); | 545 | chip->ecc.write_page_raw(mtd, chip, buf, oob_required); |
| 541 | else | 546 | else |
| 542 | chip->ecc.write_page(mtd, chip, buf); | 547 | chip->ecc.write_page(mtd, chip, buf, oob_required); |
| 543 | 548 | ||
| 544 | /* | 549 | /* |
| 545 | * Cached progamming disabled for now, Not sure if its worth the | 550 | * Cached progamming disabled for now, Not sure if its worth the |
| @@ -685,7 +690,7 @@ static int __devinit cafe_nand_probe(struct pci_dev *pdev, | |||
| 685 | 690 | ||
| 686 | /* Enable the following for a flash based bad block table */ | 691 | /* Enable the following for a flash based bad block table */ |
| 687 | cafe->nand.bbt_options = NAND_BBT_USE_FLASH; | 692 | cafe->nand.bbt_options = NAND_BBT_USE_FLASH; |
| 688 | cafe->nand.options = NAND_NO_AUTOINCR | NAND_OWN_BUFFERS; | 693 | cafe->nand.options = NAND_OWN_BUFFERS; |
| 689 | 694 | ||
| 690 | if (skipbbt) { | 695 | if (skipbbt) { |
| 691 | cafe->nand.options |= NAND_SKIP_BBTSCAN; | 696 | cafe->nand.options |= NAND_SKIP_BBTSCAN; |
| @@ -888,17 +893,7 @@ static struct pci_driver cafe_nand_pci_driver = { | |||
| 888 | .resume = cafe_nand_resume, | 893 | .resume = cafe_nand_resume, |
| 889 | }; | 894 | }; |
| 890 | 895 | ||
| 891 | static int __init cafe_nand_init(void) | 896 | module_pci_driver(cafe_nand_pci_driver); |
| 892 | { | ||
| 893 | return pci_register_driver(&cafe_nand_pci_driver); | ||
| 894 | } | ||
| 895 | |||
| 896 | static void __exit cafe_nand_exit(void) | ||
| 897 | { | ||
| 898 | pci_unregister_driver(&cafe_nand_pci_driver); | ||
| 899 | } | ||
| 900 | module_init(cafe_nand_init); | ||
| 901 | module_exit(cafe_nand_exit); | ||
| 902 | 897 | ||
| 903 | MODULE_LICENSE("GPL"); | 898 | MODULE_LICENSE("GPL"); |
| 904 | MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>"); | 899 | MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>"); |
