Lines Matching refs:ecc

1201 				void *ecc, int ecclen,  in nand_check_erased_ecc_chunk()  argument
1214 ecc_bitflips = nand_check_erased_buf(ecc, ecclen, bitflips_threshold); in nand_check_erased_ecc_chunk()
1229 memset(ecc, 0xff, ecclen); in nand_check_erased_ecc_chunk()
1271 int eccsize = chip->ecc.size; in nand_read_page_raw_syndrome()
1272 int eccbytes = chip->ecc.bytes; in nand_read_page_raw_syndrome()
1276 for (steps = chip->ecc.steps; steps > 0; steps--) { in nand_read_page_raw_syndrome()
1280 if (chip->ecc.prepad) { in nand_read_page_raw_syndrome()
1281 chip->read_buf(mtd, oob, chip->ecc.prepad); in nand_read_page_raw_syndrome()
1282 oob += chip->ecc.prepad; in nand_read_page_raw_syndrome()
1288 if (chip->ecc.postpad) { in nand_read_page_raw_syndrome()
1289 chip->read_buf(mtd, oob, chip->ecc.postpad); in nand_read_page_raw_syndrome()
1290 oob += chip->ecc.postpad; in nand_read_page_raw_syndrome()
1312 int i, eccsize = chip->ecc.size; in nand_read_page_swecc()
1313 int eccbytes = chip->ecc.bytes; in nand_read_page_swecc()
1314 int eccsteps = chip->ecc.steps; in nand_read_page_swecc()
1318 uint32_t *eccpos = chip->ecc.layout->eccpos; in nand_read_page_swecc()
1321 chip->ecc.read_page_raw(mtd, chip, buf, 1, page); in nand_read_page_swecc()
1324 chip->ecc.calculate(mtd, p, &ecc_calc[i]); in nand_read_page_swecc()
1326 for (i = 0; i < chip->ecc.total; i++) in nand_read_page_swecc()
1329 eccsteps = chip->ecc.steps; in nand_read_page_swecc()
1335 stat = chip->ecc.correct(mtd, p, &ecc_code[i], &ecc_calc[i]); in nand_read_page_swecc()
1360 uint32_t *eccpos = chip->ecc.layout->eccpos; in nand_read_subpage()
1369 start_step = data_offs / chip->ecc.size; in nand_read_subpage()
1370 end_step = (data_offs + readlen - 1) / chip->ecc.size; in nand_read_subpage()
1372 index = start_step * chip->ecc.bytes; in nand_read_subpage()
1375 datafrag_len = num_steps * chip->ecc.size; in nand_read_subpage()
1376 eccfrag_len = num_steps * chip->ecc.bytes; in nand_read_subpage()
1378 data_col_addr = start_step * chip->ecc.size; in nand_read_subpage()
1387 for (i = 0; i < eccfrag_len ; i += chip->ecc.bytes, p += chip->ecc.size) in nand_read_subpage()
1388 chip->ecc.calculate(mtd, p, &chip->buffers->ecccalc[i]); in nand_read_subpage()
1412 if (eccpos[index + (num_steps * chip->ecc.bytes)] & (busw - 1)) in nand_read_subpage()
1424 for (i = 0; i < eccfrag_len ; i += chip->ecc.bytes, p += chip->ecc.size) { in nand_read_subpage()
1427 stat = chip->ecc.correct(mtd, p, in nand_read_subpage()
1452 int i, eccsize = chip->ecc.size; in nand_read_page_hwecc()
1453 int eccbytes = chip->ecc.bytes; in nand_read_page_hwecc()
1454 int eccsteps = chip->ecc.steps; in nand_read_page_hwecc()
1458 uint32_t *eccpos = chip->ecc.layout->eccpos; in nand_read_page_hwecc()
1462 chip->ecc.hwctl(mtd, NAND_ECC_READ); in nand_read_page_hwecc()
1464 chip->ecc.calculate(mtd, p, &ecc_calc[i]); in nand_read_page_hwecc()
1468 for (i = 0; i < chip->ecc.total; i++) in nand_read_page_hwecc()
1471 eccsteps = chip->ecc.steps; in nand_read_page_hwecc()
1477 stat = chip->ecc.correct(mtd, p, &ecc_code[i], &ecc_calc[i]); in nand_read_page_hwecc()
1505 int i, eccsize = chip->ecc.size; in nand_read_page_hwecc_oob_first()
1506 int eccbytes = chip->ecc.bytes; in nand_read_page_hwecc_oob_first()
1507 int eccsteps = chip->ecc.steps; in nand_read_page_hwecc_oob_first()
1510 uint32_t *eccpos = chip->ecc.layout->eccpos; in nand_read_page_hwecc_oob_first()
1519 for (i = 0; i < chip->ecc.total; i++) in nand_read_page_hwecc_oob_first()
1525 chip->ecc.hwctl(mtd, NAND_ECC_READ); in nand_read_page_hwecc_oob_first()
1527 chip->ecc.calculate(mtd, p, &ecc_calc[i]); in nand_read_page_hwecc_oob_first()
1529 stat = chip->ecc.correct(mtd, p, &ecc_code[i], NULL); in nand_read_page_hwecc_oob_first()
1554 int i, eccsize = chip->ecc.size; in nand_read_page_syndrome()
1555 int eccbytes = chip->ecc.bytes; in nand_read_page_syndrome()
1556 int eccsteps = chip->ecc.steps; in nand_read_page_syndrome()
1564 chip->ecc.hwctl(mtd, NAND_ECC_READ); in nand_read_page_syndrome()
1567 if (chip->ecc.prepad) { in nand_read_page_syndrome()
1568 chip->read_buf(mtd, oob, chip->ecc.prepad); in nand_read_page_syndrome()
1569 oob += chip->ecc.prepad; in nand_read_page_syndrome()
1572 chip->ecc.hwctl(mtd, NAND_ECC_READSYN); in nand_read_page_syndrome()
1574 stat = chip->ecc.correct(mtd, p, oob, NULL); in nand_read_page_syndrome()
1585 if (chip->ecc.postpad) { in nand_read_page_syndrome()
1586 chip->read_buf(mtd, oob, chip->ecc.postpad); in nand_read_page_syndrome()
1587 oob += chip->ecc.postpad; in nand_read_page_syndrome()
1617 struct nand_oobfree *free = chip->ecc.layout->oobfree; in nand_transfer_oob()
1737 ret = chip->ecc.read_page_raw(mtd, chip, bufpoi, in nand_do_read_ops()
1742 ret = chip->ecc.read_subpage(mtd, chip, in nand_do_read_ops()
1746 ret = chip->ecc.read_page(mtd, chip, bufpoi, in nand_do_read_ops()
1907 int chunk = chip->ecc.bytes + chip->ecc.prepad + chip->ecc.postpad; in nand_read_oob_syndrome()
1908 int eccsize = chip->ecc.size; in nand_read_oob_syndrome()
1912 chip->cmdfunc(mtd, NAND_CMD_READ0, chip->ecc.size, page); in nand_read_oob_syndrome()
1913 for (i = 0; i < chip->ecc.steps; i++) { in nand_read_oob_syndrome()
1966 int chunk = chip->ecc.bytes + chip->ecc.prepad + chip->ecc.postpad; in nand_write_oob_syndrome()
1967 int eccsize = chip->ecc.size, length = mtd->oobsize; in nand_write_oob_syndrome()
1968 int i, len, pos, status = 0, sndcmd = 0, steps = chip->ecc.steps; in nand_write_oob_syndrome()
1976 if (!chip->ecc.prepad && !chip->ecc.postpad) { in nand_write_oob_syndrome()
2040 len = chip->ecc.layout->oobavail; in nand_do_read_oob()
2068 ret = chip->ecc.read_oob_raw(mtd, chip, page); in nand_do_read_oob()
2070 ret = chip->ecc.read_oob(mtd, chip, page); in nand_do_read_oob()
2194 int eccsize = chip->ecc.size; in nand_write_page_raw_syndrome()
2195 int eccbytes = chip->ecc.bytes; in nand_write_page_raw_syndrome()
2199 for (steps = chip->ecc.steps; steps > 0; steps--) { in nand_write_page_raw_syndrome()
2203 if (chip->ecc.prepad) { in nand_write_page_raw_syndrome()
2204 chip->write_buf(mtd, oob, chip->ecc.prepad); in nand_write_page_raw_syndrome()
2205 oob += chip->ecc.prepad; in nand_write_page_raw_syndrome()
2211 if (chip->ecc.postpad) { in nand_write_page_raw_syndrome()
2212 chip->write_buf(mtd, oob, chip->ecc.postpad); in nand_write_page_raw_syndrome()
2213 oob += chip->ecc.postpad; in nand_write_page_raw_syndrome()
2235 int i, eccsize = chip->ecc.size; in nand_write_page_swecc()
2236 int eccbytes = chip->ecc.bytes; in nand_write_page_swecc()
2237 int eccsteps = chip->ecc.steps; in nand_write_page_swecc()
2240 uint32_t *eccpos = chip->ecc.layout->eccpos; in nand_write_page_swecc()
2244 chip->ecc.calculate(mtd, p, &ecc_calc[i]); in nand_write_page_swecc()
2246 for (i = 0; i < chip->ecc.total; i++) in nand_write_page_swecc()
2249 return chip->ecc.write_page_raw(mtd, chip, buf, 1, page); in nand_write_page_swecc()
2264 int i, eccsize = chip->ecc.size; in nand_write_page_hwecc()
2265 int eccbytes = chip->ecc.bytes; in nand_write_page_hwecc()
2266 int eccsteps = chip->ecc.steps; in nand_write_page_hwecc()
2269 uint32_t *eccpos = chip->ecc.layout->eccpos; in nand_write_page_hwecc()
2272 chip->ecc.hwctl(mtd, NAND_ECC_WRITE); in nand_write_page_hwecc()
2274 chip->ecc.calculate(mtd, p, &ecc_calc[i]); in nand_write_page_hwecc()
2277 for (i = 0; i < chip->ecc.total; i++) in nand_write_page_hwecc()
2303 int ecc_size = chip->ecc.size; in nand_write_subpage_hwecc()
2304 int ecc_bytes = chip->ecc.bytes; in nand_write_subpage_hwecc()
2305 int ecc_steps = chip->ecc.steps; in nand_write_subpage_hwecc()
2306 uint32_t *eccpos = chip->ecc.layout->eccpos; in nand_write_subpage_hwecc()
2314 chip->ecc.hwctl(mtd, NAND_ECC_WRITE); in nand_write_subpage_hwecc()
2323 chip->ecc.calculate(mtd, buf, ecc_calc); in nand_write_subpage_hwecc()
2338 for (i = 0; i < chip->ecc.total; i++) in nand_write_subpage_hwecc()
2364 int i, eccsize = chip->ecc.size; in nand_write_page_syndrome()
2365 int eccbytes = chip->ecc.bytes; in nand_write_page_syndrome()
2366 int eccsteps = chip->ecc.steps; in nand_write_page_syndrome()
2372 chip->ecc.hwctl(mtd, NAND_ECC_WRITE); in nand_write_page_syndrome()
2375 if (chip->ecc.prepad) { in nand_write_page_syndrome()
2376 chip->write_buf(mtd, oob, chip->ecc.prepad); in nand_write_page_syndrome()
2377 oob += chip->ecc.prepad; in nand_write_page_syndrome()
2380 chip->ecc.calculate(mtd, p, oob); in nand_write_page_syndrome()
2384 if (chip->ecc.postpad) { in nand_write_page_syndrome()
2385 chip->write_buf(mtd, oob, chip->ecc.postpad); in nand_write_page_syndrome()
2386 oob += chip->ecc.postpad; in nand_write_page_syndrome()
2417 chip->ecc.write_subpage) in nand_write_page()
2425 status = chip->ecc.write_page_raw(mtd, chip, buf, in nand_write_page()
2428 status = chip->ecc.write_subpage(mtd, chip, offset, data_len, in nand_write_page()
2431 status = chip->ecc.write_page(mtd, chip, buf, oob_required, in nand_write_page()
2491 struct nand_oobfree *free = chip->ecc.layout->oobfree; in nand_fill_oob()
2731 len = chip->ecc.layout->oobavail; in nand_do_write_oob()
2785 status = chip->ecc.write_oob_raw(mtd, chip, page & chip->pagemask); in nand_do_write_oob()
2787 status = chip->ecc.write_oob(mtd, chip, page & chip->pagemask); in nand_do_write_oob()
3202 struct onfi_ext_ecc_info *ecc; in nand_flash_detect_ext_param_page() local
3251 ecc = (struct onfi_ext_ecc_info *)cursor; in nand_flash_detect_ext_param_page()
3253 if (!ecc->codeword_size) { in nand_flash_detect_ext_param_page()
3258 chip->ecc_strength_ds = ecc->ecc_bits; in nand_flash_detect_ext_param_page()
3259 chip->ecc_step_ds = 1 << ecc->codeword_size; in nand_flash_detect_ext_param_page()
3402 struct jedec_ecc_info *ecc; in nand_flash_detect_jedec() local
3464 ecc = &p->ecc_info[0]; in nand_flash_detect_jedec()
3466 if (ecc->codeword_size >= 9) { in nand_flash_detect_jedec()
3467 chip->ecc_strength_ds = ecc->ecc_bits; in nand_flash_detect_jedec()
3468 chip->ecc_step_ds = 1 << ecc->codeword_size; in nand_flash_detect_jedec()
3962 chip->ecc.mode = ecc_mode; in nand_dt_init()
3965 chip->ecc.strength = ecc_strength; in nand_dt_init()
3968 chip->ecc.size = ecc_step; in nand_dt_init()
4059 struct nand_ecc_ctrl *ecc = &chip->ecc; in nand_ecc_strength_good() local
4062 if (ecc->size == 0 || chip->ecc_step_ds == 0) in nand_ecc_strength_good()
4070 corr = (mtd->writesize * ecc->strength) / ecc->size; in nand_ecc_strength_good()
4073 return corr >= ds_corr && ecc->strength >= chip->ecc_strength_ds; in nand_ecc_strength_good()
4088 struct nand_ecc_ctrl *ecc = &chip->ecc; in nand_scan_tail() local
4116 if (!ecc->layout && (ecc->mode != NAND_ECC_SOFT_BCH)) { in nand_scan_tail()
4119 ecc->layout = &nand_oob_8; in nand_scan_tail()
4122 ecc->layout = &nand_oob_16; in nand_scan_tail()
4125 ecc->layout = &nand_oob_64; in nand_scan_tail()
4128 ecc->layout = &nand_oob_128; in nand_scan_tail()
4145 switch (ecc->mode) { in nand_scan_tail()
4148 if (!ecc->calculate || !ecc->correct || !ecc->hwctl) { in nand_scan_tail()
4152 if (!ecc->read_page) in nand_scan_tail()
4153 ecc->read_page = nand_read_page_hwecc_oob_first; in nand_scan_tail()
4157 if (!ecc->read_page) in nand_scan_tail()
4158 ecc->read_page = nand_read_page_hwecc; in nand_scan_tail()
4159 if (!ecc->write_page) in nand_scan_tail()
4160 ecc->write_page = nand_write_page_hwecc; in nand_scan_tail()
4161 if (!ecc->read_page_raw) in nand_scan_tail()
4162 ecc->read_page_raw = nand_read_page_raw; in nand_scan_tail()
4163 if (!ecc->write_page_raw) in nand_scan_tail()
4164 ecc->write_page_raw = nand_write_page_raw; in nand_scan_tail()
4165 if (!ecc->read_oob) in nand_scan_tail()
4166 ecc->read_oob = nand_read_oob_std; in nand_scan_tail()
4167 if (!ecc->write_oob) in nand_scan_tail()
4168 ecc->write_oob = nand_write_oob_std; in nand_scan_tail()
4169 if (!ecc->read_subpage) in nand_scan_tail()
4170 ecc->read_subpage = nand_read_subpage; in nand_scan_tail()
4171 if (!ecc->write_subpage) in nand_scan_tail()
4172 ecc->write_subpage = nand_write_subpage_hwecc; in nand_scan_tail()
4175 if ((!ecc->calculate || !ecc->correct || !ecc->hwctl) && in nand_scan_tail()
4176 (!ecc->read_page || in nand_scan_tail()
4177 ecc->read_page == nand_read_page_hwecc || in nand_scan_tail()
4178 !ecc->write_page || in nand_scan_tail()
4179 ecc->write_page == nand_write_page_hwecc)) { in nand_scan_tail()
4184 if (!ecc->read_page) in nand_scan_tail()
4185 ecc->read_page = nand_read_page_syndrome; in nand_scan_tail()
4186 if (!ecc->write_page) in nand_scan_tail()
4187 ecc->write_page = nand_write_page_syndrome; in nand_scan_tail()
4188 if (!ecc->read_page_raw) in nand_scan_tail()
4189 ecc->read_page_raw = nand_read_page_raw_syndrome; in nand_scan_tail()
4190 if (!ecc->write_page_raw) in nand_scan_tail()
4191 ecc->write_page_raw = nand_write_page_raw_syndrome; in nand_scan_tail()
4192 if (!ecc->read_oob) in nand_scan_tail()
4193 ecc->read_oob = nand_read_oob_syndrome; in nand_scan_tail()
4194 if (!ecc->write_oob) in nand_scan_tail()
4195 ecc->write_oob = nand_write_oob_syndrome; in nand_scan_tail()
4197 if (mtd->writesize >= ecc->size) { in nand_scan_tail()
4198 if (!ecc->strength) { in nand_scan_tail()
4205 ecc->size, mtd->writesize); in nand_scan_tail()
4206 ecc->mode = NAND_ECC_SOFT; in nand_scan_tail()
4209 ecc->calculate = nand_calculate_ecc; in nand_scan_tail()
4210 ecc->correct = nand_correct_data; in nand_scan_tail()
4211 ecc->read_page = nand_read_page_swecc; in nand_scan_tail()
4212 ecc->read_subpage = nand_read_subpage; in nand_scan_tail()
4213 ecc->write_page = nand_write_page_swecc; in nand_scan_tail()
4214 ecc->read_page_raw = nand_read_page_raw; in nand_scan_tail()
4215 ecc->write_page_raw = nand_write_page_raw; in nand_scan_tail()
4216 ecc->read_oob = nand_read_oob_std; in nand_scan_tail()
4217 ecc->write_oob = nand_write_oob_std; in nand_scan_tail()
4218 if (!ecc->size) in nand_scan_tail()
4219 ecc->size = 256; in nand_scan_tail()
4220 ecc->bytes = 3; in nand_scan_tail()
4221 ecc->strength = 1; in nand_scan_tail()
4229 ecc->calculate = nand_bch_calculate_ecc; in nand_scan_tail()
4230 ecc->correct = nand_bch_correct_data; in nand_scan_tail()
4231 ecc->read_page = nand_read_page_swecc; in nand_scan_tail()
4232 ecc->read_subpage = nand_read_subpage; in nand_scan_tail()
4233 ecc->write_page = nand_write_page_swecc; in nand_scan_tail()
4234 ecc->read_page_raw = nand_read_page_raw; in nand_scan_tail()
4235 ecc->write_page_raw = nand_write_page_raw; in nand_scan_tail()
4236 ecc->read_oob = nand_read_oob_std; in nand_scan_tail()
4237 ecc->write_oob = nand_write_oob_std; in nand_scan_tail()
4243 if (!ecc->size && (mtd->oobsize >= 64)) { in nand_scan_tail()
4244 ecc->size = 512; in nand_scan_tail()
4245 ecc->strength = 4; in nand_scan_tail()
4249 ecc->bytes = DIV_ROUND_UP( in nand_scan_tail()
4250 ecc->strength * fls(8 * ecc->size), 8); in nand_scan_tail()
4251 ecc->priv = nand_bch_init(mtd, ecc->size, ecc->bytes, in nand_scan_tail()
4252 &ecc->layout); in nand_scan_tail()
4253 if (!ecc->priv) { in nand_scan_tail()
4261 ecc->read_page = nand_read_page_raw; in nand_scan_tail()
4262 ecc->write_page = nand_write_page_raw; in nand_scan_tail()
4263 ecc->read_oob = nand_read_oob_std; in nand_scan_tail()
4264 ecc->read_page_raw = nand_read_page_raw; in nand_scan_tail()
4265 ecc->write_page_raw = nand_write_page_raw; in nand_scan_tail()
4266 ecc->write_oob = nand_write_oob_std; in nand_scan_tail()
4267 ecc->size = mtd->writesize; in nand_scan_tail()
4268 ecc->bytes = 0; in nand_scan_tail()
4269 ecc->strength = 0; in nand_scan_tail()
4273 pr_warn("Invalid NAND_ECC_MODE %d\n", ecc->mode); in nand_scan_tail()
4278 if (!ecc->read_oob_raw) in nand_scan_tail()
4279 ecc->read_oob_raw = ecc->read_oob; in nand_scan_tail()
4280 if (!ecc->write_oob_raw) in nand_scan_tail()
4281 ecc->write_oob_raw = ecc->write_oob; in nand_scan_tail()
4287 ecc->layout->oobavail = 0; in nand_scan_tail()
4288 for (i = 0; ecc->layout->oobfree[i].length in nand_scan_tail()
4289 && i < ARRAY_SIZE(ecc->layout->oobfree); i++) in nand_scan_tail()
4290 ecc->layout->oobavail += ecc->layout->oobfree[i].length; in nand_scan_tail()
4291 mtd->oobavail = ecc->layout->oobavail; in nand_scan_tail()
4302 ecc->steps = mtd->writesize / ecc->size; in nand_scan_tail()
4303 if (ecc->steps * ecc->size != mtd->writesize) { in nand_scan_tail()
4307 ecc->total = ecc->steps * ecc->bytes; in nand_scan_tail()
4311 switch (ecc->steps) { in nand_scan_tail()
4331 switch (ecc->mode) { in nand_scan_tail()
4366 mtd->ecclayout = ecc->layout; in nand_scan_tail()
4367 mtd->ecc_strength = ecc->strength; in nand_scan_tail()
4368 mtd->ecc_step_size = ecc->size; in nand_scan_tail()
4426 if (chip->ecc.mode == NAND_ECC_SOFT_BCH) in nand_release()
4427 nand_bch_free((struct nand_bch_control *)chip->ecc.priv); in nand_release()