Lines Matching +full:nand +full:- +full:related

1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Copyright © 1999-2010 David Woodhouse <dwmw2@infradead.org> et al.
15 #include <linux/nvmem-provider.h>
17 #include <mtd/mtd-abi.h>
21 #define MTD_FAIL_ADDR_UNKNOWN -1LL
50 * struct mtd_oob_ops - oob operation operands
61 * @datbuf: data buffer - if NULL only oob data are read/written
65 * one go. If you try to do that on such an MTD device, -EINVAL will be
67 * devices you should split the write request into several sub-requests when the
83 * struct mtd_oob_region - oob region definition
98 * struct mtd_ooblayout_ops - NAND OOB layout operations
100 * Should return -ERANGE if %section exceeds the total number of
103 * Should return -ERANGE if %section exceeds the total number of
114 * struct mtd_pairing_info - page pairing information
128 * The H27UCG8T2BTR-BC datasheet describes the following pairing scheme:
130 * group-0 group-1
132 * pair-0 page-0 page-4
133 * pair-1 page-1 page-5
134 * pair-2 page-2 page-8
136 * pair-127 page-251 page-255
149 * struct mtd_pairing_scheme - page pairing scheme description
151 * @ngroups: number of groups. Should be related to the number of bits
153 * @get_info: converts a write-unit (page number within an erase block) into
156 * -EINVAL if the wunit parameter is invalid.
157 * @get_wunit: converts pairing information into a write-unit (page) number.
160 * return -EINVAL, if there's no wunit corresponding to the
167 * NAND page pairing scheme. Instead of exposing two big tables to do the
168 * write-unit <-> (pair + group) conversions, we ask the MTD drivers to
169 * implement the ->get_info() and ->get_wunit() functions.
192 * struct mtd_debug_info - debugging information for an MTD device.
201 * struct mtd_part - MTD partition specific fields
205 * @size: partition size. Should be equal to mtd->size unless
210 * This struct is embedded in mtd_info and contains partition-specific
221 * struct mtd_master - MTD master specific fields
225 * sub-partitions.
228 * This struct is embedded in mtd_info and contains master-specific
249 * though individual bits can be cleared), in case of NAND flash it is
250 * one NAND page (or half, or one-fourths of it), in case of ECC-ed NOR
263 * equivalent to writesize (NAND page size). Some NOR flashes do have
282 * read ops return -EUCLEAN if max number of bitflips corrected on any
285 * in sysfs. N.B. The meaning of the -EUCLEAN return code has changed;
286 * see Documentation/ABI/testing/sysfs-class-mtd for more detail.
290 /* Kernel-only stuff starts here. */
297 /* NAND pairing scheme, only provided for MLC/TLC NANDs */
375 /* Subpage shift (NAND) */
405 while (mtd->parent) in mtd_get_master()
406 mtd = mtd->parent; in mtd_get_master()
413 while (mtd->parent) { in mtd_get_master_ofs()
414 ofs += mtd->part.offset; in mtd_get_master_ofs()
415 mtd = mtd->parent; in mtd_get_master_ofs()
423 return mtd->parent; in mtd_is_partition()
428 return !list_empty(&mtd->partitions); in mtd_has_partitions()
452 mtd->ooblayout = ooblayout; in mtd_set_ooblayout()
458 mtd->pairing = pairing; in mtd_set_pairing_scheme()
464 mtd->dev.of_node = np; in mtd_set_of_node()
465 if (!mtd->name) in mtd_set_of_node()
466 of_property_read_string(np, "label", &mtd->name); in mtd_set_of_node()
471 return dev_of_node(&mtd->dev); in mtd_get_of_node()
476 return ops->mode == MTD_OPS_AUTO_OOB ? mtd->oobavail : mtd->oobsize; in mtd_oobavail()
484 if (!master->_max_bad_blocks) in mtd_max_bad_blocks()
485 return -ENOTSUPP; in mtd_max_bad_blocks()
487 if (mtd->size < (len + ofs) || ofs < 0) in mtd_max_bad_blocks()
488 return -EINVAL; in mtd_max_bad_blocks()
490 return master->_max_bad_blocks(master, mtd_get_master_ofs(mtd, ofs), in mtd_max_bad_blocks()
535 if (master->_sync) in mtd_sync()
536 master->_sync(master); in mtd_sync()
551 if (master->master.suspended) in mtd_suspend()
554 ret = master->_suspend ? master->_suspend(master) : 0; in mtd_suspend()
558 master->master.suspended = 1; in mtd_suspend()
566 if (!master->master.suspended) in mtd_resume()
569 if (master->_resume) in mtd_resume()
570 master->_resume(master); in mtd_resume()
572 master->master.suspended = 0; in mtd_resume()
577 if (mtd->erasesize_shift) in mtd_div_by_eb()
578 return sz >> mtd->erasesize_shift; in mtd_div_by_eb()
579 do_div(sz, mtd->erasesize); in mtd_div_by_eb()
585 if (mtd->erasesize_shift) in mtd_mod_by_eb()
586 return sz & mtd->erasesize_mask; in mtd_mod_by_eb()
587 return do_div(sz, mtd->erasesize); in mtd_mod_by_eb()
591 * mtd_align_erase_req - Adjust an erase request to align things on eraseblock
596 * This function will adjust @req->addr and @req->len to align them on
597 * @mtd->erasesize. Of course we expect @mtd->erasesize to be != 0.
604 if (WARN_ON(!mtd->erasesize)) in mtd_align_erase_req()
607 mod = mtd_mod_by_eb(req->addr, mtd); in mtd_align_erase_req()
609 req->addr -= mod; in mtd_align_erase_req()
610 req->len += mod; in mtd_align_erase_req()
613 mod = mtd_mod_by_eb(req->addr + req->len, mtd); in mtd_align_erase_req()
615 req->len += mtd->erasesize - mod; in mtd_align_erase_req()
620 if (mtd->writesize_shift) in mtd_div_by_ws()
621 return sz >> mtd->writesize_shift; in mtd_div_by_ws()
622 do_div(sz, mtd->writesize); in mtd_div_by_ws()
628 if (mtd->writesize_shift) in mtd_mod_by_ws()
629 return sz & mtd->writesize_mask; in mtd_mod_by_ws()
630 return do_div(sz, mtd->writesize); in mtd_mod_by_ws()
637 return master->erasesize / mtd->writesize; in mtd_wunit_per_eb()
648 return base + (wunit * mtd->writesize); in mtd_wunit_to_offset()
656 return master->_read_oob && master->_write_oob; in mtd_has_oob()
661 return mtd->type == MTD_NANDFLASH || mtd->type == MTD_MLCNANDFLASH; in mtd_type_is_nand()
668 return !!master->_block_isbad; in mtd_can_have_bb()
671 /* Kernel-side ioctl definitions */
704 return err == -EUCLEAN; in mtd_is_bitflip()
708 return err == -EBADMSG; in mtd_is_eccerr()