Lines Matching refs:ecc
1137 int eccsize = chip->ecc.size; in nand_read_page_raw_syndrome()
1138 int eccbytes = chip->ecc.bytes; in nand_read_page_raw_syndrome()
1142 for (steps = chip->ecc.steps; steps > 0; steps--) { in nand_read_page_raw_syndrome()
1146 if (chip->ecc.prepad) { in nand_read_page_raw_syndrome()
1147 chip->read_buf(mtd, oob, chip->ecc.prepad); in nand_read_page_raw_syndrome()
1148 oob += chip->ecc.prepad; in nand_read_page_raw_syndrome()
1154 if (chip->ecc.postpad) { in nand_read_page_raw_syndrome()
1155 chip->read_buf(mtd, oob, chip->ecc.postpad); in nand_read_page_raw_syndrome()
1156 oob += chip->ecc.postpad; in nand_read_page_raw_syndrome()
1178 int i, eccsize = chip->ecc.size; in nand_read_page_swecc()
1179 int eccbytes = chip->ecc.bytes; in nand_read_page_swecc()
1180 int eccsteps = chip->ecc.steps; in nand_read_page_swecc()
1184 uint32_t *eccpos = chip->ecc.layout->eccpos; in nand_read_page_swecc()
1187 chip->ecc.read_page_raw(mtd, chip, buf, 1, page); in nand_read_page_swecc()
1190 chip->ecc.calculate(mtd, p, &ecc_calc[i]); in nand_read_page_swecc()
1192 for (i = 0; i < chip->ecc.total; i++) in nand_read_page_swecc()
1195 eccsteps = chip->ecc.steps; in nand_read_page_swecc()
1201 stat = chip->ecc.correct(mtd, p, &ecc_code[i], &ecc_calc[i]); in nand_read_page_swecc()
1226 uint32_t *eccpos = chip->ecc.layout->eccpos; in nand_read_subpage()
1235 start_step = data_offs / chip->ecc.size; in nand_read_subpage()
1236 end_step = (data_offs + readlen - 1) / chip->ecc.size; in nand_read_subpage()
1238 index = start_step * chip->ecc.bytes; in nand_read_subpage()
1241 datafrag_len = num_steps * chip->ecc.size; in nand_read_subpage()
1242 eccfrag_len = num_steps * chip->ecc.bytes; in nand_read_subpage()
1244 data_col_addr = start_step * chip->ecc.size; in nand_read_subpage()
1253 for (i = 0; i < eccfrag_len ; i += chip->ecc.bytes, p += chip->ecc.size) in nand_read_subpage()
1254 chip->ecc.calculate(mtd, p, &chip->buffers->ecccalc[i]); in nand_read_subpage()
1278 if (eccpos[index + (num_steps * chip->ecc.bytes)] & (busw - 1)) in nand_read_subpage()
1290 for (i = 0; i < eccfrag_len ; i += chip->ecc.bytes, p += chip->ecc.size) { in nand_read_subpage()
1293 stat = chip->ecc.correct(mtd, p, in nand_read_subpage()
1318 int i, eccsize = chip->ecc.size; in nand_read_page_hwecc()
1319 int eccbytes = chip->ecc.bytes; in nand_read_page_hwecc()
1320 int eccsteps = chip->ecc.steps; in nand_read_page_hwecc()
1324 uint32_t *eccpos = chip->ecc.layout->eccpos; in nand_read_page_hwecc()
1328 chip->ecc.hwctl(mtd, NAND_ECC_READ); in nand_read_page_hwecc()
1330 chip->ecc.calculate(mtd, p, &ecc_calc[i]); in nand_read_page_hwecc()
1334 for (i = 0; i < chip->ecc.total; i++) in nand_read_page_hwecc()
1337 eccsteps = chip->ecc.steps; in nand_read_page_hwecc()
1343 stat = chip->ecc.correct(mtd, p, &ecc_code[i], &ecc_calc[i]); in nand_read_page_hwecc()
1371 int i, eccsize = chip->ecc.size; in nand_read_page_hwecc_oob_first()
1372 int eccbytes = chip->ecc.bytes; in nand_read_page_hwecc_oob_first()
1373 int eccsteps = chip->ecc.steps; in nand_read_page_hwecc_oob_first()
1376 uint32_t *eccpos = chip->ecc.layout->eccpos; in nand_read_page_hwecc_oob_first()
1385 for (i = 0; i < chip->ecc.total; i++) in nand_read_page_hwecc_oob_first()
1391 chip->ecc.hwctl(mtd, NAND_ECC_READ); in nand_read_page_hwecc_oob_first()
1393 chip->ecc.calculate(mtd, p, &ecc_calc[i]); in nand_read_page_hwecc_oob_first()
1395 stat = chip->ecc.correct(mtd, p, &ecc_code[i], NULL); in nand_read_page_hwecc_oob_first()
1420 int i, eccsize = chip->ecc.size; in nand_read_page_syndrome()
1421 int eccbytes = chip->ecc.bytes; in nand_read_page_syndrome()
1422 int eccsteps = chip->ecc.steps; in nand_read_page_syndrome()
1430 chip->ecc.hwctl(mtd, NAND_ECC_READ); in nand_read_page_syndrome()
1433 if (chip->ecc.prepad) { in nand_read_page_syndrome()
1434 chip->read_buf(mtd, oob, chip->ecc.prepad); in nand_read_page_syndrome()
1435 oob += chip->ecc.prepad; in nand_read_page_syndrome()
1438 chip->ecc.hwctl(mtd, NAND_ECC_READSYN); in nand_read_page_syndrome()
1440 stat = chip->ecc.correct(mtd, p, oob, NULL); in nand_read_page_syndrome()
1451 if (chip->ecc.postpad) { in nand_read_page_syndrome()
1452 chip->read_buf(mtd, oob, chip->ecc.postpad); in nand_read_page_syndrome()
1453 oob += chip->ecc.postpad; in nand_read_page_syndrome()
1483 struct nand_oobfree *free = chip->ecc.layout->oobfree; in nand_transfer_oob()
1603 ret = chip->ecc.read_page_raw(mtd, chip, bufpoi, in nand_do_read_ops()
1608 ret = chip->ecc.read_subpage(mtd, chip, in nand_do_read_ops()
1612 ret = chip->ecc.read_page(mtd, chip, bufpoi, in nand_do_read_ops()
1773 int chunk = chip->ecc.bytes + chip->ecc.prepad + chip->ecc.postpad; in nand_read_oob_syndrome()
1774 int eccsize = chip->ecc.size; in nand_read_oob_syndrome()
1778 chip->cmdfunc(mtd, NAND_CMD_READ0, chip->ecc.size, page); in nand_read_oob_syndrome()
1779 for (i = 0; i < chip->ecc.steps; i++) { in nand_read_oob_syndrome()
1832 int chunk = chip->ecc.bytes + chip->ecc.prepad + chip->ecc.postpad; in nand_write_oob_syndrome()
1833 int eccsize = chip->ecc.size, length = mtd->oobsize; in nand_write_oob_syndrome()
1834 int i, len, pos, status = 0, sndcmd = 0, steps = chip->ecc.steps; in nand_write_oob_syndrome()
1842 if (!chip->ecc.prepad && !chip->ecc.postpad) { in nand_write_oob_syndrome()
1906 len = chip->ecc.layout->oobavail; in nand_do_read_oob()
1934 ret = chip->ecc.read_oob_raw(mtd, chip, page); in nand_do_read_oob()
1936 ret = chip->ecc.read_oob(mtd, chip, page); in nand_do_read_oob()
2057 int eccsize = chip->ecc.size; in nand_write_page_raw_syndrome()
2058 int eccbytes = chip->ecc.bytes; in nand_write_page_raw_syndrome()
2062 for (steps = chip->ecc.steps; steps > 0; steps--) { in nand_write_page_raw_syndrome()
2066 if (chip->ecc.prepad) { in nand_write_page_raw_syndrome()
2067 chip->write_buf(mtd, oob, chip->ecc.prepad); in nand_write_page_raw_syndrome()
2068 oob += chip->ecc.prepad; in nand_write_page_raw_syndrome()
2074 if (chip->ecc.postpad) { in nand_write_page_raw_syndrome()
2075 chip->write_buf(mtd, oob, chip->ecc.postpad); in nand_write_page_raw_syndrome()
2076 oob += chip->ecc.postpad; in nand_write_page_raw_syndrome()
2096 int i, eccsize = chip->ecc.size; in nand_write_page_swecc()
2097 int eccbytes = chip->ecc.bytes; in nand_write_page_swecc()
2098 int eccsteps = chip->ecc.steps; in nand_write_page_swecc()
2101 uint32_t *eccpos = chip->ecc.layout->eccpos; in nand_write_page_swecc()
2105 chip->ecc.calculate(mtd, p, &ecc_calc[i]); in nand_write_page_swecc()
2107 for (i = 0; i < chip->ecc.total; i++) in nand_write_page_swecc()
2110 return chip->ecc.write_page_raw(mtd, chip, buf, 1); in nand_write_page_swecc()
2123 int i, eccsize = chip->ecc.size; in nand_write_page_hwecc()
2124 int eccbytes = chip->ecc.bytes; in nand_write_page_hwecc()
2125 int eccsteps = chip->ecc.steps; in nand_write_page_hwecc()
2128 uint32_t *eccpos = chip->ecc.layout->eccpos; in nand_write_page_hwecc()
2131 chip->ecc.hwctl(mtd, NAND_ECC_WRITE); in nand_write_page_hwecc()
2133 chip->ecc.calculate(mtd, p, &ecc_calc[i]); in nand_write_page_hwecc()
2136 for (i = 0; i < chip->ecc.total; i++) in nand_write_page_hwecc()
2161 int ecc_size = chip->ecc.size; in nand_write_subpage_hwecc()
2162 int ecc_bytes = chip->ecc.bytes; in nand_write_subpage_hwecc()
2163 int ecc_steps = chip->ecc.steps; in nand_write_subpage_hwecc()
2164 uint32_t *eccpos = chip->ecc.layout->eccpos; in nand_write_subpage_hwecc()
2172 chip->ecc.hwctl(mtd, NAND_ECC_WRITE); in nand_write_subpage_hwecc()
2181 chip->ecc.calculate(mtd, buf, ecc_calc); in nand_write_subpage_hwecc()
2196 for (i = 0; i < chip->ecc.total; i++) in nand_write_subpage_hwecc()
2220 int i, eccsize = chip->ecc.size; in nand_write_page_syndrome()
2221 int eccbytes = chip->ecc.bytes; in nand_write_page_syndrome()
2222 int eccsteps = chip->ecc.steps; in nand_write_page_syndrome()
2228 chip->ecc.hwctl(mtd, NAND_ECC_WRITE); in nand_write_page_syndrome()
2231 if (chip->ecc.prepad) { in nand_write_page_syndrome()
2232 chip->write_buf(mtd, oob, chip->ecc.prepad); in nand_write_page_syndrome()
2233 oob += chip->ecc.prepad; in nand_write_page_syndrome()
2236 chip->ecc.calculate(mtd, p, oob); in nand_write_page_syndrome()
2240 if (chip->ecc.postpad) { in nand_write_page_syndrome()
2241 chip->write_buf(mtd, oob, chip->ecc.postpad); in nand_write_page_syndrome()
2242 oob += chip->ecc.postpad; in nand_write_page_syndrome()
2273 chip->ecc.write_subpage) in nand_write_page()
2281 status = chip->ecc.write_page_raw(mtd, chip, buf, in nand_write_page()
2284 status = chip->ecc.write_subpage(mtd, chip, offset, data_len, in nand_write_page()
2287 status = chip->ecc.write_page(mtd, chip, buf, oob_required); in nand_write_page()
2346 struct nand_oobfree *free = chip->ecc.layout->oobfree; in nand_fill_oob()
2586 len = chip->ecc.layout->oobavail; in nand_do_write_oob()
2640 status = chip->ecc.write_oob_raw(mtd, chip, page & chip->pagemask); in nand_do_write_oob()
2642 status = chip->ecc.write_oob(mtd, chip, page & chip->pagemask); in nand_do_write_oob()
3060 struct onfi_ext_ecc_info *ecc; in nand_flash_detect_ext_param_page() local
3109 ecc = (struct onfi_ext_ecc_info *)cursor; in nand_flash_detect_ext_param_page()
3111 if (!ecc->codeword_size) { in nand_flash_detect_ext_param_page()
3116 chip->ecc_strength_ds = ecc->ecc_bits; in nand_flash_detect_ext_param_page()
3117 chip->ecc_step_ds = 1 << ecc->codeword_size; in nand_flash_detect_ext_param_page()
3260 struct jedec_ecc_info *ecc; in nand_flash_detect_jedec() local
3322 ecc = &p->ecc_info[0]; in nand_flash_detect_jedec()
3324 if (ecc->codeword_size >= 9) { in nand_flash_detect_jedec()
3325 chip->ecc_strength_ds = ecc->ecc_bits; in nand_flash_detect_jedec()
3326 chip->ecc_step_ds = 1 << ecc->codeword_size; in nand_flash_detect_jedec()
3878 struct nand_ecc_ctrl *ecc = &chip->ecc; in nand_ecc_strength_good() local
3881 if (ecc->size == 0 || chip->ecc_step_ds == 0) in nand_ecc_strength_good()
3889 corr = (mtd->writesize * ecc->strength) / ecc->size; in nand_ecc_strength_good()
3892 return corr >= ds_corr && ecc->strength >= chip->ecc_strength_ds; in nand_ecc_strength_good()
3907 struct nand_ecc_ctrl *ecc = &chip->ecc; in nand_scan_tail() local
3935 if (!ecc->layout && (ecc->mode != NAND_ECC_SOFT_BCH)) { in nand_scan_tail()
3938 ecc->layout = &nand_oob_8; in nand_scan_tail()
3941 ecc->layout = &nand_oob_16; in nand_scan_tail()
3944 ecc->layout = &nand_oob_64; in nand_scan_tail()
3947 ecc->layout = &nand_oob_128; in nand_scan_tail()
3964 switch (ecc->mode) { in nand_scan_tail()
3967 if (!ecc->calculate || !ecc->correct || !ecc->hwctl) { in nand_scan_tail()
3971 if (!ecc->read_page) in nand_scan_tail()
3972 ecc->read_page = nand_read_page_hwecc_oob_first; in nand_scan_tail()
3976 if (!ecc->read_page) in nand_scan_tail()
3977 ecc->read_page = nand_read_page_hwecc; in nand_scan_tail()
3978 if (!ecc->write_page) in nand_scan_tail()
3979 ecc->write_page = nand_write_page_hwecc; in nand_scan_tail()
3980 if (!ecc->read_page_raw) in nand_scan_tail()
3981 ecc->read_page_raw = nand_read_page_raw; in nand_scan_tail()
3982 if (!ecc->write_page_raw) in nand_scan_tail()
3983 ecc->write_page_raw = nand_write_page_raw; in nand_scan_tail()
3984 if (!ecc->read_oob) in nand_scan_tail()
3985 ecc->read_oob = nand_read_oob_std; in nand_scan_tail()
3986 if (!ecc->write_oob) in nand_scan_tail()
3987 ecc->write_oob = nand_write_oob_std; in nand_scan_tail()
3988 if (!ecc->read_subpage) in nand_scan_tail()
3989 ecc->read_subpage = nand_read_subpage; in nand_scan_tail()
3990 if (!ecc->write_subpage) in nand_scan_tail()
3991 ecc->write_subpage = nand_write_subpage_hwecc; in nand_scan_tail()
3994 if ((!ecc->calculate || !ecc->correct || !ecc->hwctl) && in nand_scan_tail()
3995 (!ecc->read_page || in nand_scan_tail()
3996 ecc->read_page == nand_read_page_hwecc || in nand_scan_tail()
3997 !ecc->write_page || in nand_scan_tail()
3998 ecc->write_page == nand_write_page_hwecc)) { in nand_scan_tail()
4003 if (!ecc->read_page) in nand_scan_tail()
4004 ecc->read_page = nand_read_page_syndrome; in nand_scan_tail()
4005 if (!ecc->write_page) in nand_scan_tail()
4006 ecc->write_page = nand_write_page_syndrome; in nand_scan_tail()
4007 if (!ecc->read_page_raw) in nand_scan_tail()
4008 ecc->read_page_raw = nand_read_page_raw_syndrome; in nand_scan_tail()
4009 if (!ecc->write_page_raw) in nand_scan_tail()
4010 ecc->write_page_raw = nand_write_page_raw_syndrome; in nand_scan_tail()
4011 if (!ecc->read_oob) in nand_scan_tail()
4012 ecc->read_oob = nand_read_oob_syndrome; in nand_scan_tail()
4013 if (!ecc->write_oob) in nand_scan_tail()
4014 ecc->write_oob = nand_write_oob_syndrome; in nand_scan_tail()
4016 if (mtd->writesize >= ecc->size) { in nand_scan_tail()
4017 if (!ecc->strength) { in nand_scan_tail()
4024 ecc->size, mtd->writesize); in nand_scan_tail()
4025 ecc->mode = NAND_ECC_SOFT; in nand_scan_tail()
4028 ecc->calculate = nand_calculate_ecc; in nand_scan_tail()
4029 ecc->correct = nand_correct_data; in nand_scan_tail()
4030 ecc->read_page = nand_read_page_swecc; in nand_scan_tail()
4031 ecc->read_subpage = nand_read_subpage; in nand_scan_tail()
4032 ecc->write_page = nand_write_page_swecc; in nand_scan_tail()
4033 ecc->read_page_raw = nand_read_page_raw; in nand_scan_tail()
4034 ecc->write_page_raw = nand_write_page_raw; in nand_scan_tail()
4035 ecc->read_oob = nand_read_oob_std; in nand_scan_tail()
4036 ecc->write_oob = nand_write_oob_std; in nand_scan_tail()
4037 if (!ecc->size) in nand_scan_tail()
4038 ecc->size = 256; in nand_scan_tail()
4039 ecc->bytes = 3; in nand_scan_tail()
4040 ecc->strength = 1; in nand_scan_tail()
4048 ecc->calculate = nand_bch_calculate_ecc; in nand_scan_tail()
4049 ecc->correct = nand_bch_correct_data; in nand_scan_tail()
4050 ecc->read_page = nand_read_page_swecc; in nand_scan_tail()
4051 ecc->read_subpage = nand_read_subpage; in nand_scan_tail()
4052 ecc->write_page = nand_write_page_swecc; in nand_scan_tail()
4053 ecc->read_page_raw = nand_read_page_raw; in nand_scan_tail()
4054 ecc->write_page_raw = nand_write_page_raw; in nand_scan_tail()
4055 ecc->read_oob = nand_read_oob_std; in nand_scan_tail()
4056 ecc->write_oob = nand_write_oob_std; in nand_scan_tail()
4062 if (!ecc->size && (mtd->oobsize >= 64)) { in nand_scan_tail()
4063 ecc->size = 512; in nand_scan_tail()
4064 ecc->strength = 4; in nand_scan_tail()
4068 ecc->bytes = DIV_ROUND_UP( in nand_scan_tail()
4069 ecc->strength * fls(8 * ecc->size), 8); in nand_scan_tail()
4070 ecc->priv = nand_bch_init(mtd, ecc->size, ecc->bytes, in nand_scan_tail()
4071 &ecc->layout); in nand_scan_tail()
4072 if (!ecc->priv) { in nand_scan_tail()
4080 ecc->read_page = nand_read_page_raw; in nand_scan_tail()
4081 ecc->write_page = nand_write_page_raw; in nand_scan_tail()
4082 ecc->read_oob = nand_read_oob_std; in nand_scan_tail()
4083 ecc->read_page_raw = nand_read_page_raw; in nand_scan_tail()
4084 ecc->write_page_raw = nand_write_page_raw; in nand_scan_tail()
4085 ecc->write_oob = nand_write_oob_std; in nand_scan_tail()
4086 ecc->size = mtd->writesize; in nand_scan_tail()
4087 ecc->bytes = 0; in nand_scan_tail()
4088 ecc->strength = 0; in nand_scan_tail()
4092 pr_warn("Invalid NAND_ECC_MODE %d\n", ecc->mode); in nand_scan_tail()
4097 if (!ecc->read_oob_raw) in nand_scan_tail()
4098 ecc->read_oob_raw = ecc->read_oob; in nand_scan_tail()
4099 if (!ecc->write_oob_raw) in nand_scan_tail()
4100 ecc->write_oob_raw = ecc->write_oob; in nand_scan_tail()
4106 ecc->layout->oobavail = 0; in nand_scan_tail()
4107 for (i = 0; ecc->layout->oobfree[i].length in nand_scan_tail()
4108 && i < ARRAY_SIZE(ecc->layout->oobfree); i++) in nand_scan_tail()
4109 ecc->layout->oobavail += ecc->layout->oobfree[i].length; in nand_scan_tail()
4110 mtd->oobavail = ecc->layout->oobavail; in nand_scan_tail()
4121 ecc->steps = mtd->writesize / ecc->size; in nand_scan_tail()
4122 if (ecc->steps * ecc->size != mtd->writesize) { in nand_scan_tail()
4126 ecc->total = ecc->steps * ecc->bytes; in nand_scan_tail()
4130 switch (ecc->steps) { in nand_scan_tail()
4150 switch (ecc->mode) { in nand_scan_tail()
4185 mtd->ecclayout = ecc->layout; in nand_scan_tail()
4186 mtd->ecc_strength = ecc->strength; in nand_scan_tail()
4187 mtd->ecc_step_size = ecc->size; in nand_scan_tail()
4252 if (chip->ecc.mode == NAND_ECC_SOFT_BCH) in nand_release()
4253 nand_bch_free((struct nand_bch_control *)chip->ecc.priv); in nand_release()