Lines Matching refs:ecc
528 struct nand_ecc_ctrl *ecc = &chip->ecc; in sunxi_nfc_hw_ecc_read_page() local
529 struct nand_ecclayout *layout = ecc->layout; in sunxi_nfc_hw_ecc_read_page()
530 struct sunxi_nand_hw_ecc *data = ecc->priv; in sunxi_nfc_hw_ecc_read_page()
545 for (i = 0; i < ecc->steps; i++) { in sunxi_nfc_hw_ecc_read_page()
547 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, i * ecc->size, -1); in sunxi_nfc_hw_ecc_read_page()
549 offset = mtd->writesize + layout->eccpos[i * ecc->bytes] - 4; in sunxi_nfc_hw_ecc_read_page()
551 chip->read_buf(mtd, NULL, ecc->size); in sunxi_nfc_hw_ecc_read_page()
566 memcpy_fromio(buf + (i * ecc->size), in sunxi_nfc_hw_ecc_read_page()
567 nfc->regs + NFC_RAM0_BASE, ecc->size); in sunxi_nfc_hw_ecc_read_page()
586 ecc->bytes + 4); in sunxi_nfc_hw_ecc_read_page()
591 cnt = ecc->layout->oobfree[ecc->steps].length; in sunxi_nfc_hw_ecc_read_page()
594 ecc->layout->oobfree[ecc->steps].offset; in sunxi_nfc_hw_ecc_read_page()
614 struct nand_ecc_ctrl *ecc = &chip->ecc; in sunxi_nfc_hw_ecc_write_page() local
615 struct nand_ecclayout *layout = ecc->layout; in sunxi_nfc_hw_ecc_write_page()
616 struct sunxi_nand_hw_ecc *data = ecc->priv; in sunxi_nfc_hw_ecc_write_page()
630 for (i = 0; i < ecc->steps; i++) { in sunxi_nfc_hw_ecc_write_page()
632 chip->cmdfunc(mtd, NAND_CMD_RNDIN, i * ecc->size, -1); in sunxi_nfc_hw_ecc_write_page()
634 chip->write_buf(mtd, buf + (i * ecc->size), ecc->size); in sunxi_nfc_hw_ecc_write_page()
636 offset = layout->eccpos[i * ecc->bytes] - 4 + mtd->writesize; in sunxi_nfc_hw_ecc_write_page()
658 cnt = ecc->layout->oobfree[i].length; in sunxi_nfc_hw_ecc_write_page()
661 ecc->layout->oobfree[i].offset; in sunxi_nfc_hw_ecc_write_page()
682 struct nand_ecc_ctrl *ecc = &chip->ecc; in sunxi_nfc_hw_syndrome_ecc_read_page() local
683 struct sunxi_nand_hw_ecc *data = ecc->priv; in sunxi_nfc_hw_syndrome_ecc_read_page()
699 for (i = 0; i < ecc->steps; i++) { in sunxi_nfc_hw_syndrome_ecc_read_page()
700 chip->read_buf(mtd, NULL, ecc->size); in sunxi_nfc_hw_syndrome_ecc_read_page()
709 memcpy_fromio(buf, nfc->regs + NFC_RAM0_BASE, ecc->size); in sunxi_nfc_hw_syndrome_ecc_read_page()
710 buf += ecc->size; in sunxi_nfc_hw_syndrome_ecc_read_page()
711 offset += ecc->size; in sunxi_nfc_hw_syndrome_ecc_read_page()
723 chip->read_buf(mtd, oob, ecc->bytes + ecc->prepad); in sunxi_nfc_hw_syndrome_ecc_read_page()
724 oob += ecc->bytes + ecc->prepad; in sunxi_nfc_hw_syndrome_ecc_read_page()
727 offset += ecc->bytes + ecc->prepad; in sunxi_nfc_hw_syndrome_ecc_read_page()
750 struct nand_ecc_ctrl *ecc = &chip->ecc; in sunxi_nfc_hw_syndrome_ecc_write_page() local
751 struct sunxi_nand_hw_ecc *data = ecc->priv; in sunxi_nfc_hw_syndrome_ecc_write_page()
766 for (i = 0; i < ecc->steps; i++) { in sunxi_nfc_hw_syndrome_ecc_write_page()
767 chip->write_buf(mtd, buf + (i * ecc->size), ecc->size); in sunxi_nfc_hw_syndrome_ecc_write_page()
768 offset += ecc->size; in sunxi_nfc_hw_syndrome_ecc_write_page()
782 offset += ecc->bytes + ecc->prepad; in sunxi_nfc_hw_syndrome_ecc_write_page()
783 oob += ecc->bytes + ecc->prepad; in sunxi_nfc_hw_syndrome_ecc_write_page()
917 struct nand_ecc_ctrl *ecc, in sunxi_nand_hw_common_ecc_ctrl_init() argument
936 if (ecc->strength <= strengths[i]) in sunxi_nand_hw_common_ecc_ctrl_init()
949 ecc->bytes = DIV_ROUND_UP(ecc->strength * fls(8 * 1024), 8); in sunxi_nand_hw_common_ecc_ctrl_init()
952 ecc->bytes = ALIGN(ecc->bytes, 2); in sunxi_nand_hw_common_ecc_ctrl_init()
955 nsectors = mtd->writesize / ecc->size; in sunxi_nand_hw_common_ecc_ctrl_init()
957 if (mtd->oobsize < ((ecc->bytes + 4) * nsectors)) { in sunxi_nand_hw_common_ecc_ctrl_init()
962 layout->eccbytes = (ecc->bytes * nsectors); in sunxi_nand_hw_common_ecc_ctrl_init()
964 ecc->layout = layout; in sunxi_nand_hw_common_ecc_ctrl_init()
965 ecc->priv = data; in sunxi_nand_hw_common_ecc_ctrl_init()
975 static void sunxi_nand_hw_common_ecc_ctrl_cleanup(struct nand_ecc_ctrl *ecc) in sunxi_nand_hw_common_ecc_ctrl_cleanup() argument
977 kfree(ecc->priv); in sunxi_nand_hw_common_ecc_ctrl_cleanup()
981 struct nand_ecc_ctrl *ecc, in sunxi_nand_hw_ecc_ctrl_init() argument
989 ret = sunxi_nand_hw_common_ecc_ctrl_init(mtd, ecc, np); in sunxi_nand_hw_ecc_ctrl_init()
993 ecc->read_page = sunxi_nfc_hw_ecc_read_page; in sunxi_nand_hw_ecc_ctrl_init()
994 ecc->write_page = sunxi_nfc_hw_ecc_write_page; in sunxi_nand_hw_ecc_ctrl_init()
995 layout = ecc->layout; in sunxi_nand_hw_ecc_ctrl_init()
996 nsectors = mtd->writesize / ecc->size; in sunxi_nand_hw_ecc_ctrl_init()
1003 ecc->bytes; in sunxi_nand_hw_ecc_ctrl_init()
1015 for (j = 0; j < ecc->bytes; j++) in sunxi_nand_hw_ecc_ctrl_init()
1016 layout->eccpos[(ecc->bytes * i) + j] = in sunxi_nand_hw_ecc_ctrl_init()
1021 if (mtd->oobsize > (ecc->bytes + 4) * nsectors) { in sunxi_nand_hw_ecc_ctrl_init()
1025 ecc->bytes; in sunxi_nand_hw_ecc_ctrl_init()
1027 ((ecc->bytes + 4) * nsectors); in sunxi_nand_hw_ecc_ctrl_init()
1034 struct nand_ecc_ctrl *ecc, in sunxi_nand_hw_syndrome_ecc_ctrl_init() argument
1042 ret = sunxi_nand_hw_common_ecc_ctrl_init(mtd, ecc, np); in sunxi_nand_hw_syndrome_ecc_ctrl_init()
1046 ecc->prepad = 4; in sunxi_nand_hw_syndrome_ecc_ctrl_init()
1047 ecc->read_page = sunxi_nfc_hw_syndrome_ecc_read_page; in sunxi_nand_hw_syndrome_ecc_ctrl_init()
1048 ecc->write_page = sunxi_nfc_hw_syndrome_ecc_write_page; in sunxi_nand_hw_syndrome_ecc_ctrl_init()
1050 layout = ecc->layout; in sunxi_nand_hw_syndrome_ecc_ctrl_init()
1051 nsectors = mtd->writesize / ecc->size; in sunxi_nand_hw_syndrome_ecc_ctrl_init()
1053 for (i = 0; i < (ecc->bytes * nsectors); i++) in sunxi_nand_hw_syndrome_ecc_ctrl_init()
1062 static void sunxi_nand_ecc_cleanup(struct nand_ecc_ctrl *ecc) in sunxi_nand_ecc_cleanup() argument
1064 switch (ecc->mode) { in sunxi_nand_ecc_cleanup()
1067 sunxi_nand_hw_common_ecc_ctrl_cleanup(ecc); in sunxi_nand_ecc_cleanup()
1070 kfree(ecc->layout); in sunxi_nand_ecc_cleanup()
1076 static int sunxi_nand_ecc_init(struct mtd_info *mtd, struct nand_ecc_ctrl *ecc, in sunxi_nand_ecc_init() argument
1087 ecc->size = blk_size; in sunxi_nand_ecc_init()
1088 ecc->strength = strength; in sunxi_nand_ecc_init()
1090 ecc->size = nand->ecc_step_ds; in sunxi_nand_ecc_init()
1091 ecc->strength = nand->ecc_strength_ds; in sunxi_nand_ecc_init()
1094 if (!ecc->size || !ecc->strength) in sunxi_nand_ecc_init()
1097 ecc->mode = NAND_ECC_HW; in sunxi_nand_ecc_init()
1101 ecc->mode = ret; in sunxi_nand_ecc_init()
1103 switch (ecc->mode) { in sunxi_nand_ecc_init()
1107 ret = sunxi_nand_hw_ecc_ctrl_init(mtd, ecc, np); in sunxi_nand_ecc_init()
1112 ret = sunxi_nand_hw_syndrome_ecc_ctrl_init(mtd, ecc, np); in sunxi_nand_ecc_init()
1117 ecc->layout = kzalloc(sizeof(*ecc->layout), GFP_KERNEL); in sunxi_nand_ecc_init()
1118 if (!ecc->layout) in sunxi_nand_ecc_init()
1120 ecc->layout->oobfree[0].length = mtd->oobsize; in sunxi_nand_ecc_init()
1252 ret = sunxi_nand_ecc_init(mtd, &nand->ecc, np); in sunxi_nand_chip_init()
1306 sunxi_nand_ecc_cleanup(&chip->nand.ecc); in sunxi_nand_chips_cleanup()