Lines Matching defs:mtd

8  *	http://www.linux-mtd.infradead.org/doc/nand.html
21 * Check, if mtd->ecctype should be set to MTD_ECC_HW
36 #include <linux/mtd/mtd.h>
37 #include <linux/mtd/nand.h>
38 #include <linux/mtd/nand_ecc.h>
39 #include <linux/mtd/nand_bch.h>
43 #include <linux/mtd/partitions.h>
49 static int nand_pairing_dist3_get_info(struct mtd_info *mtd, int page,
52 int lastpage = (mtd->erasesize / mtd->writesize) - 1;
69 static int nand_pairing_dist3_get_wunit(struct mtd_info *mtd,
72 int lastpair = ((mtd->erasesize / mtd->writesize) - 1) / 2;
87 if (page >= mtd->erasesize / mtd->writesize)
227 struct mtd_info *mtd = nand_to_mtd(chip);
228 int last_page = ((mtd->erasesize - mtd->writesize) >>
349 struct mtd_info *mtd = nand_to_mtd(chip);
356 memset(chip->oob_poi, 0xff, mtd->oobsize);
366 ret = mtd_ooblayout_set_databytes(mtd, oob, chip->oob_poi,
388 struct mtd_info *mtd = nand_to_mtd(chip);
394 len = mtd_oobavail(mtd, ops);
458 struct mtd_info *mtd = nand_to_mtd(chip);
478 ofs + (page_offset * mtd->writesize),
524 struct mtd_info *mtd = nand_to_mtd(chip);
551 mtd->ecc_stats.badblocks++;
558 * @mtd: MTD device structure
563 static int nand_block_isreserved(struct mtd_info *mtd, loff_t ofs)
565 struct nand_chip *chip = mtd_to_nand(mtd);
966 struct mtd_info *mtd = nand_to_mtd(chip);
969 if (offset_in_page > mtd->writesize + mtd->oobsize)
977 if (mtd->writesize <= 512 && offset_in_page >= mtd->writesize)
978 offset_in_page -= mtd->writesize;
997 if (mtd->writesize <= 512)
1011 struct mtd_info *mtd = nand_to_mtd(chip);
1027 if (offset_in_page >= mtd->writesize)
1101 struct mtd_info *mtd = nand_to_mtd(chip);
1106 if (offset_in_page + len > mtd->writesize + mtd->oobsize)
1110 if (mtd->writesize > 512)
1191 struct mtd_info *mtd = nand_to_mtd(chip);
1196 if (offset_in_page + len > mtd->writesize + mtd->oobsize)
1200 if (mtd->writesize <= 512)
1254 struct mtd_info *mtd = nand_to_mtd(chip);
1259 if (offset_in_oob + len > mtd->oobsize)
1264 mtd->writesize + offset_in_oob,
1281 struct mtd_info *mtd = nand_to_mtd(chip);
1319 if (mtd->writesize <= 512) {
1325 if (offset_in_page >= mtd->writesize)
1367 struct mtd_info *mtd = nand_to_mtd(chip);
1372 if (offset_in_page + len > mtd->writesize + mtd->oobsize)
1452 struct mtd_info *mtd = nand_to_mtd(chip);
1458 if (offset_in_page + len > mtd->writesize + mtd->oobsize)
1497 struct mtd_info *mtd = nand_to_mtd(chip);
1502 if (offset_in_page + len > mtd->writesize + mtd->oobsize)
1506 if (mtd->writesize <= 512)
2599 struct mtd_info *mtd = nand_to_mtd(chip);
2602 ret = nand_read_page_op(chip, page, 0, buf, mtd->writesize);
2607 ret = nand_read_data_op(chip, chip->oob_poi, mtd->oobsize,
2635 struct mtd_info *mtd = nand_to_mtd(chip);
2636 unsigned int size = mtd->writesize;
2641 size += mtd->oobsize;
2652 memcpy(buf, read_buf, mtd->writesize);
2670 struct mtd_info *mtd = nand_to_mtd(chip);
2712 size = mtd->oobsize - (oob - chip->oob_poi);
2732 struct mtd_info *mtd = nand_to_mtd(chip);
2746 ret = mtd_ooblayout_get_eccbytes(mtd, ecc_code, chip->oob_poi, 0,
2759 mtd->ecc_stats.failed++;
2761 mtd->ecc_stats.corrected += stat;
2779 struct mtd_info *mtd = nand_to_mtd(chip);
2814 ret = mtd_ooblayout_find_eccregion(mtd, index, &section, &oobregion);
2822 ret = nand_change_read_column_op(chip, mtd->writesize,
2823 chip->oob_poi, mtd->oobsize,
2841 mtd->writesize + aligned_pos,
2848 ret = mtd_ooblayout_get_eccbytes(mtd, chip->ecc.code_buf,
2870 mtd->ecc_stats.failed++;
2872 mtd->ecc_stats.corrected += stat;
2891 struct mtd_info *mtd = nand_to_mtd(chip);
2914 ret = nand_read_data_op(chip, chip->oob_poi, mtd->oobsize, false,
2919 ret = mtd_ooblayout_get_eccbytes(mtd, ecc_code, chip->oob_poi, 0,
2941 mtd->ecc_stats.failed++;
2943 mtd->ecc_stats.corrected += stat;
2963 struct mtd_info *mtd = nand_to_mtd(chip);
3024 mtd->ecc_stats.failed++;
3026 mtd->ecc_stats.corrected += stat;
3032 i = mtd->oobsize - (oob - chip->oob_poi);
3052 struct mtd_info *mtd = nand_to_mtd(chip);
3063 ret = mtd_ooblayout_get_databytes(mtd, oob, chip->oob_poi,
3119 struct mtd_info *mtd = nand_to_mtd(chip);
3123 uint32_t max_oobsize = mtd_oobavail(mtd, ops);
3137 col = (int)(from & (mtd->writesize - 1));
3144 struct mtd_ecc_stats ecc_stats = mtd->ecc_stats;
3146 bytes = min(mtd->writesize - col, readlen);
3147 aligned = (bytes == mtd->writesize);
3195 !(mtd->ecc_stats.failed - ecc_stats.failed) &&
3218 if (mtd->ecc_stats.failed - ecc_stats.failed) {
3227 mtd->ecc_stats = ecc_stats;
3292 struct mtd_info *mtd = nand_to_mtd(chip);
3294 return nand_read_oob_op(chip, page, 0, chip->oob_poi, mtd->oobsize);
3306 struct mtd_info *mtd = nand_to_mtd(chip);
3307 int length = mtd->oobsize;
3322 if (mtd->writesize > 512)
3359 struct mtd_info *mtd = nand_to_mtd(chip);
3361 return nand_prog_page_op(chip, page, mtd->writesize, chip->oob_poi,
3362 mtd->oobsize);
3374 struct mtd_info *mtd = nand_to_mtd(chip);
3376 int eccsize = chip->ecc.size, length = mtd->oobsize;
3397 if (mtd->writesize <= 512) {
3450 struct mtd_info *mtd = nand_to_mtd(chip);
3462 stats = mtd->ecc_stats;
3464 len = mtd_oobavail(mtd, ops);
3511 if (mtd->ecc_stats.failed - stats.failed)
3519 * @mtd: MTD device structure
3525 static int nand_read_oob(struct mtd_info *mtd, loff_t from,
3528 struct nand_chip *chip = mtd_to_nand(mtd);
3576 struct mtd_info *mtd = nand_to_mtd(chip);
3579 ret = nand_prog_page_begin_op(chip, page, 0, buf, mtd->writesize);
3584 ret = nand_write_data_op(chip, chip->oob_poi, mtd->oobsize,
3613 struct mtd_info *mtd = nand_to_mtd(chip);
3614 unsigned int size = mtd->writesize;
3618 size += mtd->oobsize;
3622 memcpy(write_buf, buf, mtd->writesize);
3643 struct mtd_info *mtd = nand_to_mtd(chip);
3685 size = mtd->oobsize - (oob - chip->oob_poi);
3704 struct mtd_info *mtd = nand_to_mtd(chip);
3715 ret = mtd_ooblayout_set_eccbytes(mtd, ecc_calc, chip->oob_poi, 0,
3733 struct mtd_info *mtd = nand_to_mtd(chip);
3754 ret = mtd_ooblayout_set_eccbytes(mtd, ecc_calc, chip->oob_poi, 0,
3759 ret = nand_write_data_op(chip, chip->oob_poi, mtd->oobsize, false);
3780 struct mtd_info *mtd = nand_to_mtd(chip);
3788 int oob_bytes = mtd->oobsize / ecc_steps;
3823 ret = mtd_ooblayout_set_eccbytes(mtd, ecc_calc, chip->oob_poi, 0,
3829 ret = nand_write_data_op(chip, chip->oob_poi, mtd->oobsize, false);
3850 struct mtd_info *mtd = nand_to_mtd(chip);
3897 i = mtd->oobsize - (oob - chip->oob_poi);
3921 struct mtd_info *mtd = nand_to_mtd(chip);
3926 subpage = offset || (data_len < mtd->writesize);
3958 struct mtd_info *mtd = nand_to_mtd(chip);
3963 uint32_t oobmaxlen = mtd_oobavail(mtd, ops);
3981 column = to & (mtd->writesize - 1);
4007 int bytes = mtd->writesize;
4010 int part_pagewr = (column || writelen < mtd->writesize);
4031 memset(wbuf, 0xff, mtd->writesize);
4041 memset(chip->oob_poi, 0xff, mtd->oobsize);
4078 * @mtd: MTD device structure
4087 static int panic_nand_write(struct mtd_info *mtd, loff_t to, size_t len,
4090 struct nand_chip *chip = mtd_to_nand(mtd);
4113 * @mtd: MTD device structure
4117 static int nand_write_oob(struct mtd_info *mtd, loff_t to,
4120 struct nand_chip *chip = mtd_to_nand(mtd);
4149 * @mtd: MTD device structure
4154 static int nand_erase(struct mtd_info *mtd, struct erase_info *instr)
4156 return nand_erase_nand(mtd_to_nand(mtd), instr, 0);
4257 * @mtd: MTD device structure
4261 static void nand_sync(struct mtd_info *mtd)
4263 struct nand_chip *chip = mtd_to_nand(mtd);
4275 * @mtd: MTD device structure
4276 * @offs: offset relative to mtd start
4278 static int nand_block_isbad(struct mtd_info *mtd, loff_t offs)
4280 struct nand_chip *chip = mtd_to_nand(mtd);
4299 * @mtd: MTD device structure
4300 * @ofs: offset relative to mtd start
4302 static int nand_block_markbad(struct mtd_info *mtd, loff_t ofs)
4306 ret = nand_block_isbad(mtd, ofs);
4314 return nand_block_markbad_lowlevel(mtd_to_nand(mtd), ofs);
4319 * @mtd: MTD device structure
4323 static int nand_suspend(struct mtd_info *mtd)
4325 struct nand_chip *chip = mtd_to_nand(mtd);
4340 * @mtd: MTD device structure
4342 static void nand_resume(struct mtd_info *mtd)
4344 struct nand_chip *chip = mtd_to_nand(mtd);
4363 * @mtd: MTD device structure
4365 static void nand_shutdown(struct mtd_info *mtd)
4367 nand_suspend(mtd);
4372 * @mtd: MTD device structure
4376 static int nand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
4378 struct nand_chip *chip = mtd_to_nand(mtd);
4388 * @mtd: MTD device structure
4392 static int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
4394 struct nand_chip *chip = mtd_to_nand(mtd);
4512 struct mtd_info *mtd = nand_to_mtd(chip);
4525 mtd->writesize = memorg->pagesize;
4528 memorg->oobsize = (8 << (extid & 0x01)) * (mtd->writesize >> 9);
4529 mtd->oobsize = memorg->oobsize;
4534 mtd->erasesize = (64 * 1024) << (extid & 0x03);
4549 struct mtd_info *mtd = nand_to_mtd(chip);
4555 mtd->erasesize = type->erasesize;
4557 mtd->writesize = memorg->pagesize;
4559 mtd->oobsize = memorg->oobsize;
4572 struct mtd_info *mtd = nand_to_mtd(chip);
4575 if (mtd->writesize > 512 || (chip->options & NAND_BUSWIDTH_16))
4591 struct mtd_info *mtd = nand_to_mtd(chip);
4599 mtd->writesize = memorg->pagesize;
4602 mtd->erasesize = type->erasesize;
4604 mtd->oobsize = memorg->oobsize;
4691 struct mtd_info *mtd = nand_to_mtd(chip);
4814 if (!mtd->name)
4815 mtd->name = chip->parameters.model;
4828 mtd->name);
4839 chip->page_shift = ffs(mtd->writesize) - 1;
4845 ffs(mtd->erasesize) - 1;
4866 mtd->erasesize >> 10, mtd->writesize, mtd->oobsize);
5054 struct mtd_info *mtd = nand_to_mtd(chip);
5075 if (!mtd->name && mtd->dev.parent)
5076 mtd->name = dev_name(mtd->dev.parent);
5125 /* Store the number of chips and calc total size for mtd */
5127 mtd->size = i * nanddev_target_size(&chip->base);
5199 struct mtd_info *mtd = nand_to_mtd(chip);
5200 struct nand_device *nanddev = mtd_to_nanddev(mtd);
5250 if (!ecc->size && (mtd->oobsize >= 64)) {
5259 if (!mtd->ooblayout) {
5261 if (mtd->oobsize < 64) {
5266 mtd_set_ooblayout(mtd, nand_get_large_page_ooblayout());
5275 if (mtd->ooblayout == nand_get_large_page_ooblayout() &&
5281 steps = mtd->writesize / ecc->size;
5284 bytes = (mtd->oobsize - 2) / steps;
5290 ecc->priv = nand_bch_init(mtd);
5316 struct mtd_info *mtd = nand_to_mtd(chip);
5320 int ecc_bytes, nsteps = mtd->writesize / preset_step;
5372 struct mtd_info *mtd = nand_to_mtd(chip);
5386 req_corr = mtd->writesize / req_step * req_strength;
5403 if (mtd->writesize % step_size)
5406 nsteps = mtd->writesize / step_size;
5453 struct mtd_info *mtd = nand_to_mtd(chip);
5472 if (mtd->writesize % step_size)
5475 nsteps = mtd->writesize / step_size;
5531 struct mtd_info *mtd = nand_to_mtd(chip);
5532 struct nand_device *nanddev = mtd_to_nanddev(mtd);
5534 if (WARN_ON(oobavail < 0 || oobavail > mtd->oobsize))
5604 struct mtd_info *mtd = nand_to_mtd(chip);
5614 chip->data_buf = kmalloc(mtd->writesize + mtd->oobsize, GFP_KERNEL);
5631 chip->oob_poi = chip->data_buf + mtd->writesize;
5636 if (!mtd->ooblayout &&
5639 switch (mtd->oobsize) {
5642 mtd_set_ooblayout(mtd, nand_get_small_page_ooblayout());
5646 mtd_set_ooblayout(mtd,
5658 mtd_set_ooblayout(mtd,
5664 mtd->oobsize);
5681 if (mtd->writesize >= ecc->size) {
5690 ecc->size, mtd->writesize);
5721 ecc->size = mtd->writesize;
5733 ecc->calc_buf = kmalloc(mtd->oobsize, GFP_KERNEL);
5734 ecc->code_buf = kmalloc(mtd->oobsize, GFP_KERNEL);
5748 mtd->ecc_strength = ecc->strength;
5749 mtd->ecc_step_size = ecc->size;
5755 ecc->steps = mtd->writesize / ecc->size;
5756 if (ecc->steps * ecc->size != mtd->writesize) {
5765 if (ecc->total > mtd->oobsize) {
5775 ret = mtd_ooblayout_count_freebytes(mtd);
5779 mtd->oobavail = ret;
5784 mtd->name, chip->ecc.strength, chip->ecc.size,
5792 mtd->subpage_sft = 1;
5797 mtd->subpage_sft = 2;
5801 chip->subpagesize = mtd->writesize >> mtd->subpage_sft;
5817 ret = nanddev_init(&chip->base, &rawnand_ops, mtd->owner);
5823 mtd->flags = MTD_CAP_ROM;
5826 mtd->_erase = nand_erase;
5827 mtd->_point = NULL;
5828 mtd->_unpoint = NULL;
5829 mtd->_panic_write = panic_nand_write;
5830 mtd->_read_oob = nand_read_oob;
5831 mtd->_write_oob = nand_write_oob;
5832 mtd->_sync = nand_sync;
5833 mtd->_lock = nand_lock;
5834 mtd->_unlock = nand_unlock;
5835 mtd->_suspend = nand_suspend;
5836 mtd->_resume = nand_resume;
5837 mtd->_reboot = nand_shutdown;
5838 mtd->_block_isreserved = nand_block_isreserved;
5839 mtd->_block_isbad = nand_block_isbad;
5840 mtd->_block_markbad = nand_block_markbad;
5841 mtd->_max_bad_blocks = nanddev_mtd_max_bad_blocks;
5848 if (!mtd->bitflip_threshold)
5849 mtd->bitflip_threshold = DIV_ROUND_UP(mtd->ecc_strength * 3, 4);
5912 * The flash ID is read and the mtd/chip structures are filled with the