Patchwork [RESEND,v5,4/5] omap: nand: ecc layout select from board file

login
register
mail settings
Submitter Sukumar Ghorai
Date Sept. 27, 2010, 2:11 p.m.
Message ID <1285596710-25658-5-git-send-email-s-ghorai@ti.com>
Download mbox | patch
Permalink /patch/65866/
State New
Headers show

Comments

Sukumar Ghorai - Sept. 27, 2010, 2:11 p.m.
This patch makes it possible to select sw or hw (different layout options)
ecc scheme supported by omap nand driver.  And hw ecc layout selected for
sdp and zoom boards, by default.

Signed-off-by: Vimal Singh <vimalsingh@ti.com>
Signed-off-by: Sukumar Ghorai <s-ghorai@ti.com>
---
 arch/arm/mach-omap2/board-flash.c      |    1 +
 arch/arm/plat-omap/include/plat/gpmc.h |    7 +++++++
 arch/arm/plat-omap/include/plat/nand.h |    2 ++
 drivers/mtd/nand/omap2.c               |   29 +++++++++++++----------------
 4 files changed, 23 insertions(+), 16 deletions(-)
Grazvydas Ignotas - Nov. 3, 2010, 1:02 p.m.
On Mon, Sep 27, 2010 at 5:11 PM, Sukumar Ghorai <s-ghorai@ti.com> wrote:
> This patch makes it possible to select sw or hw (different layout options)
> ecc scheme supported by omap nand driver.  And hw ecc layout selected for
> sdp and zoom boards, by default.
>
> Signed-off-by: Vimal Singh <vimalsingh@ti.com>
> Signed-off-by: Sukumar Ghorai <s-ghorai@ti.com>

Any news on this? Commit 2c01946c accidentally (?) enabled hardware
ECC and now my board is broken, as the driver always used sw ecc and
my NAND partitions are formatted accordingly. We should at least
switch the default back to sw ecc, don't you think?
Sukumar Ghorai - Nov. 4, 2010, 1:02 a.m.
> -----Original Message-----
> From: Grazvydas Ignotas [mailto:notasas@gmail.com]
> Sent: Wednesday, November 03, 2010 6:33 PM
> To: Ghorai, Sukumar
> Cc: linux-omap@vger.kernel.org; linux-mtd@lists.infradead.org; linux-arm-
> kernel@lists.infradead.org; Vimal Singh; Artem.Bityutskiy@nokia.com
> Subject: Re: [PATCH RESEND v5 4/5] omap: nand: ecc layout select from
> board file
> 
> On Mon, Sep 27, 2010 at 5:11 PM, Sukumar Ghorai <s-ghorai@ti.com> wrote:
> > This patch makes it possible to select sw or hw (different layout
> options)
> > ecc scheme supported by omap nand driver.  And hw ecc layout selected
> for
> > sdp and zoom boards, by default.
> >
> > Signed-off-by: Vimal Singh <vimalsingh@ti.com>
> > Signed-off-by: Sukumar Ghorai <s-ghorai@ti.com>
> 
> Any news on this? Commit 2c01946c accidentally (?) enabled hardware
> ECC and now my board is broken, as the driver always used sw ecc and
> my NAND partitions are formatted accordingly. We should at least
> switch the default back to sw ecc, don't you think?
[Ghorai] 
1. which board you are working. 
2. and the default layout is the same as previous 
+       board_nand_data.ecc_opt         = OMAP_ECC_HAMMING_CODE_DIFF_LAYOUT;
Grazvydas Ignotas - Nov. 4, 2010, 9:52 a.m.
On Thu, Nov 4, 2010 at 3:02 AM, Ghorai, Sukumar <s-ghorai@ti.com> wrote:
>> -----Original Message-----
>> From: Grazvydas Ignotas [mailto:notasas@gmail.com]
>> Sent: Wednesday, November 03, 2010 6:33 PM
>> To: Ghorai, Sukumar
>> Cc: linux-omap@vger.kernel.org; linux-mtd@lists.infradead.org; linux-arm-
>> kernel@lists.infradead.org; Vimal Singh; Artem.Bityutskiy@nokia.com
>> Subject: Re: [PATCH RESEND v5 4/5] omap: nand: ecc layout select from
>> board file
>>
>> On Mon, Sep 27, 2010 at 5:11 PM, Sukumar Ghorai <s-ghorai@ti.com> wrote:
>> > This patch makes it possible to select sw or hw (different layout
>> options)
>> > ecc scheme supported by omap nand driver.  And hw ecc layout selected
>> for
>> > sdp and zoom boards, by default.
>> >
>> > Signed-off-by: Vimal Singh <vimalsingh@ti.com>
>> > Signed-off-by: Sukumar Ghorai <s-ghorai@ti.com>
>>
>> Any news on this? Commit 2c01946c accidentally (?) enabled hardware
>> ECC and now my board is broken, as the driver always used sw ecc and
>> my NAND partitions are formatted accordingly. We should at least
>> switch the default back to sw ecc, don't you think?
> [Ghorai]
> 1. which board you are working.
> 2. and the default layout is the same as previous
> +       board_nand_data.ecc_opt         = OMAP_ECC_HAMMING_CODE_DIFF_LAYOUT;

