summaryrefslogtreecommitdiff
path: root/meta/packages/uboot/u-boot-mkimage-openmoko-native/bbt-scan-second.patch
blob: 37b2807908b12b921958ff96da4a02a5f73c606d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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