aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand/nand_base.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-04-22 15:00:44 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-04-22 15:00:44 -0400
commita62d016cece2fce1d5e4eedf36b17f03a7a5c78e (patch)
treeac37b4835be5f4fe0e04611fdb40c85abb98ec78 /drivers/mtd/nand/nand_base.c
parent7c034dfd58bbc056280262887acf5b7a98944d0a (diff)
parent3e550d2396d9deef77328237ed992e19dcfefca5 (diff)
Merge tag 'for-linus-20150422' of git://git.infradead.org/linux-mtd
Pull MTD updates from Brian Norris: "Common MTD: - Add Kconfig option for keeping both the 'master' and 'partition' MTDs registered as devices. This would really make a better default if we could do it over, as it allows a lot more flexibility in (1) determining the flash topology of the system from user-space and (2) adding temporary partitions at runtime (ioctl(BLKPG)). Unfortunately, this would possibly cause user-space breakage, as it will cause renumbering of the /dev/mtdX devices. We'll see if we can change this in the future, as there have already been a few people looking for this feature, and I know others have just been working around our current limitations instead of fixing them this way. - Along with the previous change, add some additional information to sysfs, so user-space can read the offset of each partition within its master device SPI NOR: - add new device tree compatible binding to represent the mostly-compatible class of SPI NOR flash which can be detected by their extended JEDEC ID bytes, cutting down the duplication of our ID tables - misc. new IDs Various other miscellaneous fixes and changes" * tag 'for-linus-20150422' of git://git.infradead.org/linux-mtd: (53 commits) mtd: spi-nor: Add support for Macronix mx25u6435f serial flash mtd: spi-nor: Add support for Winbond w25q64dw serial flash mtd: spi-nor: add support for the Winbond W25X05 flash mtd: spi-nor: support en25s64 device mtd: m25p80: bind to "nor-jedec" ID, for auto-detection Documentation: devicetree: m25p80: add "nor-jedec" binding mtd: Make MTD tests cancelable mtd: mtd_oobtest: Fix bitflip_limit usage in test case 3 mtd: docg3: remove invalid __exit annotations mtd: fsl_ifc_nand: use msecs_to_jiffies for time conversion mtd: atmel_nand: don't map the ROM table if no pmecc table offset in DT mtd: atmel_nand: add a definition for the oob reserved bytes mtd: part: Remove partition overlap checks mtd: part: Add sysfs variable for offset of partition mtd: part: Create the master device node when partitioned mtd: ts5500_flash: Fix typo in MODULE_DESCRIPTION in ts5500_flash.c mtd: denali: Disable sub-page writes in Denali NAND driver mtd: pxa3xx_nand: cleanup wait_for_completion handling mtd: nand: gpmi: Check for scan_bbt() error mtd: nand: gpmi: fixup return type of wait_for_completion_timeout ...
Diffstat (limited to 'drivers/mtd/nand/nand_base.c')
-rw-r--r--drivers/mtd/nand/nand_base.c41
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)
566EXPORT_SYMBOL_GPL(nand_wait_ready); 566EXPORT_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 */
575static 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;