summaryrefslogtreecommitdiff
path: root/target/linux/xburst/patches-3.10/002-NAND-Optimize-NAND_ECC_HW_OOB_FIRST-read.patch
blob: 57f53b7ab139b993df77c30c5994b0e99e2744f7 (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
From f2b7099d3986e59aab5792cecc052e440caf2cdd Mon Sep 17 00:00:00 2001
From: Lars-Peter Clausen <lars@metafoo.de>
Date: Sat, 26 Feb 2011 15:30:07 +0100
Subject: [PATCH 02/16] NAND: Optimize NAND_ECC_HW_OOB_FIRST read

Avoid sending unnecessary READ commands to the chip.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/mtd/nand/nand_base.c |   17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -1278,9 +1278,16 @@ static int nand_read_page_hwecc_oob_firs
 	unsigned int max_bitflips = 0;
 
 	/* Read the OOB area first */
-	chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page);
-	chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
-	chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page);
+	/* Read the OOB area first */
+	if (mtd->writesize > 512) {
+		chip->cmdfunc(mtd, NAND_CMD_READ0, mtd->writesize, page);
+		chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
+		chip->cmdfunc(mtd, NAND_CMD_RNDOUT, 0, -1);
+	} else {
+		chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page);
+		chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
+		chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page);
+	}
 
 	for (i = 0; i < chip->ecc.total; i++)
 		ecc_code[i] = chip->oob_poi[eccpos[i]];
@@ -1455,7 +1462,9 @@ static int nand_do_read_ops(struct mtd_i
 		if (realpage != chip->pagebuf || oob) {
 			bufpoi = aligned ? buf : chip->buffers->databuf;
 
-			chip->cmdfunc(mtd, NAND_CMD_READ0, 0x00, page);
+			if (chip->ecc.mode != NAND_ECC_HW_OOB_FIRST) {
+				chip->cmdfunc(mtd, NAND_CMD_READ0, 0x00, page);
+			}
 
 			/*
 			 * Now read the page into the buffer.  Absent an error,