OMAP3 pandora.
What I wanted to say is that current mainline code has hw ECC forced
which is wrong for some boards, and this patch did not make into last
merge window, so NAND is broken. It would be good to take this patch
out of larger series you sent earlier and resend as a fix for -rc1, so
that NAND works on 2.6.37.  It's not too large and should probably be
ok for -rc2.
Sukumar Ghorai - Nov. 4, 2010, 10:15 a.m.
> -----Original Message-----
> From: Grazvydas Ignotas [mailto:notasas@gmail.com]
> Sent: Thursday, November 04, 2010 3:22 PM
> To: Ghorai, Sukumar
> Cc: linux-omap@vger.kernel.org; linux-mtd@lists.infradead.org; linux-arm-
> kernel@lists.infradead.org; Artem.Bityutskiy@nokia.com; Vimal Singh; Tony
> Lindgren
> Subject: Re: [PATCH RESEND v5 4/5] omap: nand: ecc layout select from
> board file
> 
> On Thu, Nov 4, 2010 at 3:02 AM, Ghorai, Sukumar <s-ghorai@ti.com> wrote:
> >> -----Original Message-----
> >> From: Grazvydas Ignotas [mailto:notasas@gmail.com]
> >> Sent: Wednesday, November 03, 2010 6:33 PM
> >> To: Ghorai, Sukumar
> >> Cc: linux-omap@vger.kernel.org; linux-mtd@lists.infradead.org; linux-
> arm-
> >> kernel@lists.infradead.org; Vimal Singh; Artem.Bityutskiy@nokia.com
> >> Subject: Re: [PATCH RESEND v5 4/5] omap: nand: ecc layout select from
> >> board file
> >>
> >> On Mon, Sep 27, 2010 at 5:11 PM, Sukumar Ghorai <s-ghorai@ti.com>
> wrote:
> >> > This patch makes it possible to select sw or hw (different layout
> >> options)
> >> > ecc scheme supported by omap nand driver.  And hw ecc layout selected
> >> for
> >> > sdp and zoom boards, by default.
> >> >
> >> > Signed-off-by: Vimal Singh <vimalsingh@ti.com>
> >> > Signed-off-by: Sukumar Ghorai <s-ghorai@ti.com>
> >>
> >> Any news on this? Commit 2c01946c accidentally (?) enabled hardware
> >> ECC and now my board is broken, as the driver always used sw ecc and
> >> my NAND partitions are formatted accordingly. We should at least
> >> switch the default back to sw ecc, don't you think?
> > [Ghorai]
> > 1. which board you are working.
> > 2. and the default layout is the same as previous
> > +       board_nand_data.ecc_opt         =
> OMAP_ECC_HAMMING_CODE_DIFF_LAYOUT;
> 
> OMAP3 pandora.
> What I wanted to say is that current mainline code has hw ECC forced
> which is wrong for some boards, and this patch did not make into last
> merge window, so NAND is broken. It would be good to take this patch
> out of larger series you sent earlier and resend as a fix for -rc1, so
> that NAND works on 2.6.37.  It's not too large and should probably be
> ok for -rc2.

