From f3f81740815d9207356cb4fcddc3196c7cbadb72 Mon Sep 17 00:00:00 2001
From: Holger Freyther <zecke@openmoko.org>
Date: Wed, 19 Nov 2008 17:10:51 +0000
Subject: [PATCH 03/69] mtd: s3c2410_nand: Add config option to disable hw ecc at runtime

This patch adds a flag to the s3c2410_nand platform data, which configures
whether hardware ecc is used for that chip.

Currently hardware ecc is used if it was compiled into the kernel. But if you
want to build a kernel which runs on multiple devices you might have a
configuration where you have devices which require hw ecc as well as devices
which want software ecc.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 arch/arm/plat-samsung/include/plat/nand.h |    1 +
 drivers/mtd/nand/s3c2410.c                |    2 +-
 2 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/arm/plat-samsung/include/plat/nand.h b/arch/arm/plat-samsung/include/plat/nand.h
index b64115f..cbdc8f0 100644
--- a/arch/arm/plat-samsung/include/plat/nand.h
+++ b/arch/arm/plat-samsung/include/plat/nand.h
@@ -49,6 +49,7 @@ struct s3c2410_platform_nand {
 	int	twrph1;	/* time for release CLE/ALE from nWE/nOE inactive */
 
 	unsigned int	ignore_unset_ecc:1;
+	unsigned int	software_ecc:1; /* force software ecc at runtime */
 
 	int			nr_sets;
 	struct s3c2410_nand_set *sets;
diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c
index 33d832d..cb5d2c0 100644
--- a/drivers/mtd/nand/s3c2410.c
+++ b/drivers/mtd/nand/s3c2410.c
@@ -813,7 +813,7 @@ static void s3c2410_nand_init_chip(struct s3c2410_nand_info *info,
 	nmtd->mtd.owner    = THIS_MODULE;
 	nmtd->set	   = set;
 
-	if (hardware_ecc) {
+	if (!(info->platform && info->platform->software_ecc) && hardware_ecc) {
 		chip->ecc.calculate = s3c2410_nand_calculate_ecc;
 		chip->ecc.correct   = s3c2410_nand_correct_data;
 		chip->ecc.mode	    = NAND_ECC_HW;
-- 
1.7.2.5

