aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2016-09-15 04:32:45 -0400
committerBoris Brezillon <boris.brezillon@free-electrons.com>2016-09-23 03:35:16 -0400
commit2f94abfe35b210e7711af9202a3dcfc9e779219a (patch)
tree070e4edf10d03b98550c527c1eceb7f6c67e4792
parent79022591839f110f465cac0223e117b91d47d5db (diff)
mtd: nand: Create a NAND reset function
When NAND devices are resetted some initialization may have to be done, like for example they have to be configured for the timing mode that shall be used. To get a common place where this initialization can be implemented create a nand_reset() function. This currently only issues a NAND_CMD_RESET to the NAND device. The places issuing this command manually are replaced with a call to nand_reset(). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
-rw-r--r--drivers/mtd/nand/nand_base.c25
-rw-r--r--include/linux/mtd/nand.h4
2 files changed, 24 insertions, 5 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 108adefcc8cc..1a6310573ab4 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -948,6 +948,21 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *chip)
948} 948}
949 949
950/** 950/**
951 * nand_reset - Reset and initialize a NAND device
952 * @chip: The NAND chip
953 *
954 * Returns 0 for success or negative error code otherwise
955 */
956int nand_reset(struct nand_chip *chip)
957{
958 struct mtd_info *mtd = nand_to_mtd(chip);
959
960 chip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1);
961
962 return 0;
963}
964
965/**
951 * __nand_unlock - [REPLACEABLE] unlocks specified locked blocks 966 * __nand_unlock - [REPLACEABLE] unlocks specified locked blocks
952 * @mtd: mtd info 967 * @mtd: mtd info
953 * @ofs: offset to start unlock from 968 * @ofs: offset to start unlock from
@@ -1025,7 +1040,7 @@ int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
1025 * some operation can also clear the bit 7 of status register 1040 * some operation can also clear the bit 7 of status register
1026 * eg. erase/program a locked block 1041 * eg. erase/program a locked block
1027 */ 1042 */
1028 chip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1); 1043 nand_reset(chip);
1029 1044
1030 /* Check, if it is write protected */ 1045 /* Check, if it is write protected */
1031 if (nand_check_wp(mtd)) { 1046 if (nand_check_wp(mtd)) {
@@ -1084,7 +1099,7 @@ int nand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
1084 * some operation can also clear the bit 7 of status register 1099 * some operation can also clear the bit 7 of status register
1085 * eg. erase/program a locked block 1100 * eg. erase/program a locked block
1086 */ 1101 */
1087 chip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1); 1102 nand_reset(chip);
1088 1103
1089 /* Check, if it is write protected */ 1104 /* Check, if it is write protected */
1090 if (nand_check_wp(mtd)) { 1105 if (nand_check_wp(mtd)) {
@@ -2782,7 +2797,7 @@ static int nand_do_write_oob(struct mtd_info *mtd, loff_t to,
2782 * if we don't do this. I have no clue why, but I seem to have 'fixed' 2797 * if we don't do this. I have no clue why, but I seem to have 'fixed'
2783 * it in the doc2000 driver in August 1999. dwmw2. 2798 * it in the doc2000 driver in August 1999. dwmw2.
2784 */ 2799 */
2785 chip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1); 2800 nand_reset(chip);
2786 2801
2787 /* Check, if it is write protected */ 2802 /* Check, if it is write protected */
2788 if (nand_check_wp(mtd)) { 2803 if (nand_check_wp(mtd)) {
@@ -3822,7 +3837,7 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
3822 * Reset the chip, required by some chips (e.g. Micron MT29FxGxxxxx) 3837 * Reset the chip, required by some chips (e.g. Micron MT29FxGxxxxx)
3823 * after power-up. 3838 * after power-up.
3824 */ 3839 */
3825 chip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1); 3840 nand_reset(chip);
3826 3841
3827 /* Send the command for reading device ID */ 3842 /* Send the command for reading device ID */
3828 chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1); 3843 chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1);
@@ -4163,7 +4178,7 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips,
4163 for (i = 1; i < maxchips; i++) { 4178 for (i = 1; i < maxchips; i++) {
4164 chip->select_chip(mtd, i); 4179 chip->select_chip(mtd, i);
4165 /* See comment in nand_get_flash_type for reset */ 4180 /* See comment in nand_get_flash_type for reset */
4166 chip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1); 4181 nand_reset(chip);
4167 /* Send the command for reading device ID */ 4182 /* Send the command for reading device ID */
4168 chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1); 4183 chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1);
4169 /* Read manufacturer and device IDs */ 4184 /* Read manufacturer and device IDs */
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 28c1833ad708..73ccbf6e057c 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -1100,4 +1100,8 @@ int nand_read_oob_std(struct mtd_info *mtd, struct nand_chip *chip, int page);
1100/* Default read_oob syndrome implementation */ 1100/* Default read_oob syndrome implementation */
1101int nand_read_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip, 1101int nand_read_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
1102 int page); 1102 int page);
1103
1104/* Reset and initialize a NAND device */
1105int nand_reset(struct nand_chip *chip);
1106
1103#endif /* __LINUX_MTD_NAND_H */ 1107#endif /* __LINUX_MTD_NAND_H */