[Ghorai] 
There is an additional patch I will send (with this series by next week) to select the ECC from board file, such that different board file can select the different ECC method. 

1. This is mainly for OMAP3630 onwards and has been aligned with many customers to use the hw ecc.

2. I did not understand how it's not working, would you please explain again? If you apply the series then it's storing the same ecc value in different location and generated from h/w module. 
File: arch/arm/mach-omap2/board-flash.c 
board_nand_data.ecc_opt         = OMAP_ECC_HAMMING_CODE_DIFF_LAYOUT;
change to -
board_nand_data.ecc_opt         = OMAP_ECC_HAMMING_CODE_HW;
- to switch back to s/w generated ECC stores at end of the spare area.

3. This patches are not upstream yet; send me the git-link you referring that these patches are available in 2.6.37?
Grazvydas Ignotas - Nov. 4, 2010, 10:56 a.m.
On Thu, Nov 4, 2010 at 12:15 PM, Ghorai, Sukumar <s-ghorai@ti.com> wrote:
>> -----Original Message-----
>> From: Grazvydas Ignotas [mailto:notasas@gmail.com]
>> OMAP3 pandora.
>> What I wanted to say is that current mainline code has hw ECC forced
>> which is wrong for some boards, and this patch did not make into last
>> merge window, so NAND is broken. It would be good to take this patch
>> out of larger series you sent earlier and resend as a fix for -rc1, so
>> that NAND works on 2.6.37.  It's not too large and should probably be
>> ok for -rc2.
>
> [Ghorai]
> There is an additional patch I will send (with this series by next week) to select the ECC from board file, such that different board file can select the different ECC method.
>
> 1. This is mainly for OMAP3630 onwards and has been aligned with many customers to use the hw ecc.
>
> 2. I did not understand how it's not working, would you please explain again? If you apply the series then it's storing the same ecc value in different location and generated from h/w module.

It most likely works (need to test more), I was just complaining it's
not upstream and sw ecc is broken on both 2.6.36 and 2.6.37.

> 3. This patches are not upstream yet; send me the git-link you referring that these patches are available in 2.6.37?
Correct, they are not upstream, so that's why suggest sending smaller
fix patch for 2.6.37-rc2, so that sw ecc works on 2.6.37.
Sukumar Ghorai - Nov. 4, 2010, 11:03 a.m.
> -----Original Message-----
> From: Grazvydas Ignotas [mailto:notasas@gmail.com]
> Sent: Thursday, November 04, 2010 4:27 PM
> To: Ghorai, Sukumar
> Cc: linux-omap@vger.kernel.org; linux-mtd@lists.infradead.org; linux-arm-
> kernel@lists.infradead.org; Artem.Bityutskiy@nokia.com; Vimal Singh; Tony
> Lindgren
> Subject: Re: [PATCH RESEND v5 4/5] omap: nand: ecc layout select from
> board file
> 
> On Thu, Nov 4, 2010 at 12:15 PM, Ghorai, Sukumar <s-ghorai@ti.com> wrote:
> >> -----Original Message-----
> >> From: Grazvydas Ignotas [mailto:notasas@gmail.com]
> >> OMAP3 pandora.
> >> What I wanted to say is that current mainline code has hw ECC forced
> >> which is wrong for some boards, and this patch did not make into last
> >> merge window, so NAND is broken. It would be good to take this patch
> >> out of larger series you sent earlier and resend as a fix for -rc1, so
> >> that NAND works on 2.6.37.  It's not too large and should probably be
> >> ok for -rc2.
> >
> > [Ghorai]
> > There is an additional patch I will send (with this series by next week)
> to select the ECC from board file, such that different board file can
> select the different ECC method.
> >
> > 1. This is mainly for OMAP3630 onwards and has been aligned with many
> customers to use the hw ecc.
> >
> > 2. I did not understand how it's not working, would you please explain
> again? If you apply the series then it's storing the same ecc value in
> different location and generated from h/w module.
> 
> It most likely works (need to test more), I was just complaining it's
> not upstream and sw ecc is broken on both 2.6.36 and 2.6.37.

