Lines Matching refs:mtd
48 struct mtd_info *mtd; member
131 int (*ecc)(struct mtd_info *mtd, int section,
133 int (*rfree)(struct mtd_info *mtd, int section,
234 int (*_erase) (struct mtd_info *mtd, struct erase_info *instr);
236 int (*_point) (struct mtd_info *mtd, loff_t from, size_t len,
238 int (*_unpoint) (struct mtd_info *mtd, loff_t from, size_t len);
240 unsigned long (*_get_unmapped_area) (struct mtd_info *mtd,
244 int (*_read) (struct mtd_info *mtd, loff_t from, size_t len,
246 int (*_write) (struct mtd_info *mtd, loff_t to, size_t len,
248 int (*_panic_write) (struct mtd_info *mtd, loff_t to, size_t len,
250 int (*_read_oob) (struct mtd_info *mtd, loff_t from,
252 int (*_write_oob) (struct mtd_info *mtd, loff_t to,
254 int (*_get_fact_prot_info) (struct mtd_info *mtd, size_t len,
256 int (*_read_fact_prot_reg) (struct mtd_info *mtd, loff_t from,
258 int (*_get_user_prot_info) (struct mtd_info *mtd, size_t len,
260 int (*_read_user_prot_reg) (struct mtd_info *mtd, loff_t from,
262 int (*_write_user_prot_reg) (struct mtd_info *mtd, loff_t to,
264 int (*_lock_user_prot_reg) (struct mtd_info *mtd, loff_t from,
267 int (*_writev) (struct mtd_info *mtd, const struct kvec *vecs,
270 void (*_sync) (struct mtd_info *mtd);
271 int (*_lock) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
272 int (*_unlock) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
273 int (*_is_locked) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
274 int (*_block_isreserved) (struct mtd_info *mtd, loff_t ofs);
275 int (*_block_isbad) (struct mtd_info *mtd, loff_t ofs);
276 int (*_block_markbad) (struct mtd_info *mtd, loff_t ofs);
278 int (*_suspend) (struct mtd_info *mtd);
279 void (*_resume) (struct mtd_info *mtd);
280 void (*_reboot) (struct mtd_info *mtd);
286 int (*_get_device) (struct mtd_info *mtd);
287 void (*_put_device) (struct mtd_info *mtd);
337 static inline void mtd_set_ofnode(struct mtd_info *mtd, ofnode node) in mtd_set_ofnode() argument
339 dev_set_ofnode(mtd->dev, node); in mtd_set_ofnode()
342 static inline ofnode mtd_get_ofnode(struct mtd_info *mtd) in mtd_get_ofnode() argument
344 return dev_ofnode(mtd->dev); in mtd_get_ofnode()
349 static inline void mtd_set_of_node(struct mtd_info *mtd, in mtd_set_of_node() argument
354 static inline const struct device_node *mtd_get_of_node(struct mtd_info *mtd) in mtd_get_of_node() argument
360 static inline bool mtd_is_partition(const struct mtd_info *mtd) in mtd_is_partition() argument
362 return mtd->parent; in mtd_is_partition()
365 static inline bool mtd_has_partitions(const struct mtd_info *mtd) in mtd_has_partitions() argument
367 return !list_empty(&mtd->partitions); in mtd_has_partitions()
372 int mtd_ooblayout_ecc(struct mtd_info *mtd, int section,
374 int mtd_ooblayout_find_eccregion(struct mtd_info *mtd, int eccbyte,
377 int mtd_ooblayout_get_eccbytes(struct mtd_info *mtd, u8 *eccbuf,
379 int mtd_ooblayout_set_eccbytes(struct mtd_info *mtd, const u8 *eccbuf,
381 int mtd_ooblayout_free(struct mtd_info *mtd, int section,
383 int mtd_ooblayout_get_databytes(struct mtd_info *mtd, u8 *databuf,
385 int mtd_ooblayout_set_databytes(struct mtd_info *mtd, const u8 *databuf,
387 int mtd_ooblayout_count_freebytes(struct mtd_info *mtd);
388 int mtd_ooblayout_count_eccbytes(struct mtd_info *mtd);
390 static inline void mtd_set_ooblayout(struct mtd_info *mtd, in mtd_set_ooblayout() argument
393 mtd->ooblayout = ooblayout; in mtd_set_ooblayout()
396 static inline u32 mtd_oobavail(struct mtd_info *mtd, struct mtd_oob_ops *ops) in mtd_oobavail() argument
398 return ops->mode == MTD_OPS_AUTO_OOB ? mtd->oobavail : mtd->oobsize; in mtd_oobavail()
401 int mtd_erase(struct mtd_info *mtd, struct erase_info *instr);
403 int mtd_point(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
405 int mtd_unpoint(struct mtd_info *mtd, loff_t from, size_t len);
407 unsigned long mtd_get_unmapped_area(struct mtd_info *mtd, unsigned long len,
409 int mtd_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
411 int mtd_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
413 int mtd_panic_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
427 int mtd_bind(struct udevice *dev, struct mtd_info **mtd);
434 static inline int mtd_bind(struct udevice *dev, struct mtd_info **mtd) in mtd_bind() argument
440 int mtd_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops);
441 int mtd_write_oob(struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops);
443 int mtd_get_fact_prot_info(struct mtd_info *mtd, size_t len, size_t *retlen,
445 int mtd_read_fact_prot_reg(struct mtd_info *mtd, loff_t from, size_t len,
447 int mtd_get_user_prot_info(struct mtd_info *mtd, size_t len, size_t *retlen,
449 int mtd_read_user_prot_reg(struct mtd_info *mtd, loff_t from, size_t len,
451 int mtd_write_user_prot_reg(struct mtd_info *mtd, loff_t to, size_t len,
453 int mtd_lock_user_prot_reg(struct mtd_info *mtd, loff_t from, size_t len);
456 int mtd_writev(struct mtd_info *mtd, const struct kvec *vecs,
460 static inline void mtd_sync(struct mtd_info *mtd) in mtd_sync() argument
462 if (mtd->_sync) in mtd_sync()
463 mtd->_sync(mtd); in mtd_sync()
466 int mtd_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
467 int mtd_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
468 int mtd_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len);
469 int mtd_block_isreserved(struct mtd_info *mtd, loff_t ofs);
470 int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs);
471 int mtd_block_markbad(struct mtd_info *mtd, loff_t ofs);
474 static inline int mtd_suspend(struct mtd_info *mtd) in mtd_suspend() argument
476 return mtd->_suspend ? mtd->_suspend(mtd) : 0; in mtd_suspend()
479 static inline void mtd_resume(struct mtd_info *mtd) in mtd_resume() argument
481 if (mtd->_resume) in mtd_resume()
482 mtd->_resume(mtd); in mtd_resume()
486 static inline uint32_t mtd_div_by_eb(uint64_t sz, struct mtd_info *mtd) in mtd_div_by_eb() argument
488 if (mtd->erasesize_shift) in mtd_div_by_eb()
489 return sz >> mtd->erasesize_shift; in mtd_div_by_eb()
490 do_div(sz, mtd->erasesize); in mtd_div_by_eb()
494 static inline uint32_t mtd_mod_by_eb(uint64_t sz, struct mtd_info *mtd) in mtd_mod_by_eb() argument
496 if (mtd->erasesize_shift) in mtd_mod_by_eb()
497 return sz & mtd->erasesize_mask; in mtd_mod_by_eb()
498 return do_div(sz, mtd->erasesize); in mtd_mod_by_eb()
501 static inline uint32_t mtd_div_by_ws(uint64_t sz, struct mtd_info *mtd) in mtd_div_by_ws() argument
503 if (mtd->writesize_shift) in mtd_div_by_ws()
504 return sz >> mtd->writesize_shift; in mtd_div_by_ws()
505 do_div(sz, mtd->writesize); in mtd_div_by_ws()
509 static inline uint32_t mtd_mod_by_ws(uint64_t sz, struct mtd_info *mtd) in mtd_mod_by_ws() argument
511 if (mtd->writesize_shift) in mtd_mod_by_ws()
512 return sz & mtd->writesize_mask; in mtd_mod_by_ws()
513 return do_div(sz, mtd->writesize); in mtd_mod_by_ws()
516 static inline int mtd_has_oob(const struct mtd_info *mtd) in mtd_has_oob() argument
518 return mtd->_read_oob && mtd->_write_oob; in mtd_has_oob()
521 static inline int mtd_type_is_nand(const struct mtd_info *mtd) in mtd_type_is_nand() argument
523 return mtd->type == MTD_NANDFLASH || mtd->type == MTD_MLCNANDFLASH; in mtd_type_is_nand()
526 static inline int mtd_can_have_bb(const struct mtd_info *mtd) in mtd_can_have_bb() argument
528 return !!mtd->_block_isbad; in mtd_can_have_bb()
536 extern int mtd_device_parse_register(struct mtd_info *mtd,
544 extern struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num);
545 extern int __get_mtd_device(struct mtd_info *mtd);
546 extern void __put_mtd_device(struct mtd_info *mtd);
548 extern void put_mtd_device(struct mtd_info *mtd);
552 void (*add)(struct mtd_info *mtd);
553 void (*remove)(struct mtd_info *mtd);
560 void *mtd_kmalloc_up_to(const struct mtd_info *mtd, size_t *size);
574 unsigned mtd_mmap_capabilities(struct mtd_info *mtd);
579 int add_mtd_device(struct mtd_info *mtd);
580 int del_mtd_device(struct mtd_info *mtd);
582 static inline int add_mtd_device(struct mtd_info *mtd) in add_mtd_device() argument
587 static inline int del_mtd_device(struct mtd_info *mtd) in del_mtd_device() argument
597 static inline int add_mtd_partitions(struct mtd_info *mtd, in add_mtd_partitions() argument
604 static inline int del_mtd_partitions(struct mtd_info *mtd) in del_mtd_partitions() argument
621 #define mtd_for_each_device(mtd) \ argument
622 for ((mtd) = __mtd_next_device(0); \
623 (mtd) != NULL; \
624 (mtd) = __mtd_next_device(mtd->index + 1))
627 void mtd_get_len_incl_bad(struct mtd_info *mtd, uint64_t offset,