Commit 1c03dcc106f16fd08e88869b62b2ed37c3c52148

Authored by Philip, Avinash
Committed by Hebbar, Gururaja
1 parent 04c001b04e
Exists in master

arch:arm:nand - 14 byte ECC support for BCH8

14 bytes of ECC is provided for every 512 byte even though 13 byte is the
actual requirement. This is to synchronize the ECC layout with U-boot.
Extra byte is cleared to 0.

Signed-off-by: Philip, Avinash <avinashphilip@ti.com>
Signed-off-by: Hebbar, Gururaja <gururaja.hebbar@ti.com>

Showing 2 changed files with 13 additions and 5 deletions Side-by-side Diff

drivers/mtd/nand/nand_base.c
... ... @@ -1983,6 +1983,7 @@
1983 1983 const uint8_t *p = buf;
1984 1984 uint32_t *eccpos = chip->ecc.layout->eccpos;
1985 1985  
  1986 + memset(ecc_calc, 0, eccsteps * eccbytes);
1986 1987 for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {
1987 1988 chip->ecc.hwctl(mtd, NAND_ECC_WRITE);
1988 1989 chip->write_buf(mtd, p, eccsize);
drivers/mtd/nand/omap2.c
... ... @@ -102,7 +102,7 @@
102 102 #define MAX_HWECC_BYTES_OOB_64 24
103 103 #define JFFS2_CLEAN_MARKER_OFFSET 0x2
104 104 #define BCH_ECC_POS 0x2
105   -#define BCH_JFFS2_CLEAN_MARKER_OFFSET 0x36
  105 +#define BCH_JFFS2_CLEAN_MARKER_OFFSET 0x3a
106 106  
107 107 static const char *part_probes[] = { "cmdlinepart", NULL };
108 108  
... ... @@ -820,6 +820,8 @@
820 820 uint32_t data_pos;
821 821 uint32_t oob_pos;
822 822  
  823 + struct omap_nand_info *info = container_of(mtd, struct omap_nand_info,
  824 + mtd);
823 825 data_pos = 0;
824 826 /* oob area start */
825 827 oob_pos = (eccsize * eccsteps) + chip->ecc.layout->eccpos[0];
... ... @@ -833,7 +835,12 @@
833 835  
834 836 /* read respective ecc from oob area */
835 837 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, oob_pos, page);
836   - chip->read_buf(mtd, oob, eccbytes);
  838 +
  839 + if (info->ecc_opt == OMAP_ECC_BCH8_CODE_HW) {
  840 + chip->read_buf(mtd, oob, 13);
  841 + oob++;
  842 + } else
  843 + chip->read_buf(mtd, oob, eccbytes);
837 844 /* read syndrome */
838 845 chip->ecc.calculate(mtd, p, &ecc_calc[i]);
839 846  
... ... @@ -983,8 +990,8 @@
983 990 }
984 991  
985 992 stat += count;
986   - calc_ecc = calc_ecc + eccsize;
987   - read_ecc = read_ecc + eccsize;
  993 + calc_ecc = calc_ecc + 14;
  994 + read_ecc = read_ecc + 14;
988 995 dat += BCH8_ECC_BYTES;
989 996 }
990 997 break;
... ... @@ -1226,7 +1233,7 @@
1226 1233 info->nand.ecc.bytes = 4*7;
1227 1234 info->nand.ecc.size = 4*512;
1228 1235 } else if (pdata->ecc_opt == OMAP_ECC_BCH8_CODE_HW) {
1229   - info->nand.ecc.bytes = 13;
  1236 + info->nand.ecc.bytes = 14;
1230 1237 info->nand.ecc.size = 512;
1231 1238 info->nand.ecc.read_page = omap_read_page_bch;
1232 1239 } else {