Commit f25ac66c528553a38d349c563d67d0eebbdd77f9

Authored by Siva Durga Prasad Paladugu
Committed by Michal Simek
1 parent cacb8a029f

nand: arasan_nfc: Use the calculated ecc address for updating ecc register

This patch corrects the ecc address calculation before updating
to ecc register. The ecc address has to be calculated based on
page, oob and ecc sizes of the device.

Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>

Showing 1 changed file with 5 additions and 2 deletions Side-by-side Diff

drivers/mtd/nand/arasan_nfc.c
... ... @@ -1133,7 +1133,7 @@
1133 1133 static int arasan_nand_ecc_init(struct mtd_info *mtd)
1134 1134 {
1135 1135 int found = -1;
1136   - u32 regval, eccpos_start, i;
  1136 + u32 regval, eccpos_start, i, eccaddr;
1137 1137 struct nand_chip *nand_chip = mtd_to_nand(mtd);
1138 1138  
1139 1139 for (i = 0; i < ARRAY_SIZE(ecc_matrix); i++) {
... ... @@ -1152,7 +1152,10 @@
1152 1152 if (found < 0)
1153 1153 return 1;
1154 1154  
1155   - regval = ecc_matrix[found].eccaddr |
  1155 + eccaddr = mtd->writesize + mtd->oobsize -
  1156 + ecc_matrix[found].eccsize;
  1157 +
  1158 + regval = eccaddr |
1156 1159 (ecc_matrix[found].eccsize << ARASAN_NAND_ECC_SIZE_SHIFT) |
1157 1160 (ecc_matrix[found].bch << ARASAN_NAND_ECC_BCH_SHIFT);
1158 1161 writel(regval, &arasan_nand_base->ecc_reg);