summaryrefslogtreecommitdiff
path: root/recipes/u-boot/u-boot-mkimage-openmoko-native/bbt-scan-second.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes/u-boot/u-boot-mkimage-openmoko-native/bbt-scan-second.patch')
-rw-r--r--recipes/u-boot/u-boot-mkimage-openmoko-native/bbt-scan-second.patch69
1 files changed, 69 insertions, 0 deletions
diff --git a/recipes/u-boot/u-boot-mkimage-openmoko-native/bbt-scan-second.patch b/recipes/u-boot/u-boot-mkimage-openmoko-native/bbt-scan-second.patch
new file mode 100644
index 0000000000..37b2807908
--- /dev/null
+++ b/recipes/u-boot/u-boot-mkimage-openmoko-native/bbt-scan-second.patch
@@ -0,0 +1,69 @@
+Scan also the second OOB page for bad block information.
+
+board/neo1973/gta01/nand.c (board_nand_init): added board-specific badblock
+ pattern which sets NAND_BBT_SCAN2NDPAGE
+drivers/nand/nand_base.c (nand_block_bad): also consider the second page in a
+ block if NAND_BBT_SCAN2NDPAGE is set
+
+- Werner Almesberger <werner@openmoko.org>
+
+Index: u-boot/board/neo1973/gta01/nand.c
+===================================================================
+--- u-boot.orig/board/neo1973/gta01/nand.c
++++ u-boot/board/neo1973/gta01/nand.c
+@@ -113,9 +113,23 @@
+ }
+
+
++/* Derived from drivers/nand/nand_bbt.c:smallpage_flashbased */
++
++static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
++
++static struct nand_bbt_descr badblock_pattern = {
++ .options =
++ NAND_BBT_SCANEMPTY | NAND_BBT_SCANALLPAGES | NAND_BBT_SCAN2NDPAGE,
++ .offs = 5,
++ .len = 1,
++ .pattern = scan_ff_pattern
++};
++
++
+ int board_nand_init(struct nand_chip *nand)
+ {
+ nand->read_otp = samsung_nand_read_otp;
+ nand->write_otp = samsung_nand_write_otp;
++ nand->badblock_pattern = &badblock_pattern;
+ return s3c24x0_nand_init(nand);
+ }
+Index: u-boot/drivers/nand/nand_base.c
+===================================================================
+--- u-boot.orig/drivers/nand/nand_base.c
++++ u-boot/drivers/nand/nand_base.c
+@@ -421,7 +421,7 @@
+ *
+ * Check, if the block is bad.
+ */
+-static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
++static int nand_block_bad_page(struct mtd_info *mtd, loff_t ofs, int getchip)
+ {
+ int page, chipnr, res = 0;
+ struct nand_chip *this = mtd->priv;
+@@ -460,6 +460,18 @@
+ return res;
+ }
+
++static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
++{
++ struct nand_chip *this = mtd->priv;
++
++ if (nand_block_bad_page(mtd, ofs, getchip))
++ return 1;
++ if (this->badblock_pattern->options & NAND_BBT_SCAN2NDPAGE &&
++ nand_block_bad_page(mtd, ofs+(1 << this->page_shift), getchip))
++ return 1;
++ return 0;
++}
++
+ /**
+ * nand_default_block_markbad - [DEFAULT] mark a block bad
+ * @mtd: MTD device structure