[Ghorai] In 2.6.36, it's a s/w ecc by default and working in all platforms like - omap3430 SDP, zoom2, 3630SDP, ZOOM3.
So please explain more when you found that - sw ecc is broken on both 2.6.36  

> 
> > 3. This patches are not upstream yet; send me the git-link you referring
> that these patches are available in 2.6.37?
> Correct, they are not upstream, so that's why suggest sending smaller
> fix patch for 2.6.37-rc2, so that sw ecc works on 2.6.37.
Grazvydas Ignotas - Nov. 4, 2010, 11:11 a.m.
> [Ghorai] In 2.6.36, it's a s/w ecc by default and working in all platforms like - omap3430 SDP, zoom2, 3630SDP, ZOOM3.
> So please explain more when you found that - sw ecc is broken on both 2.6.36

It doesn't for me, see
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=drivers/mtd/nand/omap2.c;h=513e0a76a4a73866d52bba8151e43556a3b30a54;hb=f6f94e2ab1b33f0082ac22d71f66385a60d8157f

This is omap NAND driver at v2.6.36 tag, and it has
CONFIG_MTD_NAND_OMAP_HWECC forced.
Sukumar Ghorai - Nov. 4, 2010, 11:15 a.m.
> -----Original Message-----
> From: Grazvydas Ignotas [mailto:notasas@gmail.com]
> Sent: Thursday, November 04, 2010 4:42 PM
> To: Ghorai, Sukumar
> Cc: linux-omap@vger.kernel.org; linux-mtd@lists.infradead.org; linux-arm-
> kernel@lists.infradead.org; Artem.Bityutskiy@nokia.com; Vimal Singh; Tony
> Lindgren
> Subject: Re: [PATCH RESEND v5 4/5] omap: nand: ecc layout select from
> board file
> 
> > [Ghorai] In 2.6.36, it's a s/w ecc by default and working in all
> platforms like - omap3430 SDP, zoom2, 3630SDP, ZOOM3.
> > So please explain more when you found that - sw ecc is broken on both
> 2.6.36
> 
> It doesn't for me, see
> http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-
> 2.6.git;a=blob;f=drivers/mtd/nand/omap2.c;h=513e0a76a4a73866d52bba8151e435
> 56a3b30a54;hb=f6f94e2ab1b33f0082ac22d71f66385a60d8157f
> 
> This is omap NAND driver at v2.6.36 tag, and it has
> CONFIG_MTD_NAND_OMAP_HWECC forced.

