[U-Boot] [PATCH 1/2] arm: omap: nand: introduce CONFIG_NAND_OMAP_SW_ECC_LEGACY

Nikita Kiryanov nikita at compulab.co.il
Wed Dec 11 17:57:43 CET 2013


Commit "mtd: nand: omap: enable BCH ECC scheme using ELM for generic platform"
(d016dc42cedbf6102e100fa9ecb58462edfb14f8) changed the way software ECC is
configured, both during boot, and during ecc switch, in a way that is not
backwards compatible with older systems (for example, X-Loader on CM-T35 relies
on the old behavior).

The culprit is the line which assigns ecc.size for software ECC.
Older version of omap_gpmc.c always assigned ecc.size = 0 when configuring for
software ecc, relying on nand_scan_tail() to select a default for ecc.size
(256), while the new version of omap_gpmc.c assigns ecc.size = pagesize, which
is likely to not be 256.

With this change, "nandecc sw" no longer sets up software ECC the old way,
which makes it unusable to those who rely on the old behavior, and if the user
wants to default to hardware ECC, the old software ECC configuration becomes
completely unattainable.

To provide backwards compatibility, introduce CONFIG_NAND_OMAP_SW_ECC_LEGACY.
If this CONFIG option is set, omap_select_ecc_scheme() will assign the old
default to ecc.size, instead of the value of pagesize.

Cc: Igor Grinberg <grinberg at compulab.co.il>
Cc: Tom Rini <trini at ti.com>
Cc: Scott Wood <scottwood at freescale.com>
Cc: Pekon Gupta <pekon at ti.com>
Signed-off-by: Nikita Kiryanov <nikita at compulab.co.il>
---
 doc/README.nand              | 7 +++++++
 drivers/mtd/nand/omap_gpmc.c | 4 ++++
 2 files changed, 11 insertions(+)

diff --git a/doc/README.nand b/doc/README.nand
index b91f198..a115260 100644
--- a/doc/README.nand
+++ b/doc/README.nand
@@ -232,6 +232,13 @@ Platform specific options
 		- ecc calculation using GPMC hardware engine,
 		- error detection using ELM hardware engine.
 
+   CONFIG_NAND_OMAP_SW_ECC_LEGACY
+   	On OMAP platforms, this CONFIG is used to force pre v2014.01
+   	configuration of software ECC. This is necessary for old systems which
+   	rely on the old behavior (such as systems that boot with X-Loader).
+   	Use this CONFIG if you have an old software stack and are having
+   	problems reading U-Boot data that was written using software ECC.
+
 NOTE:
 =====
 
diff --git a/drivers/mtd/nand/omap_gpmc.c b/drivers/mtd/nand/omap_gpmc.c
index 23a961c..0eb65d5 100644
--- a/drivers/mtd/nand/omap_gpmc.c
+++ b/drivers/mtd/nand/omap_gpmc.c
@@ -774,7 +774,11 @@ static int omap_select_ecc_scheme(struct nand_chip *nand,
 		bch_priv.type		= 0;
 		nand->ecc.mode		= NAND_ECC_SOFT;
 		nand->ecc.layout	= NULL;
+#ifdef CONFIG_NAND_OMAP_SW_ECC_LEGACY
+		nand->ecc.size		= 256;
+#else
 		nand->ecc.size		= pagesize;
+#endif
 		bch->ecc_scheme		= OMAP_ECC_HAM1_CODE_SW;
 		break;
 
-- 
1.8.1.2



More information about the U-Boot mailing list