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-sw-hamming.h>
39 #include <linux/mtd/nand-ecc-sw-bch.h>
43 #include <linux/mtd/partitions.h>
50 static int nand_pairing_dist3_get_info(struct mtd_info *mtd, int page,
53 int lastpage = (mtd->erasesize / mtd->writesize) - 1;
70 static int nand_pairing_dist3_get_wunit(struct mtd_info *mtd,
73 int lastpair = ((mtd->erasesize / mtd->writesize) - 1) / 2;
88 if (page >= mtd->erasesize / mtd->writesize)
228 struct mtd_info *mtd = nand_to_mtd(chip);
229 int last_page = ((mtd->erasesize - mtd->writesize) >>
315 struct mtd_info *mtd = nand_to_mtd(chip);
321 if (nand_region_is_secured(chip, ofs, mtd->erasesize))
388 struct mtd_info *mtd = nand_to_mtd(chip);
395 memset(chip->oob_poi, 0xff, mtd->oobsize);
405 ret = mtd_ooblayout_set_databytes(mtd, oob, chip->oob_poi,
427 struct mtd_info *mtd = nand_to_mtd(chip);
433 len = mtd_oobavail(mtd, ops);
501 struct mtd_info *mtd = nand_to_mtd(chip);
521 ofs + (page_offset * mtd->writesize),
567 struct mtd_info *mtd = nand_to_mtd(chip);
594 mtd->ecc_stats.badblocks++;
601 * @mtd: MTD device structure
606 static int nand_block_isreserved(struct mtd_info *mtd, loff_t ofs)
608 struct nand_chip *chip = mtd_to_nand(mtd);
1092 struct mtd_info *mtd = nand_to_mtd(chip);
1095 if (offset_in_page > mtd->writesize + mtd->oobsize)
1103 if (mtd->writesize <= 512 && offset_in_page >= mtd->writesize)
1104 offset_in_page -= mtd->writesize;
1123 if (mtd->writesize <= 512)
1137 struct mtd_info *mtd = nand_to_mtd(chip);
1153 if (offset_in_page >= mtd->writesize)
1324 struct mtd_info *mtd = nand_to_mtd(chip);
1329 if (offset_in_page + len > mtd->writesize + mtd->oobsize)
1333 if (mtd->writesize > 512) {
1421 struct mtd_info *mtd = nand_to_mtd(chip);
1426 if (offset_in_page + len > mtd->writesize + mtd->oobsize)
1430 if (mtd->writesize <= 512)
1484 struct mtd_info *mtd = nand_to_mtd(chip);
1489 if (offset_in_oob + len > mtd->oobsize)
1494 mtd->writesize + offset_in_oob,
1511 struct mtd_info *mtd = nand_to_mtd(chip);
1548 if (mtd->writesize <= 512) {
1554 if (offset_in_page >= mtd->writesize)
1588 struct mtd_info *mtd = nand_to_mtd(chip);
1593 if (offset_in_page + len > mtd->writesize + mtd->oobsize)
1674 struct mtd_info *mtd = nand_to_mtd(chip);
1681 if (offset_in_page + len > mtd->writesize + mtd->oobsize)
1730 struct mtd_info *mtd = nand_to_mtd(chip);
1735 if (offset_in_page + len > mtd->writesize + mtd->oobsize)
1739 if (mtd->writesize <= 512)
2918 struct mtd_info *mtd = nand_to_mtd(chip);
2921 ret = nand_read_page_op(chip, page, 0, buf, mtd->writesize);
2926 ret = nand_read_data_op(chip, chip->oob_poi, mtd->oobsize,
2954 struct mtd_info *mtd = nand_to_mtd(chip);
2955 unsigned int size = mtd->writesize;
2960 size += mtd->oobsize;
2971 memcpy(buf, read_buf, mtd->writesize);
2989 struct mtd_info *mtd = nand_to_mtd(chip);
3031 size = mtd->oobsize - (oob - chip->oob_poi);
3051 struct mtd_info *mtd = nand_to_mtd(chip);
3065 ret = mtd_ooblayout_get_eccbytes(mtd, ecc_code, chip->oob_poi, 0,
3078 mtd->ecc_stats.failed++;
3080 mtd->ecc_stats.corrected += stat;
3098 struct mtd_info *mtd = nand_to_mtd(chip);
3133 ret = mtd_ooblayout_find_eccregion(mtd, index, §ion, &oobregion);
3141 ret = nand_change_read_column_op(chip, mtd->writesize,
3142 chip->oob_poi, mtd->oobsize,
3160 mtd->writesize + aligned_pos,
3167 ret = mtd_ooblayout_get_eccbytes(mtd, chip->ecc.code_buf,
3189 mtd->ecc_stats.failed++;
3191 mtd->ecc_stats.corrected += stat;
3210 struct mtd_info *mtd = nand_to_mtd(chip);
3233 ret = nand_read_data_op(chip, chip->oob_poi, mtd->oobsize, false,
3238 ret = mtd_ooblayout_get_eccbytes(mtd, ecc_code, chip->oob_poi, 0,
3260 mtd->ecc_stats.failed++;
3262 mtd->ecc_stats.corrected += stat;
3283 struct mtd_info *mtd = nand_to_mtd(chip);
3292 ret = nand_read_oob_op(chip, page, 0, chip->oob_poi, mtd->oobsize);
3301 ret = mtd_ooblayout_get_eccbytes(mtd, ecc_code, chip->oob_poi, 0,
3326 mtd->ecc_stats.failed++;
3328 mtd->ecc_stats.corrected += stat;
3349 struct mtd_info *mtd = nand_to_mtd(chip);
3410 mtd->ecc_stats.failed++;
3412 mtd->ecc_stats.corrected += stat;
3418 i = mtd->oobsize - (oob - chip->oob_poi);
3438 struct mtd_info *mtd = nand_to_mtd(chip);
3449 ret = mtd_ooblayout_get_databytes(mtd, oob, chip->oob_poi,
3463 struct mtd_info *mtd = nand_to_mtd(chip);
3471 end_page = DIV_ROUND_UP(col + readlen, mtd->writesize);
3472 end_col = (col + readlen) % mtd->writesize;
3547 struct mtd_info *mtd = nand_to_mtd(chip);
3551 uint32_t max_oobsize = mtd_oobavail(mtd, ops);
3569 col = (int)(from & (mtd->writesize - 1));
3578 struct mtd_ecc_stats ecc_stats = mtd->ecc_stats;
3580 bytes = min(mtd->writesize - col, readlen);
3581 aligned = (bytes == mtd->writesize);
3629 !(mtd->ecc_stats.failed - ecc_stats.failed) &&
3652 if (mtd->ecc_stats.failed - ecc_stats.failed) {
3661 mtd->ecc_stats = ecc_stats;
3728 struct mtd_info *mtd = nand_to_mtd(chip);
3730 return nand_read_oob_op(chip, page, 0, chip->oob_poi, mtd->oobsize);
3742 struct mtd_info *mtd = nand_to_mtd(chip);
3743 int length = mtd->oobsize;
3758 if (mtd->writesize > 512)
3795 struct mtd_info *mtd = nand_to_mtd(chip);
3797 return nand_prog_page_op(chip, page, mtd->writesize, chip->oob_poi,
3798 mtd->oobsize);
3810 struct mtd_info *mtd = nand_to_mtd(chip);
3812 int eccsize = chip->ecc.size, length = mtd->oobsize;
3833 if (mtd->writesize <= 512) {
3886 struct mtd_info *mtd = nand_to_mtd(chip);
3902 stats = mtd->ecc_stats;
3904 len = mtd_oobavail(mtd, ops);
3951 if (mtd->ecc_stats.failed - stats.failed)
3959 * @mtd: MTD device structure
3965 static int nand_read_oob(struct mtd_info *mtd, loff_t from,
3968 struct nand_chip *chip = mtd_to_nand(mtd);
3981 old_stats = mtd->ecc_stats;
3990 mtd->ecc_stats.failed - old_stats.failed;
3992 mtd->ecc_stats.corrected - old_stats.corrected;
4026 struct mtd_info *mtd = nand_to_mtd(chip);
4029 ret = nand_prog_page_begin_op(chip, page, 0, buf, mtd->writesize);
4034 ret = nand_write_data_op(chip, chip->oob_poi, mtd->oobsize,
4063 struct mtd_info *mtd = nand_to_mtd(chip);
4064 unsigned int size = mtd->writesize;
4068 size += mtd->oobsize;
4072 memcpy(write_buf, buf, mtd->writesize);
4093 struct mtd_info *mtd = nand_to_mtd(chip);
4135 size = mtd->oobsize - (oob - chip->oob_poi);
4154 struct mtd_info *mtd = nand_to_mtd(chip);
4165 ret = mtd_ooblayout_set_eccbytes(mtd, ecc_calc, chip->oob_poi, 0,
4183 struct mtd_info *mtd = nand_to_mtd(chip);
4204 ret = mtd_ooblayout_set_eccbytes(mtd, ecc_calc, chip->oob_poi, 0,
4209 ret = nand_write_data_op(chip, chip->oob_poi, mtd->oobsize, false);
4230 struct mtd_info *mtd = nand_to_mtd(chip);
4238 int oob_bytes = mtd->oobsize / ecc_steps;
4273 ret = mtd_ooblayout_set_eccbytes(mtd, ecc_calc, chip->oob_poi, 0,
4279 ret = nand_write_data_op(chip, chip->oob_poi, mtd->oobsize, false);
4300 struct mtd_info *mtd = nand_to_mtd(chip);
4347 i = mtd->oobsize - (oob - chip->oob_poi);
4371 struct mtd_info *mtd = nand_to_mtd(chip);
4376 subpage = offset || (data_len < mtd->writesize);
4408 struct mtd_info *mtd = nand_to_mtd(chip);
4413 uint32_t oobmaxlen = mtd_oobavail(mtd, ops);
4435 column = to & (mtd->writesize - 1);
4461 int bytes = mtd->writesize;
4464 int part_pagewr = (column || writelen < mtd->writesize);
4485 memset(wbuf, 0xff, mtd->writesize);
4495 memset(chip->oob_poi, 0xff, mtd->oobsize);
4532 * @mtd: MTD device structure
4541 static int panic_nand_write(struct mtd_info *mtd, loff_t to, size_t len,
4544 struct nand_chip *chip = mtd_to_nand(mtd);
4567 * @mtd: MTD device structure
4571 static int nand_write_oob(struct mtd_info *mtd, loff_t to,
4574 struct nand_chip *chip = mtd_to_nand(mtd);
4603 * @mtd: MTD device structure
4608 static int nand_erase(struct mtd_info *mtd, struct erase_info *instr)
4610 return nand_erase_nand(mtd_to_nand(mtd), instr, 0);
4716 * @mtd: MTD device structure
4720 static void nand_sync(struct mtd_info *mtd)
4722 struct nand_chip *chip = mtd_to_nand(mtd);
4734 * @mtd: MTD device structure
4735 * @offs: offset relative to mtd start
4737 static int nand_block_isbad(struct mtd_info *mtd, loff_t offs)
4739 struct nand_chip *chip = mtd_to_nand(mtd);
4758 * @mtd: MTD device structure
4759 * @ofs: offset relative to mtd start
4761 static int nand_block_markbad(struct mtd_info *mtd, loff_t ofs)
4765 ret = nand_block_isbad(mtd, ofs);
4773 return nand_block_markbad_lowlevel(mtd_to_nand(mtd), ofs);
4778 * @mtd: MTD device structure
4782 static int nand_suspend(struct mtd_info *mtd)
4784 struct nand_chip *chip = mtd_to_nand(mtd);
4799 * @mtd: MTD device structure
4801 static void nand_resume(struct mtd_info *mtd)
4803 struct nand_chip *chip = mtd_to_nand(mtd);
4822 * @mtd: MTD device structure
4824 static void nand_shutdown(struct mtd_info *mtd)
4826 nand_suspend(mtd);
4831 * @mtd: MTD device structure
4835 static int nand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
4837 struct nand_chip *chip = mtd_to_nand(mtd);
4847 * @mtd: MTD device structure
4851 static int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
4853 struct nand_chip *chip = mtd_to_nand(mtd);
4971 struct mtd_info *mtd = nand_to_mtd(chip);
4984 mtd->writesize = memorg->pagesize;
4987 memorg->oobsize = (8 << (extid & 0x01)) * (mtd->writesize >> 9);
4988 mtd->oobsize = memorg->oobsize;
4993 mtd->erasesize = (64 * 1024) << (extid & 0x03);
5008 struct mtd_info *mtd = nand_to_mtd(chip);
5014 mtd->erasesize = type->erasesize;
5016 mtd->writesize = memorg->pagesize;
5018 mtd->oobsize = memorg->oobsize;
5031 struct mtd_info *mtd = nand_to_mtd(chip);
5034 if (mtd->writesize > 512 || (chip->options & NAND_BUSWIDTH_16))
5050 struct mtd_info *mtd = nand_to_mtd(chip);
5058 mtd->writesize = memorg->pagesize;
5061 mtd->erasesize = type->erasesize;
5063 mtd->oobsize = memorg->oobsize;
5164 struct mtd_info *mtd = nand_to_mtd(chip);
5173 mtd->writesize, true))
5202 struct mtd_info *mtd = nand_to_mtd(chip);
5327 if (!mtd->name)
5328 mtd->name = chip->parameters.model;
5341 mtd->name);
5352 chip->page_shift = ffs(mtd->writesize) - 1;
5358 ffs(mtd->erasesize) - 1;
5379 mtd->erasesize >> 10, mtd->writesize, mtd->oobsize);
5636 struct mtd_info *mtd = nand_to_mtd(chip);
5657 if (!mtd->name && mtd->dev.parent)
5658 mtd->name = dev_name(mtd->dev.parent);
5707 /* Store the number of chips and calc total size for mtd */
5709 mtd->size = i * nanddev_target_size(&chip->base);
5891 struct mtd_info *mtd = nand_to_mtd(chip);
5892 struct nand_device *nanddev = mtd_to_nanddev(mtd);
5950 mtd->ooblayout != nand_get_large_page_ooblayout())
5980 struct mtd_info *mtd = nand_to_mtd(chip);
5984 int ecc_bytes, nsteps = mtd->writesize / preset_step;
6036 struct mtd_info *mtd = nand_to_mtd(chip);
6050 req_corr = mtd->writesize / req_step * req_strength;
6067 if (mtd->writesize % step_size)
6070 nsteps = mtd->writesize / step_size;
6117 struct mtd_info *mtd = nand_to_mtd(chip);
6136 if (mtd->writesize % step_size)
6139 nsteps = mtd->writesize / step_size;
6195 struct mtd_info *mtd = nand_to_mtd(chip);
6196 struct nand_device *nanddev = mtd_to_nanddev(mtd);
6198 if (WARN_ON(oobavail < 0 || oobavail > mtd->oobsize))
6268 struct mtd_info *mtd = nand_to_mtd(chip);
6278 chip->data_buf = kmalloc(mtd->writesize + mtd->oobsize, GFP_KERNEL);
6295 chip->oob_poi = chip->data_buf + mtd->writesize;
6300 if (!mtd->ooblayout &&
6305 switch (mtd->oobsize) {
6308 mtd_set_ooblayout(mtd, nand_get_small_page_ooblayout());
6312 mtd_set_ooblayout(mtd,
6324 mtd_set_ooblayout(mtd,
6330 mtd->oobsize);
6347 if (mtd->writesize >= ecc->size) {
6356 ecc->size, mtd->writesize);
6387 ecc->size = mtd->writesize;
6399 ecc->calc_buf = kmalloc(mtd->oobsize, GFP_KERNEL);
6400 ecc->code_buf = kmalloc(mtd->oobsize, GFP_KERNEL);
6414 mtd->ecc_strength = ecc->strength;
6415 mtd->ecc_step_size = ecc->size;
6422 ecc->steps = mtd->writesize / ecc->size;
6423 if (ecc->steps * ecc->size != mtd->writesize) {
6434 if (ecc->total > mtd->oobsize) {
6444 ret = mtd_ooblayout_count_freebytes(mtd);
6448 mtd->oobavail = ret;
6453 mtd->name, chip->ecc.strength, chip->ecc.size,
6461 mtd->subpage_sft = 1;
6466 mtd->subpage_sft = 2;
6470 chip->subpagesize = mtd->writesize >> mtd->subpage_sft;
6486 ret = nanddev_init(&chip->base, &rawnand_ops, mtd->owner);
6492 mtd->flags = MTD_CAP_ROM;
6495 mtd->_erase = nand_erase;
6496 mtd->_point = NULL;
6497 mtd->_unpoint = NULL;
6498 mtd->_panic_write = panic_nand_write;
6499 mtd->_read_oob = nand_read_oob;
6500 mtd->_write_oob = nand_write_oob;
6501 mtd->_sync = nand_sync;
6502 mtd->_lock = nand_lock;
6503 mtd->_unlock = nand_unlock;
6504 mtd->_suspend = nand_suspend;
6505 mtd->_resume = nand_resume;
6506 mtd->_reboot = nand_shutdown;
6507 mtd->_block_isreserved = nand_block_isreserved;
6508 mtd->_block_isbad = nand_block_isbad;
6509 mtd->_block_markbad = nand_block_markbad;
6510 mtd->_max_bad_blocks = nanddev_mtd_max_bad_blocks;
6517 if (!mtd->bitflip_threshold)
6518 mtd->bitflip_threshold = DIV_ROUND_UP(mtd->ecc_strength * 3, 4);
6596 * The flash ID is read and the mtd/chip structures are filled with the