[Ghorai] This is the same old code since log. And this portion of code not touched for 2.6.36.
And please let me know what kind of problem you are facing when you using 2.6.36; also let me know how to reproduce, I can check in my platform too.
Grazvydas Ignotas - Nov. 4, 2010, 11:32 a.m.
On Thu, Nov 4, 2010 at 1:15 PM, Ghorai, Sukumar <s-ghorai@ti.com> wrote:
>
>
>> -----Original Message-----
>> From: Grazvydas Ignotas [mailto:notasas@gmail.com]
>> Sent: Thursday, November 04, 2010 4:42 PM
>> To: Ghorai, Sukumar
>> Cc: linux-omap@vger.kernel.org; linux-mtd@lists.infradead.org; linux-arm-
>> kernel@lists.infradead.org; Artem.Bityutskiy@nokia.com; Vimal Singh; Tony
>> Lindgren
>> Subject: Re: [PATCH RESEND v5 4/5] omap: nand: ecc layout select from
>> board file
>>
>> > [Ghorai] In 2.6.36, it's a s/w ecc by default and working in all
>> platforms like - omap3430 SDP, zoom2, 3630SDP, ZOOM3.
>> > So please explain more when you found that - sw ecc is broken on both
>> 2.6.36
>>
>> It doesn't for me, see
>> http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-
>> 2.6.git;a=blob;f=drivers/mtd/nand/omap2.c;h=513e0a76a4a73866d52bba8151e435
>> 56a3b30a54;hb=f6f94e2ab1b33f0082ac22d71f66385a60d8157f
>>
>> This is omap NAND driver at v2.6.36 tag, and it has
>> CONFIG_MTD_NAND_OMAP_HWECC forced.
>
> [Ghorai] This is the same old code since log. And this portion of code not touched for 2.6.36.
> And please let me know what kind of problem you are facing when you using 2.6.36; also let me know how to reproduce, I can check in my platform too.

It has changed in 2.5.36, take a look how it was in 2.6.35, when it
worked for me:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=drivers/mtd/nand/omap2.c;h=ee87325c7712a8eeee4bbc683f93014c9901f337;hb=9fe6206f400646a2322096b56c59891d530e8d51

notice how 2.5.36 has CONFIG_MTD_NAND_OMAP_HWECC defined and 2.6.35 doesn't.

The test case is simple:
format and use NAND on 2.6.35 or earlier, works fine.
upgrade to 2.6.36 or 2.6.37-rc1 and try to mount the same NAND
partition - lots of ECC errors.
Sukumar Ghorai - Nov. 4, 2010, 12:52 p.m.
> -----Original Message-----
> From: Grazvydas Ignotas [mailto:notasas@gmail.com]
> Sent: Thursday, November 04, 2010 5:03 PM
> To: Ghorai, Sukumar
> Cc: linux-omap@vger.kernel.org; linux-mtd@lists.infradead.org; linux-arm-
> kernel@lists.infradead.org; Artem.Bityutskiy@nokia.com; Vimal Singh; Tony
> Lindgren
> Subject: Re: [PATCH RESEND v5 4/5] omap: nand: ecc layout select from
> board file
> 
> On Thu, Nov 4, 2010 at 1:15 PM, Ghorai, Sukumar <s-ghorai@ti.com> wrote:
> >
> >
> >> -----Original Message-----
> >> From: Grazvydas Ignotas [mailto:notasas@gmail.com]
> >> Sent: Thursday, November 04, 2010 4:42 PM
> >> To: Ghorai, Sukumar
> >> Cc: linux-omap@vger.kernel.org; linux-mtd@lists.infradead.org; linux-
> arm-
> >> kernel@lists.infradead.org; Artem.Bityutskiy@nokia.com; Vimal Singh;
> Tony
> >> Lindgren
> >> Subject: Re: [PATCH RESEND v5 4/5] omap: nand: ecc layout select from
> >> board file
> >>
> >> > [Ghorai] In 2.6.36, it's a s/w ecc by default and working in all
> >> platforms like - omap3430 SDP, zoom2, 3630SDP, ZOOM3.
> >> > So please explain more when you found that - sw ecc is broken on both
> >> 2.6.36
> >>
> >> It doesn't for me, see
> >> http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-
> >>
> 2.6.git;a=blob;f=drivers/mtd/nand/omap2.c;h=513e0a76a4a73866d52bba8151e435
> >> 56a3b30a54;hb=f6f94e2ab1b33f0082ac22d71f66385a60d8157f
> >>
> >> This is omap NAND driver at v2.6.36 tag, and it has
> >> CONFIG_MTD_NAND_OMAP_HWECC forced.
> >
> > [Ghorai] This is the same old code since log. And this portion of code
> not touched for 2.6.36.
> > And please let me know what kind of problem you are facing when you
> using 2.6.36; also let me know how to reproduce, I can check in my
> platform too.
> 
> It has changed in 2.5.36, take a look how it was in 2.6.35, when it
> worked for me:
> http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-
> 2.6.git;a=blob;f=drivers/mtd/nand/omap2.c;h=ee87325c7712a8eeee4bbc683f9301
> 4c9901f337;hb=9fe6206f400646a2322096b56c59891d530e8d51
> 
> notice how 2.5.36 has CONFIG_MTD_NAND_OMAP_HWECC defined and 2.6.35
> doesn't.
> 
> The test case is simple:
> format and use NAND on 2.6.35 or earlier, works fine.
> upgrade to 2.6.36 or 2.6.37-rc1 and try to mount the same NAND
> partition - lots of ECC errors.

