Lines Matching +full:ecc +full:- +full:engine

1 // SPDX-License-Identifier: GPL-2.0
6 * Boris Brezillon <boris.brezillon@free-electrons.com>
16 * nanddev_isbad() - Check if a block is bad
35 if (nand->ops->isbad(nand, pos)) in nanddev_isbad()
50 return nand->ops->isbad(nand, pos); in nanddev_isbad()
55 * nanddev_markbad() - Mark a block as bad
60 * calls the low-level markbad hook (nand->ops->markbad()).
73 ret = nand->ops->markbad(nand, pos); in nanddev_markbad()
90 mtd->ecc_stats.badblocks++; in nanddev_markbad()
97 * nanddev_isreserved() - Check whether an eraseblock is reserved or not
121 * nanddev_erase() - Erase a NAND portion
134 return -EIO; in nanddev_erase()
137 return nand->ops->erase(nand, pos); in nanddev_erase()
142 * nanddev_mtd_erase() - Generic mtd->_erase() implementation for NAND devices
146 * This is a simple mtd->_erase() implementation iterating over all blocks
147 * concerned by @einfo and calling nand->ops->erase() on each of them.
149 * Note that mtd->_erase should not be directly assigned to this helper,
162 nanddev_offs_to_pos(nand, einfo->addr, &pos); in nanddev_mtd_erase()
163 nanddev_offs_to_pos(nand, einfo->addr + einfo->len - 1, &last); in nanddev_mtd_erase()
167 einfo->fail_addr = nanddev_pos_to_offs(nand, &pos); in nanddev_mtd_erase()
180 * nanddev_mtd_max_bad_blocks() - Get the maximum number of bad eraseblock on
186 * Default implementation for mtd->_max_bad_blocks(). Only works if
187 * nand->memorg.max_bad_eraseblocks_per_lun is > 0.
198 if (!nand->memorg.max_bad_eraseblocks_per_lun) in nanddev_mtd_max_bad_blocks()
199 return -ENOTSUPP; in nanddev_mtd_max_bad_blocks()
207 max_bb += nand->memorg.max_bad_eraseblocks_per_lun; in nanddev_mtd_max_bad_blocks()
214 * nanddev_get_ecc_engine() - Find and get a suitable ECC engine
221 /* Read the user desires in terms of ECC engine/configuration */ in nanddev_get_ecc_engine()
224 engine_type = nand->ecc.user_conf.engine_type; in nanddev_get_ecc_engine()
226 engine_type = nand->ecc.defaults.engine_type; in nanddev_get_ecc_engine()
232 nand->ecc.engine = nand_ecc_get_sw_engine(nand); in nanddev_get_ecc_engine()
235 nand->ecc.engine = nand_ecc_get_on_die_hw_engine(nand); in nanddev_get_ecc_engine()
238 nand->ecc.engine = nand_ecc_get_on_host_hw_engine(nand); in nanddev_get_ecc_engine()
239 if (PTR_ERR(nand->ecc.engine) == -EPROBE_DEFER) in nanddev_get_ecc_engine()
240 return -EPROBE_DEFER; in nanddev_get_ecc_engine()
243 pr_err("Missing ECC engine type\n"); in nanddev_get_ecc_engine()
246 if (!nand->ecc.engine) in nanddev_get_ecc_engine()
247 return -EINVAL; in nanddev_get_ecc_engine()
253 * nanddev_put_ecc_engine() - Dettach and put the in-use ECC engine
258 switch (nand->ecc.ctx.conf.engine_type) { in nanddev_put_ecc_engine()
273 * nanddev_find_ecc_configuration() - Find a suitable ECC configuration
280 if (!nand->ecc.engine) in nanddev_find_ecc_configuration()
281 return -ENOTSUPP; in nanddev_find_ecc_configuration()
288 …pr_warn("WARNING: %s: the ECC used on your system is too weak compared to the one required by the … in nanddev_find_ecc_configuration()
289 nand->mtd.name); in nanddev_find_ecc_configuration()
295 * nanddev_ecc_engine_init() - Initialize an ECC engine for the chip
302 /* Look for the ECC engine to use */ in nanddev_ecc_engine_init()
305 if (ret != -EPROBE_DEFER) in nanddev_ecc_engine_init()
306 pr_err("No ECC engine found\n"); in nanddev_ecc_engine_init()
311 /* No ECC engine requested */ in nanddev_ecc_engine_init()
312 if (!nand->ecc.engine) in nanddev_ecc_engine_init()
315 /* Configure the engine: balance user input and chip requirements */ in nanddev_ecc_engine_init()
318 pr_err("No suitable ECC configuration\n"); in nanddev_ecc_engine_init()
329 * nanddev_ecc_engine_cleanup() - Cleanup ECC engine initializations
334 if (nand->ecc.engine) in nanddev_ecc_engine_cleanup()
342 * nanddev_init() - Initialize a NAND device
348 * @nand->memorg. Also takes care of initializing the BBT.
359 return -EINVAL; in nanddev_init()
361 if (!ops->erase || !ops->markbad || !ops->isbad) in nanddev_init()
362 return -EINVAL; in nanddev_init()
364 if (!memorg->bits_per_cell || !memorg->pagesize || in nanddev_init()
365 !memorg->pages_per_eraseblock || !memorg->eraseblocks_per_lun || in nanddev_init()
366 !memorg->planes_per_lun || !memorg->luns_per_target || in nanddev_init()
367 !memorg->ntargets) in nanddev_init()
368 return -EINVAL; in nanddev_init()
370 nand->rowconv.eraseblock_addr_shift = in nanddev_init()
371 fls(memorg->pages_per_eraseblock - 1); in nanddev_init()
372 nand->rowconv.lun_addr_shift = fls(memorg->eraseblocks_per_lun - 1) + in nanddev_init()
373 nand->rowconv.eraseblock_addr_shift; in nanddev_init()
375 nand->ops = ops; in nanddev_init()
377 mtd->type = memorg->bits_per_cell == 1 ? in nanddev_init()
379 mtd->flags = MTD_CAP_NANDFLASH; in nanddev_init()
380 mtd->erasesize = memorg->pagesize * memorg->pages_per_eraseblock; in nanddev_init()
381 mtd->writesize = memorg->pagesize; in nanddev_init()
382 mtd->writebufsize = memorg->pagesize; in nanddev_init()
383 mtd->oobsize = memorg->oobsize; in nanddev_init()
384 mtd->size = nanddev_size(nand); in nanddev_init()
385 mtd->owner = owner; in nanddev_init()
392 * nanddev_cleanup() - Release resources allocated in nanddev_init()
405 MODULE_AUTHOR("Boris Brezillon <boris.brezillon@free-electrons.com>");