]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
omap: gpmc: 'nandecc sw' can use HAM1 or BCH8
authorAsh Charles <ashcharles@gmail.com>
Wed, 18 Feb 2015 19:25:11 +0000 (11:25 -0800)
committerLothar Waßmann <LW@KARO-electronics.de>
Tue, 1 Sep 2015 12:24:11 +0000 (14:24 +0200)
The 'nandecc sw' command selects a software-based error correction
algorithm.  By default, this is OMAP_ECC_HAM1_CODE_SW but some
platforms use OMAP_ECC_BCH8_CODE_HW_DETECTION_SW as their
software-based correction algorithm.  Allow a user to be specific e.g.
 # nandecc sw <hamming|bch8>
where 'hamming' is still the default.

Note: we don't just use CONFIG_NAND_OMAP_ECCSCHEME as it might be set
      to a hardware-based ECC scheme---a little strange when the user
      has requested 'sw' ECC.

Signed-off-by: Ash Charles <ashcharles@gmail.com>
arch/arm/cpu/armv7/omap3/board.c
drivers/mtd/nand/omap_gpmc.c

index 347947c4b3545bcfe1a583d0115a3f0faea17812..dd53b207f850e2fbe2c5064df414f4ed77457d5a 100644 (file)
@@ -347,7 +347,16 @@ static int do_switch_ecc(cmd_tbl_t * cmdtp, int flag, int argc, char * const arg
                                goto usage;
                }
        } else if (strncmp(argv[1], "sw", 2) == 0) {
-               omap_nand_switch_ecc(0, 0);
+               if (argc == 2) {
+                       omap_nand_switch_ecc(0, 1);
+               } else {
+                       if (strncmp(argv[2], "hamming", 7) == 0)
+                               omap_nand_switch_ecc(0, 1);
+                       else if (strncmp(argv[2], "bch8", 4) == 0)
+                               omap_nand_switch_ecc(0, 8);
+                       else
+                               goto usage;
+               }
        } else {
                goto usage;
        }
index 966fdbf81f5941026c90bc111fd8c1d1bc55f8c3..c6997dcf3b8be654c7d44a4f70f9be899d274073 100644 (file)
@@ -1099,8 +1099,18 @@ int __maybe_unused omap_nand_switch_ecc(uint32_t hardware, uint32_t eccstrength)
                        return -EINVAL;
                }
        } else {
-               err = omap_select_ecc_scheme(nand, OMAP_ECC_HAM1_CODE_SW,
+               if (eccstrength == 1) {
+                       err = omap_select_ecc_scheme(nand,
+                                       OMAP_ECC_HAM1_CODE_SW,
+                                       mtd->writesize, mtd->oobsize);
+               } else if (eccstrength == 8) {
+                       err = omap_select_ecc_scheme(nand,
+                                       OMAP_ECC_BCH8_CODE_HW_DETECTION_SW,
                                        mtd->writesize, mtd->oobsize);
+               } else {
+                       printf("nand: error: unsupported ECC scheme\n");
+                       return -EINVAL;
+               }
        }
 
        /* Update NAND handling after ECC mode switch */