Lines Matching full:nand

14 #include <linux/mtd/nand.h>
15 #include <linux/mtd/nand-ecc-sw-bch.h>
19 * @nand: NAND device
23 int nand_ecc_sw_bch_calculate(struct nand_device *nand, in nand_ecc_sw_bch_calculate() argument
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()
42 * @nand: NAND device
49 int nand_ecc_sw_bch_correct(struct nand_device *nand, unsigned char *buf, in nand_ecc_sw_bch_correct() argument
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()
80 * @nand: NAND device
82 static void nand_ecc_sw_bch_cleanup(struct nand_device *nand) in nand_ecc_sw_bch_cleanup() argument
84 struct nand_ecc_sw_bch_conf *engine_conf = nand->ecc.ctx.priv; in nand_ecc_sw_bch_cleanup()
93 * @nand: NAND device
95 * Returns: a pointer to a new NAND BCH control structure, or NULL upon failure
97 * Initialize NAND BCH error correction. @nand.ecc parameters 'step_size' and
108 static int nand_ecc_sw_bch_init(struct nand_device *nand) in nand_ecc_sw_bch_init() argument
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()
165 nand_ecc_sw_bch_cleanup(nand); in nand_ecc_sw_bch_init()
170 int nand_ecc_sw_bch_init_ctx(struct nand_device *nand) in nand_ecc_sw_bch_init_ctx() argument
172 struct nand_ecc_props *conf = &nand->ecc.ctx.conf; in nand_ecc_sw_bch_init_ctx()
173 struct mtd_info *mtd = nanddev_to_mtd(nand); in nand_ecc_sw_bch_init_ctx()
178 /* Only large page NAND chips may use BCH */ in nand_ecc_sw_bch_init_ctx()
180 pr_err("BCH cannot be used with small page NAND chips\n"); 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()
210 if (nand->ecc.user_conf.flags & NAND_ECC_MAXIMIZE_STRENGTH) { in nand_ecc_sw_bch_init_ctx()
234 ret = nand_ecc_init_req_tweaking(&engine_conf->req_ctx, nand); 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()
250 ret = nand_ecc_sw_bch_init(nand); in nand_ecc_sw_bch_init_ctx()
256 nand->ecc.ctx.nsteps * engine_conf->code_size) { in nand_ecc_sw_bch_init_ctx()
265 nand_ecc_sw_bch_cleanup(nand); in nand_ecc_sw_bch_init_ctx()
277 void nand_ecc_sw_bch_cleanup_ctx(struct nand_device *nand) in nand_ecc_sw_bch_cleanup_ctx() argument
279 struct nand_ecc_sw_bch_conf *engine_conf = nand->ecc.ctx.priv; in nand_ecc_sw_bch_cleanup_ctx()
282 nand_ecc_sw_bch_cleanup(nand); in nand_ecc_sw_bch_cleanup_ctx()
291 static int nand_ecc_sw_bch_prepare_io_req(struct nand_device *nand, in nand_ecc_sw_bch_prepare_io_req() argument
294 struct nand_ecc_sw_bch_conf *engine_conf = nand->ecc.ctx.priv; in nand_ecc_sw_bch_prepare_io_req()
295 struct mtd_info *mtd = nanddev_to_mtd(nand); 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()
322 nand_ecc_sw_bch_calculate(nand, data, &ecccalc[i]); in nand_ecc_sw_bch_prepare_io_req()
328 static int nand_ecc_sw_bch_finish_io_req(struct nand_device *nand, in nand_ecc_sw_bch_finish_io_req() argument
331 struct nand_ecc_sw_bch_conf *engine_conf = nand->ecc.ctx.priv; in nand_ecc_sw_bch_finish_io_req()
332 struct mtd_info *mtd = nanddev_to_mtd(nand); 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()
365 nand_ecc_sw_bch_calculate(nand, data, &ecccalc[i]); 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()
371 int stat = nand_ecc_sw_bch_correct(nand, data, in nand_ecc_sw_bch_finish_io_req()
406 MODULE_DESCRIPTION("NAND software BCH ECC support");