From: Ilya Yanok <yanok@emcraft.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH] mtd: CONFIG_NAND_LAZY_SCAN option support
Date: Thu, 26 Jun 2008 13:50:02 +0400 [thread overview]
Message-ID: <4863664A.4020807@emcraft.com> (raw)
With this option set, the nand_init() doesn't scan NAND for bad blocks.
This allows one to avoid boot delays caused by the scanning procedure for
the boards which do not need NAND for booting.
To work with NAND having this option set, one should explicitely call
nand_lazy_scan_finish() before using the NAND chip. This function
automatically
called at the first access to NAND chip from the U-Boot command line.
Signed-off-by: Ilya Yanok <yanok@emcraft.com>
Signed-off-by: Yuri Tikhonov <yur@emcraft.com>
---
common/cmd_nand.c | 2 ++
drivers/mtd/nand/nand_base.c | 5 +++++
include/linux/mtd/nand.h | 4 ++++
include/nand.h | 14 ++++++++++++++
4 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/common/cmd_nand.c b/common/cmd_nand.c
index 37eb41b..6f5d13d 100644
--- a/common/cmd_nand.c
+++ b/common/cmd_nand.c
@@ -236,6 +236,8 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc,
char *argv[])
}
nand = &nand_info[nand_curr_device];
+ nand_lazy_scan_finish(nand);
+
if (strcmp(cmd, "bad") == 0) {
printf("\nDevice %d bad blocks:\n", nand_curr_device);
for (off = 0; off < nand->size; off += nand->erasesize)
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 740d3fc..f3ee705 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2652,8 +2652,13 @@ int nand_scan (struct mtd_info *mtd, int maxchips)
#if 0
mtd->owner = THIS_MODULE;
#endif
+#ifdef CONFIG_NAND_LAZY_SCAN
+ this->options &= ~NAND_BBT_SCANNED;
+ return 0;
+#else
/* Build bad block table */
return this->scan_bbt (mtd);
+#endif
}
/**
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 4cc4a7d..8a6d69e 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -450,6 +450,10 @@ struct nand_bbt_descr {
#define NAND_BBT_SAVECONTENT 0x00002000
/* Search good / bad pattern on the first and the second page */
#define NAND_BBT_SCAN2NDPAGE 0x00004000
+#ifdef CONFIG_NAND_LAZY_SCAN
+/* bbt is already read */
+#define NAND_BBT_SCANNED 0x80000000
+#endif
/* The maximum number of blocks to scan for a bbt */
#define NAND_BBT_SCAN_MAXBLOCKS 4
diff --git a/include/nand.h b/include/nand.h
index 247d346..6d3e91a 100644
--- a/include/nand.h
+++ b/include/nand.h
@@ -122,4 +122,18 @@ int nand_get_lock_status(nand_info_t *meminfo,
ulong offset);
void board_nand_select_device(struct nand_chip *nand, int chip);
#endif
+#ifdef CONFIG_NAND_LAZY_SCAN
+static inline void nand_lazy_scan_finish(nand_info_t *info)
+{
+ struct nand_chip *chip = info->priv;
+
+ if (!(chip->options & NAND_BBT_SCANNED)) {
+ chip->scan_bbt(info);
+ chip->options |= NAND_BBT_SCANNED;
+ }
+}
+#else
+#define nand_lazy_scan_finish(info) do {} while(0)
+#endif
+
#endif
--
1.5.4.2
next reply other threads:[~2008-06-26 9:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-26 9:50 Ilya Yanok [this message]
2008-06-26 16:52 ` [U-Boot-Users] [PATCH] mtd: CONFIG_NAND_LAZY_SCAN option support Scott Wood
2008-06-30 14:10 ` [U-Boot-Users] [PATCH] mtd: CONFIG_NAND_LAZY_SCAN support (2nd rev) Ilya Yanok
2008-07-06 20:47 ` Wolfgang Denk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4863664A.4020807@emcraft.com \
--to=yanok@emcraft.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox