2c364e375bded662a83b41c68de7744d30f113c9
[openwrt.git] / target / linux / s3c24xx / patches-2.6.24 / 1279-From-5ee1ee9e1c8a652b0f9cde72ad5e547db87d4d67-Mon-Se.patch
1 From cb3cc53a76c7f1f7c827d048db7a849e77071515 Mon Sep 17 00:00:00 2001
2 From: Holger Freyther <zecke@openmoko.org>
3 Date: Wed, 13 Aug 2008 11:28:00 +0100
4 Subject: [PATCH] From 5ee1ee9e1c8a652b0f9cde72ad5e547db87d4d67 Mon Sep 17 00:00:00 2001
5  Subject: [PATCH] [gta02] Disable hardware ECC unless we get instructed to enable it
6       This is restoring the old behavior in regard to ECC. Even if
7       hardware ECC was compiled in we didn't use it. Make this a runtime
8       option. If the bootloader passes hardware_ecc we will enable the
9       hardware ECC for real.
10
11 ---
12  arch/arm/mach-s3c2440/mach-gta02.c |   19 +++++++++++++++++++
13  drivers/mtd/nand/s3c2410.c         |    2 +-
14  include/asm-arm/plat-s3c/nand.h    |    3 +++
15  3 files changed, 23 insertions(+), 1 deletions(-)
16
17 diff --git a/arch/arm/mach-s3c2440/mach-gta02.c b/arch/arm/mach-s3c2440/mach-gta02.c
18 index ff3c3c0..7d4cc67 100644
19 --- a/arch/arm/mach-s3c2440/mach-gta02.c
20 +++ b/arch/arm/mach-s3c2440/mach-gta02.c
21 @@ -882,6 +882,7 @@ static struct s3c2410_platform_nand gta02_nand_info = {
22         .twrph1         = 20,
23         .nr_sets        = ARRAY_SIZE(gta02_nand_sets),
24         .sets           = gta02_nand_sets,
25 +       .software_ecc   = 1,
26  };
27  
28  static struct s3c24xx_mci_pdata gta02_mmc_cfg = {
29 @@ -1546,6 +1547,20 @@ static irqreturn_t ar6000_wow_irq(int irq, void *param)
30         return IRQ_HANDLED;
31  }
32  
33 +/*
34 + * hardware_ecc=1|0
35 + */
36 +static char hardware_ecc_str[4] __initdata = "";
37 +
38 +static int __init hardware_ecc_setup(char *str)
39 +{
40 +       if (str)
41 +               strlcpy(hardware_ecc_str, str, sizeof(hardware_ecc_str));
42 +       return 1;
43 +}
44 +
45 +__setup("hardware_ecc=", hardware_ecc_setup);
46 +
47  static void __init gta02_machine_init(void)
48  {
49         int rc;
50 @@ -1565,6 +1580,10 @@ static void __init gta02_machine_init(void)
51  
52         spin_lock_init(&motion_irq_lock);
53  
54 +       /* do not force soft ecc if we are asked to use hardware_ecc */
55 +       if (hardware_ecc_str[0] == '1')
56 +               gta02_nand_info.software_ecc = 0;
57 +
58         s3c_device_usb.dev.platform_data = &gta02_usb_info;
59         s3c_device_nand.dev.platform_data = &gta02_nand_info;
60         s3c_device_sdi.dev.platform_data = &gta02_mmc_cfg;
61 diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c
62 index 495381c..4413d76 100644
63 --- a/drivers/mtd/nand/s3c2410.c
64 +++ b/drivers/mtd/nand/s3c2410.c
65 @@ -656,7 +656,7 @@ static void s3c2410_nand_init_chip(struct s3c2410_nand_info *info,
66         nmtd->mtd.owner    = THIS_MODULE;
67         nmtd->set          = set;
68  
69 -       if (hardware_ecc) {
70 +       if (!info->platform->software_ecc && hardware_ecc) {
71                 chip->ecc.calculate = s3c2410_nand_calculate_ecc;
72                 chip->ecc.correct   = s3c2410_nand_correct_data;
73                 chip->ecc.mode      = NAND_ECC_HW;
74 diff --git a/include/asm-arm/plat-s3c/nand.h b/include/asm-arm/plat-s3c/nand.h
75 index cb87f9e..676a061 100644
76 --- a/include/asm-arm/plat-s3c/nand.h
77 +++ b/include/asm-arm/plat-s3c/nand.h
78 @@ -42,6 +42,9 @@ struct s3c2410_platform_nand {
79         int                     nr_sets;
80         struct s3c2410_nand_set *sets;
81  
82 +       /* force software_ecc at runtime */
83 +       int     software_ecc;
84 +
85         void                    (*select_chip)(struct s3c2410_nand_set *,
86                                                int chip);
87  };
88 -- 
89 1.5.6.5
90