Lines Matching full:ecc
3 * This file provides ECC correction for more than 1 bit per block of data,
15 #include <linux/mtd/nand-ecc-sw-bch.h>
18 * nand_ecc_sw_bch_calculate - Calculate the ECC corresponding to a data block
21 * @code: Output buffer with ECC
26 struct nand_ecc_sw_bch_conf *engine_conf = nand->ecc.ctx.priv; in nand_ecc_sw_bch_calculate()
30 bch_encode(engine_conf->bch, buf, nand->ecc.ctx.conf.step_size, code); in nand_ecc_sw_bch_calculate()
44 * @read_ecc: ECC bytes from the chip
45 * @calc_ecc: ECC calculated from the raw data
52 struct nand_ecc_sw_bch_conf *engine_conf = nand->ecc.ctx.priv; in nand_ecc_sw_bch_correct()
53 unsigned int step_size = nand->ecc.ctx.conf.step_size; in nand_ecc_sw_bch_correct()
65 /* Otherwise the error is in the ECC area: nothing to do */ in nand_ecc_sw_bch_correct()
70 pr_err("ECC unrecoverable error\n"); in nand_ecc_sw_bch_correct()
79 * nand_ecc_sw_bch_cleanup - Cleanup software BCH ECC resources
84 struct nand_ecc_sw_bch_conf *engine_conf = nand->ecc.ctx.priv; in nand_ecc_sw_bch_cleanup()
92 * nand_ecc_sw_bch_init - Initialize software BCH ECC engine
97 * Initialize NAND BCH error correction. @nand.ecc parameters 'step_size' and
110 struct nand_ecc_sw_bch_conf *engine_conf = nand->ecc.ctx.priv; in nand_ecc_sw_bch_init()
111 unsigned int eccsize = nand->ecc.ctx.conf.step_size; in nand_ecc_sw_bch_init()
132 /* Compute and store the inverted ECC of an erased step */ in nand_ecc_sw_bch_init()
149 pr_err("Invalid number of ECC bytes: %u, expected: %u\n", in nand_ecc_sw_bch_init()
157 pr_err("ECC step size is too large (%u)\n", eccsize); in nand_ecc_sw_bch_init()
172 struct nand_ecc_props *conf = &nand->ecc.ctx.conf; in nand_ecc_sw_bch_init_ctx()
189 conf->step_size = nand->ecc.user_conf.step_size; in nand_ecc_sw_bch_init_ctx()
190 conf->strength = nand->ecc.user_conf.strength; in nand_ecc_sw_bch_init_ctx()
193 * Board driver should supply ECC size and ECC strength in nand_ecc_sw_bch_init_ctx()
210 if (nand->ecc.user_conf.flags & NAND_ECC_MAXIMIZE_STRENGTH) { in nand_ecc_sw_bch_init_ctx()
226 pr_err("Missing ECC parameters\n"); in nand_ecc_sw_bch_init_ctx()
246 nand->ecc.ctx.priv = engine_conf; in nand_ecc_sw_bch_init_ctx()
247 nand->ecc.ctx.nsteps = nsteps; in nand_ecc_sw_bch_init_ctx()
248 nand->ecc.ctx.total = nsteps * code_size; in nand_ecc_sw_bch_init_ctx()
256 nand->ecc.ctx.nsteps * engine_conf->code_size) { in nand_ecc_sw_bch_init_ctx()
257 pr_err("Invalid ECC layout\n"); in nand_ecc_sw_bch_init_ctx()
279 struct nand_ecc_sw_bch_conf *engine_conf = nand->ecc.ctx.priv; in nand_ecc_sw_bch_cleanup_ctx()
294 struct nand_ecc_sw_bch_conf *engine_conf = nand->ecc.ctx.priv; in nand_ecc_sw_bch_prepare_io_req()
296 int eccsize = nand->ecc.ctx.conf.step_size; in nand_ecc_sw_bch_prepare_io_req()
298 int eccsteps = nand->ecc.ctx.nsteps; in nand_ecc_sw_bch_prepare_io_req()
299 int total = nand->ecc.ctx.total; in nand_ecc_sw_bch_prepare_io_req()
318 /* Preparation for page write: derive the ECC bytes and place them */ in nand_ecc_sw_bch_prepare_io_req()
331 struct nand_ecc_sw_bch_conf *engine_conf = nand->ecc.ctx.priv; in nand_ecc_sw_bch_finish_io_req()
333 int eccsize = nand->ecc.ctx.conf.step_size; in nand_ecc_sw_bch_finish_io_req()
334 int total = nand->ecc.ctx.total; in nand_ecc_sw_bch_finish_io_req()
336 int eccsteps = nand->ecc.ctx.nsteps; in nand_ecc_sw_bch_finish_io_req()
357 /* Finish a page read: retrieve the (raw) ECC bytes*/ in nand_ecc_sw_bch_finish_io_req()
363 /* Calculate the ECC bytes */ in nand_ecc_sw_bch_finish_io_req()
368 for (eccsteps = nand->ecc.ctx.nsteps, i = 0, data = req->databuf.in; in nand_ecc_sw_bch_finish_io_req()
406 MODULE_DESCRIPTION("NAND software BCH ECC support");