• Home
  • Raw
  • Download

Lines Matching full:ecc

179  * sunxi HW ECC infos: stores information related to HW ECC support
181 * @mode: the sunxi ECC mode field deduced from ECC requirements
691 static u16 sunxi_nfc_randomizer_state(struct mtd_info *mtd, int page, bool ecc) in sunxi_nfc_randomizer_state() argument
699 if (ecc) { in sunxi_nfc_randomizer_state()
710 int page, bool ecc) in sunxi_nfc_randomizer_config() argument
721 state = sunxi_nfc_randomizer_state(mtd, page, ecc); in sunxi_nfc_randomizer_config()
760 bool ecc, int page) in sunxi_nfc_randomizer_write_buf() argument
762 sunxi_nfc_randomizer_config(mtd, page, ecc); in sunxi_nfc_randomizer_write_buf()
769 int len, bool ecc, int page) in sunxi_nfc_randomizer_read_buf() argument
771 sunxi_nfc_randomizer_config(mtd, page, ecc); in sunxi_nfc_randomizer_read_buf()
781 struct sunxi_nand_hw_ecc *data = nand->ecc.priv; in sunxi_nfc_hw_ecc_enable()
790 if (nand->ecc.size == 512) in sunxi_nfc_hw_ecc_enable()
867 struct nand_ecc_ctrl *ecc = &nand->ecc; in sunxi_nfc_hw_ecc_correct() local
886 memset(data, pattern, ecc->size); in sunxi_nfc_hw_ecc_correct()
889 memset(oob, pattern, ecc->bytes + 4); in sunxi_nfc_hw_ecc_correct()
908 struct nand_ecc_ctrl *ecc = &nand->ecc; in sunxi_nfc_hw_ecc_read_chunk() local
916 sunxi_nfc_randomizer_read_buf(mtd, NULL, ecc->size, false, page); in sunxi_nfc_hw_ecc_read_chunk()
918 if (data_off + ecc->size != oob_off) in sunxi_nfc_hw_ecc_read_chunk()
934 *cur_off = oob_off + ecc->bytes + 4; in sunxi_nfc_hw_ecc_read_chunk()
949 ecc->size, false); in sunxi_nfc_hw_ecc_read_chunk()
952 ecc->size); in sunxi_nfc_hw_ecc_read_chunk()
954 nand_change_read_column_op(nand, oob_off, oob, ecc->bytes + 4, in sunxi_nfc_hw_ecc_read_chunk()
957 ret = nand_check_erased_ecc_chunk(data, ecc->size, in sunxi_nfc_hw_ecc_read_chunk()
958 oob, ecc->bytes + 4, in sunxi_nfc_hw_ecc_read_chunk()
959 NULL, 0, ecc->strength); in sunxi_nfc_hw_ecc_read_chunk()
963 memcpy_fromio(data, nfc->regs + NFC_RAM0_BASE, ecc->size); in sunxi_nfc_hw_ecc_read_chunk()
968 sunxi_nfc_randomizer_read_buf(mtd, oob, ecc->bytes + 4, in sunxi_nfc_hw_ecc_read_chunk()
986 struct nand_ecc_ctrl *ecc = &nand->ecc; in sunxi_nfc_hw_ecc_read_extra_oob() local
987 int offset = ((ecc->bytes + 4) * ecc->steps); in sunxi_nfc_hw_ecc_read_extra_oob()
1014 struct nand_ecc_ctrl *ecc = &nand->ecc; in sunxi_nfc_hw_ecc_read_chunks_dma() local
1024 ret = sunxi_nfc_dma_op_prepare(mtd, buf, ecc->size, nchunks, in sunxi_nfc_hw_ecc_read_chunks_dma()
1056 int data_off = i * ecc->size; in sunxi_nfc_hw_ecc_read_chunks_dma()
1057 int oob_off = i * (ecc->bytes + 4); in sunxi_nfc_hw_ecc_read_chunks_dma()
1066 /* ECC errors are handled in the second loop. */ in sunxi_nfc_hw_ecc_read_chunks_dma()
1074 oob, ecc->bytes + 4, false); in sunxi_nfc_hw_ecc_read_chunks_dma()
1088 int data_off = i * ecc->size; in sunxi_nfc_hw_ecc_read_chunks_dma()
1089 int oob_off = i * (ecc->bytes + 4); in sunxi_nfc_hw_ecc_read_chunks_dma()
1103 data, ecc->size, in sunxi_nfc_hw_ecc_read_chunks_dma()
1109 oob, ecc->bytes + 4, false); in sunxi_nfc_hw_ecc_read_chunks_dma()
1111 ret = nand_check_erased_ecc_chunk(data, ecc->size, in sunxi_nfc_hw_ecc_read_chunks_dma()
1112 oob, ecc->bytes + 4, in sunxi_nfc_hw_ecc_read_chunks_dma()
1114 ecc->strength); in sunxi_nfc_hw_ecc_read_chunks_dma()
1138 struct nand_ecc_ctrl *ecc = &nand->ecc; in sunxi_nfc_hw_ecc_write_chunk() local
1144 sunxi_nfc_randomizer_write_buf(mtd, data, ecc->size, false, page); in sunxi_nfc_hw_ecc_write_chunk()
1146 if (data_off + ecc->size != oob_off) in sunxi_nfc_hw_ecc_write_chunk()
1165 *cur_off = oob_off + ecc->bytes + 4; in sunxi_nfc_hw_ecc_write_chunk()
1175 struct nand_ecc_ctrl *ecc = &nand->ecc; in sunxi_nfc_hw_ecc_write_extra_oob() local
1176 int offset = ((ecc->bytes + 4) * ecc->steps); in sunxi_nfc_hw_ecc_write_extra_oob()
1196 struct nand_ecc_ctrl *ecc = &chip->ecc; in sunxi_nfc_hw_ecc_read_page() local
1205 for (i = 0; i < ecc->steps; i++) { in sunxi_nfc_hw_ecc_read_page()
1206 int data_off = i * ecc->size; in sunxi_nfc_hw_ecc_read_page()
1207 int oob_off = i * (ecc->bytes + 4); in sunxi_nfc_hw_ecc_read_page()
1239 chip->ecc.steps); in sunxi_nfc_hw_ecc_read_page_dma()
1252 struct nand_ecc_ctrl *ecc = &chip->ecc; in sunxi_nfc_hw_ecc_read_subpage() local
1260 for (i = data_offs / ecc->size; in sunxi_nfc_hw_ecc_read_subpage()
1261 i < DIV_ROUND_UP(data_offs + readlen, ecc->size); i++) { in sunxi_nfc_hw_ecc_read_subpage()
1262 int data_off = i * ecc->size; in sunxi_nfc_hw_ecc_read_subpage()
1263 int oob_off = i * (ecc->bytes + 4); in sunxi_nfc_hw_ecc_read_subpage()
1286 int nchunks = DIV_ROUND_UP(data_offs + readlen, chip->ecc.size); in sunxi_nfc_hw_ecc_read_subpage_dma()
1305 struct nand_ecc_ctrl *ecc = &chip->ecc; in sunxi_nfc_hw_ecc_write_page() local
1312 for (i = 0; i < ecc->steps; i++) { in sunxi_nfc_hw_ecc_write_page()
1313 int data_off = i * ecc->size; in sunxi_nfc_hw_ecc_write_page()
1314 int oob_off = i * (ecc->bytes + 4); in sunxi_nfc_hw_ecc_write_page()
1340 struct nand_ecc_ctrl *ecc = &chip->ecc; in sunxi_nfc_hw_ecc_write_subpage() local
1347 for (i = data_offs / ecc->size; in sunxi_nfc_hw_ecc_write_subpage()
1348 i < DIV_ROUND_UP(data_offs + data_len, ecc->size); i++) { in sunxi_nfc_hw_ecc_write_subpage()
1349 int data_off = i * ecc->size; in sunxi_nfc_hw_ecc_write_subpage()
1350 int oob_off = i * (ecc->bytes + 4); in sunxi_nfc_hw_ecc_write_subpage()
1374 struct nand_ecc_ctrl *ecc = &nand->ecc; in sunxi_nfc_hw_ecc_write_page_dma() local
1382 ret = sunxi_nfc_dma_op_prepare(mtd, buf, ecc->size, ecc->steps, in sunxi_nfc_hw_ecc_write_page_dma()
1387 for (i = 0; i < ecc->steps; i++) { in sunxi_nfc_hw_ecc_write_page_dma()
1388 const u8 *oob = nand->oob_poi + (i * (ecc->bytes + 4)); in sunxi_nfc_hw_ecc_write_page_dma()
1437 return chip->ecc.read_page(mtd, chip, chip->data_buf, 1, page); in sunxi_nfc_hw_ecc_read_oob()
1449 ret = chip->ecc.write_page(mtd, chip, chip->data_buf, 1, page); in sunxi_nfc_hw_ecc_write_oob()
1636 struct nand_ecc_ctrl *ecc = &nand->ecc; in sunxi_nand_ooblayout_ecc() local
1638 if (section >= ecc->steps) in sunxi_nand_ooblayout_ecc()
1641 oobregion->offset = section * (ecc->bytes + 4) + 4; in sunxi_nand_ooblayout_ecc()
1642 oobregion->length = ecc->bytes; in sunxi_nand_ooblayout_ecc()
1651 struct nand_ecc_ctrl *ecc = &nand->ecc; in sunxi_nand_ooblayout_free() local
1653 if (section > ecc->steps) in sunxi_nand_ooblayout_free()
1661 if (!section && ecc->mode == NAND_ECC_HW) { in sunxi_nand_ooblayout_free()
1668 oobregion->offset = section * (ecc->bytes + 4); in sunxi_nand_ooblayout_free()
1670 if (section < ecc->steps) in sunxi_nand_ooblayout_free()
1679 .ecc = sunxi_nand_ooblayout_ecc,
1683 static void sunxi_nand_hw_ecc_ctrl_cleanup(struct nand_ecc_ctrl *ecc) in sunxi_nand_hw_ecc_ctrl_cleanup() argument
1685 kfree(ecc->priv); in sunxi_nand_hw_ecc_ctrl_cleanup()
1689 struct nand_ecc_ctrl *ecc, in sunxi_nand_hw_ecc_ctrl_init() argument
1701 if (ecc->options & NAND_ECC_MAXIMIZE) { in sunxi_nand_hw_ecc_ctrl_init()
1704 ecc->size = 1024; in sunxi_nand_hw_ecc_ctrl_init()
1705 nsectors = mtd->writesize / ecc->size; in sunxi_nand_hw_ecc_ctrl_init()
1710 /* 4 non-ECC bytes are added before each ECC bytes section */ in sunxi_nand_hw_ecc_ctrl_init()
1717 ecc->strength = bytes * 8 / fls(8 * ecc->size); in sunxi_nand_hw_ecc_ctrl_init()
1720 if (strengths[i] > ecc->strength) in sunxi_nand_hw_ecc_ctrl_init()
1725 ecc->strength = 0; in sunxi_nand_hw_ecc_ctrl_init()
1727 ecc->strength = strengths[i - 1]; in sunxi_nand_hw_ecc_ctrl_init()
1730 if (ecc->size != 512 && ecc->size != 1024) in sunxi_nand_hw_ecc_ctrl_init()
1737 /* Prefer 1k ECC chunk over 512 ones */ in sunxi_nand_hw_ecc_ctrl_init()
1738 if (ecc->size == 512 && mtd->writesize > 512) { in sunxi_nand_hw_ecc_ctrl_init()
1739 ecc->size = 1024; in sunxi_nand_hw_ecc_ctrl_init()
1740 ecc->strength *= 2; in sunxi_nand_hw_ecc_ctrl_init()
1743 /* Add ECC info retrieval from DT */ in sunxi_nand_hw_ecc_ctrl_init()
1745 if (ecc->strength <= strengths[i]) { in sunxi_nand_hw_ecc_ctrl_init()
1747 * Update ecc->strength value with the actual strength in sunxi_nand_hw_ecc_ctrl_init()
1748 * that will be used by the ECC engine. in sunxi_nand_hw_ecc_ctrl_init()
1750 ecc->strength = strengths[i]; in sunxi_nand_hw_ecc_ctrl_init()
1763 /* HW ECC always request ECC bytes for 1024 bytes blocks */ in sunxi_nand_hw_ecc_ctrl_init()
1764 ecc->bytes = DIV_ROUND_UP(ecc->strength * fls(8 * 1024), 8); in sunxi_nand_hw_ecc_ctrl_init()
1766 /* HW ECC always work with even numbers of ECC bytes */ in sunxi_nand_hw_ecc_ctrl_init()
1767 ecc->bytes = ALIGN(ecc->bytes, 2); in sunxi_nand_hw_ecc_ctrl_init()
1769 nsectors = mtd->writesize / ecc->size; in sunxi_nand_hw_ecc_ctrl_init()
1771 if (mtd->oobsize < ((ecc->bytes + 4) * nsectors)) { in sunxi_nand_hw_ecc_ctrl_init()
1776 ecc->read_oob = sunxi_nfc_hw_ecc_read_oob; in sunxi_nand_hw_ecc_ctrl_init()
1777 ecc->write_oob = sunxi_nfc_hw_ecc_write_oob; in sunxi_nand_hw_ecc_ctrl_init()
1779 ecc->priv = data; in sunxi_nand_hw_ecc_ctrl_init()
1782 ecc->read_page = sunxi_nfc_hw_ecc_read_page_dma; in sunxi_nand_hw_ecc_ctrl_init()
1783 ecc->read_subpage = sunxi_nfc_hw_ecc_read_subpage_dma; in sunxi_nand_hw_ecc_ctrl_init()
1784 ecc->write_page = sunxi_nfc_hw_ecc_write_page_dma; in sunxi_nand_hw_ecc_ctrl_init()
1787 ecc->read_page = sunxi_nfc_hw_ecc_read_page; in sunxi_nand_hw_ecc_ctrl_init()
1788 ecc->read_subpage = sunxi_nfc_hw_ecc_read_subpage; in sunxi_nand_hw_ecc_ctrl_init()
1789 ecc->write_page = sunxi_nfc_hw_ecc_write_page; in sunxi_nand_hw_ecc_ctrl_init()
1793 ecc->write_subpage = sunxi_nfc_hw_ecc_write_subpage; in sunxi_nand_hw_ecc_ctrl_init()
1794 ecc->read_oob_raw = nand_read_oob_std; in sunxi_nand_hw_ecc_ctrl_init()
1795 ecc->write_oob_raw = nand_write_oob_std; in sunxi_nand_hw_ecc_ctrl_init()
1805 static void sunxi_nand_ecc_cleanup(struct nand_ecc_ctrl *ecc) in sunxi_nand_ecc_cleanup() argument
1807 switch (ecc->mode) { in sunxi_nand_ecc_cleanup()
1809 sunxi_nand_hw_ecc_ctrl_cleanup(ecc); in sunxi_nand_ecc_cleanup()
1820 struct nand_ecc_ctrl *ecc = &nand->ecc; in sunxi_nand_attach_chip() local
1832 if (!ecc->size) { in sunxi_nand_attach_chip()
1833 ecc->size = nand->ecc_step_ds; in sunxi_nand_attach_chip()
1834 ecc->strength = nand->ecc_strength_ds; in sunxi_nand_attach_chip()
1837 if (!ecc->size || !ecc->strength) in sunxi_nand_attach_chip()
1840 switch (ecc->mode) { in sunxi_nand_attach_chip()
1842 ret = sunxi_nand_hw_ecc_ctrl_init(mtd, ecc, np); in sunxi_nand_attach_chip()
1928 * Set the ECC mode to the default value in case nothing is specified in sunxi_nand_chip_init()
1931 nand->ecc.mode = NAND_ECC_HW; in sunxi_nand_chip_init()
1990 sunxi_nand_ecc_cleanup(&chip->nand.ecc); in sunxi_nand_chips_cleanup()