Lines Matching refs:ecc
124 void __iomem *ecc; member
543 value = pmecc_readl_rem_relaxed(host->ecc, sector, i / 2); in pmecc_gen_syndrome()
802 static void pmecc_correct_data(struct mtd_info *mtd, uint8_t *buf, uint8_t *ecc, in pmecc_correct_data() argument
831 tmp = sector_num * nand_chip->ecc.bytes in pmecc_correct_data()
833 err_byte = ecc[tmp]; in pmecc_correct_data()
834 ecc[tmp] ^= (1 << bit_pos); in pmecc_correct_data()
836 pos = tmp + nand_chip->ecc.layout->eccpos[0]; in pmecc_correct_data()
838 pos, bit_pos, err_byte, ecc[tmp]); in pmecc_correct_data()
849 u8 *ecc) in pmecc_correction() argument
861 for (i = 0; i < nand_chip->ecc.total; i++) in pmecc_correction()
862 if (ecc[i] != 0xff) in pmecc_correction()
868 for (i = 0; i < nand_chip->ecc.steps; i++) { in pmecc_correction()
883 pmecc_correct_data(mtd, buf_pos, ecc, i, in pmecc_correction()
884 nand_chip->ecc.bytes, err_nbr); in pmecc_correction()
904 pmecc_writel(host->ecc, CTRL, PMECC_CTRL_RST); in pmecc_enable()
905 pmecc_writel(host->ecc, CTRL, PMECC_CTRL_DISABLE); in pmecc_enable()
906 val = pmecc_readl_relaxed(host->ecc, CFG); in pmecc_enable()
909 pmecc_writel(host->ecc, CFG, (val & ~PMECC_CFG_WRITE_OP) in pmecc_enable()
912 pmecc_writel(host->ecc, CFG, (val | PMECC_CFG_WRITE_OP) in pmecc_enable()
915 pmecc_writel(host->ecc, CTRL, PMECC_CTRL_ENABLE); in pmecc_enable()
916 pmecc_writel(host->ecc, CTRL, PMECC_CTRL_DATA); in pmecc_enable()
923 int eccsize = chip->ecc.size * chip->ecc.steps; in atmel_nand_pmecc_read_page()
925 uint32_t *eccpos = chip->ecc.layout->eccpos; in atmel_nand_pmecc_read_page()
937 while ((pmecc_readl_relaxed(host->ecc, SR) & PMECC_SR_BUSY)) { in atmel_nand_pmecc_read_page()
945 stat = pmecc_readl_relaxed(host->ecc, ISR); in atmel_nand_pmecc_read_page()
961 uint32_t *eccpos = chip->ecc.layout->eccpos; in atmel_nand_pmecc_write_page()
971 while ((pmecc_readl_relaxed(host->ecc, SR) & PMECC_SR_BUSY)) { in atmel_nand_pmecc_write_page()
979 for (i = 0; i < chip->ecc.steps; i++) { in atmel_nand_pmecc_write_page()
980 for (j = 0; j < chip->ecc.bytes; j++) { in atmel_nand_pmecc_write_page()
983 pos = i * chip->ecc.bytes + j; in atmel_nand_pmecc_write_page()
985 pmecc_readb_ecc_relaxed(host->ecc, i, j); in atmel_nand_pmecc_write_page()
1000 pmecc_writel(host->ecc, CTRL, PMECC_CTRL_RST); in atmel_pmecc_core_init()
1001 pmecc_writel(host->ecc, CTRL, PMECC_CTRL_DISABLE); in atmel_pmecc_core_init()
1026 switch (nand_chip->ecc.steps) { in atmel_pmecc_core_init()
1043 pmecc_writel(host->ecc, CFG, val); in atmel_pmecc_core_init()
1045 ecc_layout = nand_chip->ecc.layout; in atmel_pmecc_core_init()
1046 pmecc_writel(host->ecc, SAREA, mtd->oobsize - 1); in atmel_pmecc_core_init()
1047 pmecc_writel(host->ecc, SADDR, ecc_layout->eccpos[0]); in atmel_pmecc_core_init()
1048 pmecc_writel(host->ecc, EADDR, in atmel_pmecc_core_init()
1051 pmecc_writel(host->ecc, CLK, 2); in atmel_pmecc_core_init()
1052 pmecc_writel(host->ecc, IDR, 0xff); in atmel_pmecc_core_init()
1053 pmecc_writel(host->ecc, CTRL, PMECC_CTRL_ENABLE); in atmel_pmecc_core_init()
1191 nand_chip->ecc.mode = NAND_ECC_SOFT; in atmel_pmecc_nand_init_params()
1195 host->ecc = devm_ioremap_resource(&pdev->dev, regs); in atmel_pmecc_nand_init_params()
1196 if (IS_ERR(host->ecc)) { in atmel_pmecc_nand_init_params()
1197 err_no = PTR_ERR(host->ecc); in atmel_pmecc_nand_init_params()
1231 nand_chip->ecc.size = sector_size; in atmel_pmecc_nand_init_params()
1253 nand_chip->ecc.strength = cap; in atmel_pmecc_nand_init_params()
1254 nand_chip->ecc.bytes = pmecc_get_ecc_bytes(cap, sector_size); in atmel_pmecc_nand_init_params()
1255 nand_chip->ecc.steps = mtd->writesize / sector_size; in atmel_pmecc_nand_init_params()
1256 nand_chip->ecc.total = nand_chip->ecc.bytes * in atmel_pmecc_nand_init_params()
1257 nand_chip->ecc.steps; in atmel_pmecc_nand_init_params()
1258 if (nand_chip->ecc.total > in atmel_pmecc_nand_init_params()
1266 nand_chip->ecc.total); in atmel_pmecc_nand_init_params()
1268 nand_chip->ecc.layout = &atmel_pmecc_oobinfo; in atmel_pmecc_nand_init_params()
1275 nand_chip->ecc.mode = NAND_ECC_SOFT; in atmel_pmecc_nand_init_params()
1288 nand_chip->ecc.read_page = atmel_nand_pmecc_read_page; in atmel_pmecc_nand_init_params()
1289 nand_chip->ecc.write_page = atmel_nand_pmecc_write_page; in atmel_pmecc_nand_init_params()
1316 ecc_value = ecc_readl(host->ecc, PR); in atmel_nand_calculate()
1322 ecc_value = ecc_readl(host->ecc, NPR) & ATMEL_ECC_NPARITY; in atmel_nand_calculate()
1341 int eccsize = chip->ecc.size; in atmel_nand_read_page()
1342 int eccbytes = chip->ecc.bytes; in atmel_nand_read_page()
1343 uint32_t *eccpos = chip->ecc.layout->eccpos; in atmel_nand_read_page()
1360 ecc_writel(host->ecc, CR, ATMEL_ECC_RST); in atmel_nand_read_page()
1382 stat = chip->ecc.correct(mtd, p, oob, NULL); in atmel_nand_read_page()
1421 ecc_status = ecc_readl(host->ecc, SR); in atmel_nand_correct()
1428 ecc_bit = ecc_readl(host->ecc, PR) & ATMEL_ECC_BITADDR; in atmel_nand_correct()
1430 ecc_word = ecc_readl(host->ecc, PR) & ATMEL_ECC_WORDADDR; in atmel_nand_correct()
1485 ecc_writel(host->ecc, CR, ATMEL_ECC_RST); in atmel_nand_hwctl()
1597 nand_chip->ecc.mode = NAND_ECC_SOFT; in atmel_hw_nand_init_params()
1601 host->ecc = devm_ioremap_resource(&pdev->dev, regs); in atmel_hw_nand_init_params()
1602 if (IS_ERR(host->ecc)) in atmel_hw_nand_init_params()
1603 return PTR_ERR(host->ecc); in atmel_hw_nand_init_params()
1606 nand_chip->ecc.size = mtd->writesize; in atmel_hw_nand_init_params()
1611 nand_chip->ecc.layout = &atmel_oobinfo_small; in atmel_hw_nand_init_params()
1612 ecc_writel(host->ecc, MR, ATMEL_ECC_PAGESIZE_528); in atmel_hw_nand_init_params()
1615 nand_chip->ecc.layout = &atmel_oobinfo_large; in atmel_hw_nand_init_params()
1616 ecc_writel(host->ecc, MR, ATMEL_ECC_PAGESIZE_1056); in atmel_hw_nand_init_params()
1619 nand_chip->ecc.layout = &atmel_oobinfo_large; in atmel_hw_nand_init_params()
1620 ecc_writel(host->ecc, MR, ATMEL_ECC_PAGESIZE_2112); in atmel_hw_nand_init_params()
1623 nand_chip->ecc.layout = &atmel_oobinfo_large; in atmel_hw_nand_init_params()
1624 ecc_writel(host->ecc, MR, ATMEL_ECC_PAGESIZE_4224); in atmel_hw_nand_init_params()
1629 nand_chip->ecc.mode = NAND_ECC_SOFT; in atmel_hw_nand_init_params()
1634 nand_chip->ecc.calculate = atmel_nand_calculate; in atmel_hw_nand_init_params()
1635 nand_chip->ecc.correct = atmel_nand_correct; in atmel_hw_nand_init_params()
1636 nand_chip->ecc.hwctl = atmel_nand_hwctl; in atmel_hw_nand_init_params()
1637 nand_chip->ecc.read_page = atmel_nand_read_page; in atmel_hw_nand_init_params()
1638 nand_chip->ecc.bytes = 4; in atmel_hw_nand_init_params()
1639 nand_chip->ecc.strength = 1; in atmel_hw_nand_init_params()
1908 if (chip->ecc.mode == NAND_ECC_HW && host->has_pmecc) in nfc_nand_command()
1995 if (chip->ecc.mode == NAND_ECC_HW && host->has_pmecc) in nfc_sram_write_page()
2009 status = chip->ecc.write_page(mtd, chip, buf, oob_required, in nfc_sram_write_page()
2074 if ((chip->ecc.mode == NAND_ECC_HW && host->has_pmecc) || in nfc_sram_init()
2075 chip->ecc.mode == NAND_ECC_NONE) in nfc_sram_init()
2168 nand_chip->ecc.mode = host->board.ecc_mode; in atmel_nand_probe()
2236 if (nand_chip->ecc.mode == NAND_ECC_HW) { in atmel_nand_probe()
2269 if (host->has_pmecc && host->nand_chip.ecc.mode == NAND_ECC_HW) in atmel_nand_probe()
2270 pmecc_writel(host->ecc, CTRL, PMECC_CTRL_DISABLE); in atmel_nand_probe()
2293 if (host->has_pmecc && host->nand_chip.ecc.mode == NAND_ECC_HW) { in atmel_nand_remove()
2294 pmecc_writel(host->ecc, CTRL, PMECC_CTRL_DISABLE); in atmel_nand_remove()