]> git.sur5r.net Git - u-boot/commitdiff
mtd: atmel_nand: pmecc: fix bug fail to correct bit error in 1024-bytes sector
authorWu, Josh <Josh.wu@atmel.com>
Fri, 23 Aug 2013 07:09:05 +0000 (15:09 +0800)
committerAndreas Bießmann <andreas.devel@googlemail.com>
Wed, 4 Sep 2013 15:07:21 +0000 (17:07 +0200)
The PMECC use BCH algorithm to correct error. In BCH algorithm, the
primitive polynomial value is GF(2^13) for 512-bytes sector size. And it is
GF(2^14) for 1024-bytes sector size.

This patch will choose correct degree of the remainders (13 or 14) for
different sector size.
Tested in AT91SAM9X5-EK with MLC nand flash.

More detail can be refered to section 5.4.1 of:
  AT91SAM ARM-based Embedded MPU Application Note
  <http://www.atmel.com/Images/doc11127.pdf>

Signed-off-by: Josh Wu <josh.wu@atmel.com>
Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>
drivers/mtd/nand/atmel_nand.c

index 96aca00ebc4c7aa3611630a3557a290b3d1339dd..da83f06e4734d186eb3661f8938bcad039e871a2 100644 (file)
@@ -827,7 +827,8 @@ static int atmel_pmecc_nand_init_params(struct nand_chip *nand,
        switch (mtd->writesize) {
        case 2048:
        case 4096:
-               host->pmecc_degree = PMECC_GF_DIMENSION_13;
+               host->pmecc_degree = (sector_size == 512) ?
+                       PMECC_GF_DIMENSION_13 : PMECC_GF_DIMENSION_14;
                host->pmecc_cw_len = (1 << host->pmecc_degree) - 1;
                host->pmecc_sector_number = mtd->writesize / sector_size;
                host->pmecc_bytes_per_sector = pmecc_get_ecc_bytes(