[Ghorai] I tested this and working fine in zoom3.
 
And as you mentioned there may be an issue we need to identify, 
So remove this #define form 2.6.36 and let me know the test result.
Grazvydas Ignotas - Nov. 4, 2010, 3:54 p.m.
On Thu, Nov 4, 2010 at 2:52 PM, Ghorai, Sukumar <s-ghorai@ti.com> wrote:
>> -----Original Message-----
>> It has changed in 2.5.36, take a look how it was in 2.6.35, when it
>> worked for me:
>> http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-
>> 2.6.git;a=blob;f=drivers/mtd/nand/omap2.c;h=ee87325c7712a8eeee4bbc683f9301
>> 4c9901f337;hb=9fe6206f400646a2322096b56c59891d530e8d51
>>
>> notice how 2.5.36 has CONFIG_MTD_NAND_OMAP_HWECC defined and 2.6.35
>> doesn't.
>>
>> The test case is simple:
>> format and use NAND on 2.6.35 or earlier, works fine.
>> upgrade to 2.6.36 or 2.6.37-rc1 and try to mount the same NAND
>> partition - lots of ECC errors.
>
> [Ghorai] I tested this and working fine in zoom3.
>
> And as you mentioned there may be an issue we need to identify,
> So remove this #define form 2.6.36 and let me know the test result.

After removing #define it works, but only without
CONFIG_MTD_NAND_OMAP_PREFETCH. With prefetch enabled, sub-page reads
return ECC errors, for example:

nanddump -p -l 1024 -s 512 /dev/mtd3
ECC: 3 uncorrectable bitflip(s) at offset 0x00000200

nanddump -p -l 1024 -s 0 /dev/mtd3
nanddump -p -l 1024 -s 1024 /dev/mtd3
works ok.

Sub-pages need to be working for UBI, my NAND partitions are formatted
with UBIFS.

Patch

diff --git a/arch/arm/mach-omap2/board-flash.c b/arch/arm/mach-omap2/board-flash.c
index 2355e4a..ecd41ae 100644
--- a/arch/arm/mach-omap2/board-flash.c
+++ b/arch/arm/mach-omap2/board-flash.c
@@ -144,6 +144,7 @@  __init board_nand_init(struct mtd_partition *nand_parts, u8 nr_parts, u8 cs)
 	board_nand_data.cs		= cs;
 	board_nand_data.parts		= nand_parts;
 	board_nand_data.nr_parts	= nr_parts;
+	board_nand_data.ecc_opt		= OMAP_ECC_HAMMING_CODE_DIFF_LAYOUT;
 
 	board_nand_data.gpmc_irq = OMAP_GPMC_IRQ_BASE + cs;
 	gpmc_nand_init(&board_nand_data);
diff --git a/arch/arm/plat-omap/include/plat/gpmc.h b/arch/arm/plat-omap/include/plat/gpmc.h
index fb82335..54902d8 100644
--- a/arch/arm/plat-omap/include/plat/gpmc.h
+++ b/arch/arm/plat-omap/include/plat/gpmc.h
@@ -86,6 +86,13 @@ 
 #define PREFETCH_FIFOTHRESHOLD_MAX	0x40
 #define PREFETCH_FIFOTHRESHOLD(val)	(val << 8)
 
