diff options
Diffstat (limited to 'drivers/mtd/nand/nand_base.c')
-rw-r--r-- | drivers/mtd/nand/nand_base.c | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index df7eb4ff07d1..c2e1232cd45c 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c | |||
@@ -386,7 +386,7 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs) | |||
386 | uint8_t buf[2] = { 0, 0 }; | 386 | uint8_t buf[2] = { 0, 0 }; |
387 | int ret = 0, res, i = 0; | 387 | int ret = 0, res, i = 0; |
388 | 388 | ||
389 | ops.datbuf = NULL; | 389 | memset(&ops, 0, sizeof(ops)); |
390 | ops.oobbuf = buf; | 390 | ops.oobbuf = buf; |
391 | ops.ooboffs = chip->badblockpos; | 391 | ops.ooboffs = chip->badblockpos; |
392 | if (chip->options & NAND_BUSWIDTH_16) { | 392 | if (chip->options & NAND_BUSWIDTH_16) { |
@@ -566,6 +566,25 @@ void nand_wait_ready(struct mtd_info *mtd) | |||
566 | EXPORT_SYMBOL_GPL(nand_wait_ready); | 566 | EXPORT_SYMBOL_GPL(nand_wait_ready); |
567 | 567 | ||
568 | /** | 568 | /** |
569 | * nand_wait_status_ready - [GENERIC] Wait for the ready status after commands. | ||
570 | * @mtd: MTD device structure | ||
571 | * @timeo: Timeout in ms | ||
572 | * | ||
573 | * Wait for status ready (i.e. command done) or timeout. | ||
574 | */ | ||
575 | static void nand_wait_status_ready(struct mtd_info *mtd, unsigned long timeo) | ||
576 | { | ||
577 | register struct nand_chip *chip = mtd->priv; | ||
578 | |||
579 | timeo = jiffies + msecs_to_jiffies(timeo); | ||
580 | do { | ||
581 | if ((chip->read_byte(mtd) & NAND_STATUS_READY)) | ||
582 | break; | ||
583 | touch_softlockup_watchdog(); | ||
584 | } while (time_before(jiffies, timeo)); | ||
585 | }; | ||
586 | |||
587 | /** | ||
569 | * nand_command - [DEFAULT] Send command to NAND device | 588 | * nand_command - [DEFAULT] Send command to NAND device |
570 | * @mtd: MTD device structure | 589 | * @mtd: MTD device structure |
571 | * @command: the command to be sent | 590 | * @command: the command to be sent |
@@ -643,8 +662,8 @@ static void nand_command(struct mtd_info *mtd, unsigned int command, | |||
643 | NAND_CTRL_CLE | NAND_CTRL_CHANGE); | 662 | NAND_CTRL_CLE | NAND_CTRL_CHANGE); |
644 | chip->cmd_ctrl(mtd, | 663 | chip->cmd_ctrl(mtd, |
645 | NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); | 664 | NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); |
646 | while (!(chip->read_byte(mtd) & NAND_STATUS_READY)) | 665 | /* EZ-NAND can take upto 250ms as per ONFi v4.0 */ |
647 | ; | 666 | nand_wait_status_ready(mtd, 250); |
648 | return; | 667 | return; |
649 | 668 | ||
650 | /* This applies to read commands */ | 669 | /* This applies to read commands */ |
@@ -740,8 +759,8 @@ static void nand_command_lp(struct mtd_info *mtd, unsigned int command, | |||
740 | NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE); | 759 | NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE); |
741 | chip->cmd_ctrl(mtd, NAND_CMD_NONE, | 760 | chip->cmd_ctrl(mtd, NAND_CMD_NONE, |
742 | NAND_NCE | NAND_CTRL_CHANGE); | 761 | NAND_NCE | NAND_CTRL_CHANGE); |
743 | while (!(chip->read_byte(mtd) & NAND_STATUS_READY)) | 762 | /* EZ-NAND can take upto 250ms as per ONFi v4.0 */ |
744 | ; | 763 | nand_wait_status_ready(mtd, 250); |
745 | return; | 764 | return; |
746 | 765 | ||
747 | case NAND_CMD_RNDOUT: | 766 | case NAND_CMD_RNDOUT: |
@@ -968,7 +987,7 @@ int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) | |||
968 | __func__, (unsigned long long)ofs, len); | 987 | __func__, (unsigned long long)ofs, len); |
969 | 988 | ||
970 | if (check_offs_len(mtd, ofs, len)) | 989 | if (check_offs_len(mtd, ofs, len)) |
971 | ret = -EINVAL; | 990 | return -EINVAL; |
972 | 991 | ||
973 | /* Align to last block address if size addresses end of the device */ | 992 | /* Align to last block address if size addresses end of the device */ |
974 | if (ofs + len == mtd->size) | 993 | if (ofs + len == mtd->size) |
@@ -1031,7 +1050,7 @@ int nand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) | |||
1031 | __func__, (unsigned long long)ofs, len); | 1050 | __func__, (unsigned long long)ofs, len); |
1032 | 1051 | ||
1033 | if (check_offs_len(mtd, ofs, len)) | 1052 | if (check_offs_len(mtd, ofs, len)) |
1034 | ret = -EINVAL; | 1053 | return -EINVAL; |
1035 | 1054 | ||
1036 | nand_get_device(mtd, FL_LOCKING); | 1055 | nand_get_device(mtd, FL_LOCKING); |
1037 | 1056 | ||
@@ -1716,9 +1735,9 @@ static int nand_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
1716 | int ret; | 1735 | int ret; |
1717 | 1736 | ||
1718 | nand_get_device(mtd, FL_READING); | 1737 | nand_get_device(mtd, FL_READING); |
1738 | memset(&ops, 0, sizeof(ops)); | ||
1719 | ops.len = len; | 1739 | ops.len = len; |
1720 | ops.datbuf = buf; | 1740 | ops.datbuf = buf; |
1721 | ops.oobbuf = NULL; | ||
1722 | ops.mode = MTD_OPS_PLACE_OOB; | 1741 | ops.mode = MTD_OPS_PLACE_OOB; |
1723 | ret = nand_do_read_ops(mtd, from, &ops); | 1742 | ret = nand_do_read_ops(mtd, from, &ops); |
1724 | *retlen = ops.retlen; | 1743 | *retlen = ops.retlen; |
@@ -2124,7 +2143,7 @@ static int nand_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, | |||
2124 | 2143 | ||
2125 | 2144 | ||
2126 | /** | 2145 | /** |
2127 | * nand_write_subpage_hwecc - [REPLACABLE] hardware ECC based subpage write | 2146 | * nand_write_subpage_hwecc - [REPLACEABLE] hardware ECC based subpage write |
2128 | * @mtd: mtd info structure | 2147 | * @mtd: mtd info structure |
2129 | * @chip: nand chip info structure | 2148 | * @chip: nand chip info structure |
2130 | * @offset: column address of subpage within the page | 2149 | * @offset: column address of subpage within the page |
@@ -2508,9 +2527,9 @@ static int panic_nand_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
2508 | /* Grab the device */ | 2527 | /* Grab the device */ |
2509 | panic_nand_get_device(chip, mtd, FL_WRITING); | 2528 | panic_nand_get_device(chip, mtd, FL_WRITING); |
2510 | 2529 | ||
2530 | memset(&ops, 0, sizeof(ops)); | ||
2511 | ops.len = len; | 2531 | ops.len = len; |
2512 | ops.datbuf = (uint8_t *)buf; | 2532 | ops.datbuf = (uint8_t *)buf; |
2513 | ops.oobbuf = NULL; | ||
2514 | ops.mode = MTD_OPS_PLACE_OOB; | 2533 | ops.mode = MTD_OPS_PLACE_OOB; |
2515 | 2534 | ||
2516 | ret = nand_do_write_ops(mtd, to, &ops); | 2535 | ret = nand_do_write_ops(mtd, to, &ops); |
@@ -2536,9 +2555,9 @@ static int nand_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
2536 | int ret; | 2555 | int ret; |
2537 | 2556 | ||
2538 | nand_get_device(mtd, FL_WRITING); | 2557 | nand_get_device(mtd, FL_WRITING); |
2558 | memset(&ops, 0, sizeof(ops)); | ||
2539 | ops.len = len; | 2559 | ops.len = len; |
2540 | ops.datbuf = (uint8_t *)buf; | 2560 | ops.datbuf = (uint8_t *)buf; |
2541 | ops.oobbuf = NULL; | ||
2542 | ops.mode = MTD_OPS_PLACE_OOB; | 2561 | ops.mode = MTD_OPS_PLACE_OOB; |
2543 | ret = nand_do_write_ops(mtd, to, &ops); | 2562 | ret = nand_do_write_ops(mtd, to, &ops); |
2544 | *retlen = ops.retlen; | 2563 | *retlen = ops.retlen; |