aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoger Quadros <rogerq@ti.com>2014-08-25 19:15:32 -0400
committerTony Lindgren <tony@atomide.com>2014-08-25 19:15:32 -0400
commit7d5929c1f34304ca5a970cfde8044053e56aa8c9 (patch)
tree411c3fa537815dd726d4123a59f208402260483f
parent52addcf9d6669fa439387610bc65c92fa0980cef (diff)
mtd: nand: omap: Revert to using software ECC by default
For v3.12 and prior, 1-bit Hamming code ECC via software was the default choice. Commit c66d039197e4 in v3.13 changed the behaviour to use 1-bit Hamming code via Hardware using a different ECC layout i.e. (ROM code layout) than what is used by software ECC. This ECC layout change causes NAND filesystems created in v3.12 and prior to be unusable in v3.13 and later. So revert back to using software ECC by default if an ECC scheme is not explicitely specified. This defect can be observed on the following boards during legacy boot -omap3beagle -omap3touchbook -overo -am3517crane -devkit8000 -ldp -3430sdp Signed-off-by: Roger Quadros <rogerq@ti.com> Tested-by: Grazvydas Ignotas <notasas@gmail.com> Signed-off-by: Tony Lindgren <tony@atomide.com>
-rw-r--r--arch/arm/mach-omap2/board-flash.c2
-rw-r--r--arch/arm/mach-omap2/gpmc-nand.c3
-rw-r--r--drivers/mtd/nand/omap2.c14
-rw-r--r--include/linux/platform_data/mtd-nand-omap2.h13
4 files changed, 25 insertions, 7 deletions
diff --git a/arch/arm/mach-omap2/board-flash.c b/arch/arm/mach-omap2/board-flash.c
index e87f2a83d6bf..2d245c2e641c 100644
--- a/arch/arm/mach-omap2/board-flash.c
+++ b/arch/arm/mach-omap2/board-flash.c
@@ -142,7 +142,7 @@ __init board_nand_init(struct mtd_partition *nand_parts, u8 nr_parts, u8 cs,
142 board_nand_data.nr_parts = nr_parts; 142 board_nand_data.nr_parts = nr_parts;
143 board_nand_data.devsize = nand_type; 143 board_nand_data.devsize = nand_type;
144 144
145 board_nand_data.ecc_opt = OMAP_ECC_HAM1_CODE_HW; 145 board_nand_data.ecc_opt = OMAP_ECC_HAM1_CODE_SW;
146 gpmc_nand_init(&board_nand_data, gpmc_t); 146 gpmc_nand_init(&board_nand_data, gpmc_t);
147} 147}
148#endif /* CONFIG_MTD_NAND_OMAP2 || CONFIG_MTD_NAND_OMAP2_MODULE */ 148#endif /* CONFIG_MTD_NAND_OMAP2 || CONFIG_MTD_NAND_OMAP2_MODULE */
diff --git a/arch/arm/mach-omap2/gpmc-nand.c b/arch/arm/mach-omap2/gpmc-nand.c
index 8897ad7035fd..cb7764314f17 100644
--- a/arch/arm/mach-omap2/gpmc-nand.c
+++ b/arch/arm/mach-omap2/gpmc-nand.c
@@ -49,7 +49,8 @@ static bool gpmc_hwecc_bch_capable(enum omap_ecc ecc_opt)
49 return 0; 49 return 0;
50 50
51 /* legacy platforms support only HAM1 (1-bit Hamming) ECC scheme */ 51 /* legacy platforms support only HAM1 (1-bit Hamming) ECC scheme */
52 if (ecc_opt == OMAP_ECC_HAM1_CODE_HW) 52 if (ecc_opt == OMAP_ECC_HAM1_CODE_HW ||
53 ecc_opt == OMAP_ECC_HAM1_CODE_SW)
53 return 1; 54 return 1;
54 else 55 else
55 return 0; 56 return 0;
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index f0ed92e210a1..4dd617897eee 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -1794,9 +1794,12 @@ static int omap_nand_probe(struct platform_device *pdev)
1794 } 1794 }
1795 1795
1796 /* populate MTD interface based on ECC scheme */ 1796 /* populate MTD interface based on ECC scheme */
1797 nand_chip->ecc.layout = &omap_oobinfo;
1798 ecclayout = &omap_oobinfo; 1797 ecclayout = &omap_oobinfo;
1799 switch (info->ecc_opt) { 1798 switch (info->ecc_opt) {
1799 case OMAP_ECC_HAM1_CODE_SW:
1800 nand_chip->ecc.mode = NAND_ECC_SOFT;
1801 break;
1802
1800 case OMAP_ECC_HAM1_CODE_HW: 1803 case OMAP_ECC_HAM1_CODE_HW:
1801 pr_info("nand: using OMAP_ECC_HAM1_CODE_HW\n"); 1804 pr_info("nand: using OMAP_ECC_HAM1_CODE_HW\n");
1802 nand_chip->ecc.mode = NAND_ECC_HW; 1805 nand_chip->ecc.mode = NAND_ECC_HW;
@@ -1848,7 +1851,7 @@ static int omap_nand_probe(struct platform_device *pdev)
1848 nand_chip->ecc.priv = nand_bch_init(mtd, 1851 nand_chip->ecc.priv = nand_bch_init(mtd,
1849 nand_chip->ecc.size, 1852 nand_chip->ecc.size,
1850 nand_chip->ecc.bytes, 1853 nand_chip->ecc.bytes,
1851 &nand_chip->ecc.layout); 1854 &ecclayout);
1852 if (!nand_chip->ecc.priv) { 1855 if (!nand_chip->ecc.priv) {
1853 pr_err("nand: error: unable to use s/w BCH library\n"); 1856 pr_err("nand: error: unable to use s/w BCH library\n");
1854 err = -EINVAL; 1857 err = -EINVAL;
@@ -1923,7 +1926,7 @@ static int omap_nand_probe(struct platform_device *pdev)
1923 nand_chip->ecc.priv = nand_bch_init(mtd, 1926 nand_chip->ecc.priv = nand_bch_init(mtd,
1924 nand_chip->ecc.size, 1927 nand_chip->ecc.size,
1925 nand_chip->ecc.bytes, 1928 nand_chip->ecc.bytes,
1926 &nand_chip->ecc.layout); 1929 &ecclayout);
1927 if (!nand_chip->ecc.priv) { 1930 if (!nand_chip->ecc.priv) {
1928 pr_err("nand: error: unable to use s/w BCH library\n"); 1931 pr_err("nand: error: unable to use s/w BCH library\n");
1929 err = -EINVAL; 1932 err = -EINVAL;
@@ -2012,6 +2015,9 @@ static int omap_nand_probe(struct platform_device *pdev)
2012 goto return_error; 2015 goto return_error;
2013 } 2016 }
2014 2017
2018 if (info->ecc_opt == OMAP_ECC_HAM1_CODE_SW)
2019 goto scan_tail;
2020
2015 /* all OOB bytes from oobfree->offset till end off OOB are free */ 2021 /* all OOB bytes from oobfree->offset till end off OOB are free */
2016 ecclayout->oobfree->length = mtd->oobsize - ecclayout->oobfree->offset; 2022 ecclayout->oobfree->length = mtd->oobsize - ecclayout->oobfree->offset;
2017 /* check if NAND device's OOB is enough to store ECC signatures */ 2023 /* check if NAND device's OOB is enough to store ECC signatures */
@@ -2021,7 +2027,9 @@ static int omap_nand_probe(struct platform_device *pdev)
2021 err = -EINVAL; 2027 err = -EINVAL;
2022 goto return_error; 2028 goto return_error;
2023 } 2029 }
2030 nand_chip->ecc.layout = ecclayout;
2024 2031
2032scan_tail:
2025 /* second phase scan */ 2033 /* second phase scan */
2026 if (nand_scan_tail(mtd)) { 2034 if (nand_scan_tail(mtd)) {
2027 err = -ENXIO; 2035 err = -ENXIO;
diff --git a/include/linux/platform_data/mtd-nand-omap2.h b/include/linux/platform_data/mtd-nand-omap2.h
index 660c029d694f..16ec262dfcc8 100644
--- a/include/linux/platform_data/mtd-nand-omap2.h
+++ b/include/linux/platform_data/mtd-nand-omap2.h
@@ -21,8 +21,17 @@ enum nand_io {
21}; 21};
22 22
23enum omap_ecc { 23enum omap_ecc {
24 /* 1-bit ECC calculation by GPMC, Error detection by Software */ 24 /*
25 OMAP_ECC_HAM1_CODE_HW = 0, 25 * 1-bit ECC: calculation and correction by SW
26 * ECC stored at end of spare area
27 */
28 OMAP_ECC_HAM1_CODE_SW = 0,
29
30 /*
31 * 1-bit ECC: calculation by GPMC, Error detection by Software
32 * ECC layout compatible with ROM code layout
33 */
34 OMAP_ECC_HAM1_CODE_HW,
26 /* 4-bit ECC calculation by GPMC, Error detection by Software */ 35 /* 4-bit ECC calculation by GPMC, Error detection by Software */
27 OMAP_ECC_BCH4_CODE_HW_DETECTION_SW, 36 OMAP_ECC_BCH4_CODE_HW_DETECTION_SW,
28 /* 4-bit ECC calculation by GPMC, Error detection by ELM */ 37 /* 4-bit ECC calculation by GPMC, Error detection by ELM */