+enum omap_ecc{
+	OMAP_ECC_HAMMING_CODE_DIFF_LAYOUT = 0,
+		/* 1-bit s/w ecc and layout different from romcode */
+	OMAP_ECC_HAMMING_CODE_HW,/* 1-bit ecc, romcode layout */
+	OMAP_ECC_HAMMING_CODE_SW,/* 1-bit ecc, romcode layout */
+};
+
 /*
  * Note that all values in this struct are in nanoseconds, while
  * the register values are in gpmc_fck cycles.
diff --git a/arch/arm/plat-omap/include/plat/nand.h b/arch/arm/plat-omap/include/plat/nand.h
index 5e69463..d5b6fc6 100644
--- a/arch/arm/plat-omap/include/plat/nand.h
+++ b/arch/arm/plat-omap/include/plat/nand.h
@@ -8,6 +8,7 @@ 
  * published by the Free Software Foundation.
  */
 
+#include <plat/gpmc.h>
 #include <linux/mtd/partitions.h>
 
 struct omap_nand_platform_data {
@@ -23,6 +24,7 @@  struct omap_nand_platform_data {
 	int			gpmc_irq;
 	unsigned long		phys_base;
 	int			devsize;
+	enum omap_ecc           ecc_opt;
 };
 
 /* minimum size for IO mapping */
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 5ac7f7c..3fd9ee0 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -7,7 +7,6 @@ 
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
-#define CONFIG_MTD_NAND_OMAP_HWECC
 
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
@@ -659,8 +658,6 @@  static int omap_verify_buf(struct mtd_info *mtd, const u_char * buf, int len)
 	return 0;
 }
 
-#ifdef CONFIG_MTD_NAND_OMAP_HWECC
-
 /**
  * gen_true_ecc - This function will generate true ECC value
  * @ecc_buf: buffer to store ecc code
@@ -880,8 +877,6 @@  static void omap_enable_hwecc(struct mtd_info *mtd, int mode)
 	gpmc_enable_hwecc(info->gpmc_cs, mode, dev_width, info->nand.ecc.size);
 }
 
-#endif
-
 /**
  * omap_wait - wait until the command is done
  * @mtd: MTD device structure
@@ -1059,17 +1054,19 @@  static int __devinit omap_nand_probe(struct platform_device *pdev)
 	}
 	info->nand.verify_buf = omap_verify_buf;
 
-#ifdef CONFIG_MTD_NAND_OMAP_HWECC
-	info->nand.ecc.bytes		= 3;
-	info->nand.ecc.size		= 512;
-	info->nand.ecc.calculate	= omap_calculate_ecc;
-	info->nand.ecc.hwctl		= omap_enable_hwecc;
-	info->nand.ecc.correct		= omap_correct_data;
-	info->nand.ecc.mode		= NAND_ECC_HW;
-
-#else
-	info->nand.ecc.mode = NAND_ECC_SOFT;
-#endif
+	/* selsect the ecc type */
+	if ((pdata->ecc_opt == OMAP_ECC_HAMMING_CODE_DIFF_LAYOUT) ||
+		(pdata->ecc_opt == OMAP_ECC_HAMMING_CODE_HW)) {
+		info->nand.ecc.bytes		= 3;
+		info->nand.ecc.size		= 512;
+		info->nand.ecc.calculate	= omap_calculate_ecc;
+		info->nand.ecc.hwctl		= omap_enable_hwecc;
+		info->nand.ecc.correct		= omap_correct_data;
+		info->nand.ecc.mode		= NAND_ECC_HW;
+
+	} else if (pdata->ecc_opt == OMAP_ECC_HAMMING_CODE_SW) {
+		info->nand.ecc.mode = NAND_ECC_SOFT;
+	}
 
 	/* DIP switches on some boards change between 8 and 16 bit
 	 * bus widths for flash.  Try the other width if the first try fails.