xref: /openbmc/linux/include/linux/mtd/mtd.h (revision e2e24e8e)
11da177e4SLinus Torvalds /*
2a1452a37SDavid Woodhouse  * Copyright © 1999-2010 David Woodhouse <dwmw2@infradead.org> et al.
31da177e4SLinus Torvalds  *
4a1452a37SDavid Woodhouse  * This program is free software; you can redistribute it and/or modify
5a1452a37SDavid Woodhouse  * it under the terms of the GNU General Public License as published by
6a1452a37SDavid Woodhouse  * the Free Software Foundation; either version 2 of the License, or
7a1452a37SDavid Woodhouse  * (at your option) any later version.
8a1452a37SDavid Woodhouse  *
9a1452a37SDavid Woodhouse  * This program is distributed in the hope that it will be useful,
10a1452a37SDavid Woodhouse  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11a1452a37SDavid Woodhouse  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12a1452a37SDavid Woodhouse  * GNU General Public License for more details.
13a1452a37SDavid Woodhouse  *
14a1452a37SDavid Woodhouse  * You should have received a copy of the GNU General Public License
15a1452a37SDavid Woodhouse  * along with this program; if not, write to the Free Software
16a1452a37SDavid Woodhouse  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17a1452a37SDavid Woodhouse  *
181da177e4SLinus Torvalds  */
191da177e4SLinus Torvalds 
201da177e4SLinus Torvalds #ifndef __MTD_MTD_H__
211da177e4SLinus Torvalds #define __MTD_MTD_H__
221da177e4SLinus Torvalds 
231da177e4SLinus Torvalds #include <linux/types.h>
241da177e4SLinus Torvalds #include <linux/module.h>
251da177e4SLinus Torvalds #include <linux/uio.h>
26963a6fb0SNicolas Pitre #include <linux/notifier.h>
271f24b5a8SDavid Brownell #include <linux/device.h>
281da177e4SLinus Torvalds 
291da177e4SLinus Torvalds #include <mtd/mtd-abi.h>
301da177e4SLinus Torvalds 
3169423d99SAdrian Hunter #include <asm/div64.h>
3269423d99SAdrian Hunter 
331da177e4SLinus Torvalds #define MTD_CHAR_MAJOR 90
341da177e4SLinus Torvalds #define MTD_BLOCK_MAJOR 31
351da177e4SLinus Torvalds 
361da177e4SLinus Torvalds #define MTD_ERASE_PENDING	0x01
371da177e4SLinus Torvalds #define MTD_ERASING		0x02
381da177e4SLinus Torvalds #define MTD_ERASE_SUSPEND	0x04
391da177e4SLinus Torvalds #define MTD_ERASE_DONE		0x08
401da177e4SLinus Torvalds #define MTD_ERASE_FAILED	0x10
411da177e4SLinus Torvalds 
4269423d99SAdrian Hunter #define MTD_FAIL_ADDR_UNKNOWN -1LL
43bb0eb217SAdrian Hunter 
44e2e24e8eSBrian Norris /*
45e2e24e8eSBrian Norris  * If the erase fails, fail_addr might indicate exactly which block failed. If
46e2e24e8eSBrian Norris  * fail_addr = MTD_FAIL_ADDR_UNKNOWN, the failure was not at the device level
47e2e24e8eSBrian Norris  * or was not specific to any particular block.
48e2e24e8eSBrian Norris  */
491da177e4SLinus Torvalds struct erase_info {
501da177e4SLinus Torvalds 	struct mtd_info *mtd;
5169423d99SAdrian Hunter 	uint64_t addr;
5269423d99SAdrian Hunter 	uint64_t len;
5369423d99SAdrian Hunter 	uint64_t fail_addr;
541da177e4SLinus Torvalds 	u_long time;
551da177e4SLinus Torvalds 	u_long retries;
5626cdb67cSDavid Woodhouse 	unsigned dev;
5726cdb67cSDavid Woodhouse 	unsigned cell;
581da177e4SLinus Torvalds 	void (*callback) (struct erase_info *self);
591da177e4SLinus Torvalds 	u_long priv;
601da177e4SLinus Torvalds 	u_char state;
611da177e4SLinus Torvalds 	struct erase_info *next;
621da177e4SLinus Torvalds };
631da177e4SLinus Torvalds 
641da177e4SLinus Torvalds struct mtd_erase_region_info {
6569423d99SAdrian Hunter 	uint64_t offset;		/* At which this region starts, from the beginning of the MTD */
6626cdb67cSDavid Woodhouse 	uint32_t erasesize;		/* For this region */
6726cdb67cSDavid Woodhouse 	uint32_t numblocks;		/* Number of blocks of erasesize in this region */
680ecbc81aSRodolfo Giometti 	unsigned long *lockmap;		/* If keeping bitmap of locks */
691da177e4SLinus Torvalds };
701da177e4SLinus Torvalds 
718593fbc6SThomas Gleixner /*
728593fbc6SThomas Gleixner  * oob operation modes
738593fbc6SThomas Gleixner  *
748593fbc6SThomas Gleixner  * MTD_OOB_PLACE:	oob data are placed at the given offset
758593fbc6SThomas Gleixner  * MTD_OOB_AUTO:	oob data are automatically placed at the free areas
768593fbc6SThomas Gleixner  *			which are defined by the ecclayout
77b64d39d8SMaxim Levitsky  * MTD_OOB_RAW:		mode to read oob and data without doing ECC checking
788593fbc6SThomas Gleixner  */
798593fbc6SThomas Gleixner typedef enum {
808593fbc6SThomas Gleixner 	MTD_OOB_PLACE,
818593fbc6SThomas Gleixner 	MTD_OOB_AUTO,
828593fbc6SThomas Gleixner 	MTD_OOB_RAW,
838593fbc6SThomas Gleixner } mtd_oob_mode_t;
848593fbc6SThomas Gleixner 
858593fbc6SThomas Gleixner /**
868593fbc6SThomas Gleixner  * struct mtd_oob_ops - oob operation operands
878593fbc6SThomas Gleixner  * @mode:	operation mode
888593fbc6SThomas Gleixner  *
897014568bSVitaly Wool  * @len:	number of data bytes to write/read
908593fbc6SThomas Gleixner  *
917014568bSVitaly Wool  * @retlen:	number of data bytes written/read
928593fbc6SThomas Gleixner  *
937014568bSVitaly Wool  * @ooblen:	number of oob bytes to write/read
947014568bSVitaly Wool  * @oobretlen:	number of oob bytes written/read
958593fbc6SThomas Gleixner  * @ooboffs:	offset of oob data in the oob area (only relevant when
968593fbc6SThomas Gleixner  *		mode = MTD_OOB_PLACE)
978593fbc6SThomas Gleixner  * @datbuf:	data buffer - if NULL only oob data are read/written
988593fbc6SThomas Gleixner  * @oobbuf:	oob data buffer
9973a4421cSArtem Bityutskiy  *
100025dfdafSFrederik Schwarzer  * Note, it is allowed to read more than one OOB area at one go, but not write.
10173a4421cSArtem Bityutskiy  * The interface assumes that the OOB write requests program only one page's
10273a4421cSArtem Bityutskiy  * OOB area.
1038593fbc6SThomas Gleixner  */
1048593fbc6SThomas Gleixner struct mtd_oob_ops {
1058593fbc6SThomas Gleixner 	mtd_oob_mode_t	mode;
1068593fbc6SThomas Gleixner 	size_t		len;
1078593fbc6SThomas Gleixner 	size_t		retlen;
1088593fbc6SThomas Gleixner 	size_t		ooblen;
1097014568bSVitaly Wool 	size_t		oobretlen;
1108593fbc6SThomas Gleixner 	uint32_t	ooboffs;
1118593fbc6SThomas Gleixner 	uint8_t		*datbuf;
1128593fbc6SThomas Gleixner 	uint8_t		*oobbuf;
1138593fbc6SThomas Gleixner };
1148593fbc6SThomas Gleixner 
115cc26c3cdSBrian Norris #define MTD_MAX_OOBFREE_ENTRIES_LARGE	32
116cc26c3cdSBrian Norris #define MTD_MAX_ECCPOS_ENTRIES_LARGE	448
117cc26c3cdSBrian Norris /*
1180ceacf36SBrian Norris  * Internal ECC layout control structure. For historical reasons, there is a
1190ceacf36SBrian Norris  * similar, smaller struct nand_ecclayout_user (in mtd-abi.h) that is retained
1200ceacf36SBrian Norris  * for export to user-space via the ECCGETLAYOUT ioctl.
1210ceacf36SBrian Norris  * nand_ecclayout should be expandable in the future simply by the above macros.
122cc26c3cdSBrian Norris  */
123cc26c3cdSBrian Norris struct nand_ecclayout {
124cc26c3cdSBrian Norris 	__u32 eccbytes;
125cc26c3cdSBrian Norris 	__u32 eccpos[MTD_MAX_ECCPOS_ENTRIES_LARGE];
126cc26c3cdSBrian Norris 	__u32 oobavail;
127cc26c3cdSBrian Norris 	struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES_LARGE];
128cc26c3cdSBrian Norris };
129cc26c3cdSBrian Norris 
1301da177e4SLinus Torvalds struct mtd_info {
1311da177e4SLinus Torvalds 	u_char type;
13226cdb67cSDavid Woodhouse 	uint32_t flags;
13369423d99SAdrian Hunter 	uint64_t size;	 // Total size of the MTD
1341da177e4SLinus Torvalds 
135151e7659SDavid Woodhouse 	/* "Major" erase size for the device. Naïve users may take this
1361da177e4SLinus Torvalds 	 * to be the only erase size available, or may use the more detailed
1371da177e4SLinus Torvalds 	 * information below if they desire
1381da177e4SLinus Torvalds 	 */
13926cdb67cSDavid Woodhouse 	uint32_t erasesize;
140783ed81fSArtem B. Bityutskiy 	/* Minimal writable flash unit size. In case of NOR flash it is 1 (even
141783ed81fSArtem B. Bityutskiy 	 * though individual bits can be cleared), in case of NAND flash it is
142783ed81fSArtem B. Bityutskiy 	 * one NAND page (or half, or one-fourths of it), in case of ECC-ed NOR
143783ed81fSArtem B. Bityutskiy 	 * it is of ECC block size, etc. It is illegal to have writesize = 0.
144783ed81fSArtem B. Bityutskiy 	 * Any driver registering a struct mtd_info must ensure a writesize of
145783ed81fSArtem B. Bityutskiy 	 * 1 or larger.
14628318776SJoern Engel 	 */
14726cdb67cSDavid Woodhouse 	uint32_t writesize;
1481da177e4SLinus Torvalds 
1490e4ca7e5SAnatolij Gustschin 	/*
1500e4ca7e5SAnatolij Gustschin 	 * Size of the write buffer used by the MTD. MTD devices having a write
1510e4ca7e5SAnatolij Gustschin 	 * buffer can write multiple writesize chunks at a time. E.g. while
1520e4ca7e5SAnatolij Gustschin 	 * writing 4 * writesize bytes to a device with 2 * writesize bytes
1530e4ca7e5SAnatolij Gustschin 	 * buffer the MTD driver can (but doesn't have to) do 2 writesize
1540e4ca7e5SAnatolij Gustschin 	 * operations, but not 4. Currently, all NANDs have writebufsize
1550e4ca7e5SAnatolij Gustschin 	 * equivalent to writesize (NAND page size). Some NOR flashes do have
1560e4ca7e5SAnatolij Gustschin 	 * writebufsize greater than writesize.
1570e4ca7e5SAnatolij Gustschin 	 */
1580e4ca7e5SAnatolij Gustschin 	uint32_t writebufsize;
1590e4ca7e5SAnatolij Gustschin 
16026cdb67cSDavid Woodhouse 	uint32_t oobsize;   // Amount of OOB data per block (e.g. 16)
16126cdb67cSDavid Woodhouse 	uint32_t oobavail;  // Available OOB bytes per block
1621da177e4SLinus Torvalds 
16369423d99SAdrian Hunter 	/*
16469423d99SAdrian Hunter 	 * If erasesize is a power of 2 then the shift is stored in
16569423d99SAdrian Hunter 	 * erasesize_shift otherwise erasesize_shift is zero. Ditto writesize.
16669423d99SAdrian Hunter 	 */
16769423d99SAdrian Hunter 	unsigned int erasesize_shift;
16869423d99SAdrian Hunter 	unsigned int writesize_shift;
16969423d99SAdrian Hunter 	/* Masks based on erasesize_shift and writesize_shift */
17069423d99SAdrian Hunter 	unsigned int erasesize_mask;
17169423d99SAdrian Hunter 	unsigned int writesize_mask;
1721da177e4SLinus Torvalds 
1731da177e4SLinus Torvalds 	// Kernel-only stuff starts here.
174eadcf0d7SGreg Kroah-Hartman 	const char *name;
1751da177e4SLinus Torvalds 	int index;
1761da177e4SLinus Torvalds 
1777854d3f7SBrian Norris 	/* ECC layout structure pointer - read only! */
1785bd34c09SThomas Gleixner 	struct nand_ecclayout *ecclayout;
1791da177e4SLinus Torvalds 
1801da177e4SLinus Torvalds 	/* Data for variable erase regions. If numeraseregions is zero,
1811da177e4SLinus Torvalds 	 * it means that the whole device has erasesize as given above.
1821da177e4SLinus Torvalds 	 */
1831da177e4SLinus Torvalds 	int numeraseregions;
1841da177e4SLinus Torvalds 	struct mtd_erase_region_info *eraseregions;
1851da177e4SLinus Torvalds 
186b38178eeSJörn Engel 	/*
187b38178eeSJörn Engel 	 * Erase is an asynchronous operation.  Device drivers are supposed
188b38178eeSJörn Engel 	 * to call instr->callback() whenever the operation completes, even
189b38178eeSJörn Engel 	 * if it completes with a failure.
190b38178eeSJörn Engel 	 * Callers are supposed to pass a callback function and wait for it
191b38178eeSJörn Engel 	 * to be called before writing to the block.
192b38178eeSJörn Engel 	 */
1931da177e4SLinus Torvalds 	int (*erase) (struct mtd_info *mtd, struct erase_info *instr);
1941da177e4SLinus Torvalds 
1951da177e4SLinus Torvalds 	/* This stuff for eXecute-In-Place */
196a98889f3SJared Hulbert 	/* phys is optional and may be set to NULL */
197a98889f3SJared Hulbert 	int (*point) (struct mtd_info *mtd, loff_t from, size_t len,
198a98889f3SJared Hulbert 			size_t *retlen, void **virt, resource_size_t *phys);
1991da177e4SLinus Torvalds 
2001da177e4SLinus Torvalds 	/* We probably shouldn't allow XIP if the unpoint isn't a NULL */
201a98889f3SJared Hulbert 	void (*unpoint) (struct mtd_info *mtd, loff_t from, size_t len);
2021da177e4SLinus Torvalds 
203402d3265SDavid Howells 	/* Allow NOMMU mmap() to directly map the device (if not NULL)
204402d3265SDavid Howells 	 * - return the address to which the offset maps
205402d3265SDavid Howells 	 * - return -ENOSYS to indicate refusal to do the mapping
206402d3265SDavid Howells 	 */
207402d3265SDavid Howells 	unsigned long (*get_unmapped_area) (struct mtd_info *mtd,
208402d3265SDavid Howells 					    unsigned long len,
209402d3265SDavid Howells 					    unsigned long offset,
210402d3265SDavid Howells 					    unsigned long flags);
211402d3265SDavid Howells 
212402d3265SDavid Howells 	/* Backing device capabilities for this device
213402d3265SDavid Howells 	 * - provides mmap capabilities
214402d3265SDavid Howells 	 */
215402d3265SDavid Howells 	struct backing_dev_info *backing_dev_info;
216402d3265SDavid Howells 
2171da177e4SLinus Torvalds 
2181da177e4SLinus Torvalds 	int (*read) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf);
2191da177e4SLinus Torvalds 	int (*write) (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf);
2201da177e4SLinus Torvalds 
221388bbb09SRichard Purdie 	/* In blackbox flight recorder like scenarios we want to make successful
222388bbb09SRichard Purdie 	   writes in interrupt context. panic_write() is only intended to be
223388bbb09SRichard Purdie 	   called when its known the kernel is about to panic and we need the
224388bbb09SRichard Purdie 	   write to succeed. Since the kernel is not going to be running for much
225388bbb09SRichard Purdie 	   longer, this function can break locks and delay to ensure the write
226388bbb09SRichard Purdie 	   succeeds (but not sleep). */
227388bbb09SRichard Purdie 
228388bbb09SRichard Purdie 	int (*panic_write) (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf);
229388bbb09SRichard Purdie 
2308593fbc6SThomas Gleixner 	int (*read_oob) (struct mtd_info *mtd, loff_t from,
2318593fbc6SThomas Gleixner 			 struct mtd_oob_ops *ops);
2328593fbc6SThomas Gleixner 	int (*write_oob) (struct mtd_info *mtd, loff_t to,
2338593fbc6SThomas Gleixner 			 struct mtd_oob_ops *ops);
2341da177e4SLinus Torvalds 
2351da177e4SLinus Torvalds 	/*
2361da177e4SLinus Torvalds 	 * Methods to access the protection register area, present in some
2371da177e4SLinus Torvalds 	 * flash devices. The user data is one time programmable but the
2381da177e4SLinus Torvalds 	 * factory data is read only.
2391da177e4SLinus Torvalds 	 */
240f77814ddSNicolas Pitre 	int (*get_fact_prot_info) (struct mtd_info *mtd, struct otp_info *buf, size_t len);
2411da177e4SLinus Torvalds 	int (*read_fact_prot_reg) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf);
242f77814ddSNicolas Pitre 	int (*get_user_prot_info) (struct mtd_info *mtd, struct otp_info *buf, size_t len);
243f77814ddSNicolas Pitre 	int (*read_user_prot_reg) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf);
2441da177e4SLinus Torvalds 	int (*write_user_prot_reg) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf);
245f77814ddSNicolas Pitre 	int (*lock_user_prot_reg) (struct mtd_info *mtd, loff_t from, size_t len);
2461da177e4SLinus Torvalds 
2472528e8cdSThomas Gleixner 	/* kvec-based read/write methods.
2481da177e4SLinus Torvalds 	   NB: The 'count' parameter is the number of _vectors_, each of
2491da177e4SLinus Torvalds 	   which contains an (ofs, len) tuple.
2501da177e4SLinus Torvalds 	*/
2511da177e4SLinus Torvalds 	int (*writev) (struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, loff_t to, size_t *retlen);
2521da177e4SLinus Torvalds 
2531da177e4SLinus Torvalds 	/* Sync */
2541da177e4SLinus Torvalds 	void (*sync) (struct mtd_info *mtd);
2551da177e4SLinus Torvalds 
2561da177e4SLinus Torvalds 	/* Chip-supported device locking */
25769423d99SAdrian Hunter 	int (*lock) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
25869423d99SAdrian Hunter 	int (*unlock) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
2599938424fSRichard Cochran 	int (*is_locked) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
2601da177e4SLinus Torvalds 
2611da177e4SLinus Torvalds 	/* Power Management functions */
2621da177e4SLinus Torvalds 	int (*suspend) (struct mtd_info *mtd);
2631da177e4SLinus Torvalds 	void (*resume) (struct mtd_info *mtd);
2641da177e4SLinus Torvalds 
2651da177e4SLinus Torvalds 	/* Bad block management functions */
2661da177e4SLinus Torvalds 	int (*block_isbad) (struct mtd_info *mtd, loff_t ofs);
2671da177e4SLinus Torvalds 	int (*block_markbad) (struct mtd_info *mtd, loff_t ofs);
2681da177e4SLinus Torvalds 
269963a6fb0SNicolas Pitre 	struct notifier_block reboot_notifier;  /* default mode before reboot */
270963a6fb0SNicolas Pitre 
2717fac4648SThomas Gleixner 	/* ECC status information */
2727fac4648SThomas Gleixner 	struct mtd_ecc_stats ecc_stats;
27329072b96SThomas Gleixner 	/* Subpage shift (NAND) */
27429072b96SThomas Gleixner 	int subpage_sft;
2757fac4648SThomas Gleixner 
2761da177e4SLinus Torvalds 	void *priv;
2771da177e4SLinus Torvalds 
2781da177e4SLinus Torvalds 	struct module *owner;
2791f24b5a8SDavid Brownell 	struct device dev;
2801da177e4SLinus Torvalds 	int usecount;
2819fe912ceSArtem Bityutskiy 
2829fe912ceSArtem Bityutskiy 	/* If the driver is something smart, like UBI, it may need to maintain
2839fe912ceSArtem Bityutskiy 	 * its own reference counting. The below functions are only for driver.
2849fe912ceSArtem Bityutskiy 	 * The driver may register its callbacks. These callbacks are not
2859fe912ceSArtem Bityutskiy 	 * supposed to be called by MTD users */
2869fe912ceSArtem Bityutskiy 	int (*get_device) (struct mtd_info *mtd);
2879fe912ceSArtem Bityutskiy 	void (*put_device) (struct mtd_info *mtd);
2881da177e4SLinus Torvalds };
2891da177e4SLinus Torvalds 
2901f24b5a8SDavid Brownell static inline struct mtd_info *dev_to_mtd(struct device *dev)
2911f24b5a8SDavid Brownell {
2926afc4fdbSSaeed Bishara 	return dev ? dev_get_drvdata(dev) : NULL;
2931f24b5a8SDavid Brownell }
2941f24b5a8SDavid Brownell 
29526cdb67cSDavid Woodhouse static inline uint32_t mtd_div_by_eb(uint64_t sz, struct mtd_info *mtd)
29669423d99SAdrian Hunter {
29769423d99SAdrian Hunter 	if (mtd->erasesize_shift)
29869423d99SAdrian Hunter 		return sz >> mtd->erasesize_shift;
29969423d99SAdrian Hunter 	do_div(sz, mtd->erasesize);
30069423d99SAdrian Hunter 	return sz;
30169423d99SAdrian Hunter }
30269423d99SAdrian Hunter 
30326cdb67cSDavid Woodhouse static inline uint32_t mtd_mod_by_eb(uint64_t sz, struct mtd_info *mtd)
30469423d99SAdrian Hunter {
30569423d99SAdrian Hunter 	if (mtd->erasesize_shift)
30669423d99SAdrian Hunter 		return sz & mtd->erasesize_mask;
30769423d99SAdrian Hunter 	return do_div(sz, mtd->erasesize);
30869423d99SAdrian Hunter }
30969423d99SAdrian Hunter 
31026cdb67cSDavid Woodhouse static inline uint32_t mtd_div_by_ws(uint64_t sz, struct mtd_info *mtd)
31169423d99SAdrian Hunter {
31269423d99SAdrian Hunter 	if (mtd->writesize_shift)
31369423d99SAdrian Hunter 		return sz >> mtd->writesize_shift;
31469423d99SAdrian Hunter 	do_div(sz, mtd->writesize);
31569423d99SAdrian Hunter 	return sz;
31669423d99SAdrian Hunter }
31769423d99SAdrian Hunter 
31826cdb67cSDavid Woodhouse static inline uint32_t mtd_mod_by_ws(uint64_t sz, struct mtd_info *mtd)
31969423d99SAdrian Hunter {
32069423d99SAdrian Hunter 	if (mtd->writesize_shift)
32169423d99SAdrian Hunter 		return sz & mtd->writesize_mask;
32269423d99SAdrian Hunter 	return do_div(sz, mtd->writesize);
32369423d99SAdrian Hunter }
3241da177e4SLinus Torvalds 
3251da177e4SLinus Torvalds 	/* Kernel-side ioctl definitions */
3261da177e4SLinus Torvalds 
327f5671ab3SJamie Iles struct mtd_partition;
328c7975330SDmitry Eremin-Solenikov struct mtd_part_parser_data;
329f5671ab3SJamie Iles 
3301c4c215cSDmitry Eremin-Solenikov extern int mtd_device_parse_register(struct mtd_info *mtd,
3311c4c215cSDmitry Eremin-Solenikov 			      const char **part_probe_types,
332c7975330SDmitry Eremin-Solenikov 			      struct mtd_part_parser_data *parser_data,
3331c4c215cSDmitry Eremin-Solenikov 			      const struct mtd_partition *defparts,
3341c4c215cSDmitry Eremin-Solenikov 			      int defnr_parts);
33515c60a50SDmitry Eremin-Solenikov #define mtd_device_register(master, parts, nr_parts)	\
33615c60a50SDmitry Eremin-Solenikov 	mtd_device_parse_register(master, NULL, NULL, parts, nr_parts)
337f5671ab3SJamie Iles extern int mtd_device_unregister(struct mtd_info *master);
3381da177e4SLinus Torvalds extern struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num);
3393bd45657SMaxim Levitsky extern int __get_mtd_device(struct mtd_info *mtd);
3403bd45657SMaxim Levitsky extern void __put_mtd_device(struct mtd_info *mtd);
3417799308fSArtem Bityutskiy extern struct mtd_info *get_mtd_device_nm(const char *name);
3421da177e4SLinus Torvalds extern void put_mtd_device(struct mtd_info *mtd);
3431da177e4SLinus Torvalds 
3441da177e4SLinus Torvalds 
3451da177e4SLinus Torvalds struct mtd_notifier {
3461da177e4SLinus Torvalds 	void (*add)(struct mtd_info *mtd);
3471da177e4SLinus Torvalds 	void (*remove)(struct mtd_info *mtd);
3481da177e4SLinus Torvalds 	struct list_head list;
3491da177e4SLinus Torvalds };
3501da177e4SLinus Torvalds 
3511da177e4SLinus Torvalds 
3521da177e4SLinus Torvalds extern void register_mtd_user (struct mtd_notifier *new);
3531da177e4SLinus Torvalds extern int unregister_mtd_user (struct mtd_notifier *old);
3541da177e4SLinus Torvalds 
3551da177e4SLinus Torvalds int default_mtd_writev(struct mtd_info *mtd, const struct kvec *vecs,
3561da177e4SLinus Torvalds 		       unsigned long count, loff_t to, size_t *retlen);
3571da177e4SLinus Torvalds 
3581da177e4SLinus Torvalds int default_mtd_readv(struct mtd_info *mtd, struct kvec *vecs,
3591da177e4SLinus Torvalds 		      unsigned long count, loff_t from, size_t *retlen);
3601da177e4SLinus Torvalds 
36133b53716SGrant Erickson void *mtd_kmalloc_up_to(const struct mtd_info *mtd, size_t *size);
36233b53716SGrant Erickson 
3631da177e4SLinus Torvalds void mtd_erase_callback(struct erase_info *instr);
3641da177e4SLinus Torvalds 
3651da177e4SLinus Torvalds #endif /* __MTD_MTD_H__ */
366