Lines Matching refs:ecc

546 	struct sunxi_nand_hw_ecc *data = nand->ecc.priv;  in sunxi_nfc_hw_ecc_enable()
582 struct nand_ecc_ctrl *ecc = &nand->ecc; in sunxi_nfc_hw_ecc_read_chunk() local
589 sunxi_nfc_read_buf(mtd, NULL, ecc->size); in sunxi_nfc_hw_ecc_read_chunk()
591 if (data_off + ecc->size != oob_off) in sunxi_nfc_hw_ecc_read_chunk()
608 memcpy_fromio(data, nfc->regs + NFC_RAM0_BASE, ecc->size); in sunxi_nfc_hw_ecc_read_chunk()
611 sunxi_nfc_read_buf(mtd, oob, ecc->bytes + 4); in sunxi_nfc_hw_ecc_read_chunk()
614 ret = nand_check_erased_ecc_chunk(data, ecc->size, in sunxi_nfc_hw_ecc_read_chunk()
615 oob, ecc->bytes + 4, in sunxi_nfc_hw_ecc_read_chunk()
616 NULL, 0, ecc->strength); in sunxi_nfc_hw_ecc_read_chunk()
633 *cur_off = oob_off + ecc->bytes + 4; in sunxi_nfc_hw_ecc_read_chunk()
642 struct nand_ecc_ctrl *ecc = &nand->ecc; in sunxi_nfc_hw_ecc_read_extra_oob() local
643 int offset = ((ecc->bytes + 4) * ecc->steps); in sunxi_nfc_hw_ecc_read_extra_oob()
670 struct nand_ecc_ctrl *ecc = &nand->ecc; in sunxi_nfc_hw_ecc_write_chunk() local
676 sunxi_nfc_write_buf(mtd, data, ecc->size); in sunxi_nfc_hw_ecc_write_chunk()
682 if (data_off + ecc->size != oob_off) in sunxi_nfc_hw_ecc_write_chunk()
697 *cur_off = oob_off + ecc->bytes + 4; in sunxi_nfc_hw_ecc_write_chunk()
706 struct nand_ecc_ctrl *ecc = &nand->ecc; in sunxi_nfc_hw_ecc_write_extra_oob() local
707 int offset = ((ecc->bytes + 4) * ecc->steps); in sunxi_nfc_hw_ecc_write_extra_oob()
726 struct nand_ecc_ctrl *ecc = &chip->ecc; in sunxi_nfc_hw_ecc_read_page() local
732 for (i = 0; i < ecc->steps; i++) { in sunxi_nfc_hw_ecc_read_page()
733 int data_off = i * ecc->size; in sunxi_nfc_hw_ecc_read_page()
734 int oob_off = i * (ecc->bytes + 4); in sunxi_nfc_hw_ecc_read_page()
758 struct nand_ecc_ctrl *ecc = &chip->ecc; in sunxi_nfc_hw_ecc_write_page() local
763 for (i = 0; i < ecc->steps; i++) { in sunxi_nfc_hw_ecc_write_page()
764 int data_off = i * ecc->size; in sunxi_nfc_hw_ecc_write_page()
765 int oob_off = i * (ecc->bytes + 4); in sunxi_nfc_hw_ecc_write_page()
789 struct nand_ecc_ctrl *ecc = &chip->ecc; in sunxi_nfc_hw_syndrome_ecc_read_page() local
795 for (i = 0; i < ecc->steps; i++) { in sunxi_nfc_hw_syndrome_ecc_read_page()
796 int data_off = i * (ecc->size + ecc->bytes + 4); in sunxi_nfc_hw_syndrome_ecc_read_page()
797 int oob_off = data_off + ecc->size; in sunxi_nfc_hw_syndrome_ecc_read_page()
798 u8 *data = buf + (i * ecc->size); in sunxi_nfc_hw_syndrome_ecc_read_page()
799 u8 *oob = chip->oob_poi + (i * (ecc->bytes + 4)); in sunxi_nfc_hw_syndrome_ecc_read_page()
821 struct nand_ecc_ctrl *ecc = &chip->ecc; in sunxi_nfc_hw_syndrome_ecc_write_page() local
826 for (i = 0; i < ecc->steps; i++) { in sunxi_nfc_hw_syndrome_ecc_write_page()
827 int data_off = i * (ecc->size + ecc->bytes + 4); in sunxi_nfc_hw_syndrome_ecc_write_page()
828 int oob_off = data_off + ecc->size; in sunxi_nfc_hw_syndrome_ecc_write_page()
829 const u8 *data = buf + (i * ecc->size); in sunxi_nfc_hw_syndrome_ecc_write_page()
830 const u8 *oob = chip->oob_poi + (i * (ecc->bytes + 4)); in sunxi_nfc_hw_syndrome_ecc_write_page()
1030 struct nand_ecc_ctrl *ecc, in sunxi_nand_hw_common_ecc_ctrl_init() argument
1049 if (ecc->strength <= strengths[i]) in sunxi_nand_hw_common_ecc_ctrl_init()
1062 ecc->bytes = DIV_ROUND_UP(ecc->strength * fls(8 * 1024), 8); in sunxi_nand_hw_common_ecc_ctrl_init()
1065 ecc->bytes = ALIGN(ecc->bytes, 2); in sunxi_nand_hw_common_ecc_ctrl_init()
1068 nsectors = mtd->writesize / ecc->size; in sunxi_nand_hw_common_ecc_ctrl_init()
1070 if (mtd->oobsize < ((ecc->bytes + 4) * nsectors)) { in sunxi_nand_hw_common_ecc_ctrl_init()
1075 layout->eccbytes = (ecc->bytes * nsectors); in sunxi_nand_hw_common_ecc_ctrl_init()
1077 ecc->layout = layout; in sunxi_nand_hw_common_ecc_ctrl_init()
1078 ecc->priv = data; in sunxi_nand_hw_common_ecc_ctrl_init()
1088 static void sunxi_nand_hw_common_ecc_ctrl_cleanup(struct nand_ecc_ctrl *ecc) in sunxi_nand_hw_common_ecc_ctrl_cleanup() argument
1090 kfree(ecc->priv); in sunxi_nand_hw_common_ecc_ctrl_cleanup()
1094 struct nand_ecc_ctrl *ecc, in sunxi_nand_hw_ecc_ctrl_init() argument
1102 ret = sunxi_nand_hw_common_ecc_ctrl_init(mtd, ecc, np); in sunxi_nand_hw_ecc_ctrl_init()
1106 ecc->read_page = sunxi_nfc_hw_ecc_read_page; in sunxi_nand_hw_ecc_ctrl_init()
1107 ecc->write_page = sunxi_nfc_hw_ecc_write_page; in sunxi_nand_hw_ecc_ctrl_init()
1108 layout = ecc->layout; in sunxi_nand_hw_ecc_ctrl_init()
1109 nsectors = mtd->writesize / ecc->size; in sunxi_nand_hw_ecc_ctrl_init()
1116 ecc->bytes; in sunxi_nand_hw_ecc_ctrl_init()
1128 for (j = 0; j < ecc->bytes; j++) in sunxi_nand_hw_ecc_ctrl_init()
1129 layout->eccpos[(ecc->bytes * i) + j] = in sunxi_nand_hw_ecc_ctrl_init()
1134 if (mtd->oobsize > (ecc->bytes + 4) * nsectors) { in sunxi_nand_hw_ecc_ctrl_init()
1138 ecc->bytes; in sunxi_nand_hw_ecc_ctrl_init()
1140 ((ecc->bytes + 4) * nsectors); in sunxi_nand_hw_ecc_ctrl_init()
1147 struct nand_ecc_ctrl *ecc, in sunxi_nand_hw_syndrome_ecc_ctrl_init() argument
1155 ret = sunxi_nand_hw_common_ecc_ctrl_init(mtd, ecc, np); in sunxi_nand_hw_syndrome_ecc_ctrl_init()
1159 ecc->prepad = 4; in sunxi_nand_hw_syndrome_ecc_ctrl_init()
1160 ecc->read_page = sunxi_nfc_hw_syndrome_ecc_read_page; in sunxi_nand_hw_syndrome_ecc_ctrl_init()
1161 ecc->write_page = sunxi_nfc_hw_syndrome_ecc_write_page; in sunxi_nand_hw_syndrome_ecc_ctrl_init()
1163 layout = ecc->layout; in sunxi_nand_hw_syndrome_ecc_ctrl_init()
1164 nsectors = mtd->writesize / ecc->size; in sunxi_nand_hw_syndrome_ecc_ctrl_init()
1166 for (i = 0; i < (ecc->bytes * nsectors); i++) in sunxi_nand_hw_syndrome_ecc_ctrl_init()
1175 static void sunxi_nand_ecc_cleanup(struct nand_ecc_ctrl *ecc) in sunxi_nand_ecc_cleanup() argument
1177 switch (ecc->mode) { in sunxi_nand_ecc_cleanup()
1180 sunxi_nand_hw_common_ecc_ctrl_cleanup(ecc); in sunxi_nand_ecc_cleanup()
1183 kfree(ecc->layout); in sunxi_nand_ecc_cleanup()
1189 static int sunxi_nand_ecc_init(struct mtd_info *mtd, struct nand_ecc_ctrl *ecc, in sunxi_nand_ecc_init() argument
1195 if (!ecc->size) { in sunxi_nand_ecc_init()
1196 ecc->size = nand->ecc_step_ds; in sunxi_nand_ecc_init()
1197 ecc->strength = nand->ecc_strength_ds; in sunxi_nand_ecc_init()
1200 if (!ecc->size || !ecc->strength) in sunxi_nand_ecc_init()
1203 switch (ecc->mode) { in sunxi_nand_ecc_init()
1207 ret = sunxi_nand_hw_ecc_ctrl_init(mtd, ecc, np); in sunxi_nand_ecc_init()
1212 ret = sunxi_nand_hw_syndrome_ecc_ctrl_init(mtd, ecc, np); in sunxi_nand_ecc_init()
1217 ecc->layout = kzalloc(sizeof(*ecc->layout), GFP_KERNEL); in sunxi_nand_ecc_init()
1218 if (!ecc->layout) in sunxi_nand_ecc_init()
1220 ecc->layout->oobfree[0].length = mtd->oobsize; in sunxi_nand_ecc_init()
1332 nand->ecc.mode = NAND_ECC_HW; in sunxi_nand_chip_init()
1357 ret = sunxi_nand_ecc_init(mtd, &nand->ecc, np); in sunxi_nand_chip_init()
1411 sunxi_nand_ecc_cleanup(&chip->nand.ecc); in sunxi_nand_chips_cleanup()