Lines Matching full:mtd
16 #include <mtd/mtd-abi.h>
21 #include <mtd/mtd-abi.h>
46 struct mtd_info *mtd; member
62 uint64_t offset; /* At which this region starts, from the beginning of the MTD */
130 int (*ecc)(struct mtd_info *mtd, int section,
132 int (*free)(struct mtd_info *mtd, int section,
138 * similar, smaller struct nand_ecclayout_user (in mtd-abi.h) that is retained
154 uint64_t size; // Total size of the MTD
171 * Size of the write buffer used by the MTD. MTD devices having a write
174 * buffer the MTD driver can (but doesn't have to) do 2 writesize
199 * see Documentation/ABI/testing/sysfs-class-mtd for more detail.
233 int (*_erase) (struct mtd_info *mtd, struct erase_info *instr);
235 int (*_point) (struct mtd_info *mtd, loff_t from, size_t len,
237 int (*_unpoint) (struct mtd_info *mtd, loff_t from, size_t len);
239 unsigned long (*_get_unmapped_area) (struct mtd_info *mtd,
243 int (*_read) (struct mtd_info *mtd, loff_t from, size_t len,
245 int (*_write) (struct mtd_info *mtd, loff_t to, size_t len,
247 int (*_panic_write) (struct mtd_info *mtd, loff_t to, size_t len,
249 int (*_read_oob) (struct mtd_info *mtd, loff_t from,
251 int (*_write_oob) (struct mtd_info *mtd, loff_t to,
253 int (*_get_fact_prot_info) (struct mtd_info *mtd, size_t len,
255 int (*_read_fact_prot_reg) (struct mtd_info *mtd, loff_t from,
257 int (*_get_user_prot_info) (struct mtd_info *mtd, size_t len,
259 int (*_read_user_prot_reg) (struct mtd_info *mtd, loff_t from,
261 int (*_write_user_prot_reg) (struct mtd_info *mtd, loff_t to,
263 int (*_lock_user_prot_reg) (struct mtd_info *mtd, loff_t from,
266 int (*_writev) (struct mtd_info *mtd, const struct kvec *vecs,
269 void (*_sync) (struct mtd_info *mtd);
270 int (*_lock) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
271 int (*_unlock) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
272 int (*_is_locked) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
273 int (*_block_isreserved) (struct mtd_info *mtd, loff_t ofs);
274 int (*_block_isbad) (struct mtd_info *mtd, loff_t ofs);
275 int (*_block_markbad) (struct mtd_info *mtd, loff_t ofs);
277 int (*_suspend) (struct mtd_info *mtd);
278 void (*_resume) (struct mtd_info *mtd);
279 void (*_reboot) (struct mtd_info *mtd);
285 int (*_get_device) (struct mtd_info *mtd);
286 void (*_put_device) (struct mtd_info *mtd);
312 /* MTD devices do not have any parent. MTD partitions do. */
317 * Is 0 for real MTD devices (ie. not partitions).
322 * List node used to add an MTD partition to the parent
328 * List of partitions attached to this MTD device (the parent
329 * MTD device can itself be a partition).
335 static inline void mtd_set_of_node(struct mtd_info *mtd, in mtd_set_of_node() argument
338 mtd->dev->node.np = np; in mtd_set_of_node()
341 static inline const struct device_node *mtd_get_of_node(struct mtd_info *mtd) in mtd_get_of_node() argument
343 return mtd->dev->node.np; in mtd_get_of_node()
348 static inline void mtd_set_of_node(struct mtd_info *mtd, in mtd_set_of_node() argument
353 static inline const struct device_node *mtd_get_of_node(struct mtd_info *mtd) in mtd_get_of_node() argument
359 static inline bool mtd_is_partition(const struct mtd_info *mtd) in mtd_is_partition() argument
361 return mtd->parent; in mtd_is_partition()
364 static inline bool mtd_has_partitions(const struct mtd_info *mtd) in mtd_has_partitions() argument
366 return !list_empty(&mtd->partitions); in mtd_has_partitions()
371 int mtd_ooblayout_ecc(struct mtd_info *mtd, int section,
373 int mtd_ooblayout_find_eccregion(struct mtd_info *mtd, int eccbyte,
376 int mtd_ooblayout_get_eccbytes(struct mtd_info *mtd, u8 *eccbuf,
378 int mtd_ooblayout_set_eccbytes(struct mtd_info *mtd, const u8 *eccbuf,
380 int mtd_ooblayout_free(struct mtd_info *mtd, int section,
382 int mtd_ooblayout_get_databytes(struct mtd_info *mtd, u8 *databuf,
384 int mtd_ooblayout_set_databytes(struct mtd_info *mtd, const u8 *databuf,
386 int mtd_ooblayout_count_freebytes(struct mtd_info *mtd);
387 int mtd_ooblayout_count_eccbytes(struct mtd_info *mtd);
389 static inline void mtd_set_ooblayout(struct mtd_info *mtd, in mtd_set_ooblayout() argument
392 mtd->ooblayout = ooblayout; in mtd_set_ooblayout()
395 static inline int mtd_oobavail(struct mtd_info *mtd, struct mtd_oob_ops *ops) in mtd_oobavail() argument
397 return ops->mode == MTD_OPS_AUTO_OOB ? mtd->oobavail : mtd->oobsize; in mtd_oobavail()
400 int mtd_erase(struct mtd_info *mtd, struct erase_info *instr);
402 int mtd_point(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
404 int mtd_unpoint(struct mtd_info *mtd, loff_t from, size_t len);
406 unsigned long mtd_get_unmapped_area(struct mtd_info *mtd, unsigned long len,
408 int mtd_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
410 int mtd_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
412 int mtd_panic_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
415 int mtd_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops);
416 int mtd_write_oob(struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops);
418 int mtd_get_fact_prot_info(struct mtd_info *mtd, size_t len, size_t *retlen,
420 int mtd_read_fact_prot_reg(struct mtd_info *mtd, loff_t from, size_t len,
422 int mtd_get_user_prot_info(struct mtd_info *mtd, size_t len, size_t *retlen,
424 int mtd_read_user_prot_reg(struct mtd_info *mtd, loff_t from, size_t len,
426 int mtd_write_user_prot_reg(struct mtd_info *mtd, loff_t to, size_t len,
428 int mtd_lock_user_prot_reg(struct mtd_info *mtd, loff_t from, size_t len);
431 int mtd_writev(struct mtd_info *mtd, const struct kvec *vecs,
435 static inline void mtd_sync(struct mtd_info *mtd) in mtd_sync() argument
437 if (mtd->_sync) in mtd_sync()
438 mtd->_sync(mtd); in mtd_sync()
441 int mtd_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
442 int mtd_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
443 int mtd_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len);
444 int mtd_block_isreserved(struct mtd_info *mtd, loff_t ofs);
445 int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs);
446 int mtd_block_markbad(struct mtd_info *mtd, loff_t ofs);
449 static inline int mtd_suspend(struct mtd_info *mtd) in mtd_suspend() argument
451 return mtd->_suspend ? mtd->_suspend(mtd) : 0; in mtd_suspend()
454 static inline void mtd_resume(struct mtd_info *mtd) in mtd_resume() argument
456 if (mtd->_resume) in mtd_resume()
457 mtd->_resume(mtd); in mtd_resume()
461 static inline uint32_t mtd_div_by_eb(uint64_t sz, struct mtd_info *mtd) in mtd_div_by_eb() argument
463 if (mtd->erasesize_shift) in mtd_div_by_eb()
464 return sz >> mtd->erasesize_shift; in mtd_div_by_eb()
465 do_div(sz, mtd->erasesize); in mtd_div_by_eb()
469 static inline uint32_t mtd_mod_by_eb(uint64_t sz, struct mtd_info *mtd) in mtd_mod_by_eb() argument
471 if (mtd->erasesize_shift) in mtd_mod_by_eb()
472 return sz & mtd->erasesize_mask; in mtd_mod_by_eb()
473 return do_div(sz, mtd->erasesize); in mtd_mod_by_eb()
476 static inline uint32_t mtd_div_by_ws(uint64_t sz, struct mtd_info *mtd) in mtd_div_by_ws() argument
478 if (mtd->writesize_shift) in mtd_div_by_ws()
479 return sz >> mtd->writesize_shift; in mtd_div_by_ws()
480 do_div(sz, mtd->writesize); in mtd_div_by_ws()
484 static inline uint32_t mtd_mod_by_ws(uint64_t sz, struct mtd_info *mtd) in mtd_mod_by_ws() argument
486 if (mtd->writesize_shift) in mtd_mod_by_ws()
487 return sz & mtd->writesize_mask; in mtd_mod_by_ws()
488 return do_div(sz, mtd->writesize); in mtd_mod_by_ws()
491 static inline int mtd_has_oob(const struct mtd_info *mtd) in mtd_has_oob() argument
493 return mtd->_read_oob && mtd->_write_oob; in mtd_has_oob()
496 static inline int mtd_type_is_nand(const struct mtd_info *mtd) in mtd_type_is_nand() argument
498 return mtd->type == MTD_NANDFLASH || mtd->type == MTD_MLCNANDFLASH; in mtd_type_is_nand()
501 static inline int mtd_can_have_bb(const struct mtd_info *mtd) in mtd_can_have_bb() argument
503 return !!mtd->_block_isbad; in mtd_can_have_bb()
511 extern int mtd_device_parse_register(struct mtd_info *mtd,
519 extern struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num);
520 extern int __get_mtd_device(struct mtd_info *mtd);
521 extern void __put_mtd_device(struct mtd_info *mtd);
523 extern void put_mtd_device(struct mtd_info *mtd);
528 void (*add)(struct mtd_info *mtd);
529 void (*remove)(struct mtd_info *mtd);
537 void *mtd_kmalloc_up_to(const struct mtd_info *mtd, size_t *size);
561 unsigned mtd_mmap_capabilities(struct mtd_info *mtd);
564 /* drivers/mtd/mtdcore.h */
565 int add_mtd_device(struct mtd_info *mtd);
566 int del_mtd_device(struct mtd_info *mtd);
572 static inline int add_mtd_partitions(struct mtd_info *mtd, in add_mtd_partitions() argument
579 static inline int del_mtd_partitions(struct mtd_info *mtd) in del_mtd_partitions() argument
586 #define mtd_for_each_device(mtd) \ argument
587 for ((mtd) = __mtd_next_device(0); \
588 (mtd) != NULL; \
589 (mtd) = __mtd_next_device(mtd->index + 1))
597 /* drivers/mtd/mtdcore.c */
598 void mtd_get_len_incl_bad(struct mtd_info *mtd, uint64_t offset,
603 /* drivers/mtd/mtd_uboot.c */