Searched refs:mtd (Results 1 - 200 of 555) sorted by relevance

123

/linux-4.1.27/include/linux/mtd/
H A Dmtdram.h4 #include <linux/mtd/mtd.h>
5 int mtdram_init_device(struct mtd_info *mtd, void *mapped_address,
H A Dmtd.h28 #include <mtd/mtd-abi.h>
46 struct mtd_info *mtd; member in struct:erase_info
101 * similar, smaller struct nand_ecclayout_user (in mtd-abi.h) that is retained
162 * see Documentation/ABI/testing/sysfs-class-mtd for more detail.
189 int (*_erase) (struct mtd_info *mtd, struct erase_info *instr);
190 int (*_point) (struct mtd_info *mtd, loff_t from, size_t len,
192 int (*_unpoint) (struct mtd_info *mtd, loff_t from, size_t len);
193 unsigned long (*_get_unmapped_area) (struct mtd_info *mtd,
197 int (*_read) (struct mtd_info *mtd, loff_t from, size_t len,
199 int (*_write) (struct mtd_info *mtd, loff_t to, size_t len,
201 int (*_panic_write) (struct mtd_info *mtd, loff_t to, size_t len,
203 int (*_read_oob) (struct mtd_info *mtd, loff_t from,
205 int (*_write_oob) (struct mtd_info *mtd, loff_t to,
207 int (*_get_fact_prot_info) (struct mtd_info *mtd, size_t len,
209 int (*_read_fact_prot_reg) (struct mtd_info *mtd, loff_t from,
211 int (*_get_user_prot_info) (struct mtd_info *mtd, size_t len,
213 int (*_read_user_prot_reg) (struct mtd_info *mtd, loff_t from,
215 int (*_write_user_prot_reg) (struct mtd_info *mtd, loff_t to,
217 int (*_lock_user_prot_reg) (struct mtd_info *mtd, loff_t from,
219 int (*_writev) (struct mtd_info *mtd, const struct kvec *vecs,
221 void (*_sync) (struct mtd_info *mtd);
222 int (*_lock) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
223 int (*_unlock) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
224 int (*_is_locked) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
225 int (*_block_isreserved) (struct mtd_info *mtd, loff_t ofs);
226 int (*_block_isbad) (struct mtd_info *mtd, loff_t ofs);
227 int (*_block_markbad) (struct mtd_info *mtd, loff_t ofs);
228 int (*_suspend) (struct mtd_info *mtd);
229 void (*_resume) (struct mtd_info *mtd);
230 void (*_reboot) (struct mtd_info *mtd);
235 int (*_get_device) (struct mtd_info *mtd);
236 void (*_put_device) (struct mtd_info *mtd);
257 int mtd_erase(struct mtd_info *mtd, struct erase_info *instr);
258 int mtd_point(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
260 int mtd_unpoint(struct mtd_info *mtd, loff_t from, size_t len);
261 unsigned long mtd_get_unmapped_area(struct mtd_info *mtd, unsigned long len,
263 int mtd_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
265 int mtd_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
267 int mtd_panic_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
270 int mtd_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops);
272 static inline int mtd_write_oob(struct mtd_info *mtd, loff_t to, mtd_write_oob() argument
276 if (!mtd->_write_oob) mtd_write_oob()
278 if (!(mtd->flags & MTD_WRITEABLE)) mtd_write_oob()
280 return mtd->_write_oob(mtd, to, ops); mtd_write_oob()
283 int mtd_get_fact_prot_info(struct mtd_info *mtd, size_t len, size_t *retlen,
285 int mtd_read_fact_prot_reg(struct mtd_info *mtd, loff_t from, size_t len,
287 int mtd_get_user_prot_info(struct mtd_info *mtd, size_t len, size_t *retlen,
289 int mtd_read_user_prot_reg(struct mtd_info *mtd, loff_t from, size_t len,
291 int mtd_write_user_prot_reg(struct mtd_info *mtd, loff_t to, size_t len,
293 int mtd_lock_user_prot_reg(struct mtd_info *mtd, loff_t from, size_t len);
295 int mtd_writev(struct mtd_info *mtd, const struct kvec *vecs,
298 static inline void mtd_sync(struct mtd_info *mtd) mtd_sync() argument
300 if (mtd->_sync) mtd_sync()
301 mtd->_sync(mtd); mtd_sync()
304 int mtd_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
305 int mtd_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
306 int mtd_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len);
307 int mtd_block_isreserved(struct mtd_info *mtd, loff_t ofs);
308 int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs);
309 int mtd_block_markbad(struct mtd_info *mtd, loff_t ofs);
311 static inline int mtd_suspend(struct mtd_info *mtd) mtd_suspend() argument
313 return mtd->_suspend ? mtd->_suspend(mtd) : 0; mtd_suspend()
316 static inline void mtd_resume(struct mtd_info *mtd) mtd_resume() argument
318 if (mtd->_resume) mtd_resume()
319 mtd->_resume(mtd); mtd_resume()
322 static inline uint32_t mtd_div_by_eb(uint64_t sz, struct mtd_info *mtd) mtd_div_by_eb() argument
324 if (mtd->erasesize_shift) mtd_div_by_eb()
325 return sz >> mtd->erasesize_shift; mtd_div_by_eb()
326 do_div(sz, mtd->erasesize); mtd_div_by_eb()
330 static inline uint32_t mtd_mod_by_eb(uint64_t sz, struct mtd_info *mtd) mtd_mod_by_eb() argument
332 if (mtd->erasesize_shift) mtd_mod_by_eb()
333 return sz & mtd->erasesize_mask; mtd_mod_by_eb()
334 return do_div(sz, mtd->erasesize); mtd_mod_by_eb()
337 static inline uint32_t mtd_div_by_ws(uint64_t sz, struct mtd_info *mtd) mtd_div_by_ws() argument
339 if (mtd->writesize_shift) mtd_div_by_ws()
340 return sz >> mtd->writesize_shift; mtd_div_by_ws()
341 do_div(sz, mtd->writesize); mtd_div_by_ws()
345 static inline uint32_t mtd_mod_by_ws(uint64_t sz, struct mtd_info *mtd) mtd_mod_by_ws() argument
347 if (mtd->writesize_shift) mtd_mod_by_ws()
348 return sz & mtd->writesize_mask; mtd_mod_by_ws()
349 return do_div(sz, mtd->writesize); mtd_mod_by_ws()
352 static inline int mtd_has_oob(const struct mtd_info *mtd) mtd_has_oob() argument
354 return mtd->_read_oob && mtd->_write_oob; mtd_has_oob()
357 static inline int mtd_type_is_nand(const struct mtd_info *mtd) mtd_type_is_nand() argument
359 return mtd->type == MTD_NANDFLASH || mtd->type == MTD_MLCNANDFLASH; mtd_type_is_nand()
362 static inline int mtd_can_have_bb(const struct mtd_info *mtd) mtd_can_have_bb() argument
364 return !!mtd->_block_isbad; mtd_can_have_bb()
372 extern int mtd_device_parse_register(struct mtd_info *mtd,
380 extern struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num);
381 extern int __get_mtd_device(struct mtd_info *mtd);
382 extern void __put_mtd_device(struct mtd_info *mtd);
384 extern void put_mtd_device(struct mtd_info *mtd);
388 void (*add)(struct mtd_info *mtd);
389 void (*remove)(struct mtd_info *mtd);
396 void *mtd_kmalloc_up_to(const struct mtd_info *mtd, size_t *size);
412 unsigned mtd_mmap_capabilities(struct mtd_info *mtd);
H A Dsharpsl.h11 #include <linux/mtd/nand.h>
12 #include <linux/mtd/nand_ecc.h>
13 #include <linux/mtd/partitions.h>
H A Dinftl.h14 #include <linux/mtd/blktrans.h>
15 #include <linux/mtd/mtd.h>
16 #include <linux/mtd/nftl.h>
18 #include <mtd/inftl-user.h>
56 int inftl_read_oob(struct mtd_info *mtd, loff_t offs, size_t len,
58 int inftl_write_oob(struct mtd_info *mtd, loff_t offs, size_t len,
H A Dnand-gpio.h4 #include <linux/mtd/nand.h>
H A Dphysmap.h3 * drivers/mtd/maps/physmap.c mapping driver.
18 #include <linux/mtd/mtd.h>
19 #include <linux/mtd/partitions.h>
H A Dnand_bch.h24 int nand_bch_calculate_ecc(struct mtd_info *mtd, const u_char *dat, mtd_nand_has_bch()
30 int nand_bch_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, mtd_nand_has_bch()
36 nand_bch_init(struct mtd_info *mtd, unsigned int eccsize, mtd_nand_has_bch()
48 nand_bch_calculate_ecc(struct mtd_info *mtd, const u_char *dat, nand_bch_calculate_ecc() argument
55 nand_bch_correct_data(struct mtd_info *mtd, unsigned char *buf, nand_bch_correct_data() argument
62 nand_bch_init(struct mtd_info *mtd, unsigned int eccsize, nand_bch_init() argument
H A Donenand.h2 * linux/include/linux/mtd/onenand.h
17 #include <linux/mtd/flashchip.h>
18 #include <linux/mtd/onenand_regs.h>
19 #include <linux/mtd/bbm.h>
25 extern int onenand_scan(struct mtd_info *mtd, int max_chips);
27 extern void onenand_release(struct mtd_info *mtd);
107 int (*command)(struct mtd_info *mtd, int cmd, loff_t address, size_t len);
108 int (*wait)(struct mtd_info *mtd, int state);
109 int (*bbt_wait)(struct mtd_info *mtd, int state);
110 void (*unlock_all)(struct mtd_info *mtd);
111 int (*read_bufferram)(struct mtd_info *mtd, int area,
113 int (*write_bufferram)(struct mtd_info *mtd, int area,
117 void (*mmcontrol)(struct mtd_info *mtd, int sync_read);
118 int (*chip_probe)(struct mtd_info *mtd);
119 int (*block_markbad)(struct mtd_info *mtd, loff_t ofs);
120 int (*scan_bbt)(struct mtd_info *mtd);
121 int (*enable)(struct mtd_info *mtd);
122 int (*disable)(struct mtd_info *mtd);
226 int onenand_bbt_read_oob(struct mtd_info *mtd, loff_t from,
230 int flexonenand_region(struct mtd_info *mtd, loff_t addr);
235 void (*mmcontrol)(struct mtd_info *mtd, int sync_read);
236 int (*read_bufferram)(struct mtd_info *mtd, int area,
H A Dnand_ecc.h2 * drivers/mtd/nand_ecc.h
29 int nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code);
40 int nand_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_char *calc_ecc);
H A Dnftl.h23 #include <linux/mtd/mtd.h>
24 #include <linux/mtd/blktrans.h>
26 #include <mtd/nftl-user.h>
59 int nftl_read_oob(struct mtd_info *mtd, loff_t offs, size_t len,
61 int nftl_write_oob(struct mtd_info *mtd, loff_t offs, size_t len,
H A Dsuper.h17 #include <linux/mtd/mtd.h>
H A Dnand.h2 * linux/include/linux/mtd/nand.h
23 #include <linux/mtd/mtd.h>
24 #include <linux/mtd/flashchip.h>
25 #include <linux/mtd/bbm.h>
30 extern int nand_scan(struct mtd_info *mtd, int max_chips);
35 extern int nand_scan_ident(struct mtd_info *mtd, int max_chips,
37 extern int nand_scan_tail(struct mtd_info *mtd);
40 extern void nand_release(struct mtd_info *mtd);
43 extern void nand_wait_ready(struct mtd_info *mtd);
46 extern int nand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
49 extern int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
431 * @active: the mtd device which holds the controller currently
497 void (*hwctl)(struct mtd_info *mtd, int mode);
498 int (*calculate)(struct mtd_info *mtd, const uint8_t *dat,
500 int (*correct)(struct mtd_info *mtd, uint8_t *dat, uint8_t *read_ecc,
502 int (*read_page_raw)(struct mtd_info *mtd, struct nand_chip *chip,
504 int (*write_page_raw)(struct mtd_info *mtd, struct nand_chip *chip,
506 int (*read_page)(struct mtd_info *mtd, struct nand_chip *chip,
508 int (*read_subpage)(struct mtd_info *mtd, struct nand_chip *chip,
510 int (*write_subpage)(struct mtd_info *mtd, struct nand_chip *chip,
513 int (*write_page)(struct mtd_info *mtd, struct nand_chip *chip,
515 int (*write_oob_raw)(struct mtd_info *mtd, struct nand_chip *chip,
517 int (*read_oob_raw)(struct mtd_info *mtd, struct nand_chip *chip,
519 int (*read_oob)(struct mtd_info *mtd, struct nand_chip *chip, int page);
520 int (*write_oob)(struct mtd_info *mtd, struct nand_chip *chip,
557 * mtd->oobsize, mtd->writesize and so on.
647 uint8_t (*read_byte)(struct mtd_info *mtd);
648 u16 (*read_word)(struct mtd_info *mtd);
649 void (*write_byte)(struct mtd_info *mtd, uint8_t byte);
650 void (*write_buf)(struct mtd_info *mtd, const uint8_t *buf, int len);
651 void (*read_buf)(struct mtd_info *mtd, uint8_t *buf, int len);
652 void (*select_chip)(struct mtd_info *mtd, int chip);
653 int (*block_bad)(struct mtd_info *mtd, loff_t ofs, int getchip);
654 int (*block_markbad)(struct mtd_info *mtd, loff_t ofs);
655 void (*cmd_ctrl)(struct mtd_info *mtd, int dat, unsigned int ctrl);
656 int (*init_size)(struct mtd_info *mtd, struct nand_chip *this,
658 int (*dev_ready)(struct mtd_info *mtd);
659 void (*cmdfunc)(struct mtd_info *mtd, unsigned command, int column,
661 int(*waitfunc)(struct mtd_info *mtd, struct nand_chip *this);
662 int (*erase)(struct mtd_info *mtd, int page);
663 int (*scan_bbt)(struct mtd_info *mtd);
664 int (*errstat)(struct mtd_info *mtd, struct nand_chip *this, int state,
666 int (*write_page)(struct mtd_info *mtd, struct nand_chip *chip,
669 int (*onfi_set_features)(struct mtd_info *mtd, struct nand_chip *chip,
671 int (*onfi_get_features)(struct mtd_info *mtd, struct nand_chip *chip,
673 int (*setup_read_retry)(struct mtd_info *mtd, int retry_mode);
836 extern int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd);
837 extern int nand_default_bbt(struct mtd_info *mtd);
838 extern int nand_markbad_bbt(struct mtd_info *mtd, loff_t offs);
839 extern int nand_isreserved_bbt(struct mtd_info *mtd, loff_t offs);
840 extern int nand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt);
841 extern int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr,
843 extern int nand_do_read(struct mtd_info *mtd, loff_t from, size_t len,
851 * @partitions: mtd partition list
892 void (*hwcontrol)(struct mtd_info *mtd, int cmd);
893 int (*dev_ready)(struct mtd_info *mtd);
894 void (*select_chip)(struct mtd_info *mtd, int chip);
895 void (*cmd_ctrl)(struct mtd_info *mtd, int dat, unsigned int ctrl);
896 void (*write_buf)(struct mtd_info *mtd, const uint8_t *buf, int len);
897 void (*read_buf)(struct mtd_info *mtd, uint8_t *buf, int len);
898 unsigned char (*read_byte)(struct mtd_info *mtd);
914 struct platform_nand_chip *get_platform_nandchip(struct mtd_info *mtd) get_platform_nandchip() argument
916 struct nand_chip *chip = mtd->priv; get_platform_nandchip()
H A Dqinfo.h4 #include <linux/mtd/map.h>
8 #include <linux/mtd/mtd.h>
9 #include <linux/mtd/flashchip.h>
10 #include <linux/mtd/partitions.h>
H A Dspear_smi.h14 #include <linux/mtd/mtd.h>
15 #include <linux/mtd/partitions.h>
H A Dgen_probe.h24 #include <linux/mtd/flashchip.h>
25 #include <linux/mtd/map.h>
26 #include <linux/mtd/cfi.h>
/linux-4.1.27/drivers/staging/goldfish/
H A Dgoldfish_nand.c2 * drivers/mtd/devices/goldfish_nand.c
25 #include <linux/mtd/mtd.h>
39 struct mtd_info mtd[0]; member in struct:goldfish_nand
42 static u32 goldfish_nand_cmd_with_params(struct mtd_info *mtd, goldfish_nand_cmd_with_params() argument
47 struct goldfish_nand *nand = mtd->priv; goldfish_nand_cmd_with_params()
67 cps->dev = mtd - nand->mtd; goldfish_nand_cmd_with_params()
77 static u32 goldfish_nand_cmd(struct mtd_info *mtd, enum nand_cmd cmd, goldfish_nand_cmd() argument
80 struct goldfish_nand *nand = mtd->priv; goldfish_nand_cmd()
85 if (goldfish_nand_cmd_with_params(mtd, cmd, addr, len, ptr, &rv)) { goldfish_nand_cmd()
86 writel(mtd - nand->mtd, base + NAND_DEV); goldfish_nand_cmd()
98 static int goldfish_nand_erase(struct mtd_info *mtd, struct erase_info *instr) goldfish_nand_erase() argument
104 if (ofs + len > mtd->size) goldfish_nand_erase()
106 rem = do_div(ofs, mtd->writesize); goldfish_nand_erase()
109 ofs *= (mtd->writesize + mtd->oobsize); goldfish_nand_erase()
111 if (len % mtd->writesize) goldfish_nand_erase()
113 len = len / mtd->writesize * (mtd->writesize + mtd->oobsize); goldfish_nand_erase()
115 if (goldfish_nand_cmd(mtd, NAND_CMD_ERASE, ofs, len, NULL) != len) { goldfish_nand_erase()
117 ofs, len, mtd->size, mtd->erasesize); goldfish_nand_erase()
128 ofs, len, mtd->size, mtd->erasesize); goldfish_nand_erase()
132 static int goldfish_nand_read_oob(struct mtd_info *mtd, loff_t ofs, goldfish_nand_read_oob() argument
137 if (ofs + ops->len > mtd->size) goldfish_nand_read_oob()
139 if (ops->datbuf && ops->len && ops->len != mtd->writesize) goldfish_nand_read_oob()
141 if (ops->ooblen + ops->ooboffs > mtd->oobsize) goldfish_nand_read_oob()
144 rem = do_div(ofs, mtd->writesize); goldfish_nand_read_oob()
147 ofs *= (mtd->writesize + mtd->oobsize); goldfish_nand_read_oob()
150 ops->retlen = goldfish_nand_cmd(mtd, NAND_CMD_READ, ofs, goldfish_nand_read_oob()
152 ofs += mtd->writesize + ops->ooboffs; goldfish_nand_read_oob()
154 ops->oobretlen = goldfish_nand_cmd(mtd, NAND_CMD_READ, ofs, goldfish_nand_read_oob()
160 ofs, ops->len, ops->ooblen, mtd->size, mtd->writesize); goldfish_nand_read_oob()
164 static int goldfish_nand_write_oob(struct mtd_info *mtd, loff_t ofs, goldfish_nand_write_oob() argument
169 if (ofs + ops->len > mtd->size) goldfish_nand_write_oob()
171 if (ops->len && ops->len != mtd->writesize) goldfish_nand_write_oob()
173 if (ops->ooblen + ops->ooboffs > mtd->oobsize) goldfish_nand_write_oob()
176 rem = do_div(ofs, mtd->writesize); goldfish_nand_write_oob()
179 ofs *= (mtd->writesize + mtd->oobsize); goldfish_nand_write_oob()
182 ops->retlen = goldfish_nand_cmd(mtd, NAND_CMD_WRITE, ofs, goldfish_nand_write_oob()
184 ofs += mtd->writesize + ops->ooboffs; goldfish_nand_write_oob()
186 ops->oobretlen = goldfish_nand_cmd(mtd, NAND_CMD_WRITE, ofs, goldfish_nand_write_oob()
192 ofs, ops->len, ops->ooblen, mtd->size, mtd->writesize); goldfish_nand_write_oob()
196 static int goldfish_nand_read(struct mtd_info *mtd, loff_t from, size_t len, goldfish_nand_read() argument
201 if (from + len > mtd->size) goldfish_nand_read()
204 rem = do_div(from, mtd->writesize); goldfish_nand_read()
207 from *= (mtd->writesize + mtd->oobsize); goldfish_nand_read()
209 *retlen = goldfish_nand_cmd(mtd, NAND_CMD_READ, from, len, buf); goldfish_nand_read()
214 from, len, mtd->size, mtd->writesize); goldfish_nand_read()
218 static int goldfish_nand_write(struct mtd_info *mtd, loff_t to, size_t len, goldfish_nand_write() argument
223 if (to + len > mtd->size) goldfish_nand_write()
226 rem = do_div(to, mtd->writesize); goldfish_nand_write()
229 to *= (mtd->writesize + mtd->oobsize); goldfish_nand_write()
231 *retlen = goldfish_nand_cmd(mtd, NAND_CMD_WRITE, to, len, (void *)buf); goldfish_nand_write()
236 to, len, mtd->size, mtd->writesize); goldfish_nand_write()
240 static int goldfish_nand_block_isbad(struct mtd_info *mtd, loff_t ofs) goldfish_nand_block_isbad() argument
244 if (ofs >= mtd->size) goldfish_nand_block_isbad()
247 rem = do_div(ofs, mtd->erasesize); goldfish_nand_block_isbad()
250 ofs *= mtd->erasesize / mtd->writesize; goldfish_nand_block_isbad()
251 ofs *= (mtd->writesize + mtd->oobsize); goldfish_nand_block_isbad()
253 return goldfish_nand_cmd(mtd, NAND_CMD_BLOCK_BAD_GET, ofs, 0, NULL); goldfish_nand_block_isbad()
257 ofs, mtd->size, mtd->writesize); goldfish_nand_block_isbad()
261 static int goldfish_nand_block_markbad(struct mtd_info *mtd, loff_t ofs) goldfish_nand_block_markbad() argument
265 if (ofs >= mtd->size) goldfish_nand_block_markbad()
268 rem = do_div(ofs, mtd->erasesize); goldfish_nand_block_markbad()
271 ofs *= mtd->erasesize / mtd->writesize; goldfish_nand_block_markbad()
272 ofs *= (mtd->writesize + mtd->oobsize); goldfish_nand_block_markbad()
274 if (goldfish_nand_cmd(mtd, NAND_CMD_BLOCK_BAD_SET, ofs, 0, NULL) != 1) goldfish_nand_block_markbad()
280 ofs, mtd->size, mtd->writesize); goldfish_nand_block_markbad()
308 struct mtd_info *mtd = &nand->mtd[id]; goldfish_nand_init_device() local
315 mtd->writesize = readl(base + NAND_DEV_PAGE_SIZE); goldfish_nand_init_device()
316 mtd->size = readl(base + NAND_DEV_SIZE_LOW); goldfish_nand_init_device()
317 mtd->size |= (u64)readl(base + NAND_DEV_SIZE_HIGH) << 32; goldfish_nand_init_device()
318 mtd->oobsize = readl(base + NAND_DEV_EXTRA_SIZE); goldfish_nand_init_device()
319 mtd->oobavail = mtd->oobsize; goldfish_nand_init_device()
320 mtd->erasesize = readl(base + NAND_DEV_ERASE_SIZE) / goldfish_nand_init_device()
321 (mtd->writesize + mtd->oobsize) * mtd->writesize; goldfish_nand_init_device()
322 do_div(mtd->size, mtd->writesize + mtd->oobsize); goldfish_nand_init_device()
323 mtd->size *= mtd->writesize; goldfish_nand_init_device()
326 id, mtd->size, mtd->writesize, goldfish_nand_init_device()
327 mtd->oobsize, mtd->erasesize); goldfish_nand_init_device()
330 mtd->priv = nand; goldfish_nand_init_device()
335 mtd->name = name; goldfish_nand_init_device()
337 result = goldfish_nand_cmd(mtd, NAND_CMD_GET_DEV_NAME, 0, name_len, goldfish_nand_init_device()
345 ((char *)mtd->name)[name_len] = '\0'; goldfish_nand_init_device()
348 mtd->type = MTD_NANDFLASH; goldfish_nand_init_device()
349 mtd->flags = MTD_CAP_NANDFLASH; goldfish_nand_init_device()
351 mtd->flags &= ~MTD_WRITEABLE; goldfish_nand_init_device()
355 mtd->owner = THIS_MODULE; goldfish_nand_init_device()
356 mtd->_erase = goldfish_nand_erase; goldfish_nand_init_device()
357 mtd->_read = goldfish_nand_read; goldfish_nand_init_device()
358 mtd->_write = goldfish_nand_write; goldfish_nand_init_device()
359 mtd->_read_oob = goldfish_nand_read_oob; goldfish_nand_init_device()
360 mtd->_write_oob = goldfish_nand_write_oob; goldfish_nand_init_device()
361 mtd->_block_isbad = goldfish_nand_block_isbad; goldfish_nand_init_device()
362 mtd->_block_markbad = goldfish_nand_block_markbad; goldfish_nand_init_device()
364 if (mtd_device_register(mtd, NULL, 0)) goldfish_nand_init_device()
427 if (nand->mtd[i].name) goldfish_nand_remove()
428 mtd_device_unregister(&nand->mtd[i]); goldfish_nand_remove()
/linux-4.1.27/drivers/mtd/tests/
H A Dmtd_test.h1 #include <linux/mtd/mtd.h>
15 int mtdtest_erase_eraseblock(struct mtd_info *mtd, unsigned int ebnum);
16 int mtdtest_scan_for_bad_eraseblocks(struct mtd_info *mtd, unsigned char *bbt,
18 int mtdtest_erase_good_eraseblocks(struct mtd_info *mtd, unsigned char *bbt,
21 int mtdtest_read(struct mtd_info *mtd, loff_t addr, size_t size, void *buf);
22 int mtdtest_write(struct mtd_info *mtd, loff_t addr, size_t size,
H A Dmtd_test.c9 int mtdtest_erase_eraseblock(struct mtd_info *mtd, unsigned int ebnum) mtdtest_erase_eraseblock() argument
13 loff_t addr = (loff_t)ebnum * mtd->erasesize; mtdtest_erase_eraseblock()
16 ei.mtd = mtd; mtdtest_erase_eraseblock()
18 ei.len = mtd->erasesize; mtdtest_erase_eraseblock()
20 err = mtd_erase(mtd, &ei); mtdtest_erase_eraseblock()
33 static int is_block_bad(struct mtd_info *mtd, unsigned int ebnum) is_block_bad() argument
36 loff_t addr = (loff_t)ebnum * mtd->erasesize; is_block_bad()
38 ret = mtd_block_isbad(mtd, addr); is_block_bad()
45 int mtdtest_scan_for_bad_eraseblocks(struct mtd_info *mtd, unsigned char *bbt, mtdtest_scan_for_bad_eraseblocks() argument
50 if (!mtd_can_have_bb(mtd)) mtdtest_scan_for_bad_eraseblocks()
55 bbt[i] = is_block_bad(mtd, eb + i) ? 1 : 0; mtdtest_scan_for_bad_eraseblocks()
65 int mtdtest_erase_good_eraseblocks(struct mtd_info *mtd, unsigned char *bbt, mtdtest_erase_good_eraseblocks() argument
74 err = mtdtest_erase_eraseblock(mtd, eb + i); mtdtest_erase_good_eraseblocks()
83 int mtdtest_read(struct mtd_info *mtd, loff_t addr, size_t size, void *buf) mtdtest_read() argument
88 err = mtd_read(mtd, addr, size, &read, buf); mtdtest_read()
100 int mtdtest_write(struct mtd_info *mtd, loff_t addr, size_t size, mtdtest_write() argument
106 err = mtd_write(mtd, addr, size, &written, buf); mtdtest_write()
H A Dreadtest.c28 #include <linux/mtd/mtd.h>
38 static struct mtd_info *mtd; variable in typeref:struct:mtd_info
50 loff_t addr = (loff_t)ebnum * mtd->erasesize; read_eraseblock_by_page()
56 ret = mtdtest_read(mtd, addr, pgsize, buf); read_eraseblock_by_page()
61 if (mtd->oobsize) { read_eraseblock_by_page()
67 ops.ooblen = mtd->oobsize; read_eraseblock_by_page()
72 ret = mtd_read_oob(mtd, addr, &ops); read_eraseblock_by_page()
74 ops.oobretlen != mtd->oobsize) { read_eraseblock_by_page()
82 oobbuf += mtd->oobsize; read_eraseblock_by_page()
98 n = mtd->erasesize; dump_eraseblock()
108 if (!mtd->oobsize) dump_eraseblock()
111 n = mtd->oobsize; dump_eraseblock()
134 pr_info("Please specify a valid mtd-device via module parameter\n"); mtd_readtest_init()
140 mtd = get_mtd_device(NULL, dev); mtd_readtest_init()
141 if (IS_ERR(mtd)) { mtd_readtest_init()
142 err = PTR_ERR(mtd); mtd_readtest_init()
147 if (mtd->writesize == 1) { mtd_readtest_init()
152 pgsize = mtd->writesize; mtd_readtest_init()
154 tmp = mtd->size; mtd_readtest_init()
155 do_div(tmp, mtd->erasesize); mtd_readtest_init()
157 pgcnt = mtd->erasesize / pgsize; mtd_readtest_init()
162 (unsigned long long)mtd->size, mtd->erasesize, mtd_readtest_init()
163 pgsize, ebcnt, pgcnt, mtd->oobsize); mtd_readtest_init()
166 iobuf = kmalloc(mtd->erasesize, GFP_KERNEL); mtd_readtest_init()
169 iobuf1 = kmalloc(mtd->erasesize, GFP_KERNEL); mtd_readtest_init()
176 err = mtdtest_scan_for_bad_eraseblocks(mtd, bbt, 0, ebcnt); mtd_readtest_init()
211 put_mtd_device(mtd); mtd_readtest_init()
H A Dpagetest.c29 #include <linux/mtd/mtd.h>
40 static struct mtd_info *mtd; variable in typeref:struct:mtd_info
55 loff_t addr = (loff_t)ebnum * mtd->erasesize; write_eraseblock()
57 prandom_bytes_state(&rnd_state, writebuf, mtd->erasesize); write_eraseblock()
59 return mtdtest_write(mtd, addr, mtd->erasesize, writebuf); write_eraseblock()
67 loff_t addr = (loff_t)ebnum * mtd->erasesize; verify_eraseblock()
71 addr0 += mtd->erasesize; verify_eraseblock()
73 addrn = mtd->size; verify_eraseblock()
75 addrn -= mtd->erasesize; verify_eraseblock()
77 prandom_bytes_state(&rnd_state, writebuf, mtd->erasesize); verify_eraseblock()
80 err = mtdtest_read(mtd, addr0, bufsize, twopages); verify_eraseblock()
83 err = mtdtest_read(mtd, addrn - bufsize, bufsize, twopages); verify_eraseblock()
87 err = mtdtest_read(mtd, addr, bufsize, twopages); verify_eraseblock()
101 err = mtdtest_read(mtd, addr0, bufsize, twopages); verify_eraseblock()
104 err = mtdtest_read(mtd, addrn - bufsize, bufsize, twopages); verify_eraseblock()
108 err = mtdtest_read(mtd, addr, bufsize, twopages); verify_eraseblock()
111 memcpy(boundary, writebuf + mtd->erasesize - pgsize, pgsize); verify_eraseblock()
140 addr0 += mtd->erasesize; crosstest()
142 addrn = mtd->size; crosstest()
144 addrn -= mtd->erasesize; crosstest()
148 err = mtdtest_read(mtd, addr, pgsize, pp1); crosstest()
156 err = mtdtest_read(mtd, addr, pgsize, pp1); crosstest()
165 err = mtdtest_read(mtd, addr, pgsize, pp2); crosstest()
174 err = mtdtest_read(mtd, addr, pgsize, pp3); crosstest()
183 err = mtdtest_read(mtd, addr, pgsize, pp4); crosstest()
212 addr0 += mtd->erasesize; erasecrosstest()
221 err = mtdtest_erase_eraseblock(mtd, ebnum); erasecrosstest()
228 err = mtdtest_write(mtd, addr0, pgsize, writebuf); erasecrosstest()
234 err = mtdtest_read(mtd, addr0, pgsize, readbuf); erasecrosstest()
246 err = mtdtest_erase_eraseblock(mtd, ebnum); erasecrosstest()
253 err = mtdtest_write(mtd, addr0, pgsize, writebuf); erasecrosstest()
258 err = mtdtest_erase_eraseblock(mtd, ebnum2); erasecrosstest()
264 err = mtdtest_read(mtd, addr0, pgsize, readbuf); erasecrosstest()
290 addr0 += mtd->erasesize; erasetest()
295 err = mtdtest_erase_eraseblock(mtd, ebnum); erasetest()
301 err = mtdtest_write(mtd, addr0, pgsize, writebuf); erasetest()
306 err = mtdtest_erase_eraseblock(mtd, ebnum); erasetest()
311 err = mtdtest_read(mtd, addr0, pgsize, twopages); erasetest()
342 pr_info("Please specify a valid mtd-device via module parameter\n"); mtd_pagetest_init()
349 mtd = get_mtd_device(NULL, dev); mtd_pagetest_init()
350 if (IS_ERR(mtd)) { mtd_pagetest_init()
351 err = PTR_ERR(mtd); mtd_pagetest_init()
356 if (!mtd_type_is_nand(mtd)) { mtd_pagetest_init()
361 tmp = mtd->size; mtd_pagetest_init()
362 do_div(tmp, mtd->erasesize); mtd_pagetest_init()
364 pgcnt = mtd->erasesize / mtd->writesize; mtd_pagetest_init()
365 pgsize = mtd->writesize; mtd_pagetest_init()
370 (unsigned long long)mtd->size, mtd->erasesize, mtd_pagetest_init()
371 pgsize, ebcnt, pgcnt, mtd->oobsize); mtd_pagetest_init()
375 writebuf = kmalloc(mtd->erasesize, GFP_KERNEL); mtd_pagetest_init()
388 err = mtdtest_scan_for_bad_eraseblocks(mtd, bbt, 0, ebcnt); mtd_pagetest_init()
394 err = mtdtest_erase_good_eraseblocks(mtd, bbt, 0, ebcnt); mtd_pagetest_init()
454 put_mtd_device(mtd); mtd_pagetest_init()
H A Dstresstest.c28 #include <linux/mtd/mtd.h>
44 static struct mtd_info *mtd; variable in typeref:struct:mtd_info
94 if (offs >= mtd->erasesize) do_read()
95 offs -= mtd->erasesize; do_read()
96 if (offs + len > mtd->erasesize) do_read()
97 len = mtd->erasesize - offs; do_read()
99 addr = (loff_t)eb * mtd->erasesize + offs; do_read()
100 return mtdtest_read(mtd, addr, len, readbuf); do_read()
109 if (offs >= mtd->erasesize) { do_write()
110 err = mtdtest_erase_eraseblock(mtd, eb); do_write()
117 if (offs + len > mtd->erasesize) { do_write()
119 len = mtd->erasesize - offs; do_write()
121 err = mtdtest_erase_eraseblock(mtd, eb + 1); do_write()
127 addr = (loff_t)eb * mtd->erasesize + offs; do_write()
128 err = mtdtest_write(mtd, addr, len, writebuf); do_write()
132 while (offs > mtd->erasesize) { do_write()
133 offsets[eb++] = mtd->erasesize; do_write()
134 offs -= mtd->erasesize; do_write()
158 pr_info("Please specify a valid mtd-device via module parameter\n"); mtd_stresstest_init()
165 mtd = get_mtd_device(NULL, dev); mtd_stresstest_init()
166 if (IS_ERR(mtd)) { mtd_stresstest_init()
167 err = PTR_ERR(mtd); mtd_stresstest_init()
172 if (mtd->writesize == 1) { mtd_stresstest_init()
177 pgsize = mtd->writesize; mtd_stresstest_init()
179 tmp = mtd->size; mtd_stresstest_init()
180 do_div(tmp, mtd->erasesize); mtd_stresstest_init()
182 pgcnt = mtd->erasesize / pgsize; mtd_stresstest_init()
187 (unsigned long long)mtd->size, mtd->erasesize, mtd_stresstest_init()
188 pgsize, ebcnt, pgcnt, mtd->oobsize); mtd_stresstest_init()
197 bufsize = mtd->erasesize * 2; mtd_stresstest_init()
206 offsets[i] = mtd->erasesize; mtd_stresstest_init()
212 err = mtdtest_scan_for_bad_eraseblocks(mtd, bbt, 0, ebcnt); mtd_stresstest_init()
237 put_mtd_device(mtd); mtd_stresstest_init()
H A Dspeedtest.c28 #include <linux/mtd/mtd.h>
44 static struct mtd_info *mtd; variable in typeref:struct:mtd_info
58 loff_t addr = (loff_t)ebnum * mtd->erasesize; multiblock_erase()
61 ei.mtd = mtd; multiblock_erase()
63 ei.len = mtd->erasesize * blocks; multiblock_erase()
65 err = mtd_erase(mtd, &ei); multiblock_erase()
83 loff_t addr = (loff_t)ebnum * mtd->erasesize; write_eraseblock()
85 return mtdtest_write(mtd, addr, mtd->erasesize, iobuf); write_eraseblock()
91 loff_t addr = (loff_t)ebnum * mtd->erasesize; write_eraseblock_by_page()
95 err = mtdtest_write(mtd, addr, pgsize, buf); write_eraseblock_by_page()
109 loff_t addr = (loff_t)ebnum * mtd->erasesize; write_eraseblock_by_2pages()
113 err = mtdtest_write(mtd, addr, sz, buf); write_eraseblock_by_2pages()
120 err = mtdtest_write(mtd, addr, pgsize, buf); write_eraseblock_by_2pages()
127 loff_t addr = (loff_t)ebnum * mtd->erasesize; read_eraseblock()
129 return mtdtest_read(mtd, addr, mtd->erasesize, iobuf); read_eraseblock()
135 loff_t addr = (loff_t)ebnum * mtd->erasesize; read_eraseblock_by_page()
139 err = mtdtest_read(mtd, addr, pgsize, buf); read_eraseblock_by_page()
153 loff_t addr = (loff_t)ebnum * mtd->erasesize; read_eraseblock_by_2pages()
157 err = mtdtest_read(mtd, addr, sz, buf); read_eraseblock_by_2pages()
164 err = mtdtest_read(mtd, addr, pgsize, buf); read_eraseblock_by_2pages()
188 k = (uint64_t)goodebcnt * (mtd->erasesize / 1024) * 1000; calc_speed()
203 pr_info("Please specify a valid mtd-device via module parameter\n"); mtd_speedtest_init()
213 mtd = get_mtd_device(NULL, dev); mtd_speedtest_init()
214 if (IS_ERR(mtd)) { mtd_speedtest_init()
215 err = PTR_ERR(mtd); mtd_speedtest_init()
220 if (mtd->writesize == 1) { mtd_speedtest_init()
225 pgsize = mtd->writesize; mtd_speedtest_init()
227 tmp = mtd->size; mtd_speedtest_init()
228 do_div(tmp, mtd->erasesize); mtd_speedtest_init()
230 pgcnt = mtd->erasesize / pgsize; mtd_speedtest_init()
235 (unsigned long long)mtd->size, mtd->erasesize, mtd_speedtest_init()
236 pgsize, ebcnt, pgcnt, mtd->oobsize); mtd_speedtest_init()
242 iobuf = kmalloc(mtd->erasesize, GFP_KERNEL); mtd_speedtest_init()
246 prandom_bytes(iobuf, mtd->erasesize); mtd_speedtest_init()
251 err = mtdtest_scan_for_bad_eraseblocks(mtd, bbt, 0, ebcnt); mtd_speedtest_init()
259 err = mtdtest_erase_good_eraseblocks(mtd, bbt, 0, ebcnt); mtd_speedtest_init()
299 err = mtdtest_erase_good_eraseblocks(mtd, bbt, 0, ebcnt); mtd_speedtest_init()
339 err = mtdtest_erase_good_eraseblocks(mtd, bbt, 0, ebcnt); mtd_speedtest_init()
382 err = mtdtest_erase_good_eraseblocks(mtd, bbt, 0, ebcnt); mtd_speedtest_init()
422 put_mtd_device(mtd); mtd_speedtest_init()
H A Doobtest.c29 #include <linux/mtd/mtd.h>
43 static struct mtd_info *mtd; variable in typeref:struct:mtd_info
73 loff_t addr = (loff_t)ebnum * mtd->erasesize; write_eraseblock()
76 for (i = 0; i < pgcnt; ++i, addr += mtd->writesize) { write_eraseblock()
85 err = mtd_write_oob(mtd, addr, &ops); write_eraseblock()
177 loff_t addr = (loff_t)ebnum * mtd->erasesize; verify_eraseblock()
181 for (i = 0; i < pgcnt; ++i, addr += mtd->writesize) { verify_eraseblock()
190 err = mtd_read_oob(mtd, addr, &ops); verify_eraseblock()
213 if (use_offset != 0 || use_len < mtd->ecclayout->oobavail) { verify_eraseblock()
219 ops.ooblen = mtd->ecclayout->oobavail; verify_eraseblock()
224 err = mtd_read_oob(mtd, addr, &ops); verify_eraseblock()
225 if (err || ops.oobretlen != mtd->ecclayout->oobavail) { verify_eraseblock()
241 mtd->ecclayout->oobavail - k); verify_eraseblock()
265 loff_t addr = (loff_t)ebnum * mtd->erasesize; verify_eraseblock_in_one_go()
266 size_t len = mtd->ecclayout->oobavail * pgcnt; verify_eraseblock_in_one_go()
267 size_t oobavail = mtd->ecclayout->oobavail; verify_eraseblock_in_one_go()
282 err = mtd_read_oob(mtd, addr, &ops); verify_eraseblock_in_one_go()
291 for (i = 0; i < pgcnt; ++i, addr += mtd->writesize) { verify_eraseblock_in_one_go()
345 pr_info("Please specify a valid mtd-device via module parameter\n"); mtd_oobtest_init()
352 mtd = get_mtd_device(NULL, dev); mtd_oobtest_init()
353 if (IS_ERR(mtd)) { mtd_oobtest_init()
354 err = PTR_ERR(mtd); mtd_oobtest_init()
359 if (!mtd_type_is_nand(mtd)) { mtd_oobtest_init()
364 tmp = mtd->size; mtd_oobtest_init()
365 do_div(tmp, mtd->erasesize); mtd_oobtest_init()
367 pgcnt = mtd->erasesize / mtd->writesize; mtd_oobtest_init()
372 (unsigned long long)mtd->size, mtd->erasesize, mtd_oobtest_init()
373 mtd->writesize, ebcnt, pgcnt, mtd->oobsize); mtd_oobtest_init()
376 readbuf = kmalloc(mtd->erasesize, GFP_KERNEL); mtd_oobtest_init()
379 writebuf = kmalloc(mtd->erasesize, GFP_KERNEL); mtd_oobtest_init()
386 err = mtdtest_scan_for_bad_eraseblocks(mtd, bbt, 0, ebcnt); mtd_oobtest_init()
391 use_len = mtd->ecclayout->oobavail; mtd_oobtest_init()
392 use_len_max = mtd->ecclayout->oobavail; mtd_oobtest_init()
398 err = mtdtest_erase_good_eraseblocks(mtd, bbt, 0, ebcnt); mtd_oobtest_init()
418 err = mtdtest_erase_good_eraseblocks(mtd, bbt, 0, ebcnt); mtd_oobtest_init()
451 err = mtdtest_erase_good_eraseblocks(mtd, bbt, 0, ebcnt); mtd_oobtest_init()
457 use_len = mtd->ecclayout->oobavail; mtd_oobtest_init()
458 use_len_max = mtd->ecclayout->oobavail; mtd_oobtest_init()
468 use_len = mtd->ecclayout->oobavail; mtd_oobtest_init()
469 use_len_max = mtd->ecclayout->oobavail; mtd_oobtest_init()
477 use_len = mtd->ecclayout->oobavail; mtd_oobtest_init()
478 use_len_max = mtd->ecclayout->oobavail; mtd_oobtest_init()
484 err = mtdtest_erase_good_eraseblocks(mtd, bbt, 0, ebcnt); mtd_oobtest_init()
490 addr0 += mtd->erasesize; mtd_oobtest_init()
498 ops.ooboffs = mtd->ecclayout->oobavail; mtd_oobtest_init()
503 err = mtd_write_oob(mtd, addr0, &ops); mtd_oobtest_init()
518 ops.ooboffs = mtd->ecclayout->oobavail; mtd_oobtest_init()
523 err = mtd_read_oob(mtd, addr0, &ops); mtd_oobtest_init()
540 ops.ooblen = mtd->ecclayout->oobavail + 1; mtd_oobtest_init()
547 err = mtd_write_oob(mtd, mtd->size - mtd->writesize, &ops); mtd_oobtest_init()
560 ops.ooblen = mtd->ecclayout->oobavail + 1; mtd_oobtest_init()
567 err = mtd_read_oob(mtd, mtd->size - mtd->writesize, &ops); mtd_oobtest_init()
576 err = mtdtest_erase_eraseblock(mtd, ebcnt - 1); mtd_oobtest_init()
584 ops.ooblen = mtd->ecclayout->oobavail; mtd_oobtest_init()
591 err = mtd_write_oob(mtd, mtd->size - mtd->writesize, &ops); mtd_oobtest_init()
604 ops.ooblen = mtd->ecclayout->oobavail; mtd_oobtest_init()
611 err = mtd_read_oob(mtd, mtd->size - mtd->writesize, &ops); mtd_oobtest_init()
625 err = mtdtest_erase_good_eraseblocks(mtd, bbt, 0, ebcnt); mtd_oobtest_init()
635 size_t sz = mtd->ecclayout->oobavail; mtd_oobtest_init()
638 addr = (loff_t)(i + 1) * mtd->erasesize - mtd->writesize; mtd_oobtest_init()
649 err = mtd_write_oob(mtd, addr, &ops); mtd_oobtest_init()
659 addr += mtd->writesize; mtd_oobtest_init()
671 mtd->ecclayout->oobavail * 2); mtd_oobtest_init()
672 addr = (loff_t)(i + 1) * mtd->erasesize - mtd->writesize; mtd_oobtest_init()
676 ops.ooblen = mtd->ecclayout->oobavail * 2; mtd_oobtest_init()
681 err = mtd_read_oob(mtd, addr, &ops); mtd_oobtest_init()
685 mtd->ecclayout->oobavail * 2)) { mtd_oobtest_init()
708 put_mtd_device(mtd); mtd_oobtest_init()
H A Dsubpagetest.c28 #include <linux/mtd/mtd.h>
39 static struct mtd_info *mtd; variable in typeref:struct:mtd_info
60 loff_t addr = (loff_t)ebnum * mtd->erasesize; write_eraseblock()
63 err = mtd_write(mtd, addr, subpgsize, &written, writebuf); write_eraseblock()
77 err = mtd_write(mtd, addr, subpgsize, &written, writebuf); write_eraseblock()
95 loff_t addr = (loff_t)ebnum * mtd->erasesize; write_eraseblock2()
98 if (addr + (subpgsize * k) > (loff_t)(ebnum + 1) * mtd->erasesize) write_eraseblock2()
101 err = mtd_write(mtd, addr, subpgsize * k, &written, writebuf); write_eraseblock2()
134 loff_t addr = (loff_t)ebnum * mtd->erasesize; verify_eraseblock()
138 err = mtd_read(mtd, addr, subpgsize, &read, readbuf); verify_eraseblock()
165 err = mtd_read(mtd, addr, subpgsize, &read, readbuf); verify_eraseblock()
195 loff_t addr = (loff_t)ebnum * mtd->erasesize; verify_eraseblock2()
198 if (addr + (subpgsize * k) > (loff_t)(ebnum + 1) * mtd->erasesize) verify_eraseblock2()
202 err = mtd_read(mtd, addr, subpgsize * k, &read, readbuf); verify_eraseblock2()
230 loff_t addr = (loff_t)ebnum * mtd->erasesize; verify_eraseblock_ff()
233 for (j = 0; j < mtd->erasesize / subpgsize; ++j) { verify_eraseblock_ff()
235 err = mtd_read(mtd, addr, subpgsize, &read, readbuf); verify_eraseblock_ff()
291 pr_info("Please specify a valid mtd-device via module parameter\n"); mtd_subpagetest_init()
298 mtd = get_mtd_device(NULL, dev); mtd_subpagetest_init()
299 if (IS_ERR(mtd)) { mtd_subpagetest_init()
300 err = PTR_ERR(mtd); mtd_subpagetest_init()
305 if (!mtd_type_is_nand(mtd)) { mtd_subpagetest_init()
310 subpgsize = mtd->writesize >> mtd->subpage_sft; mtd_subpagetest_init()
311 tmp = mtd->size; mtd_subpagetest_init()
312 do_div(tmp, mtd->erasesize); mtd_subpagetest_init()
314 pgcnt = mtd->erasesize / mtd->writesize; mtd_subpagetest_init()
319 (unsigned long long)mtd->size, mtd->erasesize, mtd_subpagetest_init()
320 mtd->writesize, subpgsize, ebcnt, pgcnt, mtd->oobsize); mtd_subpagetest_init()
334 err = mtdtest_scan_for_bad_eraseblocks(mtd, bbt, 0, ebcnt); mtd_subpagetest_init()
338 err = mtdtest_erase_good_eraseblocks(mtd, bbt, 0, ebcnt); mtd_subpagetest_init()
376 err = mtdtest_erase_good_eraseblocks(mtd, bbt, 0, ebcnt); mtd_subpagetest_init()
420 err = mtdtest_erase_good_eraseblocks(mtd, bbt, 0, ebcnt); mtd_subpagetest_init()
434 put_mtd_device(mtd); mtd_subpagetest_init()
H A Dnandbiterrs.c48 #include <linux/mtd/mtd.h>
50 #include <linux/mtd/nand.h>
80 static struct mtd_info *mtd; /* MTD device */ variable in typeref:struct:mtd_info
108 return mtdtest_write(mtd, offset, mtd->writesize, wbuffer); write_page()
121 ops.len = mtd->writesize; rewrite_page()
129 err = mtd_write_oob(mtd, offset, &ops); rewrite_page()
130 if (err || ops.retlen != mtd->writesize) { rewrite_page()
150 /* Saving last mtd stats */ read_page()
151 memcpy(&oldstats, &mtd->ecc_stats, sizeof(oldstats)); read_page()
153 err = mtd_read(mtd, offset, mtd->writesize, &read, rbuffer); read_page()
155 err = mtd->ecc_stats.corrected - oldstats.corrected; read_page()
157 if (err < 0 || read != mtd->writesize) { read_page()
174 for (i = 0; i < mtd->writesize; i++) { verify_page()
197 while (byte < mtd->writesize) { insert_biterror()
221 for (i = 0; i < mtd->writesize; i++) incremental_errors_test()
284 for (i = 0; i < mtd->writesize; i++) overwrite_test()
349 mtd = get_mtd_device(NULL, dev); mtd_nandbiterrs_init()
350 if (IS_ERR(mtd)) { mtd_nandbiterrs_init()
351 err = PTR_ERR(mtd); mtd_nandbiterrs_init()
356 if (!mtd_type_is_nand(mtd)) { mtd_nandbiterrs_init()
363 (unsigned long long)mtd->size, mtd->erasesize, mtd_nandbiterrs_init()
364 mtd->writesize, mtd->oobsize); mtd_nandbiterrs_init()
366 subsize = mtd->writesize >> mtd->subpage_sft; mtd_nandbiterrs_init()
367 subcount = mtd->writesize / subsize; mtd_nandbiterrs_init()
371 offset = (loff_t)page_offset * mtd->writesize; mtd_nandbiterrs_init()
372 eraseblock = mtd_div_by_eb(offset, mtd); mtd_nandbiterrs_init()
377 wbuffer = kmalloc(mtd->writesize, GFP_KERNEL); mtd_nandbiterrs_init()
383 rbuffer = kmalloc(mtd->writesize, GFP_KERNEL); mtd_nandbiterrs_init()
389 err = mtdtest_erase_eraseblock(mtd, eraseblock); mtd_nandbiterrs_init()
402 err = mtdtest_erase_eraseblock(mtd, eraseblock); mtd_nandbiterrs_init()
417 put_mtd_device(mtd); mtd_nandbiterrs_init()
H A Dtorturetest.c32 #include <linux/mtd/mtd.h>
68 static struct mtd_info *mtd; variable in typeref:struct:mtd_info
104 loff_t addr = (loff_t)ebnum * mtd->erasesize; check_eraseblock()
105 size_t len = mtd->erasesize; check_eraseblock()
108 addr = (loff_t)(ebnum + 1) * mtd->erasesize - pgcnt * pgsize; check_eraseblock()
113 err = mtd_read(mtd, addr, len, &read, check_buf); check_eraseblock()
158 loff_t addr = (loff_t)ebnum * mtd->erasesize; write_pattern()
159 size_t len = mtd->erasesize; write_pattern()
162 addr = (loff_t)(ebnum + 1) * mtd->erasesize - pgcnt * pgsize; write_pattern()
165 err = mtd_write(mtd, addr, len, &written, buf); write_pattern()
191 pr_info("Please specify a valid mtd-device via module parameter\n"); tort_init()
197 pr_info("torture %d eraseblocks (%d-%d) of mtd%d\n", tort_init()
204 mtd = get_mtd_device(NULL, dev); tort_init()
205 if (IS_ERR(mtd)) { tort_init()
206 err = PTR_ERR(mtd); tort_init()
211 if (mtd->writesize == 1) { tort_init()
216 pgsize = mtd->writesize; tort_init()
218 if (pgcnt && (pgcnt > mtd->erasesize / pgsize || pgcnt < 0)) { tort_init()
224 patt_5A5 = kmalloc(mtd->erasesize, GFP_KERNEL); tort_init()
228 patt_A5A = kmalloc(mtd->erasesize, GFP_KERNEL); tort_init()
232 patt_FF = kmalloc(mtd->erasesize, GFP_KERNEL); tort_init()
236 check_buf = kmalloc(mtd->erasesize, GFP_KERNEL); tort_init()
247 memset(patt_FF, 0xFF, mtd->erasesize); tort_init()
248 for (i = 0; i < mtd->erasesize / pgsize; i++) { tort_init()
258 err = mtdtest_scan_for_bad_eraseblocks(mtd, bad_ebs, eb, ebcnt); tort_init()
267 err = mtdtest_erase_good_eraseblocks(mtd, bad_ebs, eb, ebcnt); tort_init()
361 put_mtd_device(mtd); tort_init()
390 size_t check_len = mtd->erasesize; report_corrupt()
419 (mtd->erasesize - check_len + i) / pgsize, report_corrupt()
/linux-4.1.27/drivers/mtd/devices/
H A Dmtdram.c2 * mtdram - a test mtd device
17 #include <linux/mtd/mtd.h>
18 #include <linux/mtd/mtdram.h>
32 // We could store these in the mtd structure, but we only support 1 device..
35 static int ram_erase(struct mtd_info *mtd, struct erase_info *instr) ram_erase() argument
37 memset((char *)mtd->priv + instr->addr, 0xff, instr->len); ram_erase()
43 static int ram_point(struct mtd_info *mtd, loff_t from, size_t len, ram_point() argument
46 *virt = mtd->priv + from; ram_point()
51 static int ram_unpoint(struct mtd_info *mtd, loff_t from, size_t len) ram_unpoint() argument
61 static unsigned long ram_get_unmapped_area(struct mtd_info *mtd, ram_get_unmapped_area() argument
66 return (unsigned long) mtd->priv + offset; ram_get_unmapped_area()
69 static int ram_read(struct mtd_info *mtd, loff_t from, size_t len, ram_read() argument
72 memcpy(buf, mtd->priv + from, len); ram_read()
77 static int ram_write(struct mtd_info *mtd, loff_t to, size_t len, ram_write() argument
80 memcpy((char *)mtd->priv + to, buf, len); ram_write()
94 int mtdram_init_device(struct mtd_info *mtd, void *mapped_address, mtdram_init_device() argument
97 memset(mtd, 0, sizeof(*mtd)); mtdram_init_device()
100 mtd->name = name; mtdram_init_device()
101 mtd->type = MTD_RAM; mtdram_init_device()
102 mtd->flags = MTD_CAP_RAM; mtdram_init_device()
103 mtd->size = size; mtdram_init_device()
104 mtd->writesize = 1; mtdram_init_device()
105 mtd->writebufsize = 64; /* Mimic CFI NOR flashes */ mtdram_init_device()
106 mtd->erasesize = MTDRAM_ERASE_SIZE; mtdram_init_device()
107 mtd->priv = mapped_address; mtdram_init_device()
109 mtd->owner = THIS_MODULE; mtdram_init_device()
110 mtd->_erase = ram_erase; mtdram_init_device()
111 mtd->_point = ram_point; mtdram_init_device()
112 mtd->_unpoint = ram_unpoint; mtdram_init_device()
113 mtd->_get_unmapped_area = ram_get_unmapped_area; mtdram_init_device()
114 mtd->_read = ram_read; mtdram_init_device()
115 mtd->_write = ram_write; mtdram_init_device()
117 if (mtd_device_register(mtd, NULL, 0)) mtdram_init_device()
H A Dsst25l.c25 #include <linux/mtd/mtd.h>
26 #include <linux/mtd/partitions.h>
53 struct mtd_info mtd; member in struct:sst25l_flash
64 #define to_sst25l_flash(x) container_of(x, struct sst25l_flash, mtd)
170 static int sst25l_erase(struct mtd_info *mtd, struct erase_info *instr) sst25l_erase() argument
172 struct sst25l_flash *flash = to_sst25l_flash(mtd); sst25l_erase()
177 if ((uint32_t)instr->len % mtd->erasesize) sst25l_erase()
180 if ((uint32_t)instr->addr % mtd->erasesize) sst25l_erase()
203 addr += mtd->erasesize; sst25l_erase()
213 static int sst25l_read(struct mtd_info *mtd, loff_t from, size_t len, sst25l_read() argument
216 struct sst25l_flash *flash = to_sst25l_flash(mtd); sst25l_read()
256 static int sst25l_write(struct mtd_info *mtd, loff_t to, size_t len, sst25l_write() argument
259 struct sst25l_flash *flash = to_sst25l_flash(mtd); sst25l_write()
263 if ((uint32_t)to % mtd->writesize) sst25l_write()
272 for (i = 0; i < len; i += mtd->writesize) { sst25l_write()
292 bytes = min_t(uint32_t, mtd->writesize, len - i); sst25l_write()
376 flash->mtd.name = data->name; sst25l_probe()
378 flash->mtd.name = dev_name(&spi->dev); sst25l_probe()
380 flash->mtd.type = MTD_NORFLASH; sst25l_probe()
381 flash->mtd.flags = MTD_CAP_NORFLASH; sst25l_probe()
382 flash->mtd.erasesize = flash_info->erase_size; sst25l_probe()
383 flash->mtd.writesize = flash_info->page_size; sst25l_probe()
384 flash->mtd.writebufsize = flash_info->page_size; sst25l_probe()
385 flash->mtd.size = flash_info->page_size * flash_info->nr_pages; sst25l_probe()
386 flash->mtd._erase = sst25l_erase; sst25l_probe()
387 flash->mtd._read = sst25l_read; sst25l_probe()
388 flash->mtd._write = sst25l_write; sst25l_probe()
391 (long long)flash->mtd.size >> 10); sst25l_probe()
393 pr_debug("mtd .name = %s, .size = 0x%llx (%lldMiB) " sst25l_probe()
395 flash->mtd.name, sst25l_probe()
396 (long long)flash->mtd.size, (long long)(flash->mtd.size >> 20), sst25l_probe()
397 flash->mtd.erasesize, flash->mtd.erasesize / 1024, sst25l_probe()
398 flash->mtd.numeraseregions); sst25l_probe()
401 ret = mtd_device_parse_register(&flash->mtd, NULL, NULL, sst25l_probe()
414 return mtd_device_unregister(&flash->mtd); sst25l_remove()
H A Dbcm47xxsflash.c5 #include <linux/mtd/mtd.h>
67 static int bcm47xxsflash_erase(struct mtd_info *mtd, struct erase_info *erase) bcm47xxsflash_erase() argument
69 struct bcm47xxsflash *b47s = mtd->priv; bcm47xxsflash_erase()
103 static int bcm47xxsflash_read(struct mtd_info *mtd, loff_t from, size_t len, bcm47xxsflash_read() argument
106 struct bcm47xxsflash *b47s = mtd->priv; bcm47xxsflash_read()
109 if ((from + len) > mtd->size) bcm47xxsflash_read()
119 static int bcm47xxsflash_write_st(struct mtd_info *mtd, u32 offset, size_t len, bcm47xxsflash_write_st() argument
122 struct bcm47xxsflash *b47s = mtd->priv; bcm47xxsflash_write_st()
164 static int bcm47xxsflash_write_at(struct mtd_info *mtd, u32 offset, size_t len, bcm47xxsflash_write_at() argument
167 struct bcm47xxsflash *b47s = mtd->priv; bcm47xxsflash_write_at()
207 static int bcm47xxsflash_write(struct mtd_info *mtd, loff_t to, size_t len, bcm47xxsflash_write() argument
210 struct bcm47xxsflash *b47s = mtd->priv; bcm47xxsflash_write()
219 written = bcm47xxsflash_write_st(mtd, to, len, buf); bcm47xxsflash_write()
222 written = bcm47xxsflash_write_at(mtd, to, len, buf); bcm47xxsflash_write()
242 struct mtd_info *mtd = &b47s->mtd; bcm47xxsflash_fill_mtd() local
244 mtd->priv = b47s; bcm47xxsflash_fill_mtd()
245 mtd->name = "bcm47xxsflash"; bcm47xxsflash_fill_mtd()
246 mtd->owner = THIS_MODULE; bcm47xxsflash_fill_mtd()
248 mtd->type = MTD_NORFLASH; bcm47xxsflash_fill_mtd()
249 mtd->flags = MTD_CAP_NORFLASH; bcm47xxsflash_fill_mtd()
250 mtd->size = b47s->size; bcm47xxsflash_fill_mtd()
251 mtd->erasesize = b47s->blocksize; bcm47xxsflash_fill_mtd()
252 mtd->writesize = 1; bcm47xxsflash_fill_mtd()
253 mtd->writebufsize = 1; bcm47xxsflash_fill_mtd()
255 mtd->_erase = bcm47xxsflash_erase; bcm47xxsflash_fill_mtd()
256 mtd->_read = bcm47xxsflash_read; bcm47xxsflash_fill_mtd()
257 mtd->_write = bcm47xxsflash_write; bcm47xxsflash_fill_mtd()
305 err = mtd_device_parse_register(&b47s->mtd, probes, NULL, NULL, 0); bcm47xxsflash_bcma_probe()
322 mtd_device_unregister(&b47s->mtd); bcm47xxsflash_bcma_remove()
H A Dphram.c27 #include <linux/mtd/mtd.h>
30 struct mtd_info mtd; member in struct:phram_mtd_list
36 static int phram_erase(struct mtd_info *mtd, struct erase_info *instr) phram_erase() argument
38 u_char *start = mtd->priv; phram_erase()
52 static int phram_point(struct mtd_info *mtd, loff_t from, size_t len, phram_point() argument
55 *virt = mtd->priv + from; phram_point()
60 static int phram_unpoint(struct mtd_info *mtd, loff_t from, size_t len) phram_unpoint() argument
65 static int phram_read(struct mtd_info *mtd, loff_t from, size_t len, phram_read() argument
68 u_char *start = mtd->priv; phram_read()
75 static int phram_write(struct mtd_info *mtd, loff_t to, size_t len, phram_write() argument
78 u_char *start = mtd->priv; phram_write()
90 mtd_device_unregister(&this->mtd); unregister_devices()
91 iounmap(this->mtd.priv); unregister_devices()
92 kfree(this->mtd.name); unregister_devices()
107 new->mtd.priv = ioremap(start, len); register_device()
108 if (!new->mtd.priv) { register_device()
114 new->mtd.name = name; register_device()
115 new->mtd.size = len; register_device()
116 new->mtd.flags = MTD_CAP_RAM; register_device()
117 new->mtd._erase = phram_erase; register_device()
118 new->mtd._point = phram_point; register_device()
119 new->mtd._unpoint = phram_unpoint; register_device()
120 new->mtd._read = phram_read; register_device()
121 new->mtd._write = phram_write; register_device()
122 new->mtd.owner = THIS_MODULE; register_device()
123 new->mtd.type = MTD_RAM; register_device()
124 new->mtd.erasesize = PAGE_SIZE; register_device()
125 new->mtd.writesize = 1; register_device()
128 if (mtd_device_register(&new->mtd, NULL, 0)) { register_device()
137 iounmap(new->mtd.priv); register_device()
H A Dlart.c20 * - http://www.linux-mtd.infradead.org/
43 #include <linux/mtd/mtd.h>
44 #include <linux/mtd/partitions.h>
361 static int flash_erase (struct mtd_info *mtd,struct erase_info *instr) flash_erase() argument
379 for (i = 0; i < mtd->numeraseregions && instr->addr >= mtd->eraseregions[i].offset; i++) ; flash_erase()
388 if (i < 0 || (instr->addr & (mtd->eraseregions[i].erasesize - 1))) flash_erase()
401 for (; i < mtd->numeraseregions && instr->addr + instr->len >= mtd->eraseregions[i].offset; i++) ; flash_erase()
405 if (i < 0 || ((instr->addr + instr->len) & (mtd->eraseregions[i].erasesize - 1))) flash_erase()
422 addr += mtd->eraseregions[i].erasesize; flash_erase()
423 len -= mtd->eraseregions[i].erasesize; flash_erase()
425 if (addr == mtd->eraseregions[i].offset + (mtd->eraseregions[i].erasesize * mtd->eraseregions[i].numblocks)) i++; flash_erase()
434 static int flash_read (struct mtd_info *mtd,loff_t from,size_t len,size_t *retlen,u_char *buf) flash_read() argument
509 static int flash_write (struct mtd_info *mtd,loff_t to,size_t len,size_t *retlen,const u_char *buf) flash_write() argument
569 static struct mtd_info mtd; variable in typeref:struct:mtd_info
611 memset (&mtd,0,sizeof (mtd)); lart_flash_init()
620 mtd.name = module_name; lart_flash_init()
621 mtd.type = MTD_NORFLASH; lart_flash_init()
622 mtd.writesize = 1; lart_flash_init()
623 mtd.writebufsize = 4; lart_flash_init()
624 mtd.flags = MTD_CAP_NORFLASH; lart_flash_init()
625 mtd.size = FLASH_BLOCKSIZE_PARAM * FLASH_NUMBLOCKS_16m_PARAM + FLASH_BLOCKSIZE_MAIN * FLASH_NUMBLOCKS_16m_MAIN; lart_flash_init()
626 mtd.erasesize = FLASH_BLOCKSIZE_MAIN; lart_flash_init()
627 mtd.numeraseregions = ARRAY_SIZE(erase_regions); lart_flash_init()
628 mtd.eraseregions = erase_regions; lart_flash_init()
629 mtd._erase = flash_erase; lart_flash_init()
630 mtd._read = flash_read; lart_flash_init()
631 mtd._write = flash_write; lart_flash_init()
632 mtd.owner = THIS_MODULE; lart_flash_init()
636 "mtd.name = %s\n" lart_flash_init()
637 "mtd.size = 0x%.8x (%uM)\n" lart_flash_init()
638 "mtd.erasesize = 0x%.8x (%uK)\n" lart_flash_init()
639 "mtd.numeraseregions = %d\n", lart_flash_init()
640 mtd.name, lart_flash_init()
641 mtd.size,mtd.size / (1024*1024), lart_flash_init()
642 mtd.erasesize,mtd.erasesize / 1024, lart_flash_init()
643 mtd.numeraseregions); lart_flash_init()
645 if (mtd.numeraseregions) lart_flash_init()
646 for (result = 0; result < mtd.numeraseregions; result++) lart_flash_init()
649 "mtd.eraseregions[%d].offset = 0x%.8x\n" lart_flash_init()
650 "mtd.eraseregions[%d].erasesize = 0x%.8x (%uK)\n" lart_flash_init()
651 "mtd.eraseregions[%d].numblocks = %d\n", lart_flash_init()
652 result,mtd.eraseregions[result].offset, lart_flash_init()
653 result,mtd.eraseregions[result].erasesize,mtd.eraseregions[result].erasesize / 1024, lart_flash_init()
654 result,mtd.eraseregions[result].numblocks); lart_flash_init()
669 result = mtd_device_register(&mtd, lart_partitions, lart_flash_init()
677 mtd_device_unregister(&mtd); lart_flash_exit()
H A Dblock2mtd.c2 * block2mtd.c - create an mtd from a block device
27 #include <linux/mtd/mtd.h>
37 struct mtd_info mtd; member in struct:block2mtd_dev
83 static int block2mtd_erase(struct mtd_info *mtd, struct erase_info *instr) block2mtd_erase() argument
85 struct block2mtd_dev *dev = mtd->priv; block2mtd_erase()
105 static int block2mtd_read(struct mtd_info *mtd, loff_t from, size_t len, block2mtd_read() argument
108 struct block2mtd_dev *dev = mtd->priv; block2mtd_read()
179 static int block2mtd_write(struct mtd_info *mtd, loff_t to, size_t len, block2mtd_write() argument
182 struct block2mtd_dev *dev = mtd->priv; block2mtd_write()
195 static void block2mtd_sync(struct mtd_info *mtd) block2mtd_sync() argument
197 struct block2mtd_dev *dev = mtd->priv; block2mtd_sync()
208 kfree(dev->mtd.name); block2mtd_free_device()
289 dev->mtd.name = name; add_device()
291 dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK; add_device()
292 dev->mtd.erasesize = erase_size; add_device()
293 dev->mtd.writesize = 1; add_device()
294 dev->mtd.writebufsize = PAGE_SIZE; add_device()
295 dev->mtd.type = MTD_RAM; add_device()
296 dev->mtd.flags = MTD_CAP_RAM; add_device()
297 dev->mtd._erase = block2mtd_erase; add_device()
298 dev->mtd._write = block2mtd_write; add_device()
299 dev->mtd._sync = block2mtd_sync; add_device()
300 dev->mtd._read = block2mtd_read; add_device()
301 dev->mtd.priv = dev; add_device()
302 dev->mtd.owner = THIS_MODULE; add_device()
304 if (mtd_device_register(&dev->mtd, NULL, 0)) { add_device()
310 pr_info("mtd%d: [%s] erase_size = %dKiB [%d]\n", add_device()
311 dev->mtd.index, add_device()
312 dev->mtd.name + strlen("block2mtd: "), add_device()
313 dev->mtd.erasesize >> 10, dev->mtd.erasesize); add_device()
484 block2mtd_sync(&dev->mtd); block2mtd_exit()
485 mtd_device_unregister(&dev->mtd); block2mtd_exit()
487 pr_info("mtd%d: [%s] removed\n", block2mtd_exit()
488 dev->mtd.index, block2mtd_exit()
489 dev->mtd.name + strlen("block2mtd: ")); block2mtd_exit()
H A Dms02-nv.c14 #include <linux/mtd/mtd.h>
57 static int ms02nv_read(struct mtd_info *mtd, loff_t from, ms02nv_read() argument
60 struct ms02nv_private *mp = mtd->priv; ms02nv_read()
67 static int ms02nv_write(struct mtd_info *mtd, loff_t to, ms02nv_write() argument
70 struct ms02nv_private *mp = mtd->priv; ms02nv_write()
110 struct mtd_info *mtd; ms02nv_init_one() local
145 mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); ms02nv_init_one()
146 if (!mtd) ms02nv_init_one()
152 mtd->priv = mp; ms02nv_init_one()
205 mtd->type = MTD_RAM; ms02nv_init_one()
206 mtd->flags = MTD_CAP_RAM; ms02nv_init_one()
207 mtd->size = fixsize; ms02nv_init_one()
208 mtd->name = ms02nv_name; ms02nv_init_one()
209 mtd->owner = THIS_MODULE; ms02nv_init_one()
210 mtd->_read = ms02nv_read; ms02nv_init_one()
211 mtd->_write = ms02nv_write; ms02nv_init_one()
212 mtd->writesize = 1; ms02nv_init_one()
215 if (mtd_device_register(mtd, NULL, 0)) { ms02nv_init_one()
221 printk(KERN_INFO "mtd%d: %s at 0x%08lx, size %zuMiB.\n", ms02nv_init_one()
222 mtd->index, ms02nv_name, addr, size >> 20); ms02nv_init_one()
225 root_ms02nv_mtd = mtd; ms02nv_init_one()
242 kfree(mtd); ms02nv_init_one()
252 struct mtd_info *mtd = root_ms02nv_mtd; ms02nv_remove_one() local
253 struct ms02nv_private *mp = mtd->priv; ms02nv_remove_one()
257 mtd_device_unregister(mtd); ms02nv_remove_one()
268 kfree(mtd); ms02nv_remove_one()
H A Dpmc551.c97 #include <linux/mtd/mtd.h>
136 static int pmc551_point(struct mtd_info *mtd, loff_t from, size_t len,
139 static int pmc551_erase(struct mtd_info *mtd, struct erase_info *instr) pmc551_erase() argument
141 struct mypriv *priv = mtd->priv; pmc551_erase()
159 pmc551_point(mtd, instr->addr, instr->len, &retlen, pmc551_erase()
162 if (soff_hi == eoff_hi || mtd->size == priv->asize) { pmc551_erase()
175 if (soff_hi + priv->asize >= mtd->size) { pmc551_erase()
179 pmc551_point(mtd, (priv->base_map0 | soff_hi), pmc551_erase()
196 static int pmc551_point(struct mtd_info *mtd, loff_t from, size_t len, pmc551_point() argument
199 struct mypriv *priv = mtd->priv; pmc551_point()
222 static int pmc551_unpoint(struct mtd_info *mtd, loff_t from, size_t len) pmc551_unpoint() argument
230 static int pmc551_read(struct mtd_info *mtd, loff_t from, size_t len, pmc551_read() argument
233 struct mypriv *priv = mtd->priv; pmc551_read()
251 pmc551_point(mtd, from, len, retlen, (void **)&ptr, NULL); pmc551_read()
268 if (soff_hi + priv->asize >= mtd->size) { pmc551_read()
272 pmc551_point(mtd, soff_hi, priv->asize, retlen, pmc551_read()
287 static int pmc551_write(struct mtd_info *mtd, loff_t to, size_t len, pmc551_write() argument
290 struct mypriv *priv = mtd->priv; pmc551_write()
308 pmc551_point(mtd, to, len, retlen, (void **)&ptr, NULL); pmc551_write()
325 if (soff_hi >= mtd->size) { pmc551_write()
329 pmc551_point(mtd, soff_hi, priv->asize, retlen, pmc551_write()
665 struct mtd_info *mtd; init_pmc551() local
727 mtd = kzalloc(sizeof(struct mtd_info), GFP_KERNEL); init_pmc551()
728 if (!mtd) init_pmc551()
733 kfree(mtd); init_pmc551()
736 mtd->priv = priv; init_pmc551()
756 kfree(mtd->priv); init_pmc551()
757 kfree(mtd); init_pmc551()
777 mtd->size = msize; init_pmc551()
778 mtd->flags = MTD_CAP_RAM; init_pmc551()
779 mtd->_erase = pmc551_erase; init_pmc551()
780 mtd->_read = pmc551_read; init_pmc551()
781 mtd->_write = pmc551_write; init_pmc551()
782 mtd->_point = pmc551_point; init_pmc551()
783 mtd->_unpoint = pmc551_unpoint; init_pmc551()
784 mtd->type = MTD_RAM; init_pmc551()
785 mtd->name = "PMC551 RAM board"; init_pmc551()
786 mtd->erasesize = 0x10000; init_pmc551()
787 mtd->writesize = 1; init_pmc551()
788 mtd->owner = THIS_MODULE; init_pmc551()
790 if (mtd_device_register(mtd, NULL, 0)) { init_pmc551()
793 kfree(mtd->priv); init_pmc551()
794 kfree(mtd); init_pmc551()
810 pmc551list = mtd; init_pmc551()
832 struct mtd_info *mtd; cleanup_pmc551() local
835 while ((mtd = pmc551list)) { cleanup_pmc551()
836 priv = mtd->priv; cleanup_pmc551()
846 kfree(mtd->priv); cleanup_pmc551()
847 mtd_device_unregister(mtd); cleanup_pmc551()
848 kfree(mtd); cleanup_pmc551()
H A Dbcm47xxsflash.h4 #include <linux/mtd/mtd.h>
73 struct mtd_info mtd; member in struct:bcm47xxsflash
H A Dslram.c15 <name>: name of the device that will be listed in /proc/mtd
46 #include <linux/mtd/mtd.h>
82 static int slram_erase(struct mtd_info *mtd, struct erase_info *instr) slram_erase() argument
84 slram_priv_t *priv = mtd->priv; slram_erase()
96 static int slram_point(struct mtd_info *mtd, loff_t from, size_t len, slram_point() argument
99 slram_priv_t *priv = mtd->priv; slram_point()
106 static int slram_unpoint(struct mtd_info *mtd, loff_t from, size_t len) slram_unpoint() argument
111 static int slram_read(struct mtd_info *mtd, loff_t from, size_t len, slram_read() argument
114 slram_priv_t *priv = mtd->priv; slram_read()
121 static int slram_write(struct mtd_info *mtd, loff_t to, size_t len, slram_write() argument
124 slram_priv_t *priv = mtd->priv; slram_write()
H A Ddocg3.c31 #include <linux/mtd/mtd.h>
32 #include <linux/mtd/partitions.h>
848 * @mtd: the device
851 * @ops: the mtd oob structure
857 static int doc_read_oob(struct mtd_info *mtd, loff_t from, doc_read_oob() argument
860 struct docg3 *docg3 = mtd->priv; doc_read_oob()
885 if (from + len > mtd->size) doc_read_oob()
942 mtd->ecc_stats.failed++; doc_read_oob()
946 mtd->ecc_stats.corrected += ret; doc_read_oob()
973 * @mtd: the device
985 static int doc_read(struct mtd_info *mtd, loff_t from, size_t len, doc_read() argument
996 ret = doc_read_oob(mtd, from, &ops); doc_read()
1025 * @mtd: the device
1030 static int doc_block_isbad(struct mtd_info *mtd, loff_t from) doc_block_isbad() argument
1032 struct docg3 *docg3 = mtd->priv; doc_block_isbad()
1192 * @mtd: the device
1195 * Erase a bunch of contiguous blocks, by pairs, as a "mtd" page of 1024 is
1201 static int doc_erase(struct mtd_info *mtd, struct erase_info *info) doc_erase() argument
1203 struct docg3 *docg3 = mtd->priv; doc_erase()
1213 if (info->addr + info->len > mtd->size || page || ofs) doc_erase()
1222 for (len = info->len; !ret && len > 0; len -= mtd->erasesize) { doc_erase()
1398 * @mtd: the device
1401 * @ops: the mtd oob structure
1411 static int doc_write_oob(struct mtd_info *mtd, loff_t ofs, doc_write_oob() argument
1414 struct docg3 *docg3 = mtd->priv; doc_write_oob()
1438 oobdelta = mtd->oobsize; doc_write_oob()
1441 oobdelta = mtd->ecclayout->oobavail; doc_write_oob()
1452 if (ofs + len > mtd->size) doc_write_oob()
1496 * @mtd: the device
1507 static int doc_write(struct mtd_info *mtd, loff_t to, size_t len, doc_write() argument
1510 struct docg3 *docg3 = mtd->priv; doc_write()
1522 ret = doc_write_oob(mtd, to, &ops); doc_write()
1816 * @mtd: The structure to fill
1818 static void __init doc_set_driver_info(int chip_id, struct mtd_info *mtd) doc_set_driver_info() argument
1820 struct docg3 *docg3 = mtd->priv; doc_set_driver_info()
1829 mtd->name = kasprintf(GFP_KERNEL, "docg3.%d", doc_set_driver_info()
1834 mtd->type = MTD_NANDFLASH; doc_set_driver_info()
1835 mtd->flags = MTD_CAP_NANDFLASH; doc_set_driver_info()
1836 mtd->size = (docg3->max_block + 1) * DOC_LAYOUT_BLOCK_SIZE; doc_set_driver_info()
1838 mtd->size /= 2; doc_set_driver_info()
1839 mtd->erasesize = DOC_LAYOUT_BLOCK_SIZE * DOC_LAYOUT_NBPLANES; doc_set_driver_info()
1841 mtd->erasesize /= 2; doc_set_driver_info()
1842 mtd->writebufsize = mtd->writesize = DOC_LAYOUT_PAGE_SIZE; doc_set_driver_info()
1843 mtd->oobsize = DOC_LAYOUT_OOB_SIZE; doc_set_driver_info()
1844 mtd->owner = THIS_MODULE; doc_set_driver_info()
1845 mtd->_erase = doc_erase; doc_set_driver_info()
1846 mtd->_read = doc_read; doc_set_driver_info()
1847 mtd->_write = doc_write; doc_set_driver_info()
1848 mtd->_read_oob = doc_read_oob; doc_set_driver_info()
1849 mtd->_write_oob = doc_write_oob; doc_set_driver_info()
1850 mtd->_block_isbad = doc_block_isbad; doc_set_driver_info()
1851 mtd->ecclayout = &docg3_oobinfo; doc_set_driver_info()
1852 mtd->ecc_strength = DOC_ECC_BCH_T; doc_set_driver_info()
1874 struct mtd_info *mtd; doc_probe_device() local
1880 mtd = kzalloc(sizeof(struct mtd_info), GFP_KERNEL); doc_probe_device()
1881 if (!mtd) doc_probe_device()
1883 mtd->priv = docg3; doc_probe_device()
1916 doc_set_driver_info(chip_id, mtd); doc_probe_device()
1920 return mtd; doc_probe_device()
1923 kfree(mtd); doc_probe_device()
1932 * @mtd: the device
1934 static void doc_release_device(struct mtd_info *mtd) doc_release_device() argument
1936 struct docg3 *docg3 = mtd->priv; doc_release_device()
1938 mtd_device_unregister(mtd); doc_release_device()
1941 kfree(mtd->name); doc_release_device()
1942 kfree(mtd); doc_release_device()
1955 struct mtd_info **docg3_floors, *mtd; docg3_resume() local
1960 mtd = docg3_floors[0]; docg3_resume()
1961 docg3 = mtd->priv; docg3_resume()
1982 struct mtd_info **docg3_floors, *mtd; docg3_suspend() local
1989 mtd = docg3_floors[floor]; docg3_suspend()
1990 if (!mtd) docg3_suspend()
1992 docg3 = mtd->priv; docg3_suspend()
2015 mtd = docg3_floors[0]; docg3_suspend()
2016 docg3 = mtd->priv; docg3_suspend()
2033 struct mtd_info *mtd; docg3_probe() local
2060 mtd = doc_probe_device(cascade, floor, dev); docg3_probe()
2061 if (IS_ERR(mtd)) { docg3_probe()
2062 ret = PTR_ERR(mtd); docg3_probe()
2065 if (!mtd) { docg3_probe()
2071 cascade->floors[floor] = mtd; docg3_probe()
2072 ret = mtd_device_parse_register(mtd, part_probes, NULL, NULL, docg3_probe()
H A Dspear_smi.c4 * The serial nor interface is largely based on drivers/mtd/m25p80.c,
30 #include <linux/mtd/mtd.h>
31 #include <linux/mtd/partitions.h>
32 #include <linux/mtd/spear_smi.h>
187 * @mtd: MTD info for each NOR-flash.
199 struct mtd_info mtd; member in struct:spear_snor_flash
208 static inline struct spear_snor_flash *get_flash_data(struct mtd_info *mtd) get_flash_data() argument
210 return container_of(mtd, struct spear_snor_flash, mtd); get_flash_data()
488 * @mtd: Provides the memory characteristics
494 static int spear_mtd_erase(struct mtd_info *mtd, struct erase_info *e_info) spear_mtd_erase() argument
496 struct spear_snor_flash *flash = get_flash_data(mtd); spear_mtd_erase()
497 struct spear_smi *dev = mtd->priv; spear_mtd_erase()
525 addr += mtd->erasesize; spear_mtd_erase()
526 len -= mtd->erasesize; spear_mtd_erase()
538 * @mtd: MTD information of the memory bank
548 static int spear_mtd_read(struct mtd_info *mtd, loff_t from, size_t len, spear_mtd_read() argument
551 struct spear_snor_flash *flash = get_flash_data(mtd); spear_mtd_read()
552 struct spear_smi *dev = mtd->priv; spear_mtd_read()
630 * @mtd: MTD information of the memory bank.
641 static int spear_mtd_write(struct mtd_info *mtd, loff_t to, size_t len, spear_mtd_write() argument
644 struct spear_snor_flash *flash = get_flash_data(mtd); spear_mtd_write()
645 struct spear_smi *dev = mtd->priv; spear_mtd_write()
850 flash->mtd.priv = dev; spear_smi_setup_banks()
853 flash->mtd.name = flash_info->name; spear_smi_setup_banks()
855 flash->mtd.name = flash_devices[flash_index].name; spear_smi_setup_banks()
857 flash->mtd.type = MTD_NORFLASH; spear_smi_setup_banks()
858 flash->mtd.writesize = 1; spear_smi_setup_banks()
859 flash->mtd.flags = MTD_CAP_NORFLASH; spear_smi_setup_banks()
860 flash->mtd.size = flash_info->size; spear_smi_setup_banks()
861 flash->mtd.erasesize = flash_devices[flash_index].sectorsize; spear_smi_setup_banks()
863 flash->mtd.writebufsize = flash->page_size; spear_smi_setup_banks()
865 flash->mtd._erase = spear_mtd_erase; spear_smi_setup_banks()
866 flash->mtd._read = spear_mtd_read; spear_smi_setup_banks()
867 flash->mtd._write = spear_mtd_write; spear_smi_setup_banks()
870 dev_info(&dev->pdev->dev, "mtd .name=%s .size=%llx(%lluM)\n", spear_smi_setup_banks()
871 flash->mtd.name, flash->mtd.size, spear_smi_setup_banks()
872 flash->mtd.size / (1024 * 1024)); spear_smi_setup_banks()
875 flash->mtd.erasesize, flash->mtd.erasesize / 1024); spear_smi_setup_banks()
885 ret = mtd_device_parse_register(&flash->mtd, NULL, &ppdata, parts, spear_smi_setup_banks()
1032 /* clean up mtd stuff */ spear_smi_remove()
1033 ret = mtd_device_unregister(&flash->mtd); spear_smi_remove()
1035 dev_err(&pdev->dev, "error removing mtd\n"); spear_smi_remove()
/linux-4.1.27/drivers/mtd/chips/
H A Dmap_ram.c14 #include <linux/mtd/mtd.h>
15 #include <linux/mtd/map.h>
35 struct mtd_info *mtd; map_ram_probe() local
58 mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); map_ram_probe()
59 if (!mtd) map_ram_probe()
63 mtd->priv = map; map_ram_probe()
64 mtd->name = map->name; map_ram_probe()
65 mtd->type = MTD_RAM; map_ram_probe()
66 mtd->size = map->size; map_ram_probe()
67 mtd->_erase = mapram_erase; map_ram_probe()
68 mtd->_get_unmapped_area = mapram_unmapped_area; map_ram_probe()
69 mtd->_read = mapram_read; map_ram_probe()
70 mtd->_write = mapram_write; map_ram_probe()
71 mtd->_panic_write = mapram_write; map_ram_probe()
72 mtd->_sync = mapram_nop; map_ram_probe()
73 mtd->flags = MTD_CAP_RAM; map_ram_probe()
74 mtd->writesize = 1; map_ram_probe()
76 mtd->erasesize = PAGE_SIZE; map_ram_probe()
77 while(mtd->size & (mtd->erasesize - 1)) map_ram_probe()
78 mtd->erasesize >>= 1; map_ram_probe()
81 return mtd; map_ram_probe()
90 static unsigned long mapram_unmapped_area(struct mtd_info *mtd, mapram_unmapped_area() argument
95 struct map_info *map = mtd->priv; mapram_unmapped_area()
99 static int mapram_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) mapram_read() argument
101 struct map_info *map = mtd->priv; mapram_read()
108 static int mapram_write (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf) mapram_write() argument
110 struct map_info *map = mtd->priv; mapram_write()
117 static int mapram_erase (struct mtd_info *mtd, struct erase_info *instr) mapram_erase() argument
121 struct map_info *map = mtd->priv; mapram_erase()
133 static void mapram_nop(struct mtd_info *mtd) mapram_nop() argument
H A Dmap_absent.c26 #include <linux/mtd/mtd.h>
27 #include <linux/mtd/map.h>
46 struct mtd_info *mtd; map_absent_probe() local
48 mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); map_absent_probe()
49 if (!mtd) { map_absent_probe()
54 mtd->priv = map; map_absent_probe()
55 mtd->name = map->name; map_absent_probe()
56 mtd->type = MTD_ABSENT; map_absent_probe()
57 mtd->size = map->size; map_absent_probe()
58 mtd->_erase = map_absent_erase; map_absent_probe()
59 mtd->_read = map_absent_read; map_absent_probe()
60 mtd->_write = map_absent_write; map_absent_probe()
61 mtd->_sync = map_absent_sync; map_absent_probe()
62 mtd->flags = 0; map_absent_probe()
63 mtd->erasesize = PAGE_SIZE; map_absent_probe()
64 mtd->writesize = 1; map_absent_probe()
67 return mtd; map_absent_probe()
71 static int map_absent_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) map_absent_read() argument
76 static int map_absent_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf) map_absent_write() argument
81 static int map_absent_erase(struct mtd_info *mtd, struct erase_info *instr) map_absent_erase() argument
86 static void map_absent_sync(struct mtd_info *mtd) map_absent_sync() argument
91 static void map_absent_destroy(struct mtd_info *mtd) map_absent_destroy() argument
H A Dmap_rom.c15 #include <linux/mtd/mtd.h>
16 #include <linux/mtd/map.h>
22 static int maprom_erase (struct mtd_info *mtd, struct erase_info *info);
43 struct mtd_info *mtd; map_rom_probe() local
45 mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); map_rom_probe()
46 if (!mtd) map_rom_probe()
50 mtd->priv = map; map_rom_probe()
51 mtd->name = map->name; map_rom_probe()
52 mtd->type = MTD_ROM; map_rom_probe()
53 mtd->size = map->size; map_rom_probe()
54 mtd->_get_unmapped_area = maprom_unmapped_area; map_rom_probe()
55 mtd->_read = maprom_read; map_rom_probe()
56 mtd->_write = maprom_write; map_rom_probe()
57 mtd->_sync = maprom_nop; map_rom_probe()
58 mtd->_erase = maprom_erase; map_rom_probe()
59 mtd->flags = MTD_CAP_ROM; map_rom_probe()
60 mtd->erasesize = default_erasesize(map); map_rom_probe()
61 mtd->writesize = 1; map_rom_probe()
62 mtd->writebufsize = 1; map_rom_probe()
65 return mtd; map_rom_probe()
74 static unsigned long maprom_unmapped_area(struct mtd_info *mtd, maprom_unmapped_area() argument
79 struct map_info *map = mtd->priv; maprom_unmapped_area()
83 static int maprom_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) maprom_read() argument
85 struct map_info *map = mtd->priv; maprom_read()
92 static void maprom_nop(struct mtd_info *mtd) maprom_nop() argument
97 static int maprom_write (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf) maprom_write() argument
102 static int maprom_erase (struct mtd_info *mtd, struct erase_info *info) maprom_erase() argument
H A Dchipreg.c11 #include <linux/mtd/map.h>
12 #include <linux/mtd/mtd.h>
85 void map_destroy(struct mtd_info *mtd) map_destroy() argument
87 struct map_info *map = mtd->priv; map_destroy()
90 map->fldrv->destroy(mtd); map_destroy()
94 kfree(mtd); map_destroy()
H A Dgen_probe.c10 #include <linux/mtd/mtd.h>
11 #include <linux/mtd/map.h>
12 #include <linux/mtd/cfi.h>
13 #include <linux/mtd/gen_probe.h>
23 struct mtd_info *mtd = NULL; mtd_do_chip_probe() local
35 mtd = check_cmd_set(map, 1); /* First the primary cmdset */ mtd_do_chip_probe()
36 if (!mtd) mtd_do_chip_probe()
37 mtd = check_cmd_set(map, 0); /* Then the secondary */ mtd_do_chip_probe()
39 if (mtd) { mtd_do_chip_probe()
40 if (mtd->size > map->size) { mtd_do_chip_probe()
42 (unsigned long)mtd->size >> 10, mtd_do_chip_probe()
44 mtd->size = map->size; mtd_do_chip_probe()
46 return mtd; mtd_do_chip_probe()
217 struct mtd_info *mtd; cfi_cmdset_unknown() local
219 mtd = (*probe_function)(map, primary); cfi_cmdset_unknown()
222 return mtd; cfi_cmdset_unknown()
H A Dcfi_cmdset_0001.c12 * (see include/linux/mtd/cfi.h for selection)
33 #include <linux/mtd/xip.h>
34 #include <linux/mtd/map.h>
35 #include <linux/mtd/mtd.h>
36 #include <linux/mtd/cfi.h>
67 static int cfi_intelext_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
68 static int cfi_intelext_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
69 static int cfi_intelext_is_locked(struct mtd_info *mtd, loff_t ofs,
92 static int cfi_intelext_point (struct mtd_info *mtd, loff_t from, size_t len,
94 static int cfi_intelext_unpoint(struct mtd_info *mtd, loff_t from, size_t len);
169 static void fixup_convert_atmel_pri(struct mtd_info *mtd) fixup_convert_atmel_pri() argument
171 struct map_info *map = mtd->priv; fixup_convert_atmel_pri()
209 static void fixup_at49bv640dx_lock(struct mtd_info *mtd) fixup_at49bv640dx_lock() argument
211 struct map_info *map = mtd->priv; fixup_at49bv640dx_lock()
216 mtd->flags |= MTD_POWERUP_LOCK; fixup_at49bv640dx_lock()
221 static void fixup_intel_strataflash(struct mtd_info *mtd) fixup_intel_strataflash() argument
223 struct map_info *map = mtd->priv; fixup_intel_strataflash()
234 static void fixup_no_write_suspend(struct mtd_info *mtd) fixup_no_write_suspend() argument
236 struct map_info *map = mtd->priv; fixup_no_write_suspend()
247 static void fixup_st_m28w320ct(struct mtd_info *mtd) fixup_st_m28w320ct() argument
249 struct map_info *map = mtd->priv; fixup_st_m28w320ct()
256 static void fixup_st_m28w320cb(struct mtd_info *mtd) fixup_st_m28w320cb() argument
258 struct map_info *map = mtd->priv; fixup_st_m28w320cb()
276 static void fixup_LH28F640BF(struct mtd_info *mtd) fixup_LH28F640BF() argument
278 struct map_info *map = mtd->priv; fixup_LH28F640BF()
296 static void fixup_use_point(struct mtd_info *mtd) fixup_use_point() argument
298 struct map_info *map = mtd->priv; fixup_use_point()
299 if (!mtd->_point && map_is_linear(map)) { fixup_use_point()
300 mtd->_point = cfi_intelext_point; fixup_use_point()
301 mtd->_unpoint = cfi_intelext_unpoint; fixup_use_point()
305 static void fixup_use_write_buffers(struct mtd_info *mtd) fixup_use_write_buffers() argument
307 struct map_info *map = mtd->priv; fixup_use_write_buffers()
311 mtd->_write = cfi_intelext_write_buffers; fixup_use_write_buffers()
312 mtd->_writev = cfi_intelext_writev; fixup_use_write_buffers()
319 static void fixup_unlock_powerup_lock(struct mtd_info *mtd) fixup_unlock_powerup_lock() argument
321 struct map_info *map = mtd->priv; fixup_unlock_powerup_lock()
327 mtd->flags |= MTD_POWERUP_LOCK; fixup_unlock_powerup_lock()
470 struct mtd_info *mtd; cfi_cmdset_0001() local
473 mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); cfi_cmdset_0001()
474 if (!mtd) cfi_cmdset_0001()
476 mtd->priv = map; cfi_cmdset_0001()
477 mtd->type = MTD_NORFLASH; cfi_cmdset_0001()
479 /* Fill in the default mtd operations */ cfi_cmdset_0001()
480 mtd->_erase = cfi_intelext_erase_varsize; cfi_cmdset_0001()
481 mtd->_read = cfi_intelext_read; cfi_cmdset_0001()
482 mtd->_write = cfi_intelext_write_words; cfi_cmdset_0001()
483 mtd->_sync = cfi_intelext_sync; cfi_cmdset_0001()
484 mtd->_lock = cfi_intelext_lock; cfi_cmdset_0001()
485 mtd->_unlock = cfi_intelext_unlock; cfi_cmdset_0001()
486 mtd->_is_locked = cfi_intelext_is_locked; cfi_cmdset_0001()
487 mtd->_suspend = cfi_intelext_suspend; cfi_cmdset_0001()
488 mtd->_resume = cfi_intelext_resume; cfi_cmdset_0001()
489 mtd->flags = MTD_CAP_NORFLASH; cfi_cmdset_0001()
490 mtd->name = map->name; cfi_cmdset_0001()
491 mtd->writesize = 1; cfi_cmdset_0001()
492 mtd->writebufsize = cfi_interleave(cfi) << cfi->cfiq->MaxBufWriteSize; cfi_cmdset_0001()
494 mtd->reboot_notifier.notifier_call = cfi_intelext_reboot; cfi_cmdset_0001()
507 kfree(mtd); cfi_cmdset_0001()
514 cfi_fixup(mtd, cfi_fixup_table); cfi_cmdset_0001()
527 cfi_fixup(mtd, jedec_fixup_table); cfi_cmdset_0001()
530 cfi_fixup(mtd, fixup_table); cfi_cmdset_0001()
578 return cfi_intelext_setup(mtd); cfi_cmdset_0001()
586 static struct mtd_info *cfi_intelext_setup(struct mtd_info *mtd) cfi_intelext_setup() argument
588 struct map_info *map = mtd->priv; cfi_intelext_setup()
596 mtd->size = devsize * cfi->numchips; cfi_intelext_setup()
598 mtd->numeraseregions = cfi->cfiq->NumEraseRegions * cfi->numchips; cfi_intelext_setup()
599 mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info) cfi_intelext_setup()
600 * mtd->numeraseregions, GFP_KERNEL); cfi_intelext_setup()
601 if (!mtd->eraseregions) cfi_intelext_setup()
609 if (mtd->erasesize < ersize) { cfi_intelext_setup()
610 mtd->erasesize = ersize; cfi_intelext_setup()
613 mtd->eraseregions[(j*cfi->cfiq->NumEraseRegions)+i].offset = (j*devsize)+offset; cfi_intelext_setup()
614 mtd->eraseregions[(j*cfi->cfiq->NumEraseRegions)+i].erasesize = ersize; cfi_intelext_setup()
615 mtd->eraseregions[(j*cfi->cfiq->NumEraseRegions)+i].numblocks = ernum; cfi_intelext_setup()
616 mtd->eraseregions[(j*cfi->cfiq->NumEraseRegions)+i].lockmap = kmalloc(ernum / 8 + 1, GFP_KERNEL); cfi_intelext_setup()
627 for (i=0; i<mtd->numeraseregions;i++){ cfi_intelext_setup()
629 i,(unsigned long long)mtd->eraseregions[i].offset, cfi_intelext_setup()
630 mtd->eraseregions[i].erasesize, cfi_intelext_setup()
631 mtd->eraseregions[i].numblocks); cfi_intelext_setup()
635 mtd->_read_fact_prot_reg = cfi_intelext_read_fact_prot_reg; cfi_intelext_setup()
636 mtd->_read_user_prot_reg = cfi_intelext_read_user_prot_reg; cfi_intelext_setup()
637 mtd->_write_user_prot_reg = cfi_intelext_write_user_prot_reg; cfi_intelext_setup()
638 mtd->_lock_user_prot_reg = cfi_intelext_lock_user_prot_reg; cfi_intelext_setup()
639 mtd->_get_fact_prot_info = cfi_intelext_get_fact_prot_info; cfi_intelext_setup()
640 mtd->_get_user_prot_info = cfi_intelext_get_user_prot_info; cfi_intelext_setup()
645 if (cfi_intelext_partition_fixup(mtd, &cfi) != 0) cfi_intelext_setup()
649 register_reboot_notifier(&mtd->reboot_notifier); cfi_intelext_setup()
650 return mtd; cfi_intelext_setup()
653 kfree(mtd->eraseregions); cfi_intelext_setup()
654 kfree(mtd); cfi_intelext_setup()
659 static int cfi_intelext_partition_fixup(struct mtd_info *mtd, cfi_intelext_partition_fixup() argument
662 struct map_info *map = mtd->priv; cfi_intelext_partition_fixup()
717 mtd->writesize = cfi->interleave << prinfo->ProgRegShift; cfi_intelext_partition_fixup()
718 mtd->flags &= ~MTD_BIT_WRITEABLE; cfi_intelext_partition_fixup()
720 map->name, mtd->writesize, cfi_intelext_partition_fixup()
732 if ((1 << partshift) < mtd->erasesize) { cfi_intelext_partition_fixup()
1348 static int cfi_intelext_point(struct mtd_info *mtd, loff_t from, size_t len, cfi_intelext_point() argument
1351 struct map_info *map = mtd->priv; cfi_intelext_point()
1401 static int cfi_intelext_unpoint(struct mtd_info *mtd, loff_t from, size_t len) cfi_intelext_unpoint() argument
1403 struct map_info *map = mtd->priv; cfi_intelext_unpoint()
1480 static int cfi_intelext_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) cfi_intelext_read() argument
1482 struct map_info *map = mtd->priv; cfi_intelext_read()
1592 static int cfi_intelext_write_words (struct mtd_info *mtd, loff_t to , size_t len, size_t *retlen, const u_char *buf) cfi_intelext_write_words() argument
1594 struct map_info *map = mtd->priv; cfi_intelext_write_words()
1837 static int cfi_intelext_writev (struct mtd_info *mtd, const struct kvec *vecs, cfi_intelext_writev() argument
1840 struct map_info *map = mtd->priv; cfi_intelext_writev()
1889 static int cfi_intelext_write_buffers (struct mtd_info *mtd, loff_t to, cfi_intelext_write_buffers() argument
1897 return cfi_intelext_writev(mtd, &vec, 1, to, retlen); cfi_intelext_write_buffers()
1988 static int cfi_intelext_erase_varsize(struct mtd_info *mtd, struct erase_info *instr) cfi_intelext_erase_varsize() argument
1996 ret = cfi_varsize_frob(mtd, do_erase_oneblock, ofs, len, NULL); cfi_intelext_erase_varsize()
2006 static void cfi_intelext_sync (struct mtd_info *mtd) cfi_intelext_sync() argument
2008 struct map_info *map = mtd->priv; cfi_intelext_sync()
2139 static int cfi_intelext_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) cfi_intelext_lock() argument
2146 cfi_varsize_frob(mtd, do_printlockstatus_oneblock, cfi_intelext_lock()
2150 ret = cfi_varsize_frob(mtd, do_xxlock_oneblock, cfi_intelext_lock()
2156 cfi_varsize_frob(mtd, do_printlockstatus_oneblock, cfi_intelext_lock()
2163 static int cfi_intelext_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) cfi_intelext_unlock() argument
2170 cfi_varsize_frob(mtd, do_printlockstatus_oneblock, cfi_intelext_unlock()
2174 ret = cfi_varsize_frob(mtd, do_xxlock_oneblock, cfi_intelext_unlock()
2180 cfi_varsize_frob(mtd, do_printlockstatus_oneblock, cfi_intelext_unlock()
2187 static int cfi_intelext_is_locked(struct mtd_info *mtd, loff_t ofs, cfi_intelext_is_locked() argument
2190 return cfi_varsize_frob(mtd, do_getlockstatus_oneblock, cfi_intelext_is_locked()
2274 static int cfi_intelext_otp_walk(struct mtd_info *mtd, loff_t from, size_t len, cfi_intelext_otp_walk() argument
2278 struct map_info *map = mtd->priv; cfi_intelext_otp_walk()
2408 static int cfi_intelext_read_fact_prot_reg(struct mtd_info *mtd, loff_t from, cfi_intelext_read_fact_prot_reg() argument
2412 return cfi_intelext_otp_walk(mtd, from, len, retlen, cfi_intelext_read_fact_prot_reg()
2416 static int cfi_intelext_read_user_prot_reg(struct mtd_info *mtd, loff_t from, cfi_intelext_read_user_prot_reg() argument
2420 return cfi_intelext_otp_walk(mtd, from, len, retlen, cfi_intelext_read_user_prot_reg()
2424 static int cfi_intelext_write_user_prot_reg(struct mtd_info *mtd, loff_t from, cfi_intelext_write_user_prot_reg() argument
2428 return cfi_intelext_otp_walk(mtd, from, len, retlen, cfi_intelext_write_user_prot_reg()
2432 static int cfi_intelext_lock_user_prot_reg(struct mtd_info *mtd, cfi_intelext_lock_user_prot_reg() argument
2436 return cfi_intelext_otp_walk(mtd, from, len, &retlen, cfi_intelext_lock_user_prot_reg()
2440 static int cfi_intelext_get_fact_prot_info(struct mtd_info *mtd, size_t len, cfi_intelext_get_fact_prot_info() argument
2444 return cfi_intelext_otp_walk(mtd, 0, len, retlen, (u_char *)buf, cfi_intelext_get_fact_prot_info()
2448 static int cfi_intelext_get_user_prot_info(struct mtd_info *mtd, size_t len, cfi_intelext_get_user_prot_info() argument
2451 return cfi_intelext_otp_walk(mtd, 0, len, retlen, (u_char *)buf, cfi_intelext_get_user_prot_info()
2457 static void cfi_intelext_save_locks(struct mtd_info *mtd) cfi_intelext_save_locks() argument
2464 for (i = 0; i < mtd->numeraseregions; i++) { cfi_intelext_save_locks()
2465 region = &mtd->eraseregions[i]; cfi_intelext_save_locks()
2473 status = cfi_varsize_frob(mtd, cfi_intelext_save_locks()
2483 static int cfi_intelext_suspend(struct mtd_info *mtd) cfi_intelext_suspend() argument
2485 struct map_info *map = mtd->priv; cfi_intelext_suspend()
2492 if ((mtd->flags & MTD_POWERUP_LOCK) cfi_intelext_suspend()
2494 cfi_intelext_save_locks(mtd); cfi_intelext_suspend()
2557 static void cfi_intelext_restore_locks(struct mtd_info *mtd) cfi_intelext_restore_locks() argument
2564 for (i = 0; i < mtd->numeraseregions; i++) { cfi_intelext_restore_locks()
2565 region = &mtd->eraseregions[i]; cfi_intelext_restore_locks()
2572 cfi_intelext_unlock(mtd, adr, len); cfi_intelext_restore_locks()
2577 static void cfi_intelext_resume(struct mtd_info *mtd) cfi_intelext_resume() argument
2579 struct map_info *map = mtd->priv; cfi_intelext_resume()
2594 fixup_LH28F640BF(mtd); cfi_intelext_resume()
2603 if ((mtd->flags & MTD_POWERUP_LOCK) cfi_intelext_resume()
2605 cfi_intelext_restore_locks(mtd); cfi_intelext_resume()
2608 static int cfi_intelext_reset(struct mtd_info *mtd) cfi_intelext_reset() argument
2610 struct map_info *map = mtd->priv; cfi_intelext_reset()
2636 struct mtd_info *mtd; cfi_intelext_reboot() local
2638 mtd = container_of(nb, struct mtd_info, reboot_notifier); cfi_intelext_reboot()
2639 cfi_intelext_reset(mtd); cfi_intelext_reboot()
2643 static void cfi_intelext_destroy(struct mtd_info *mtd) cfi_intelext_destroy() argument
2645 struct map_info *map = mtd->priv; cfi_intelext_destroy()
2649 cfi_intelext_reset(mtd); cfi_intelext_destroy()
2650 unregister_reboot_notifier(&mtd->reboot_notifier); cfi_intelext_destroy()
2655 for (i = 0; i < mtd->numeraseregions; i++) { cfi_intelext_destroy()
2656 region = &mtd->eraseregions[i]; cfi_intelext_destroy()
2659 kfree(mtd->eraseregions); cfi_intelext_destroy()
H A Dfwh_lock.h79 static int fwh_lock_varsize(struct mtd_info *mtd, loff_t ofs, uint64_t len) fwh_lock_varsize() argument
83 ret = cfi_varsize_frob(mtd, fwh_xxlock_oneblock, ofs, len, fwh_lock_varsize()
90 static int fwh_unlock_varsize(struct mtd_info *mtd, loff_t ofs, uint64_t len) fwh_unlock_varsize() argument
94 ret = cfi_varsize_frob(mtd, fwh_xxlock_oneblock, ofs, len, fwh_unlock_varsize()
100 static void fixup_use_fwh_lock(struct mtd_info *mtd) fixup_use_fwh_lock() argument
104 mtd->_lock = fwh_lock_varsize; fixup_use_fwh_lock()
105 mtd->_unlock = fwh_unlock_varsize; fixup_use_fwh_lock()
H A Dcfi_cmdset_0002.c37 #include <linux/mtd/map.h>
38 #include <linux/mtd/mtd.h>
39 #include <linux/mtd/cfi.h>
40 #include <linux/mtd/xip.h>
74 static int cfi_amdstd_panic_write(struct mtd_info *mtd, loff_t to, size_t len,
86 static int cfi_atmel_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
87 static int cfi_atmel_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
89 static int cfi_ppb_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
90 static int cfi_ppb_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
91 static int cfi_ppb_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len);
156 static void fixup_amd_bootblock(struct mtd_info *mtd) fixup_amd_bootblock() argument
158 struct map_info *map = mtd->priv; fixup_amd_bootblock()
205 static void fixup_use_write_buffers(struct mtd_info *mtd) fixup_use_write_buffers() argument
207 struct map_info *map = mtd->priv; fixup_use_write_buffers()
211 mtd->_write = cfi_amdstd_write_buffers; fixup_use_write_buffers()
216 static void fixup_convert_atmel_pri(struct mtd_info *mtd) fixup_convert_atmel_pri() argument
218 struct map_info *map = mtd->priv; fixup_convert_atmel_pri()
247 static void fixup_use_secsi(struct mtd_info *mtd) fixup_use_secsi() argument
250 mtd->_read_user_prot_reg = cfi_amdstd_secsi_read; fixup_use_secsi()
251 mtd->_read_fact_prot_reg = cfi_amdstd_secsi_read; fixup_use_secsi()
254 static void fixup_use_erase_chip(struct mtd_info *mtd) fixup_use_erase_chip() argument
256 struct map_info *map = mtd->priv; fixup_use_erase_chip()
260 mtd->_erase = cfi_amdstd_erase_chip; fixup_use_erase_chip()
269 static void fixup_use_atmel_lock(struct mtd_info *mtd) fixup_use_atmel_lock() argument
271 mtd->_lock = cfi_atmel_lock; fixup_use_atmel_lock()
272 mtd->_unlock = cfi_atmel_unlock; fixup_use_atmel_lock()
273 mtd->flags |= MTD_POWERUP_LOCK; fixup_use_atmel_lock()
276 static void fixup_old_sst_eraseregion(struct mtd_info *mtd) fixup_old_sst_eraseregion() argument
278 struct map_info *map = mtd->priv; fixup_old_sst_eraseregion()
290 static void fixup_sst39vf(struct mtd_info *mtd) fixup_sst39vf() argument
292 struct map_info *map = mtd->priv; fixup_sst39vf()
295 fixup_old_sst_eraseregion(mtd); fixup_sst39vf()
301 static void fixup_sst39vf_rev_b(struct mtd_info *mtd) fixup_sst39vf_rev_b() argument
303 struct map_info *map = mtd->priv; fixup_sst39vf_rev_b()
306 fixup_old_sst_eraseregion(mtd); fixup_sst39vf_rev_b()
314 static void fixup_sst38vf640x_sectorsize(struct mtd_info *mtd) fixup_sst38vf640x_sectorsize() argument
316 struct map_info *map = mtd->priv; fixup_sst38vf640x_sectorsize()
319 fixup_sst39vf_rev_b(mtd); fixup_sst38vf640x_sectorsize()
326 pr_warning("%s: Bad 38VF640x CFI data; adjusting sector size from 64 to 8KiB\n", mtd->name); fixup_sst38vf640x_sectorsize()
329 static void fixup_s29gl064n_sectors(struct mtd_info *mtd) fixup_s29gl064n_sectors() argument
331 struct map_info *map = mtd->priv; fixup_s29gl064n_sectors()
336 pr_warning("%s: Bad S29GL064N CFI data; adjust from 64 to 128 sectors\n", mtd->name); fixup_s29gl064n_sectors()
340 static void fixup_s29gl032n_sectors(struct mtd_info *mtd) fixup_s29gl032n_sectors() argument
342 struct map_info *map = mtd->priv; fixup_s29gl032n_sectors()
347 pr_warning("%s: Bad S29GL032N CFI data; adjust from 127 to 63 sectors\n", mtd->name); fixup_s29gl032n_sectors()
351 static void fixup_s29ns512p_sectors(struct mtd_info *mtd) fixup_s29ns512p_sectors() argument
353 struct map_info *map = mtd->priv; fixup_s29ns512p_sectors()
361 pr_warning("%s: Bad S29NS512P CFI data; adjust to 512 sectors\n", mtd->name); fixup_s29ns512p_sectors()
516 struct mtd_info *mtd; cfi_cmdset_0002() local
519 mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); cfi_cmdset_0002()
520 if (!mtd) cfi_cmdset_0002()
522 mtd->priv = map; cfi_cmdset_0002()
523 mtd->type = MTD_NORFLASH; cfi_cmdset_0002()
525 /* Fill in the default mtd operations */ cfi_cmdset_0002()
526 mtd->_erase = cfi_amdstd_erase_varsize; cfi_cmdset_0002()
527 mtd->_write = cfi_amdstd_write_words; cfi_cmdset_0002()
528 mtd->_read = cfi_amdstd_read; cfi_cmdset_0002()
529 mtd->_sync = cfi_amdstd_sync; cfi_cmdset_0002()
530 mtd->_suspend = cfi_amdstd_suspend; cfi_cmdset_0002()
531 mtd->_resume = cfi_amdstd_resume; cfi_cmdset_0002()
532 mtd->_read_user_prot_reg = cfi_amdstd_read_user_prot_reg; cfi_cmdset_0002()
533 mtd->_read_fact_prot_reg = cfi_amdstd_read_fact_prot_reg; cfi_cmdset_0002()
534 mtd->_get_fact_prot_info = cfi_amdstd_get_fact_prot_info; cfi_cmdset_0002()
535 mtd->_get_user_prot_info = cfi_amdstd_get_user_prot_info; cfi_cmdset_0002()
536 mtd->_write_user_prot_reg = cfi_amdstd_write_user_prot_reg; cfi_cmdset_0002()
537 mtd->_lock_user_prot_reg = cfi_amdstd_lock_user_prot_reg; cfi_cmdset_0002()
538 mtd->flags = MTD_CAP_NORFLASH; cfi_cmdset_0002()
539 mtd->name = map->name; cfi_cmdset_0002()
540 mtd->writesize = 1; cfi_cmdset_0002()
541 mtd->writebufsize = cfi_interleave(cfi) << cfi->cfiq->MaxBufWriteSize; cfi_cmdset_0002()
544 mtd->writebufsize); cfi_cmdset_0002()
546 mtd->_panic_write = cfi_amdstd_panic_write; cfi_cmdset_0002()
547 mtd->reboot_notifier.notifier_call = cfi_amdstd_reboot; cfi_cmdset_0002()
576 kfree(mtd); cfi_cmdset_0002()
587 cfi_fixup(mtd, cfi_fixup_table); cfi_cmdset_0002()
599 mtd->_lock = cfi_ppb_lock; cfi_cmdset_0002()
600 mtd->_unlock = cfi_ppb_unlock; cfi_cmdset_0002()
601 mtd->_is_locked = cfi_ppb_is_locked; cfi_cmdset_0002()
629 cfi_fixup(mtd, cfi_nopri_fixup_table); cfi_cmdset_0002()
632 kfree(mtd); cfi_cmdset_0002()
639 cfi_fixup(mtd, jedec_fixup_table); cfi_cmdset_0002()
642 cfi_fixup(mtd, fixup_table); cfi_cmdset_0002()
671 return cfi_amdstd_setup(mtd); cfi_cmdset_0002()
679 static struct mtd_info *cfi_amdstd_setup(struct mtd_info *mtd) cfi_amdstd_setup() argument
681 struct map_info *map = mtd->priv; cfi_amdstd_setup()
690 mtd->size = devsize * cfi->numchips; cfi_amdstd_setup()
692 mtd->numeraseregions = cfi->cfiq->NumEraseRegions * cfi->numchips; cfi_amdstd_setup()
693 mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info) cfi_amdstd_setup()
694 * mtd->numeraseregions, GFP_KERNEL); cfi_amdstd_setup()
695 if (!mtd->eraseregions) cfi_amdstd_setup()
703 if (mtd->erasesize < ersize) { cfi_amdstd_setup()
704 mtd->erasesize = ersize; cfi_amdstd_setup()
707 mtd->eraseregions[(j*cfi->cfiq->NumEraseRegions)+i].offset = (j*devsize)+offset; cfi_amdstd_setup()
708 mtd->eraseregions[(j*cfi->cfiq->NumEraseRegions)+i].erasesize = ersize; cfi_amdstd_setup()
709 mtd->eraseregions[(j*cfi->cfiq->NumEraseRegions)+i].numblocks = ernum; cfi_amdstd_setup()
720 register_reboot_notifier(&mtd->reboot_notifier); cfi_amdstd_setup()
721 return mtd; cfi_amdstd_setup()
724 kfree(mtd->eraseregions); cfi_amdstd_setup()
725 kfree(mtd); cfi_amdstd_setup()
1137 static int cfi_amdstd_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) cfi_amdstd_read() argument
1139 struct map_info *map = mtd->priv; cfi_amdstd_read()
1247 static int cfi_amdstd_secsi_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) cfi_amdstd_secsi_read() argument
1249 struct map_info *map = mtd->priv; cfi_amdstd_secsi_read()
1384 static int cfi_amdstd_otp_walk(struct mtd_info *mtd, loff_t from, size_t len, cfi_amdstd_otp_walk() argument
1388 struct map_info *map = mtd->priv; cfi_amdstd_otp_walk()
1502 static int cfi_amdstd_get_fact_prot_info(struct mtd_info *mtd, size_t len, cfi_amdstd_get_fact_prot_info() argument
1505 return cfi_amdstd_otp_walk(mtd, 0, len, retlen, (u_char *)buf, cfi_amdstd_get_fact_prot_info()
1509 static int cfi_amdstd_get_user_prot_info(struct mtd_info *mtd, size_t len, cfi_amdstd_get_user_prot_info() argument
1512 return cfi_amdstd_otp_walk(mtd, 0, len, retlen, (u_char *)buf, cfi_amdstd_get_user_prot_info()
1516 static int cfi_amdstd_read_fact_prot_reg(struct mtd_info *mtd, loff_t from, cfi_amdstd_read_fact_prot_reg() argument
1520 return cfi_amdstd_otp_walk(mtd, from, len, retlen, cfi_amdstd_read_fact_prot_reg()
1524 static int cfi_amdstd_read_user_prot_reg(struct mtd_info *mtd, loff_t from, cfi_amdstd_read_user_prot_reg() argument
1528 return cfi_amdstd_otp_walk(mtd, from, len, retlen, cfi_amdstd_read_user_prot_reg()
1532 static int cfi_amdstd_write_user_prot_reg(struct mtd_info *mtd, loff_t from, cfi_amdstd_write_user_prot_reg() argument
1536 return cfi_amdstd_otp_walk(mtd, from, len, retlen, buf, cfi_amdstd_write_user_prot_reg()
1540 static int cfi_amdstd_lock_user_prot_reg(struct mtd_info *mtd, loff_t from, cfi_amdstd_lock_user_prot_reg() argument
1544 return cfi_amdstd_otp_walk(mtd, from, len, &retlen, NULL, cfi_amdstd_lock_user_prot_reg()
1665 static int cfi_amdstd_write_words(struct mtd_info *mtd, loff_t to, size_t len, cfi_amdstd_write_words() argument
1668 struct map_info *map = mtd->priv; cfi_amdstd_write_words()
1920 static int cfi_amdstd_write_buffers(struct mtd_info *mtd, loff_t to, size_t len, cfi_amdstd_write_buffers() argument
1923 struct map_info *map = mtd->priv; cfi_amdstd_write_buffers()
1938 ret = cfi_amdstd_write_words(mtd, ofs + (chipnum<<cfi->chipshift), cfi_amdstd_write_buffers()
1985 ret = cfi_amdstd_write_words(mtd, ofs + (chipnum<<cfi->chipshift), cfi_amdstd_write_buffers()
2130 static int cfi_amdstd_panic_write(struct mtd_info *mtd, loff_t to, size_t len, cfi_amdstd_panic_write() argument
2133 struct map_info *map = mtd->priv; cfi_amdstd_panic_write()
2414 static int cfi_amdstd_erase_varsize(struct mtd_info *mtd, struct erase_info *instr) cfi_amdstd_erase_varsize() argument
2422 ret = cfi_varsize_frob(mtd, do_erase_oneblock, ofs, len, NULL); cfi_amdstd_erase_varsize()
2433 static int cfi_amdstd_erase_chip(struct mtd_info *mtd, struct erase_info *instr) cfi_amdstd_erase_chip() argument
2435 struct map_info *map = mtd->priv; cfi_amdstd_erase_chip()
2442 if (instr->len != mtd->size) cfi_amdstd_erase_chip()
2517 static int cfi_atmel_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) cfi_atmel_lock() argument
2519 return cfi_varsize_frob(mtd, do_atmel_lock, ofs, len, NULL); cfi_atmel_lock()
2522 static int cfi_atmel_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) cfi_atmel_unlock() argument
2524 return cfi_varsize_frob(mtd, do_atmel_unlock, ofs, len, NULL); cfi_atmel_unlock()
2615 static int __maybe_unused cfi_ppb_lock(struct mtd_info *mtd, loff_t ofs, cfi_ppb_lock() argument
2618 return cfi_varsize_frob(mtd, do_ppb_xxlock, ofs, len, cfi_ppb_lock()
2622 static int __maybe_unused cfi_ppb_unlock(struct mtd_info *mtd, loff_t ofs, cfi_ppb_unlock() argument
2625 struct mtd_erase_region_info *regions = mtd->eraseregions; cfi_ppb_unlock()
2626 struct map_info *map = mtd->priv; cfi_ppb_unlock()
2656 length = mtd->size; cfi_ppb_unlock()
2699 ret = cfi_varsize_frob(mtd, do_ppb_xxlock, ofs, len, cfi_ppb_unlock()
2720 static int __maybe_unused cfi_ppb_is_locked(struct mtd_info *mtd, loff_t ofs, cfi_ppb_is_locked() argument
2723 return cfi_varsize_frob(mtd, do_ppb_xxlock, ofs, len, cfi_ppb_is_locked()
2727 static void cfi_amdstd_sync (struct mtd_info *mtd) cfi_amdstd_sync() argument
2729 struct map_info *map = mtd->priv; cfi_amdstd_sync()
2788 static int cfi_amdstd_suspend(struct mtd_info *mtd) cfi_amdstd_suspend() argument
2790 struct map_info *map = mtd->priv; cfi_amdstd_suspend()
2842 static void cfi_amdstd_resume(struct mtd_info *mtd) cfi_amdstd_resume() argument
2844 struct map_info *map = mtd->priv; cfi_amdstd_resume()
2874 static int cfi_amdstd_reset(struct mtd_info *mtd) cfi_amdstd_reset() argument
2876 struct map_info *map = mtd->priv; cfi_amdstd_reset()
2904 struct mtd_info *mtd; cfi_amdstd_reboot() local
2906 mtd = container_of(nb, struct mtd_info, reboot_notifier); cfi_amdstd_reboot()
2907 cfi_amdstd_reset(mtd); cfi_amdstd_reboot()
2912 static void cfi_amdstd_destroy(struct mtd_info *mtd) cfi_amdstd_destroy() argument
2914 struct map_info *map = mtd->priv; cfi_amdstd_destroy()
2917 cfi_amdstd_reset(mtd); cfi_amdstd_destroy()
2918 unregister_reboot_notifier(&mtd->reboot_notifier); cfi_amdstd_destroy()
2922 kfree(mtd->eraseregions); cfi_amdstd_destroy()
H A Dcfi_cmdset_0020.c11 * (see include/linux/mtd/cfi.h for selection)
32 #include <linux/mtd/map.h>
33 #include <linux/mtd/cfi.h>
34 #include <linux/mtd/mtd.h>
39 static int cfi_staa_writev(struct mtd_info *mtd, const struct kvec *vecs,
43 static int cfi_staa_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
44 static int cfi_staa_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
106 /* This routine is made available to other mtd code via
169 struct mtd_info *mtd; cfi_staa_setup() local
174 mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); cfi_staa_setup()
177 if (!mtd) { cfi_staa_setup()
182 mtd->priv = map; cfi_staa_setup()
183 mtd->type = MTD_NORFLASH; cfi_staa_setup()
184 mtd->size = devsize * cfi->numchips; cfi_staa_setup()
186 mtd->numeraseregions = cfi->cfiq->NumEraseRegions * cfi->numchips; cfi_staa_setup()
187 mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info) cfi_staa_setup()
188 * mtd->numeraseregions, GFP_KERNEL); cfi_staa_setup()
189 if (!mtd->eraseregions) { cfi_staa_setup()
191 kfree(mtd); cfi_staa_setup()
200 if (mtd->erasesize < ersize) { cfi_staa_setup()
201 mtd->erasesize = ersize; cfi_staa_setup()
204 mtd->eraseregions[(j*cfi->cfiq->NumEraseRegions)+i].offset = (j*devsize)+offset; cfi_staa_setup()
205 mtd->eraseregions[(j*cfi->cfiq->NumEraseRegions)+i].erasesize = ersize; cfi_staa_setup()
206 mtd->eraseregions[(j*cfi->cfiq->NumEraseRegions)+i].numblocks = ernum; cfi_staa_setup()
214 kfree(mtd->eraseregions); cfi_staa_setup()
216 kfree(mtd); cfi_staa_setup()
220 for (i=0; i<mtd->numeraseregions;i++){ cfi_staa_setup()
222 i, (unsigned long long)mtd->eraseregions[i].offset, cfi_staa_setup()
223 mtd->eraseregions[i].erasesize, cfi_staa_setup()
224 mtd->eraseregions[i].numblocks); cfi_staa_setup()
228 mtd->_erase = cfi_staa_erase_varsize; cfi_staa_setup()
229 mtd->_read = cfi_staa_read; cfi_staa_setup()
230 mtd->_write = cfi_staa_write_buffers; cfi_staa_setup()
231 mtd->_writev = cfi_staa_writev; cfi_staa_setup()
232 mtd->_sync = cfi_staa_sync; cfi_staa_setup()
233 mtd->_lock = cfi_staa_lock; cfi_staa_setup()
234 mtd->_unlock = cfi_staa_unlock; cfi_staa_setup()
235 mtd->_suspend = cfi_staa_suspend; cfi_staa_setup()
236 mtd->_resume = cfi_staa_resume; cfi_staa_setup()
237 mtd->flags = MTD_CAP_NORFLASH & ~MTD_BIT_WRITEABLE; cfi_staa_setup()
238 mtd->writesize = 8; /* FIXME: Should be 0 for STMicro flashes w/out ECC */ cfi_staa_setup()
239 mtd->writebufsize = cfi_interleave(cfi) << cfi->cfiq->MaxBufWriteSize; cfi_staa_setup()
242 mtd->name = map->name; cfi_staa_setup()
243 return mtd; cfi_staa_setup()
382 static int cfi_staa_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) cfi_staa_read() argument
384 struct map_info *map = mtd->priv; cfi_staa_read()
605 static int cfi_staa_write_buffers (struct mtd_info *mtd, loff_t to, cfi_staa_write_buffers() argument
608 struct map_info *map = mtd->priv; cfi_staa_write_buffers()
658 #define ECCBUF_SIZE (mtd->writesize)
662 cfi_staa_writev(struct mtd_info *mtd, const struct kvec *vecs, cfi_staa_writev() argument
693 ret = mtd_write(mtd, to, ECCBUF_SIZE, &thislen, cfi_staa_writev()
703 ret = mtd_write(mtd, to, ECCBUF_DIV(elem_len), cfi_staa_writev()
718 ret = mtd_write(mtd, to, buflen, &thislen, buffer); cfi_staa_writev()
889 static int cfi_staa_erase_varsize(struct mtd_info *mtd, cfi_staa_erase_varsize() argument
891 { struct map_info *map = mtd->priv; cfi_staa_erase_varsize()
896 struct mtd_erase_region_info *regions = mtd->eraseregions; cfi_staa_erase_varsize()
910 while (i < mtd->numeraseregions && instr->addr >= regions[i].offset) cfi_staa_erase_varsize()
930 while (i<mtd->numeraseregions && (instr->addr + instr->len) >= regions[i].offset) cfi_staa_erase_varsize()
974 static void cfi_staa_sync (struct mtd_info *mtd) cfi_staa_sync() argument
976 struct map_info *map = mtd->priv; cfi_staa_sync()
1127 static int cfi_staa_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) cfi_staa_lock() argument
1129 struct map_info *map = mtd->priv; cfi_staa_lock()
1137 if (ofs & (mtd->erasesize - 1)) cfi_staa_lock()
1140 if (len & (mtd->erasesize -1)) cfi_staa_lock()
1165 adr += mtd->erasesize; cfi_staa_lock()
1166 len -= mtd->erasesize; cfi_staa_lock()
1273 static int cfi_staa_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) cfi_staa_unlock() argument
1275 struct map_info *map = mtd->priv; cfi_staa_unlock()
1294 temp_adr += mtd->erasesize; cfi_staa_unlock()
1295 temp_len -= mtd->erasesize; cfi_staa_unlock()
1312 static int cfi_staa_suspend(struct mtd_info *mtd) cfi_staa_suspend() argument
1314 struct map_info *map = mtd->priv; cfi_staa_suspend()
1368 static void cfi_staa_resume(struct mtd_info *mtd) cfi_staa_resume() argument
1370 struct map_info *map = mtd->priv; cfi_staa_resume()
1392 static void cfi_staa_destroy(struct mtd_info *mtd) cfi_staa_destroy() argument
1394 struct map_info *map = mtd->priv; cfi_staa_destroy()
H A Dcfi_util.c21 #include <linux/mtd/xip.h>
22 #include <linux/mtd/mtd.h>
23 #include <linux/mtd/map.h>
24 #include <linux/mtd/cfi.h>
148 void cfi_fixup(struct mtd_info *mtd, struct cfi_fixup *fixups) cfi_fixup() argument
150 struct map_info *map = mtd->priv; cfi_fixup()
157 f->fixup(mtd); cfi_fixup()
164 int cfi_varsize_frob(struct mtd_info *mtd, varsize_frob_t frob, cfi_varsize_frob() argument
167 struct map_info *map = mtd->priv; cfi_varsize_frob()
172 struct mtd_erase_region_info *regions = mtd->eraseregions; cfi_varsize_frob()
186 while (i < mtd->numeraseregions && ofs >= regions[i].offset) cfi_varsize_frob()
206 while (i<mtd->numeraseregions && (ofs + len) >= regions[i].offset) cfi_varsize_frob()
/linux-4.1.27/drivers/mtd/
H A Dmtdcore.c43 #include <linux/mtd/mtd.h>
44 #include <linux/mtd/partitions.h>
55 .name = "mtd",
84 struct mtd_info *mtd = dev_get_drvdata(dev); mtd_release() local
85 dev_t index = MTD_DEVT(mtd->index); mtd_release()
93 struct mtd_info *mtd = dev_get_drvdata(dev); mtd_cls_suspend() local
95 return mtd ? mtd_suspend(mtd) : 0; mtd_cls_suspend()
100 struct mtd_info *mtd = dev_get_drvdata(dev); mtd_cls_resume() local
102 if (mtd) mtd_cls_resume()
103 mtd_resume(mtd); mtd_cls_resume()
110 struct mtd_info *mtd = dev_get_drvdata(dev); mtd_type_show() local
113 switch (mtd->type) { mtd_type_show()
149 struct mtd_info *mtd = dev_get_drvdata(dev); mtd_flags_show() local
151 return snprintf(buf, PAGE_SIZE, "0x%lx\n", (unsigned long)mtd->flags); mtd_flags_show()
159 struct mtd_info *mtd = dev_get_drvdata(dev); mtd_size_show() local
162 (unsigned long long)mtd->size); mtd_size_show()
170 struct mtd_info *mtd = dev_get_drvdata(dev); mtd_erasesize_show() local
172 return snprintf(buf, PAGE_SIZE, "%lu\n", (unsigned long)mtd->erasesize); mtd_erasesize_show()
180 struct mtd_info *mtd = dev_get_drvdata(dev); mtd_writesize_show() local
182 return snprintf(buf, PAGE_SIZE, "%lu\n", (unsigned long)mtd->writesize); mtd_writesize_show()
190 struct mtd_info *mtd = dev_get_drvdata(dev); mtd_subpagesize_show() local
191 unsigned int subpagesize = mtd->writesize >> mtd->subpage_sft; mtd_subpagesize_show()
201 struct mtd_info *mtd = dev_get_drvdata(dev); mtd_oobsize_show() local
203 return snprintf(buf, PAGE_SIZE, "%lu\n", (unsigned long)mtd->oobsize); mtd_oobsize_show()
211 struct mtd_info *mtd = dev_get_drvdata(dev); mtd_numeraseregions_show() local
213 return snprintf(buf, PAGE_SIZE, "%u\n", mtd->numeraseregions); mtd_numeraseregions_show()
222 struct mtd_info *mtd = dev_get_drvdata(dev); mtd_name_show() local
224 return snprintf(buf, PAGE_SIZE, "%s\n", mtd->name); mtd_name_show()
232 struct mtd_info *mtd = dev_get_drvdata(dev); mtd_ecc_strength_show() local
234 return snprintf(buf, PAGE_SIZE, "%u\n", mtd->ecc_strength); mtd_ecc_strength_show()
242 struct mtd_info *mtd = dev_get_drvdata(dev); mtd_bitflip_threshold_show() local
244 return snprintf(buf, PAGE_SIZE, "%u\n", mtd->bitflip_threshold); mtd_bitflip_threshold_show()
251 struct mtd_info *mtd = dev_get_drvdata(dev); mtd_bitflip_threshold_store() local
259 mtd->bitflip_threshold = bitflip_threshold; mtd_bitflip_threshold_store()
269 struct mtd_info *mtd = dev_get_drvdata(dev); mtd_ecc_step_size_show() local
271 return snprintf(buf, PAGE_SIZE, "%u\n", mtd->ecc_step_size); mtd_ecc_step_size_show()
279 struct mtd_info *mtd = dev_get_drvdata(dev); mtd_ecc_stats_corrected_show() local
280 struct mtd_ecc_stats *ecc_stats = &mtd->ecc_stats; mtd_ecc_stats_corrected_show()
290 struct mtd_info *mtd = dev_get_drvdata(dev); mtd_ecc_stats_errors_show() local
291 struct mtd_ecc_stats *ecc_stats = &mtd->ecc_stats; mtd_ecc_stats_errors_show()
300 struct mtd_info *mtd = dev_get_drvdata(dev); mtd_badblocks_show() local
301 struct mtd_ecc_stats *ecc_stats = &mtd->ecc_stats; mtd_badblocks_show()
310 struct mtd_info *mtd = dev_get_drvdata(dev); mtd_bbtblocks_show() local
311 struct mtd_ecc_stats *ecc_stats = &mtd->ecc_stats; mtd_bbtblocks_show()
336 ATTRIBUTE_GROUPS(mtd); variable
339 .name = "mtd",
345 unsigned mtd_mmap_capabilities(struct mtd_info *mtd) mtd_mmap_capabilities() argument
347 switch (mtd->type) { mtd_mmap_capabilities()
364 struct mtd_info *mtd; mtd_reboot_notifier() local
366 mtd = container_of(n, struct mtd_info, reboot_notifier); mtd_reboot_notifier()
367 mtd->_reboot(mtd); mtd_reboot_notifier()
374 * @mtd: pointer to new MTD device info structure
382 int add_mtd_device(struct mtd_info *mtd) add_mtd_device() argument
387 mtd->backing_dev_info = &mtd_bdi; add_mtd_device()
389 BUG_ON(mtd->writesize == 0); add_mtd_device()
392 i = idr_alloc(&mtd_idr, mtd, 0, 0, GFP_KERNEL); add_mtd_device()
396 mtd->index = i; add_mtd_device()
397 mtd->usecount = 0; add_mtd_device()
400 if (mtd->bitflip_threshold == 0) add_mtd_device()
401 mtd->bitflip_threshold = mtd->ecc_strength; add_mtd_device()
403 if (is_power_of_2(mtd->erasesize)) add_mtd_device()
404 mtd->erasesize_shift = ffs(mtd->erasesize) - 1; add_mtd_device()
406 mtd->erasesize_shift = 0; add_mtd_device()
408 if (is_power_of_2(mtd->writesize)) add_mtd_device()
409 mtd->writesize_shift = ffs(mtd->writesize) - 1; add_mtd_device()
411 mtd->writesize_shift = 0; add_mtd_device()
413 mtd->erasesize_mask = (1 << mtd->erasesize_shift) - 1; add_mtd_device()
414 mtd->writesize_mask = (1 << mtd->writesize_shift) - 1; add_mtd_device()
417 if ((mtd->flags & MTD_WRITEABLE) && (mtd->flags & MTD_POWERUP_LOCK)) { add_mtd_device()
418 error = mtd_unlock(mtd, 0, mtd->size); add_mtd_device()
422 mtd->name); add_mtd_device()
428 mtd->dev.type = &mtd_devtype; add_mtd_device()
429 mtd->dev.class = &mtd_class; add_mtd_device()
430 mtd->dev.devt = MTD_DEVT(i); add_mtd_device()
431 dev_set_name(&mtd->dev, "mtd%d", i); add_mtd_device()
432 dev_set_drvdata(&mtd->dev, mtd); add_mtd_device()
433 if (device_register(&mtd->dev) != 0) add_mtd_device()
436 device_create(&mtd_class, mtd->dev.parent, MTD_DEVT(i) + 1, NULL, add_mtd_device()
437 "mtd%dro", i); add_mtd_device()
439 pr_debug("mtd: Giving out device %d to %s\n", i, mtd->name); add_mtd_device()
443 not->add(mtd); add_mtd_device()
462 * @mtd: pointer to MTD device info structure
470 int del_mtd_device(struct mtd_info *mtd) del_mtd_device() argument
477 if (idr_find(&mtd_idr, mtd->index) != mtd) { del_mtd_device()
485 not->remove(mtd); del_mtd_device()
487 if (mtd->usecount) { del_mtd_device()
489 mtd->index, mtd->name, mtd->usecount); del_mtd_device()
492 device_unregister(&mtd->dev); del_mtd_device()
494 idr_remove(&mtd_idr, mtd->index); del_mtd_device()
505 static int mtd_add_device_partitions(struct mtd_info *mtd, mtd_add_device_partitions() argument
512 ret = add_mtd_device(mtd); mtd_add_device_partitions()
518 ret = add_mtd_partitions(mtd, real_parts, nbparts); mtd_add_device_partitions()
520 del_mtd_device(mtd); mtd_add_device_partitions()
531 * @mtd: the MTD device to register
544 * * It first tries to probe partitions on MTD device @mtd using parsers
553 * @mtd and exits.
557 int mtd_device_parse_register(struct mtd_info *mtd, const char * const *types, mtd_device_parse_register() argument
565 ret = parse_mtd_partitions(mtd, types, &real_parts, parser_data); mtd_device_parse_register()
576 ret = mtd_add_device_partitions(mtd, real_parts, ret); mtd_device_parse_register()
586 if (mtd->_reboot && !mtd->reboot_notifier.notifier_call) { mtd_device_parse_register()
587 mtd->reboot_notifier.notifier_call = mtd_reboot_notifier; mtd_device_parse_register()
588 register_reboot_notifier(&mtd->reboot_notifier); mtd_device_parse_register()
630 struct mtd_info *mtd; register_mtd_user() local
638 mtd_for_each_device(mtd) register_mtd_user()
639 new->add(mtd); register_mtd_user()
656 struct mtd_info *mtd; unregister_mtd_user() local
662 mtd_for_each_device(mtd) unregister_mtd_user()
663 old->remove(mtd); unregister_mtd_user()
673 * @mtd: last known address of the required MTD device
682 struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num) get_mtd_device() argument
691 if (other == mtd) { mtd_for_each_device()
692 ret = mtd; mtd_for_each_device()
698 if (mtd && mtd != ret)
717 int __get_mtd_device(struct mtd_info *mtd) __get_mtd_device() argument
721 if (!try_module_get(mtd->owner)) __get_mtd_device()
724 if (mtd->_get_device) { __get_mtd_device()
725 err = mtd->_get_device(mtd); __get_mtd_device()
728 module_put(mtd->owner); __get_mtd_device()
732 mtd->usecount++; __get_mtd_device()
748 struct mtd_info *mtd = NULL, *other; get_mtd_device_nm() local
754 mtd = other; mtd_for_each_device()
759 if (!mtd)
762 err = __get_mtd_device(mtd);
767 return mtd;
775 void put_mtd_device(struct mtd_info *mtd) put_mtd_device() argument
778 __put_mtd_device(mtd); put_mtd_device()
784 void __put_mtd_device(struct mtd_info *mtd) __put_mtd_device() argument
786 --mtd->usecount; __put_mtd_device()
787 BUG_ON(mtd->usecount < 0); __put_mtd_device()
789 if (mtd->_put_device) __put_mtd_device()
790 mtd->_put_device(mtd); __put_mtd_device()
792 module_put(mtd->owner); __put_mtd_device()
803 int mtd_erase(struct mtd_info *mtd, struct erase_info *instr) mtd_erase() argument
805 if (instr->addr >= mtd->size || instr->len > mtd->size - instr->addr) mtd_erase()
807 if (!(mtd->flags & MTD_WRITEABLE)) mtd_erase()
815 return mtd->_erase(mtd, instr); mtd_erase()
822 int mtd_point(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, mtd_point() argument
829 if (!mtd->_point) mtd_point()
831 if (from < 0 || from >= mtd->size || len > mtd->size - from) mtd_point()
835 return mtd->_point(mtd, from, len, retlen, virt, phys); mtd_point()
840 int mtd_unpoint(struct mtd_info *mtd, loff_t from, size_t len) mtd_unpoint() argument
842 if (!mtd->_point) mtd_unpoint()
844 if (from < 0 || from >= mtd->size || len > mtd->size - from) mtd_unpoint()
848 return mtd->_unpoint(mtd, from, len); mtd_unpoint()
857 unsigned long mtd_get_unmapped_area(struct mtd_info *mtd, unsigned long len, mtd_get_unmapped_area() argument
860 if (!mtd->_get_unmapped_area) mtd_get_unmapped_area()
862 if (offset >= mtd->size || len > mtd->size - offset) mtd_get_unmapped_area()
864 return mtd->_get_unmapped_area(mtd, len, offset, flags); mtd_get_unmapped_area()
868 int mtd_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, mtd_read() argument
873 if (from < 0 || from >= mtd->size || len > mtd->size - from) mtd_read()
883 ret_code = mtd->_read(mtd, from, len, retlen, buf); mtd_read()
886 if (mtd->ecc_strength == 0) mtd_read()
888 return ret_code >= mtd->bitflip_threshold ? -EUCLEAN : 0; mtd_read()
892 int mtd_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, mtd_write() argument
896 if (to < 0 || to >= mtd->size || len > mtd->size - to) mtd_write()
898 if (!mtd->_write || !(mtd->flags & MTD_WRITEABLE)) mtd_write()
902 return mtd->_write(mtd, to, len, retlen, buf); mtd_write()
913 int mtd_panic_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, mtd_panic_write() argument
917 if (!mtd->_panic_write) mtd_panic_write()
919 if (to < 0 || to >= mtd->size || len > mtd->size - to) mtd_panic_write()
921 if (!(mtd->flags & MTD_WRITEABLE)) mtd_panic_write()
925 return mtd->_panic_write(mtd, to, len, retlen, buf); mtd_panic_write()
929 int mtd_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops) mtd_read_oob() argument
933 if (!mtd->_read_oob) mtd_read_oob()
936 * In cases where ops->datbuf != NULL, mtd->_read_oob() has semantics mtd_read_oob()
937 * similar to mtd->_read(), returning a non-negative integer mtd_read_oob()
938 * representing max bitflips. In other cases, mtd->_read_oob() may mtd_read_oob()
941 ret_code = mtd->_read_oob(mtd, from, ops); mtd_read_oob()
944 if (mtd->ecc_strength == 0) mtd_read_oob()
946 return ret_code >= mtd->bitflip_threshold ? -EUCLEAN : 0; mtd_read_oob()
955 int mtd_get_fact_prot_info(struct mtd_info *mtd, size_t len, size_t *retlen, mtd_get_fact_prot_info() argument
958 if (!mtd->_get_fact_prot_info) mtd_get_fact_prot_info()
962 return mtd->_get_fact_prot_info(mtd, len, retlen, buf); mtd_get_fact_prot_info()
966 int mtd_read_fact_prot_reg(struct mtd_info *mtd, loff_t from, size_t len, mtd_read_fact_prot_reg() argument
970 if (!mtd->_read_fact_prot_reg) mtd_read_fact_prot_reg()
974 return mtd->_read_fact_prot_reg(mtd, from, len, retlen, buf); mtd_read_fact_prot_reg()
978 int mtd_get_user_prot_info(struct mtd_info *mtd, size_t len, size_t *retlen, mtd_get_user_prot_info() argument
981 if (!mtd->_get_user_prot_info) mtd_get_user_prot_info()
985 return mtd->_get_user_prot_info(mtd, len, retlen, buf); mtd_get_user_prot_info()
989 int mtd_read_user_prot_reg(struct mtd_info *mtd, loff_t from, size_t len, mtd_read_user_prot_reg() argument
993 if (!mtd->_read_user_prot_reg) mtd_read_user_prot_reg()
997 return mtd->_read_user_prot_reg(mtd, from, len, retlen, buf); mtd_read_user_prot_reg()
1001 int mtd_write_user_prot_reg(struct mtd_info *mtd, loff_t to, size_t len, mtd_write_user_prot_reg() argument
1007 if (!mtd->_write_user_prot_reg) mtd_write_user_prot_reg()
1011 ret = mtd->_write_user_prot_reg(mtd, to, len, retlen, buf); mtd_write_user_prot_reg()
1023 int mtd_lock_user_prot_reg(struct mtd_info *mtd, loff_t from, size_t len) mtd_lock_user_prot_reg() argument
1025 if (!mtd->_lock_user_prot_reg) mtd_lock_user_prot_reg()
1029 return mtd->_lock_user_prot_reg(mtd, from, len); mtd_lock_user_prot_reg()
1034 int mtd_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) mtd_lock() argument
1036 if (!mtd->_lock) mtd_lock()
1038 if (ofs < 0 || ofs >= mtd->size || len > mtd->size - ofs) mtd_lock()
1042 return mtd->_lock(mtd, ofs, len); mtd_lock()
1046 int mtd_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) mtd_unlock() argument
1048 if (!mtd->_unlock) mtd_unlock()
1050 if (ofs < 0 || ofs >= mtd->size || len > mtd->size - ofs) mtd_unlock()
1054 return mtd->_unlock(mtd, ofs, len); mtd_unlock()
1058 int mtd_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len) mtd_is_locked() argument
1060 if (!mtd->_is_locked) mtd_is_locked()
1062 if (ofs < 0 || ofs >= mtd->size || len > mtd->size - ofs) mtd_is_locked()
1066 return mtd->_is_locked(mtd, ofs, len); mtd_is_locked()
1070 int mtd_block_isreserved(struct mtd_info *mtd, loff_t ofs) mtd_block_isreserved() argument
1072 if (ofs < 0 || ofs >= mtd->size) mtd_block_isreserved()
1074 if (!mtd->_block_isreserved) mtd_block_isreserved()
1076 return mtd->_block_isreserved(mtd, ofs); mtd_block_isreserved()
1080 int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs) mtd_block_isbad() argument
1082 if (ofs < 0 || ofs >= mtd->size) mtd_block_isbad()
1084 if (!mtd->_block_isbad) mtd_block_isbad()
1086 return mtd->_block_isbad(mtd, ofs); mtd_block_isbad()
1090 int mtd_block_markbad(struct mtd_info *mtd, loff_t ofs) mtd_block_markbad() argument
1092 if (!mtd->_block_markbad) mtd_block_markbad()
1094 if (ofs < 0 || ofs >= mtd->size) mtd_block_markbad()
1096 if (!(mtd->flags & MTD_WRITEABLE)) mtd_block_markbad()
1098 return mtd->_block_markbad(mtd, ofs); mtd_block_markbad()
1104 * @mtd: mtd device description object pointer
1113 static int default_mtd_writev(struct mtd_info *mtd, const struct kvec *vecs, default_mtd_writev() argument
1123 ret = mtd_write(mtd, to, vecs[i].iov_len, &thislen, default_mtd_writev()
1136 * @mtd: mtd device description object pointer
1145 int mtd_writev(struct mtd_info *mtd, const struct kvec *vecs, mtd_writev() argument
1149 if (!(mtd->flags & MTD_WRITEABLE)) mtd_writev()
1151 if (!mtd->_writev) mtd_writev()
1152 return default_mtd_writev(mtd, vecs, count, to, retlen); mtd_writev()
1153 return mtd->_writev(mtd, vecs, count, to, retlen); mtd_writev()
1159 * @mtd: mtd device description object pointer
1172 * the MTD device's min. I/O unit, i.e. the "mtd->writesize" value.
1181 void *mtd_kmalloc_up_to(const struct mtd_info *mtd, size_t *size) mtd_kmalloc_up_to() argument
1185 size_t min_alloc = max_t(size_t, mtd->writesize, PAGE_SIZE); mtd_kmalloc_up_to()
1196 *size = ALIGN(*size, mtd->writesize); mtd_kmalloc_up_to()
1210 /* Support for /proc/mtd */
1214 struct mtd_info *mtd; mtd_proc_show() local
1218 mtd_for_each_device(mtd) { mtd_for_each_device()
1219 seq_printf(m, "mtd%d: %8.8llx %8.8x \"%s\"\n", mtd_for_each_device()
1220 mtd->index, (unsigned long long)mtd->size, mtd_for_each_device()
1221 mtd->erasesize, mtd->name); mtd_for_each_device()
1267 ret = mtd_bdi_init(&mtd_bdi, "mtd"); init_mtd()
1271 proc_mtd = proc_create("mtd", 0, NULL, &mtd_proc_ops); init_mtd()
1281 remove_proc_entry("mtd", NULL); init_mtd()
1285 pr_err("Error registering mtd class or bdi: %d\n", ret); init_mtd()
1293 remove_proc_entry("mtd", NULL); cleanup_mtd()
H A Dmtdpart.c30 #include <linux/mtd/mtd.h>
31 #include <linux/mtd/partitions.h>
43 struct mtd_info mtd; member in struct:mtd_part
61 static int part_read(struct mtd_info *mtd, loff_t from, size_t len, part_read() argument
64 struct mtd_part *part = PART(mtd); part_read()
72 mtd->ecc_stats.failed += part_read()
75 mtd->ecc_stats.corrected += part_read()
80 static int part_point(struct mtd_info *mtd, loff_t from, size_t len, part_point() argument
83 struct mtd_part *part = PART(mtd); part_point()
89 static int part_unpoint(struct mtd_info *mtd, loff_t from, size_t len) part_unpoint() argument
91 struct mtd_part *part = PART(mtd); part_unpoint()
96 static unsigned long part_get_unmapped_area(struct mtd_info *mtd, part_get_unmapped_area() argument
101 struct mtd_part *part = PART(mtd); part_get_unmapped_area()
108 static int part_read_oob(struct mtd_info *mtd, loff_t from, part_read_oob() argument
111 struct mtd_part *part = PART(mtd); part_read_oob()
114 if (from >= mtd->size) part_read_oob()
116 if (ops->datbuf && from + ops->len > mtd->size) part_read_oob()
127 len = mtd->oobavail; part_read_oob()
129 len = mtd->oobsize; part_read_oob()
130 pages = mtd_div_by_ws(mtd->size, mtd); part_read_oob()
131 pages -= mtd_div_by_ws(from, mtd); part_read_oob()
139 mtd->ecc_stats.corrected++; part_read_oob()
141 mtd->ecc_stats.failed++; part_read_oob()
146 static int part_read_user_prot_reg(struct mtd_info *mtd, loff_t from, part_read_user_prot_reg() argument
149 struct mtd_part *part = PART(mtd); part_read_user_prot_reg()
154 static int part_get_user_prot_info(struct mtd_info *mtd, size_t len, part_get_user_prot_info() argument
157 struct mtd_part *part = PART(mtd); part_get_user_prot_info()
162 static int part_read_fact_prot_reg(struct mtd_info *mtd, loff_t from, part_read_fact_prot_reg() argument
165 struct mtd_part *part = PART(mtd); part_read_fact_prot_reg()
170 static int part_get_fact_prot_info(struct mtd_info *mtd, size_t len, part_get_fact_prot_info() argument
173 struct mtd_part *part = PART(mtd); part_get_fact_prot_info()
178 static int part_write(struct mtd_info *mtd, loff_t to, size_t len, part_write() argument
181 struct mtd_part *part = PART(mtd); part_write()
186 static int part_panic_write(struct mtd_info *mtd, loff_t to, size_t len, part_panic_write() argument
189 struct mtd_part *part = PART(mtd); part_panic_write()
194 static int part_write_oob(struct mtd_info *mtd, loff_t to, part_write_oob() argument
197 struct mtd_part *part = PART(mtd); part_write_oob()
199 if (to >= mtd->size) part_write_oob()
201 if (ops->datbuf && to + ops->len > mtd->size) part_write_oob()
206 static int part_write_user_prot_reg(struct mtd_info *mtd, loff_t from, part_write_user_prot_reg() argument
209 struct mtd_part *part = PART(mtd); part_write_user_prot_reg()
214 static int part_lock_user_prot_reg(struct mtd_info *mtd, loff_t from, part_lock_user_prot_reg() argument
217 struct mtd_part *part = PART(mtd); part_lock_user_prot_reg()
221 static int part_writev(struct mtd_info *mtd, const struct kvec *vecs, part_writev() argument
224 struct mtd_part *part = PART(mtd); part_writev()
229 static int part_erase(struct mtd_info *mtd, struct erase_info *instr) part_erase() argument
231 struct mtd_part *part = PART(mtd); part_erase()
246 if (instr->mtd->_erase == part_erase) { mtd_erase_callback()
247 struct mtd_part *part = PART(instr->mtd); mtd_erase_callback()
258 static int part_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) part_lock() argument
260 struct mtd_part *part = PART(mtd); part_lock()
264 static int part_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) part_unlock() argument
266 struct mtd_part *part = PART(mtd); part_unlock()
270 static int part_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len) part_is_locked() argument
272 struct mtd_part *part = PART(mtd); part_is_locked()
276 static void part_sync(struct mtd_info *mtd) part_sync() argument
278 struct mtd_part *part = PART(mtd); part_sync()
282 static int part_suspend(struct mtd_info *mtd) part_suspend() argument
284 struct mtd_part *part = PART(mtd); part_suspend()
288 static void part_resume(struct mtd_info *mtd) part_resume() argument
290 struct mtd_part *part = PART(mtd); part_resume()
294 static int part_block_isreserved(struct mtd_info *mtd, loff_t ofs) part_block_isreserved() argument
296 struct mtd_part *part = PART(mtd); part_block_isreserved()
301 static int part_block_isbad(struct mtd_info *mtd, loff_t ofs) part_block_isbad() argument
303 struct mtd_part *part = PART(mtd); part_block_isbad()
308 static int part_block_markbad(struct mtd_info *mtd, loff_t ofs) part_block_markbad() argument
310 struct mtd_part *part = PART(mtd); part_block_markbad()
316 mtd->ecc_stats.badblocks++; part_block_markbad()
322 kfree(p->mtd.name); free_partition()
339 ret = del_mtd_device(&slave->mtd); del_mtd_partitions()
371 slave->mtd.type = master->type; allocate_partition()
372 slave->mtd.flags = master->flags & ~part->mask_flags; allocate_partition()
373 slave->mtd.size = part->size; allocate_partition()
374 slave->mtd.writesize = master->writesize; allocate_partition()
375 slave->mtd.writebufsize = master->writebufsize; allocate_partition()
376 slave->mtd.oobsize = master->oobsize; allocate_partition()
377 slave->mtd.oobavail = master->oobavail; allocate_partition()
378 slave->mtd.subpage_sft = master->subpage_sft; allocate_partition()
380 slave->mtd.name = name; allocate_partition()
381 slave->mtd.owner = master->owner; allocate_partition()
391 slave->mtd.dev.parent = IS_ENABLED(CONFIG_MTD_PARTITIONED_MASTER) ? allocate_partition()
395 slave->mtd._read = part_read; allocate_partition()
396 slave->mtd._write = part_write; allocate_partition()
399 slave->mtd._panic_write = part_panic_write; allocate_partition()
402 slave->mtd._point = part_point; allocate_partition()
403 slave->mtd._unpoint = part_unpoint; allocate_partition()
407 slave->mtd._get_unmapped_area = part_get_unmapped_area; allocate_partition()
409 slave->mtd._read_oob = part_read_oob; allocate_partition()
411 slave->mtd._write_oob = part_write_oob; allocate_partition()
413 slave->mtd._read_user_prot_reg = part_read_user_prot_reg; allocate_partition()
415 slave->mtd._read_fact_prot_reg = part_read_fact_prot_reg; allocate_partition()
417 slave->mtd._write_user_prot_reg = part_write_user_prot_reg; allocate_partition()
419 slave->mtd._lock_user_prot_reg = part_lock_user_prot_reg; allocate_partition()
421 slave->mtd._get_user_prot_info = part_get_user_prot_info; allocate_partition()
423 slave->mtd._get_fact_prot_info = part_get_fact_prot_info; allocate_partition()
425 slave->mtd._sync = part_sync; allocate_partition()
428 slave->mtd._suspend = part_suspend; allocate_partition()
429 slave->mtd._resume = part_resume; allocate_partition()
432 slave->mtd._writev = part_writev; allocate_partition()
434 slave->mtd._lock = part_lock; allocate_partition()
436 slave->mtd._unlock = part_unlock; allocate_partition()
438 slave->mtd._is_locked = part_is_locked; allocate_partition()
440 slave->mtd._block_isreserved = part_block_isreserved; allocate_partition()
442 slave->mtd._block_isbad = part_block_isbad; allocate_partition()
444 slave->mtd._block_markbad = part_block_markbad; allocate_partition()
445 slave->mtd._erase = part_erase; allocate_partition()
463 if (master->size - slave->offset >= slave->mtd.size) { allocate_partition()
464 slave->mtd.size = master->size - slave->offset allocate_partition()
465 - slave->mtd.size; allocate_partition()
467 printk(KERN_ERR "mtd partition \"%s\" doesn't have enough space: %#llx < %#llx, disabled\n", allocate_partition()
469 slave->mtd.size); allocate_partition()
474 if (slave->mtd.size == MTDPART_SIZ_FULL) allocate_partition()
475 slave->mtd.size = master->size - slave->offset; allocate_partition()
478 (unsigned long long)(slave->offset + slave->mtd.size), slave->mtd.name); allocate_partition()
484 slave->mtd.size = 0; allocate_partition()
485 printk(KERN_ERR"mtd: partition \"%s\" is out of reach -- disabled\n", allocate_partition()
489 if (slave->offset + slave->mtd.size > master->size) { allocate_partition()
490 slave->mtd.size = master->size - slave->offset; allocate_partition()
491 printk(KERN_WARNING"mtd: partition \"%s\" extends beyond the end of device \"%s\" -- size truncated to %#llx\n", allocate_partition()
492 part->name, master->name, (unsigned long long)slave->mtd.size); allocate_partition()
497 u64 end = slave->offset + slave->mtd.size; allocate_partition()
510 if (slave->mtd.erasesize < regions[i].erasesize) { allocate_partition()
511 slave->mtd.erasesize = regions[i].erasesize; allocate_partition()
514 BUG_ON(slave->mtd.erasesize == 0); allocate_partition()
517 slave->mtd.erasesize = master->erasesize; allocate_partition()
520 if ((slave->mtd.flags & MTD_WRITEABLE) && allocate_partition()
521 mtd_mod_by_eb(slave->offset, &slave->mtd)) { allocate_partition()
525 slave->mtd.flags &= ~MTD_WRITEABLE; allocate_partition()
526 printk(KERN_WARNING"mtd: partition \"%s\" doesn't start on an erase block boundary -- force read-only\n", allocate_partition()
529 if ((slave->mtd.flags & MTD_WRITEABLE) && allocate_partition()
530 mtd_mod_by_eb(slave->mtd.size, &slave->mtd)) { allocate_partition()
531 slave->mtd.flags &= ~MTD_WRITEABLE; allocate_partition()
532 printk(KERN_WARNING"mtd: partition \"%s\" doesn't end on an erase block -- force read-only\n", allocate_partition()
536 slave->mtd.ecclayout = master->ecclayout; allocate_partition()
537 slave->mtd.ecc_step_size = master->ecc_step_size; allocate_partition()
538 slave->mtd.ecc_strength = master->ecc_strength; allocate_partition()
539 slave->mtd.bitflip_threshold = master->bitflip_threshold; allocate_partition()
544 while (offs < slave->mtd.size) { allocate_partition()
546 slave->mtd.ecc_stats.bbtblocks++; allocate_partition()
548 slave->mtd.ecc_stats.badblocks++; allocate_partition()
549 offs += slave->mtd.erasesize; allocate_partition()
560 struct mtd_info *mtd = dev_get_drvdata(dev); mtd_partition_offset_show() local
561 struct mtd_part *part = PART(mtd); mtd_partition_offset_show()
574 int ret = sysfs_create_files(&new->mtd.dev.kobj, mtd_partition_attrs); mtd_add_partition_attrs()
577 "mtd: failed to create partition attrs, err=%d\n", ret); mtd_add_partition_attrs()
613 add_mtd_device(&new->mtd); mtd_add_partition()
629 (slave->mtd.index == partno)) { mtd_del_partition()
630 sysfs_remove_files(&slave->mtd.dev.kobj, mtd_del_partition()
632 ret = del_mtd_device(&slave->mtd); mtd_del_partition()
674 add_mtd_device(&slave->mtd); add_mtd_partitions()
677 cur_offset = slave->offset + slave->mtd.size; add_mtd_partitions()
778 int mtd_is_partition(const struct mtd_info *mtd) mtd_is_partition() argument
785 if (&part->mtd == mtd) { mtd_is_partition()
796 uint64_t mtd_get_device_size(const struct mtd_info *mtd) mtd_get_device_size() argument
798 if (!mtd_is_partition(mtd)) mtd_get_device_size()
799 return mtd->size; mtd_get_device_size()
801 return PART(mtd)->master->size; mtd_get_device_size()
H A Dmtdcore.h9 int add_mtd_device(struct mtd_info *mtd);
10 int del_mtd_device(struct mtd_info *mtd);
20 #define mtd_for_each_device(mtd) \
21 for ((mtd) = __mtd_next_device(0); \
22 (mtd) != NULL; \
23 (mtd) = __mtd_next_device(mtd->index + 1))
H A Dmtdsuper.c15 #include <linux/mtd/super.h>
28 struct mtd_info *mtd = _mtd; get_sb_mtd_compare() local
30 if (sb->s_mtd == mtd) { get_sb_mtd_compare()
32 mtd->index, mtd->name); get_sb_mtd_compare()
37 sb->s_mtd->index, sb->s_mtd->name, mtd->index, mtd->name); get_sb_mtd_compare()
48 struct mtd_info *mtd = _mtd; get_sb_mtd_set() local
50 sb->s_mtd = mtd; get_sb_mtd_set()
51 sb->s_dev = MKDEV(MTD_BLOCK_MAJOR, mtd->index); get_sb_mtd_set()
52 sb->s_bdi = mtd->backing_dev_info; get_sb_mtd_set()
61 struct mtd_info *mtd, mount_mtd_aux()
67 sb = sget(fs_type, get_sb_mtd_compare, get_sb_mtd_set, flags, mtd); mount_mtd_aux()
76 mtd->index, mtd->name); mount_mtd_aux()
91 mtd->index, mtd->name); mount_mtd_aux()
92 put_mtd_device(mtd); mount_mtd_aux()
96 put_mtd_device(mtd); mount_mtd_aux()
107 struct mtd_info *mtd; mount_mtd_nr() local
109 mtd = get_mtd_device(NULL, mtdnr); mount_mtd_nr()
110 if (IS_ERR(mtd)) { mount_mtd_nr()
112 return ERR_CAST(mtd); mount_mtd_nr()
115 return mount_mtd_aux(fs_type, flags, dev_name, data, mtd, fill_super); mount_mtd_nr()
142 struct mtd_info *mtd; mount_mtd() local
145 pr_debug("MTDSB: mtd:%%s, name \"%s\"\n", mount_mtd()
148 mtd = get_mtd_device_nm(dev_name + 4); mount_mtd()
149 if (!IS_ERR(mtd)) mount_mtd()
152 dev_name, data, mtd, mount_mtd()
166 pr_debug("MTDSB: mtd%%d, mtdnr %d\n", mount_mtd()
59 mount_mtd_aux(struct file_system_type *fs_type, int flags, const char *dev_name, void *data, struct mtd_info *mtd, int (*fill_super)(struct super_block *, void *, int)) mount_mtd_aux() argument
H A Dmtdconcat.c32 #include <linux/mtd/mtd.h>
33 #include <linux/mtd/concat.h>
44 struct mtd_info mtd; member in struct:mtd_concat
68 concat_read(struct mtd_info *mtd, loff_t from, size_t len, concat_read() argument
71 struct mtd_concat *concat = CONCAT(mtd); concat_read()
97 mtd->ecc_stats.failed++; concat_read()
100 mtd->ecc_stats.corrected++; concat_read()
120 concat_write(struct mtd_info *mtd, loff_t to, size_t len, concat_write() argument
123 struct mtd_concat *concat = CONCAT(mtd); concat_write()
158 concat_writev(struct mtd_info *mtd, const struct kvec *vecs, concat_writev() argument
161 struct mtd_concat *concat = CONCAT(mtd); concat_writev()
173 if (mtd->writesize > 1) { concat_writev()
175 if (do_div(__to, mtd->writesize) || (total_len % mtd->writesize)) concat_writev()
233 concat_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops) concat_read_oob() argument
235 struct mtd_concat *concat = CONCAT(mtd); concat_read_oob()
260 mtd->ecc_stats.failed++; concat_read_oob()
263 mtd->ecc_stats.corrected++; concat_read_oob()
290 concat_write_oob(struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops) concat_write_oob() argument
292 struct mtd_concat *concat = CONCAT(mtd); concat_write_oob()
296 if (!(mtd->flags & MTD_WRITEABLE)) concat_write_oob()
341 static int concat_dev_erase(struct mtd_info *mtd, struct erase_info *erase) concat_dev_erase() argument
352 erase->mtd = mtd; concat_dev_erase()
360 err = mtd_erase(mtd, erase); concat_dev_erase()
375 static int concat_erase(struct mtd_info *mtd, struct erase_info *instr) concat_erase() argument
377 struct mtd_concat *concat = CONCAT(mtd); concat_erase()
389 if (!concat->mtd.numeraseregions) { concat_erase()
391 if (instr->addr & (concat->mtd.erasesize - 1)) concat_erase()
393 if (instr->len & (concat->mtd.erasesize - 1)) concat_erase()
398 concat->mtd.eraseregions; concat_erase()
403 for (i = 0; i < concat->mtd.numeraseregions && concat_erase()
418 for (; i < concat->mtd.numeraseregions && concat_erase()
498 static int concat_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) concat_lock() argument
500 struct mtd_concat *concat = CONCAT(mtd); concat_lock()
532 static int concat_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) concat_unlock() argument
534 struct mtd_concat *concat = CONCAT(mtd); concat_unlock()
566 static void concat_sync(struct mtd_info *mtd) concat_sync() argument
568 struct mtd_concat *concat = CONCAT(mtd); concat_sync()
577 static int concat_suspend(struct mtd_info *mtd) concat_suspend() argument
579 struct mtd_concat *concat = CONCAT(mtd); concat_suspend()
590 static void concat_resume(struct mtd_info *mtd) concat_resume() argument
592 struct mtd_concat *concat = CONCAT(mtd); concat_resume()
601 static int concat_block_isbad(struct mtd_info *mtd, loff_t ofs) concat_block_isbad() argument
603 struct mtd_concat *concat = CONCAT(mtd); concat_block_isbad()
624 static int concat_block_markbad(struct mtd_info *mtd, loff_t ofs) concat_block_markbad() argument
626 struct mtd_concat *concat = CONCAT(mtd); concat_block_markbad()
639 mtd->ecc_stats.badblocks++; concat_block_markbad()
650 static unsigned long concat_get_unmapped_area(struct mtd_info *mtd, concat_get_unmapped_area() argument
655 struct mtd_concat *concat = CONCAT(mtd); concat_get_unmapped_area()
709 concat->mtd.type = subdev[0]->type; mtd_concat_create()
710 concat->mtd.flags = subdev[0]->flags; mtd_concat_create()
711 concat->mtd.size = subdev[0]->size; mtd_concat_create()
712 concat->mtd.erasesize = subdev[0]->erasesize; mtd_concat_create()
713 concat->mtd.writesize = subdev[0]->writesize; mtd_concat_create()
718 concat->mtd.writebufsize = max_writebufsize; mtd_concat_create()
720 concat->mtd.subpage_sft = subdev[0]->subpage_sft; mtd_concat_create()
721 concat->mtd.oobsize = subdev[0]->oobsize; mtd_concat_create()
722 concat->mtd.oobavail = subdev[0]->oobavail; mtd_concat_create()
724 concat->mtd._writev = concat_writev; mtd_concat_create()
726 concat->mtd._read_oob = concat_read_oob; mtd_concat_create()
728 concat->mtd._write_oob = concat_write_oob; mtd_concat_create()
730 concat->mtd._block_isbad = concat_block_isbad; mtd_concat_create()
732 concat->mtd._block_markbad = concat_block_markbad; mtd_concat_create()
734 concat->mtd.ecc_stats.badblocks = subdev[0]->ecc_stats.badblocks; mtd_concat_create()
739 if (concat->mtd.type != subdev[i]->type) { mtd_concat_create()
745 if (concat->mtd.flags != subdev[i]->flags) { mtd_concat_create()
750 if ((concat->mtd.flags ^ subdev[i]-> mtd_concat_create()
759 concat->mtd.flags |= mtd_concat_create()
763 concat->mtd.size += subdev[i]->size; mtd_concat_create()
764 concat->mtd.ecc_stats.badblocks += mtd_concat_create()
766 if (concat->mtd.writesize != subdev[i]->writesize || mtd_concat_create()
767 concat->mtd.subpage_sft != subdev[i]->subpage_sft || mtd_concat_create()
768 concat->mtd.oobsize != subdev[i]->oobsize || mtd_concat_create()
769 !concat->mtd._read_oob != !subdev[i]->_read_oob || mtd_concat_create()
770 !concat->mtd._write_oob != !subdev[i]->_write_oob) { mtd_concat_create()
780 concat->mtd.ecclayout = subdev[0]->ecclayout; mtd_concat_create()
783 concat->mtd.name = name; mtd_concat_create()
785 concat->mtd._erase = concat_erase; mtd_concat_create()
786 concat->mtd._read = concat_read; mtd_concat_create()
787 concat->mtd._write = concat_write; mtd_concat_create()
788 concat->mtd._sync = concat_sync; mtd_concat_create()
789 concat->mtd._lock = concat_lock; mtd_concat_create()
790 concat->mtd._unlock = concat_unlock; mtd_concat_create()
791 concat->mtd._suspend = concat_suspend; mtd_concat_create()
792 concat->mtd._resume = concat_resume; mtd_concat_create()
793 concat->mtd._get_unmapped_area = concat_get_unmapped_area; mtd_concat_create()
837 concat->mtd.erasesize = curr_erasesize; mtd_concat_create()
838 concat->mtd.numeraseregions = 0; mtd_concat_create()
849 concat->mtd.erasesize = max_erasesize; mtd_concat_create()
850 concat->mtd.numeraseregions = num_erase_region; mtd_concat_create()
851 concat->mtd.eraseregions = erase_region_p = mtd_concat_create()
922 return &concat->mtd; mtd_concat_create()
929 void mtd_concat_destroy(struct mtd_info *mtd) mtd_concat_destroy() argument
931 struct mtd_concat *concat = CONCAT(mtd); mtd_concat_destroy()
932 if (concat->mtd.numeraseregions) mtd_concat_destroy()
933 kfree(concat->mtd.eraseregions); mtd_concat_destroy()
H A Dmtdoops.c33 #include <linux/mtd/mtd.h>
63 struct mtd_info *mtd; member in struct:mtdoops_context
95 struct mtd_info *mtd = cxt->mtd; mtdoops_erase_block() local
96 u32 start_page_offset = mtd_div_by_eb(offset, mtd) * mtd->erasesize; mtdoops_erase_block()
98 u32 erase_pages = mtd->erasesize / record_size; mtdoops_erase_block()
106 erase.mtd = mtd; mtdoops_erase_block()
109 erase.len = mtd->erasesize; mtdoops_erase_block()
115 ret = mtd_erase(mtd, &erase); mtdoops_erase_block()
158 struct mtd_info *mtd = cxt->mtd; mtdoops_workfunc_erase() local
162 if (!mtd) mtdoops_workfunc_erase()
165 mod = (cxt->nextpage * record_size) % mtd->erasesize; mtdoops_workfunc_erase()
167 cxt->nextpage = cxt->nextpage + ((mtd->erasesize - mod) / record_size); mtdoops_workfunc_erase()
172 while ((ret = mtd_block_isbad(mtd, cxt->nextpage * record_size)) > 0) { mtdoops_workfunc_erase()
177 cxt->nextpage = cxt->nextpage + (mtd->erasesize / record_size); mtdoops_workfunc_erase()
180 if (i == cxt->oops_pages / (mtd->erasesize / record_size)) { mtdoops_workfunc_erase()
201 ret = mtd_block_markbad(mtd, cxt->nextpage * record_size); mtdoops_workfunc_erase()
212 struct mtd_info *mtd = cxt->mtd; mtdoops_write() local
223 ret = mtd_panic_write(mtd, cxt->nextpage * record_size, mtdoops_write()
230 ret = mtd_write(mtd, cxt->nextpage * record_size, mtdoops_write()
252 struct mtd_info *mtd = cxt->mtd; find_next_position() local
258 if (mtd_block_isbad(mtd, page * record_size)) find_next_position()
262 ret = mtd_read(mtd, page * record_size, MTDOOPS_HEADER_SIZE, find_next_position()
324 static void mtdoops_notify_add(struct mtd_info *mtd) mtdoops_notify_add() argument
327 u64 mtdoops_pages = div_u64(mtd->size, record_size); mtdoops_notify_add()
330 if (!strcmp(mtd->name, mtddev)) mtdoops_notify_add()
331 cxt->mtd_index = mtd->index; mtdoops_notify_add()
333 if (mtd->index != cxt->mtd_index || cxt->mtd_index < 0) mtdoops_notify_add()
336 if (mtd->size < mtd->erasesize * 2) { mtdoops_notify_add()
338 mtd->index); mtdoops_notify_add()
341 if (mtd->erasesize < record_size) { mtdoops_notify_add()
343 mtd->index); mtdoops_notify_add()
346 if (mtd->size > MTDOOPS_MAX_MTD_SIZE) { mtdoops_notify_add()
347 printk(KERN_ERR "mtdoops: mtd%d is too large (limit is %d MiB)\n", mtdoops_notify_add()
348 mtd->index, MTDOOPS_MAX_MTD_SIZE / 1024 / 1024); mtdoops_notify_add()
370 cxt->mtd = mtd; mtdoops_notify_add()
371 cxt->oops_pages = (int)mtd->size / record_size; mtdoops_notify_add()
373 printk(KERN_INFO "mtdoops: Attached to MTD device %d\n", mtd->index); mtdoops_notify_add()
376 static void mtdoops_notify_remove(struct mtd_info *mtd) mtdoops_notify_remove() argument
380 if (mtd->index != cxt->mtd_index || cxt->mtd_index < 0) mtdoops_notify_remove()
386 cxt->mtd = NULL; mtdoops_notify_remove()
404 printk(KERN_ERR "mtdoops: mtd device (mtddev=name/number) must be supplied\n"); mtdoops_init()
H A Dmtdblock_ro.c24 #include <linux/mtd/mtd.h>
25 #include <linux/mtd/blktrans.h>
34 if (mtd_read(dev->mtd, (block * 512), 512, &retlen, buf)) mtdblock_readsect()
44 if (mtd_write(dev->mtd, (block * 512), 512, &retlen, buf)) mtdblock_writesect()
49 static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) mtdblock_add_mtd() argument
56 dev->mtd = mtd; mtdblock_add_mtd()
57 dev->devnum = mtd->index; mtdblock_add_mtd()
59 dev->size = mtd->size >> 9; mtdblock_add_mtd()
H A Dmtdchar.c36 #include <linux/mtd/mtd.h>
37 #include <linux/mtd/partitions.h>
38 #include <linux/mtd/map.h>
47 * Data structure to hold the pointer to the mtd device as well
51 struct mtd_info *mtd; member in struct:mtd_file_info
58 return fixed_size_llseek(file, offset, orig, mfi->mtd->size); mtdchar_lseek()
66 struct mtd_info *mtd; mtdchar_open() local
76 mtd = get_mtd_device(NULL, devnum); mtdchar_open()
78 if (IS_ERR(mtd)) { mtdchar_open()
79 ret = PTR_ERR(mtd); mtdchar_open()
83 if (mtd->type == MTD_ABSENT) { mtdchar_open()
89 if ((file->f_mode & FMODE_WRITE) && !(mtd->flags & MTD_WRITEABLE)) { mtdchar_open()
99 mfi->mtd = mtd; mtdchar_open()
105 put_mtd_device(mtd); mtdchar_open()
116 struct mtd_info *mtd = mfi->mtd; mtdchar_close() local
122 mtd_sync(mtd); mtdchar_close()
124 put_mtd_device(mtd); mtdchar_close()
153 struct mtd_info *mtd = mfi->mtd; mtdchar_read() local
163 if (*ppos + count > mtd->size) mtdchar_read()
164 count = mtd->size - *ppos; mtdchar_read()
169 kbuf = mtd_kmalloc_up_to(mtd, &size); mtdchar_read()
178 ret = mtd_read_fact_prot_reg(mtd, *ppos, len, mtdchar_read()
182 ret = mtd_read_user_prot_reg(mtd, *ppos, len, mtdchar_read()
194 ret = mtd_read_oob(mtd, *ppos, &ops); mtdchar_read()
199 ret = mtd_read(mtd, *ppos, len, &retlen, kbuf); mtdchar_read()
239 struct mtd_info *mtd = mfi->mtd; mtdchar_write() local
249 if (*ppos == mtd->size) mtdchar_write()
252 if (*ppos + count > mtd->size) mtdchar_write()
253 count = mtd->size - *ppos; mtdchar_write()
258 kbuf = mtd_kmalloc_up_to(mtd, &size); mtdchar_write()
275 ret = mtd_write_user_prot_reg(mtd, *ppos, len, mtdchar_write()
289 ret = mtd_write_oob(mtd, *ppos, &ops); mtdchar_write()
295 ret = mtd_write(mtd, *ppos, len, &retlen, kbuf); mtdchar_write()
334 struct mtd_info *mtd = mfi->mtd; otp_select_filemode() local
339 if (mtd_read_fact_prot_reg(mtd, -1, 0, &retlen, NULL) == otp_select_filemode()
346 if (mtd_read_user_prot_reg(mtd, -1, 0, &retlen, NULL) == otp_select_filemode()
362 static int mtdchar_writeoob(struct file *file, struct mtd_info *mtd, mtdchar_writeoob() argument
377 if (!mtd->_write_oob) mtdchar_writeoob()
386 ops.ooboffs = start & (mtd->writesize - 1); mtdchar_writeoob()
391 if (ops.ooboffs && ops.ooblen > (mtd->oobsize - ops.ooboffs)) mtdchar_writeoob()
398 start &= ~((uint64_t)mtd->writesize - 1); mtdchar_writeoob()
399 ret = mtd_write_oob(mtd, start, &ops); mtdchar_writeoob()
411 static int mtdchar_readoob(struct file *file, struct mtd_info *mtd, mtdchar_readoob() argument
426 ops.ooboffs = start & (mtd->writesize - 1); mtdchar_readoob()
431 if (ops.ooboffs && ops.ooblen > (mtd->oobsize - ops.ooboffs)) mtdchar_readoob()
438 start &= ~((uint64_t)mtd->writesize - 1); mtdchar_readoob()
439 ret = mtd_read_oob(mtd, start, &ops); mtdchar_readoob()
500 static int mtdchar_blkpg_ioctl(struct mtd_info *mtd, mtdchar_blkpg_ioctl() argument
518 /* Only master mtd device must be used to add partitions */ mtdchar_blkpg_ioctl()
519 if (mtd_is_partition(mtd)) mtdchar_blkpg_ioctl()
525 return mtd_add_partition(mtd, p.devname, p.start, p.length); mtdchar_blkpg_ioctl()
532 return mtd_del_partition(mtd, p.pno); mtdchar_blkpg_ioctl()
539 static int mtdchar_write_ioctl(struct mtd_info *mtd, mtdchar_write_ioctl() argument
556 if (!mtd->_write_oob) mtdchar_write_ioctl()
582 ret = mtd_write_oob(mtd, (loff_t)req.start, &ops); mtdchar_write_ioctl()
593 struct mtd_info *mtd = mfi->mtd; mtdchar_ioctl() local
613 if (copy_to_user(argp, &(mtd->numeraseregions), sizeof(int))) mtdchar_ioctl()
626 if (ur_idx >= mtd->numeraseregions) mtdchar_ioctl()
629 kr = &(mtd->eraseregions[ur_idx]); mtdchar_ioctl()
641 info.type = mtd->type; mtdchar_ioctl()
642 info.flags = mtd->flags; mtdchar_ioctl()
643 info.size = mtd->size; mtdchar_ioctl()
644 info.erasesize = mtd->erasesize; mtdchar_ioctl()
645 info.writesize = mtd->writesize; mtdchar_ioctl()
646 info.oobsize = mtd->oobsize; mtdchar_ioctl()
691 erase->mtd = mtd; mtdchar_ioctl()
704 ret = mtd_erase(mtd, erase); mtdchar_ioctl()
730 ret = mtdchar_writeoob(file, mtd, buf.start, buf.length, mtdchar_ioctl()
744 ret = mtdchar_readoob(file, mtd, buf.start, buf.length, mtdchar_ioctl()
757 ret = mtdchar_writeoob(file, mtd, buf.start, buf.length, mtdchar_ioctl()
771 ret = mtdchar_readoob(file, mtd, buf.start, buf.length, mtdchar_ioctl()
779 ret = mtdchar_write_ioctl(mtd, mtdchar_ioctl()
791 ret = mtd_lock(mtd, einfo.start, einfo.length); mtdchar_ioctl()
802 ret = mtd_unlock(mtd, einfo.start, einfo.length); mtdchar_ioctl()
813 ret = mtd_is_locked(mtd, einfo.start, einfo.length); mtdchar_ioctl()
822 if (!mtd->ecclayout) mtdchar_ioctl()
824 if (mtd->ecclayout->eccbytes > ARRAY_SIZE(oi.eccpos)) mtdchar_ioctl()
828 memcpy(&oi.eccpos, mtd->ecclayout->eccpos, sizeof(oi.eccpos)); mtdchar_ioctl()
829 memcpy(&oi.oobfree, mtd->ecclayout->oobfree, mtdchar_ioctl()
831 oi.eccbytes = mtd->ecclayout->eccbytes; mtdchar_ioctl()
844 return mtd_block_isbad(mtd, offs); mtdchar_ioctl()
854 return mtd_block_markbad(mtd, offs); mtdchar_ioctl()
881 ret = mtd_get_fact_prot_info(mtd, 4096, &retlen, buf); mtdchar_ioctl()
884 ret = mtd_get_user_prot_info(mtd, 4096, &retlen, buf); mtdchar_ioctl()
911 ret = mtd_lock_user_prot_reg(mtd, oinfo.start, oinfo.length); mtdchar_ioctl()
920 if (!mtd->ecclayout) mtdchar_ioctl()
927 shrink_ecclayout(mtd->ecclayout, usrlay); mtdchar_ioctl()
937 if (copy_to_user(argp, &mtd->ecc_stats, mtdchar_ioctl()
954 if (!mtd_has_oob(mtd)) mtdchar_ioctl()
969 ret = mtdchar_blkpg_ioctl(mtd, mtdchar_ioctl()
1014 struct mtd_info *mtd = mfi->mtd; mtdchar_compat_ioctl() local
1029 ret = mtdchar_writeoob(file, mtd, buf.start, mtdchar_compat_ioctl()
1044 ret = mtdchar_readoob(file, mtd, buf.start, mtdchar_compat_ioctl()
1073 struct mtd_info *mtd = mfi->mtd; mtdchar_get_unmapped_area() local
1080 if (len > mtd->size || pgoff >= (mtd->size >> PAGE_SHIFT)) mtdchar_get_unmapped_area()
1084 if (offset > mtd->size - len) mtdchar_get_unmapped_area()
1087 ret = mtd_get_unmapped_area(mtd, len, offset, flags); mtdchar_get_unmapped_area()
1095 return mtd_mmap_capabilities(mfi->mtd); mtdchar_mmap_capabilities()
1106 struct mtd_info *mtd = mfi->mtd; mtdchar_mmap() local
1107 struct map_info *map = mtd->priv; mtdchar_mmap()
1110 and that mtd->priv is a valid struct map_info. It should be mtdchar_mmap()
1113 if (0 /*mtd->type == MTD_RAM || mtd->type == MTD_ROM*/) { mtdchar_mmap()
1149 "mtd", &mtd_fops); init_mtdchar()
1161 __unregister_chrdev(MTD_CHAR_MAJOR, 0, 1 << MINORBITS, "mtd"); cleanup_mtdchar()
H A Dssfdc.c18 #include <linux/mtd/mtd.h>
19 #include <linux/mtd/nand.h>
20 #include <linux/mtd/blktrans.h>
106 static int get_valid_cis_sector(struct mtd_info *mtd) get_valid_cis_sector() argument
124 for (k = 0, offset = 0; k < 4; k++, offset += mtd->erasesize) { get_valid_cis_sector()
125 if (mtd_block_isbad(mtd, offset)) { get_valid_cis_sector()
126 ret = mtd_read(mtd, offset, SECTOR_SIZE, &retlen, get_valid_cis_sector()
139 " on %s (mtd%d)\n", mtd->name, get_valid_cis_sector()
140 mtd->index); get_valid_cis_sector()
152 static int read_physical_sector(struct mtd_info *mtd, uint8_t *sect_buf, read_physical_sector() argument
159 ret = mtd_read(mtd, offset, SECTOR_SIZE, &retlen, sect_buf); read_physical_sector()
167 static int read_raw_oob(struct mtd_info *mtd, loff_t offs, uint8_t *buf) read_raw_oob() argument
178 ret = mtd_read_oob(mtd, offs, &ops); read_raw_oob()
248 struct mtd_info *mtd = ssfdc->mbd.mtd; build_logical_block_map() local
258 if (mtd_block_isbad(mtd, offset)) build_logical_block_map()
261 ret = read_raw_oob(mtd, offset, oob_buf); build_logical_block_map()
263 pr_debug("SSFDC_RO: mtd read_oob() failed at %lu\n", build_logical_block_map()
287 static void ssfdcr_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) ssfdcr_add_mtd() argument
293 if (!mtd_type_is_nand(mtd) || mtd->oobsize != OOB_SIZE || ssfdcr_add_mtd()
294 mtd->size > UINT_MAX) ssfdcr_add_mtd()
298 cis_sector = get_valid_cis_sector(mtd); ssfdcr_add_mtd()
306 ssfdc->mbd.mtd = mtd; ssfdcr_add_mtd()
311 ssfdc->cis_block = cis_sector / (mtd->erasesize >> SECTOR_SHIFT); ssfdcr_add_mtd()
312 ssfdc->erase_size = mtd->erasesize; ssfdcr_add_mtd()
313 ssfdc->map_len = (u32)mtd->size / mtd->erasesize; ssfdcr_add_mtd()
322 get_chs(mtd->size, NULL, &ssfdc->heads, &ssfdc->sectors); ssfdcr_add_mtd()
323 ssfdc->cylinders = (unsigned short)(((u32)mtd->size >> SECTOR_SHIFT) / ssfdcr_add_mtd()
350 printk(KERN_INFO "SSFDC_RO: Found ssfdc%c on mtd%d (%s)\n", ssfdcr_add_mtd()
351 ssfdc->mbd.devnum + 'a', mtd->index, mtd->name); ssfdcr_add_mtd()
400 if (read_physical_sector(ssfdc->mbd.mtd, buf, sect_no) < 0) ssfdcr_readsect()
H A Dmtdblock.c32 #include <linux/mtd/mtd.h>
33 #include <linux/mtd/blktrans.h>
64 static int erase_write (struct mtd_info *mtd, unsigned long pos, erase_write() argument
78 erase.mtd = mtd; erase_write()
87 ret = mtd_erase(mtd, &erase); erase_write()
93 pos, len, mtd->name); erase_write()
104 ret = mtd_write(mtd, pos, len, &retlen, buf); erase_write()
115 struct mtd_info *mtd = mtdblk->mbd.mtd; write_cached_data() local
122 "at 0x%lx, size 0x%x\n", mtd->name, write_cached_data()
125 ret = erase_write (mtd, mtdblk->cache_offset, write_cached_data()
145 struct mtd_info *mtd = mtdblk->mbd.mtd; do_cached_write() local
151 mtd->name, pos, len); do_cached_write()
154 return mtd_write(mtd, pos, len, &retlen, buf); do_cached_write()
169 ret = erase_write (mtd, pos, size, buf); do_cached_write()
186 ret = mtd_read(mtd, sect_start, sect_size, do_cached_write()
215 struct mtd_info *mtd = mtdblk->mbd.mtd; do_cached_read() local
221 mtd->name, pos, len); do_cached_read()
224 return mtd_read(mtd, pos, len, &retlen, buf); do_cached_read()
243 ret = mtd_read(mtd, pos, size, &retlen, buf); do_cached_read()
270 mtdblk->cache_data = vmalloc(mtdblk->mbd.mtd->erasesize); mtdblock_writesect()
296 if (!(mbd->mtd->flags & MTD_NO_ERASE) && mbd->mtd->erasesize) { mtdblock_open()
297 mtdblk->cache_size = mbd->mtd->erasesize; mtdblock_open()
322 mtd_sync(mbd->mtd); mtdblock_release()
336 mtd_sync(dev->mtd); mtdblock_flush()
340 static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) mtdblock_add_mtd() argument
347 dev->mbd.mtd = mtd; mtdblock_add_mtd()
348 dev->mbd.devnum = mtd->index; mtdblock_add_mtd()
350 dev->mbd.size = mtd->size >> 9; mtdblock_add_mtd()
353 if (!(mtd->flags & MTD_WRITEABLE)) mtdblock_add_mtd()
H A Dafs.c3 drivers/mtd/afs.c: ARM Flash Layout/Partitioning
33 #include <linux/mtd/mtd.h>
34 #include <linux/mtd/map.h>
35 #include <linux/mtd/partitions.h>
70 afs_read_footer(struct mtd_info *mtd, u_int *img_start, u_int *iis_start, afs_read_footer() argument
74 u_int ptr = off + mtd->erasesize - sizeof(fs); afs_read_footer()
78 ret = mtd_read(mtd, ptr, sizeof(fs), &sz, (u_char *)&fs); afs_read_footer()
83 printk(KERN_ERR "AFS: mtd read failed at 0x%x: %d\n", afs_read_footer()
129 afs_read_iis(struct mtd_info *mtd, struct image_info_struct *iis, u_int ptr) afs_read_iis() argument
135 ret = mtd_read(mtd, ptr, sizeof(*iis), &sz, (u_char *)iis); afs_read_iis()
159 printk(KERN_ERR "AFS: mtd read failed at 0x%x: %d\n", afs_read_iis()
164 static int parse_afs_partitions(struct mtd_info *mtd, parse_afs_partitions() argument
177 mask = mtd->size - 1; parse_afs_partitions()
184 for (idx = off = sz = 0; off < mtd->size; off += mtd->erasesize) { parse_afs_partitions()
188 ret = afs_read_footer(mtd, &img_ptr, &iis_ptr, off, mask); parse_afs_partitions()
194 ret = afs_read_iis(mtd, &iis, iis_ptr); parse_afs_partitions()
217 for (idx = off = 0; off < mtd->size; off += mtd->erasesize) { parse_afs_partitions()
222 ret = afs_read_footer(mtd, &img_ptr, &iis_ptr, off, mask); parse_afs_partitions()
229 ret = afs_read_iis(mtd, &iis, iis_ptr); parse_afs_partitions()
238 parts[idx].size = (iis.length + mtd->erasesize - 1) & ~(mtd->erasesize - 1); parse_afs_partitions()
242 printk(" mtd%d: at 0x%08x, %5lluKiB, %8u, %s\n", parse_afs_partitions()
H A Dmtdswap.c29 #include <linux/mtd/mtd.h>
30 #include <linux/mtd/blktrans.h>
115 struct mtd_info *mtd; member in struct:mtdswap_dev
201 return (loff_t)(eb - d->eb_data) * d->mtd->erasesize; mtdswap_eb_offset()
277 if (!mtd_can_have_bb(d->mtd)) mtdswap_handle_badblock()
282 ret = mtd_block_markbad(d->mtd, offset); mtdswap_handle_badblock()
315 int ret = mtd_read_oob(d->mtd, from, ops); mtdswap_read_oob()
346 if (mtd_can_have_bb(d->mtd) && mtd_block_isbad(d->mtd, offset)) mtdswap_read_markers()
349 ops.ooblen = 2 * d->mtd->ecclayout->oobavail; mtdswap_read_markers()
362 (d->oob_buf + d->mtd->ecclayout->oobavail); mtdswap_read_markers()
403 offset = mtdswap_eb_offset(d, eb) + d->mtd->writesize; mtdswap_write_marker()
406 ret = mtd_write_oob(d->mtd, offset, &ops); mtdswap_write_marker()
550 struct mtd_info *mtd = d->mtd; mtdswap_erase_block() local
564 erase.mtd = mtd; mtdswap_erase_block()
567 erase.len = mtd->erasesize; mtdswap_erase_block()
570 ret = mtd_erase(mtd, &erase); mtdswap_erase_block()
575 erase.addr, mtd->name); mtdswap_erase_block()
581 erase.addr, mtd->name); mtdswap_erase_block()
591 erase.addr, mtd->name); mtdswap_erase_block()
599 erase.addr, mtd->name); mtdswap_erase_block()
666 struct mtd_info *mtd = d->mtd; mtdswap_write_block() local
692 ret = mtd_write(mtd, writepos, PAGE_SIZE, &retlen, buf); mtdswap_write_block()
727 struct mtd_info *mtd = d->mtd; mtdswap_move_block() local
739 ret = mtd_read(mtd, readpos, PAGE_SIZE, &retlen, d->page_buf); mtdswap_move_block()
926 struct mtd_info *mtd = d->mtd; mtdswap_eblk_passes() local
935 ops.len = mtd->writesize; mtdswap_eblk_passes()
936 ops.ooblen = mtd->ecclayout->oobavail; mtdswap_eblk_passes()
941 mtd_pages = d->pages_per_eblk * PAGE_SIZE / mtd->writesize; mtdswap_eblk_passes()
947 memset(d->page_buf, patt, mtd->writesize); mtdswap_eblk_passes()
948 memset(d->oob_buf, patt, mtd->ecclayout->oobavail); mtdswap_eblk_passes()
949 ret = mtd_write_oob(mtd, pos, &ops); mtdswap_eblk_passes()
953 pos += mtd->writesize; mtdswap_eblk_passes()
958 ret = mtd_read_oob(mtd, pos, &ops); mtdswap_eblk_passes()
963 for (j = 0; j < mtd->writesize/sizeof(int); j++) mtdswap_eblk_passes()
967 for (j = 0; j < mtd->ecclayout->oobavail; j++) mtdswap_eblk_passes()
971 pos += mtd->writesize; mtdswap_eblk_passes()
1050 mtd_sync(d->mtd); mtdswap_flush()
1054 static unsigned int mtdswap_badblocks(struct mtd_info *mtd, uint64_t size) mtdswap_badblocks() argument
1061 if (mtd_can_have_bb(mtd)) mtdswap_badblocks()
1062 for (offset = 0; offset < size; offset += mtd->erasesize) mtdswap_badblocks()
1063 if (mtd_block_isbad(mtd, offset)) mtdswap_badblocks()
1131 struct mtd_info *mtd = d->mtd; mtdswap_readsect() local
1163 ret = mtd_read(mtd, readpos, PAGE_SIZE, &retlen, buf); mtdswap_readsect()
1256 use_size = (uint64_t)d->eblks * d->mtd->erasesize; mtdswap_show()
1257 bb_cnt = mtdswap_badblocks(d->mtd, use_size); mtdswap_show()
1295 seq_printf(s, "mtd read count: %llu\n", d->mtd_read_count); mtdswap_show()
1296 seq_printf(s, "mtd write count: %llu\n", d->mtd_write_count); mtdswap_show()
1352 struct mtd_info *mtd = d->mbd_dev->mtd; mtdswap_init() local
1356 d->mtd = mtd; mtdswap_init()
1359 d->pages_per_eblk = mtd->erasesize >> PAGE_SHIFT; mtdswap_init()
1390 d->oob_buf = kmalloc(2 * mtd->ecclayout->oobavail, GFP_KERNEL); mtdswap_init()
1411 static void mtdswap_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) mtdswap_add_mtd() argument
1431 if (mtd->index == part) mtdswap_add_mtd()
1435 if (mtd->index != part) mtdswap_add_mtd()
1438 if (mtd->erasesize < PAGE_SIZE || mtd->erasesize % PAGE_SIZE) { mtdswap_add_mtd()
1440 "%lu\n", MTDSWAP_PREFIX, mtd->erasesize, PAGE_SIZE); mtdswap_add_mtd()
1444 if (PAGE_SIZE % mtd->writesize || mtd->writesize > PAGE_SIZE) { mtdswap_add_mtd()
1446 " %u\n", MTDSWAP_PREFIX, PAGE_SIZE, mtd->writesize); mtdswap_add_mtd()
1450 oinfo = mtd->ecclayout; mtdswap_add_mtd()
1452 printk(KERN_ERR "%s: mtd%d does not have OOB\n", mtdswap_add_mtd()
1453 MTDSWAP_PREFIX, mtd->index); mtdswap_add_mtd()
1457 if (!mtd->oobsize || oinfo->oobavail < MTDSWAP_OOBSIZE) { mtdswap_add_mtd()
1467 use_size = mtd->size; mtdswap_add_mtd()
1470 if (mtd->size > size_limit) { mtdswap_add_mtd()
1476 eblocks = mtd_div_by_eb(use_size, mtd); mtdswap_add_mtd()
1477 use_size = (uint64_t)eblocks * mtd->erasesize; mtdswap_add_mtd()
1478 bad_blocks = mtdswap_badblocks(mtd, use_size); mtdswap_add_mtd()
1496 swap_size = (uint64_t)(eavailable - spare_cnt) * mtd->erasesize + mtdswap_add_mtd()
1516 mbd_dev->mtd = mtd; mtdswap_add_mtd()
1517 mbd_dev->devnum = mtd->index; mtdswap_add_mtd()
1521 if (!(mtd->flags & MTD_WRITEABLE)) mtdswap_add_mtd()
H A DMakefile6 obj-$(CONFIG_MTD) += mtd.o
7 mtd-y := mtdcore.o mtdsuper.o mtdconcat.o mtdpart.o mtdchar.o
H A Drfd_ftl.c16 #include <linux/mtd/blktrans.h>
17 #include <linux/mtd/mtd.h>
126 part->mbd.mtd->name, block_no, i, entry); build_block_map()
133 part->mbd.mtd->name, entry); build_block_map()
158 part->total_blocks = (u32)part->mbd.mtd->size / part->block_size; scan_header()
195 "sector map", part->mbd.mtd->name); scan_header()
203 rc = mtd_read(part->mbd.mtd, i * part->block_size, scan_header()
219 part->mbd.mtd->name); scan_header()
226 part->mbd.mtd->name); scan_header()
253 rc = mtd_read(part->mbd.mtd, addr, SECTOR_SIZE, &retlen, rfd_ftl_readsect()
260 "0x%lx\n", part->mbd.mtd->name, addr); rfd_ftl_readsect()
282 "on '%s'\n", (unsigned long long)erase->addr, part->mbd.mtd->name); erase_callback()
289 part->mbd.mtd->name, erase->state); erase_callback()
307 rc = mtd_write(part->mbd.mtd, part->blocks[i].offset, sizeof(magic), erase_callback()
316 part->mbd.mtd->name, erase_callback()
335 erase->mtd = part->mbd.mtd; erase_block()
344 rc = mtd_erase(part->mbd.mtd, erase); erase_block()
349 (unsigned long long)erase->len, part->mbd.mtd->name); erase_block()
374 rc = mtd_read(part->mbd.mtd, part->blocks[block_no].offset, move_block_contents()
382 "0x%lx\n", part->mbd.mtd->name, move_block_contents()
414 rc = mtd_read(part->mbd.mtd, addr, SECTOR_SIZE, &retlen, move_block_contents()
423 part->mbd.mtd->name); move_block_contents()
451 mtd_sync(part->mbd.mtd); reclaim_block()
563 rc = mtd_read(part->mbd.mtd, part->blocks[block].offset, find_writable_block()
572 "0x%lx\n", part->mbd.mtd->name, find_writable_block()
596 rc = mtd_write(part->mbd.mtd, addr, sizeof(del), &retlen, mark_sector_deleted()
604 "0x%lx\n", part->mbd.mtd->name, addr); mark_sector_deleted()
668 rc = mtd_write(part->mbd.mtd, addr, SECTOR_SIZE, &retlen, do_writesect()
676 part->mbd.mtd->name, addr); do_writesect()
687 rc = mtd_write(part->mbd.mtd, addr, sizeof(entry), &retlen, do_writesect()
695 part->mbd.mtd->name, addr); do_writesect()
757 static void rfd_ftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) rfd_ftl_add_mtd() argument
761 if (mtd->type != MTD_NORFLASH || mtd->size > UINT_MAX) rfd_ftl_add_mtd()
768 part->mbd.mtd = mtd; rfd_ftl_add_mtd()
773 if (!mtd->erasesize) { rfd_ftl_add_mtd()
777 part->block_size = mtd->erasesize; rfd_ftl_add_mtd()
784 if (!(mtd->flags & MTD_WRITEABLE)) rfd_ftl_add_mtd()
788 "setting read-only\n", mtd->name); rfd_ftl_add_mtd()
793 mtd->name, mtd->type, mtd->flags); rfd_ftl_add_mtd()
809 part->mbd.mtd->name, i, part->blocks[i].erases); rfd_ftl_remove_dev()
H A Dinftlmount.c33 #include <linux/mtd/mtd.h>
34 #include <linux/mtd/nftl.h>
35 #include <linux/mtd/inftl.h>
51 struct mtd_info *mtd = inftl->mbd.mtd; find_boot_record() local
62 inftl->EraseSize = inftl->mbd.mtd->erasesize; find_boot_record()
63 inftl->nb_blocks = (u32)inftl->mbd.mtd->size / inftl->EraseSize; find_boot_record()
75 ret = mtd_read(mtd, block * inftl->EraseSize, SECTORSIZE, find_boot_record()
84 "of mtd%d failed: %d\n", find_boot_record()
86 inftl->mbd.mtd->index, ret); find_boot_record()
101 ret = inftl_read_oob(mtd, find_boot_record()
106 "0x%x in mtd%d, but OOB data read failed " find_boot_record()
108 inftl->mbd.mtd->index, ret); find_boot_record()
120 mtd_read(mtd, block * inftl->EraseSize + 4096, SECTORSIZE, find_boot_record()
182 inftl->EraseSize = inftl->mbd.mtd->erasesize << find_boot_record()
184 inftl->nb_blocks = (u32)inftl->mbd.mtd->size / inftl->EraseSize; find_boot_record()
211 instr->mtd = inftl->mbd.mtd; find_boot_record()
222 mtd_erase(mtd, instr); find_boot_record()
307 for (physblock = 0; physblock < inftl->EraseSize; physblock += inftl->mbd.mtd->erasesize) { find_boot_record()
308 if (mtd_block_isbad(inftl->mbd.mtd, find_boot_record()
339 u8 buf[SECTORSIZE + inftl->mbd.mtd->oobsize]; check_free_sectors()
340 struct mtd_info *mtd = inftl->mbd.mtd; check_free_sectors() local
345 if (mtd_read(mtd, address, SECTORSIZE, &retlen, buf)) check_free_sectors()
351 if(inftl_read_oob(mtd, address, mtd->oobsize, check_free_sectors()
354 if (memcmpb(buf + SECTORSIZE, 0xff, mtd->oobsize) != 0) check_free_sectors()
377 struct mtd_info *mtd = inftl->mbd.mtd; INFTL_formatblock() local
388 instr->mtd = inftl->mbd.mtd; INFTL_formatblock()
390 instr->len = inftl->mbd.mtd->erasesize; INFTL_formatblock()
396 mtd_erase(inftl->mbd.mtd, instr); INFTL_formatblock()
420 if (inftl_write_oob(mtd, instr->addr + 8, 8, &retlen, (char *)&uci) < 0) INFTL_formatblock()
426 mtd_block_markbad(inftl->mbd.mtd, instr->addr); INFTL_formatblock()
539 struct mtd_info *mtd = s->mbd.mtd; INFTL_mount() local
597 if (inftl_read_oob(mtd, block * s->EraseSize + 8, INFTL_mount()
599 inftl_read_oob(mtd, block * s->EraseSize + INFTL_mount()
H A Dnftlmount.c27 #include <linux/mtd/mtd.h>
28 #include <linux/mtd/nand.h>
29 #include <linux/mtd/nftl.h>
45 struct mtd_info *mtd = nftl->mbd.mtd; find_boot_record() local
52 the mtd device accordingly. We could even get rid of find_boot_record()
54 nftl->EraseSize = nftl->mbd.mtd->erasesize; find_boot_record()
55 nftl->nb_blocks = (u32)nftl->mbd.mtd->size / nftl->EraseSize; find_boot_record()
66 ret = mtd_read(mtd, block * nftl->EraseSize, SECTORSIZE, find_boot_record()
74 printk(KERN_WARNING "Block read at 0x%x of mtd%d failed: %d\n", find_boot_record()
75 block * nftl->EraseSize, nftl->mbd.mtd->index, ret); find_boot_record()
85 printk(KERN_DEBUG "ANAND header not found at 0x%x in mtd%d\n", find_boot_record()
86 block * nftl->EraseSize, nftl->mbd.mtd->index); find_boot_record()
92 ret = nftl_read_oob(mtd, block * nftl->EraseSize + find_boot_record()
96 printk(KERN_WARNING "ANAND header found at 0x%x in mtd%d, but OOB data read failed (err %d)\n", find_boot_record()
97 block * nftl->EraseSize, nftl->mbd.mtd->index, ret); find_boot_record()
106 printk(KERN_NOTICE "ANAND header found at 0x%x in mtd%d, but erase mark not present (0x%04x,0x%04x instead)\n", find_boot_record()
107 block * nftl->EraseSize, nftl->mbd.mtd->index, find_boot_record()
113 ret = mtd->read(mtd, block * nftl->EraseSize, SECTORSIZE, find_boot_record()
116 printk(KERN_NOTICE "ANAND header found at 0x%x in mtd%d, but ECC read failed (err %d)\n", find_boot_record()
117 block * nftl->EraseSize, nftl->mbd.mtd->index, ret); find_boot_record()
123 printk(KERN_NOTICE "ANAND header found at 0x%x in mtd%d, but went away on reread!\n", find_boot_record()
124 block * nftl->EraseSize, nftl->mbd.mtd->index); find_boot_record()
162 erasesize based on UnitSizeFactor. So the erasesize we read from the mtd find_boot_record()
173 nftl->EraseSize = nftl->mbd.mtd->erasesize << (0xff - mh->UnitSizeFactor); find_boot_record()
174 nftl->nb_blocks = (u32)nftl->mbd.mtd->size / nftl->EraseSize; find_boot_record()
233 ret = mtd->read(nftl->mbd.mtd, find_boot_record()
249 if (mtd_block_isbad(nftl->mbd.mtd, find_boot_record()
276 u8 buf[SECTORSIZE + nftl->mbd.mtd->oobsize]; check_free_sectors()
277 struct mtd_info *mtd = nftl->mbd.mtd; check_free_sectors() local
282 if (mtd_read(mtd, address, SECTORSIZE, &retlen, buf)) check_free_sectors()
288 if(nftl_read_oob(mtd, address, mtd->oobsize, check_free_sectors()
291 if (memcmpb(buf + SECTORSIZE, 0xff, mtd->oobsize) != 0) check_free_sectors()
313 struct mtd_info *mtd = nftl->mbd.mtd; NFTL_formatblock() local
316 if (nftl_read_oob(mtd, block * nftl->EraseSize + SECTORSIZE + 8, NFTL_formatblock()
331 instr->mtd = nftl->mbd.mtd; NFTL_formatblock()
334 mtd_erase(mtd, instr); NFTL_formatblock()
356 if (nftl_write_oob(mtd, block * nftl->EraseSize + SECTORSIZE + NFTL_formatblock()
363 mtd_block_markbad(nftl->mbd.mtd, instr->addr); NFTL_formatblock()
378 struct mtd_info *mtd = nftl->mbd.mtd; check_sectors_in_chain() local
388 if (nftl_read_oob(mtd, check_sectors_in_chain()
409 nftl_write_oob(mtd, block * check_sectors_in_chain()
497 struct mtd_info *mtd = nftl->mbd.mtd; check_and_mark_free_block() local
503 if (nftl_read_oob(mtd, block * nftl->EraseSize + SECTORSIZE + 8, 8, check_and_mark_free_block()
518 if (nftl_write_oob(mtd, check_and_mark_free_block()
531 if (nftl_read_oob(mtd, block * nftl->EraseSize + i, check_and_mark_free_block()
558 struct mtd_info *mtd = nftl->mbd.mtd; get_fold_mark() local
562 if (nftl_read_oob(mtd, block * nftl->EraseSize + 2 * SECTORSIZE + 8, get_fold_mark()
577 struct mtd_info *mtd = s->mbd.mtd; NFTL_mount() local
602 if (nftl_read_oob(mtd, NFTL_mount()
605 nftl_read_oob(mtd, NFTL_mount()
H A Dmtd_blkdevs.c27 #include <linux/mtd/blktrans.h>
28 #include <linux/mtd/mtd.h>
208 if (!dev->mtd) blktrans_open()
217 ret = __get_mtd_device(dev->mtd); blktrans_open()
257 if (dev->mtd) { blktrans_release()
260 __put_mtd_device(dev->mtd); blktrans_release()
278 if (!dev->mtd) blktrans_getgeo()
299 if (!dev->mtd) blktrans_ioctl()
433 tr->name, new->mtd->index); add_mtd_blktrans_dev()
438 gd->driverfs_dev = &new->mtd->dev; add_mtd_blktrans_dev()
487 then put mtd device, and don't touch it again */ del_mtd_blktrans_dev()
492 __put_mtd_device(old->mtd); del_mtd_blktrans_dev()
495 old->mtd = NULL; del_mtd_blktrans_dev()
502 static void blktrans_notify_remove(struct mtd_info *mtd) blktrans_notify_remove() argument
509 if (dev->mtd == mtd) blktrans_notify_remove()
513 static void blktrans_notify_add(struct mtd_info *mtd) blktrans_notify_add() argument
517 if (mtd->type == MTD_ABSENT) blktrans_notify_add()
521 tr->add_mtd(tr, mtd); blktrans_notify_add()
531 struct mtd_info *mtd; register_mtd_blktrans() local
559 mtd_for_each_device(mtd) register_mtd_blktrans()
560 if (mtd->type != MTD_ABSENT) register_mtd_blktrans()
561 tr->add_mtd(tr, mtd); register_mtd_blktrans()
H A Dinftlcore.c33 #include <linux/mtd/mtd.h>
34 #include <linux/mtd/nftl.h>
35 #include <linux/mtd/inftl.h>
36 #include <linux/mtd/nand.h>
48 static void inftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) inftl_add_mtd() argument
53 if (!mtd_type_is_nand(mtd) || mtd->size > UINT_MAX) inftl_add_mtd()
56 if (memcmp(mtd->name, "DiskOnChip", 10)) inftl_add_mtd()
59 if (!mtd->_block_isbad) { inftl_add_mtd()
66 pr_debug("INFTL: add_mtd for %s\n", mtd->name); inftl_add_mtd()
73 inftl->mbd.mtd = mtd; inftl_add_mtd()
149 int inftl_read_oob(struct mtd_info *mtd, loff_t offs, size_t len, inftl_read_oob() argument
156 ops.ooboffs = offs & (mtd->writesize - 1); inftl_read_oob()
161 res = mtd_read_oob(mtd, offs & ~(mtd->writesize - 1), &ops); inftl_read_oob()
169 int inftl_write_oob(struct mtd_info *mtd, loff_t offs, size_t len, inftl_write_oob() argument
176 ops.ooboffs = offs & (mtd->writesize - 1); inftl_write_oob()
181 res = mtd_write_oob(mtd, offs & ~(mtd->writesize - 1), &ops); inftl_write_oob()
189 static int inftl_write(struct mtd_info *mtd, loff_t offs, size_t len, inftl_write() argument
197 ops.ooblen = mtd->oobsize; inftl_write()
202 res = mtd_write_oob(mtd, offs & ~(mtd->writesize - 1), &ops); inftl_write()
254 struct mtd_info *mtd = inftl->mbd.mtd; INFTL_foldchain() local
285 if (inftl_read_oob(mtd, (thisEUN * inftl->EraseSize) INFTL_foldchain()
346 ret = mtd_read(mtd, INFTL_foldchain()
352 ret = mtd_read(mtd, INFTL_foldchain()
363 inftl_write(inftl->mbd.mtd, (inftl->EraseSize * targetEUN) + INFTL_foldchain()
478 struct mtd_info *mtd = inftl->mbd.mtd; INFTL_findwriteunit() local
498 inftl_read_oob(mtd, (thisEUN * inftl->EraseSize) + INFTL_findwriteunit()
586 inftl_read_oob(mtd, thisEUN * inftl->EraseSize INFTL_findwriteunit()
608 inftl_write_oob(mtd, writeEUN * inftl->EraseSize + 8, 8, INFTL_findwriteunit()
619 inftl_write_oob(mtd, writeEUN * inftl->EraseSize + INFTL_findwriteunit()
640 struct mtd_info *mtd = inftl->mbd.mtd; INFTL_trydeletechain() local
671 if (inftl_read_oob(mtd, (thisEUN * inftl->EraseSize) INFTL_trydeletechain()
762 struct mtd_info *mtd = inftl->mbd.mtd; INFTL_deleteblock() local
772 if (inftl_read_oob(mtd, (thisEUN * inftl->EraseSize) + INFTL_deleteblock()
807 if (inftl_read_oob(mtd, ptr, 8, &retlen, (char *)&bci) < 0) INFTL_deleteblock()
810 if (inftl_write_oob(mtd, ptr, 8, &retlen, (char *)&bci) < 0) INFTL_deleteblock()
851 inftl_write(inftl->mbd.mtd, (writeEUN * inftl->EraseSize) + inftl_writeblock()
871 struct mtd_info *mtd = inftl->mbd.mtd; inftl_readblock() local
881 if (inftl_read_oob(mtd, (thisEUN * inftl->EraseSize) + inftl_readblock()
920 int ret = mtd_read(mtd, ptr, SECTORSIZE, &retlen, buffer); inftl_readblock()
H A Dcmdlinepart.c24 * <mtddef> := <mtd-id>:<partdef>[,<partdef>]
26 * <mtd-id> := unique name used in mapping driver/device (mtd->name)
34 * NAME will appear in /proc/mtd
53 #include <linux/mtd/mtd.h>
54 #include <linux/mtd/partitions.h>
59 #define ERRP "mtd: "
237 /* fetch <mtd-id> */ mtdpart_setup_real()
240 printk(KERN_ERR ERRP "no mtd-id\n"); mtdpart_setup_real()
248 * parse one mtd. have it reserve memory for the mtdpart_setup_real()
249 * struct cmdline_mtd_partition and the mtd-id string. mtdpart_setup_real()
263 * Either way, this mtd is hosed and we're mtdpart_setup_real()
305 * information. It returns partitions for the requested mtd device, or
H A Dnftlcore.c36 #include <linux/mtd/mtd.h>
37 #include <linux/mtd/nand.h>
38 #include <linux/mtd/nftl.h>
39 #include <linux/mtd/blktrans.h>
48 static void nftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) nftl_add_mtd() argument
53 if (!mtd_type_is_nand(mtd) || mtd->size > UINT_MAX) nftl_add_mtd()
56 if (memcmp(mtd->name, "DiskOnChip", 10)) nftl_add_mtd()
59 pr_debug("NFTL: add_mtd for %s\n", mtd->name); nftl_add_mtd()
66 nftl->mbd.mtd = mtd; nftl_add_mtd()
136 int nftl_read_oob(struct mtd_info *mtd, loff_t offs, size_t len, nftl_read_oob() argument
139 loff_t mask = mtd->writesize - 1; nftl_read_oob()
149 res = mtd_read_oob(mtd, offs & ~mask, &ops); nftl_read_oob()
157 int nftl_write_oob(struct mtd_info *mtd, loff_t offs, size_t len, nftl_write_oob() argument
160 loff_t mask = mtd->writesize - 1; nftl_write_oob()
170 res = mtd_write_oob(mtd, offs & ~mask, &ops); nftl_write_oob()
180 static int nftl_write(struct mtd_info *mtd, loff_t offs, size_t len, nftl_write() argument
183 loff_t mask = mtd->writesize - 1; nftl_write()
189 ops.ooblen = mtd->oobsize; nftl_write()
194 res = mtd_write_oob(mtd, offs & ~mask, &ops); nftl_write()
246 struct mtd_info *mtd = nftl->mbd.mtd; NFTL_foldchain() local
279 nftl_read_oob(mtd, (thisEUN * nftl->EraseSize) + NFTL_foldchain()
395 nftl_write_oob(mtd, (nftl->EraseSize * targetEUN) + 2 * 512 + 8, NFTL_foldchain()
419 ret = mtd_read(mtd, NFTL_foldchain()
425 ret = mtd_read(mtd, NFTL_foldchain()
436 nftl_write(nftl->mbd.mtd, (nftl->EraseSize * targetEUN) + NFTL_foldchain()
444 nftl_write_oob(mtd, (nftl->EraseSize * targetEUN) + 8, NFTL_foldchain()
539 struct mtd_info *mtd = nftl->mbd.mtd; NFTL_findwriteunit() local
564 nftl_read_oob(mtd, NFTL_findwriteunit()
653 nftl_read_oob(mtd, writeEUN * nftl->EraseSize + 8, 8, NFTL_findwriteunit()
658 nftl_write_oob(mtd, writeEUN * nftl->EraseSize + 8, 8, NFTL_findwriteunit()
668 nftl_read_oob(mtd, (lastEUN * nftl->EraseSize) + 8, NFTL_findwriteunit()
674 nftl_write_oob(mtd, (lastEUN * nftl->EraseSize) + 8, NFTL_findwriteunit()
708 nftl_write(nftl->mbd.mtd, (writeEUN * nftl->EraseSize) + blockofs, nftl_writeblock()
718 struct mtd_info *mtd = nftl->mbd.mtd; nftl_readblock() local
731 if (nftl_read_oob(mtd, (thisEUN * nftl->EraseSize) + nftl_readblock()
772 int res = mtd_read(mtd, ptr, 512, &retlen, buffer); nftl_readblock()
/linux-4.1.27/drivers/mtd/nand/bcm47xxnflash/
H A Dbcm47xxnflash.h8 #include <linux/mtd/mtd.h>
9 #include <linux/mtd/nand.h>
15 struct mtd_info mtd; member in struct:bcm47xxnflash
H A Dmain.c37 b47n->mtd.owner = THIS_MODULE; bcm47xxnflash_probe()
38 b47n->mtd.priv = &b47n->nand_chip; /* Required */ bcm47xxnflash_probe()
52 err = mtd_device_parse_register(&b47n->mtd, probes, NULL, NULL, 0); bcm47xxnflash_probe()
65 if (nflash->mtd) bcm47xxnflash_remove()
66 mtd_device_unregister(nflash->mtd); bcm47xxnflash_remove()
H A Dops_bcm4706.c89 static void bcm47xxnflash_ops_bcm4706_read(struct mtd_info *mtd, uint8_t *buf, bcm47xxnflash_ops_bcm4706_read() argument
92 struct nand_chip *nand_chip = (struct nand_chip *)mtd->priv; bcm47xxnflash_ops_bcm4706_read()
139 static void bcm47xxnflash_ops_bcm4706_write(struct mtd_info *mtd, bcm47xxnflash_ops_bcm4706_write() argument
142 struct nand_chip *nand_chip = (struct nand_chip *)mtd->priv; bcm47xxnflash_ops_bcm4706_write()
173 static void bcm47xxnflash_ops_bcm4706_cmd_ctrl(struct mtd_info *mtd, int cmd, bcm47xxnflash_ops_bcm4706_cmd_ctrl() argument
176 struct nand_chip *nand_chip = (struct nand_chip *)mtd->priv; bcm47xxnflash_ops_bcm4706_cmd_ctrl()
194 static void bcm47xxnflash_ops_bcm4706_select_chip(struct mtd_info *mtd, bcm47xxnflash_ops_bcm4706_select_chip() argument
200 static int bcm47xxnflash_ops_bcm4706_dev_ready(struct mtd_info *mtd) bcm47xxnflash_ops_bcm4706_dev_ready() argument
202 struct nand_chip *nand_chip = (struct nand_chip *)mtd->priv; bcm47xxnflash_ops_bcm4706_dev_ready()
215 static void bcm47xxnflash_ops_bcm4706_cmdfunc(struct mtd_info *mtd, bcm47xxnflash_ops_bcm4706_cmdfunc() argument
219 struct nand_chip *nand_chip = (struct nand_chip *)mtd->priv; bcm47xxnflash_ops_bcm4706_cmdfunc()
232 nand_chip->cmd_ctrl(mtd, command, NAND_CTRL_CLE); bcm47xxnflash_ops_bcm4706_cmdfunc()
235 nand_wait_ready(mtd); bcm47xxnflash_ops_bcm4706_cmdfunc()
274 b47n->curr_column += mtd->writesize; bcm47xxnflash_ops_bcm4706_cmdfunc()
313 static u8 bcm47xxnflash_ops_bcm4706_read_byte(struct mtd_info *mtd) bcm47xxnflash_ops_bcm4706_read_byte() argument
315 struct nand_chip *nand_chip = (struct nand_chip *)mtd->priv; bcm47xxnflash_ops_bcm4706_read_byte()
333 bcm47xxnflash_ops_bcm4706_read(mtd, (u8 *)&tmp, 4); bcm47xxnflash_ops_bcm4706_read_byte()
341 static void bcm47xxnflash_ops_bcm4706_read_buf(struct mtd_info *mtd, bcm47xxnflash_ops_bcm4706_read_buf() argument
344 struct nand_chip *nand_chip = (struct nand_chip *)mtd->priv; bcm47xxnflash_ops_bcm4706_read_buf()
350 bcm47xxnflash_ops_bcm4706_read(mtd, buf, len); bcm47xxnflash_ops_bcm4706_read_buf()
357 static void bcm47xxnflash_ops_bcm4706_write_buf(struct mtd_info *mtd, bcm47xxnflash_ops_bcm4706_write_buf() argument
360 struct nand_chip *nand_chip = (struct nand_chip *)mtd->priv; bcm47xxnflash_ops_bcm4706_write_buf()
365 bcm47xxnflash_ops_bcm4706_write(mtd, buf, len); bcm47xxnflash_ops_bcm4706_write_buf()
424 err = nand_scan(&b47n->mtd, 1); bcm47xxnflash_ops_bcm4706_init()
/linux-4.1.27/drivers/mtd/nand/
H A Dsocrates_nand.c2 * drivers/mtd/nand/socrates_nand.c
15 #include <linux/mtd/mtd.h>
16 #include <linux/mtd/nand.h>
17 #include <linux/mtd/partitions.h>
33 struct mtd_info mtd; member in struct:socrates_nand_host
40 * @mtd: MTD device structure
44 static void socrates_nand_write_buf(struct mtd_info *mtd, socrates_nand_write_buf() argument
48 struct nand_chip *this = mtd->priv; socrates_nand_write_buf()
60 * @mtd: MTD device structure
64 static void socrates_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) socrates_nand_read_buf() argument
67 struct nand_chip *this = mtd->priv; socrates_nand_read_buf()
82 * @mtd: MTD device structure
84 static uint8_t socrates_nand_read_byte(struct mtd_info *mtd) socrates_nand_read_byte() argument
87 socrates_nand_read_buf(mtd, &byte, sizeof(byte)); socrates_nand_read_byte()
93 * @mtd: MTD device structure
95 static uint16_t socrates_nand_read_word(struct mtd_info *mtd) socrates_nand_read_word() argument
98 socrates_nand_read_buf(mtd, (uint8_t *)&word, sizeof(word)); socrates_nand_read_word()
105 static void socrates_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, socrates_nand_cmd_ctrl() argument
108 struct nand_chip *nand_chip = mtd->priv; socrates_nand_cmd_ctrl()
131 static int socrates_nand_device_ready(struct mtd_info *mtd) socrates_nand_device_ready() argument
133 struct nand_chip *nand_chip = mtd->priv; socrates_nand_device_ready()
147 struct mtd_info *mtd; socrates_nand_probe() local
163 mtd = &host->mtd; socrates_nand_probe()
168 mtd->priv = nand_chip; socrates_nand_probe()
169 mtd->name = "socrates_nand"; socrates_nand_probe()
170 mtd->owner = THIS_MODULE; socrates_nand_probe()
171 mtd->dev.parent = &ofdev->dev; socrates_nand_probe()
193 if (nand_scan_ident(mtd, 1, NULL)) { socrates_nand_probe()
199 if (nand_scan_tail(mtd)) { socrates_nand_probe()
204 res = mtd_device_parse_register(mtd, NULL, &ppdata, NULL, 0); socrates_nand_probe()
208 nand_release(mtd); socrates_nand_probe()
221 struct mtd_info *mtd = &host->mtd; socrates_nand_remove() local
223 nand_release(mtd); socrates_nand_remove()
H A Dmpc5121_nfc.c10 * of drivers/mtd/nand/mxc_nand.c. Reworked and extended
35 #include <linux/mtd/mtd.h>
36 #include <linux/mtd/nand.h>
37 #include <linux/mtd/partitions.h>
121 struct mtd_info mtd; member in struct:mpc5121_nfc_prv
133 static void mpc5121_nfc_done(struct mtd_info *mtd);
136 static inline u16 nfc_read(struct mtd_info *mtd, uint reg) nfc_read() argument
138 struct nand_chip *chip = mtd->priv; nfc_read()
145 static inline void nfc_write(struct mtd_info *mtd, uint reg, u16 val) nfc_write() argument
147 struct nand_chip *chip = mtd->priv; nfc_write()
154 static inline void nfc_set(struct mtd_info *mtd, uint reg, u16 bits) nfc_set() argument
156 nfc_write(mtd, reg, nfc_read(mtd, reg) | bits); nfc_set()
160 static inline void nfc_clear(struct mtd_info *mtd, uint reg, u16 bits) nfc_clear() argument
162 nfc_write(mtd, reg, nfc_read(mtd, reg) & ~bits); nfc_clear()
166 static inline void mpc5121_nfc_send_addr(struct mtd_info *mtd, u16 addr) mpc5121_nfc_send_addr() argument
168 nfc_write(mtd, NFC_FLASH_ADDR, addr); mpc5121_nfc_send_addr()
169 nfc_write(mtd, NFC_CONFIG2, NFC_ADDRESS); mpc5121_nfc_send_addr()
170 mpc5121_nfc_done(mtd); mpc5121_nfc_send_addr()
174 static inline void mpc5121_nfc_send_cmd(struct mtd_info *mtd, u16 cmd) mpc5121_nfc_send_cmd() argument
176 nfc_write(mtd, NFC_FLASH_CMD, cmd); mpc5121_nfc_send_cmd()
177 nfc_write(mtd, NFC_CONFIG2, NFC_COMMAND); mpc5121_nfc_send_cmd()
178 mpc5121_nfc_done(mtd); mpc5121_nfc_send_cmd()
182 static inline void mpc5121_nfc_send_prog_page(struct mtd_info *mtd) mpc5121_nfc_send_prog_page() argument
184 nfc_clear(mtd, NFC_BUF_ADDR, NFC_RBA_MASK); mpc5121_nfc_send_prog_page()
185 nfc_write(mtd, NFC_CONFIG2, NFC_INPUT); mpc5121_nfc_send_prog_page()
186 mpc5121_nfc_done(mtd); mpc5121_nfc_send_prog_page()
190 static inline void mpc5121_nfc_send_read_page(struct mtd_info *mtd) mpc5121_nfc_send_read_page() argument
192 nfc_clear(mtd, NFC_BUF_ADDR, NFC_RBA_MASK); mpc5121_nfc_send_read_page()
193 nfc_write(mtd, NFC_CONFIG2, NFC_OUTPUT); mpc5121_nfc_send_read_page()
194 mpc5121_nfc_done(mtd); mpc5121_nfc_send_read_page()
198 static inline void mpc5121_nfc_send_read_id(struct mtd_info *mtd) mpc5121_nfc_send_read_id() argument
200 nfc_clear(mtd, NFC_BUF_ADDR, NFC_RBA_MASK); mpc5121_nfc_send_read_id()
201 nfc_write(mtd, NFC_CONFIG2, NFC_ID); mpc5121_nfc_send_read_id()
202 mpc5121_nfc_done(mtd); mpc5121_nfc_send_read_id()
206 static inline void mpc5121_nfc_send_read_status(struct mtd_info *mtd) mpc5121_nfc_send_read_status() argument
208 nfc_clear(mtd, NFC_BUF_ADDR, NFC_RBA_MASK); mpc5121_nfc_send_read_status()
209 nfc_write(mtd, NFC_CONFIG2, NFC_STATUS); mpc5121_nfc_send_read_status()
210 mpc5121_nfc_done(mtd); mpc5121_nfc_send_read_status()
216 struct mtd_info *mtd = data; mpc5121_nfc_irq() local
217 struct nand_chip *chip = mtd->priv; mpc5121_nfc_irq()
220 nfc_set(mtd, NFC_CONFIG1, NFC_INT_MASK); mpc5121_nfc_irq()
227 static void mpc5121_nfc_done(struct mtd_info *mtd) mpc5121_nfc_done() argument
229 struct nand_chip *chip = mtd->priv; mpc5121_nfc_done()
233 if ((nfc_read(mtd, NFC_CONFIG2) & NFC_INT) == 0) { mpc5121_nfc_done()
234 nfc_clear(mtd, NFC_CONFIG1, NFC_INT_MASK); mpc5121_nfc_done()
236 (nfc_read(mtd, NFC_CONFIG2) & NFC_INT), NFC_TIMEOUT); mpc5121_nfc_done()
243 nfc_clear(mtd, NFC_CONFIG2, NFC_INT); mpc5121_nfc_done()
247 static void mpc5121_nfc_addr_cycle(struct mtd_info *mtd, int column, int page) mpc5121_nfc_addr_cycle() argument
249 struct nand_chip *chip = mtd->priv; mpc5121_nfc_addr_cycle()
253 mpc5121_nfc_send_addr(mtd, column); mpc5121_nfc_addr_cycle()
254 if (mtd->writesize > 512) mpc5121_nfc_addr_cycle()
255 mpc5121_nfc_send_addr(mtd, column >> 8); mpc5121_nfc_addr_cycle()
260 mpc5121_nfc_send_addr(mtd, page & 0xFF); mpc5121_nfc_addr_cycle()
268 static void mpc5121_nfc_select_chip(struct mtd_info *mtd, int chip) mpc5121_nfc_select_chip() argument
271 nfc_clear(mtd, NFC_CONFIG1, NFC_CE); mpc5121_nfc_select_chip()
275 nfc_clear(mtd, NFC_BUF_ADDR, NFC_ACTIVE_CS_MASK); mpc5121_nfc_select_chip()
276 nfc_set(mtd, NFC_BUF_ADDR, (chip << NFC_ACTIVE_CS_SHIFT) & mpc5121_nfc_select_chip()
278 nfc_set(mtd, NFC_CONFIG1, NFC_CE); mpc5121_nfc_select_chip()
282 static int ads5121_chipselect_init(struct mtd_info *mtd) ads5121_chipselect_init() argument
284 struct nand_chip *chip = mtd->priv; ads5121_chipselect_init()
304 static void ads5121_select_chip(struct mtd_info *mtd, int chip) ads5121_select_chip() argument
306 struct nand_chip *nand = mtd->priv; ads5121_select_chip()
314 mpc5121_nfc_select_chip(mtd, 0); ads5121_select_chip()
317 mpc5121_nfc_select_chip(mtd, -1); ads5121_select_chip()
323 static int mpc5121_nfc_dev_ready(struct mtd_info *mtd) mpc5121_nfc_dev_ready() argument
333 static void mpc5121_nfc_command(struct mtd_info *mtd, unsigned command, mpc5121_nfc_command() argument
336 struct nand_chip *chip = mtd->priv; mpc5121_nfc_command()
344 mpc5121_nfc_send_prog_page(mtd); mpc5121_nfc_command()
367 mpc5121_nfc_command(mtd, NAND_CMD_READ0, column, page); mpc5121_nfc_command()
381 mpc5121_nfc_send_cmd(mtd, command); mpc5121_nfc_command()
382 mpc5121_nfc_addr_cycle(mtd, column, page); mpc5121_nfc_command()
386 if (mtd->writesize > 512) mpc5121_nfc_command()
387 mpc5121_nfc_send_cmd(mtd, NAND_CMD_READSTART); mpc5121_nfc_command()
388 mpc5121_nfc_send_read_page(mtd); mpc5121_nfc_command()
392 mpc5121_nfc_send_read_id(mtd); mpc5121_nfc_command()
396 mpc5121_nfc_send_read_status(mtd); mpc5121_nfc_command()
406 static void mpc5121_nfc_copy_spare(struct mtd_info *mtd, uint offset, mpc5121_nfc_copy_spare() argument
409 struct nand_chip *nand = mtd->priv; mpc5121_nfc_copy_spare()
429 sbsize = (mtd->oobsize / (mtd->writesize / 512)) & ~1; mpc5121_nfc_copy_spare()
458 static void mpc5121_nfc_buf_copy(struct mtd_info *mtd, u_char *buf, int len, mpc5121_nfc_buf_copy() argument
461 struct nand_chip *chip = mtd->priv; mpc5121_nfc_buf_copy()
467 if (prv->spareonly || c >= mtd->writesize) { mpc5121_nfc_buf_copy()
469 if (c >= mtd->writesize) mpc5121_nfc_buf_copy()
470 c -= mtd->writesize; mpc5121_nfc_buf_copy()
473 mpc5121_nfc_copy_spare(mtd, c, buf, len, wr); mpc5121_nfc_buf_copy()
481 l = min((uint)len, mtd->writesize - c); mpc5121_nfc_buf_copy()
493 mpc5121_nfc_buf_copy(mtd, buf, len, wr); mpc5121_nfc_buf_copy()
498 static void mpc5121_nfc_read_buf(struct mtd_info *mtd, u_char *buf, int len) mpc5121_nfc_read_buf() argument
500 mpc5121_nfc_buf_copy(mtd, buf, len, 0); mpc5121_nfc_read_buf()
504 static void mpc5121_nfc_write_buf(struct mtd_info *mtd, mpc5121_nfc_write_buf() argument
507 mpc5121_nfc_buf_copy(mtd, (u_char *)buf, len, 1); mpc5121_nfc_write_buf()
511 static u8 mpc5121_nfc_read_byte(struct mtd_info *mtd) mpc5121_nfc_read_byte() argument
515 mpc5121_nfc_read_buf(mtd, &tmp, sizeof(tmp)); mpc5121_nfc_read_byte()
521 static u16 mpc5121_nfc_read_word(struct mtd_info *mtd) mpc5121_nfc_read_word() argument
525 mpc5121_nfc_read_buf(mtd, (u_char *)&tmp, sizeof(tmp)); mpc5121_nfc_read_word()
537 static int mpc5121_nfc_read_hw_config(struct mtd_info *mtd) mpc5121_nfc_read_hw_config() argument
539 struct nand_chip *chip = mtd->priv; mpc5121_nfc_read_hw_config()
599 mtd->writesize = rcw_pagesize; mpc5121_nfc_read_hw_config()
600 mtd->oobsize = rcw_sparesize; mpc5121_nfc_read_hw_config()
616 static void mpc5121_nfc_free(struct device *dev, struct mtd_info *mtd) mpc5121_nfc_free() argument
618 struct nand_chip *chip = mtd->priv; mpc5121_nfc_free()
635 struct mtd_info *mtd; mpc5121_nfc_probe() local
658 mtd = &prv->mtd; mpc5121_nfc_probe()
661 mtd->priv = chip; mpc5121_nfc_probe()
666 retval = mpc5121_nfc_read_hw_config(mtd); mpc5121_nfc_probe()
704 mtd->name = "MPC5121 NAND"; mpc5121_nfc_probe()
719 retval = ads5121_chipselect_init(mtd); mpc5121_nfc_probe()
745 nfc_set(mtd, NFC_CONFIG1, NFC_RESET); mpc5121_nfc_probe()
746 while (nfc_read(mtd, NFC_CONFIG1) & NFC_RESET) { mpc5121_nfc_probe()
757 nfc_write(mtd, NFC_CONFIG, NFC_BLS_UNLOCKED); mpc5121_nfc_probe()
760 nfc_write(mtd, NFC_UNLOCKSTART_BLK0, 0x0000); mpc5121_nfc_probe()
761 nfc_write(mtd, NFC_UNLOCKEND_BLK0, 0xFFFF); mpc5121_nfc_probe()
762 nfc_write(mtd, NFC_WRPROT, NFC_WPC_UNLOCK); mpc5121_nfc_probe()
769 nfc_write(mtd, NFC_CONFIG1, NFC_BIG_ENDIAN | NFC_INT_MASK | mpc5121_nfc_probe()
773 nfc_write(mtd, NFC_SPAS, mtd->oobsize >> 1); mpc5121_nfc_probe()
777 mtd); mpc5121_nfc_probe()
784 if (nand_scan(mtd, be32_to_cpup(chips_no))) { mpc5121_nfc_probe()
791 switch (mtd->erasesize / mtd->writesize) { mpc5121_nfc_probe()
793 nfc_set(mtd, NFC_CONFIG1, NFC_PPB_32); mpc5121_nfc_probe()
797 nfc_set(mtd, NFC_CONFIG1, NFC_PPB_64); mpc5121_nfc_probe()
801 nfc_set(mtd, NFC_CONFIG1, NFC_PPB_128); mpc5121_nfc_probe()
805 nfc_set(mtd, NFC_CONFIG1, NFC_PPB_256); mpc5121_nfc_probe()
814 dev_set_drvdata(dev, mtd); mpc5121_nfc_probe()
817 retval = mtd_device_parse_register(mtd, NULL, &ppdata, NULL, 0); mpc5121_nfc_probe()
825 mpc5121_nfc_free(dev, mtd); mpc5121_nfc_probe()
832 struct mtd_info *mtd = dev_get_drvdata(dev); mpc5121_nfc_remove() local
834 nand_release(mtd); mpc5121_nfc_remove()
835 mpc5121_nfc_free(dev, mtd); mpc5121_nfc_remove()
H A Dnand_base.c2 * drivers/mtd/nand.c
9 * http://www.linux-mtd.infradead.org/doc/nand.html
22 * Check, if mtd->ecctype should be set to MTD_ECC_HW
42 #include <linux/mtd/mtd.h>
43 #include <linux/mtd/nand.h>
44 #include <linux/mtd/nand_ecc.h>
45 #include <linux/mtd/nand_bch.h>
50 #include <linux/mtd/partitions.h>
96 static int nand_get_device(struct mtd_info *mtd, int new_state);
98 static int nand_do_write_oob(struct mtd_info *mtd, loff_t to,
107 static int check_offs_len(struct mtd_info *mtd, check_offs_len() argument
110 struct nand_chip *chip = mtd->priv; check_offs_len()
130 * @mtd: MTD device structure
134 static void nand_release_device(struct mtd_info *mtd) nand_release_device() argument
136 struct nand_chip *chip = mtd->priv; nand_release_device()
148 * @mtd: MTD device structure
152 static uint8_t nand_read_byte(struct mtd_info *mtd) nand_read_byte() argument
154 struct nand_chip *chip = mtd->priv; nand_read_byte()
160 * @mtd: MTD device structure
165 static uint8_t nand_read_byte16(struct mtd_info *mtd) nand_read_byte16() argument
167 struct nand_chip *chip = mtd->priv; nand_read_byte16()
173 * @mtd: MTD device structure
177 static u16 nand_read_word(struct mtd_info *mtd) nand_read_word() argument
179 struct nand_chip *chip = mtd->priv; nand_read_word()
185 * @mtd: MTD device structure
190 static void nand_select_chip(struct mtd_info *mtd, int chipnr) nand_select_chip() argument
192 struct nand_chip *chip = mtd->priv; nand_select_chip()
196 chip->cmd_ctrl(mtd, NAND_CMD_NONE, 0 | NAND_CTRL_CHANGE); nand_select_chip()
208 * @mtd: MTD device structure
213 static void nand_write_byte(struct mtd_info *mtd, uint8_t byte) nand_write_byte() argument
215 struct nand_chip *chip = mtd->priv; nand_write_byte()
217 chip->write_buf(mtd, &byte, 1); nand_write_byte()
222 * @mtd: MTD device structure
227 static void nand_write_byte16(struct mtd_info *mtd, uint8_t byte) nand_write_byte16() argument
229 struct nand_chip *chip = mtd->priv; nand_write_byte16()
248 chip->write_buf(mtd, (uint8_t *)&word, 2); nand_write_byte16()
253 * @mtd: MTD device structure
259 static void nand_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) nand_write_buf() argument
261 struct nand_chip *chip = mtd->priv; nand_write_buf()
268 * @mtd: MTD device structure
274 static void nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) nand_read_buf() argument
276 struct nand_chip *chip = mtd->priv; nand_read_buf()
283 * @mtd: MTD device structure
289 static void nand_write_buf16(struct mtd_info *mtd, const uint8_t *buf, int len) nand_write_buf16() argument
291 struct nand_chip *chip = mtd->priv; nand_write_buf16()
299 * @mtd: MTD device structure
305 static void nand_read_buf16(struct mtd_info *mtd, uint8_t *buf, int len) nand_read_buf16() argument
307 struct nand_chip *chip = mtd->priv; nand_read_buf16()
315 * @mtd: MTD device structure
321 static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip) nand_block_bad() argument
324 struct nand_chip *chip = mtd->priv; nand_block_bad()
328 ofs += mtd->erasesize - mtd->writesize; nand_block_bad()
335 nand_get_device(mtd, FL_READING); nand_block_bad()
338 chip->select_chip(mtd, chipnr); nand_block_bad()
343 chip->cmdfunc(mtd, NAND_CMD_READOOB, nand_block_bad()
345 bad = cpu_to_le16(chip->read_word(mtd)); nand_block_bad()
351 chip->cmdfunc(mtd, NAND_CMD_READOOB, chip->badblockpos, nand_block_bad()
353 bad = chip->read_byte(mtd); nand_block_bad()
360 ofs += mtd->writesize; nand_block_bad()
366 chip->select_chip(mtd, -1); nand_block_bad()
367 nand_release_device(mtd); nand_block_bad()
375 * @mtd: MTD device structure
382 static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs) nand_default_block_markbad() argument
384 struct nand_chip *chip = mtd->priv; nand_default_block_markbad()
402 ofs += mtd->erasesize - mtd->writesize; nand_default_block_markbad()
404 res = nand_do_write_oob(mtd, ofs, &ops); nand_default_block_markbad()
409 ofs += mtd->writesize; nand_default_block_markbad()
417 * @mtd: MTD device structure
432 static int nand_block_markbad_lowlevel(struct mtd_info *mtd, loff_t ofs) nand_block_markbad_lowlevel() argument
434 struct nand_chip *chip = mtd->priv; nand_block_markbad_lowlevel()
442 einfo.mtd = mtd; nand_block_markbad_lowlevel()
445 nand_erase_nand(mtd, &einfo, 0); nand_block_markbad_lowlevel()
448 nand_get_device(mtd, FL_WRITING); nand_block_markbad_lowlevel()
449 ret = chip->block_markbad(mtd, ofs); nand_block_markbad_lowlevel()
450 nand_release_device(mtd); nand_block_markbad_lowlevel()
455 res = nand_markbad_bbt(mtd, ofs); nand_block_markbad_lowlevel()
461 mtd->ecc_stats.badblocks++; nand_block_markbad_lowlevel()
468 * @mtd: MTD device structure
473 static int nand_check_wp(struct mtd_info *mtd) nand_check_wp() argument
475 struct nand_chip *chip = mtd->priv; nand_check_wp()
482 chip->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1); nand_check_wp()
483 return (chip->read_byte(mtd) & NAND_STATUS_WP) ? 0 : 1; nand_check_wp()
488 * @mtd: MTD device structure
493 static int nand_block_isreserved(struct mtd_info *mtd, loff_t ofs) nand_block_isreserved() argument
495 struct nand_chip *chip = mtd->priv; nand_block_isreserved()
500 return nand_isreserved_bbt(mtd, ofs); nand_block_isreserved()
505 * @mtd: MTD device structure
513 static int nand_block_checkbad(struct mtd_info *mtd, loff_t ofs, int getchip, nand_block_checkbad() argument
516 struct nand_chip *chip = mtd->priv; nand_block_checkbad()
519 return chip->block_bad(mtd, ofs, getchip); nand_block_checkbad()
522 return nand_isbad_bbt(mtd, ofs, allowbbt); nand_block_checkbad()
527 * @mtd: MTD device structure
533 static void panic_nand_wait_ready(struct mtd_info *mtd, unsigned long timeo) panic_nand_wait_ready() argument
535 struct nand_chip *chip = mtd->priv; panic_nand_wait_ready()
540 if (chip->dev_ready(mtd)) panic_nand_wait_ready()
548 void nand_wait_ready(struct mtd_info *mtd) nand_wait_ready() argument
550 struct nand_chip *chip = mtd->priv; nand_wait_ready()
555 return panic_nand_wait_ready(mtd, 400); nand_wait_ready()
560 if (chip->dev_ready(mtd)) nand_wait_ready()
570 * @mtd: MTD device structure
575 static void nand_wait_status_ready(struct mtd_info *mtd, unsigned long timeo) nand_wait_status_ready() argument
577 register struct nand_chip *chip = mtd->priv; nand_wait_status_ready()
581 if ((chip->read_byte(mtd) & NAND_STATUS_READY)) nand_wait_status_ready()
589 * @mtd: MTD device structure
597 static void nand_command(struct mtd_info *mtd, unsigned int command, nand_command() argument
600 register struct nand_chip *chip = mtd->priv; nand_command()
607 if (column >= mtd->writesize) { nand_command()
609 column -= mtd->writesize; nand_command()
618 chip->cmd_ctrl(mtd, readcmd, ctrl); nand_command()
621 chip->cmd_ctrl(mtd, command, ctrl); nand_command()
631 chip->cmd_ctrl(mtd, column, ctrl); nand_command()
635 chip->cmd_ctrl(mtd, page_addr, ctrl); nand_command()
637 chip->cmd_ctrl(mtd, page_addr >> 8, ctrl); nand_command()
640 chip->cmd_ctrl(mtd, page_addr >> 16, ctrl); nand_command()
642 chip->cmd_ctrl(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); nand_command()
661 chip->cmd_ctrl(mtd, NAND_CMD_STATUS, nand_command()
663 chip->cmd_ctrl(mtd, nand_command()
666 nand_wait_status_ready(mtd, 250); nand_command()
686 nand_wait_ready(mtd); nand_command()
691 * @mtd: MTD device structure
700 static void nand_command_lp(struct mtd_info *mtd, unsigned int command, nand_command_lp() argument
703 register struct nand_chip *chip = mtd->priv; nand_command_lp()
707 column += mtd->writesize; nand_command_lp()
712 chip->cmd_ctrl(mtd, command, NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE); nand_command_lp()
723 chip->cmd_ctrl(mtd, column, ctrl); nand_command_lp()
725 chip->cmd_ctrl(mtd, column >> 8, ctrl); nand_command_lp()
728 chip->cmd_ctrl(mtd, page_addr, ctrl); nand_command_lp()
729 chip->cmd_ctrl(mtd, page_addr >> 8, nand_command_lp()
733 chip->cmd_ctrl(mtd, page_addr >> 16, nand_command_lp()
737 chip->cmd_ctrl(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); nand_command_lp()
758 chip->cmd_ctrl(mtd, NAND_CMD_STATUS, nand_command_lp()
760 chip->cmd_ctrl(mtd, NAND_CMD_NONE, nand_command_lp()
763 nand_wait_status_ready(mtd, 250); nand_command_lp()
768 chip->cmd_ctrl(mtd, NAND_CMD_RNDOUTSTART, nand_command_lp()
770 chip->cmd_ctrl(mtd, NAND_CMD_NONE, nand_command_lp()
775 chip->cmd_ctrl(mtd, NAND_CMD_READSTART, nand_command_lp()
777 chip->cmd_ctrl(mtd, NAND_CMD_NONE, nand_command_lp()
798 nand_wait_ready(mtd); nand_command_lp()
804 * @mtd: MTD device structure
810 struct mtd_info *mtd, int new_state) panic_nand_get_device()
819 * @mtd: MTD device structure
825 nand_get_device(struct mtd_info *mtd, int new_state) nand_get_device() argument
827 struct nand_chip *chip = mtd->priv; nand_get_device()
860 * @mtd: MTD device structure
868 static void panic_nand_wait(struct mtd_info *mtd, struct nand_chip *chip, panic_nand_wait() argument
874 if (chip->dev_ready(mtd)) panic_nand_wait()
877 if (chip->read_byte(mtd) & NAND_STATUS_READY) panic_nand_wait()
886 * @mtd: MTD device structure
893 static int nand_wait(struct mtd_info *mtd, struct nand_chip *chip) nand_wait() argument
907 chip->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1); nand_wait()
910 panic_nand_wait(mtd, chip, timeo); nand_wait()
915 if (chip->dev_ready(mtd)) nand_wait()
918 if (chip->read_byte(mtd) & NAND_STATUS_READY) nand_wait()
926 status = (int)chip->read_byte(mtd); nand_wait()
934 * @mtd: mtd info
944 static int __nand_unlock(struct mtd_info *mtd, loff_t ofs, __nand_unlock() argument
949 struct nand_chip *chip = mtd->priv; __nand_unlock()
953 chip->cmdfunc(mtd, NAND_CMD_UNLOCK1, -1, page & chip->pagemask); __nand_unlock()
957 chip->cmdfunc(mtd, NAND_CMD_UNLOCK2, -1, __nand_unlock()
961 status = chip->waitfunc(mtd, chip); __nand_unlock()
974 * @mtd: mtd info
980 int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) nand_unlock() argument
984 struct nand_chip *chip = mtd->priv; nand_unlock()
989 if (check_offs_len(mtd, ofs, len)) nand_unlock()
993 if (ofs + len == mtd->size) nand_unlock()
994 len -= mtd->erasesize; nand_unlock()
996 nand_get_device(mtd, FL_UNLOCKING); nand_unlock()
1001 chip->select_chip(mtd, chipnr); nand_unlock()
1010 chip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1); nand_unlock()
1013 if (nand_check_wp(mtd)) { nand_unlock()
1020 ret = __nand_unlock(mtd, ofs, len, 0); nand_unlock()
1023 chip->select_chip(mtd, -1); nand_unlock()
1024 nand_release_device(mtd); nand_unlock()
1032 * @mtd: mtd info
1043 int nand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) nand_lock() argument
1047 struct nand_chip *chip = mtd->priv; nand_lock()
1052 if (check_offs_len(mtd, ofs, len)) nand_lock()
1055 nand_get_device(mtd, FL_LOCKING); nand_lock()
1060 chip->select_chip(mtd, chipnr); nand_lock()
1069 chip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1); nand_lock()
1072 if (nand_check_wp(mtd)) { nand_lock()
1082 chip->cmdfunc(mtd, NAND_CMD_LOCK, -1, page & chip->pagemask); nand_lock()
1085 status = chip->waitfunc(mtd, chip); nand_lock()
1094 ret = __nand_unlock(mtd, ofs, len, 0x1); nand_lock()
1097 chip->select_chip(mtd, -1); nand_lock()
1098 nand_release_device(mtd); nand_lock()
1106 * @mtd: mtd info structure
1114 static int nand_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip, nand_read_page_raw() argument
1117 chip->read_buf(mtd, buf, mtd->writesize); nand_read_page_raw()
1119 chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); nand_read_page_raw()
1125 * @mtd: mtd info structure
1133 static int nand_read_page_raw_syndrome(struct mtd_info *mtd, nand_read_page_raw_syndrome() argument
1143 chip->read_buf(mtd, buf, eccsize); nand_read_page_raw_syndrome()
1147 chip->read_buf(mtd, oob, chip->ecc.prepad); nand_read_page_raw_syndrome()
1151 chip->read_buf(mtd, oob, eccbytes); nand_read_page_raw_syndrome()
1155 chip->read_buf(mtd, oob, chip->ecc.postpad); nand_read_page_raw_syndrome()
1160 size = mtd->oobsize - (oob - chip->oob_poi); nand_read_page_raw_syndrome()
1162 chip->read_buf(mtd, oob, size); nand_read_page_raw_syndrome()
1169 * @mtd: mtd info structure
1175 static int nand_read_page_swecc(struct mtd_info *mtd, struct nand_chip *chip, nand_read_page_swecc() argument
1187 chip->ecc.read_page_raw(mtd, chip, buf, 1, page); nand_read_page_swecc()
1190 chip->ecc.calculate(mtd, p, &ecc_calc[i]); nand_read_page_swecc()
1201 stat = chip->ecc.correct(mtd, p, &ecc_code[i], &ecc_calc[i]); nand_read_page_swecc()
1203 mtd->ecc_stats.failed++; nand_read_page_swecc()
1205 mtd->ecc_stats.corrected += stat; nand_read_page_swecc()
1214 * @mtd: mtd info structure
1221 static int nand_read_subpage(struct mtd_info *mtd, struct nand_chip *chip, nand_read_subpage() argument
1247 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, data_col_addr, -1); nand_read_subpage()
1250 chip->read_buf(mtd, p, datafrag_len); nand_read_subpage()
1254 chip->ecc.calculate(mtd, p, &chip->buffers->ecccalc[i]); nand_read_subpage()
1267 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, mtd->writesize, -1); nand_read_subpage()
1268 chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); nand_read_subpage()
1281 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, nand_read_subpage()
1282 mtd->writesize + aligned_pos, -1); nand_read_subpage()
1283 chip->read_buf(mtd, &chip->oob_poi[aligned_pos], aligned_len); nand_read_subpage()
1293 stat = chip->ecc.correct(mtd, p, nand_read_subpage()
1296 mtd->ecc_stats.failed++; nand_read_subpage()
1298 mtd->ecc_stats.corrected += stat; nand_read_subpage()
1307 * @mtd: mtd info structure
1315 static int nand_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, nand_read_page_hwecc() argument
1328 chip->ecc.hwctl(mtd, NAND_ECC_READ); nand_read_page_hwecc()
1329 chip->read_buf(mtd, p, eccsize); nand_read_page_hwecc()
1330 chip->ecc.calculate(mtd, p, &ecc_calc[i]); nand_read_page_hwecc()
1332 chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); nand_read_page_hwecc()
1343 stat = chip->ecc.correct(mtd, p, &ecc_code[i], &ecc_calc[i]); nand_read_page_hwecc()
1345 mtd->ecc_stats.failed++; nand_read_page_hwecc()
1347 mtd->ecc_stats.corrected += stat; nand_read_page_hwecc()
1356 * @mtd: mtd info structure
1368 static int nand_read_page_hwecc_oob_first(struct mtd_info *mtd, nand_read_page_hwecc_oob_first() argument
1381 chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page); nand_read_page_hwecc_oob_first()
1382 chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); nand_read_page_hwecc_oob_first()
1383 chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page); nand_read_page_hwecc_oob_first()
1391 chip->ecc.hwctl(mtd, NAND_ECC_READ); nand_read_page_hwecc_oob_first()
1392 chip->read_buf(mtd, p, eccsize); nand_read_page_hwecc_oob_first()
1393 chip->ecc.calculate(mtd, p, &ecc_calc[i]); nand_read_page_hwecc_oob_first()
1395 stat = chip->ecc.correct(mtd, p, &ecc_code[i], NULL); nand_read_page_hwecc_oob_first()
1397 mtd->ecc_stats.failed++; nand_read_page_hwecc_oob_first()
1399 mtd->ecc_stats.corrected += stat; nand_read_page_hwecc_oob_first()
1408 * @mtd: mtd info structure
1417 static int nand_read_page_syndrome(struct mtd_info *mtd, struct nand_chip *chip, nand_read_page_syndrome() argument
1430 chip->ecc.hwctl(mtd, NAND_ECC_READ); nand_read_page_syndrome()
1431 chip->read_buf(mtd, p, eccsize); nand_read_page_syndrome()
1434 chip->read_buf(mtd, oob, chip->ecc.prepad); nand_read_page_syndrome()
1438 chip->ecc.hwctl(mtd, NAND_ECC_READSYN); nand_read_page_syndrome()
1439 chip->read_buf(mtd, oob, eccbytes); nand_read_page_syndrome()
1440 stat = chip->ecc.correct(mtd, p, oob, NULL); nand_read_page_syndrome()
1443 mtd->ecc_stats.failed++; nand_read_page_syndrome()
1445 mtd->ecc_stats.corrected += stat; nand_read_page_syndrome()
1452 chip->read_buf(mtd, oob, chip->ecc.postpad); nand_read_page_syndrome()
1458 i = mtd->oobsize - (oob - chip->oob_poi); nand_read_page_syndrome()
1460 chip->read_buf(mtd, oob, i); nand_read_page_syndrome()
1515 * @mtd: MTD device structure
1522 static int nand_setup_read_retry(struct mtd_info *mtd, int retry_mode) nand_setup_read_retry() argument
1524 struct nand_chip *chip = mtd->priv; nand_setup_read_retry()
1534 return chip->setup_read_retry(mtd, retry_mode); nand_setup_read_retry()
1539 * @mtd: MTD device structure
1545 static int nand_do_read_ops(struct mtd_info *mtd, loff_t from, nand_do_read_ops() argument
1549 struct nand_chip *chip = mtd->priv; nand_do_read_ops()
1554 mtd->oobavail : mtd->oobsize; nand_do_read_ops()
1563 chip->select_chip(mtd, chipnr); nand_do_read_ops()
1568 col = (int)(from & (mtd->writesize - 1)); nand_do_read_ops()
1575 unsigned int ecc_failures = mtd->ecc_stats.failed; nand_do_read_ops()
1577 bytes = min(mtd->writesize - col, readlen); nand_do_read_ops()
1578 aligned = (bytes == mtd->writesize); nand_do_read_ops()
1596 chip->cmdfunc(mtd, NAND_CMD_READ0, 0x00, page); nand_do_read_ops()
1603 ret = chip->ecc.read_page_raw(mtd, chip, bufpoi, nand_do_read_ops()
1608 ret = chip->ecc.read_subpage(mtd, chip, nand_do_read_ops()
1612 ret = chip->ecc.read_page(mtd, chip, bufpoi, nand_do_read_ops()
1626 !(mtd->ecc_stats.failed - ecc_failures) && nand_do_read_ops()
1652 nand_wait_ready(mtd); nand_do_read_ops()
1655 if (mtd->ecc_stats.failed - ecc_failures) { nand_do_read_ops()
1658 ret = nand_setup_read_retry(mtd, nand_do_read_ops()
1664 mtd->ecc_stats.failed = ecc_failures; nand_do_read_ops()
1684 ret = nand_setup_read_retry(mtd, 0); nand_do_read_ops()
1702 chip->select_chip(mtd, -1); nand_do_read_ops()
1703 chip->select_chip(mtd, chipnr); nand_do_read_ops()
1706 chip->select_chip(mtd, -1); nand_do_read_ops()
1723 * @mtd: MTD device structure
1731 static int nand_read(struct mtd_info *mtd, loff_t from, size_t len, nand_read() argument
1737 nand_get_device(mtd, FL_READING); nand_read()
1742 ret = nand_do_read_ops(mtd, from, &ops); nand_read()
1744 nand_release_device(mtd); nand_read()
1750 * @mtd: mtd info structure
1754 static int nand_read_oob_std(struct mtd_info *mtd, struct nand_chip *chip, nand_read_oob_std() argument
1757 chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page); nand_read_oob_std()
1758 chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); nand_read_oob_std()
1765 * @mtd: mtd info structure
1769 static int nand_read_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip, nand_read_oob_syndrome() argument
1772 int length = mtd->oobsize; nand_read_oob_syndrome()
1778 chip->cmdfunc(mtd, NAND_CMD_READ0, chip->ecc.size, page); nand_read_oob_syndrome()
1782 if (mtd->writesize > 512) nand_read_oob_syndrome()
1783 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, pos, -1); nand_read_oob_syndrome()
1785 chip->cmdfunc(mtd, NAND_CMD_READ0, pos, page); nand_read_oob_syndrome()
1789 chip->read_buf(mtd, bufpoi, toread); nand_read_oob_syndrome()
1794 chip->read_buf(mtd, bufpoi, length); nand_read_oob_syndrome()
1801 * @mtd: mtd info structure
1805 static int nand_write_oob_std(struct mtd_info *mtd, struct nand_chip *chip, nand_write_oob_std() argument
1810 int length = mtd->oobsize; nand_write_oob_std()
1812 chip->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->writesize, page); nand_write_oob_std()
1813 chip->write_buf(mtd, buf, length); nand_write_oob_std()
1815 chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1); nand_write_oob_std()
1817 status = chip->waitfunc(mtd, chip); nand_write_oob_std()
1825 * @mtd: mtd info structure
1829 static int nand_write_oob_syndrome(struct mtd_info *mtd, nand_write_oob_syndrome() argument
1833 int eccsize = chip->ecc.size, length = mtd->oobsize; nand_write_oob_syndrome()
1848 chip->cmdfunc(mtd, NAND_CMD_SEQIN, pos, page); nand_write_oob_syndrome()
1851 if (mtd->writesize <= 512) { nand_write_oob_syndrome()
1857 chip->write_buf(mtd, (uint8_t *)&fill, nand_write_oob_syndrome()
1863 chip->cmdfunc(mtd, NAND_CMD_RNDIN, pos, -1); nand_write_oob_syndrome()
1868 chip->write_buf(mtd, bufpoi, len); nand_write_oob_syndrome()
1873 chip->write_buf(mtd, bufpoi, length); nand_write_oob_syndrome()
1875 chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1); nand_write_oob_syndrome()
1876 status = chip->waitfunc(mtd, chip); nand_write_oob_syndrome()
1883 * @mtd: MTD device structure
1889 static int nand_do_read_oob(struct mtd_info *mtd, loff_t from, nand_do_read_oob() argument
1893 struct nand_chip *chip = mtd->priv; nand_do_read_oob()
1903 stats = mtd->ecc_stats; nand_do_read_oob()
1908 len = mtd->oobsize; nand_do_read_oob()
1917 if (unlikely(from >= mtd->size || nand_do_read_oob()
1918 ops->ooboffs + readlen > ((mtd->size >> chip->page_shift) - nand_do_read_oob()
1926 chip->select_chip(mtd, chipnr); nand_do_read_oob()
1934 ret = chip->ecc.read_oob_raw(mtd, chip, page); nand_do_read_oob()
1936 ret = chip->ecc.read_oob(mtd, chip, page); nand_do_read_oob()
1949 nand_wait_ready(mtd); nand_do_read_oob()
1963 chip->select_chip(mtd, -1); nand_do_read_oob()
1964 chip->select_chip(mtd, chipnr); nand_do_read_oob()
1967 chip->select_chip(mtd, -1); nand_do_read_oob()
1974 if (mtd->ecc_stats.failed - stats.failed) nand_do_read_oob()
1977 return mtd->ecc_stats.corrected - stats.corrected ? -EUCLEAN : 0; nand_do_read_oob()
1982 * @mtd: MTD device structure
1988 static int nand_read_oob(struct mtd_info *mtd, loff_t from, nand_read_oob() argument
1996 if (ops->datbuf && (from + ops->len) > mtd->size) { nand_read_oob()
2002 nand_get_device(mtd, FL_READING); nand_read_oob()
2015 ret = nand_do_read_oob(mtd, from, ops); nand_read_oob()
2017 ret = nand_do_read_ops(mtd, from, ops); nand_read_oob()
2020 nand_release_device(mtd); nand_read_oob()
2027 * @mtd: mtd info structure
2034 static int nand_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip, nand_write_page_raw() argument
2037 chip->write_buf(mtd, buf, mtd->writesize); nand_write_page_raw()
2039 chip->write_buf(mtd, chip->oob_poi, mtd->oobsize); nand_write_page_raw()
2046 * @mtd: mtd info structure
2053 static int nand_write_page_raw_syndrome(struct mtd_info *mtd, nand_write_page_raw_syndrome() argument
2063 chip->write_buf(mtd, buf, eccsize); nand_write_page_raw_syndrome()
2067 chip->write_buf(mtd, oob, chip->ecc.prepad); nand_write_page_raw_syndrome()
2071 chip->write_buf(mtd, oob, eccbytes); nand_write_page_raw_syndrome()
2075 chip->write_buf(mtd, oob, chip->ecc.postpad); nand_write_page_raw_syndrome()
2080 size = mtd->oobsize - (oob - chip->oob_poi); nand_write_page_raw_syndrome()
2082 chip->write_buf(mtd, oob, size); nand_write_page_raw_syndrome()
2088 * @mtd: mtd info structure
2093 static int nand_write_page_swecc(struct mtd_info *mtd, struct nand_chip *chip, nand_write_page_swecc() argument
2105 chip->ecc.calculate(mtd, p, &ecc_calc[i]); nand_write_page_swecc()
2110 return chip->ecc.write_page_raw(mtd, chip, buf, 1); nand_write_page_swecc()
2115 * @mtd: mtd info structure
2120 static int nand_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, nand_write_page_hwecc() argument
2131 chip->ecc.hwctl(mtd, NAND_ECC_WRITE); nand_write_page_hwecc()
2132 chip->write_buf(mtd, p, eccsize); nand_write_page_hwecc()
2133 chip->ecc.calculate(mtd, p, &ecc_calc[i]); nand_write_page_hwecc()
2139 chip->write_buf(mtd, chip->oob_poi, mtd->oobsize); nand_write_page_hwecc()
2147 * @mtd: mtd info structure
2154 static int nand_write_subpage_hwecc(struct mtd_info *mtd, nand_write_subpage_hwecc() argument
2167 int oob_bytes = mtd->oobsize / ecc_steps; nand_write_subpage_hwecc()
2172 chip->ecc.hwctl(mtd, NAND_ECC_WRITE); nand_write_subpage_hwecc()
2175 chip->write_buf(mtd, buf, ecc_size); nand_write_subpage_hwecc()
2181 chip->ecc.calculate(mtd, buf, ecc_calc); nand_write_subpage_hwecc()
2200 chip->write_buf(mtd, chip->oob_poi, mtd->oobsize); nand_write_subpage_hwecc()
2208 * @mtd: mtd info structure
2216 static int nand_write_page_syndrome(struct mtd_info *mtd, nand_write_page_syndrome() argument
2228 chip->ecc.hwctl(mtd, NAND_ECC_WRITE); nand_write_page_syndrome()
2229 chip->write_buf(mtd, p, eccsize); nand_write_page_syndrome()
2232 chip->write_buf(mtd, oob, chip->ecc.prepad); nand_write_page_syndrome()
2236 chip->ecc.calculate(mtd, p, oob); nand_write_page_syndrome()
2237 chip->write_buf(mtd, oob, eccbytes); nand_write_page_syndrome()
2241 chip->write_buf(mtd, oob, chip->ecc.postpad); nand_write_page_syndrome()
2247 i = mtd->oobsize - (oob - chip->oob_poi); nand_write_page_syndrome()
2249 chip->write_buf(mtd, oob, i); nand_write_page_syndrome()
2256 * @mtd: MTD device structure
2266 static int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip, nand_write_page() argument
2274 subpage = offset || (data_len < mtd->writesize); nand_write_page()
2278 chip->cmdfunc(mtd, NAND_CMD_SEQIN, 0x00, page); nand_write_page()
2281 status = chip->ecc.write_page_raw(mtd, chip, buf, nand_write_page()
2284 status = chip->ecc.write_subpage(mtd, chip, offset, data_len, nand_write_page()
2287 status = chip->ecc.write_page(mtd, chip, buf, oob_required); nand_write_page()
2300 chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1); nand_write_page()
2301 status = chip->waitfunc(mtd, chip); nand_write_page()
2307 status = chip->errstat(mtd, chip, FL_WRITING, status, nand_write_page()
2313 chip->cmdfunc(mtd, NAND_CMD_CACHEDPROG, -1, -1); nand_write_page()
2314 status = chip->waitfunc(mtd, chip); nand_write_page()
2322 * @mtd: MTD device structure
2327 static uint8_t *nand_fill_oob(struct mtd_info *mtd, uint8_t *oob, size_t len, nand_fill_oob() argument
2330 struct nand_chip *chip = mtd->priv; nand_fill_oob()
2336 memset(chip->oob_poi, 0xff, mtd->oobsize); nand_fill_oob()
2380 * @mtd: MTD device structure
2386 static int nand_do_write_ops(struct mtd_info *mtd, loff_t to, nand_do_write_ops() argument
2390 struct nand_chip *chip = mtd->priv; nand_do_write_ops()
2395 mtd->oobavail : mtd->oobsize; nand_do_write_ops()
2413 column = to & (mtd->writesize - 1); nand_do_write_ops()
2416 chip->select_chip(mtd, chipnr); nand_do_write_ops()
2419 if (nand_check_wp(mtd)) { nand_do_write_ops()
2440 int bytes = mtd->writesize; nand_do_write_ops()
2444 int part_pagewr = (column || writelen < (mtd->writesize - 1)); nand_do_write_ops()
2461 memset(chip->buffers->databuf, 0xff, mtd->writesize); nand_do_write_ops()
2468 oob = nand_fill_oob(mtd, oob, len, ops); nand_do_write_ops()
2472 memset(chip->oob_poi, 0xff, mtd->oobsize); nand_do_write_ops()
2474 ret = chip->write_page(mtd, chip, column, bytes, wbuf, nand_do_write_ops()
2492 chip->select_chip(mtd, -1); nand_do_write_ops()
2493 chip->select_chip(mtd, chipnr); nand_do_write_ops()
2502 chip->select_chip(mtd, -1); nand_do_write_ops()
2508 * @mtd: MTD device structure
2517 static int panic_nand_write(struct mtd_info *mtd, loff_t to, size_t len, panic_nand_write() argument
2520 struct nand_chip *chip = mtd->priv; panic_nand_write()
2525 panic_nand_wait(mtd, chip, 400); panic_nand_write()
2528 panic_nand_get_device(chip, mtd, FL_WRITING); panic_nand_write()
2535 ret = nand_do_write_ops(mtd, to, &ops); panic_nand_write()
2543 * @mtd: MTD device structure
2551 static int nand_write(struct mtd_info *mtd, loff_t to, size_t len, nand_write() argument
2557 nand_get_device(mtd, FL_WRITING); nand_write()
2562 ret = nand_do_write_ops(mtd, to, &ops); nand_write()
2564 nand_release_device(mtd); nand_write()
2570 * @mtd: MTD device structure
2576 static int nand_do_write_oob(struct mtd_info *mtd, loff_t to, nand_do_write_oob() argument
2580 struct nand_chip *chip = mtd->priv; nand_do_write_oob()
2588 len = mtd->oobsize; nand_do_write_oob()
2604 if (unlikely(to >= mtd->size || nand_do_write_oob()
2606 ((mtd->size >> chip->page_shift) - nand_do_write_oob()
2614 chip->select_chip(mtd, chipnr); nand_do_write_oob()
2625 chip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1); nand_do_write_oob()
2628 if (nand_check_wp(mtd)) { nand_do_write_oob()
2629 chip->select_chip(mtd, -1); nand_do_write_oob()
2637 nand_fill_oob(mtd, ops->oobbuf, ops->ooblen, ops); nand_do_write_oob()
2640 status = chip->ecc.write_oob_raw(mtd, chip, page & chip->pagemask); nand_do_write_oob()
2642 status = chip->ecc.write_oob(mtd, chip, page & chip->pagemask); nand_do_write_oob()
2644 chip->select_chip(mtd, -1); nand_do_write_oob()
2656 * @mtd: MTD device structure
2660 static int nand_write_oob(struct mtd_info *mtd, loff_t to, nand_write_oob() argument
2668 if (ops->datbuf && (to + ops->len) > mtd->size) { nand_write_oob()
2674 nand_get_device(mtd, FL_WRITING); nand_write_oob()
2687 ret = nand_do_write_oob(mtd, to, ops); nand_write_oob()
2689 ret = nand_do_write_ops(mtd, to, ops); nand_write_oob()
2692 nand_release_device(mtd); nand_write_oob()
2698 * @mtd: MTD device structure
2703 static int single_erase(struct mtd_info *mtd, int page) single_erase() argument
2705 struct nand_chip *chip = mtd->priv; single_erase()
2707 chip->cmdfunc(mtd, NAND_CMD_ERASE1, -1, page); single_erase()
2708 chip->cmdfunc(mtd, NAND_CMD_ERASE2, -1, -1); single_erase()
2710 return chip->waitfunc(mtd, chip); single_erase()
2715 * @mtd: MTD device structure
2720 static int nand_erase(struct mtd_info *mtd, struct erase_info *instr) nand_erase() argument
2722 return nand_erase_nand(mtd, instr, 0); nand_erase()
2727 * @mtd: MTD device structure
2733 int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr, nand_erase_nand() argument
2737 struct nand_chip *chip = mtd->priv; nand_erase_nand()
2744 if (check_offs_len(mtd, instr->addr, instr->len)) nand_erase_nand()
2748 nand_get_device(mtd, FL_ERASING); nand_erase_nand()
2758 chip->select_chip(mtd, chipnr); nand_erase_nand()
2761 if (nand_check_wp(mtd)) { nand_erase_nand()
2775 if (nand_block_checkbad(mtd, ((loff_t) page) << nand_erase_nand()
2791 status = chip->erase(mtd, page & chip->pagemask); nand_erase_nand()
2798 status = chip->errstat(mtd, chip, FL_ERASING, nand_erase_nand()
2818 chip->select_chip(mtd, -1); nand_erase_nand()
2819 chip->select_chip(mtd, chipnr); nand_erase_nand()
2829 chip->select_chip(mtd, -1); nand_erase_nand()
2830 nand_release_device(mtd); nand_erase_nand()
2842 * @mtd: MTD device structure
2846 static void nand_sync(struct mtd_info *mtd) nand_sync() argument
2851 nand_get_device(mtd, FL_SYNCING); nand_sync()
2853 nand_release_device(mtd); nand_sync()
2858 * @mtd: MTD device structure
2859 * @offs: offset relative to mtd start
2861 static int nand_block_isbad(struct mtd_info *mtd, loff_t offs) nand_block_isbad() argument
2863 return nand_block_checkbad(mtd, offs, 1, 0); nand_block_isbad()
2868 * @mtd: MTD device structure
2869 * @ofs: offset relative to mtd start
2871 static int nand_block_markbad(struct mtd_info *mtd, loff_t ofs) nand_block_markbad() argument
2875 ret = nand_block_isbad(mtd, ofs); nand_block_markbad()
2883 return nand_block_markbad_lowlevel(mtd, ofs); nand_block_markbad()
2888 * @mtd: MTD device structure
2893 static int nand_onfi_set_features(struct mtd_info *mtd, struct nand_chip *chip, nand_onfi_set_features() argument
2904 chip->cmdfunc(mtd, NAND_CMD_SET_FEATURES, addr, -1); nand_onfi_set_features()
2906 chip->write_byte(mtd, subfeature_param[i]); nand_onfi_set_features()
2908 status = chip->waitfunc(mtd, chip); nand_onfi_set_features()
2916 * @mtd: MTD device structure
2921 static int nand_onfi_get_features(struct mtd_info *mtd, struct nand_chip *chip, nand_onfi_get_features() argument
2934 chip->cmdfunc(mtd, NAND_CMD_GET_FEATURES, addr, -1); nand_onfi_get_features()
2936 *subfeature_param++ = chip->read_byte(mtd); nand_onfi_get_features()
2942 * @mtd: MTD device structure
2944 static int nand_suspend(struct mtd_info *mtd) nand_suspend() argument
2946 return nand_get_device(mtd, FL_PM_SUSPENDED); nand_suspend()
2951 * @mtd: MTD device structure
2953 static void nand_resume(struct mtd_info *mtd) nand_resume() argument
2955 struct nand_chip *chip = mtd->priv; nand_resume()
2958 nand_release_device(mtd); nand_resume()
2967 * @mtd: MTD device structure
2969 static void nand_shutdown(struct mtd_info *mtd) nand_shutdown() argument
2971 nand_get_device(mtd, FL_SHUTDOWN); nand_shutdown()
3055 static int nand_flash_detect_ext_param_page(struct mtd_info *mtd, nand_flash_detect_ext_param_page() argument
3072 chip->cmdfunc(mtd, NAND_CMD_PARAM, 0, -1); nand_flash_detect_ext_param_page()
3075 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, nand_flash_detect_ext_param_page()
3079 chip->read_buf(mtd, (uint8_t *)ep, len); nand_flash_detect_ext_param_page()
3125 static int nand_setup_read_retry_micron(struct mtd_info *mtd, int retry_mode) nand_setup_read_retry_micron() argument
3127 struct nand_chip *chip = mtd->priv; nand_setup_read_retry_micron()
3130 return chip->onfi_set_features(mtd, chip, ONFI_FEATURE_ADDR_READ_RETRY, nand_setup_read_retry_micron()
3152 static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip, nand_flash_detect_onfi() argument
3160 chip->cmdfunc(mtd, NAND_CMD_READID, 0x20, -1); nand_flash_detect_onfi()
3161 if (chip->read_byte(mtd) != 'O' || chip->read_byte(mtd) != 'N' || nand_flash_detect_onfi()
3162 chip->read_byte(mtd) != 'F' || chip->read_byte(mtd) != 'I') nand_flash_detect_onfi()
3165 chip->cmdfunc(mtd, NAND_CMD_PARAM, 0, -1); nand_flash_detect_onfi()
3168 ((uint8_t *)p)[j] = chip->read_byte(mtd); nand_flash_detect_onfi()
3200 if (!mtd->name) nand_flash_detect_onfi()
3201 mtd->name = p->model; nand_flash_detect_onfi()
3203 mtd->writesize = le32_to_cpu(p->byte_per_page); nand_flash_detect_onfi()
3210 mtd->erasesize = 1 << (fls(le32_to_cpu(p->pages_per_block)) - 1); nand_flash_detect_onfi()
3211 mtd->erasesize *= mtd->writesize; nand_flash_detect_onfi()
3213 mtd->oobsize = le16_to_cpu(p->spare_bytes_per_page); nand_flash_detect_onfi()
3217 chip->chipsize *= (uint64_t)mtd->erasesize * p->lun_count; nand_flash_detect_onfi()
3237 if (mtd->writesize > 512 && chip->cmdfunc == nand_command) nand_flash_detect_onfi()
3241 if (nand_flash_detect_ext_param_page(mtd, chip, p)) nand_flash_detect_onfi()
3256 static int nand_flash_detect_jedec(struct mtd_info *mtd, struct nand_chip *chip, nand_flash_detect_jedec() argument
3265 chip->cmdfunc(mtd, NAND_CMD_READID, 0x40, -1); nand_flash_detect_jedec()
3266 if (chip->read_byte(mtd) != 'J' || chip->read_byte(mtd) != 'E' || nand_flash_detect_jedec()
3267 chip->read_byte(mtd) != 'D' || chip->read_byte(mtd) != 'E' || nand_flash_detect_jedec()
3268 chip->read_byte(mtd) != 'C') nand_flash_detect_jedec()
3271 chip->cmdfunc(mtd, NAND_CMD_PARAM, 0x40, -1); nand_flash_detect_jedec()
3274 ((uint8_t *)p)[j] = chip->read_byte(mtd); nand_flash_detect_jedec()
3300 if (!mtd->name) nand_flash_detect_jedec()
3301 mtd->name = p->model; nand_flash_detect_jedec()
3303 mtd->writesize = le32_to_cpu(p->byte_per_page); nand_flash_detect_jedec()
3306 mtd->erasesize = 1 << (fls(le32_to_cpu(p->pages_per_block)) - 1); nand_flash_detect_jedec()
3307 mtd->erasesize *= mtd->writesize; nand_flash_detect_jedec()
3309 mtd->oobsize = le16_to_cpu(p->spare_bytes_per_page); nand_flash_detect_jedec()
3313 chip->chipsize *= (uint64_t)mtd->erasesize * p->lun_count; nand_flash_detect_jedec()
3408 static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip, nand_decode_ext_id() argument
3431 mtd->writesize = 2048 << (extid & 0x03); nand_decode_ext_id()
3436 mtd->oobsize = 128; nand_decode_ext_id()
3439 mtd->oobsize = 218; nand_decode_ext_id()
3442 mtd->oobsize = 400; nand_decode_ext_id()
3445 mtd->oobsize = 436; nand_decode_ext_id()
3448 mtd->oobsize = 512; nand_decode_ext_id()
3451 mtd->oobsize = 640; nand_decode_ext_id()
3455 mtd->oobsize = 1024; nand_decode_ext_id()
3460 mtd->erasesize = (128 * 1024) << nand_decode_ext_id()
3468 mtd->writesize = 2048 << (extid & 0x03); nand_decode_ext_id()
3473 mtd->oobsize = 128; nand_decode_ext_id()
3476 mtd->oobsize = 224; nand_decode_ext_id()
3479 mtd->oobsize = 448; nand_decode_ext_id()
3482 mtd->oobsize = 64; nand_decode_ext_id()
3485 mtd->oobsize = 32; nand_decode_ext_id()
3488 mtd->oobsize = 16; nand_decode_ext_id()
3491 mtd->oobsize = 640; nand_decode_ext_id()
3498 mtd->erasesize = (128 * 1024) << tmp; nand_decode_ext_id()
3500 mtd->erasesize = 768 * 1024; nand_decode_ext_id()
3502 mtd->erasesize = (64 * 1024) << tmp; nand_decode_ext_id()
3506 mtd->writesize = 1024 << (extid & 0x03); nand_decode_ext_id()
3509 mtd->oobsize = (8 << (extid & 0x01)) * nand_decode_ext_id()
3510 (mtd->writesize >> 9); nand_decode_ext_id()
3513 mtd->erasesize = (64 * 1024) << (extid & 0x03); nand_decode_ext_id()
3530 mtd->oobsize = 32 * mtd->writesize >> 9; nand_decode_ext_id()
3541 static void nand_decode_id(struct mtd_info *mtd, struct nand_chip *chip, nand_decode_id() argument
3547 mtd->erasesize = type->erasesize; nand_decode_id()
3548 mtd->writesize = type->pagesize; nand_decode_id()
3549 mtd->oobsize = mtd->writesize / 32; nand_decode_id()
3563 && mtd->writesize == 512) { nand_decode_id()
3564 mtd->erasesize = 128 * 1024; nand_decode_id()
3565 mtd->erasesize <<= ((id_data[3] & 0x03) << 1); nand_decode_id()
3574 static void nand_decode_bbm_options(struct mtd_info *mtd, nand_decode_bbm_options() argument
3580 if (mtd->writesize > 512 || (chip->options & NAND_BUSWIDTH_16)) nand_decode_bbm_options()
3601 (mtd->writesize == 2048 && nand_decode_bbm_options()
3611 static bool find_full_id_nand(struct mtd_info *mtd, struct nand_chip *chip, find_full_id_nand() argument
3615 mtd->writesize = type->pagesize; find_full_id_nand()
3616 mtd->erasesize = type->erasesize; find_full_id_nand()
3617 mtd->oobsize = type->oobsize; find_full_id_nand()
3629 if (!mtd->name) find_full_id_nand()
3630 mtd->name = type->name; find_full_id_nand()
3640 static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, nand_get_flash_type() argument
3650 chip->select_chip(mtd, 0); nand_get_flash_type()
3656 chip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1); nand_get_flash_type()
3659 chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1); nand_get_flash_type()
3662 *maf_id = chip->read_byte(mtd); nand_get_flash_type()
3663 *dev_id = chip->read_byte(mtd); nand_get_flash_type()
3672 chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1); nand_get_flash_type()
3676 id_data[i] = chip->read_byte(mtd); nand_get_flash_type()
3689 if (find_full_id_nand(mtd, chip, type, id_data, &busw)) nand_get_flash_type()
3699 if (nand_flash_detect_onfi(mtd, chip, &busw)) nand_get_flash_type()
3703 if (nand_flash_detect_jedec(mtd, chip, &busw)) nand_get_flash_type()
3710 if (!mtd->name) nand_get_flash_type()
3711 mtd->name = type->name; nand_get_flash_type()
3717 busw = chip->init_size(mtd, chip, id_data); nand_get_flash_type()
3720 nand_decode_ext_id(mtd, chip, id_data, &busw); nand_get_flash_type()
3722 nand_decode_id(mtd, chip, type, id_data, &busw); nand_get_flash_type()
3752 pr_info("%s %s\n", nand_manuf_ids[maf_idx].name, mtd->name); nand_get_flash_type()
3759 nand_decode_bbm_options(mtd, chip, id_data); nand_get_flash_type()
3762 chip->page_shift = ffs(mtd->writesize) - 1; nand_get_flash_type()
3767 ffs(mtd->erasesize) - 1; nand_get_flash_type()
3779 if (mtd->writesize > 512 && chip->cmdfunc == nand_command) nand_get_flash_type()
3797 mtd->erasesize >> 10, mtd->writesize, mtd->oobsize); nand_get_flash_type()
3803 * @mtd: MTD device structure
3810 * The mtd->owner field must be set to the module of the caller.
3812 int nand_scan_ident(struct mtd_info *mtd, int maxchips, nand_scan_ident() argument
3816 struct nand_chip *chip = mtd->priv; nand_scan_ident()
3823 type = nand_get_flash_type(mtd, chip, &nand_maf_id, nand_scan_ident()
3829 chip->select_chip(mtd, -1); nand_scan_ident()
3833 chip->select_chip(mtd, -1); nand_scan_ident()
3837 chip->select_chip(mtd, i); nand_scan_ident()
3839 chip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1); nand_scan_ident()
3841 chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1); nand_scan_ident()
3843 if (nand_maf_id != chip->read_byte(mtd) || nand_scan_ident()
3844 nand_dev_id != chip->read_byte(mtd)) { nand_scan_ident()
3845 chip->select_chip(mtd, -1); nand_scan_ident()
3848 chip->select_chip(mtd, -1); nand_scan_ident()
3853 /* Store the number of chips and calc total size for mtd */ nand_scan_ident()
3855 mtd->size = i * chip->chipsize; nand_scan_ident()
3875 static bool nand_ecc_strength_good(struct mtd_info *mtd) nand_ecc_strength_good() argument
3877 struct nand_chip *chip = mtd->priv; nand_ecc_strength_good()
3889 corr = (mtd->writesize * ecc->strength) / ecc->size; nand_ecc_strength_good()
3890 ds_corr = (mtd->writesize * chip->ecc_strength_ds) / chip->ecc_step_ds; nand_ecc_strength_good()
3897 * @mtd: MTD device structure
3903 int nand_scan_tail(struct mtd_info *mtd) nand_scan_tail() argument
3906 struct nand_chip *chip = mtd->priv; nand_scan_tail()
3915 nbuf = kzalloc(sizeof(*nbuf) + mtd->writesize nand_scan_tail()
3916 + mtd->oobsize * 3, GFP_KERNEL); nand_scan_tail()
3920 nbuf->ecccode = nbuf->ecccalc + mtd->oobsize; nand_scan_tail()
3921 nbuf->databuf = nbuf->ecccode + mtd->oobsize; nand_scan_tail()
3930 chip->oob_poi = chip->buffers->databuf + mtd->writesize; nand_scan_tail()
3936 switch (mtd->oobsize) { nand_scan_tail()
3951 mtd->oobsize); nand_scan_tail()
4016 if (mtd->writesize >= ecc->size) { nand_scan_tail()
4024 ecc->size, mtd->writesize); nand_scan_tail()
4062 if (!ecc->size && (mtd->oobsize >= 64)) { nand_scan_tail()
4070 ecc->priv = nand_bch_init(mtd, ecc->size, ecc->bytes, nand_scan_tail()
4086 ecc->size = mtd->writesize; nand_scan_tail()
4110 mtd->oobavail = ecc->layout->oobavail; nand_scan_tail()
4113 if (!nand_ecc_strength_good(mtd)) nand_scan_tail()
4115 mtd->name); nand_scan_tail()
4121 ecc->steps = mtd->writesize / ecc->size; nand_scan_tail()
4122 if (ecc->steps * ecc->size != mtd->writesize) { nand_scan_tail()
4132 mtd->subpage_sft = 1; nand_scan_tail()
4137 mtd->subpage_sft = 2; nand_scan_tail()
4141 chip->subpagesize = mtd->writesize >> mtd->subpage_sft; nand_scan_tail()
4162 mtd->type = nand_is_slc(chip) ? MTD_NANDFLASH : MTD_MLCNANDFLASH; nand_scan_tail()
4163 mtd->flags = (chip->options & NAND_ROM) ? MTD_CAP_ROM : nand_scan_tail()
4165 mtd->_erase = nand_erase; nand_scan_tail()
4166 mtd->_point = NULL; nand_scan_tail()
4167 mtd->_unpoint = NULL; nand_scan_tail()
4168 mtd->_read = nand_read; nand_scan_tail()
4169 mtd->_write = nand_write; nand_scan_tail()
4170 mtd->_panic_write = panic_nand_write; nand_scan_tail()
4171 mtd->_read_oob = nand_read_oob; nand_scan_tail()
4172 mtd->_write_oob = nand_write_oob; nand_scan_tail()
4173 mtd->_sync = nand_sync; nand_scan_tail()
4174 mtd->_lock = NULL; nand_scan_tail()
4175 mtd->_unlock = NULL; nand_scan_tail()
4176 mtd->_suspend = nand_suspend; nand_scan_tail()
4177 mtd->_resume = nand_resume; nand_scan_tail()
4178 mtd->_reboot = nand_shutdown; nand_scan_tail()
4179 mtd->_block_isreserved = nand_block_isreserved; nand_scan_tail()
4180 mtd->_block_isbad = nand_block_isbad; nand_scan_tail()
4181 mtd->_block_markbad = nand_block_markbad; nand_scan_tail()
4182 mtd->writebufsize = mtd->writesize; nand_scan_tail()
4185 mtd->ecclayout = ecc->layout; nand_scan_tail()
4186 mtd->ecc_strength = ecc->strength; nand_scan_tail()
4187 mtd->ecc_step_size = ecc->size; nand_scan_tail()
4193 if (!mtd->bitflip_threshold) nand_scan_tail()
4194 mtd->bitflip_threshold = DIV_ROUND_UP(mtd->ecc_strength * 3, 4); nand_scan_tail()
4201 return chip->scan_bbt(mtd); nand_scan_tail()
4219 * @mtd: MTD device structure
4223 * The flash ID is read and the mtd/chip structures are filled with the
4224 * appropriate values. The mtd->owner field must be set to the module of the
4227 int nand_scan(struct mtd_info *mtd, int maxchips) nand_scan() argument
4232 if (!mtd->owner && caller_is_module()) { nand_scan()
4233 pr_crit("%s called with NULL mtd->owner!\n", __func__); nand_scan()
4237 ret = nand_scan_ident(mtd, maxchips, NULL); nand_scan()
4239 ret = nand_scan_tail(mtd); nand_scan()
4246 * @mtd: MTD device structure
4248 void nand_release(struct mtd_info *mtd) nand_release() argument
4250 struct nand_chip *chip = mtd->priv; nand_release()
4255 mtd_device_unregister(mtd); nand_release()
809 panic_nand_get_device(struct nand_chip *chip, struct mtd_info *mtd, int new_state) panic_nand_get_device() argument
H A Dsharpsl.c2 * drivers/mtd/nand/sharpsl.c
19 #include <linux/mtd/mtd.h>
20 #include <linux/mtd/nand.h>
21 #include <linux/mtd/nand_ecc.h>
22 #include <linux/mtd/partitions.h>
23 #include <linux/mtd/sharpsl.h>
32 struct mtd_info mtd; member in struct:sharpsl_nand
38 #define mtd_to_sharpsl(_mtd) container_of(_mtd, struct sharpsl_nand, mtd)
65 static void sharpsl_nand_hwcontrol(struct mtd_info *mtd, int cmd, sharpsl_nand_hwcontrol() argument
68 struct sharpsl_nand *sharpsl = mtd_to_sharpsl(mtd); sharpsl_nand_hwcontrol()
69 struct nand_chip *chip = mtd->priv; sharpsl_nand_hwcontrol()
85 static int sharpsl_nand_dev_ready(struct mtd_info *mtd) sharpsl_nand_dev_ready() argument
87 struct sharpsl_nand *sharpsl = mtd_to_sharpsl(mtd); sharpsl_nand_dev_ready()
91 static void sharpsl_nand_enable_hwecc(struct mtd_info *mtd, int mode) sharpsl_nand_enable_hwecc() argument
93 struct sharpsl_nand *sharpsl = mtd_to_sharpsl(mtd); sharpsl_nand_enable_hwecc()
97 static int sharpsl_nand_calculate_ecc(struct mtd_info *mtd, const u_char * dat, u_char * ecc_code) sharpsl_nand_calculate_ecc() argument
99 struct sharpsl_nand *sharpsl = mtd_to_sharpsl(mtd); sharpsl_nand_calculate_ecc()
146 sharpsl->mtd.priv = this; sharpsl_nand_probe()
147 sharpsl->mtd.owner = THIS_MODULE; sharpsl_nand_probe()
176 err = nand_scan(&sharpsl->mtd, 1); sharpsl_nand_probe()
181 sharpsl->mtd.name = "sharpsl-nand"; sharpsl_nand_probe()
183 err = mtd_device_parse_register(&sharpsl->mtd, NULL, NULL, sharpsl_nand_probe()
192 nand_release(&sharpsl->mtd); sharpsl_nand_probe()
210 nand_release(&sharpsl->mtd); sharpsl_nand_remove()
H A Dcafe_nand.c15 #include <linux/mtd/mtd.h>
16 #include <linux/mtd/nand.h>
17 #include <linux/mtd/partitions.h>
102 static int cafe_device_ready(struct mtd_info *mtd) cafe_device_ready() argument
104 struct cafe_priv *cafe = mtd->priv; cafe_device_ready()
118 static void cafe_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) cafe_write_buf() argument
120 struct cafe_priv *cafe = mtd->priv; cafe_write_buf()
133 static void cafe_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) cafe_read_buf() argument
135 struct cafe_priv *cafe = mtd->priv; cafe_read_buf()
147 static uint8_t cafe_read_byte(struct mtd_info *mtd) cafe_read_byte() argument
149 struct cafe_priv *cafe = mtd->priv; cafe_read_byte()
152 cafe_read_buf(mtd, &d, 1); cafe_read_byte()
158 static void cafe_nand_cmdfunc(struct mtd_info *mtd, unsigned command, cafe_nand_cmdfunc() argument
161 struct cafe_priv *cafe = mtd->priv; cafe_nand_cmdfunc()
182 if (mtd->writesize > 512 && cafe_nand_cmdfunc()
184 column += mtd->writesize; cafe_nand_cmdfunc()
202 if (mtd->size > mtd->writesize << 16) cafe_nand_cmdfunc()
222 cafe->datalen = mtd->writesize + mtd->oobsize - column; cafe_nand_cmdfunc()
241 else if (command == NAND_CMD_READ0 && mtd->writesize > 512) cafe_nand_cmdfunc()
310 nand_wait_ready(mtd); cafe_nand_cmdfunc()
314 static void cafe_select_chip(struct mtd_info *mtd, int chipnr) cafe_select_chip() argument
316 struct cafe_priv *cafe = mtd->priv; cafe_select_chip()
330 struct mtd_info *mtd = id; cafe_nand_interrupt() local
331 struct cafe_priv *cafe = mtd->priv; cafe_nand_interrupt()
341 static void cafe_nand_bug(struct mtd_info *mtd) cafe_nand_bug() argument
346 static int cafe_nand_write_oob(struct mtd_info *mtd, cafe_nand_write_oob() argument
351 chip->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->writesize, page); cafe_nand_write_oob()
352 chip->write_buf(mtd, chip->oob_poi, mtd->oobsize); cafe_nand_write_oob()
353 chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1); cafe_nand_write_oob()
354 status = chip->waitfunc(mtd, chip); cafe_nand_write_oob()
360 static int cafe_nand_read_oob(struct mtd_info *mtd, struct nand_chip *chip, cafe_nand_read_oob() argument
363 chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page); cafe_nand_read_oob()
364 chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); cafe_nand_read_oob()
369 * @mtd: mtd info structure
377 static int cafe_nand_read_page(struct mtd_info *mtd, struct nand_chip *chip, cafe_nand_read_page() argument
380 struct cafe_priv *cafe = mtd->priv; cafe_nand_read_page()
387 chip->read_buf(mtd, buf, mtd->writesize); cafe_nand_read_page()
388 chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); cafe_nand_read_page()
444 mtd->ecc_stats.failed++; cafe_nand_read_page()
447 mtd->ecc_stats.corrected += n; cafe_nand_read_page()
517 static int cafe_nand_write_page_lowlevel(struct mtd_info *mtd, cafe_nand_write_page_lowlevel() argument
521 struct cafe_priv *cafe = mtd->priv; cafe_nand_write_page_lowlevel()
523 chip->write_buf(mtd, buf, mtd->writesize); cafe_nand_write_page_lowlevel()
524 chip->write_buf(mtd, chip->oob_poi, mtd->oobsize); cafe_nand_write_page_lowlevel()
532 static int cafe_nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip) cafe_nand_block_bad() argument
582 struct mtd_info *mtd; cafe_nand_probe() local
600 mtd = kzalloc(sizeof(*mtd) + sizeof(struct cafe_priv), GFP_KERNEL); cafe_nand_probe()
601 if (!mtd) cafe_nand_probe()
603 cafe = (void *)(&mtd[1]); cafe_nand_probe()
605 mtd->dev.parent = &pdev->dev; cafe_nand_probe()
606 mtd->priv = cafe; cafe_nand_probe()
607 mtd->owner = THIS_MODULE; cafe_nand_probe()
672 "CAFE NAND", mtd); cafe_nand_probe()
700 if (nand_scan_ident(mtd, 2, NULL)) { cafe_nand_probe()
707 mtd->writesize + mtd->oobsize, cafe_nand_probe()
735 if (mtd->writesize == 2048) cafe_nand_probe()
739 if (mtd->writesize == 2048) { cafe_nand_probe()
743 } else if (mtd->writesize == 512) { cafe_nand_probe()
749 mtd->writesize); cafe_nand_probe()
753 cafe->nand.ecc.size = mtd->writesize; cafe_nand_probe()
764 err = nand_scan_tail(mtd); cafe_nand_probe()
768 pci_set_drvdata(pdev, mtd); cafe_nand_probe()
770 mtd->name = "cafe_nand"; cafe_nand_probe()
771 mtd_device_parse_register(mtd, part_probes, NULL, NULL, 0); cafe_nand_probe()
778 mtd->writesize + mtd->oobsize, cafe_nand_probe()
783 free_irq(pdev->irq, mtd); cafe_nand_probe()
787 kfree(mtd); cafe_nand_probe()
794 struct mtd_info *mtd = pci_get_drvdata(pdev); cafe_nand_remove() local
795 struct cafe_priv *cafe = mtd->priv; cafe_nand_remove()
799 free_irq(pdev->irq, mtd); cafe_nand_remove()
800 nand_release(mtd); cafe_nand_remove()
805 mtd->writesize + mtd->oobsize, cafe_nand_remove()
807 kfree(mtd); cafe_nand_remove()
821 struct mtd_info *mtd = pci_get_drvdata(pdev); cafe_nand_resume() local
822 struct cafe_priv *cafe = mtd->priv; cafe_nand_resume()
H A Dtxx9ndfmc.c18 #include <linux/mtd/mtd.h>
19 #include <linux/mtd/nand.h>
20 #include <linux/mtd/nand_ecc.h>
21 #include <linux/mtd/partitions.h>
66 struct mtd_info mtd; member in struct:txx9ndfmc_priv
80 static struct platform_device *mtd_to_platdev(struct mtd_info *mtd) mtd_to_platdev() argument
82 struct nand_chip *chip = mtd->priv; mtd_to_platdev()
106 static uint8_t txx9ndfmc_read_byte(struct mtd_info *mtd) txx9ndfmc_read_byte() argument
108 struct platform_device *dev = mtd_to_platdev(mtd); txx9ndfmc_read_byte()
113 static void txx9ndfmc_write_buf(struct mtd_info *mtd, const uint8_t *buf, txx9ndfmc_write_buf() argument
116 struct platform_device *dev = mtd_to_platdev(mtd); txx9ndfmc_write_buf()
126 static void txx9ndfmc_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) txx9ndfmc_read_buf() argument
128 struct platform_device *dev = mtd_to_platdev(mtd); txx9ndfmc_read_buf()
135 static void txx9ndfmc_cmd_ctrl(struct mtd_info *mtd, int cmd, txx9ndfmc_cmd_ctrl() argument
138 struct nand_chip *chip = mtd->priv; txx9ndfmc_cmd_ctrl()
167 static int txx9ndfmc_dev_ready(struct mtd_info *mtd) txx9ndfmc_dev_ready() argument
169 struct platform_device *dev = mtd_to_platdev(mtd); txx9ndfmc_dev_ready()
174 static int txx9ndfmc_calculate_ecc(struct mtd_info *mtd, const uint8_t *dat, txx9ndfmc_calculate_ecc() argument
177 struct platform_device *dev = mtd_to_platdev(mtd); txx9ndfmc_calculate_ecc()
178 struct nand_chip *chip = mtd->priv; txx9ndfmc_calculate_ecc()
195 static int txx9ndfmc_correct_data(struct mtd_info *mtd, unsigned char *buf, txx9ndfmc_correct_data() argument
198 struct nand_chip *chip = mtd->priv; txx9ndfmc_correct_data()
215 static void txx9ndfmc_enable_hwecc(struct mtd_info *mtd, int mode) txx9ndfmc_enable_hwecc() argument
217 struct platform_device *dev = mtd_to_platdev(mtd); txx9ndfmc_enable_hwecc()
258 static int txx9ndfmc_nand_scan(struct mtd_info *mtd) txx9ndfmc_nand_scan() argument
260 struct nand_chip *chip = mtd->priv; txx9ndfmc_nand_scan()
263 ret = nand_scan_ident(mtd, 1, NULL); txx9ndfmc_nand_scan()
265 if (mtd->writesize >= 512) { txx9ndfmc_nand_scan()
270 ret = nand_scan_tail(mtd); txx9ndfmc_nand_scan()
316 struct mtd_info *mtd; txx9ndfmc_probe() local
325 mtd = &txx9_priv->mtd; txx9ndfmc_probe()
326 mtd->owner = THIS_MODULE; txx9ndfmc_probe()
328 mtd->priv = chip; txx9ndfmc_probe()
366 if (txx9ndfmc_nand_scan(mtd)) { txx9ndfmc_probe()
371 mtd->name = txx9_priv->mtdname; txx9ndfmc_probe()
373 mtd_device_parse_register(mtd, NULL, NULL, NULL, 0); txx9ndfmc_probe()
374 drvdata->mtds[i] = mtd; txx9ndfmc_probe()
388 struct mtd_info *mtd = drvdata->mtds[i]; txx9ndfmc_remove() local
392 if (!mtd) txx9ndfmc_remove()
394 chip = mtd->priv; txx9ndfmc_remove()
397 nand_release(mtd); txx9ndfmc_remove()
H A Dorion_nand.c2 * drivers/mtd/nand/orion_nand.c
17 #include <linux/mtd/mtd.h>
18 #include <linux/mtd/nand.h>
19 #include <linux/mtd/partitions.h>
24 #include <linux/platform_data/mtd-orion_nand.h>
26 static void orion_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) orion_nand_cmd_ctrl() argument
28 struct nand_chip *nc = mtd->priv; orion_nand_cmd_ctrl()
48 static void orion_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) orion_nand_read_buf() argument
50 struct nand_chip *chip = mtd->priv; orion_nand_read_buf()
78 struct mtd_info *mtd; orion_nand_probe() local
93 mtd = (struct mtd_info *)(nc + 1); orion_nand_probe()
126 mtd->priv = nc; orion_nand_probe()
127 mtd->owner = THIS_MODULE; orion_nand_probe()
148 platform_set_drvdata(pdev, mtd); orion_nand_probe()
158 if (nand_scan(mtd, 1)) { orion_nand_probe()
163 mtd->name = "orion_nand"; orion_nand_probe()
165 ret = mtd_device_parse_register(mtd, NULL, &ppdata, orion_nand_probe()
168 nand_release(mtd); orion_nand_probe()
185 struct mtd_info *mtd = platform_get_drvdata(pdev); orion_nand_remove() local
188 nand_release(mtd); orion_nand_remove()
H A Dau1550nd.c2 * drivers/mtd/nand/au1550nd.c
16 #include <linux/mtd/mtd.h>
17 #include <linux/mtd/nand.h>
18 #include <linux/mtd/partitions.h>
36 * @mtd: MTD device structure
40 static u_char au_read_byte(struct mtd_info *mtd) au_read_byte() argument
42 struct nand_chip *this = mtd->priv; au_read_byte()
50 * @mtd: MTD device structure
55 static void au_write_byte(struct mtd_info *mtd, u_char byte) au_write_byte() argument
57 struct nand_chip *this = mtd->priv; au_write_byte()
64 * @mtd: MTD device structure
68 static u_char au_read_byte16(struct mtd_info *mtd) au_read_byte16() argument
70 struct nand_chip *this = mtd->priv; au_read_byte16()
78 * @mtd: MTD device structure
83 static void au_write_byte16(struct mtd_info *mtd, u_char byte) au_write_byte16() argument
85 struct nand_chip *this = mtd->priv; au_write_byte16()
92 * @mtd: MTD device structure
96 static u16 au_read_word(struct mtd_info *mtd) au_read_word() argument
98 struct nand_chip *this = mtd->priv; au_read_word()
106 * @mtd: MTD device structure
112 static void au_write_buf(struct mtd_info *mtd, const u_char *buf, int len) au_write_buf() argument
115 struct nand_chip *this = mtd->priv; au_write_buf()
125 * @mtd: MTD device structure
131 static void au_read_buf(struct mtd_info *mtd, u_char *buf, int len) au_read_buf() argument
134 struct nand_chip *this = mtd->priv; au_read_buf()
144 * @mtd: MTD device structure
150 static void au_write_buf16(struct mtd_info *mtd, const u_char *buf, int len) au_write_buf16() argument
153 struct nand_chip *this = mtd->priv; au_write_buf16()
166 * @mtd: MTD device structure
172 static void au_read_buf16(struct mtd_info *mtd, u_char *buf, int len) au_read_buf16() argument
175 struct nand_chip *this = mtd->priv; au_read_buf16()
198 static void au1550_hwcontrol(struct mtd_info *mtd, int cmd) au1550_hwcontrol() argument
200 struct au1550nd_ctx *ctx = container_of(mtd, struct au1550nd_ctx, info); au1550_hwcontrol()
201 struct nand_chip *this = mtd->priv; au1550_hwcontrol()
240 int au1550_device_ready(struct mtd_info *mtd) au1550_device_ready() argument
254 * @mtd: MTD device structure
257 static void au1550_select_chip(struct mtd_info *mtd, int chip) au1550_select_chip() argument
263 * @mtd: MTD device structure
268 static void au1550_command(struct mtd_info *mtd, unsigned command, int column, int page_addr) au1550_command() argument
270 struct au1550nd_ctx *ctx = container_of(mtd, struct au1550nd_ctx, info); au1550_command()
271 struct nand_chip *this = mtd->priv; au1550_command()
276 au1550_hwcontrol(mtd, NAND_CTL_SETCLE); au1550_command()
283 if (column >= mtd->writesize) { au1550_command()
285 column -= mtd->writesize; au1550_command()
294 ctx->write_byte(mtd, readcmd); au1550_command()
296 ctx->write_byte(mtd, command); au1550_command()
299 au1550_hwcontrol(mtd, NAND_CTL_CLRCLE); au1550_command()
302 au1550_hwcontrol(mtd, NAND_CTL_SETALE); au1550_command()
310 ctx->write_byte(mtd, column); au1550_command()
313 ctx->write_byte(mtd, (u8)(page_addr & 0xff)); au1550_command()
328 au1550_hwcontrol(mtd, NAND_CTL_SETNCE); au1550_command()
331 ctx->write_byte(mtd, (u8)(page_addr >> 8)); au1550_command()
335 ctx->write_byte(mtd, au1550_command()
339 au1550_hwcontrol(mtd, NAND_CTL_CLRALE); au1550_command()
368 for (i = this->chip_delay; !this->dev_ready(mtd) && i > 0; --i) au1550_command()
372 au1550_hwcontrol(mtd, NAND_CTL_CLRNCE); au1550_command()
379 while(!this->dev_ready(mtd)); au1550_command()
H A Dfsl_upm.c17 #include <linux/mtd/nand.h>
18 #include <linux/mtd/nand_ecc.h>
19 #include <linux/mtd/partitions.h>
20 #include <linux/mtd/mtd.h>
34 struct mtd_info mtd; member in struct:fsl_upm_nand
52 return container_of(mtdinfo, struct fsl_upm_nand, mtd); to_fsl_upm_nand()
55 static int fun_chip_ready(struct mtd_info *mtd) fun_chip_ready() argument
57 struct fsl_upm_nand *fun = to_fsl_upm_nand(mtd); fun_chip_ready()
71 while (--cnt && !fun_chip_ready(&fun->mtd)) fun_wait_rnb()
80 static void fun_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) fun_cmd_ctrl() argument
82 struct nand_chip *chip = mtd->priv; fun_cmd_ctrl()
83 struct fsl_upm_nand *fun = to_fsl_upm_nand(mtd); fun_cmd_ctrl()
110 static void fun_select_chip(struct mtd_info *mtd, int mchip_nr) fun_select_chip() argument
112 struct nand_chip *chip = mtd->priv; fun_select_chip()
113 struct fsl_upm_nand *fun = to_fsl_upm_nand(mtd); fun_select_chip()
116 chip->cmd_ctrl(mtd, NAND_CMD_NONE, 0 | NAND_CTRL_CHANGE); fun_select_chip()
126 static uint8_t fun_read_byte(struct mtd_info *mtd) fun_read_byte() argument
128 struct fsl_upm_nand *fun = to_fsl_upm_nand(mtd); fun_read_byte()
133 static void fun_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) fun_read_buf() argument
135 struct fsl_upm_nand *fun = to_fsl_upm_nand(mtd); fun_read_buf()
142 static void fun_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) fun_write_buf() argument
144 struct fsl_upm_nand *fun = to_fsl_upm_nand(mtd); fun_write_buf()
178 fun->mtd.priv = &fun->chip; fun_chip_init()
179 fun->mtd.owner = THIS_MODULE; fun_chip_init()
185 fun->mtd.name = kasprintf(GFP_KERNEL, "0x%llx.%s", (u64)io_res->start, fun_chip_init()
187 if (!fun->mtd.name) { fun_chip_init()
192 ret = nand_scan(&fun->mtd, fun->mchip_count); fun_chip_init()
197 ret = mtd_device_parse_register(&fun->mtd, NULL, &ppdata, NULL, 0); fun_chip_init()
201 kfree(fun->mtd.name); fun_chip_init()
327 nand_release(&fun->mtd); fun_remove()
328 kfree(fun->mtd.name); fun_remove()
H A Dndfc.c2 * drivers/mtd/ndfc.c
27 #include <linux/mtd/nand.h>
28 #include <linux/mtd/nand_ecc.h>
29 #include <linux/mtd/partitions.h>
30 #include <linux/mtd/ndfc.h>
32 #include <linux/mtd/mtd.h>
42 struct mtd_info mtd; member in struct:ndfc_controller
50 static void ndfc_select_chip(struct mtd_info *mtd, int chip) ndfc_select_chip() argument
53 struct nand_chip *nchip = mtd->priv; ndfc_select_chip()
65 static void ndfc_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl) ndfc_hwcontrol() argument
67 struct nand_chip *chip = mtd->priv; ndfc_hwcontrol()
79 static int ndfc_ready(struct mtd_info *mtd) ndfc_ready() argument
81 struct nand_chip *chip = mtd->priv; ndfc_ready()
87 static void ndfc_enable_hwecc(struct mtd_info *mtd, int mode) ndfc_enable_hwecc() argument
90 struct nand_chip *chip = mtd->priv; ndfc_enable_hwecc()
99 static int ndfc_calculate_ecc(struct mtd_info *mtd, ndfc_calculate_ecc() argument
102 struct nand_chip *chip = mtd->priv; ndfc_calculate_ecc()
124 static void ndfc_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) ndfc_read_buf() argument
126 struct nand_chip *chip = mtd->priv; ndfc_read_buf()
134 static void ndfc_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) ndfc_write_buf() argument
136 struct nand_chip *chip = mtd->priv; ndfc_write_buf()
173 ndfc->mtd.priv = chip; ndfc_chip_init()
174 ndfc->mtd.owner = THIS_MODULE; ndfc_chip_init()
181 ndfc->mtd.name = kasprintf(GFP_KERNEL, "%s.%s", ndfc_chip_init()
183 if (!ndfc->mtd.name) { ndfc_chip_init()
188 ret = nand_scan(&ndfc->mtd, 1); ndfc_chip_init()
192 ret = mtd_device_parse_register(&ndfc->mtd, NULL, &ppdata, NULL, 0); ndfc_chip_init()
197 kfree(ndfc->mtd.name); ndfc_chip_init()
265 nand_release(&ndfc->mtd); ndfc_remove()
266 kfree(ndfc->mtd.name); ndfc_remove()
H A Dbf5xx_nand.c1 /* linux/drivers/mtd/nand/bf5xx_nand.c
9 * Derived from drivers/mtd/nand/s3c2410.c
12 * Derived from drivers/mtd/nand/cafe.c
51 #include <linux/mtd/mtd.h>
52 #include <linux/mtd/nand.h>
53 #include <linux/mtd/nand_ecc.h>
54 #include <linux/mtd/partitions.h>
143 /* mtd info */
145 struct mtd_info mtd; member in struct:bf5xx_nand_info
161 static struct bf5xx_nand_info *mtd_to_nand_info(struct mtd_info *mtd) mtd_to_nand_info() argument
163 return container_of(mtd, struct bf5xx_nand_info, mtd); mtd_to_nand_info()
185 static void bf5xx_nand_hwcontrol(struct mtd_info *mtd, int cmd, bf5xx_nand_hwcontrol() argument
206 static int bf5xx_nand_devready(struct mtd_info *mtd) bf5xx_nand_devready() argument
225 static int bf5xx_nand_correct_data_256(struct mtd_info *mtd, u_char *dat, bf5xx_nand_correct_data_256() argument
228 struct bf5xx_nand_info *info = mtd_to_nand_info(mtd); bf5xx_nand_correct_data_256()
304 static int bf5xx_nand_correct_data(struct mtd_info *mtd, u_char *dat, bf5xx_nand_correct_data() argument
307 struct nand_chip *chip = mtd->priv; bf5xx_nand_correct_data()
310 ret = bf5xx_nand_correct_data_256(mtd, dat, read_ecc, calc_ecc); bf5xx_nand_correct_data()
317 ret |= bf5xx_nand_correct_data_256(mtd, dat, read_ecc, calc_ecc); bf5xx_nand_correct_data()
323 static void bf5xx_nand_enable_hwecc(struct mtd_info *mtd, int mode) bf5xx_nand_enable_hwecc() argument
328 static int bf5xx_nand_calculate_ecc(struct mtd_info *mtd, bf5xx_nand_calculate_ecc() argument
331 struct bf5xx_nand_info *info = mtd_to_nand_info(mtd); bf5xx_nand_calculate_ecc()
332 struct nand_chip *chip = mtd->priv; bf5xx_nand_calculate_ecc()
368 static void bf5xx_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) bf5xx_nand_read_buf() argument
397 static uint8_t bf5xx_nand_read_byte(struct mtd_info *mtd) bf5xx_nand_read_byte() argument
401 bf5xx_nand_read_buf(mtd, &val, 1); bf5xx_nand_read_byte()
406 static void bf5xx_nand_write_buf(struct mtd_info *mtd, bf5xx_nand_write_buf() argument
420 static void bf5xx_nand_read_buf16(struct mtd_info *mtd, uint8_t *buf, int len) bf5xx_nand_read_buf16() argument
438 static void bf5xx_nand_write_buf16(struct mtd_info *mtd, bf5xx_nand_write_buf16() argument
465 static void bf5xx_nand_dma_rw(struct mtd_info *mtd, bf5xx_nand_dma_rw() argument
468 struct bf5xx_nand_info *info = mtd_to_nand_info(mtd); bf5xx_nand_dma_rw()
469 struct nand_chip *chip = mtd->priv; bf5xx_nand_dma_rw()
472 dev_dbg(info->device, " mtd->%p, buf->%p, is_read %d\n", bf5xx_nand_dma_rw()
473 mtd, buf, is_read); bf5xx_nand_dma_rw()
531 static void bf5xx_nand_dma_read_buf(struct mtd_info *mtd, bf5xx_nand_dma_read_buf() argument
534 struct bf5xx_nand_info *info = mtd_to_nand_info(mtd); bf5xx_nand_dma_read_buf()
535 struct nand_chip *chip = mtd->priv; bf5xx_nand_dma_read_buf()
537 dev_dbg(info->device, "mtd->%p, buf->%p, int %d\n", mtd, buf, len); bf5xx_nand_dma_read_buf()
540 bf5xx_nand_dma_rw(mtd, buf, 1); bf5xx_nand_dma_read_buf()
542 bf5xx_nand_read_buf(mtd, buf, len); bf5xx_nand_dma_read_buf()
545 static void bf5xx_nand_dma_write_buf(struct mtd_info *mtd, bf5xx_nand_dma_write_buf() argument
548 struct bf5xx_nand_info *info = mtd_to_nand_info(mtd); bf5xx_nand_dma_write_buf()
549 struct nand_chip *chip = mtd->priv; bf5xx_nand_dma_write_buf()
551 dev_dbg(info->device, "mtd->%p, buf->%p, len %d\n", mtd, buf, len); bf5xx_nand_dma_write_buf()
554 bf5xx_nand_dma_rw(mtd, (uint8_t *)buf, 0); bf5xx_nand_dma_write_buf()
556 bf5xx_nand_write_buf(mtd, buf, len); bf5xx_nand_dma_write_buf()
559 static int bf5xx_nand_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip, bf5xx_nand_read_page_raw() argument
562 bf5xx_nand_read_buf(mtd, buf, mtd->writesize); bf5xx_nand_read_page_raw()
563 bf5xx_nand_read_buf(mtd, chip->oob_poi, mtd->oobsize); bf5xx_nand_read_page_raw()
568 static int bf5xx_nand_write_page_raw(struct mtd_info *mtd, bf5xx_nand_write_page_raw() argument
571 bf5xx_nand_write_buf(mtd, buf, mtd->writesize); bf5xx_nand_write_page_raw()
572 bf5xx_nand_write_buf(mtd, chip->oob_poi, mtd->oobsize); bf5xx_nand_write_page_raw()
662 struct mtd_info *mtd = &info->mtd; bf5xx_nand_add_partition() local
666 return mtd_device_register(mtd, parts, nr); bf5xx_nand_add_partition()
677 nand_release(&info->mtd); bf5xx_nand_remove()
685 static int bf5xx_nand_scan(struct mtd_info *mtd) bf5xx_nand_scan() argument
687 struct nand_chip *chip = mtd->priv; bf5xx_nand_scan()
690 ret = nand_scan_ident(mtd, 1, NULL); bf5xx_nand_scan()
698 if (likely(mtd->writesize >= 512)) { bf5xx_nand_scan()
711 return nand_scan_tail(mtd); bf5xx_nand_scan()
727 struct mtd_info *mtd = NULL; bf5xx_nand_probe() local
774 chip->priv = &info->mtd; bf5xx_nand_probe()
782 /* initialise mtd info data struct */ bf5xx_nand_probe()
783 mtd = &info->mtd; bf5xx_nand_probe()
784 mtd->priv = chip; bf5xx_nand_probe()
785 mtd->owner = THIS_MODULE; bf5xx_nand_probe()
809 /* scan hardware nand chip and setup mtd info data struct */ bf5xx_nand_probe()
810 if (bf5xx_nand_scan(mtd)) { bf5xx_nand_probe()
H A Ddiskonchip.c2 * drivers/mtd/nand/diskonchip.c
29 #include <linux/mtd/mtd.h>
30 #include <linux/mtd/nand.h>
31 #include <linux/mtd/doc2000.h>
32 #include <linux/mtd/partitions.h>
33 #include <linux/mtd/inftl.h>
88 static void doc200x_hwcontrol(struct mtd_info *mtd, int cmd,
90 static void doc200x_select_chip(struct mtd_info *mtd, int chip);
297 static void doc2000_write_byte(struct mtd_info *mtd, u_char datum) doc2000_write_byte() argument
299 struct nand_chip *this = mtd->priv; doc2000_write_byte()
309 static u_char doc2000_read_byte(struct mtd_info *mtd) doc2000_read_byte() argument
311 struct nand_chip *this = mtd->priv; doc2000_read_byte()
324 static void doc2000_writebuf(struct mtd_info *mtd, const u_char *buf, int len) doc2000_writebuf() argument
326 struct nand_chip *this = mtd->priv; doc2000_writebuf()
341 static void doc2000_readbuf(struct mtd_info *mtd, u_char *buf, int len) doc2000_readbuf() argument
343 struct nand_chip *this = mtd->priv; doc2000_readbuf()
356 static void doc2000_readbuf_dword(struct mtd_info *mtd, u_char *buf, int len) doc2000_readbuf_dword() argument
358 struct nand_chip *this = mtd->priv; doc2000_readbuf_dword()
377 static uint16_t __init doc200x_ident_chip(struct mtd_info *mtd, int nr) doc200x_ident_chip() argument
379 struct nand_chip *this = mtd->priv; doc200x_ident_chip()
383 doc200x_select_chip(mtd, nr); doc200x_ident_chip()
384 doc200x_hwcontrol(mtd, NAND_CMD_READID, doc200x_ident_chip()
386 doc200x_hwcontrol(mtd, 0, NAND_CTRL_ALE | NAND_CTRL_CHANGE); doc200x_ident_chip()
387 doc200x_hwcontrol(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); doc200x_ident_chip()
394 ret = this->read_byte(mtd) << 8; doc200x_ident_chip()
395 ret |= this->read_byte(mtd); doc200x_ident_chip()
405 doc200x_hwcontrol(mtd, NAND_CMD_READID, doc200x_ident_chip()
407 doc200x_hwcontrol(mtd, 0, NAND_CTRL_ALE | NAND_CTRL_CHANGE); doc200x_ident_chip()
408 doc200x_hwcontrol(mtd, NAND_CMD_NONE, doc200x_ident_chip()
423 static void __init doc2000_count_chips(struct mtd_info *mtd) doc2000_count_chips() argument
425 struct nand_chip *this = mtd->priv; doc2000_count_chips()
434 mfrid = doc200x_ident_chip(mtd, 0); doc2000_count_chips()
438 if (doc200x_ident_chip(mtd, i) != mfrid) doc2000_count_chips()
445 static int doc200x_wait(struct mtd_info *mtd, struct nand_chip *this) doc200x_wait() argument
452 this->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1); doc200x_wait()
454 status = (int)this->read_byte(mtd); doc200x_wait()
459 static void doc2001_write_byte(struct mtd_info *mtd, u_char datum) doc2001_write_byte() argument
461 struct nand_chip *this = mtd->priv; doc2001_write_byte()
470 static u_char doc2001_read_byte(struct mtd_info *mtd) doc2001_read_byte() argument
472 struct nand_chip *this = mtd->priv; doc2001_read_byte()
484 static void doc2001_writebuf(struct mtd_info *mtd, const u_char *buf, int len) doc2001_writebuf() argument
486 struct nand_chip *this = mtd->priv; doc2001_writebuf()
497 static void doc2001_readbuf(struct mtd_info *mtd, u_char *buf, int len) doc2001_readbuf() argument
499 struct nand_chip *this = mtd->priv; doc2001_readbuf()
514 static u_char doc2001plus_read_byte(struct mtd_info *mtd) doc2001plus_read_byte() argument
516 struct nand_chip *this = mtd->priv; doc2001plus_read_byte()
529 static void doc2001plus_writebuf(struct mtd_info *mtd, const u_char *buf, int len) doc2001plus_writebuf() argument
531 struct nand_chip *this = mtd->priv; doc2001plus_writebuf()
547 static void doc2001plus_readbuf(struct mtd_info *mtd, u_char *buf, int len) doc2001plus_readbuf() argument
549 struct nand_chip *this = mtd->priv; doc2001plus_readbuf()
578 static void doc2001plus_select_chip(struct mtd_info *mtd, int chip) doc2001plus_select_chip() argument
580 struct nand_chip *this = mtd->priv; doc2001plus_select_chip()
599 this->cmdfunc(mtd, NAND_CMD_RESET, -1, -1); doc2001plus_select_chip()
605 static void doc200x_select_chip(struct mtd_info *mtd, int chip) doc200x_select_chip() argument
607 struct nand_chip *this = mtd->priv; doc200x_select_chip()
622 doc200x_hwcontrol(mtd, NAND_CMD_NONE, 0 | NAND_CTRL_CHANGE); doc200x_select_chip()
627 doc200x_hwcontrol(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); doc200x_select_chip()
635 static void doc200x_hwcontrol(struct mtd_info *mtd, int cmd, doc200x_hwcontrol() argument
638 struct nand_chip *this = mtd->priv; doc200x_hwcontrol()
653 doc2000_write_byte(mtd, cmd); doc200x_hwcontrol()
655 doc2001_write_byte(mtd, cmd); doc200x_hwcontrol()
659 static void doc2001plus_command(struct mtd_info *mtd, unsigned command, int column, int page_addr) doc2001plus_command() argument
661 struct nand_chip *this = mtd->priv; doc2001plus_command()
680 if (column >= mtd->writesize) { doc2001plus_command()
682 column -= mtd->writesize; doc2001plus_command()
743 while (!(this->read_byte(mtd) & 0x40)) ; doc2001plus_command()
762 while (!this->dev_ready(mtd)) ; doc2001plus_command()
765 static int doc200x_dev_ready(struct mtd_info *mtd) doc200x_dev_ready() argument
767 struct nand_chip *this = mtd->priv; doc200x_dev_ready()
798 static int doc200x_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip) doc200x_block_bad() argument
805 static void doc200x_enable_hwecc(struct mtd_info *mtd, int mode) doc200x_enable_hwecc() argument
807 struct nand_chip *this = mtd->priv; doc200x_enable_hwecc()
824 static void doc2001plus_enable_hwecc(struct mtd_info *mtd, int mode) doc2001plus_enable_hwecc() argument
826 struct nand_chip *this = mtd->priv; doc2001plus_enable_hwecc()
844 static int doc200x_calculate_ecc(struct mtd_info *mtd, const u_char *dat, unsigned char *ecc_code) doc200x_calculate_ecc() argument
846 struct nand_chip *this = mtd->priv; doc200x_calculate_ecc()
903 static int doc200x_correct_data(struct mtd_info *mtd, u_char *dat, doc200x_correct_data() argument
907 struct nand_chip *this = mtd->priv; doc200x_correct_data()
1005 static int __init find_media_headers(struct mtd_info *mtd, u_char *buf, const char *id, int findmirror) find_media_headers() argument
1007 struct nand_chip *this = mtd->priv; find_media_headers()
1013 for (offs = 0; offs < mtd->size; offs += mtd->erasesize) { find_media_headers()
1014 ret = mtd_read(mtd, offs, mtd->writesize, &retlen, buf); find_media_headers()
1015 if (retlen != mtd->writesize) find_media_headers()
1039 ret = mtd_read(mtd, offs, mtd->writesize, &retlen, buf); find_media_headers()
1040 if (retlen != mtd->writesize) { find_media_headers()
1048 static inline int __init nftl_partscan(struct mtd_info *mtd, struct mtd_partition *parts) nftl_partscan() argument
1050 struct nand_chip *this = mtd->priv; nftl_partscan()
1060 buf = kmalloc(mtd->writesize, GFP_KERNEL); nftl_partscan()
1064 if (!(numheaders = find_media_headers(mtd, buf, "ANAND", 1))) nftl_partscan()
1081 blocks = mtd->size >> this->phys_erase_shift; nftl_partscan()
1082 maxblocks = min(32768U, mtd->erasesize - psize); nftl_partscan()
1106 mtd->erasesize <<= (0xff - mh->UnitSizeFactor); nftl_partscan()
1107 printk(KERN_INFO "Setting virtual erase size to %d\n", mtd->erasesize); nftl_partscan()
1108 blocks = mtd->size >> this->bbt_erase_shift; nftl_partscan()
1109 maxblocks = min(32768U, mtd->erasesize - psize); nftl_partscan()
1120 offs += mtd->erasesize; nftl_partscan()
1136 if (offs < mtd->size) { nftl_partscan()
1139 parts[numparts].size = mtd->size - offs; nftl_partscan()
1150 static inline int __init inftl_partscan(struct mtd_info *mtd, struct mtd_partition *parts) inftl_partscan() argument
1152 struct nand_chip *this = mtd->priv; inftl_partscan()
1162 int end = mtd->size; inftl_partscan()
1167 buf = kmalloc(mtd->writesize, GFP_KERNEL); inftl_partscan()
1172 if (!find_media_headers(mtd, buf, "BNAND", 0)) inftl_partscan()
1204 blocks = mtd->size >> vshift; inftl_partscan()
1211 if (inftl_bbt_write && (blocks > mtd->erasesize)) { inftl_partscan()
1240 parts[0].size = mtd->erasesize * ip->firstUnit; inftl_partscan()
1269 static int __init nftl_scan_bbt(struct mtd_info *mtd) nftl_scan_bbt() argument
1272 struct nand_chip *this = mtd->priv; nftl_scan_bbt()
1279 numparts = nftl_partscan(mtd, parts); nftl_scan_bbt()
1299 if ((ret = nand_scan_bbt(mtd, NULL))) nftl_scan_bbt()
1301 mtd_device_register(mtd, NULL, 0); nftl_scan_bbt()
1303 mtd_device_register(mtd, parts, numparts); nftl_scan_bbt()
1307 static int __init inftl_scan_bbt(struct mtd_info *mtd) inftl_scan_bbt() argument
1310 struct nand_chip *this = mtd->priv; inftl_scan_bbt()
1349 if ((ret = nand_scan_bbt(mtd, NULL))) inftl_scan_bbt()
1352 numparts = inftl_partscan(mtd, parts); inftl_scan_bbt()
1358 mtd_device_register(mtd, NULL, 0); inftl_scan_bbt()
1360 mtd_device_register(mtd, parts, numparts); inftl_scan_bbt()
1364 static inline int __init doc2000_init(struct mtd_info *mtd) doc2000_init() argument
1366 struct nand_chip *this = mtd->priv; doc2000_init()
1375 doc2000_count_chips(mtd); doc2000_init()
1376 mtd->name = "DiskOnChip 2000 (NFTL Model)"; doc2000_init()
1380 static inline int __init doc2001_init(struct mtd_info *mtd) doc2001_init() argument
1382 struct nand_chip *this = mtd->priv; doc2001_init()
1397 doc2000_count_chips(mtd); doc2001_init()
1398 mtd->name = "DiskOnChip 2000 (INFTL Model)"; doc2001_init()
1404 mtd->name = "DiskOnChip Millennium"; doc2001_init()
1410 static inline int __init doc2001plus_init(struct mtd_info *mtd) doc2001plus_init() argument
1412 struct nand_chip *this = mtd->priv; doc2001plus_init()
1425 mtd->name = "DiskOnChip Millennium Plus"; doc2001plus_init()
1433 struct mtd_info *mtd; doc_probe() local
1526 for (mtd = doclist; mtd; mtd = doc->nextdoc) { doc_probe()
1529 nand = mtd->priv; doc_probe()
1564 mtd = kzalloc(len, GFP_KERNEL); doc_probe()
1565 if (!mtd) { doc_probe()
1570 nand = (struct nand_chip *) (mtd + 1); doc_probe()
1575 mtd->priv = nand; doc_probe()
1576 mtd->owner = THIS_MODULE; doc_probe()
1605 numchips = doc2000_init(mtd); doc_probe()
1607 numchips = doc2001plus_init(mtd); doc_probe()
1609 numchips = doc2001_init(mtd); doc_probe()
1611 if ((ret = nand_scan(mtd, numchips))) { doc_probe()
1618 nand_release(mtd); doc_probe()
1619 kfree(mtd); doc_probe()
1624 doclist = mtd; doc_probe()
1642 struct mtd_info *mtd, *nextmtd; release_nanddoc() local
1646 for (mtd = doclist; mtd; mtd = nextmtd) { release_nanddoc()
1647 nand = mtd->priv; release_nanddoc()
1651 nand_release(mtd); release_nanddoc()
1654 kfree(mtd); release_nanddoc()
H A Dnand_bbt.c2 * drivers/mtd/nand_bbt.c
64 #include <linux/mtd/mtd.h>
65 #include <linux/mtd/bbm.h>
66 #include <linux/mtd/nand.h>
67 #include <linux/mtd/nand_ecc.h>
82 static int nand_update_bbt(struct mtd_info *mtd, loff_t offs);
165 * @mtd: MTD device structure
174 static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num, read_bbt() argument
178 struct nand_chip *this = mtd->priv; read_bbt()
201 res = mtd_read(mtd, from, len, &retlen, buf); read_bbt()
205 from & ~mtd->writesize); read_bbt()
209 from & ~mtd->writesize); read_bbt()
230 mtd->ecc_stats.bbtblocks++; read_bbt()
247 mtd->ecc_stats.badblocks++; read_bbt()
258 * @mtd: MTD device structure
267 static int read_abs_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *td, int chip) read_abs_bbt() argument
269 struct nand_chip *this = mtd->priv; read_abs_bbt()
276 res = read_bbt(mtd, buf, td->pages[i], read_abs_bbt()
284 res = read_bbt(mtd, buf, td->pages[0], read_abs_bbt()
285 mtd->size >> this->bbt_erase_shift, td, 0); read_abs_bbt()
293 static int scan_read_data(struct mtd_info *mtd, uint8_t *buf, loff_t offs, scan_read_data() argument
303 return mtd_read(mtd, offs, len, &retlen, buf); scan_read_data()
308 * @mtd: MTD device structure
317 static int scan_read_oob(struct mtd_info *mtd, uint8_t *buf, loff_t offs, scan_read_oob() argument
325 ops.ooblen = mtd->oobsize; scan_read_oob()
329 ops.len = min(len, (size_t)mtd->writesize); scan_read_oob()
332 res = mtd_read_oob(mtd, offs, &ops); scan_read_oob()
340 buf += mtd->oobsize + mtd->writesize; scan_read_oob()
341 len -= mtd->writesize; scan_read_oob()
342 offs += mtd->writesize; scan_read_oob()
347 static int scan_read(struct mtd_info *mtd, uint8_t *buf, loff_t offs, scan_read() argument
351 return scan_read_data(mtd, buf, offs, td); scan_read()
353 return scan_read_oob(mtd, buf, offs, len); scan_read()
357 static int scan_write_bbt(struct mtd_info *mtd, loff_t offs, size_t len, scan_write_bbt() argument
364 ops.ooblen = mtd->oobsize; scan_write_bbt()
369 return mtd_write_oob(mtd, offs, &ops); scan_write_bbt()
372 static u32 bbt_get_ver_offs(struct mtd_info *mtd, struct nand_bbt_descr *td) bbt_get_ver_offs() argument
377 ver_offs += mtd->writesize; bbt_get_ver_offs()
383 * @mtd: MTD device structure
391 static void read_abs_bbts(struct mtd_info *mtd, uint8_t *buf, read_abs_bbts() argument
394 struct nand_chip *this = mtd->priv; read_abs_bbts()
398 scan_read(mtd, buf, (loff_t)td->pages[0] << this->page_shift, read_abs_bbts()
399 mtd->writesize, td); read_abs_bbts()
400 td->version[0] = buf[bbt_get_ver_offs(mtd, td)]; read_abs_bbts()
407 scan_read(mtd, buf, (loff_t)md->pages[0] << this->page_shift, read_abs_bbts()
408 mtd->writesize, md); read_abs_bbts()
409 md->version[0] = buf[bbt_get_ver_offs(mtd, md)]; read_abs_bbts()
416 static int scan_block_fast(struct mtd_info *mtd, struct nand_bbt_descr *bd, scan_block_fast() argument
422 ops.ooblen = mtd->oobsize; scan_block_fast()
433 ret = mtd_read_oob(mtd, offs, &ops); scan_block_fast()
441 offs += mtd->writesize; scan_block_fast()
448 * @mtd: MTD device structure
457 static int create_bbt(struct mtd_info *mtd, uint8_t *buf, create_bbt() argument
460 struct nand_chip *this = mtd->priv; create_bbt()
473 numblocks = mtd->size >> this->bbt_erase_shift; create_bbt()
489 from += mtd->erasesize - (mtd->writesize * numpages); create_bbt()
496 ret = scan_block_fast(mtd, bd, from, buf, numpages); create_bbt()
504 mtd->ecc_stats.badblocks++; create_bbt()
514 * @mtd: MTD device structure
527 static int search_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *td) search_bbt() argument
529 struct nand_chip *this = mtd->priv; search_bbt()
532 int scanlen = mtd->writesize + mtd->oobsize; search_bbt()
538 startblock = (mtd->size >> this->bbt_erase_shift) - 1; search_bbt()
552 bbtblocks = mtd->size >> this->bbt_erase_shift; search_bbt()
566 scan_read(mtd, buf, offs, mtd->writesize, td); search_bbt()
567 if (!check_pattern(buf, scanlen, mtd->writesize, td)) { search_bbt()
570 offs = bbt_get_ver_offs(mtd, td); search_bbt()
591 * @mtd: MTD device structure
598 static void search_read_bbts(struct mtd_info *mtd, uint8_t *buf, search_read_bbts() argument
603 search_bbt(mtd, buf, td); search_read_bbts()
607 search_bbt(mtd, buf, md); search_read_bbts()
612 * @mtd: MTD device structure
620 static int write_bbt(struct mtd_info *mtd, uint8_t *buf, write_bbt() argument
624 struct nand_chip *this = mtd->priv; write_bbt()
635 ops.ooblen = mtd->oobsize; write_bbt()
653 numblocks = (int)(mtd->size >> this->bbt_erase_shift); write_bbt()
725 res = mtd_read(mtd, to, len, &retlen, buf); write_bbt()
734 ops.ooblen = (len >> this->page_shift) * mtd->oobsize; write_bbt()
736 res = mtd_read_oob(mtd, to + mtd->writesize, &ops); write_bbt()
745 ooboffs = len + (pageoffs * mtd->oobsize); write_bbt()
757 len = ALIGN(len, mtd->writesize); write_bbt()
766 len = ALIGN(len, mtd->writesize); write_bbt()
769 (len >> this->page_shift)* mtd->oobsize); write_bbt()
789 einfo.mtd = mtd; write_bbt()
792 res = nand_erase_nand(mtd, &einfo, 1); write_bbt()
796 res = scan_write_bbt(mtd, to, len, buf, write_bbt()
817 * @mtd: MTD device structure
823 static inline int nand_memory_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd) nand_memory_bbt() argument
825 struct nand_chip *this = mtd->priv; nand_memory_bbt()
827 return create_bbt(mtd, this->buffers->databuf, bd, -1); nand_memory_bbt()
832 * @mtd: MTD device structure
841 static int check_create(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *bd) check_create() argument
844 struct nand_chip *this = mtd->priv; check_create()
901 create_bbt(mtd, buf, bd, chipsel); check_create()
910 res = read_abs_bbt(mtd, buf, rd, chipsel); check_create()
921 res2 = read_abs_bbt(mtd, buf, rd2, chipsel); check_create()
943 res = write_bbt(mtd, buf, td, md, chipsel); check_create()
950 res = write_bbt(mtd, buf, md, td, chipsel); check_create()
960 * @mtd: MTD device structure
966 static void mark_bbt_region(struct mtd_info *mtd, struct nand_bbt_descr *td) mark_bbt_region() argument
968 struct nand_chip *this = mtd->priv; mark_bbt_region()
978 nrblocks = (int)(mtd->size >> this->bbt_erase_shift); mark_bbt_region()
991 nand_update_bbt(mtd, (loff_t)block << mark_bbt_region()
1013 nand_update_bbt(mtd, (loff_t)(block - 1) << mark_bbt_region()
1020 * @mtd: MTD device structure
1026 static void verify_bbt_descr(struct mtd_info *mtd, struct nand_bbt_descr *bd) verify_bbt_descr() argument
1028 struct nand_chip *this = mtd->priv; verify_bbt_descr()
1058 table_size = mtd->size >> this->bbt_erase_shift; verify_bbt_descr()
1068 * @mtd: MTD device structure
1078 int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd) nand_scan_bbt() argument
1080 struct nand_chip *this = mtd->priv; nand_scan_bbt()
1086 len = mtd->size >> (this->bbt_erase_shift + 2); nand_scan_bbt()
1100 if ((res = nand_memory_bbt(mtd, bd))) { nand_scan_bbt()
1107 verify_bbt_descr(mtd, td); nand_scan_bbt()
1108 verify_bbt_descr(mtd, md); nand_scan_bbt()
1112 len += (len >> this->page_shift) * mtd->oobsize; nand_scan_bbt()
1122 read_abs_bbts(mtd, buf, td, md); nand_scan_bbt()
1125 search_read_bbts(mtd, buf, td, md); nand_scan_bbt()
1128 res = check_create(mtd, buf, bd); nand_scan_bbt()
1131 mark_bbt_region(mtd, td); nand_scan_bbt()
1133 mark_bbt_region(mtd, md); nand_scan_bbt()
1141 * @mtd: MTD device structure
1146 static int nand_update_bbt(struct mtd_info *mtd, loff_t offs) nand_update_bbt() argument
1148 struct nand_chip *this = mtd->priv; nand_update_bbt()
1160 len += (len >> this->page_shift) * mtd->oobsize; nand_update_bbt()
1180 res = write_bbt(mtd, buf, td, md, chipsel); nand_update_bbt()
1186 res = write_bbt(mtd, buf, md, td, chipsel); nand_update_bbt()
1275 * @mtd: MTD device structure
1280 int nand_default_bbt(struct mtd_info *mtd) nand_default_bbt() argument
1282 struct nand_chip *this = mtd->priv; nand_default_bbt()
1308 return nand_scan_bbt(mtd, this->badblock_pattern); nand_default_bbt()
1313 * @mtd: MTD device structure
1316 int nand_isreserved_bbt(struct mtd_info *mtd, loff_t offs) nand_isreserved_bbt() argument
1318 struct nand_chip *this = mtd->priv; nand_isreserved_bbt()
1327 * @mtd: MTD device structure
1331 int nand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt) nand_isbad_bbt() argument
1333 struct nand_chip *this = mtd->priv; nand_isbad_bbt()
1355 * @mtd: MTD device structure
1358 int nand_markbad_bbt(struct mtd_info *mtd, loff_t offs) nand_markbad_bbt() argument
1360 struct nand_chip *this = mtd->priv; nand_markbad_bbt()
1370 ret = nand_update_bbt(mtd, offs); nand_markbad_bbt()
H A Dnuc900_nand.c21 #include <linux/mtd/mtd.h>
22 #include <linux/mtd/nand.h>
23 #include <linux/mtd/partitions.h>
58 struct mtd_info mtd; member in struct:nuc900_nand
78 static unsigned char nuc900_nand_read_byte(struct mtd_info *mtd) nuc900_nand_read_byte() argument
83 nand = container_of(mtd, struct nuc900_nand, mtd); nuc900_nand_read_byte()
90 static void nuc900_nand_read_buf(struct mtd_info *mtd, nuc900_nand_read_buf() argument
96 nand = container_of(mtd, struct nuc900_nand, mtd); nuc900_nand_read_buf()
102 static void nuc900_nand_write_buf(struct mtd_info *mtd, nuc900_nand_write_buf() argument
108 nand = container_of(mtd, struct nuc900_nand, mtd); nuc900_nand_write_buf()
125 static int nuc900_nand_devready(struct mtd_info *mtd) nuc900_nand_devready() argument
130 nand = container_of(mtd, struct nuc900_nand, mtd); nuc900_nand_devready()
136 static void nuc900_nand_command_lp(struct mtd_info *mtd, unsigned int command, nuc900_nand_command_lp() argument
139 register struct nand_chip *chip = mtd->priv; nuc900_nand_command_lp()
142 nand = container_of(mtd, struct nuc900_nand, mtd); nuc900_nand_command_lp()
145 column += mtd->writesize; nuc900_nand_command_lp()
214 while (!chip->dev_ready(mtd)) nuc900_nand_command_lp()
252 nuc900_nand->mtd.priv = chip; nuc900_nand_probe()
253 nuc900_nand->mtd.owner = THIS_MODULE; nuc900_nand_probe()
277 if (nand_scan(&(nuc900_nand->mtd), 1)) nuc900_nand_probe()
280 mtd_device_register(&(nuc900_nand->mtd), partitions, nuc900_nand_probe()
292 nand_release(&nuc900_nand->mtd); nuc900_nand_remove()
H A Dhisi504_nand.c23 #include <linux/mtd/mtd.h>
30 #include <linux/mtd/nand.h>
33 #include <linux/mtd/partitions.h>
137 struct mtd_info mtd; member in struct:hinfc_host
192 struct mtd_info *mtd = &host->mtd; hisi_nfc_dma_transfer() local
193 struct nand_chip *chip = mtd->priv; hisi_nfc_dma_transfer()
201 hinfc_write(host, ((mtd->oobsize & HINFC504_DMA_LEN_OOB_MASK) hisi_nfc_dma_transfer()
265 struct mtd_info *mtd = &host->mtd; hisi_nfc_send_cmd_readstart() local
279 hinfc_write(host, mtd->writesize + mtd->oobsize, hisi_nfc_send_cmd_readstart()
358 static void hisi_nfc_select_chip(struct mtd_info *mtd, int chipselect) hisi_nfc_select_chip() argument
360 struct nand_chip *chip = mtd->priv; hisi_nfc_select_chip()
369 static uint8_t hisi_nfc_read_byte(struct mtd_info *mtd) hisi_nfc_read_byte() argument
371 struct nand_chip *chip = mtd->priv; hisi_nfc_read_byte()
385 static u16 hisi_nfc_read_word(struct mtd_info *mtd) hisi_nfc_read_word() argument
387 struct nand_chip *chip = mtd->priv; hisi_nfc_read_word()
395 hisi_nfc_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) hisi_nfc_write_buf() argument
397 struct nand_chip *chip = mtd->priv; hisi_nfc_write_buf()
404 static void hisi_nfc_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) hisi_nfc_read_buf() argument
406 struct nand_chip *chip = mtd->priv; hisi_nfc_read_buf()
413 static void set_addr(struct mtd_info *mtd, int column, int page_addr) set_addr() argument
415 struct nand_chip *chip = mtd->priv; set_addr()
448 static void hisi_nfc_cmdfunc(struct mtd_info *mtd, unsigned command, int column, hisi_nfc_cmdfunc() argument
451 struct nand_chip *chip = mtd->priv; hisi_nfc_cmdfunc()
464 host->offset = column + mtd->writesize; hisi_nfc_cmdfunc()
467 set_addr(mtd, column, page_addr); hisi_nfc_cmdfunc()
473 set_addr(mtd, column, page_addr); hisi_nfc_cmdfunc()
477 set_addr(mtd, column, page_addr); hisi_nfc_cmdfunc()
543 static int hisi_nand_read_page_hwecc(struct mtd_info *mtd, hisi_nand_read_page_hwecc() argument
550 chip->read_buf(mtd, buf, mtd->writesize); hisi_nand_read_page_hwecc()
551 chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); hisi_nand_read_page_hwecc()
555 mtd->ecc_stats.failed++; hisi_nand_read_page_hwecc()
567 mtd->ecc_stats.corrected += stat; hisi_nand_read_page_hwecc()
575 static int hisi_nand_read_oob(struct mtd_info *mtd, struct nand_chip *chip, hisi_nand_read_oob() argument
580 chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page); hisi_nand_read_oob()
581 chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); hisi_nand_read_oob()
592 static int hisi_nand_write_page_hwecc(struct mtd_info *mtd, hisi_nand_write_page_hwecc() argument
595 chip->write_buf(mtd, buf, mtd->writesize); hisi_nand_write_page_hwecc()
597 chip->write_buf(mtd, chip->oob_poi, mtd->oobsize); hisi_nand_write_page_hwecc()
645 struct mtd_info *mtd = &host->mtd; hisi_nfc_ecc_probe() local
671 if (mtd->writesize == 2048) hisi_nfc_ecc_probe()
703 struct mtd_info *mtd; hisi_nfc_probe() local
715 mtd = &host->mtd; hisi_nfc_probe()
739 mtd->priv = chip; hisi_nfc_probe()
740 mtd->owner = THIS_MODULE; hisi_nfc_probe()
741 mtd->name = "hisi_nand"; hisi_nfc_probe()
742 mtd->dev.parent = &pdev->dev; hisi_nfc_probe()
767 ret = nand_scan_ident(mtd, max_chips, NULL); hisi_nfc_probe()
773 host->buffer = dmam_alloc_coherent(dev, mtd->writesize + mtd->oobsize, hisi_nfc_probe()
780 host->dma_oob = host->dma_buffer + mtd->writesize; hisi_nfc_probe()
781 memset(host->buffer, 0xff, mtd->writesize + mtd->oobsize); hisi_nfc_probe()
785 switch (mtd->writesize) { hisi_nfc_probe()
802 ret = nand_scan_tail(mtd); hisi_nfc_probe()
809 ret = mtd_device_parse_register(mtd, NULL, &ppdata, NULL, 0); hisi_nfc_probe()
818 nand_release(mtd); hisi_nfc_probe()
826 struct mtd_info *mtd = &host->mtd; hisi_nfc_remove() local
828 nand_release(mtd); hisi_nfc_remove()
H A Dplat_nand.c17 #include <linux/mtd/mtd.h>
18 #include <linux/mtd/nand.h>
19 #include <linux/mtd/partitions.h>
23 struct mtd_info mtd; member in struct:plat_nand_data
63 data->mtd.priv = &data->chip; plat_nand_probe()
64 data->mtd.owner = THIS_MODULE; plat_nand_probe()
65 data->mtd.name = dev_name(&pdev->dev); plat_nand_probe()
93 if (nand_scan(&data->mtd, pdata->chip.nr_chips)) { plat_nand_probe()
101 err = mtd_device_parse_register(&data->mtd, part_types, &ppdata, plat_nand_probe()
108 nand_release(&data->mtd); plat_nand_probe()
123 nand_release(&data->mtd); plat_nand_remove()
H A Djz4740_nand.c22 #include <linux/mtd/mtd.h>
23 #include <linux/mtd/nand.h>
24 #include <linux/mtd/partitions.h>
61 struct mtd_info mtd; member in struct:jz_nand
76 static inline struct jz_nand *mtd_to_jz_nand(struct mtd_info *mtd) mtd_to_jz_nand() argument
78 return container_of(mtd, struct jz_nand, mtd); mtd_to_jz_nand()
81 static void jz_nand_select_chip(struct mtd_info *mtd, int chipnr) jz_nand_select_chip() argument
83 struct jz_nand *nand = mtd_to_jz_nand(mtd); jz_nand_select_chip()
84 struct nand_chip *chip = mtd->priv; jz_nand_select_chip()
103 static void jz_nand_cmd_ctrl(struct mtd_info *mtd, int dat, unsigned int ctrl) jz_nand_cmd_ctrl() argument
105 struct jz_nand *nand = mtd_to_jz_nand(mtd); jz_nand_cmd_ctrl()
106 struct nand_chip *chip = mtd->priv; jz_nand_cmd_ctrl()
131 static int jz_nand_dev_ready(struct mtd_info *mtd) jz_nand_dev_ready() argument
133 struct jz_nand *nand = mtd_to_jz_nand(mtd); jz_nand_dev_ready()
137 static void jz_nand_hwctl(struct mtd_info *mtd, int mode) jz_nand_hwctl() argument
139 struct jz_nand *nand = mtd_to_jz_nand(mtd); jz_nand_hwctl()
165 static int jz_nand_calculate_ecc_rs(struct mtd_info *mtd, const uint8_t *dat, jz_nand_calculate_ecc_rs() argument
168 struct jz_nand *nand = mtd_to_jz_nand(mtd); jz_nand_calculate_ecc_rs()
218 static int jz_nand_correct_ecc_rs(struct mtd_info *mtd, uint8_t *dat, jz_nand_correct_ecc_rs() argument
221 struct jz_nand *nand = mtd_to_jz_nand(mtd); jz_nand_correct_ecc_rs()
336 struct mtd_info *mtd = &nand->mtd; jz_nand_detect_bank() local
366 ret = nand_scan_ident(mtd, 1, NULL); jz_nand_detect_bank()
371 chip->select_chip(mtd, 0); jz_nand_detect_bank()
372 chip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1); jz_nand_detect_bank()
373 chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1); jz_nand_detect_bank()
374 *nand_maf_id = chip->read_byte(mtd); jz_nand_detect_bank()
375 *nand_dev_id = chip->read_byte(mtd); jz_nand_detect_bank()
378 chip->select_chip(mtd, chipnr); jz_nand_detect_bank()
379 chip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1); jz_nand_detect_bank()
380 chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1); jz_nand_detect_bank()
381 if (*nand_maf_id != chip->read_byte(mtd) jz_nand_detect_bank()
382 || *nand_dev_id != chip->read_byte(mtd)) { jz_nand_detect_bank()
389 mtd->size += chip->chipsize; jz_nand_detect_bank()
413 struct mtd_info *mtd; jz_nand_probe() local
434 mtd = &nand->mtd; jz_nand_probe()
436 mtd->priv = chip; jz_nand_probe()
437 mtd->owner = THIS_MODULE; jz_nand_probe()
438 mtd->name = "jz4740-nand"; jz_nand_probe()
504 ret = nand_scan_tail(mtd); jz_nand_probe()
510 ret = mtd_device_parse_register(mtd, NULL, NULL, jz_nand_probe()
515 dev_err(&pdev->dev, "Failed to add mtd device\n"); jz_nand_probe()
524 nand_release(mtd); jz_nand_probe()
545 nand_release(&nand->mtd); jz_nand_remove()
H A Dsm_common.c10 #include <linux/mtd/nand.h>
41 static int sm_block_markbad(struct mtd_info *mtd, loff_t ofs) sm_block_markbad() argument
54 ops.ooblen = mtd->oobsize; sm_block_markbad()
59 ret = mtd_write_oob(mtd, ofs, &ops); sm_block_markbad()
103 int sm_register_device(struct mtd_info *mtd, int smartmedia) sm_register_device() argument
105 struct nand_chip *chip = mtd->priv; sm_register_device()
111 ret = nand_scan_ident(mtd, 1, smartmedia ? sm_register_device()
123 if (mtd->writesize == SM_SECTOR_SIZE) sm_register_device()
125 else if (mtd->writesize == SM_SMALL_PAGE) sm_register_device()
130 ret = nand_scan_tail(mtd); sm_register_device()
135 return mtd_device_register(mtd, NULL, 0); sm_register_device()
H A Dfsl_ifc_nand.c28 #include <linux/mtd/mtd.h>
29 #include <linux/mtd/nand.h>
30 #include <linux/mtd/partitions.h>
31 #include <linux/mtd/nand_ecc.h>
41 /* mtd information per set */
43 struct mtd_info mtd; member in struct:fsl_ifc_mtd
231 static void set_addr(struct mtd_info *mtd, int column, int page_addr, int oob) set_addr() argument
233 struct nand_chip *chip = mtd->priv; set_addr()
246 ifc_nand_ctrl->addr = priv->vbase + buf_num * (mtd->writesize * 2); set_addr()
251 ifc_nand_ctrl->index += mtd->writesize; set_addr()
254 static int is_blank(struct mtd_info *mtd, unsigned int bufnum) is_blank() argument
256 struct nand_chip *chip = mtd->priv; is_blank()
258 u8 __iomem *addr = priv->vbase + bufnum * (mtd->writesize * 2); is_blank()
260 u8 __iomem *oob = addr + mtd->writesize; is_blank()
263 for (i = 0; i < mtd->writesize / 4; i++) { is_blank()
279 static int check_read_ecc(struct mtd_info *mtd, struct fsl_ifc_ctrl *ctrl, check_read_ecc() argument
293 static void fsl_ifc_run_command(struct mtd_info *mtd) fsl_ifc_run_command() argument
295 struct nand_chip *chip = mtd->priv; fsl_ifc_run_command()
342 errors = check_read_ecc(mtd, ctrl, eccstat, i); fsl_ifc_run_command()
353 if (!is_blank(mtd, bufnum)) fsl_ifc_run_command()
359 mtd->ecc_stats.corrected += errors; fsl_ifc_run_command()
371 struct mtd_info *mtd) fsl_ifc_do_read()
378 if (mtd->writesize > 512) { fsl_ifc_do_read()
410 static void fsl_ifc_cmdfunc(struct mtd_info *mtd, unsigned int command, fsl_ifc_cmdfunc() argument
412 struct nand_chip *chip = mtd->priv; fsl_ifc_cmdfunc()
426 set_addr(mtd, 0, page_addr, 0); fsl_ifc_cmdfunc()
428 ifc_nand_ctrl->read_bytes = mtd->writesize + mtd->oobsize; fsl_ifc_cmdfunc()
434 fsl_ifc_do_read(chip, 0, mtd); fsl_ifc_cmdfunc()
435 fsl_ifc_run_command(mtd); fsl_ifc_cmdfunc()
440 iowrite32be(mtd->oobsize - column, &ifc->ifc_nand.nand_fbcr); fsl_ifc_cmdfunc()
441 set_addr(mtd, column, page_addr, 1); fsl_ifc_cmdfunc()
443 ifc_nand_ctrl->read_bytes = mtd->writesize + mtd->oobsize; fsl_ifc_cmdfunc()
445 fsl_ifc_do_read(chip, 1, mtd); fsl_ifc_cmdfunc()
446 fsl_ifc_run_command(mtd); fsl_ifc_cmdfunc()
471 set_addr(mtd, 0, 0, 0); fsl_ifc_cmdfunc()
472 fsl_ifc_run_command(mtd); fsl_ifc_cmdfunc()
478 set_addr(mtd, 0, page_addr, 0); fsl_ifc_cmdfunc()
494 fsl_ifc_run_command(mtd); fsl_ifc_cmdfunc()
503 if (mtd->writesize > 512) { fsl_ifc_cmdfunc()
545 if (column >= mtd->writesize) fsl_ifc_cmdfunc()
553 if (column >= mtd->writesize) { fsl_ifc_cmdfunc()
555 column -= mtd->writesize; fsl_ifc_cmdfunc()
559 set_addr(mtd, column, page_addr, ifc_nand_ctrl->oob); fsl_ifc_cmdfunc()
573 fsl_ifc_run_command(mtd); fsl_ifc_cmdfunc()
584 set_addr(mtd, 0, 0, 0); fsl_ifc_cmdfunc()
587 fsl_ifc_run_command(mtd); fsl_ifc_cmdfunc()
604 fsl_ifc_run_command(mtd); fsl_ifc_cmdfunc()
613 static void fsl_ifc_select_chip(struct mtd_info *mtd, int chip) fsl_ifc_select_chip() argument
623 static void fsl_ifc_write_buf(struct mtd_info *mtd, const u8 *buf, int len) fsl_ifc_write_buf() argument
625 struct nand_chip *chip = mtd->priv; fsl_ifc_write_buf()
627 unsigned int bufsize = mtd->writesize + mtd->oobsize; fsl_ifc_write_buf()
649 static uint8_t fsl_ifc_read_byte(struct mtd_info *mtd) fsl_ifc_read_byte() argument
651 struct nand_chip *chip = mtd->priv; fsl_ifc_read_byte()
672 static uint8_t fsl_ifc_read_byte16(struct mtd_info *mtd) fsl_ifc_read_byte16() argument
674 struct nand_chip *chip = mtd->priv; fsl_ifc_read_byte16()
695 static void fsl_ifc_read_buf(struct mtd_info *mtd, u8 *buf, int len) fsl_ifc_read_buf() argument
697 struct nand_chip *chip = mtd->priv; fsl_ifc_read_buf()
721 static int fsl_ifc_wait(struct mtd_info *mtd, struct nand_chip *chip) fsl_ifc_wait() argument
735 set_addr(mtd, 0, 0, 0); fsl_ifc_wait()
738 fsl_ifc_run_command(mtd); fsl_ifc_wait()
749 static int fsl_ifc_read_page(struct mtd_info *mtd, struct nand_chip *chip, fsl_ifc_read_page() argument
756 fsl_ifc_read_buf(mtd, buf, mtd->writesize); fsl_ifc_read_page()
758 fsl_ifc_read_buf(mtd, chip->oob_poi, mtd->oobsize); fsl_ifc_read_page()
764 mtd->ecc_stats.failed++; fsl_ifc_read_page()
772 static int fsl_ifc_write_page(struct mtd_info *mtd, struct nand_chip *chip, fsl_ifc_write_page() argument
775 fsl_ifc_write_buf(mtd, buf, mtd->writesize); fsl_ifc_write_page()
776 fsl_ifc_write_buf(mtd, chip->oob_poi, mtd->oobsize); fsl_ifc_write_page()
781 static int fsl_ifc_chip_init_tail(struct mtd_info *mtd) fsl_ifc_chip_init_tail() argument
783 struct nand_chip *chip = mtd->priv; fsl_ifc_chip_init_tail()
812 dev_dbg(priv->dev, "%s: mtd->flags = %08x\n", __func__, mtd->flags); fsl_ifc_chip_init_tail()
813 dev_dbg(priv->dev, "%s: mtd->size = %lld\n", __func__, mtd->size); fsl_ifc_chip_init_tail()
814 dev_dbg(priv->dev, "%s: mtd->erasesize = %d\n", __func__, fsl_ifc_chip_init_tail()
815 mtd->erasesize); fsl_ifc_chip_init_tail()
816 dev_dbg(priv->dev, "%s: mtd->writesize = %d\n", __func__, fsl_ifc_chip_init_tail()
817 mtd->writesize); fsl_ifc_chip_init_tail()
818 dev_dbg(priv->dev, "%s: mtd->oobsize = %d\n", __func__, fsl_ifc_chip_init_tail()
819 mtd->oobsize); fsl_ifc_chip_init_tail()
882 priv->mtd.priv = chip; fsl_ifc_chip_init()
883 priv->mtd.owner = THIS_MODULE; fsl_ifc_chip_init()
994 nand_release(&priv->mtd); fsl_ifc_chip_remove()
996 kfree(priv->mtd.name); fsl_ifc_chip_remove()
1105 priv->mtd.name = kasprintf(GFP_KERNEL, "%llx.flash", (u64)res.start); fsl_ifc_nand_probe()
1106 if (!priv->mtd.name) { fsl_ifc_nand_probe()
1115 ret = nand_scan_ident(&priv->mtd, 1, NULL); fsl_ifc_nand_probe()
1119 ret = fsl_ifc_chip_init_tail(&priv->mtd); fsl_ifc_nand_probe()
1123 ret = nand_scan_tail(&priv->mtd); fsl_ifc_nand_probe()
1129 mtd_device_parse_register(&priv->mtd, part_probe_types, &ppdata, fsl_ifc_nand_probe()
369 fsl_ifc_do_read(struct nand_chip *chip, int oob, struct mtd_info *mtd) fsl_ifc_do_read() argument
H A Dlpc32xx_mlc.c29 #include <linux/mtd/mtd.h>
30 #include <linux/mtd/nand.h>
31 #include <linux/mtd/partitions.h>
40 #include <linux/mtd/lpc32xx_mlc.h>
45 #include <linux/mtd/nand_ecc.h>
176 struct mtd_info mtd; member in struct:lpc32xx_nand_host
275 static void lpc32xx_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, lpc32xx_nand_cmd_ctrl() argument
278 struct nand_chip *nand_chip = mtd->priv; lpc32xx_nand_cmd_ctrl()
292 static int lpc32xx_nand_device_ready(struct mtd_info *mtd) lpc32xx_nand_device_ready() argument
294 struct nand_chip *nand_chip = mtd->priv; lpc32xx_nand_device_ready()
319 static int lpc32xx_waitfunc_nand(struct mtd_info *mtd, struct nand_chip *chip) lpc32xx_waitfunc_nand() argument
330 dev_dbg(&mtd->dev, "Warning: NAND not ready.\n"); lpc32xx_waitfunc_nand()
338 static int lpc32xx_waitfunc_controller(struct mtd_info *mtd, lpc32xx_waitfunc_controller() argument
350 dev_dbg(&mtd->dev, "Warning: Controller not ready.\n"); lpc32xx_waitfunc_controller()
358 static int lpc32xx_waitfunc(struct mtd_info *mtd, struct nand_chip *chip) lpc32xx_waitfunc() argument
360 lpc32xx_waitfunc_nand(mtd, chip); lpc32xx_waitfunc()
361 lpc32xx_waitfunc_controller(mtd, chip); lpc32xx_waitfunc()
389 static int lpc32xx_xmit_dma(struct mtd_info *mtd, void *mem, int len, lpc32xx_xmit_dma() argument
392 struct nand_chip *chip = mtd->priv; lpc32xx_xmit_dma()
403 dev_err(mtd->dev.parent, "Failed to map sg list\n"); lpc32xx_xmit_dma()
409 dev_err(mtd->dev.parent, "Failed to prepare slave sg\n"); lpc32xx_xmit_dma()
431 static int lpc32xx_read_page(struct mtd_info *mtd, struct nand_chip *chip, lpc32xx_read_page() argument
451 chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page); lpc32xx_read_page()
459 lpc32xx_waitfunc_controller(mtd, chip); lpc32xx_read_page()
464 mtd->ecc_stats.failed++; lpc32xx_read_page()
465 dev_warn(&mtd->dev, "%s: DECODER_FAILURE\n", __func__); lpc32xx_read_page()
467 mtd->ecc_stats.corrected += ((mlc_isr >> 4) & 0x3) + 1; lpc32xx_read_page()
472 res = lpc32xx_xmit_dma(mtd, dma_buf + i * 512, 512, lpc32xx_read_page()
491 memcpy(buf, dma_buf, mtd->writesize); lpc32xx_read_page()
496 static int lpc32xx_write_page_lowlevel(struct mtd_info *mtd, lpc32xx_write_page_lowlevel() argument
508 memcpy(dma_buf, buf, mtd->writesize); lpc32xx_write_page_lowlevel()
517 res = lpc32xx_xmit_dma(mtd, dma_buf + i * 512, 512, lpc32xx_write_page_lowlevel()
537 lpc32xx_waitfunc_controller(mtd, chip); lpc32xx_write_page_lowlevel()
542 static int lpc32xx_read_oob(struct mtd_info *mtd, struct nand_chip *chip, lpc32xx_read_oob() argument
548 lpc32xx_read_page(mtd, chip, host->dummy_buf, 1, page); lpc32xx_read_oob()
553 static int lpc32xx_write_oob(struct mtd_info *mtd, struct nand_chip *chip, lpc32xx_write_oob() argument
561 static void lpc32xx_ecc_enable(struct mtd_info *mtd, int mode) lpc32xx_ecc_enable() argument
568 struct mtd_info *mtd = &host->mtd; lpc32xx_dma_setup() local
572 dev_err(mtd->dev.parent, "no DMA platform data\n"); lpc32xx_dma_setup()
581 dev_err(mtd->dev.parent, "Failed to request DMA channel\n"); lpc32xx_dma_setup()
600 dev_err(mtd->dev.parent, "Failed to setup DMA slave\n"); lpc32xx_dma_setup()
645 struct mtd_info *mtd; lpc32xx_nand_probe() local
663 mtd = &host->mtd; lpc32xx_nand_probe()
684 mtd->priv = nand_chip; lpc32xx_nand_probe()
685 mtd->owner = THIS_MODULE; lpc32xx_nand_probe()
686 mtd->dev.parent = &pdev->dev; lpc32xx_nand_probe()
736 if (nand_scan_ident(mtd, 1, NULL)) { lpc32xx_nand_probe()
741 host->dma_buf = devm_kzalloc(&pdev->dev, mtd->writesize, GFP_KERNEL); lpc32xx_nand_probe()
747 host->dummy_buf = devm_kzalloc(&pdev->dev, mtd->writesize, GFP_KERNEL); lpc32xx_nand_probe()
754 nand_chip->ecc.size = mtd->writesize; lpc32xx_nand_probe()
756 host->mlcsubpages = mtd->writesize / 512; lpc32xx_nand_probe()
782 if (nand_scan_tail(mtd)) { lpc32xx_nand_probe()
787 mtd->name = DRV_NAME; lpc32xx_nand_probe()
790 res = mtd_device_parse_register(mtd, NULL, &ppdata, host->ncfg->parts, lpc32xx_nand_probe()
795 nand_release(mtd); lpc32xx_nand_probe()
818 struct mtd_info *mtd = &host->mtd; lpc32xx_nand_remove() local
820 nand_release(mtd); lpc32xx_nand_remove()
H A Dfsl_elbc_nand.c36 #include <linux/mtd/mtd.h>
37 #include <linux/mtd/nand.h>
38 #include <linux/mtd/nand_ecc.h>
39 #include <linux/mtd/partitions.h>
48 /* mtd information per set */
51 struct mtd_info mtd; member in struct:fsl_elbc_mtd
145 static void set_addr(struct mtd_info *mtd, int column, int page_addr, int oob) set_addr() argument
147 struct nand_chip *chip = mtd->priv; set_addr()
196 static int fsl_elbc_run_command(struct mtd_info *mtd) fsl_elbc_run_command() argument
198 struct nand_chip *chip = mtd->priv; fsl_elbc_run_command()
245 if (elbc_fcm_ctrl->read_bytes == mtd->writesize + mtd->oobsize) { fsl_elbc_run_command()
261 mtd->ecc_stats.corrected++; fsl_elbc_run_command()
300 static void fsl_elbc_cmdfunc(struct mtd_info *mtd, unsigned int command, fsl_elbc_cmdfunc() argument
303 struct nand_chip *chip = mtd->priv; fsl_elbc_cmdfunc()
329 set_addr(mtd, 0, page_addr, 0); fsl_elbc_cmdfunc()
331 elbc_fcm_ctrl->read_bytes = mtd->writesize + mtd->oobsize; fsl_elbc_cmdfunc()
335 fsl_elbc_run_command(mtd); fsl_elbc_cmdfunc()
344 out_be32(&lbc->fbcr, mtd->oobsize - column); fsl_elbc_cmdfunc()
345 set_addr(mtd, column, page_addr, 1); fsl_elbc_cmdfunc()
347 elbc_fcm_ctrl->read_bytes = mtd->writesize + mtd->oobsize; fsl_elbc_cmdfunc()
350 fsl_elbc_run_command(mtd); fsl_elbc_cmdfunc()
369 set_addr(mtd, 0, 0, 0); fsl_elbc_cmdfunc()
370 fsl_elbc_run_command(mtd); fsl_elbc_cmdfunc()
378 set_addr(mtd, 0, page_addr, 0); fsl_elbc_cmdfunc()
401 fsl_elbc_run_command(mtd); fsl_elbc_cmdfunc()
415 if (column >= mtd->writesize) { fsl_elbc_cmdfunc()
417 column -= mtd->writesize; fsl_elbc_cmdfunc()
457 set_addr(mtd, column, page_addr, elbc_fcm_ctrl->oob); fsl_elbc_cmdfunc()
472 elbc_fcm_ctrl->index != mtd->writesize + mtd->oobsize) fsl_elbc_cmdfunc()
478 fsl_elbc_run_command(mtd); fsl_elbc_cmdfunc()
490 set_addr(mtd, 0, 0, 0); fsl_elbc_cmdfunc()
493 fsl_elbc_run_command(mtd); fsl_elbc_cmdfunc()
506 fsl_elbc_run_command(mtd); fsl_elbc_cmdfunc()
516 static void fsl_elbc_select_chip(struct mtd_info *mtd, int chip) fsl_elbc_select_chip() argument
526 static void fsl_elbc_write_buf(struct mtd_info *mtd, const u8 *buf, int len) fsl_elbc_write_buf() argument
528 struct nand_chip *chip = mtd->priv; fsl_elbc_write_buf()
531 unsigned int bufsize = mtd->writesize + mtd->oobsize; fsl_elbc_write_buf()
564 static u8 fsl_elbc_read_byte(struct mtd_info *mtd) fsl_elbc_read_byte() argument
566 struct nand_chip *chip = mtd->priv; fsl_elbc_read_byte()
581 static void fsl_elbc_read_buf(struct mtd_info *mtd, u8 *buf, int len) fsl_elbc_read_buf() argument
583 struct nand_chip *chip = mtd->priv; fsl_elbc_read_buf()
606 static int fsl_elbc_wait(struct mtd_info *mtd, struct nand_chip *chip) fsl_elbc_wait() argument
620 static int fsl_elbc_chip_init_tail(struct mtd_info *mtd) fsl_elbc_chip_init_tail() argument
622 struct nand_chip *chip = mtd->priv; fsl_elbc_chip_init_tail()
663 dev_dbg(priv->dev, "fsl_elbc_init: mtd->flags = %08x\n", mtd->flags); fsl_elbc_chip_init_tail()
664 dev_dbg(priv->dev, "fsl_elbc_init: mtd->size = %lld\n", mtd->size); fsl_elbc_chip_init_tail()
665 dev_dbg(priv->dev, "fsl_elbc_init: mtd->erasesize = %d\n", fsl_elbc_chip_init_tail()
666 mtd->erasesize); fsl_elbc_chip_init_tail()
667 dev_dbg(priv->dev, "fsl_elbc_init: mtd->writesize = %d\n", fsl_elbc_chip_init_tail()
668 mtd->writesize); fsl_elbc_chip_init_tail()
669 dev_dbg(priv->dev, "fsl_elbc_init: mtd->oobsize = %d\n", fsl_elbc_chip_init_tail()
670 mtd->oobsize); fsl_elbc_chip_init_tail()
673 if (mtd->writesize == 512) { fsl_elbc_chip_init_tail()
676 } else if (mtd->writesize == 2048) { fsl_elbc_chip_init_tail()
690 mtd->writesize); fsl_elbc_chip_init_tail()
697 static int fsl_elbc_read_page(struct mtd_info *mtd, struct nand_chip *chip, fsl_elbc_read_page() argument
704 fsl_elbc_read_buf(mtd, buf, mtd->writesize); fsl_elbc_read_page()
706 fsl_elbc_read_buf(mtd, chip->oob_poi, mtd->oobsize); fsl_elbc_read_page()
708 if (fsl_elbc_wait(mtd, chip) & NAND_STATUS_FAIL) fsl_elbc_read_page()
709 mtd->ecc_stats.failed++; fsl_elbc_read_page()
717 static int fsl_elbc_write_page(struct mtd_info *mtd, struct nand_chip *chip, fsl_elbc_write_page() argument
720 fsl_elbc_write_buf(mtd, buf, mtd->writesize); fsl_elbc_write_page()
721 fsl_elbc_write_buf(mtd, chip->oob_poi, mtd->oobsize); fsl_elbc_write_page()
729 static int fsl_elbc_write_subpage(struct mtd_info *mtd, struct nand_chip *chip, fsl_elbc_write_subpage() argument
733 fsl_elbc_write_buf(mtd, buf, mtd->writesize); fsl_elbc_write_subpage()
734 fsl_elbc_write_buf(mtd, chip->oob_poi, mtd->oobsize); fsl_elbc_write_subpage()
749 priv->mtd.priv = chip; fsl_elbc_chip_init()
750 priv->mtd.owner = THIS_MODULE; fsl_elbc_chip_init()
800 nand_release(&priv->mtd); fsl_elbc_chip_remove()
802 kfree(priv->mtd.name); fsl_elbc_chip_remove()
890 priv->mtd.name = kasprintf(GFP_KERNEL, "%llx.flash", (u64)res.start); fsl_elbc_nand_probe()
891 if (!priv->mtd.name) { fsl_elbc_nand_probe()
900 ret = nand_scan_ident(&priv->mtd, 1, NULL); fsl_elbc_nand_probe()
904 ret = fsl_elbc_chip_init_tail(&priv->mtd); fsl_elbc_nand_probe()
908 ret = nand_scan_tail(&priv->mtd); fsl_elbc_nand_probe()
914 mtd_device_parse_register(&priv->mtd, part_probe_types, &ppdata, fsl_elbc_nand_probe()
H A Dsh_flctl.c41 #include <linux/mtd/mtd.h>
42 #include <linux/mtd/nand.h>
43 #include <linux/mtd/partitions.h>
44 #include <linux/mtd/sh_flctl.h>
192 static void set_addr(struct mtd_info *mtd, int column, int page_addr) set_addr() argument
194 struct sh_flctl *flctl = mtd_to_flctl(mtd); set_addr()
500 static void set_cmd_regs(struct mtd_info *mtd, uint32_t cmd, uint32_t flcmcdr_val) set_cmd_regs() argument
502 struct sh_flctl *flctl = mtd_to_flctl(mtd); set_cmd_regs()
562 static int flctl_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, flctl_read_page_hwecc() argument
565 chip->read_buf(mtd, buf, mtd->writesize); flctl_read_page_hwecc()
567 chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); flctl_read_page_hwecc()
571 static int flctl_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, flctl_write_page_hwecc() argument
574 chip->write_buf(mtd, buf, mtd->writesize); flctl_write_page_hwecc()
575 chip->write_buf(mtd, chip->oob_poi, mtd->oobsize); flctl_write_page_hwecc()
579 static void execmd_read_page_sector(struct mtd_info *mtd, int page_addr) execmd_read_page_sector() argument
581 struct sh_flctl *flctl = mtd_to_flctl(mtd); execmd_read_page_sector()
587 set_cmd_regs(mtd, NAND_CMD_READ0, execmd_read_page_sector()
602 &flctl->done_buff[mtd->writesize + 16 * sector], execmd_read_page_sector()
609 flctl->mtd.ecc_stats.corrected++; execmd_read_page_sector()
615 flctl->mtd.ecc_stats.failed++; execmd_read_page_sector()
628 static void execmd_read_oob(struct mtd_info *mtd, int page_addr) execmd_read_oob() argument
630 struct sh_flctl *flctl = mtd_to_flctl(mtd); execmd_read_oob()
634 set_cmd_regs(mtd, NAND_CMD_READ0, execmd_read_oob()
640 set_addr(mtd, (512 + 16) * i + 512 , page_addr); execmd_read_oob()
649 static void execmd_write_page_sector(struct mtd_info *mtd) execmd_write_page_sector() argument
651 struct sh_flctl *flctl = mtd_to_flctl(mtd); execmd_write_page_sector()
657 set_cmd_regs(mtd, NAND_CMD_PAGEPROG, execmd_write_page_sector()
668 write_ec_fiforeg(flctl, 16, mtd->writesize + 16 * sector); execmd_write_page_sector()
675 static void execmd_write_oob(struct mtd_info *mtd) execmd_write_oob() argument
677 struct sh_flctl *flctl = mtd_to_flctl(mtd); execmd_write_oob()
683 set_cmd_regs(mtd, NAND_CMD_PAGEPROG, execmd_write_oob()
688 set_addr(mtd, sector * 528 + 512, page_addr); execmd_write_oob()
697 static void flctl_cmdfunc(struct mtd_info *mtd, unsigned int command, flctl_cmdfunc() argument
700 struct sh_flctl *flctl = mtd_to_flctl(mtd); flctl_cmdfunc()
714 execmd_read_page_sector(mtd, page_addr); flctl_cmdfunc()
718 set_cmd_regs(mtd, command, (NAND_CMD_READSTART << 8) flctl_cmdfunc()
721 set_cmd_regs(mtd, command, command); flctl_cmdfunc()
723 set_addr(mtd, 0, page_addr); flctl_cmdfunc()
725 flctl->read_bytes = mtd->writesize + mtd->oobsize; flctl_cmdfunc()
734 execmd_read_oob(mtd, page_addr); flctl_cmdfunc()
739 set_cmd_regs(mtd, command, (NAND_CMD_READSTART << 8) flctl_cmdfunc()
741 set_addr(mtd, mtd->writesize, page_addr); flctl_cmdfunc()
743 set_cmd_regs(mtd, command, command); flctl_cmdfunc()
744 set_addr(mtd, 0, page_addr); flctl_cmdfunc()
746 flctl->read_bytes = mtd->oobsize; flctl_cmdfunc()
754 set_cmd_regs(mtd, command, (NAND_CMD_RNDOUTSTART << 8) flctl_cmdfunc()
757 set_cmd_regs(mtd, command, command); flctl_cmdfunc()
759 set_addr(mtd, column, 0); flctl_cmdfunc()
761 flctl->read_bytes = mtd->writesize + mtd->oobsize - column; flctl_cmdfunc()
765 set_cmd_regs(mtd, command, command); flctl_cmdfunc()
770 set_addr(mtd, column, 0); flctl_cmdfunc()
785 set_cmd_regs(mtd, NAND_CMD_ERASE1, flctl_cmdfunc()
787 set_addr(mtd, -1, flctl->erase1_page_addr); flctl_cmdfunc()
795 if (column >= mtd->writesize) { flctl_cmdfunc()
796 column -= mtd->writesize; flctl_cmdfunc()
813 set_cmd_regs(mtd, NAND_CMD_SEQIN, flctl_cmdfunc()
815 set_addr(mtd, -1, -1); flctl_cmdfunc()
822 if (flctl->seqin_column == mtd->writesize) flctl_cmdfunc()
823 execmd_write_oob(mtd); flctl_cmdfunc()
825 execmd_write_page_sector(mtd); flctl_cmdfunc()
830 set_cmd_regs(mtd, command, (command << 8) | NAND_CMD_SEQIN); flctl_cmdfunc()
831 set_addr(mtd, flctl->seqin_column, flctl->seqin_page_addr); flctl_cmdfunc()
839 set_cmd_regs(mtd, command, command); flctl_cmdfunc()
840 set_addr(mtd, -1, -1); flctl_cmdfunc()
849 set_cmd_regs(mtd, command, command); flctl_cmdfunc()
850 set_addr(mtd, -1, -1); flctl_cmdfunc()
873 static void flctl_select_chip(struct mtd_info *mtd, int chipnr) flctl_select_chip() argument
875 struct sh_flctl *flctl = mtd_to_flctl(mtd); flctl_select_chip()
917 static void flctl_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) flctl_write_buf() argument
919 struct sh_flctl *flctl = mtd_to_flctl(mtd); flctl_write_buf()
925 static uint8_t flctl_read_byte(struct mtd_info *mtd) flctl_read_byte() argument
927 struct sh_flctl *flctl = mtd_to_flctl(mtd); flctl_read_byte()
935 static uint16_t flctl_read_word(struct mtd_info *mtd) flctl_read_word() argument
937 struct sh_flctl *flctl = mtd_to_flctl(mtd); flctl_read_word()
944 static void flctl_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) flctl_read_buf() argument
946 struct sh_flctl *flctl = mtd_to_flctl(mtd); flctl_read_buf()
952 static int flctl_chip_init_tail(struct mtd_info *mtd) flctl_chip_init_tail() argument
954 struct sh_flctl *flctl = mtd_to_flctl(mtd); flctl_chip_init_tail()
957 if (mtd->writesize == 512) { flctl_chip_init_tail()
988 if (mtd->writesize == 512) { flctl_chip_init_tail()
1123 flctl_mtd = &flctl->mtd; flctl_probe()
1181 nand_release(&flctl->mtd); flctl_remove()
H A Domap2.c19 #include <linux/mtd/mtd.h>
20 #include <linux/mtd/nand.h>
21 #include <linux/mtd/partitions.h>
28 #include <linux/mtd/nand_bch.h>
31 #include <linux/platform_data/mtd-nand-omap2.h>
155 struct mtd_info mtd; member in struct:omap_nand_info
239 * @mtd: MTD device structure
248 static void omap_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl) omap_hwcontrol() argument
250 struct omap_nand_info *info = container_of(mtd, omap_hwcontrol()
251 struct omap_nand_info, mtd); omap_hwcontrol()
267 * @mtd: MTD device structure
271 static void omap_read_buf8(struct mtd_info *mtd, u_char *buf, int len) omap_read_buf8() argument
273 struct nand_chip *nand = mtd->priv; omap_read_buf8()
280 * @mtd: MTD device structure
284 static void omap_write_buf8(struct mtd_info *mtd, const u_char *buf, int len) omap_write_buf8() argument
286 struct omap_nand_info *info = container_of(mtd, omap_write_buf8()
287 struct omap_nand_info, mtd); omap_write_buf8()
303 * @mtd: MTD device structure
307 static void omap_read_buf16(struct mtd_info *mtd, u_char *buf, int len) omap_read_buf16() argument
309 struct nand_chip *nand = mtd->priv; omap_read_buf16()
316 * @mtd: MTD device structure
320 static void omap_write_buf16(struct mtd_info *mtd, const u_char * buf, int len) omap_write_buf16() argument
322 struct omap_nand_info *info = container_of(mtd, omap_write_buf16()
323 struct omap_nand_info, mtd); omap_write_buf16()
341 * @mtd: MTD device structure
345 static void omap_read_buf_pref(struct mtd_info *mtd, u_char *buf, int len) omap_read_buf_pref() argument
347 struct omap_nand_info *info = container_of(mtd, omap_read_buf_pref()
348 struct omap_nand_info, mtd); omap_read_buf_pref()
356 omap_read_buf16(mtd, buf, len % 4); omap_read_buf_pref()
358 omap_read_buf8(mtd, buf, len % 4); omap_read_buf_pref()
369 omap_read_buf16(mtd, (u_char *)p, len); omap_read_buf_pref()
371 omap_read_buf8(mtd, (u_char *)p, len); omap_read_buf_pref()
388 * @mtd: MTD device structure
392 static void omap_write_buf_pref(struct mtd_info *mtd, omap_write_buf_pref() argument
395 struct omap_nand_info *info = container_of(mtd, omap_write_buf_pref()
396 struct omap_nand_info, mtd); omap_write_buf_pref()
416 omap_write_buf16(mtd, (u_char *)p, len); omap_write_buf_pref()
418 omap_write_buf8(mtd, (u_char *)p, len); omap_write_buf_pref()
453 * @mtd: MTD device structure
458 static inline int omap_nand_dma_transfer(struct mtd_info *mtd, void *addr, omap_nand_dma_transfer() argument
461 struct omap_nand_info *info = container_of(mtd, omap_nand_dma_transfer()
462 struct omap_nand_info, mtd); omap_nand_dma_transfer()
533 is_write == 0 ? omap_read_buf16(mtd, (u_char *) addr, len) omap_nand_dma_transfer()
534 : omap_write_buf16(mtd, (u_char *) addr, len); omap_nand_dma_transfer()
536 is_write == 0 ? omap_read_buf8(mtd, (u_char *) addr, len) omap_nand_dma_transfer()
537 : omap_write_buf8(mtd, (u_char *) addr, len); omap_nand_dma_transfer()
543 * @mtd: MTD device structure
547 static void omap_read_buf_dma_pref(struct mtd_info *mtd, u_char *buf, int len) omap_read_buf_dma_pref() argument
549 if (len <= mtd->oobsize) omap_read_buf_dma_pref()
550 omap_read_buf_pref(mtd, buf, len); omap_read_buf_dma_pref()
553 omap_nand_dma_transfer(mtd, buf, len, 0x0); omap_read_buf_dma_pref()
558 * @mtd: MTD device structure
562 static void omap_write_buf_dma_pref(struct mtd_info *mtd, omap_write_buf_dma_pref() argument
565 if (len <= mtd->oobsize) omap_write_buf_dma_pref()
566 omap_write_buf_pref(mtd, buf, len); omap_write_buf_dma_pref()
569 omap_nand_dma_transfer(mtd, (u_char *) buf, len, 0x1); omap_write_buf_dma_pref()
620 * @mtd: MTD device structure
624 static void omap_read_buf_irq_pref(struct mtd_info *mtd, u_char *buf, int len) omap_read_buf_irq_pref() argument
626 struct omap_nand_info *info = container_of(mtd, omap_read_buf_irq_pref()
627 struct omap_nand_info, mtd); omap_read_buf_irq_pref()
630 if (len <= mtd->oobsize) { omap_read_buf_irq_pref()
631 omap_read_buf_pref(mtd, buf, len); omap_read_buf_irq_pref()
660 omap_read_buf16(mtd, buf, len); omap_read_buf_irq_pref()
662 omap_read_buf8(mtd, buf, len); omap_read_buf_irq_pref()
667 * @mtd: MTD device structure
671 static void omap_write_buf_irq_pref(struct mtd_info *mtd, omap_write_buf_irq_pref() argument
674 struct omap_nand_info *info = container_of(mtd, omap_write_buf_irq_pref()
675 struct omap_nand_info, mtd); omap_write_buf_irq_pref()
680 if (len <= mtd->oobsize) { omap_write_buf_irq_pref()
681 omap_write_buf_pref(mtd, buf, len); omap_write_buf_irq_pref()
719 omap_write_buf16(mtd, buf, len); omap_write_buf_irq_pref()
721 omap_write_buf8(mtd, buf, len); omap_write_buf_irq_pref()
874 * @mtd: MTD device structure
886 static int omap_correct_data(struct mtd_info *mtd, u_char *dat, omap_correct_data() argument
889 struct omap_nand_info *info = container_of(mtd, struct omap_nand_info, omap_correct_data()
890 mtd); omap_correct_data()
918 * @mtd: MTD device structure
928 static int omap_calculate_ecc(struct mtd_info *mtd, const u_char *dat, omap_calculate_ecc() argument
931 struct omap_nand_info *info = container_of(mtd, struct omap_nand_info, omap_calculate_ecc()
932 mtd); omap_calculate_ecc()
951 * @mtd: MTD device structure
954 static void omap_enable_hwecc(struct mtd_info *mtd, int mode) omap_enable_hwecc() argument
956 struct omap_nand_info *info = container_of(mtd, struct omap_nand_info, omap_enable_hwecc()
957 mtd); omap_enable_hwecc()
958 struct nand_chip *chip = mtd->priv; omap_enable_hwecc()
992 * @mtd: MTD device structure
1002 static int omap_wait(struct mtd_info *mtd, struct nand_chip *chip) omap_wait() argument
1004 struct nand_chip *this = mtd->priv; omap_wait()
1005 struct omap_nand_info *info = container_of(mtd, struct omap_nand_info, omap_wait()
1006 mtd); omap_wait()
1029 * @mtd: MTD device structure
1031 static int omap_dev_ready(struct mtd_info *mtd) omap_dev_ready() argument
1034 struct omap_nand_info *info = container_of(mtd, struct omap_nand_info, omap_dev_ready()
1035 mtd); omap_dev_ready()
1048 * @mtd: MTD device structure
1057 static void __maybe_unused omap_enable_hwecc_bch(struct mtd_info *mtd, int mode) omap_enable_hwecc_bch() argument
1061 struct omap_nand_info *info = container_of(mtd, struct omap_nand_info, omap_enable_hwecc_bch()
1062 mtd); omap_enable_hwecc_bch()
1064 struct nand_chip *chip = mtd->priv; omap_enable_hwecc_bch()
1156 * @mtd: MTD device structure
1162 static int __maybe_unused omap_calculate_ecc_bch(struct mtd_info *mtd, omap_calculate_ecc_bch() argument
1165 struct omap_nand_info *info = container_of(mtd, struct omap_nand_info, omap_calculate_ecc_bch()
1166 mtd); omap_calculate_ecc_bch()
1325 * @mtd: MTD device structure
1334 static int omap_elm_correct_data(struct mtd_info *mtd, u_char *data, omap_elm_correct_data() argument
1337 struct omap_nand_info *info = container_of(mtd, struct omap_nand_info, omap_elm_correct_data()
1338 mtd); omap_elm_correct_data()
1499 * @mtd: mtd info structure
1506 static int omap_write_page_bch(struct mtd_info *mtd, struct nand_chip *chip, omap_write_page_bch() argument
1514 chip->ecc.hwctl(mtd, NAND_ECC_WRITE); omap_write_page_bch()
1517 chip->write_buf(mtd, buf, mtd->writesize); omap_write_page_bch()
1520 chip->ecc.calculate(mtd, buf, &ecc_calc[0]); omap_write_page_bch()
1526 chip->write_buf(mtd, chip->oob_poi, mtd->oobsize); omap_write_page_bch()
1532 * @mtd: mtd info structure
1545 static int omap_read_page_bch(struct mtd_info *mtd, struct nand_chip *chip, omap_read_page_bch() argument
1552 uint32_t oob_pos = mtd->writesize + chip->ecc.layout->eccpos[0]; omap_read_page_bch()
1557 chip->ecc.hwctl(mtd, NAND_ECC_READ); omap_read_page_bch()
1560 chip->read_buf(mtd, buf, mtd->writesize); omap_read_page_bch()
1563 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, oob_pos, -1); omap_read_page_bch()
1564 chip->read_buf(mtd, oob, chip->ecc.total); omap_read_page_bch()
1567 chip->ecc.calculate(mtd, buf, ecc_calc); omap_read_page_bch()
1571 stat = chip->ecc.correct(mtd, buf, ecc_code, ecc_calc); omap_read_page_bch()
1574 mtd->ecc_stats.failed++; omap_read_page_bch()
1576 mtd->ecc_stats.corrected += stat; omap_read_page_bch()
1656 struct mtd_info *mtd; omap_nand_probe() local
1685 mtd = &info->mtd; omap_nand_probe()
1686 mtd->priv = &info->nand; omap_nand_probe()
1687 mtd->name = dev_name(&pdev->dev); omap_nand_probe()
1688 mtd->owner = THIS_MODULE; omap_nand_probe()
1726 if (nand_scan_ident(mtd, 1, NULL)) { omap_nand_probe()
1841 (mtd->writesize / omap_nand_probe()
1865 (mtd->writesize / omap_nand_probe()
1877 nand_chip->ecc.priv = nand_bch_init(mtd, omap_nand_probe()
1902 (mtd->writesize / omap_nand_probe()
1912 info->mtd.writesize / nand_chip->ecc.size, omap_nand_probe()
1929 (mtd->writesize / omap_nand_probe()
1941 nand_chip->ecc.priv = nand_bch_init(mtd, omap_nand_probe()
1966 info->mtd.writesize / nand_chip->ecc.size, omap_nand_probe()
1973 (mtd->writesize / omap_nand_probe()
1996 info->mtd.writesize / nand_chip->ecc.size, omap_nand_probe()
2003 (mtd->writesize / omap_nand_probe()
2022 ecclayout->oobfree->length = mtd->oobsize - ecclayout->oobfree->offset; omap_nand_probe()
2024 if (mtd->oobsize < (ecclayout->eccbytes + BADBLOCK_MARKER_LENGTH)) { omap_nand_probe()
2027 ecclayout->eccbytes, mtd->oobsize); omap_nand_probe()
2035 if (nand_scan_tail(mtd)) { omap_nand_probe()
2041 mtd_device_parse_register(mtd, NULL, &ppdata, pdata->parts, omap_nand_probe()
2044 platform_set_drvdata(pdev, mtd); omap_nand_probe()
2060 struct mtd_info *mtd = platform_get_drvdata(pdev); omap_nand_remove() local
2061 struct nand_chip *nand_chip = mtd->priv; omap_nand_remove()
2062 struct omap_nand_info *info = container_of(mtd, struct omap_nand_info, omap_nand_remove()
2063 mtd); omap_nand_remove()
2070 nand_release(mtd); omap_nand_remove()
H A Dsunxi_nand.c5 * https://github.com/yuq/sunxi-nfc-mtd
34 #include <linux/mtd/mtd.h>
35 #include <linux/mtd/nand.h>
36 #include <linux/mtd/partitions.h>
213 * @mtd: base MTD structure
222 struct mtd_info mtd; member in struct:sunxi_nand_chip
334 static int sunxi_nfc_dev_ready(struct mtd_info *mtd) sunxi_nfc_dev_ready() argument
336 struct nand_chip *nand = mtd->priv; sunxi_nfc_dev_ready()
372 static void sunxi_nfc_select_chip(struct mtd_info *mtd, int chip) sunxi_nfc_select_chip() argument
374 struct nand_chip *nand = mtd->priv; sunxi_nfc_select_chip()
402 writel(mtd->writesize, nfc->regs + NFC_REG_SPARE_AREA); sunxi_nfc_select_chip()
415 static void sunxi_nfc_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) sunxi_nfc_read_buf() argument
417 struct nand_chip *nand = mtd->priv; sunxi_nfc_read_buf()
447 static void sunxi_nfc_write_buf(struct mtd_info *mtd, const uint8_t *buf, sunxi_nfc_write_buf() argument
450 struct nand_chip *nand = mtd->priv; sunxi_nfc_write_buf()
479 static uint8_t sunxi_nfc_read_byte(struct mtd_info *mtd) sunxi_nfc_read_byte() argument
483 sunxi_nfc_read_buf(mtd, &ret, 1); sunxi_nfc_read_byte()
488 static void sunxi_nfc_cmd_ctrl(struct mtd_info *mtd, int dat, sunxi_nfc_cmd_ctrl() argument
491 struct nand_chip *nand = mtd->priv; sunxi_nfc_cmd_ctrl()
523 static int sunxi_nfc_hw_ecc_read_page(struct mtd_info *mtd, sunxi_nfc_hw_ecc_read_page() argument
547 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, i * ecc->size, -1); sunxi_nfc_hw_ecc_read_page()
549 offset = mtd->writesize + layout->eccpos[i * ecc->bytes] - 4; sunxi_nfc_hw_ecc_read_page()
551 chip->read_buf(mtd, NULL, ecc->size); sunxi_nfc_hw_ecc_read_page()
553 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, offset, -1); sunxi_nfc_hw_ecc_read_page()
570 mtd->ecc_stats.failed++; sunxi_nfc_hw_ecc_read_page()
573 mtd->ecc_stats.corrected += tmp; sunxi_nfc_hw_ecc_read_page()
578 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, offset, -1); sunxi_nfc_hw_ecc_read_page()
584 offset -= mtd->writesize; sunxi_nfc_hw_ecc_read_page()
585 chip->read_buf(mtd, chip->oob_poi + offset, sunxi_nfc_hw_ecc_read_page()
593 offset = mtd->writesize + sunxi_nfc_hw_ecc_read_page()
595 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, offset, -1); sunxi_nfc_hw_ecc_read_page()
596 offset -= mtd->writesize; sunxi_nfc_hw_ecc_read_page()
597 chip->read_buf(mtd, chip->oob_poi + offset, cnt); sunxi_nfc_hw_ecc_read_page()
609 static int sunxi_nfc_hw_ecc_write_page(struct mtd_info *mtd, sunxi_nfc_hw_ecc_write_page() argument
632 chip->cmdfunc(mtd, NAND_CMD_RNDIN, i * ecc->size, -1); sunxi_nfc_hw_ecc_write_page()
634 chip->write_buf(mtd, buf + (i * ecc->size), ecc->size); sunxi_nfc_hw_ecc_write_page()
636 offset = layout->eccpos[i * ecc->bytes] - 4 + mtd->writesize; sunxi_nfc_hw_ecc_write_page()
643 chip->cmdfunc(mtd, NAND_CMD_RNDIN, offset, -1); sunxi_nfc_hw_ecc_write_page()
660 offset = mtd->writesize + sunxi_nfc_hw_ecc_write_page()
662 chip->cmdfunc(mtd, NAND_CMD_RNDIN, offset, -1); sunxi_nfc_hw_ecc_write_page()
663 offset -= mtd->writesize; sunxi_nfc_hw_ecc_write_page()
664 chip->write_buf(mtd, chip->oob_poi + offset, cnt); sunxi_nfc_hw_ecc_write_page()
676 static int sunxi_nfc_hw_syndrome_ecc_read_page(struct mtd_info *mtd, sunxi_nfc_hw_syndrome_ecc_read_page() argument
700 chip->read_buf(mtd, NULL, ecc->size); sunxi_nfc_hw_syndrome_ecc_read_page()
714 mtd->ecc_stats.failed++; sunxi_nfc_hw_syndrome_ecc_read_page()
717 mtd->ecc_stats.corrected += tmp; sunxi_nfc_hw_syndrome_ecc_read_page()
722 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, offset, -1); sunxi_nfc_hw_syndrome_ecc_read_page()
723 chip->read_buf(mtd, oob, ecc->bytes + ecc->prepad); sunxi_nfc_hw_syndrome_ecc_read_page()
731 cnt = mtd->oobsize - (oob - chip->oob_poi); sunxi_nfc_hw_syndrome_ecc_read_page()
733 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, offset, -1); sunxi_nfc_hw_syndrome_ecc_read_page()
734 chip->read_buf(mtd, oob, cnt); sunxi_nfc_hw_syndrome_ecc_read_page()
744 static int sunxi_nfc_hw_syndrome_ecc_write_page(struct mtd_info *mtd, sunxi_nfc_hw_syndrome_ecc_write_page() argument
767 chip->write_buf(mtd, buf + (i * ecc->size), ecc->size); sunxi_nfc_hw_syndrome_ecc_write_page()
787 cnt = mtd->oobsize - (oob - chip->oob_poi); sunxi_nfc_hw_syndrome_ecc_write_page()
789 chip->cmdfunc(mtd, NAND_CMD_RNDIN, offset, -1); sunxi_nfc_hw_syndrome_ecc_write_page()
790 chip->write_buf(mtd, oob, cnt); sunxi_nfc_hw_syndrome_ecc_write_page()
902 ret = chip->nand.onfi_set_features(&chip->mtd, &chip->nand, sunxi_nand_chip_init_timings()
916 static int sunxi_nand_hw_common_ecc_ctrl_init(struct mtd_info *mtd, sunxi_nand_hw_common_ecc_ctrl_init() argument
921 struct nand_chip *nand = mtd->priv; sunxi_nand_hw_common_ecc_ctrl_init()
955 nsectors = mtd->writesize / ecc->size; sunxi_nand_hw_common_ecc_ctrl_init()
957 if (mtd->oobsize < ((ecc->bytes + 4) * nsectors)) { sunxi_nand_hw_common_ecc_ctrl_init()
980 static int sunxi_nand_hw_ecc_ctrl_init(struct mtd_info *mtd, sunxi_nand_hw_ecc_ctrl_init() argument
989 ret = sunxi_nand_hw_common_ecc_ctrl_init(mtd, ecc, np); sunxi_nand_hw_ecc_ctrl_init()
996 nsectors = mtd->writesize / ecc->size; sunxi_nand_hw_ecc_ctrl_init()
1021 if (mtd->oobsize > (ecc->bytes + 4) * nsectors) { sunxi_nand_hw_ecc_ctrl_init()
1026 layout->oobfree[nsectors].length = mtd->oobsize - sunxi_nand_hw_ecc_ctrl_init()
1033 static int sunxi_nand_hw_syndrome_ecc_ctrl_init(struct mtd_info *mtd, sunxi_nand_hw_syndrome_ecc_ctrl_init() argument
1042 ret = sunxi_nand_hw_common_ecc_ctrl_init(mtd, ecc, np); sunxi_nand_hw_syndrome_ecc_ctrl_init()
1051 nsectors = mtd->writesize / ecc->size; sunxi_nand_hw_syndrome_ecc_ctrl_init()
1056 layout->oobfree[0].length = mtd->oobsize - i; sunxi_nand_hw_syndrome_ecc_ctrl_init()
1076 static int sunxi_nand_ecc_init(struct mtd_info *mtd, struct nand_ecc_ctrl *ecc, sunxi_nand_ecc_init() argument
1079 struct nand_chip *nand = mtd->priv; sunxi_nand_ecc_init()
1107 ret = sunxi_nand_hw_ecc_ctrl_init(mtd, ecc, np); sunxi_nand_ecc_init()
1112 ret = sunxi_nand_hw_syndrome_ecc_ctrl_init(mtd, ecc, np); sunxi_nand_ecc_init()
1120 ecc->layout->oobfree[0].length = mtd->oobsize; sunxi_nand_ecc_init()
1136 struct mtd_info *mtd; sunxi_nand_chip_init() local
1237 mtd = &chip->mtd; sunxi_nand_chip_init()
1238 mtd->dev.parent = dev; sunxi_nand_chip_init()
1239 mtd->priv = nand; sunxi_nand_chip_init()
1240 mtd->owner = THIS_MODULE; sunxi_nand_chip_init()
1242 ret = nand_scan_ident(mtd, nsels, NULL); sunxi_nand_chip_init()
1252 ret = sunxi_nand_ecc_init(mtd, &nand->ecc, np); sunxi_nand_chip_init()
1258 ret = nand_scan_tail(mtd); sunxi_nand_chip_init()
1265 ret = mtd_device_parse_register(mtd, NULL, &ppdata, NULL, 0); sunxi_nand_chip_init()
1267 dev_err(dev, "failed to register mtd device: %d\n", ret); sunxi_nand_chip_init()
1268 nand_release(mtd); sunxi_nand_chip_init()
1305 nand_release(&chip->mtd); sunxi_nand_chips_cleanup()
H A Ddocg4.c4 * mtd nand driver for M-Systems DiskOnChip G4
42 #include <linux/mtd/partitions.h>
43 #include <linux/mtd/mtd.h>
44 #include <linux/mtd/nand.h>
71 * it does not use mtd nand's method for marking bad blocks (using oob area).
79 struct mtd_info *mtd; member in struct:docg4_priv
98 * Functions with names prefixed with docg4_ are mtd / nand interface functions
242 static void docg4_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) docg4_read_buf() argument
245 struct nand_chip *nand = mtd->priv; docg4_read_buf()
253 static void docg4_write_buf16(struct mtd_info *mtd, const uint8_t *buf, int len) docg4_write_buf16() argument
256 struct nand_chip *nand = mtd->priv; docg4_write_buf16()
297 static int docg4_wait(struct mtd_info *mtd, struct nand_chip *nand) docg4_wait() argument
315 static void docg4_select_chip(struct mtd_info *mtd, int chip) docg4_select_chip() argument
321 struct nand_chip *nand = mtd->priv; docg4_select_chip()
336 static void reset(struct mtd_info *mtd) reset() argument
340 struct nand_chip *nand = mtd->priv; reset()
371 static int correct_data(struct mtd_info *mtd, uint8_t *buf, int page) correct_data() argument
378 struct nand_chip *nand = mtd->priv; correct_data()
465 static uint8_t docg4_read_byte(struct mtd_info *mtd) docg4_read_byte() argument
467 struct nand_chip *nand = mtd->priv; docg4_read_byte()
541 static int pageprog(struct mtd_info *mtd) pageprog() argument
548 struct nand_chip *nand = mtd->priv; pageprog()
581 static void sequence_reset(struct mtd_info *mtd) sequence_reset() argument
585 struct nand_chip *nand = mtd->priv; sequence_reset()
598 static void read_page_prologue(struct mtd_info *mtd, uint32_t docg4_addr) read_page_prologue() argument
602 struct nand_chip *nand = mtd->priv; read_page_prologue()
609 sequence_reset(mtd); read_page_prologue()
625 static void write_page_prologue(struct mtd_info *mtd, uint32_t docg4_addr) write_page_prologue() argument
629 struct nand_chip *nand = mtd->priv; write_page_prologue()
635 sequence_reset(mtd); write_page_prologue()
656 * Convert mtd address to format used by the device, 32 bit packed. mtd_to_docg4_address()
665 * Rather than tell the mtd nand infrastructure that page size is 2k, mtd_to_docg4_address()
674 * This requires us to convert addresses passed by the mtd nand mtd_to_docg4_address()
681 * "sub-page" is 0x108, and the full device address of the start of mtd mtd_to_docg4_address()
689 static void docg4_command(struct mtd_info *mtd, unsigned command, int column, docg4_command() argument
694 struct nand_chip *nand = mtd->priv; docg4_command()
712 reset(mtd); docg4_command()
716 read_page_prologue(mtd, g4_addr); docg4_command()
733 write_page_prologue(mtd, g4_addr); docg4_command()
741 pageprog(mtd); docg4_command()
756 static int read_page(struct mtd_info *mtd, struct nand_chip *nand, read_page() argument
788 docg4_read_buf(mtd, buf, DOCG4_PAGE_SIZE); /* read the page data */ read_page()
792 docg4_read_buf(mtd, nand->oob_poi, 14); read_page()
809 bits_corrected = correct_data(mtd, buf, page); read_page()
811 mtd->ecc_stats.failed++; read_page()
813 mtd->ecc_stats.corrected += bits_corrected; read_page()
824 static int docg4_read_page_raw(struct mtd_info *mtd, struct nand_chip *nand, docg4_read_page_raw() argument
827 return read_page(mtd, nand, buf, page, false); docg4_read_page_raw()
830 static int docg4_read_page(struct mtd_info *mtd, struct nand_chip *nand, docg4_read_page() argument
833 return read_page(mtd, nand, buf, page, true); docg4_read_page()
836 static int docg4_read_oob(struct mtd_info *mtd, struct nand_chip *nand, docg4_read_oob() argument
845 docg4_command(mtd, NAND_CMD_READ0, nand->ecc.size, page); docg4_read_oob()
864 docg4_read_buf(mtd, nand->oob_poi, 16); docg4_read_oob()
875 static int docg4_erase_block(struct mtd_info *mtd, int page) docg4_erase_block() argument
877 struct nand_chip *nand = mtd->priv; docg4_erase_block()
884 sequence_reset(mtd); docg4_erase_block()
920 return nand->waitfunc(mtd, nand); docg4_erase_block()
923 static int write_page(struct mtd_info *mtd, struct nand_chip *nand, write_page() argument
939 docg4_write_buf16(mtd, buf, DOCG4_PAGE_SIZE); write_page()
942 docg4_write_buf16(mtd, nand->oob_poi, 6); write_page()
970 docg4_write_buf16(mtd, ecc_buf, 8); write_page()
979 static int docg4_write_page_raw(struct mtd_info *mtd, struct nand_chip *nand, docg4_write_page_raw() argument
982 return write_page(mtd, nand, buf, false); docg4_write_page_raw()
985 static int docg4_write_page(struct mtd_info *mtd, struct nand_chip *nand, docg4_write_page() argument
988 return write_page(mtd, nand, buf, true); docg4_write_page()
991 static int docg4_write_oob(struct mtd_info *mtd, struct nand_chip *nand, docg4_write_oob() argument
1012 static int __init read_factory_bbt(struct mtd_info *mtd) read_factory_bbt() argument
1019 struct nand_chip *nand = mtd->priv; read_factory_bbt()
1024 __u32 eccfailed_stats = mtd->ecc_stats.failed; read_factory_bbt()
1030 read_page_prologue(mtd, g4_addr); read_factory_bbt()
1031 docg4_read_page(mtd, nand, buf, 0, DOCG4_FACTORY_BBT_PAGE); read_factory_bbt()
1043 if (mtd->ecc_stats.failed > eccfailed_stats) { read_factory_bbt()
1048 eccfailed_stats = mtd->ecc_stats.failed; read_factory_bbt()
1049 docg4_read_page(mtd, nand, buf, 0, DOCG4_REDUNDANT_BBT_PAGE); read_factory_bbt()
1050 if (mtd->ecc_stats.failed > eccfailed_stats) { read_factory_bbt()
1069 mtd->ecc_stats.badblocks++; read_factory_bbt()
1079 static int docg4_block_markbad(struct mtd_info *mtd, loff_t ofs) docg4_block_markbad() argument
1092 struct nand_chip *nand = mtd->priv; docg4_block_markbad()
1110 memset(nand->oob_poi, 0xff, mtd->oobsize); docg4_block_markbad()
1115 write_page_prologue(mtd, g4_addr); docg4_block_markbad()
1116 docg4_write_page(mtd, nand, buf, 1); docg4_block_markbad()
1117 ret = pageprog(mtd); docg4_block_markbad()
1124 static int docg4_block_neverbad(struct mtd_info *mtd, loff_t ofs, int getchip) docg4_block_neverbad() argument
1190 static void __init init_mtd_structs(struct mtd_info *mtd) init_mtd_structs() argument
1192 /* initialize mtd and nand data structures */ init_mtd_structs()
1205 struct nand_chip *nand = mtd->priv; init_mtd_structs()
1208 mtd->size = DOCG4_CHIP_SIZE; init_mtd_structs()
1209 mtd->name = "Msys_Diskonchip_G4"; init_mtd_structs()
1210 mtd->writesize = DOCG4_PAGE_SIZE; init_mtd_structs()
1211 mtd->erasesize = DOCG4_BLOCK_SIZE; init_mtd_structs()
1212 mtd->oobsize = DOCG4_OOB_SIZE; init_mtd_structs()
1262 static int __init read_id_reg(struct mtd_info *mtd) read_id_reg() argument
1264 struct nand_chip *nand = mtd->priv; read_id_reg()
1288 struct mtd_info *mtd; probe_docg4() local
1310 mtd = kzalloc(len, GFP_KERNEL); probe_docg4()
1311 if (mtd == NULL) { probe_docg4()
1315 nand = (struct nand_chip *) (mtd + 1); probe_docg4()
1317 mtd->priv = nand; probe_docg4()
1319 mtd->owner = THIS_MODULE; probe_docg4()
1323 init_mtd_structs(mtd); probe_docg4()
1334 reset(mtd); probe_docg4()
1335 retval = read_id_reg(mtd); probe_docg4()
1341 retval = nand_scan_tail(mtd); probe_docg4()
1345 retval = read_factory_bbt(mtd); probe_docg4()
1349 retval = mtd_device_parse_register(mtd, part_probes, NULL, NULL, 0); probe_docg4()
1353 doc->mtd = mtd; probe_docg4()
1358 if (mtd) { probe_docg4()
1360 struct nand_chip *nand = mtd->priv; probe_docg4()
1362 nand_release(mtd); /* deletes partitions and mtd devices */ probe_docg4()
1364 kfree(mtd); probe_docg4()
1373 nand_release(doc->mtd); cleanup_docg4()
1375 kfree(doc->mtd); cleanup_docg4()
H A Dlpc32xx_slc.c25 #include <linux/mtd/mtd.h>
26 #include <linux/mtd/nand.h>
27 #include <linux/mtd/partitions.h>
35 #include <linux/mtd/nand_ecc.h>
40 #include <linux/mtd/lpc32xx_slc.h>
204 struct mtd_info mtd; member in struct:lpc32xx_nand_host
256 static void lpc32xx_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, lpc32xx_nand_cmd_ctrl() argument
260 struct nand_chip *chip = mtd->priv; lpc32xx_nand_cmd_ctrl()
282 static int lpc32xx_nand_device_ready(struct mtd_info *mtd) lpc32xx_nand_device_ready() argument
284 struct nand_chip *chip = mtd->priv; lpc32xx_nand_device_ready()
315 static void lpc32xx_nand_ecc_enable(struct mtd_info *mtd, int mode) lpc32xx_nand_ecc_enable() argument
323 static int lpc32xx_nand_ecc_calculate(struct mtd_info *mtd, lpc32xx_nand_ecc_calculate() argument
337 static uint8_t lpc32xx_nand_read_byte(struct mtd_info *mtd) lpc32xx_nand_read_byte() argument
339 struct nand_chip *chip = mtd->priv; lpc32xx_nand_read_byte()
348 static void lpc32xx_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len) lpc32xx_nand_read_buf() argument
350 struct nand_chip *chip = mtd->priv; lpc32xx_nand_read_buf()
361 static void lpc32xx_nand_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) lpc32xx_nand_write_buf() argument
363 struct nand_chip *chip = mtd->priv; lpc32xx_nand_write_buf()
374 static int lpc32xx_nand_read_oob_syndrome(struct mtd_info *mtd, lpc32xx_nand_read_oob_syndrome() argument
377 chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page); lpc32xx_nand_read_oob_syndrome()
378 chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); lpc32xx_nand_read_oob_syndrome()
386 static int lpc32xx_nand_write_oob_syndrome(struct mtd_info *mtd, lpc32xx_nand_write_oob_syndrome() argument
391 chip->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->writesize, page); lpc32xx_nand_write_oob_syndrome()
392 chip->write_buf(mtd, chip->oob_poi, mtd->oobsize); lpc32xx_nand_write_oob_syndrome()
395 chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1); lpc32xx_nand_write_oob_syndrome()
397 status = chip->waitfunc(mtd, chip); lpc32xx_nand_write_oob_syndrome()
425 static int lpc32xx_xmit_dma(struct mtd_info *mtd, dma_addr_t dma, lpc32xx_xmit_dma() argument
428 struct nand_chip *chip = mtd->priv; lpc32xx_xmit_dma()
444 dev_err(mtd->dev.parent, "Failed to setup DMA slave\n"); lpc32xx_xmit_dma()
453 dev_err(mtd->dev.parent, "Failed to map sg list\n"); lpc32xx_xmit_dma()
459 dev_err(mtd->dev.parent, "Failed to prepare slave sg\n"); lpc32xx_xmit_dma()
485 static int lpc32xx_xfer(struct mtd_info *mtd, uint8_t *buf, int eccsubpages, lpc32xx_xfer() argument
488 struct nand_chip *chip = mtd->priv; lpc32xx_xfer()
505 memcpy(host->data_buf, buf, mtd->writesize); lpc32xx_xfer()
523 writel(mtd->writesize, SLC_TC(host->io_base)); lpc32xx_xfer()
531 res = lpc32xx_xmit_dma(mtd, SLC_DMA_DATA(host->io_base_dma), lpc32xx_xfer()
533 mtd->writesize / chip->ecc.steps, dir); lpc32xx_xfer()
542 res = lpc32xx_xmit_dma(mtd, SLC_ECC(host->io_base_dma), lpc32xx_xfer()
556 dev_warn(mtd->dev.parent, "FIFO not empty!\n"); lpc32xx_xfer()
562 dev_err(mtd->dev.parent, "FIFO held data too long\n"); lpc32xx_xfer()
579 dev_err(mtd->dev.parent, "DMA FIFO failure\n"); lpc32xx_xfer()
591 memcpy(buf, host->data_buf, mtd->writesize); lpc32xx_xfer()
600 static int lpc32xx_nand_read_page_syndrome(struct mtd_info *mtd, lpc32xx_nand_read_page_syndrome() argument
609 chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page); lpc32xx_nand_read_page_syndrome()
612 status = lpc32xx_xfer(mtd, buf, chip->ecc.steps, 1); lpc32xx_nand_read_page_syndrome()
615 chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); lpc32xx_nand_read_page_syndrome()
624 stat = chip->ecc.correct(mtd, buf, oobecc, lpc32xx_nand_read_page_syndrome()
627 mtd->ecc_stats.failed++; lpc32xx_nand_read_page_syndrome()
629 mtd->ecc_stats.corrected += stat; lpc32xx_nand_read_page_syndrome()
642 static int lpc32xx_nand_read_page_raw_syndrome(struct mtd_info *mtd, lpc32xx_nand_read_page_raw_syndrome() argument
648 chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page); lpc32xx_nand_read_page_raw_syndrome()
651 chip->read_buf(mtd, buf, chip->ecc.size * chip->ecc.steps); lpc32xx_nand_read_page_raw_syndrome()
652 chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); lpc32xx_nand_read_page_raw_syndrome()
661 static int lpc32xx_nand_write_page_syndrome(struct mtd_info *mtd, lpc32xx_nand_write_page_syndrome() argument
670 error = lpc32xx_xfer(mtd, (uint8_t *)buf, chip->ecc.steps, 0); lpc32xx_nand_write_page_syndrome()
681 chip->write_buf(mtd, chip->oob_poi, mtd->oobsize); lpc32xx_nand_write_page_syndrome()
689 static int lpc32xx_nand_write_page_raw_syndrome(struct mtd_info *mtd, lpc32xx_nand_write_page_raw_syndrome() argument
695 chip->write_buf(mtd, buf, chip->ecc.size * chip->ecc.steps); lpc32xx_nand_write_page_raw_syndrome()
696 chip->write_buf(mtd, chip->oob_poi, mtd->oobsize); lpc32xx_nand_write_page_raw_syndrome()
702 struct mtd_info *mtd = &host->mtd; lpc32xx_nand_dma_setup() local
706 dev_err(mtd->dev.parent, "no DMA platform data\n"); lpc32xx_nand_dma_setup()
715 dev_err(mtd->dev.parent, "Failed to request DMA channel\n"); lpc32xx_nand_dma_setup()
759 struct mtd_info *mtd; lpc32xx_nand_probe() local
799 mtd = &host->mtd; lpc32xx_nand_probe()
802 mtd->priv = chip; lpc32xx_nand_probe()
803 mtd->owner = THIS_MODULE; lpc32xx_nand_probe()
804 mtd->dev.parent = &pdev->dev; lpc32xx_nand_probe()
862 if (nand_scan_ident(mtd, 1, NULL)) { lpc32xx_nand_probe()
875 if (mtd->writesize <= 512) lpc32xx_nand_probe()
892 if (mtd->writesize <= 512) { lpc32xx_nand_probe()
901 if (nand_scan_tail(mtd)) { lpc32xx_nand_probe()
906 mtd->name = "nxp_lpc3220_slc"; lpc32xx_nand_probe()
908 res = mtd_device_parse_register(mtd, NULL, &ppdata, host->ncfg->parts, lpc32xx_nand_probe()
913 nand_release(mtd); lpc32xx_nand_probe()
932 struct mtd_info *mtd = &host->mtd; lpc32xx_nand_remove() local
934 nand_release(mtd); lpc32xx_nand_remove()
H A Dtmio_nand.c36 #include <linux/mtd/mtd.h>
37 #include <linux/mtd/nand.h>
38 #include <linux/mtd/nand_ecc.h>
39 #include <linux/mtd/partitions.h>
106 struct mtd_info mtd; member in struct:tmio_nand
122 #define mtd_to_tmio(m) container_of(m, struct tmio_nand, mtd)
127 static void tmio_nand_hwcontrol(struct mtd_info *mtd, int cmd, tmio_nand_hwcontrol() argument
130 struct tmio_nand *tmio = mtd_to_tmio(mtd); tmio_nand_hwcontrol()
131 struct nand_chip *chip = mtd->priv; tmio_nand_hwcontrol()
160 static int tmio_nand_dev_ready(struct mtd_info *mtd) tmio_nand_dev_ready() argument
162 struct tmio_nand *tmio = mtd_to_tmio(mtd); tmio_nand_dev_ready()
189 tmio_nand_wait(struct mtd_info *mtd, struct nand_chip *nand_chip) tmio_nand_wait() argument
191 struct tmio_nand *tmio = mtd_to_tmio(mtd); tmio_nand_wait()
199 tmio_nand_dev_ready(mtd), tmio_nand_wait()
202 if (unlikely(!tmio_nand_dev_ready(mtd))) { tmio_nand_wait()
213 nand_chip->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1); tmio_nand_wait()
214 return nand_chip->read_byte(mtd); tmio_nand_wait()
225 static u_char tmio_nand_read_byte(struct mtd_info *mtd) tmio_nand_read_byte() argument
227 struct tmio_nand *tmio = mtd_to_tmio(mtd); tmio_nand_read_byte()
245 tmio_nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len) tmio_nand_write_buf() argument
247 struct tmio_nand *tmio = mtd_to_tmio(mtd); tmio_nand_write_buf()
252 static void tmio_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len) tmio_nand_read_buf() argument
254 struct tmio_nand *tmio = mtd_to_tmio(mtd); tmio_nand_read_buf()
259 static void tmio_nand_enable_hwecc(struct mtd_info *mtd, int mode) tmio_nand_enable_hwecc() argument
261 struct tmio_nand *tmio = mtd_to_tmio(mtd); tmio_nand_enable_hwecc()
268 static int tmio_nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat, tmio_nand_calculate_ecc() argument
271 struct tmio_nand *tmio = mtd_to_tmio(mtd); tmio_nand_calculate_ecc()
290 static int tmio_nand_correct_data(struct mtd_info *mtd, unsigned char *buf, tmio_nand_correct_data() argument
367 struct mtd_info *mtd; tmio_probe() local
381 mtd = &tmio->mtd; tmio_probe()
383 mtd->priv = nand_chip; tmio_probe()
384 mtd->name = "tmio-nand"; tmio_probe()
436 if (nand_scan(mtd, 1)) { tmio_probe()
441 retval = mtd_device_parse_register(mtd, NULL, NULL, tmio_probe()
447 nand_release(mtd); tmio_probe()
458 nand_release(&tmio->mtd); tmio_remove()
H A Dmxc_nand.c24 #include <linux/mtd/mtd.h>
25 #include <linux/mtd/nand.h>
26 #include <linux/mtd/partitions.h>
40 #include <linux/platform_data/mtd-mxc_nand.h>
153 void (*select_chip)(struct mtd_info *mtd, int chip);
154 int (*correct_data)(struct mtd_info *mtd, u_char *dat,
176 struct mtd_info mtd; member in struct:mxc_nand_host
500 static void send_page_v3(struct mtd_info *mtd, unsigned int ops) send_page_v3() argument
502 struct nand_chip *nand_chip = mtd->priv; send_page_v3()
516 static void send_page_v2(struct mtd_info *mtd, unsigned int ops) send_page_v2() argument
518 struct nand_chip *nand_chip = mtd->priv; send_page_v2()
530 static void send_page_v1(struct mtd_info *mtd, unsigned int ops) send_page_v1() argument
532 struct nand_chip *nand_chip = mtd->priv; send_page_v1()
536 if (mtd->writesize > 512) send_page_v1()
613 static int mxc_nand_dev_ready(struct mtd_info *mtd) mxc_nand_dev_ready() argument
622 static void mxc_nand_enable_hwecc(struct mtd_info *mtd, int mode) mxc_nand_enable_hwecc() argument
630 static int mxc_nand_correct_data_v1(struct mtd_info *mtd, u_char *dat, mxc_nand_correct_data_v1() argument
633 struct nand_chip *nand_chip = mtd->priv; mxc_nand_correct_data_v1()
651 static int mxc_nand_correct_data_v2_v3(struct mtd_info *mtd, u_char *dat, mxc_nand_correct_data_v2_v3() argument
654 struct nand_chip *nand_chip = mtd->priv; mxc_nand_correct_data_v2_v3()
664 no_subpages = mtd->writesize >> 9; mxc_nand_correct_data_v2_v3()
684 static int mxc_nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat, mxc_nand_calculate_ecc() argument
690 static u_char mxc_nand_read_byte(struct mtd_info *mtd) mxc_nand_read_byte() argument
692 struct nand_chip *nand_chip = mtd->priv; mxc_nand_read_byte()
714 static uint16_t mxc_nand_read_word(struct mtd_info *mtd) mxc_nand_read_word() argument
716 struct nand_chip *nand_chip = mtd->priv; mxc_nand_read_word()
729 static void mxc_nand_write_buf(struct mtd_info *mtd, mxc_nand_write_buf() argument
732 struct nand_chip *nand_chip = mtd->priv; mxc_nand_write_buf()
735 int n = mtd->oobsize + mtd->writesize - col; mxc_nand_write_buf()
748 static void mxc_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len) mxc_nand_read_buf() argument
750 struct nand_chip *nand_chip = mtd->priv; mxc_nand_read_buf()
753 int n = mtd->oobsize + mtd->writesize - col; mxc_nand_read_buf()
764 static void mxc_nand_select_chip_v1_v3(struct mtd_info *mtd, int chip) mxc_nand_select_chip_v1_v3() argument
766 struct nand_chip *nand_chip = mtd->priv; mxc_nand_select_chip_v1_v3()
785 static void mxc_nand_select_chip_v2(struct mtd_info *mtd, int chip) mxc_nand_select_chip_v2() argument
787 struct nand_chip *nand_chip = mtd->priv; mxc_nand_select_chip_v2()
812 static void copy_spare(struct mtd_info *mtd, bool bfrom) copy_spare() argument
814 struct nand_chip *this = mtd->priv; copy_spare()
817 u16 n = mtd->writesize >> 9; copy_spare()
818 u8 *d = host->data_buf + mtd->writesize; copy_spare()
822 j = (mtd->oobsize / n >> 1) << 1; copy_spare()
829 memcpy32_fromio(d + i * j, s + i * t, mtd->oobsize - i * j); copy_spare()
835 memcpy32_toio(&s[i * t], &d[i * j], mtd->oobsize - i * j); copy_spare()
845 static void mxc_do_addr_cycle(struct mtd_info *mtd, int column, int page_addr) mxc_do_addr_cycle() argument
847 struct nand_chip *nand_chip = mtd->priv; mxc_do_addr_cycle()
854 if (mtd->writesize > 512) mxc_do_addr_cycle()
866 if (mtd->writesize > 512) { mxc_do_addr_cycle()
867 if (mtd->size >= 0x10000000) { mxc_do_addr_cycle()
881 if (mtd->size >= 0x4000000) { mxc_do_addr_cycle()
902 static int get_eccsize(struct mtd_info *mtd) get_eccsize() argument
906 oobbytes_per_512 = mtd->oobsize * 512 / mtd->writesize; get_eccsize()
914 static void preset_v1(struct mtd_info *mtd) preset_v1() argument
916 struct nand_chip *nand_chip = mtd->priv; preset_v1()
920 if (nand_chip->ecc.mode == NAND_ECC_HW && mtd->writesize) preset_v1()
942 static void preset_v2(struct mtd_info *mtd) preset_v2() argument
944 struct nand_chip *nand_chip = mtd->priv; preset_v2()
953 if (mtd->writesize) { preset_v2()
954 uint16_t pages_per_block = mtd->erasesize / mtd->writesize; preset_v2()
959 host->eccsize = get_eccsize(mtd); preset_v2()
988 static void preset_v3(struct mtd_info *mtd) preset_v3() argument
990 struct nand_chip *chip = mtd->priv; preset_v3()
1011 NFC_V3_CONFIG2_SPAS(mtd->oobsize >> 1) | preset_v3()
1018 if (mtd->writesize == 2048) { preset_v3()
1021 } else if (mtd->writesize == 4096) { preset_v3()
1029 if (mtd->writesize) { preset_v3()
1034 ffs(mtd->erasesize / mtd->writesize) - 6, preset_v3()
1036 host->eccsize = get_eccsize(mtd); preset_v3()
1059 static void mxc_nand_command(struct mtd_info *mtd, unsigned command, mxc_nand_command() argument
1062 struct nand_chip *nand_chip = mtd->priv; mxc_nand_command()
1074 host->devtype_data->preset(mtd); mxc_nand_command()
1086 mxc_do_addr_cycle(mtd, column, page_addr); mxc_nand_command()
1094 host->buf_start = column + mtd->writesize; mxc_nand_command()
1102 mxc_do_addr_cycle(mtd, 0, page_addr); mxc_nand_command()
1104 if (mtd->writesize > 512) mxc_nand_command()
1108 host->devtype_data->send_page(mtd, NFC_OUTPUT); mxc_nand_command()
1111 mtd->writesize); mxc_nand_command()
1112 copy_spare(mtd, true); mxc_nand_command()
1116 if (column >= mtd->writesize) mxc_nand_command()
1118 mxc_nand_command(mtd, NAND_CMD_READ0, 0, page_addr); mxc_nand_command()
1126 mxc_do_addr_cycle(mtd, 0, page_addr); mxc_nand_command()
1130 memcpy32_toio(host->main_area0, host->data_buf, mtd->writesize); mxc_nand_command()
1131 copy_spare(mtd, false); mxc_nand_command()
1132 host->devtype_data->send_page(mtd, NFC_INPUT); mxc_nand_command()
1137 mxc_do_addr_cycle(mtd, column, page_addr); mxc_nand_command()
1142 mxc_do_addr_cycle(mtd, column, page_addr); mxc_nand_command()
1153 mxc_do_addr_cycle(mtd, column, page_addr); mxc_nand_command()
1158 mxc_do_addr_cycle(mtd, column, page_addr); mxc_nand_command()
1159 host->devtype_data->send_page(mtd, NFC_OUTPUT); mxc_nand_command()
1432 struct mtd_info *mtd; mxcnd_probe() local
1451 mtd = &host->mtd; mxcnd_probe()
1452 mtd->priv = this; mxcnd_probe()
1453 mtd->owner = THIS_MODULE; mxcnd_probe()
1454 mtd->dev.parent = &pdev->dev; mxcnd_probe()
1455 mtd->name = DRIVER_NAME; mxcnd_probe()
1571 if (nand_scan_ident(mtd, is_imx25_nfc(host) ? 4 : 1, NULL)) { mxcnd_probe()
1578 host->data_buf = devm_kzalloc(&pdev->dev, mtd->writesize + mtd->oobsize, mxcnd_probe()
1586 host->devtype_data->preset(mtd); mxcnd_probe()
1588 if (mtd->writesize == 2048) mxcnd_probe()
1590 else if (mtd->writesize == 4096) mxcnd_probe()
1601 if (nand_scan_tail(mtd)) { mxcnd_probe()
1607 mtd_device_parse_register(mtd, part_probes, mxcnd_probe()
1629 nand_release(&host->mtd); mxcnd_remove()
H A Dcs553x_nand.c2 * drivers/mtd/nand/cs553x_nand.c
16 * mtd-id for command line partitioning is cs553x_nand_cs[0-3]
26 #include <linux/mtd/mtd.h>
27 #include <linux/mtd/nand.h>
28 #include <linux/mtd/nand_ecc.h>
29 #include <linux/mtd/partitions.h>
98 static void cs553x_read_buf(struct mtd_info *mtd, u_char *buf, int len) cs553x_read_buf() argument
100 struct nand_chip *this = mtd->priv; cs553x_read_buf()
110 static void cs553x_write_buf(struct mtd_info *mtd, const u_char *buf, int len) cs553x_write_buf() argument
112 struct nand_chip *this = mtd->priv; cs553x_write_buf()
122 static unsigned char cs553x_read_byte(struct mtd_info *mtd) cs553x_read_byte() argument
124 struct nand_chip *this = mtd->priv; cs553x_read_byte()
128 static void cs553x_write_byte(struct mtd_info *mtd, u_char byte) cs553x_write_byte() argument
130 struct nand_chip *this = mtd->priv; cs553x_write_byte()
140 static void cs553x_hwcontrol(struct mtd_info *mtd, int cmd, cs553x_hwcontrol() argument
143 struct nand_chip *this = mtd->priv; cs553x_hwcontrol()
150 cs553x_write_byte(mtd, cmd); cs553x_hwcontrol()
153 static int cs553x_device_ready(struct mtd_info *mtd) cs553x_device_ready() argument
155 struct nand_chip *this = mtd->priv; cs553x_device_ready()
162 static void cs_enable_hwecc(struct mtd_info *mtd, int mode) cs_enable_hwecc() argument
164 struct nand_chip *this = mtd->priv; cs_enable_hwecc()
170 static int cs_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code) cs_calculate_ecc() argument
173 struct nand_chip *this = mtd->priv; cs_calculate_ecc()
327 struct mtd_info *mtd = cs553x_mtd[i]; cs553x_cleanup() local
331 if (!mtd) cs553x_cleanup()
346 kfree(mtd); cs553x_cleanup()
H A Dcmx270_nand.c2 * linux/drivers/mtd/nand/cmx270-nand.c
7 * Derived from drivers/mtd/nand/h1910.c
21 #include <linux/mtd/nand.h>
22 #include <linux/mtd/partitions.h>
54 static u_char cmx270_read_byte(struct mtd_info *mtd) cmx270_read_byte() argument
56 struct nand_chip *this = mtd->priv; cmx270_read_byte()
61 static void cmx270_write_buf(struct mtd_info *mtd, const u_char *buf, int len) cmx270_write_buf() argument
64 struct nand_chip *this = mtd->priv; cmx270_write_buf()
70 static void cmx270_read_buf(struct mtd_info *mtd, u_char *buf, int len) cmx270_read_buf() argument
73 struct nand_chip *this = mtd->priv; cmx270_read_buf()
94 static void cmx270_hwcontrol(struct mtd_info *mtd, int dat, cmx270_hwcontrol() argument
97 struct nand_chip* this = mtd->priv; cmx270_hwcontrol()
128 static int cmx270_device_ready(struct mtd_info *mtd) cmx270_device_ready() argument
H A Datmel_nand.c4 * Derived from drivers/mtd/nand/autcpu12.c
7 * Derived from drivers/mtd/spia.c
40 #include <linux/mtd/mtd.h>
41 #include <linux/mtd/nand.h>
42 #include <linux/mtd/partitions.h>
119 struct mtd_info mtd; member in struct:atmel_nand_host
183 static void atmel_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) atmel_nand_cmd_ctrl() argument
185 struct nand_chip *nand_chip = mtd->priv; atmel_nand_cmd_ctrl()
206 static int atmel_nand_device_ready(struct mtd_info *mtd) atmel_nand_device_ready() argument
208 struct nand_chip *nand_chip = mtd->priv; atmel_nand_device_ready()
216 static int atmel_nand_set_enable_ready_pins(struct mtd_info *mtd) atmel_nand_set_enable_ready_pins() argument
218 struct nand_chip *chip = mtd->priv; atmel_nand_set_enable_ready_pins()
268 static void atmel_read_buf8(struct mtd_info *mtd, u8 *buf, int len) atmel_read_buf8() argument
270 struct nand_chip *nand_chip = mtd->priv; atmel_read_buf8()
281 static void atmel_read_buf16(struct mtd_info *mtd, u8 *buf, int len) atmel_read_buf16() argument
283 struct nand_chip *nand_chip = mtd->priv; atmel_read_buf16()
294 static void atmel_write_buf8(struct mtd_info *mtd, const u8 *buf, int len) atmel_write_buf8() argument
296 struct nand_chip *nand_chip = mtd->priv; atmel_write_buf8()
301 static void atmel_write_buf16(struct mtd_info *mtd, const u8 *buf, int len) atmel_write_buf16() argument
303 struct nand_chip *nand_chip = mtd->priv; atmel_write_buf16()
321 if (host->mtd.writesize > 2048) nfc_set_sram_bank()
347 static int atmel_nand_dma_op(struct mtd_info *mtd, void *buf, int len, atmel_nand_dma_op() argument
355 struct nand_chip *chip = mtd->priv; atmel_nand_dma_op()
426 static void atmel_read_buf(struct mtd_info *mtd, u8 *buf, int len) atmel_read_buf() argument
428 struct nand_chip *chip = mtd->priv; atmel_read_buf()
431 if (use_dma && len > mtd->oobsize) atmel_read_buf()
433 if (atmel_nand_dma_op(mtd, buf, len, 1) == 0) atmel_read_buf()
437 atmel_read_buf16(mtd, buf, len); atmel_read_buf()
439 atmel_read_buf8(mtd, buf, len); atmel_read_buf()
442 static void atmel_write_buf(struct mtd_info *mtd, const u8 *buf, int len) atmel_write_buf() argument
444 struct nand_chip *chip = mtd->priv; atmel_write_buf()
447 if (use_dma && len > mtd->oobsize) atmel_write_buf()
449 if (atmel_nand_dma_op(mtd, (void *)buf, len, 0) == 0) atmel_write_buf()
453 atmel_write_buf16(mtd, buf, len); atmel_write_buf()
455 atmel_write_buf8(mtd, buf, len); atmel_write_buf()
534 static void pmecc_gen_syndrome(struct mtd_info *mtd, int sector) pmecc_gen_syndrome() argument
536 struct nand_chip *nand_chip = mtd->priv; pmecc_gen_syndrome()
551 static void pmecc_substitute(struct mtd_info *mtd) pmecc_substitute() argument
553 struct nand_chip *nand_chip = mtd->priv; pmecc_substitute()
593 static void pmecc_get_sigma(struct mtd_info *mtd) pmecc_get_sigma() argument
595 struct nand_chip *nand_chip = mtd->priv; pmecc_get_sigma()
751 static int pmecc_err_location(struct mtd_info *mtd) pmecc_err_location() argument
753 struct nand_chip *nand_chip = mtd->priv; pmecc_err_location()
802 static void pmecc_correct_data(struct mtd_info *mtd, uint8_t *buf, uint8_t *ecc, pmecc_correct_data() argument
805 struct nand_chip *nand_chip = mtd->priv; pmecc_correct_data()
848 static int pmecc_correction(struct mtd_info *mtd, u32 pmecc_stat, uint8_t *buf, pmecc_correction() argument
851 struct nand_chip *nand_chip = mtd->priv; pmecc_correction()
873 pmecc_gen_syndrome(mtd, i); pmecc_correction()
874 pmecc_substitute(mtd); pmecc_correction()
875 pmecc_get_sigma(mtd); pmecc_correction()
877 err_nbr = pmecc_err_location(mtd); pmecc_correction()
880 mtd->ecc_stats.failed++; pmecc_correction()
883 pmecc_correct_data(mtd, buf_pos, ecc, i, pmecc_correction()
885 mtd->ecc_stats.corrected += err_nbr; pmecc_correction()
919 static int atmel_nand_pmecc_read_page(struct mtd_info *mtd, atmel_nand_pmecc_read_page() argument
933 chip->read_buf(mtd, buf, eccsize); atmel_nand_pmecc_read_page()
934 chip->read_buf(mtd, oob, mtd->oobsize); atmel_nand_pmecc_read_page()
947 bitflips = pmecc_correction(mtd, stat, buf, &oob[eccpos[0]]); atmel_nand_pmecc_read_page()
956 static int atmel_nand_pmecc_write_page(struct mtd_info *mtd, atmel_nand_pmecc_write_page() argument
966 chip->write_buf(mtd, (u8 *)buf, mtd->writesize); atmel_nand_pmecc_write_page()
987 chip->write_buf(mtd, chip->oob_poi, mtd->oobsize); atmel_nand_pmecc_write_page()
992 static void atmel_pmecc_core_init(struct mtd_info *mtd) atmel_pmecc_core_init() argument
994 struct nand_chip *nand_chip = mtd->priv; atmel_pmecc_core_init()
1045 pmecc_writel(host->ecc, SAREA, mtd->oobsize - 1); atmel_pmecc_core_init()
1161 struct mtd_info *mtd = &host->mtd; atmel_pmecc_nand_init_params() local
1233 switch (mtd->writesize) { atmel_pmecc_nand_init_params()
1239 if (sector_size > mtd->writesize) { atmel_pmecc_nand_init_params()
1254 nand_chip->ecc.steps = mtd->writesize / sector_size; atmel_pmecc_nand_init_params()
1258 mtd->oobsize - PMECC_OOB_RESERVED_BYTES) { atmel_pmecc_nand_init_params()
1264 mtd->oobsize, atmel_pmecc_nand_init_params()
1290 atmel_pmecc_core_init(mtd); atmel_pmecc_nand_init_params()
1303 * mtd: MTD block structure
1307 static int atmel_nand_calculate(struct mtd_info *mtd, atmel_nand_calculate() argument
1310 struct nand_chip *nand_chip = mtd->priv; atmel_nand_calculate()
1332 * mtd: mtd info structure
1337 static int atmel_nand_read_page(struct mtd_info *mtd, struct nand_chip *chip, atmel_nand_read_page() argument
1362 chip->read_buf(mtd, p, eccsize); atmel_nand_read_page()
1372 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, atmel_nand_read_page()
1373 mtd->writesize + eccpos[0], -1); atmel_nand_read_page()
1378 chip->read_buf(mtd, ecc_pos, eccbytes); atmel_nand_read_page()
1381 stat = chip->ecc.correct(mtd, p, oob, NULL); atmel_nand_read_page()
1384 mtd->ecc_stats.failed++; atmel_nand_read_page()
1386 mtd->ecc_stats.corrected += stat; atmel_nand_read_page()
1391 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, mtd->writesize, -1); atmel_nand_read_page()
1394 chip->read_buf(mtd, oob, mtd->oobsize); atmel_nand_read_page()
1404 * mtd: MTD block structure
1411 static int atmel_nand_correct(struct mtd_info *mtd, u_char *dat, atmel_nand_correct() argument
1414 struct nand_chip *nand_chip = mtd->priv; atmel_nand_correct()
1478 static void atmel_nand_hwctl(struct mtd_info *mtd, int mode) atmel_nand_hwctl() argument
1480 struct nand_chip *nand_chip = mtd->priv; atmel_nand_hwctl()
1588 struct mtd_info *mtd = &host->mtd; atmel_hw_nand_init_params() local
1605 nand_chip->ecc.size = mtd->writesize; atmel_hw_nand_init_params()
1608 switch (mtd->writesize) { atmel_hw_nand_init_params()
1770 static int nfc_device_ready(struct mtd_info *mtd) nfc_device_ready() argument
1773 struct nand_chip *nand_chip = mtd->priv; nfc_device_ready()
1787 static void nfc_select_chip(struct mtd_info *mtd, int chip) nfc_select_chip() argument
1789 struct nand_chip *nand_chip = mtd->priv; nfc_select_chip()
1798 static int nfc_make_addr(struct mtd_info *mtd, int command, int column, nfc_make_addr() argument
1801 struct nand_chip *chip = mtd->priv; nfc_make_addr()
1817 if (mtd->writesize > 512) nfc_make_addr()
1838 static void nfc_nand_command(struct mtd_info *mtd, unsigned int command, nfc_nand_command() argument
1841 struct nand_chip *chip = mtd->priv; nfc_nand_command()
1869 nfc_nand_command(mtd, NAND_CMD_STATUS, -1, -1); nfc_nand_command()
1871 while (!(chip->read_byte(mtd) & NAND_STATUS_READY)) { nfc_nand_command()
1896 column += mtd->writesize; nfc_nand_command()
1927 acycle = nfc_make_addr(mtd, command, column, page_addr, nfc_nand_command()
1962 static int nfc_sram_write_page(struct mtd_info *mtd, struct nand_chip *chip, nfc_sram_write_page() argument
1972 if (offset || (data_len < mtd->writesize)) nfc_sram_write_page()
1975 len = mtd->writesize; nfc_sram_write_page()
1978 if (atmel_nand_dma_op(mtd, (void *)buf, len, 0) != 0) nfc_sram_write_page()
1987 memcpy(sram + len, chip->oob_poi, mtd->oobsize); nfc_sram_write_page()
1988 len += mtd->oobsize; nfc_sram_write_page()
2003 chip->cmdfunc(mtd, NAND_CMD_SEQIN, 0x00, page); nfc_sram_write_page()
2008 status = chip->ecc.write_page(mtd, chip, buf, oob_required); nfc_sram_write_page()
2013 chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1); nfc_sram_write_page()
2014 status = chip->waitfunc(mtd, chip); nfc_sram_write_page()
2017 status = chip->errstat(mtd, chip, FL_WRITING, status, page); nfc_sram_write_page()
2025 static int nfc_sram_init(struct mtd_info *mtd) nfc_sram_init() argument
2027 struct nand_chip *chip = mtd->priv; nfc_sram_init()
2035 switch (mtd->writesize) { nfc_sram_init()
2059 cfg_nfc |= (((mtd->oobsize / 4) - 1) << NFC_CFG_NFC_SPARESIZE_BIT_POS nfc_sram_init()
2091 struct mtd_info *mtd; atmel_nand_probe() local
2114 mtd = &host->mtd; atmel_nand_probe()
2128 mtd->priv = nand_chip; atmel_nand_probe()
2129 mtd->owner = THIS_MODULE; atmel_nand_probe()
2159 res = atmel_nand_set_enable_ready_pins(mtd); atmel_nand_probe()
2229 if (nand_scan_ident(mtd, 1, NULL)) { atmel_nand_probe()
2246 res = nfc_sram_init(mtd); atmel_nand_probe()
2254 if (nand_scan_tail(mtd)) { atmel_nand_probe()
2259 mtd->name = "atmel_nand"; atmel_nand_probe()
2261 res = mtd_device_parse_register(mtd, NULL, &ppdata, atmel_nand_probe()
2285 struct mtd_info *mtd = &host->mtd; atmel_nand_remove() local
2287 nand_release(mtd); atmel_nand_remove()
H A Dfsmc_nand.c2 * drivers/mtd/nand/fsmc_nand.c
12 * Based on drivers/mtd/nand/nomadik_nand.c
30 #include <linux/mtd/mtd.h>
31 #include <linux/mtd/nand.h>
32 #include <linux/mtd/nand_ecc.h>
35 #include <linux/mtd/partitions.h>
38 #include <linux/mtd/fsmc.h>
40 #include <mtd/mtd-abi.h>
281 * @mtd: MTD info for a NAND flash.
302 struct mtd_info mtd; member in struct:fsmc_nand_data
330 static void fsmc_select_chip(struct mtd_info *mtd, int chipnr) fsmc_select_chip() argument
332 struct nand_chip *chip = mtd->priv; fsmc_select_chip()
335 host = container_of(mtd, struct fsmc_nand_data, mtd); fsmc_select_chip()
339 chip->cmd_ctrl(mtd, NAND_CMD_NONE, 0 | NAND_CTRL_CHANGE); fsmc_select_chip()
359 static void fsmc_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) fsmc_cmd_ctrl() argument
361 struct nand_chip *this = mtd->priv; fsmc_cmd_ctrl()
362 struct fsmc_nand_data *host = container_of(mtd, fsmc_cmd_ctrl()
363 struct fsmc_nand_data, mtd); fsmc_cmd_ctrl()
446 static void fsmc_enable_hwecc(struct mtd_info *mtd, int mode) fsmc_enable_hwecc() argument
448 struct fsmc_nand_data *host = container_of(mtd, fsmc_enable_hwecc()
449 struct fsmc_nand_data, mtd); fsmc_enable_hwecc()
466 static int fsmc_read_hwecc_ecc4(struct mtd_info *mtd, const uint8_t *data, fsmc_read_hwecc_ecc4() argument
469 struct fsmc_nand_data *host = container_of(mtd, fsmc_read_hwecc_ecc4()
470 struct fsmc_nand_data, mtd); fsmc_read_hwecc_ecc4()
517 static int fsmc_read_hwecc_ecc1(struct mtd_info *mtd, const uint8_t *data, fsmc_read_hwecc_ecc1() argument
520 struct fsmc_nand_data *host = container_of(mtd, fsmc_read_hwecc_ecc1()
521 struct fsmc_nand_data, mtd); fsmc_read_hwecc_ecc1()
625 * @mtd: MTD device structure
629 static void fsmc_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) fsmc_write_buf() argument
632 struct nand_chip *chip = mtd->priv; fsmc_write_buf()
648 * @mtd: MTD device structure
652 static void fsmc_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) fsmc_read_buf() argument
655 struct nand_chip *chip = mtd->priv; fsmc_read_buf()
671 * @mtd: MTD device structure
675 static void fsmc_read_buf_dma(struct mtd_info *mtd, uint8_t *buf, int len) fsmc_read_buf_dma() argument
679 host = container_of(mtd, struct fsmc_nand_data, mtd); fsmc_read_buf_dma()
685 * @mtd: MTD device structure
689 static void fsmc_write_buf_dma(struct mtd_info *mtd, const uint8_t *buf, fsmc_write_buf_dma() argument
694 host = container_of(mtd, struct fsmc_nand_data, mtd); fsmc_write_buf_dma()
700 * @mtd: mtd info structure
712 static int fsmc_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, fsmc_read_page_hwecc() argument
715 struct fsmc_nand_data *host = container_of(mtd, fsmc_read_page_hwecc()
716 struct fsmc_nand_data, mtd); fsmc_read_page_hwecc()
735 chip->cmdfunc(mtd, NAND_CMD_READ0, s * eccsize, page); fsmc_read_page_hwecc()
736 chip->ecc.hwctl(mtd, NAND_ECC_READ); fsmc_read_page_hwecc()
737 chip->read_buf(mtd, p, eccsize); fsmc_read_page_hwecc()
752 chip->cmdfunc(mtd, NAND_CMD_READOOB, off, page); fsmc_read_page_hwecc()
753 chip->read_buf(mtd, oob + j, len); fsmc_read_page_hwecc()
758 chip->ecc.calculate(mtd, p, &ecc_calc[i]); fsmc_read_page_hwecc()
760 stat = chip->ecc.correct(mtd, p, &ecc_code[i], &ecc_calc[i]); fsmc_read_page_hwecc()
762 mtd->ecc_stats.failed++; fsmc_read_page_hwecc()
764 mtd->ecc_stats.corrected += stat; fsmc_read_page_hwecc()
774 * @mtd: mtd info structure
782 static int fsmc_bch8_correct_data(struct mtd_info *mtd, uint8_t *dat, fsmc_bch8_correct_data() argument
785 struct fsmc_nand_data *host = container_of(mtd, fsmc_bch8_correct_data()
786 struct fsmc_nand_data, mtd); fsmc_bch8_correct_data()
787 struct nand_chip *chip = mtd->priv; fsmc_bch8_correct_data()
931 struct mtd_info *mtd; fsmc_nand_probe() local
1015 mtd = &host->mtd; fsmc_nand_probe()
1017 mtd->priv = nand; fsmc_nand_probe()
1020 host->mtd.owner = THIS_MODULE; fsmc_nand_probe()
1083 if (nand_scan_ident(&host->mtd, 1, NULL)) { fsmc_nand_probe()
1090 switch (host->mtd.oobsize) { fsmc_nand_probe()
1113 mtd->oobsize); fsmc_nand_probe()
1117 switch (host->mtd.oobsize) { fsmc_nand_probe()
1129 mtd->oobsize); fsmc_nand_probe()
1135 if (nand_scan_tail(&host->mtd)) { fsmc_nand_probe()
1150 host->mtd.name = "nand"; fsmc_nand_probe()
1152 ret = mtd_device_parse_register(&host->mtd, NULL, &ppdata, fsmc_nand_probe()
1183 nand_release(&host->mtd); fsmc_nand_remove()
H A Dpxa3xx_nand.c2 * drivers/mtd/nand/pxa3xx_nand.c
11 * See Documentation/mtd/nand/pxa3xx-nand.txt for more details.
21 #include <linux/mtd/mtd.h>
22 #include <linux/mtd/nand.h>
23 #include <linux/mtd/partitions.h>
39 #include <linux/platform_data/mtd-nand-pxa3xx.h>
165 struct mtd_info *mtd; member in struct:pxa3xx_nand_host
393 struct mtd_info *mtd) pxa3xx_set_datasize()
397 info->data_size = mtd->writesize; pxa3xx_set_datasize()
743 struct mtd_info *mtd = host->mtd; prepare_start_command() local
763 pxa3xx_set_datasize(info, mtd); prepare_start_command()
782 info->buf_count = mtd->writesize + mtd->oobsize; prepare_start_command()
793 struct mtd_info *mtd; prepare_set_command() local
796 mtd = host->mtd; prepare_set_command()
820 info->buf_start += mtd->writesize; prepare_set_command()
827 if (mtd->writesize == PAGE_CHUNK_SIZE) { prepare_set_command()
829 } else if (mtd->writesize > PAGE_CHUNK_SIZE) { prepare_set_command()
837 set_command_address(info, mtd->writesize, column, page_addr); prepare_set_command()
843 set_command_address(info, mtd->writesize, 0, page_addr); prepare_set_command()
849 if (mtd->writesize > PAGE_CHUNK_SIZE) { prepare_set_command()
862 (mtd->writesize + mtd->oobsize))) { prepare_set_command()
868 if (mtd->writesize > PAGE_CHUNK_SIZE) { prepare_set_command()
963 static void nand_cmdfunc(struct mtd_info *mtd, unsigned command, nand_cmdfunc() argument
966 struct pxa3xx_nand_host *host = mtd->priv; nand_cmdfunc()
1010 static void nand_cmdfunc_extended(struct mtd_info *mtd, nand_cmdfunc_extended() argument
1014 struct pxa3xx_nand_host *host = mtd->priv; nand_cmdfunc_extended()
1120 static int pxa3xx_nand_write_page_hwecc(struct mtd_info *mtd, pxa3xx_nand_write_page_hwecc() argument
1123 chip->write_buf(mtd, buf, mtd->writesize); pxa3xx_nand_write_page_hwecc()
1124 chip->write_buf(mtd, chip->oob_poi, mtd->oobsize); pxa3xx_nand_write_page_hwecc()
1129 static int pxa3xx_nand_read_page_hwecc(struct mtd_info *mtd, pxa3xx_nand_read_page_hwecc() argument
1133 struct pxa3xx_nand_host *host = mtd->priv; pxa3xx_nand_read_page_hwecc()
1136 chip->read_buf(mtd, buf, mtd->writesize); pxa3xx_nand_read_page_hwecc()
1137 chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); pxa3xx_nand_read_page_hwecc()
1140 mtd->ecc_stats.corrected += info->ecc_err_cnt; pxa3xx_nand_read_page_hwecc()
1148 if (is_buf_blank(buf, mtd->writesize)) pxa3xx_nand_read_page_hwecc()
1151 mtd->ecc_stats.failed++; pxa3xx_nand_read_page_hwecc()
1157 static uint8_t pxa3xx_nand_read_byte(struct mtd_info *mtd) pxa3xx_nand_read_byte() argument
1159 struct pxa3xx_nand_host *host = mtd->priv; pxa3xx_nand_read_byte()
1170 static u16 pxa3xx_nand_read_word(struct mtd_info *mtd) pxa3xx_nand_read_word() argument
1172 struct pxa3xx_nand_host *host = mtd->priv; pxa3xx_nand_read_word()
1183 static void pxa3xx_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) pxa3xx_nand_read_buf() argument
1185 struct pxa3xx_nand_host *host = mtd->priv; pxa3xx_nand_read_buf()
1193 static void pxa3xx_nand_write_buf(struct mtd_info *mtd, pxa3xx_nand_write_buf() argument
1196 struct pxa3xx_nand_host *host = mtd->priv; pxa3xx_nand_write_buf()
1204 static void pxa3xx_nand_select_chip(struct mtd_info *mtd, int chip) pxa3xx_nand_select_chip() argument
1209 static int pxa3xx_nand_waitfunc(struct mtd_info *mtd, struct nand_chip *this) pxa3xx_nand_waitfunc() argument
1211 struct pxa3xx_nand_host *host = mtd->priv; pxa3xx_nand_waitfunc()
1372 struct mtd_info *mtd; pxa3xx_nand_sensing() local
1376 mtd = info->host[info->cs]->mtd; pxa3xx_nand_sensing()
1377 chip = mtd->priv; pxa3xx_nand_sensing()
1384 chip->cmdfunc(mtd, NAND_CMD_RESET, 0, 0); pxa3xx_nand_sensing()
1385 ret = chip->waitfunc(mtd, chip); pxa3xx_nand_sensing()
1461 static int pxa3xx_nand_scan(struct mtd_info *mtd) pxa3xx_nand_scan() argument
1463 struct pxa3xx_nand_host *host = mtd->priv; pxa3xx_nand_scan()
1469 struct nand_chip *chip = mtd->priv; pxa3xx_nand_scan()
1489 chip->cmdfunc(mtd, NAND_CMD_READID, 0, 0); pxa3xx_nand_scan()
1544 if (nand_scan_ident(mtd, 1, def)) pxa3xx_nand_scan()
1563 if (mtd->writesize > PAGE_CHUNK_SIZE) { pxa3xx_nand_scan()
1588 ecc_step, mtd->writesize); pxa3xx_nand_scan()
1593 if (mtd->writesize >= 2048) pxa3xx_nand_scan()
1602 info->buf_size = mtd->writesize + mtd->oobsize; pxa3xx_nand_scan()
1606 info->oob_buff = info->data_buff + mtd->writesize; pxa3xx_nand_scan()
1608 if ((mtd->size >> chip->page_shift) > 65536) pxa3xx_nand_scan()
1612 return nand_scan_tail(mtd); pxa3xx_nand_scan()
1621 struct mtd_info *mtd; alloc_nand_resource() local
1628 info = devm_kzalloc(&pdev->dev, sizeof(*info) + (sizeof(*mtd) + alloc_nand_resource()
1636 mtd = (struct mtd_info *)((unsigned int)&info[1] + alloc_nand_resource()
1637 (sizeof(*mtd) + sizeof(*host)) * cs); alloc_nand_resource()
1638 chip = (struct nand_chip *)(&mtd[1]); alloc_nand_resource()
1641 host->mtd = mtd; alloc_nand_resource()
1644 mtd->priv = host; alloc_nand_resource()
1645 mtd->owner = THIS_MODULE; alloc_nand_resource()
1767 nand_release(info->host[cs]->mtd); pxa3xx_nand_remove()
1838 struct mtd_info *mtd = info->host[cs]->mtd; pxa3xx_nand_probe() local
1841 * The mtd name matches the one used in 'mtdparts' kernel pxa3xx_nand_probe()
1843 * user's mtd partitions configuration would get broken. pxa3xx_nand_probe()
1845 mtd->name = "pxa3xx_nand-0"; pxa3xx_nand_probe()
1847 ret = pxa3xx_nand_scan(mtd); pxa3xx_nand_probe()
1855 ret = mtd_device_parse_register(mtd, NULL, pxa3xx_nand_probe()
1875 struct mtd_info *mtd; pxa3xx_nand_suspend() local
1885 mtd = info->host[cs]->mtd; pxa3xx_nand_suspend()
1886 mtd_suspend(mtd); pxa3xx_nand_suspend()
1896 struct mtd_info *mtd; pxa3xx_nand_resume() local
1900 /* We don't want to handle interrupt without calling mtd routine */ pxa3xx_nand_resume()
1918 mtd = info->host[cs]->mtd; pxa3xx_nand_resume()
1919 mtd_resume(mtd); pxa3xx_nand_resume()
392 pxa3xx_set_datasize(struct pxa3xx_nand_info *info, struct mtd_info *mtd) pxa3xx_set_datasize() argument
H A Dnand_bch.c27 #include <linux/mtd/mtd.h>
28 #include <linux/mtd/nand.h>
29 #include <linux/mtd/nand_bch.h>
48 * @mtd: MTD block structure
52 int nand_bch_calculate_ecc(struct mtd_info *mtd, const unsigned char *buf, nand_bch_calculate_ecc() argument
55 const struct nand_chip *chip = mtd->priv; nand_bch_calculate_ecc()
72 * @mtd: MTD block structure
79 int nand_bch_correct_data(struct mtd_info *mtd, unsigned char *buf, nand_bch_correct_data() argument
82 const struct nand_chip *chip = mtd->priv; nand_bch_correct_data()
109 * @mtd: MTD block structure
127 nand_bch_init(struct mtd_info *mtd, unsigned int eccsize, unsigned int eccbytes, nand_bch_init() argument
158 eccsteps = mtd->writesize/eccsize; nand_bch_init()
164 if (mtd->oobsize < 64) { nand_bch_init()
166 "oobsize %d\n", mtd->oobsize); nand_bch_init()
174 if (layout->eccbytes+2 > mtd->oobsize) { nand_bch_init()
176 "for oobsize %d eccbytes %u\n", mtd->oobsize, nand_bch_init()
182 layout->eccpos[i] = mtd->oobsize-layout->eccbytes+i; nand_bch_init()
185 layout->oobfree[0].length = mtd->oobsize-2-layout->eccbytes; nand_bch_init()
H A Dams-delta.c2 * drivers/mtd/nand/ams-delta.c
6 * Derived from drivers/mtd/toto.c
8 * Partially stolen from drivers/mtd/nand/plat_nand.c
22 #include <linux/mtd/mtd.h>
23 #include <linux/mtd/nand.h>
24 #include <linux/mtd/partitions.h>
65 static void ams_delta_write_byte(struct mtd_info *mtd, u_char byte) ams_delta_write_byte() argument
67 struct nand_chip *this = mtd->priv; ams_delta_write_byte()
77 static u_char ams_delta_read_byte(struct mtd_info *mtd) ams_delta_read_byte() argument
80 struct nand_chip *this = mtd->priv; ams_delta_read_byte()
92 static void ams_delta_write_buf(struct mtd_info *mtd, const u_char *buf, ams_delta_write_buf() argument
98 ams_delta_write_byte(mtd, buf[i]); ams_delta_write_buf()
101 static void ams_delta_read_buf(struct mtd_info *mtd, u_char *buf, int len) ams_delta_read_buf() argument
106 buf[i] = ams_delta_read_byte(mtd); ams_delta_read_buf()
117 static void ams_delta_hwcontrol(struct mtd_info *mtd, int cmd, ams_delta_hwcontrol() argument
131 ams_delta_write_byte(mtd, cmd); ams_delta_hwcontrol()
134 static int ams_delta_nand_ready(struct mtd_info *mtd) ams_delta_nand_ready() argument
H A Dpasemi_nand.c27 #include <linux/mtd/mtd.h>
28 #include <linux/mtd/nand.h>
29 #include <linux/mtd/nand_ecc.h>
46 static void pasemi_read_buf(struct mtd_info *mtd, u_char *buf, int len) pasemi_read_buf() argument
48 struct nand_chip *chip = mtd->priv; pasemi_read_buf()
58 static void pasemi_write_buf(struct mtd_info *mtd, const u_char *buf, int len) pasemi_write_buf() argument
60 struct nand_chip *chip = mtd->priv; pasemi_write_buf()
70 static void pasemi_hwcontrol(struct mtd_info *mtd, int cmd, pasemi_hwcontrol() argument
73 struct nand_chip *chip = mtd->priv; pasemi_hwcontrol()
88 int pasemi_device_ready(struct mtd_info *mtd) pasemi_device_ready() argument
H A Dr852.c65 static inline struct r852_device *r852_get_dev(struct mtd_info *mtd) r852_get_dev() argument
67 struct nand_chip *chip = mtd->priv; r852_get_dev()
232 static void r852_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) r852_write_buf() argument
234 struct r852_device *dev = r852_get_dev(mtd); r852_write_buf()
266 static void r852_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) r852_read_buf() argument
268 struct r852_device *dev = r852_get_dev(mtd); r852_read_buf()
303 static uint8_t r852_read_byte(struct mtd_info *mtd) r852_read_byte() argument
305 struct r852_device *dev = r852_get_dev(mtd); r852_read_byte()
317 static void r852_cmdctl(struct mtd_info *mtd, int dat, unsigned int ctrl) r852_cmdctl() argument
319 struct r852_device *dev = r852_get_dev(mtd); r852_cmdctl()
362 static int r852_wait(struct mtd_info *mtd, struct nand_chip *chip) r852_wait() argument
373 if (chip->dev_ready(mtd)) r852_wait()
376 chip->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1); r852_wait()
377 status = (int)chip->read_byte(mtd); r852_wait()
391 static int r852_ready(struct mtd_info *mtd) r852_ready() argument
393 struct r852_device *dev = r852_get_dev(mtd); r852_ready()
402 static void r852_ecc_hwctl(struct mtd_info *mtd, int mode) r852_ecc_hwctl() argument
404 struct r852_device *dev = r852_get_dev(mtd); r852_ecc_hwctl()
434 static int r852_ecc_calculate(struct mtd_info *mtd, const uint8_t *dat, r852_ecc_calculate() argument
437 struct r852_device *dev = r852_get_dev(mtd); r852_ecc_calculate()
466 static int r852_ecc_correct(struct mtd_info *mtd, uint8_t *dat, r852_ecc_correct() argument
473 struct r852_device *dev = r852_get_dev(mtd); r852_ecc_correct()
522 static int r852_read_oob(struct mtd_info *mtd, struct nand_chip *chip, r852_read_oob() argument
525 chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page); r852_read_oob()
526 chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); r852_read_oob()
594 struct mtd_info *mtd = container_of(sys_dev, struct mtd_info, dev); r852_media_type_show() local
595 struct r852_device *dev = r852_get_dev(mtd); r852_media_type_show()
637 dev->mtd = kzalloc(sizeof(struct mtd_info), GFP_KERNEL); r852_register_nand_device()
639 if (!dev->mtd) r852_register_nand_device()
644 dev->mtd->owner = THIS_MODULE; r852_register_nand_device()
645 dev->mtd->priv = dev->chip; r852_register_nand_device()
646 dev->mtd->dev.parent = &dev->pci_dev->dev; r852_register_nand_device()
653 if (sm_register_device(dev->mtd, dev->sm)) r852_register_nand_device()
656 if (device_create_file(&dev->mtd->dev, &dev_attr_media_type)) r852_register_nand_device()
662 kfree(dev->mtd); r852_register_nand_device()
678 device_remove_file(&dev->mtd->dev, &dev_attr_media_type); r852_unregister_nand_device()
679 nand_release(dev->mtd); r852_unregister_nand_device()
682 kfree(dev->mtd); r852_unregister_nand_device()
683 dev->mtd = NULL; r852_unregister_nand_device()
1051 dev->chip->select_chip(dev->mtd, 0); r852_resume()
1052 dev->chip->cmdfunc(dev->mtd, NAND_CMD_RESET, -1, -1); r852_resume()
1053 dev->chip->select_chip(dev->mtd, -1); r852_resume()
H A Ds3c2410.c1 /* linux/drivers/mtd/nand/s3c2410.c
43 #include <linux/mtd/mtd.h>
44 #include <linux/mtd/nand.h>
45 #include <linux/mtd/nand_ecc.h>
46 #include <linux/mtd/partitions.h>
48 #include <linux/platform_data/mtd-nand-s3c2410.h>
94 /* controller and mtd information */
100 * @mtd: The MTD instance to pass to the MTD layer.
107 struct mtd_info mtd; member in struct:s3c2410_nand_mtd
144 /* mtd info */
169 static struct s3c2410_nand_mtd *s3c2410_nand_mtd_toours(struct mtd_info *mtd) s3c2410_nand_mtd_toours() argument
171 return container_of(mtd, struct s3c2410_nand_mtd, mtd); s3c2410_nand_mtd_toours()
174 static struct s3c2410_nand_info *s3c2410_nand_mtd_toinfo(struct mtd_info *mtd) s3c2410_nand_mtd_toinfo() argument
176 return s3c2410_nand_mtd_toours(mtd)->info; s3c2410_nand_mtd_toinfo()
370 * @mtd: The MTD instance for this chip.
374 * @mtd instance, or to indicate that the access has finished and the
381 static void s3c2410_nand_select_chip(struct mtd_info *mtd, int chip) s3c2410_nand_select_chip() argument
385 struct nand_chip *this = mtd->priv; s3c2410_nand_select_chip()
423 static void s3c2410_nand_hwcontrol(struct mtd_info *mtd, int cmd, s3c2410_nand_hwcontrol() argument
426 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd); s3c2410_nand_hwcontrol()
439 static void s3c2440_nand_hwcontrol(struct mtd_info *mtd, int cmd, s3c2440_nand_hwcontrol() argument
442 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd); s3c2440_nand_hwcontrol()
458 static int s3c2410_nand_devready(struct mtd_info *mtd) s3c2410_nand_devready() argument
460 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd); s3c2410_nand_devready()
464 static int s3c2440_nand_devready(struct mtd_info *mtd) s3c2440_nand_devready() argument
466 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd); s3c2440_nand_devready()
470 static int s3c2412_nand_devready(struct mtd_info *mtd) s3c2412_nand_devready() argument
472 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd); s3c2412_nand_devready()
479 static int s3c2410_nand_correct_data(struct mtd_info *mtd, u_char *dat, s3c2410_nand_correct_data() argument
482 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd); s3c2410_nand_correct_data()
486 pr_debug("%s(%p,%p,%p,%p)\n", __func__, mtd, dat, read_ecc, calc_ecc); s3c2410_nand_correct_data()
557 static void s3c2410_nand_enable_hwecc(struct mtd_info *mtd, int mode) s3c2410_nand_enable_hwecc() argument
559 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd); s3c2410_nand_enable_hwecc()
567 static void s3c2412_nand_enable_hwecc(struct mtd_info *mtd, int mode) s3c2412_nand_enable_hwecc() argument
569 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd); s3c2412_nand_enable_hwecc()
577 static void s3c2440_nand_enable_hwecc(struct mtd_info *mtd, int mode) s3c2440_nand_enable_hwecc() argument
579 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd); s3c2440_nand_enable_hwecc()
586 static int s3c2410_nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat, s3c2410_nand_calculate_ecc() argument
589 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd); s3c2410_nand_calculate_ecc()
600 static int s3c2412_nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat, s3c2412_nand_calculate_ecc() argument
603 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd); s3c2412_nand_calculate_ecc()
615 static int s3c2440_nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat, s3c2440_nand_calculate_ecc() argument
618 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd); s3c2440_nand_calculate_ecc()
635 static void s3c2410_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len) s3c2410_nand_read_buf() argument
637 struct nand_chip *this = mtd->priv; s3c2410_nand_read_buf()
641 static void s3c2440_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len) s3c2440_nand_read_buf() argument
643 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd); s3c2440_nand_read_buf()
656 static void s3c2410_nand_write_buf(struct mtd_info *mtd, const u_char *buf, s3c2410_nand_write_buf() argument
659 struct nand_chip *this = mtd->priv; s3c2410_nand_write_buf()
663 static void s3c2440_nand_write_buf(struct mtd_info *mtd, const u_char *buf, s3c2440_nand_write_buf() argument
666 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd); s3c2440_nand_write_buf()
747 pr_debug("releasing mtd %d (%p)\n", mtdno, ptr); s3c24xx_nand_remove()
748 nand_release(&ptr->mtd); s3c24xx_nand_remove()
761 struct s3c2410_nand_mtd *mtd, s3c2410_nand_add_partition()
765 mtd->mtd.name = set->name; s3c2410_nand_add_partition()
767 return mtd_device_parse_register(&mtd->mtd, NULL, NULL, s3c2410_nand_add_partition()
834 nmtd->mtd.priv = chip; s3c2410_nand_init_chip()
835 nmtd->mtd.owner = THIS_MODULE; s3c2410_nand_init_chip()
1021 nmtd->scan_res = nand_scan_ident(&nmtd->mtd, s3c24xx_nand_probe()
1027 nand_scan_tail(&nmtd->mtd); s3c24xx_nand_probe()
760 s3c2410_nand_add_partition(struct s3c2410_nand_info *info, struct s3c2410_nand_mtd *mtd, struct s3c2410_nand_set *set) s3c2410_nand_add_partition() argument
H A Ddenali.c25 #include <linux/mtd/mtd.h>
78 #define mtd_to_denali(m) container_of(m, struct denali_nand_info, mtd)
859 static int write_oob_data(struct mtd_info *mtd, uint8_t *buf, int page) write_oob_data() argument
861 struct denali_nand_info *denali = mtd_to_denali(mtd); write_oob_data()
871 write_data_to_flash_mem(denali, buf, mtd->oobsize); write_oob_data()
888 static void read_oob_data(struct mtd_info *mtd, uint8_t *buf, int page) read_oob_data() argument
890 struct denali_nand_info *denali = mtd_to_denali(mtd); read_oob_data()
898 read_data_from_flash_mem(denali, buf, mtd->oobsize); read_oob_data()
989 denali->mtd.ecc_stats.corrected++; handle_ecc()
1051 static int write_page(struct mtd_info *mtd, struct nand_chip *chip, write_page() argument
1054 struct denali_nand_info *denali = mtd_to_denali(mtd); write_page()
1056 size_t size = denali->mtd.writesize + denali->mtd.oobsize; write_page()
1069 memcpy(denali->buf.buf, buf, mtd->writesize); write_page()
1073 memcpy(denali->buf.buf + mtd->writesize, write_page()
1075 mtd->oobsize); write_page()
1107 static int denali_write_page(struct mtd_info *mtd, struct nand_chip *chip, denali_write_page() argument
1114 return write_page(mtd, chip, buf, false); denali_write_page()
1122 static int denali_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip, denali_write_page_raw() argument
1129 return write_page(mtd, chip, buf, true); denali_write_page_raw()
1132 static int denali_write_oob(struct mtd_info *mtd, struct nand_chip *chip, denali_write_oob() argument
1135 return write_oob_data(mtd, chip->oob_poi, page); denali_write_oob()
1138 static int denali_read_oob(struct mtd_info *mtd, struct nand_chip *chip, denali_read_oob() argument
1141 read_oob_data(mtd, chip->oob_poi, page); denali_read_oob()
1146 static int denali_read_page(struct mtd_info *mtd, struct nand_chip *chip, denali_read_page() argument
1150 struct denali_nand_info *denali = mtd_to_denali(mtd); denali_read_page()
1153 size_t size = denali->mtd.writesize + denali->mtd.oobsize; denali_read_page()
1180 memcpy(buf, denali->buf.buf, mtd->writesize); denali_read_page()
1186 read_oob_data(&denali->mtd, chip->oob_poi, denali->page); denali_read_page()
1190 if (!is_erased(buf, denali->mtd.writesize)) denali_read_page()
1191 denali->mtd.ecc_stats.failed++; denali_read_page()
1192 if (!is_erased(buf, denali->mtd.oobsize)) denali_read_page()
1193 denali->mtd.ecc_stats.failed++; denali_read_page()
1199 static int denali_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip, denali_read_page_raw() argument
1202 struct denali_nand_info *denali = mtd_to_denali(mtd); denali_read_page_raw()
1204 size_t size = denali->mtd.writesize + denali->mtd.oobsize; denali_read_page_raw()
1229 memcpy(buf, denali->buf.buf, mtd->writesize); denali_read_page_raw()
1230 memcpy(chip->oob_poi, denali->buf.buf + mtd->writesize, mtd->oobsize); denali_read_page_raw()
1235 static uint8_t denali_read_byte(struct mtd_info *mtd) denali_read_byte() argument
1237 struct denali_nand_info *denali = mtd_to_denali(mtd); denali_read_byte()
1246 static void denali_select_chip(struct mtd_info *mtd, int chip) denali_select_chip() argument
1248 struct denali_nand_info *denali = mtd_to_denali(mtd); denali_select_chip()
1255 static int denali_waitfunc(struct mtd_info *mtd, struct nand_chip *chip) denali_waitfunc() argument
1257 struct denali_nand_info *denali = mtd_to_denali(mtd); denali_waitfunc()
1265 static int denali_erase(struct mtd_info *mtd, int page) denali_erase() argument
1267 struct denali_nand_info *denali = mtd_to_denali(mtd); denali_erase()
1284 static void denali_cmdfunc(struct mtd_info *mtd, unsigned int cmd, int col, denali_cmdfunc() argument
1287 struct denali_nand_info *denali = mtd_to_denali(mtd); denali_cmdfunc()
1440 denali->mtd.dev.parent = denali->dev; denali_init()
1456 denali->mtd.name = "denali-nand"; denali_init()
1457 denali->mtd.owner = THIS_MODULE; denali_init()
1458 denali->mtd.priv = &denali->nand; denali_init()
1471 if (nand_scan_ident(&denali->mtd, denali->max_banks, NULL)) { denali_init()
1479 denali->mtd.writesize + denali->mtd.oobsize, denali_init()
1494 denali->mtd.writesize + denali->mtd.oobsize, denali_init()
1515 denali->mtd.writesize <<= (denali->devnum - 1); denali_init()
1516 denali->mtd.oobsize <<= (denali->devnum - 1); denali_init()
1517 denali->mtd.erasesize <<= (denali->devnum - 1); denali_init()
1518 denali->mtd.size = denali->nand.numchips * denali->nand.chipsize; denali_init()
1545 (denali->mtd.oobsize > (denali->bbtskipbytes + denali_init()
1546 ECC_15BITS * (denali->mtd.writesize / denali_init()
1553 } else if (denali->mtd.oobsize < (denali->bbtskipbytes + denali_init()
1554 ECC_8BITS * (denali->mtd.writesize / denali_init()
1568 denali->mtd.writesize / ECC_SECTOR_SIZE; denali_init()
1572 denali->mtd.oobsize - denali->nand.ecc.layout->eccbytes - denali_init()
1580 denali->totalblks = denali->mtd.size >> denali->nand.phys_erase_shift; denali_init()
1593 if (nand_scan_tail(&denali->mtd)) { denali_init()
1598 ret = mtd_device_register(&denali->mtd, NULL, 0); denali_init()
1618 denali->mtd.writesize + denali->mtd.oobsize, denali_remove()
H A Dsm_common.h10 #include <linux/mtd/mtd.h>
39 extern int sm_register_device(struct mtd_info *mtd, int smartmedia);
H A Ddavinci_nand.c32 #include <linux/mtd/nand.h>
33 #include <linux/mtd/partitions.h>
39 #include <linux/platform_data/mtd-davinci.h>
40 #include <linux/platform_data/mtd-davinci-aemif.h>
56 struct mtd_info mtd; member in struct:davinci_nand_info
83 #define to_davinci_nand(m) container_of(m, struct davinci_nand_info, mtd)
104 static void nand_davinci_hwcontrol(struct mtd_info *mtd, int cmd, nand_davinci_hwcontrol() argument
107 struct davinci_nand_info *info = to_davinci_nand(mtd); nand_davinci_hwcontrol()
109 struct nand_chip *nand = mtd->priv; nand_davinci_hwcontrol()
125 static void nand_davinci_select_chip(struct mtd_info *mtd, int chip) nand_davinci_select_chip() argument
127 struct davinci_nand_info *info = to_davinci_nand(mtd); nand_davinci_select_chip()
145 static inline uint32_t nand_davinci_readecc_1bit(struct mtd_info *mtd) nand_davinci_readecc_1bit() argument
147 struct davinci_nand_info *info = to_davinci_nand(mtd); nand_davinci_readecc_1bit()
153 static void nand_davinci_hwctl_1bit(struct mtd_info *mtd, int mode) nand_davinci_hwctl_1bit() argument
159 info = to_davinci_nand(mtd); nand_davinci_hwctl_1bit()
162 nand_davinci_readecc_1bit(mtd); nand_davinci_hwctl_1bit()
177 static int nand_davinci_calculate_1bit(struct mtd_info *mtd, nand_davinci_calculate_1bit() argument
180 unsigned int ecc_val = nand_davinci_readecc_1bit(mtd); nand_davinci_calculate_1bit()
192 static int nand_davinci_correct_1bit(struct mtd_info *mtd, u_char *dat, nand_davinci_correct_1bit() argument
195 struct nand_chip *chip = mtd->priv; nand_davinci_correct_1bit()
238 static void nand_davinci_hwctl_4bit(struct mtd_info *mtd, int mode) nand_davinci_hwctl_4bit() argument
240 struct davinci_nand_info *info = to_davinci_nand(mtd); nand_davinci_hwctl_4bit()
270 static int nand_davinci_calculate_4bit(struct mtd_info *mtd, nand_davinci_calculate_4bit() argument
273 struct davinci_nand_info *info = to_davinci_nand(mtd); nand_davinci_calculate_4bit()
307 static int nand_davinci_correct_4bit(struct mtd_info *mtd, nand_davinci_correct_4bit() argument
311 struct davinci_nand_info *info = to_davinci_nand(mtd); nand_davinci_correct_4bit()
448 static void nand_davinci_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) nand_davinci_read_buf() argument
450 struct nand_chip *chip = mtd->priv; nand_davinci_read_buf()
460 static void nand_davinci_write_buf(struct mtd_info *mtd, nand_davinci_write_buf() argument
463 struct nand_chip *chip = mtd->priv; nand_davinci_write_buf()
477 static int nand_davinci_dev_ready(struct mtd_info *mtd) nand_davinci_dev_ready() argument
479 struct davinci_nand_info *info = to_davinci_nand(mtd); nand_davinci_dev_ready()
659 info->mtd.priv = &info->chip; nand_davinci_probe()
660 info->mtd.name = dev_name(&pdev->dev); nand_davinci_probe()
661 info->mtd.owner = THIS_MODULE; nand_davinci_probe()
663 info->mtd.dev.parent = &pdev->dev; nand_davinci_probe()
764 ret = nand_scan_ident(&info->mtd, pdata->mask_chipsel ? 2 : 1, NULL); nand_davinci_probe()
776 int chunks = info->mtd.writesize / 512; nand_davinci_probe()
778 if (!chunks || info->mtd.oobsize < 16) { nand_davinci_probe()
791 info->mtd.oobsize - 16; nand_davinci_probe()
802 * breaks userspace ioctl interface with mtd-utils. Once we nand_davinci_probe()
818 ret = nand_scan_tail(&info->mtd); nand_davinci_probe()
823 ret = mtd_device_parse_register(&info->mtd, NULL, NULL, nand_davinci_probe()
829 ret = mtd_device_parse_register(&info->mtd, NULL, &ppdata, nand_davinci_probe()
861 nand_release(&info->mtd); nand_davinci_remove()
H A Dxway_nand.c9 #include <linux/mtd/nand.h>
73 static void xway_select_chip(struct mtd_info *mtd, int chip) xway_select_chip() argument
90 static void xway_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) xway_cmd_ctrl() argument
92 struct nand_chip *this = mtd->priv; xway_cmd_ctrl()
114 static int xway_dev_ready(struct mtd_info *mtd) xway_dev_ready() argument
119 static unsigned char xway_read_byte(struct mtd_info *mtd) xway_read_byte() argument
121 struct nand_chip *this = mtd->priv; xway_read_byte()
H A Dgpio.c2 * drivers/mtd/nand/gpio.c
28 #include <linux/mtd/mtd.h>
29 #include <linux/mtd/nand.h>
30 #include <linux/mtd/partitions.h>
31 #include <linux/mtd/nand-gpio.h>
72 static void gpio_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) gpio_nand_cmd_ctrl() argument
74 struct gpiomtd *gpiomtd = gpio_nand_getpriv(mtd); gpio_nand_cmd_ctrl()
91 static int gpio_nand_devready(struct mtd_info *mtd) gpio_nand_devready() argument
93 struct gpiomtd *gpiomtd = gpio_nand_getpriv(mtd); gpio_nand_devready()
/linux-4.1.27/drivers/mtd/maps/
H A Duclinux.c18 #include <linux/mtd/mtd.h>
19 #include <linux/mtd/map.h>
20 #include <linux/mtd/partitions.h>
58 static int uclinux_point(struct mtd_info *mtd, loff_t from, size_t len, uclinux_point() argument
61 struct map_info *map = mtd->priv; uclinux_point()
73 struct mtd_info *mtd; uclinux_mtd_init() local
87 printk("uclinux[mtd]: probe address=0x%x size=0x%x\n", uclinux_mtd_init()
99 printk("uclinux[mtd]: no virtual mapping?\n"); uclinux_mtd_init()
105 mtd = do_map_probe("map_" MAP_NAME, mapp); uclinux_mtd_init()
106 if (!mtd) { uclinux_mtd_init()
107 printk("uclinux[mtd]: failed to find a mapping?\n"); uclinux_mtd_init()
111 mtd->owner = THIS_MODULE; uclinux_mtd_init()
112 mtd->_point = uclinux_point; uclinux_mtd_init()
113 mtd->priv = mapp; uclinux_mtd_init()
115 uclinux_ram_mtdinfo = mtd; uclinux_mtd_init()
116 mtd_device_register(mtd, uclinux_romfs, NUM_PARTITIONS); uclinux_mtd_init()
H A Drbtx4939-flash.c19 #include <linux/mtd/mtd.h>
20 #include <linux/mtd/map.h>
21 #include <linux/mtd/partitions.h>
25 struct mtd_info *mtd; member in struct:rbtx4939_flash_info
37 if (info->mtd) { rbtx4939_flash_remove()
38 mtd_device_unregister(info->mtd); rbtx4939_flash_remove()
39 map_destroy(info->mtd); rbtx4939_flash_remove()
92 for (; !info->mtd && *probe_type; probe_type++) rbtx4939_flash_probe()
93 info->mtd = do_map_probe(*probe_type, &info->map); rbtx4939_flash_probe()
94 if (!info->mtd) { rbtx4939_flash_probe()
99 info->mtd->owner = THIS_MODULE; rbtx4939_flash_probe()
100 err = mtd_device_parse_register(info->mtd, NULL, NULL, pdata->parts, rbtx4939_flash_probe()
117 if (mtd_suspend(info->mtd) == 0) rbtx4939_flash_shutdown()
118 mtd_resume(info->mtd); rbtx4939_flash_shutdown()
H A Dtsunami_flash.c9 #include <linux/mtd/map.h>
10 #include <linux/mtd/mtd.h>
76 struct mtd_info *mtd; cleanup_tsunami_flash() local
77 mtd = tsunami_flash_mtd; cleanup_tsunami_flash()
78 if (mtd) { cleanup_tsunami_flash()
79 mtd_device_unregister(mtd); cleanup_tsunami_flash()
80 map_destroy(mtd); cleanup_tsunami_flash()
H A Dpxa2xx-flash.c17 #include <linux/mtd/mtd.h>
18 #include <linux/mtd/map.h>
19 #include <linux/mtd/partitions.h>
43 struct mtd_info *mtd; member in struct:pxa2xx_flash_info
88 info->mtd = do_map_probe(flash->map_name, &info->map); pxa2xx_flash_probe()
90 if (!info->mtd) { pxa2xx_flash_probe()
96 info->mtd->owner = THIS_MODULE; pxa2xx_flash_probe()
98 mtd_device_parse_register(info->mtd, probes, NULL, flash->parts, pxa2xx_flash_probe()
109 mtd_device_unregister(info->mtd); pxa2xx_flash_remove()
111 map_destroy(info->mtd); pxa2xx_flash_remove()
124 if (info && mtd_suspend(info->mtd) == 0) pxa2xx_flash_shutdown()
125 mtd_resume(info->mtd); pxa2xx_flash_shutdown()
H A Dsun_uflash.c22 #include <linux/mtd/mtd.h>
23 #include <linux/mtd/map.h>
40 struct map_info map; /* mtd map info */
41 struct mtd_info *mtd; /* mtd info */ member in struct:uflash_dev
93 up->mtd = do_map_probe("cfi_probe", &up->map); uflash_devinit()
94 if (!up->mtd) { uflash_devinit()
101 up->mtd->owner = THIS_MODULE; uflash_devinit()
103 mtd_device_register(up->mtd, NULL, 0); uflash_devinit()
127 if (up->mtd) { uflash_remove()
128 mtd_device_unregister(up->mtd); uflash_remove()
129 map_destroy(up->mtd); uflash_remove()
H A Dsa1100-flash.c17 #include <linux/mtd/mtd.h>
18 #include <linux/mtd/map.h>
19 #include <linux/mtd/partitions.h>
20 #include <linux/mtd/concat.h>
29 struct mtd_info *mtd; member in struct:sa_subdev_info
34 struct mtd_info *mtd; member in struct:sa_info
59 if (subdev->mtd) sa1100_destroy_subdev()
60 map_destroy(subdev->mtd); sa1100_destroy_subdev()
115 subdev->mtd = do_map_probe(subdev->plat->map_name, &subdev->map); sa1100_probe_subdev()
116 if (subdev->mtd == NULL) { sa1100_probe_subdev()
120 subdev->mtd->owner = THIS_MODULE; sa1100_probe_subdev()
123 phys, (unsigned)(subdev->mtd->size >> 20), sa1100_probe_subdev()
138 if (info->mtd) { sa1100_destroy()
139 mtd_device_unregister(info->mtd); sa1100_destroy()
140 if (info->mtd != info->subdev[0].mtd) sa1100_destroy()
141 mtd_concat_destroy(info->mtd); sa1100_destroy()
222 info->mtd = info->subdev[0].mtd; sa1100_setup_mtd()
230 cdev[i] = info->subdev[i].mtd; sa1100_setup_mtd()
232 info->mtd = mtd_concat_create(cdev, info->num_subdev, sa1100_setup_mtd()
234 if (info->mtd == NULL) sa1100_setup_mtd()
267 mtd_device_parse_register(info->mtd, part_probes, NULL, plat->parts, sa1100_mtd_probe()
291 .name = "sa1100-mtd",
300 MODULE_ALIAS("platform:sa1100-mtd");
H A Dplat-ram.c1 /* drivers/mtd/maps/plat-ram.c
33 #include <linux/mtd/mtd.h>
34 #include <linux/mtd/map.h>
35 #include <linux/mtd/partitions.h>
36 #include <linux/mtd/plat-ram.h>
40 /* private structure for each mtd platform ram device created */
44 struct mtd_info *mtd; member in struct:platram_info
91 if (info->mtd) { platram_remove()
92 mtd_device_unregister(info->mtd); platram_remove()
93 map_destroy(info->mtd); platram_remove()
192 dev_dbg(&pdev->dev, "initialised map, probing for mtd\n"); platram_probe()
194 /* probe for the right mtd map driver platram_probe()
200 for ( ; !info->mtd && *map_probes; map_probes++) platram_probe()
201 info->mtd = do_map_probe(*map_probes , &info->map); platram_probe()
205 info->mtd = do_map_probe("map_ram", &info->map); platram_probe()
207 if (info->mtd == NULL) { platram_probe()
213 info->mtd->owner = THIS_MODULE; platram_probe()
214 info->mtd->dev.parent = &pdev->dev; platram_probe()
221 err = mtd_device_parse_register(info->mtd, pdata->probes, NULL, platram_probe()
225 dev_info(&pdev->dev, "registered mtd device\n"); platram_probe()
229 err = mtd_device_register(info->mtd, NULL, 0); platram_probe()
247 MODULE_ALIAS("platform:mtd-ram");
253 .name = "mtd-ram",
H A Dlantiq-flash.c16 #include <linux/mtd/mtd.h>
17 #include <linux/mtd/map.h>
18 #include <linux/mtd/partitions.h>
19 #include <linux/mtd/cfi.h>
21 #include <linux/mtd/physmap.h>
43 struct mtd_info *mtd; member in struct:ltq_mtd
156 ltq_mtd->mtd = do_map_probe("cfi_probe", ltq_mtd->map); ltq_mtd_probe()
159 if (!ltq_mtd->mtd) { ltq_mtd_probe()
164 ltq_mtd->mtd->owner = THIS_MODULE; ltq_mtd_probe()
171 err = mtd_device_parse_register(ltq_mtd->mtd, ltq_probe_types, ltq_mtd_probe()
181 map_destroy(ltq_mtd->mtd); ltq_mtd_probe()
190 if (ltq_mtd && ltq_mtd->mtd) { ltq_mtd_remove()
191 mtd_device_unregister(ltq_mtd->mtd); ltq_mtd_remove()
192 map_destroy(ltq_mtd->mtd); ltq_mtd_remove()
H A Dlatch-addr-flash.c15 #include <linux/mtd/mtd.h>
16 #include <linux/mtd/map.h>
17 #include <linux/mtd/partitions.h>
19 #include <linux/mtd/latch-addr-flash.h>
25 struct mtd_info *mtd; member in struct:latch_addr_flash_info
107 if (info->mtd != NULL) { latch_addr_flash_remove()
108 mtd_device_unregister(info->mtd); latch_addr_flash_remove()
109 map_destroy(info->mtd); latch_addr_flash_remove()
189 for (probe_type = rom_probe_types; !info->mtd && *probe_type; latch_addr_flash_probe()
191 info->mtd = do_map_probe(*probe_type, &info->map); latch_addr_flash_probe()
193 if (info->mtd == NULL) { latch_addr_flash_probe()
198 info->mtd->owner = THIS_MODULE; latch_addr_flash_probe()
200 mtd_device_parse_register(info->mtd, NULL, NULL, latch_addr_flash_probe()
H A Dphysmap.c17 #include <linux/mtd/mtd.h>
18 #include <linux/mtd/map.h>
19 #include <linux/mtd/partitions.h>
20 #include <linux/mtd/physmap.h>
21 #include <linux/mtd/concat.h>
27 struct mtd_info *mtd[MAX_RESOURCES]; member in struct:physmap_flash_info
48 if (info->cmtd != info->mtd[0]) physmap_flash_remove()
53 if (info->mtd[i] != NULL) physmap_flash_remove()
54 map_destroy(info->mtd[i]); physmap_flash_remove()
158 for (; info->mtd[i] == NULL && *probe_type != NULL; probe_type++) physmap_flash_probe()
159 info->mtd[i] = do_map_probe(*probe_type, &info->map[i]); physmap_flash_probe()
161 info->mtd[i] = do_map_probe(physmap_data->probe_type, &info->map[i]); physmap_flash_probe()
163 if (info->mtd[i] == NULL) { physmap_flash_probe()
170 info->mtd[i]->owner = THIS_MODULE; physmap_flash_probe()
171 info->mtd[i]->dev.parent = &dev->dev; physmap_flash_probe()
175 info->cmtd = info->mtd[0]; physmap_flash_probe()
180 info->cmtd = mtd_concat_create(info->mtd, devices_found, dev_name(&dev->dev)); physmap_flash_probe()
206 for (i = 0; i < MAX_RESOURCES && info->mtd[i]; i++) physmap_flash_shutdown()
207 if (mtd_suspend(info->mtd[i]) == 0) physmap_flash_shutdown()
208 mtd_resume(info->mtd[i]); physmap_flash_shutdown()
H A Dphysmap_of.c19 #include <linux/mtd/mtd.h>
20 #include <linux/mtd/map.h>
21 #include <linux/mtd/partitions.h>
22 #include <linux/mtd/concat.h>
29 struct mtd_info *mtd; member in struct:of_flash_list
52 if (info->cmtd != info->list[0].mtd) of_flash_remove()
57 if (info->list[i].mtd) of_flash_remove()
58 map_destroy(info->list[i].mtd); of_flash_remove()
82 struct mtd_info *mtd; obsolete_probe() local
91 mtd = do_map_probe(rom_probe_types[i], map); obsolete_probe()
92 if (mtd) obsolete_probe()
93 return mtd; obsolete_probe()
178 of_property_read_string(dp, "linux,mtd-name", &mtd_name); of_flash_probe()
266 info->list[i].mtd = do_map_probe(probe_type, of_flash_probe()
269 info->list[i].mtd = obsolete_probe(dev, of_flash_probe()
274 if (!info->list[i].mtd) { of_flash_probe()
279 info->list[i].mtd = do_map_probe("map_rom", of_flash_probe()
282 mtd_list[i] = info->list[i].mtd; of_flash_probe()
285 if (!info->list[i].mtd) { of_flash_probe()
291 info->list[i].mtd->owner = THIS_MODULE; of_flash_probe()
292 info->list[i].mtd->dev.parent = &dev->dev; of_flash_probe()
298 info->cmtd = info->list[0].mtd; of_flash_probe()
337 * probed, although the mtd code gets it right in
340 * bypass the heuristic probe code, but the mtd layer
347 .compatible = "mtd-ram",
351 .compatible = "mtd-rom",
H A Dbfin-async-flash.c2 * drivers/mtd/maps/bfin-async-flash.c
19 #include <linux/mtd/mtd.h>
20 #include <linux/mtd/map.h>
21 #include <linux/mtd/partitions.h>
22 #include <linux/mtd/physmap.h>
38 struct mtd_info *mtd; member in struct:async_state
160 state->mtd = do_map_probe(memory->name, &state->map); bfin_flash_probe()
161 if (!state->mtd) { bfin_flash_probe()
167 mtd_device_parse_register(state->mtd, part_probe_types, NULL, bfin_flash_probe()
179 mtd_device_unregister(state->mtd); bfin_flash_remove()
180 map_destroy(state->mtd); bfin_flash_remove()
H A Damd76xrom.c13 #include <linux/mtd/mtd.h>
14 #include <linux/mtd/map.h>
15 #include <linux/mtd/cfi.h>
16 #include <linux/mtd/flashchip.h>
42 struct mtd_info *mtd; member in struct:amd76xrom_map_info
80 /* Free all of the mtd devices */ amd76xrom_cleanup()
85 mtd_device_unregister(map->mtd); amd76xrom_cleanup()
86 map_destroy(map->mtd); amd76xrom_cleanup()
223 map->mtd = do_map_probe(*probe_type, &map->map); amd76xrom_init_one()
224 if (map->mtd) amd76xrom_init_one()
232 if (map->mtd->size > map->map.size) { amd76xrom_init_one()
235 (unsigned long long)map->mtd->size, map->map.size); amd76xrom_init_one()
236 map->mtd->size = map->map.size; amd76xrom_init_one()
246 map->rsrc.end = map->map.phys + map->mtd->size - 1; amd76xrom_init_one()
263 /* Now that the mtd devices is complete claim and export it */ amd76xrom_init_one()
264 map->mtd->owner = THIS_MODULE; amd76xrom_init_one()
265 if (mtd_device_register(map->mtd, NULL, 0)) { amd76xrom_init_one()
266 map_destroy(map->mtd); amd76xrom_init_one()
267 map->mtd = NULL; amd76xrom_init_one()
273 map_top += map->mtd->size; amd76xrom_init_one()
H A Dck804xrom.c16 #include <linux/mtd/mtd.h>
17 #include <linux/mtd/map.h>
18 #include <linux/mtd/cfi.h>
19 #include <linux/mtd/flashchip.h>
46 struct mtd_info *mtd; member in struct:ck804xrom_map_info
92 /* Free all of the mtd devices */ ck804xrom_cleanup()
97 mtd_device_unregister(map->mtd); ck804xrom_cleanup()
98 map_destroy(map->mtd); ck804xrom_cleanup()
253 map->mtd = do_map_probe(*probe_type, &map->map); ck804xrom_init_one()
254 if (map->mtd) ck804xrom_init_one()
262 if (map->mtd->size > map->map.size) { ck804xrom_init_one()
265 (unsigned long long)map->mtd->size, map->map.size); ck804xrom_init_one()
266 map->mtd->size = map->map.size; ck804xrom_init_one()
276 map->rsrc.end = map->map.phys + map->mtd->size - 1; ck804xrom_init_one()
292 /* Now that the mtd devices is complete claim and export it */ ck804xrom_init_one()
293 map->mtd->owner = THIS_MODULE; ck804xrom_init_one()
294 if (mtd_device_register(map->mtd, NULL, 0)) { ck804xrom_init_one()
295 map_destroy(map->mtd); ck804xrom_init_one()
296 map->mtd = NULL; ck804xrom_init_one()
302 map_top += map->mtd->size; ck804xrom_init_one()
H A Dichxrom.c13 #include <linux/mtd/mtd.h>
14 #include <linux/mtd/map.h>
15 #include <linux/mtd/cfi.h>
16 #include <linux/mtd/flashchip.h>
47 struct mtd_info *mtd; member in struct:ichxrom_map_info
66 /* Free all of the mtd devices */ ichxrom_cleanup()
70 mtd_device_unregister(map->mtd); ichxrom_cleanup()
71 map_destroy(map->mtd); ichxrom_cleanup()
248 map->mtd = do_map_probe(*probe_type, &map->map); ichxrom_init_one()
249 if (map->mtd) ichxrom_init_one()
257 if (map->mtd->size > map->map.size) { ichxrom_init_one()
260 (unsigned long long)map->mtd->size, map->map.size); ichxrom_init_one()
261 map->mtd->size = map->map.size; ichxrom_init_one()
271 map->rsrc.end = map->map.phys + map->mtd->size - 1; ichxrom_init_one()
288 /* Now that the mtd devices is complete claim and export it */ ichxrom_init_one()
289 map->mtd->owner = THIS_MODULE; ichxrom_init_one()
290 if (mtd_device_register(map->mtd, NULL, 0)) { ichxrom_init_one()
291 map_destroy(map->mtd); ichxrom_init_one()
292 map->mtd = NULL; ichxrom_init_one()
298 map_top += map->mtd->size; ichxrom_init_one()
H A Dpci.c2 * linux/drivers/mtd/maps/pci.c
19 #include <linux/mtd/mtd.h>
20 #include <linux/mtd/map.h>
21 #include <linux/mtd/partitions.h>
259 struct mtd_info *mtd = NULL; mtd_pci_probe() local
266 err = pci_request_regions(dev, "pci mtd"); mtd_pci_probe()
285 mtd = do_map_probe(info->map_name, &map->map); mtd_pci_probe()
287 if (!mtd) mtd_pci_probe()
290 mtd->owner = THIS_MODULE; mtd_pci_probe()
291 mtd_device_register(mtd, NULL, 0); mtd_pci_probe()
293 pci_set_drvdata(dev, mtd); mtd_pci_probe()
310 struct mtd_info *mtd = pci_get_drvdata(dev); mtd_pci_remove() local
311 struct map_pci_info *map = mtd->priv; mtd_pci_remove()
313 mtd_device_unregister(mtd); mtd_pci_remove()
314 map_destroy(mtd); mtd_pci_remove()
H A Dsolutionengine.c14 #include <linux/mtd/mtd.h>
15 #include <linux/mtd/map.h>
16 #include <linux/mtd/partitions.h>
H A Dvmu-flash.c15 #include <linux/mtd/mtd.h>
16 #include <linux/mtd/map.h>
50 struct mtd_info *mtd; member in struct:memcard
59 struct mtd_info *mtd, int partition) ofs_to_block()
67 mpart = mtd->priv; ofs_to_block()
112 struct mtd_info *mtd) maple_vmu_read_block()
122 mpart = mtd->priv; maple_vmu_read_block()
229 struct mtd_info *mtd) maple_vmu_write_block()
237 mpart = mtd->priv; maple_vmu_write_block()
303 /* mtd function to simulate reading byte by byte */ vmu_flash_read_char()
305 struct mtd_info *mtd) vmu_flash_read_char()
314 mpart = mtd->priv; vmu_flash_read_char()
327 vblock = ofs_to_block(ofs, mtd, partition); vmu_flash_read_char()
334 error = maple_vmu_read_block(vblock->num, buf, mtd); vmu_flash_read_char()
351 /* mtd higher order function to read flash */ vmu_flash_read()
352 static int vmu_flash_read(struct mtd_info *mtd, loff_t from, size_t len, vmu_flash_read() argument
363 mpart = mtd->priv; vmu_flash_read()
376 vblock = ofs_to_block(from + index, mtd, partition); vmu_flash_read()
402 cx = vmu_flash_read_char(from + index, &retval, mtd); vmu_flash_read()
418 static int vmu_flash_write(struct mtd_info *mtd, loff_t to, size_t len, vmu_flash_write() argument
429 mpart = mtd->priv; vmu_flash_write()
442 vblock = ofs_to_block(to, mtd, partition); vmu_flash_write()
456 error = maple_vmu_read_block(vblock->num, buffer, mtd); vmu_flash_write()
469 error = maple_vmu_write_block(vblock->num, buffer, mtd); vmu_flash_write()
495 static void vmu_flash_sync(struct mtd_info *mtd) vmu_flash_sync() argument
533 mtd_cur = &card->mtd[card->partition]; vmu_queryblocks()
588 kfree(((card->mtd)[error]).priv); vmu_queryblocks()
589 ((card->mtd)[error]).priv = NULL; vmu_queryblocks()
639 card->mtd = kmalloc(sizeof(struct mtd_info) * card->partitions, vmu_connect()
641 if (!card->mtd) { vmu_connect()
684 kfree(card->mtd); vmu_connect()
702 mpart = ((card->mtd)[x]).priv; vmu_disconnect()
704 mtd_device_unregister(&((card->mtd)[x])); vmu_disconnect()
708 kfree(card->mtd); vmu_disconnect()
712 /* Callback to handle eccentricities of both mtd subsystem
719 struct mtd_info *mtd; vmu_can_unload() local
723 mtd = &((card->mtd)[x]); vmu_can_unload()
724 if (mtd->usecount > 0) vmu_can_unload()
58 ofs_to_block(unsigned long src_ofs, struct mtd_info *mtd, int partition) ofs_to_block() argument
111 maple_vmu_read_block(unsigned int num, unsigned char *buf, struct mtd_info *mtd) maple_vmu_read_block() argument
228 maple_vmu_write_block(unsigned int num, const unsigned char *buf, struct mtd_info *mtd) maple_vmu_write_block() argument
304 vmu_flash_read_char(unsigned long ofs, int *retval, struct mtd_info *mtd) vmu_flash_read_char() argument
H A Dscb2_flash.c51 #include <linux/mtd/mtd.h>
52 #include <linux/mtd/map.h>
53 #include <linux/mtd/cfi.h>
71 static int scb2_fixup_mtd(struct mtd_info *mtd) scb2_fixup_mtd() argument
75 struct map_info *map = mtd->priv; scb2_fixup_mtd()
88 mtd->size = map->size; scb2_fixup_mtd()
103 mtd->erasesize /= 2; scb2_fixup_mtd()
104 for (i = 0; i < mtd->numeraseregions; i++) { scb2_fixup_mtd()
105 struct mtd_erase_region_info *region = &mtd->eraseregions[i]; scb2_fixup_mtd()
115 for (i = 0; !done && i < mtd->numeraseregions; i++) { scb2_fixup_mtd()
116 struct mtd_erase_region_info *region = &mtd->eraseregions[i]; scb2_fixup_mtd()
118 if (region->numblocks * region->erasesize > mtd->size) { scb2_fixup_mtd()
119 region->numblocks = ((unsigned long)mtd->size / scb2_fixup_mtd()
H A Dgpio-addr-flash.c2 * drivers/mtd/maps/gpio-addr-flash.c
20 #include <linux/mtd/mtd.h>
21 #include <linux/mtd/map.h>
22 #include <linux/mtd/partitions.h>
23 #include <linux/mtd/physmap.h>
36 * @mtd: MTD state for this mapping
44 struct mtd_info *mtd; member in struct:async_state
262 state->mtd = do_map_probe(memory->name, &state->map); gpio_flash_probe()
263 if (!state->mtd) { gpio_flash_probe()
271 mtd_device_parse_register(state->mtd, part_probe_types, NULL, gpio_flash_probe()
284 mtd_device_unregister(state->mtd); gpio_flash_remove()
285 map_destroy(state->mtd); gpio_flash_remove()
H A Dixp4xx.c2 * drivers/mtd/maps/ixp4xx.c
26 #include <linux/mtd/mtd.h>
27 #include <linux/mtd/map.h>
28 #include <linux/mtd/partitions.h>
146 struct mtd_info *mtd; member in struct:ixp4xx_flash_info
161 if (info->mtd) { ixp4xx_flash_remove()
162 mtd_device_unregister(info->mtd); ixp4xx_flash_remove()
163 map_destroy(info->mtd); ixp4xx_flash_remove()
223 info->mtd = do_map_probe(plat->map_name, &info->map); ixp4xx_flash_probe()
224 if (!info->mtd) { ixp4xx_flash_probe()
229 info->mtd->owner = THIS_MODULE; ixp4xx_flash_probe()
234 err = mtd_device_parse_register(info->mtd, probes, &ppdata, ixp4xx_flash_probe()
H A Dmap_funcs.c9 #include <linux/mtd/map.h>
10 #include <linux/mtd/xip.h>
H A Dimpa7.c16 #include <linux/mtd/mtd.h>
17 #include <linux/mtd/map.h>
18 #include <linux/mtd/partitions.h>
H A Desb2rom.c19 #include <linux/mtd/mtd.h>
20 #include <linux/mtd/map.h>
21 #include <linux/mtd/cfi.h>
22 #include <linux/mtd/flashchip.h>
108 struct mtd_info *mtd; member in struct:esb2rom_map_info
127 /* Free all of the mtd devices */ esb2rom_cleanup()
131 mtd_device_unregister(map->mtd); esb2rom_cleanup()
132 map_destroy(map->mtd); esb2rom_cleanup()
314 map->mtd = do_map_probe(*probe_type, &map->map); esb2rom_init_one()
315 if (map->mtd) esb2rom_init_one()
323 if (map->mtd->size > map->map.size) { esb2rom_init_one()
326 (unsigned long long)map->mtd->size, map->map.size); esb2rom_init_one()
327 map->mtd->size = map->map.size; esb2rom_init_one()
337 map->rsrc.end = map->map.phys + map->mtd->size - 1; esb2rom_init_one()
353 /* Now that the mtd devices is complete claim and export it */ esb2rom_init_one()
354 map->mtd->owner = THIS_MODULE; esb2rom_init_one()
355 if (mtd_device_register(map->mtd, NULL, 0)) { esb2rom_init_one()
356 map_destroy(map->mtd); esb2rom_init_one()
357 map->mtd = NULL; esb2rom_init_one()
362 map_top += map->mtd->size; esb2rom_init_one()
H A Dscx200_docflash.c1 /* linux/drivers/mtd/maps/scx200_docflash.c
13 #include <linux/mtd/mtd.h>
14 #include <linux/mtd/map.h>
15 #include <linux/mtd/partitions.h>
222 compile-command: "make -k -C ../../.. SUBDIRS=drivers/mtd/maps modules"
/linux-4.1.27/drivers/net/ethernet/sfc/
H A Dmtd.c12 #include <linux/mtd/mtd.h>
19 #define to_efx_mtd_partition(mtd) \
20 container_of(mtd, struct efx_mtd_partition, mtd)
24 static int efx_mtd_erase(struct mtd_info *mtd, struct erase_info *erase) efx_mtd_erase() argument
26 struct efx_nic *efx = mtd->priv; efx_mtd_erase()
29 rc = efx->type->mtd_erase(mtd, erase->addr, erase->len); efx_mtd_erase()
40 static void efx_mtd_sync(struct mtd_info *mtd) efx_mtd_sync() argument
42 struct efx_mtd_partition *part = to_efx_mtd_partition(mtd); efx_mtd_sync()
43 struct efx_nic *efx = mtd->priv; efx_mtd_sync()
46 rc = efx->type->mtd_sync(mtd); efx_mtd_sync()
57 rc = mtd_device_unregister(&part->mtd); efx_mtd_remove_partition()
76 part->mtd.writesize = 1; efx_mtd_add()
78 part->mtd.owner = THIS_MODULE; efx_mtd_add()
79 part->mtd.priv = efx; efx_mtd_add()
80 part->mtd.name = part->name; efx_mtd_add()
81 part->mtd._erase = efx_mtd_erase; efx_mtd_add()
82 part->mtd._read = efx->type->mtd_read; efx_mtd_add()
83 part->mtd._write = efx->type->mtd_write; efx_mtd_add()
84 part->mtd._sync = efx_mtd_sync; efx_mtd_add()
88 if (mtd_device_register(&part->mtd, NULL, 0)) efx_mtd_add()
/linux-4.1.27/drivers/mtd/ubi/
H A Dgluebi.c28 * size (@mtd->writesize) is equivalent to the UBI minimal I/O unit. The
39 #include <linux/mtd/ubi.h>
40 #include <linux/mtd/mtd.h>
49 * @mtd: emulated MTD device description object
57 struct mtd_info mtd; member in struct:gluebi_device
91 * @mtd: the MTD device description object
97 static int gluebi_get_device(struct mtd_info *mtd) gluebi_get_device() argument
105 if (mtd->flags & MTD_WRITEABLE) gluebi_get_device()
108 gluebi = container_of(mtd, struct gluebi_device, mtd); gluebi_get_device()
142 * @mtd: the MTD device description object
147 static void gluebi_put_device(struct mtd_info *mtd) gluebi_put_device() argument
151 gluebi = container_of(mtd, struct gluebi_device, mtd); gluebi_put_device()
162 * @mtd: MTD device description object
171 static int gluebi_read(struct mtd_info *mtd, loff_t from, size_t len, gluebi_read() argument
177 gluebi = container_of(mtd, struct gluebi_device, mtd); gluebi_read()
178 lnum = div_u64_rem(from, mtd->erasesize, &offs); gluebi_read()
181 size_t to_read = mtd->erasesize - offs; gluebi_read()
202 * @mtd: MTD device description object
211 static int gluebi_write(struct mtd_info *mtd, loff_t to, size_t len, gluebi_write() argument
217 gluebi = container_of(mtd, struct gluebi_device, mtd); gluebi_write()
218 lnum = div_u64_rem(to, mtd->erasesize, &offs); gluebi_write()
220 if (len % mtd->writesize || offs % mtd->writesize) gluebi_write()
225 size_t to_write = mtd->erasesize - offs; gluebi_write()
246 * @mtd: the MTD device description object
252 static int gluebi_erase(struct mtd_info *mtd, struct erase_info *instr) gluebi_erase() argument
257 if (mtd_mod_by_ws(instr->addr, mtd) || mtd_mod_by_ws(instr->len, mtd)) gluebi_erase()
260 lnum = mtd_div_by_eb(instr->addr, mtd); gluebi_erase()
261 count = mtd_div_by_eb(instr->len, mtd); gluebi_erase()
262 gluebi = container_of(mtd, struct gluebi_device, mtd); gluebi_erase()
286 instr->fail_addr = (long long)lnum * mtd->erasesize; gluebi_erase()
303 struct mtd_info *mtd; gluebi_create() local
309 mtd = &gluebi->mtd; gluebi_create()
310 mtd->name = kmemdup(vi->name, vi->name_len + 1, GFP_KERNEL); gluebi_create()
311 if (!mtd->name) { gluebi_create()
318 mtd->type = MTD_UBIVOLUME; gluebi_create()
320 mtd->flags = MTD_WRITEABLE; gluebi_create()
321 mtd->owner = THIS_MODULE; gluebi_create()
322 mtd->writesize = di->min_io_size; gluebi_create()
323 mtd->erasesize = vi->usable_leb_size; gluebi_create()
324 mtd->_read = gluebi_read; gluebi_create()
325 mtd->_write = gluebi_write; gluebi_create()
326 mtd->_erase = gluebi_erase; gluebi_create()
327 mtd->_get_device = gluebi_get_device; gluebi_create()
328 mtd->_put_device = gluebi_put_device; gluebi_create()
336 mtd->size = (unsigned long long)vi->usable_leb_size * vi->size; gluebi_create()
338 mtd->size = vi->used_bytes; gluebi_create()
345 g->mtd.index, vi->ubi_num, vi->vol_id); gluebi_create()
348 if (mtd_device_register(mtd, NULL, 0)) { gluebi_create()
350 kfree(mtd->name); gluebi_create()
372 struct mtd_info *mtd; gluebi_remove() local
389 mtd = &gluebi->mtd; gluebi_remove()
390 err = mtd_device_unregister(mtd); gluebi_remove()
393 mtd->index, gluebi->ubi_num, gluebi->vol_id, err); gluebi_remove()
400 kfree(mtd->name); gluebi_remove()
429 gluebi->mtd.size = vi->used_bytes; gluebi_updated()
454 gluebi->mtd.size = vi->used_bytes; gluebi_resized()
504 struct mtd_info *mtd = &gluebi->mtd; ubi_gluebi_exit() local
506 err = mtd_device_unregister(mtd); ubi_gluebi_exit()
509 err, mtd->index, gluebi->ubi_num, ubi_gluebi_exit()
511 kfree(mtd->name); ubi_gluebi_exit()
H A Dbuild.c39 #include <linux/mtd/partitions.h>
47 /* Maximum length of the 'mtd=' parameter */
50 /* Maximum number of comma-separated items in the 'mtd=' parameter */
380 ret = sprintf(buf, "%d\n", ubi->mtd->index); dev_attribute_show()
610 * the MTD partition we are attaching (ubi->mtd). get_bad_peb_limit()
612 device_size = mtd_get_device_size(ubi->mtd); get_bad_peb_limit()
613 device_pebs = mtd_div_by_eb(device_size, ubi->mtd); get_bad_peb_limit()
644 if (ubi->mtd->numeraseregions != 0) { io_init()
666 ubi->peb_size = ubi->mtd->erasesize; io_init()
667 ubi->peb_count = mtd_div_by_eb(ubi->mtd->size, ubi->mtd); io_init()
668 ubi->flash_size = ubi->mtd->size; io_init()
670 if (mtd_can_have_bb(ubi->mtd)) { io_init()
675 if (ubi->mtd->type == MTD_NORFLASH) { io_init()
676 ubi_assert(ubi->mtd->writesize == 1); io_init()
680 ubi->min_io_size = ubi->mtd->writesize; io_init()
681 ubi->hdrs_min_io_size = ubi->mtd->writesize >> ubi->mtd->subpage_sft; io_init()
698 ubi->max_write_size = ubi->mtd->writebufsize; io_init()
779 if (!(ubi->mtd->flags & MTD_WRITEABLE)) { io_init()
781 ubi->mtd->index); io_init()
788 * over all physical eraseblocks and invoke mtd->block_is_bad() for io_init()
855 * @mtd: MTD device description object
869 int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, ubi_attach_mtd_dev() argument
889 if (ubi && mtd->index == ubi->mtd->index) { ubi_attach_mtd_dev()
890 ubi_err(ubi, "mtd%d is already attached to ubi%d", ubi_attach_mtd_dev()
891 mtd->index, i); ubi_attach_mtd_dev()
904 if (mtd->type == MTD_UBIVOLUME) { ubi_attach_mtd_dev()
905 ubi_err(ubi, "refuse attaching mtd%d - it is already emulated on top of UBI", ubi_attach_mtd_dev()
906 mtd->index); ubi_attach_mtd_dev()
935 ubi->mtd = mtd; ubi_attach_mtd_dev()
948 ubi->fm_pool.max_size = min(((int)mtd_div_by_eb(ubi->mtd->size, ubi_attach_mtd_dev()
949 ubi->mtd) / 100) * 5, UBI_FM_MAX_POOL_SIZE); ubi_attach_mtd_dev()
958 if (!ubi->fm_disabled && (int)mtd_div_by_eb(ubi->mtd->size, ubi->mtd) ubi_attach_mtd_dev()
978 ubi_msg(ubi, "attaching mtd%d", mtd->index); ubi_attach_mtd_dev()
997 ubi_err(ubi, "failed to attach mtd%d, error %d", ubi_attach_mtd_dev()
998 mtd->index, err); ubi_attach_mtd_dev()
1024 ubi_msg(ubi, "attached mtd%d (name \"%s\", size %llu MiB)", ubi_attach_mtd_dev()
1025 mtd->index, mtd->name, ubi->flash_size >> 20); ubi_attach_mtd_dev()
1117 ubi_msg(ubi, "detaching mtd%d", ubi->mtd->index); ubi_detach_mtd_dev()
1145 put_mtd_device(ubi->mtd); ubi_detach_mtd_dev()
1148 ubi_msg(ubi, "mtd%d is detached", ubi->mtd->index); ubi_detach_mtd_dev()
1201 struct mtd_info *mtd; open_mtd_device() local
1211 mtd = get_mtd_device_nm(mtd_dev); open_mtd_device()
1212 if (IS_ERR(mtd) && PTR_ERR(mtd) == -ENODEV) open_mtd_device()
1214 mtd = open_mtd_by_chdev(mtd_dev); open_mtd_device()
1216 mtd = get_mtd_device(NULL, mtd_num); open_mtd_device()
1218 return mtd; open_mtd_device()
1271 struct mtd_info *mtd; ubi_init() local
1275 mtd = open_mtd_device(p->name); ubi_init()
1276 if (IS_ERR(mtd)) { ubi_init()
1277 err = PTR_ERR(mtd); ubi_init()
1278 pr_err("UBI error: cannot open mtd %s, error %d", ubi_init()
1287 err = ubi_attach_mtd_dev(mtd, p->ubi_num, ubi_init()
1291 pr_err("UBI error: cannot attach mtd%d", ubi_init()
1292 mtd->index); ubi_init()
1293 put_mtd_device(mtd); ubi_init()
1404 * ubi_mtd_param_parse - parse the 'mtd=' UBI parameter.
1436 pr_warn("UBI warning: empty 'mtd=' parameter - ignored\n"); ubi_mtd_param_parse()
1492 module_param_call(mtd, ubi_mtd_param_parse, NULL, NULL, 000);
1493 MODULE_PARM_DESC(mtd, "MTD devices to attach. Parameter format: mtd=<name|num|path>[,<vid_hdr_offs>[,max_beb_per1024[,ubi_num]]].\n"
1494 "Multiple \"mtd\" parameters may be specified.\n"
1501 "Example 1: mtd=/dev/mtd0 - attach MTD device /dev/mtd0.\n"
1502 "Example 2: mtd=content,1984 mtd=4 - attach MTD device with name \"content\" using VID header offset 1984, and MTD device number 4 with default VID header offset.\n"
1503 "Example 3: mtd=/dev/mtd1,0,25 - attach MTD device /dev/mtd1 using default VID header offset and reserve 25*nand_size_in_blocks/1024 erase blocks for bad block handling.\n"
1504 "Example 4: mtd=/dev/mtd1,0,0,5 - attach MTD device /dev/mtd1 to UBI 5 and using default values for the other fields.\n"
/linux-4.1.27/drivers/mtd/onenand/
H A Donenand_base.c2 * linux/drivers/mtd/onenand/onenand_base.c
31 #include <linux/mtd/mtd.h>
32 #include <linux/mtd/onenand.h>
33 #include <linux/mtd/partitions.h>
346 * @param mtd MTD device structure
349 int flexonenand_region(struct mtd_info *mtd, loff_t addr) flexonenand_region() argument
353 for (i = 0; i < mtd->numeraseregions; i++) flexonenand_region()
354 if (addr < mtd->eraseregions[i].offset) flexonenand_region()
362 * @param mtd MTD device structure
370 static int onenand_command(struct mtd_info *mtd, int cmd, loff_t addr, size_t len) onenand_command() argument
372 struct onenand_chip *this = mtd->priv; onenand_command()
518 * @param mtd MTD device structure
525 static int onenand_wait(struct mtd_info *mtd, int state) onenand_wait() argument
527 struct onenand_chip * this = mtd->priv; onenand_wait()
560 mtd->ecc_stats.failed++; onenand_wait()
565 mtd->ecc_stats.corrected++; onenand_wait()
618 * @param mtd MTD device structure
623 static int onenand_interrupt_wait(struct mtd_info *mtd, int state) onenand_interrupt_wait() argument
625 struct onenand_chip *this = mtd->priv; onenand_interrupt_wait()
629 return onenand_wait(mtd, state); onenand_interrupt_wait()
634 * @param mtd MTD device structure
639 static int onenand_try_interrupt_wait(struct mtd_info *mtd, int state) onenand_try_interrupt_wait() argument
641 struct onenand_chip *this = mtd->priv; onenand_try_interrupt_wait()
659 return onenand_wait(mtd, state); onenand_try_interrupt_wait()
664 * @param mtd MTD device structure
670 static void onenand_setup_wait(struct mtd_info *mtd) onenand_setup_wait() argument
672 struct onenand_chip *this = mtd->priv; onenand_setup_wait()
699 * @param mtd MTD data structure
705 static inline int onenand_bufferram_offset(struct mtd_info *mtd, int area) onenand_bufferram_offset() argument
707 struct onenand_chip *this = mtd->priv; onenand_bufferram_offset()
714 return mtd->oobsize; onenand_bufferram_offset()
722 * @param mtd MTD data structure
730 static int onenand_read_bufferram(struct mtd_info *mtd, int area, onenand_read_bufferram() argument
733 struct onenand_chip *this = mtd->priv; onenand_read_bufferram()
738 bufferram += onenand_bufferram_offset(mtd, area); onenand_read_bufferram()
758 * @param mtd MTD data structure
766 static int onenand_sync_read_bufferram(struct mtd_info *mtd, int area, onenand_sync_read_bufferram() argument
769 struct onenand_chip *this = mtd->priv; onenand_sync_read_bufferram()
774 bufferram += onenand_bufferram_offset(mtd, area); onenand_sync_read_bufferram()
776 this->mmcontrol(mtd, ONENAND_SYS_CFG1_SYNC_READ); onenand_sync_read_bufferram()
791 this->mmcontrol(mtd, 0); onenand_sync_read_bufferram()
798 * @param mtd MTD data structure
806 static int onenand_write_bufferram(struct mtd_info *mtd, int area, onenand_write_bufferram() argument
809 struct onenand_chip *this = mtd->priv; onenand_write_bufferram()
814 bufferram += onenand_bufferram_offset(mtd, area); onenand_write_bufferram()
839 * @param mtd MTD data structure
845 static int onenand_get_2x_blockpage(struct mtd_info *mtd, loff_t addr) onenand_get_2x_blockpage() argument
847 struct onenand_chip *this = mtd->priv; onenand_get_2x_blockpage()
863 * @param mtd MTD data structure
869 static int onenand_check_bufferram(struct mtd_info *mtd, loff_t addr) onenand_check_bufferram() argument
871 struct onenand_chip *this = mtd->priv; onenand_check_bufferram()
876 blockpage = onenand_get_2x_blockpage(mtd, addr); onenand_check_bufferram()
905 * @param mtd MTD data structure
911 static void onenand_update_bufferram(struct mtd_info *mtd, loff_t addr, onenand_update_bufferram() argument
914 struct onenand_chip *this = mtd->priv; onenand_update_bufferram()
919 blockpage = onenand_get_2x_blockpage(mtd, addr); onenand_update_bufferram()
938 * @param mtd MTD data structure
944 static void onenand_invalidate_bufferram(struct mtd_info *mtd, loff_t addr, onenand_invalidate_bufferram() argument
947 struct onenand_chip *this = mtd->priv; onenand_invalidate_bufferram()
961 * @param mtd MTD device structure
966 static int onenand_get_device(struct mtd_info *mtd, int new_state) onenand_get_device() argument
968 struct onenand_chip *this = mtd->priv; onenand_get_device()
980 this->enable(mtd); onenand_get_device()
999 * @param mtd MTD device structure
1003 static void onenand_release_device(struct mtd_info *mtd) onenand_release_device() argument
1005 struct onenand_chip *this = mtd->priv; onenand_release_device()
1008 this->disable(mtd); onenand_release_device()
1018 * @param mtd MTD device structure
1023 static int onenand_transfer_auto_oob(struct mtd_info *mtd, uint8_t *buf, int column, onenand_transfer_auto_oob() argument
1026 struct onenand_chip *this = mtd->priv; onenand_transfer_auto_oob()
1042 this->read_bufferram(mtd, ONENAND_SPARERAM, oob_buf, 0, mtd->oobsize); onenand_transfer_auto_oob()
1060 * @param mtd MTD device structure
1071 static int onenand_recover_lsb(struct mtd_info *mtd, loff_t addr, int status) onenand_recover_lsb() argument
1073 struct onenand_chip *this = mtd->priv; onenand_recover_lsb()
1085 i = flexonenand_region(mtd, addr); onenand_recover_lsb()
1086 if (mtd->eraseregions[i].erasesize < (1 << this->erase_shift)) onenand_recover_lsb()
1094 mtd->ecc_stats.failed--; onenand_recover_lsb()
1097 this->command(mtd, FLEXONENAND_CMD_RECOVER_LSB, addr, this->writesize); onenand_recover_lsb()
1098 return this->wait(mtd, FL_READING); onenand_recover_lsb()
1103 * @param mtd MTD device structure
1110 static int onenand_mlc_read_ops_nolock(struct mtd_info *mtd, loff_t from, onenand_mlc_read_ops_nolock() argument
1113 struct onenand_chip *this = mtd->priv; onenand_mlc_read_ops_nolock()
1130 oobsize = mtd->oobsize; onenand_mlc_read_ops_nolock()
1132 oobcolumn = from & (mtd->oobsize - 1); onenand_mlc_read_ops_nolock()
1135 if (from + len > mtd->size) { onenand_mlc_read_ops_nolock()
1143 stats = mtd->ecc_stats; onenand_mlc_read_ops_nolock()
1154 if (!onenand_check_bufferram(mtd, from)) { onenand_mlc_read_ops_nolock()
1155 this->command(mtd, ONENAND_CMD_READ, from, writesize); onenand_mlc_read_ops_nolock()
1157 ret = this->wait(mtd, FL_READING); onenand_mlc_read_ops_nolock()
1159 ret = onenand_recover_lsb(mtd, from, ret); onenand_mlc_read_ops_nolock()
1160 onenand_update_bufferram(mtd, from, !ret); onenand_mlc_read_ops_nolock()
1167 this->read_bufferram(mtd, ONENAND_DATARAM, buf, column, thislen); onenand_mlc_read_ops_nolock()
1173 onenand_transfer_auto_oob(mtd, oobbuf, oobcolumn, thisooblen); onenand_mlc_read_ops_nolock()
1175 this->read_bufferram(mtd, ONENAND_SPARERAM, oobbuf, oobcolumn, thisooblen); onenand_mlc_read_ops_nolock()
1200 if (mtd->ecc_stats.failed - stats.failed) onenand_mlc_read_ops_nolock()
1204 return mtd->ecc_stats.corrected != stats.corrected ? 1 : 0; onenand_mlc_read_ops_nolock()
1209 * @param mtd MTD device structure
1215 static int onenand_read_ops_nolock(struct mtd_info *mtd, loff_t from, onenand_read_ops_nolock() argument
1218 struct onenand_chip *this = mtd->priv; onenand_read_ops_nolock()
1235 oobsize = mtd->oobsize; onenand_read_ops_nolock()
1237 oobcolumn = from & (mtd->oobsize - 1); onenand_read_ops_nolock()
1240 if ((from + len) > mtd->size) { onenand_read_ops_nolock()
1248 stats = mtd->ecc_stats; onenand_read_ops_nolock()
1254 if (!onenand_check_bufferram(mtd, from)) { onenand_read_ops_nolock()
1255 this->command(mtd, ONENAND_CMD_READ, from, writesize); onenand_read_ops_nolock()
1256 ret = this->wait(mtd, FL_READING); onenand_read_ops_nolock()
1257 onenand_update_bufferram(mtd, from, !ret); onenand_read_ops_nolock()
1272 this->command(mtd, ONENAND_CMD_READ, from, writesize); onenand_read_ops_nolock()
1287 this->read_bufferram(mtd, ONENAND_DATARAM, buf, column, thislen); onenand_read_ops_nolock()
1295 onenand_transfer_auto_oob(mtd, oobbuf, oobcolumn, thisooblen); onenand_read_ops_nolock()
1297 this->read_bufferram(mtd, ONENAND_SPARERAM, oobbuf, oobcolumn, thisooblen); onenand_read_ops_nolock()
1316 ret = this->wait(mtd, FL_READING); onenand_read_ops_nolock()
1317 onenand_update_bufferram(mtd, from, !ret); onenand_read_ops_nolock()
1333 if (mtd->ecc_stats.failed - stats.failed) onenand_read_ops_nolock()
1337 return mtd->ecc_stats.corrected != stats.corrected ? 1 : 0; onenand_read_ops_nolock()
1342 * @param mtd MTD device structure
1348 static int onenand_read_oob_nolock(struct mtd_info *mtd, loff_t from, onenand_read_oob_nolock() argument
1351 struct onenand_chip *this = mtd->priv; onenand_read_oob_nolock()
1370 oobsize = mtd->oobsize; onenand_read_oob_nolock()
1372 column = from & (mtd->oobsize - 1); onenand_read_oob_nolock()
1381 if (unlikely(from >= mtd->size || onenand_read_oob_nolock()
1382 column + len > ((mtd->size >> this->page_shift) - onenand_read_oob_nolock()
1389 stats = mtd->ecc_stats; onenand_read_oob_nolock()
1399 this->command(mtd, readcmd, from, mtd->oobsize); onenand_read_oob_nolock()
1401 onenand_update_bufferram(mtd, from, 0); onenand_read_oob_nolock()
1403 ret = this->wait(mtd, FL_READING); onenand_read_oob_nolock()
1405 ret = onenand_recover_lsb(mtd, from, ret); onenand_read_oob_nolock()
1414 onenand_transfer_auto_oob(mtd, buf, column, thislen); onenand_read_oob_nolock()
1416 this->read_bufferram(mtd, ONENAND_SPARERAM, buf, column, thislen); onenand_read_oob_nolock()
1428 from += mtd->writesize; onenand_read_oob_nolock()
1438 if (mtd->ecc_stats.failed - stats.failed) onenand_read_oob_nolock()
1446 * @param mtd MTD device structure
1454 static int onenand_read(struct mtd_info *mtd, loff_t from, size_t len, onenand_read() argument
1457 struct onenand_chip *this = mtd->priv; onenand_read()
1466 onenand_get_device(mtd, FL_READING); onenand_read()
1468 onenand_mlc_read_ops_nolock(mtd, from, &ops) : onenand_read()
1469 onenand_read_ops_nolock(mtd, from, &ops); onenand_read()
1470 onenand_release_device(mtd); onenand_read()
1478 * @param mtd: MTD device structure
1484 static int onenand_read_oob(struct mtd_info *mtd, loff_t from, onenand_read_oob() argument
1487 struct onenand_chip *this = mtd->priv; onenand_read_oob()
1500 onenand_get_device(mtd, FL_READING); onenand_read_oob()
1503 onenand_mlc_read_ops_nolock(mtd, from, ops) : onenand_read_oob()
1504 onenand_read_ops_nolock(mtd, from, ops); onenand_read_oob()
1506 ret = onenand_read_oob_nolock(mtd, from, ops); onenand_read_oob()
1507 onenand_release_device(mtd); onenand_read_oob()
1514 * @param mtd MTD device structure
1519 static int onenand_bbt_wait(struct mtd_info *mtd, int state) onenand_bbt_wait() argument
1521 struct onenand_chip *this = mtd->priv; onenand_bbt_wait()
1565 * @param mtd MTD device structure
1571 int onenand_bbt_read_oob(struct mtd_info *mtd, loff_t from, onenand_bbt_read_oob() argument
1574 struct onenand_chip *this = mtd->priv; onenand_bbt_read_oob()
1587 if (unlikely((from + len) > mtd->size)) { onenand_bbt_read_oob()
1594 onenand_get_device(mtd, FL_READING); onenand_bbt_read_oob()
1596 column = from & (mtd->oobsize - 1); onenand_bbt_read_oob()
1603 thislen = mtd->oobsize - column; onenand_bbt_read_oob()
1606 this->command(mtd, readcmd, from, mtd->oobsize); onenand_bbt_read_oob()
1608 onenand_update_bufferram(mtd, from, 0); onenand_bbt_read_oob()
1610 ret = this->bbt_wait(mtd, FL_READING); onenand_bbt_read_oob()
1612 ret = onenand_recover_lsb(mtd, from, ret); onenand_bbt_read_oob()
1617 this->read_bufferram(mtd, ONENAND_SPARERAM, buf, column, thislen); onenand_bbt_read_oob()
1633 onenand_release_device(mtd); onenand_bbt_read_oob()
1642 * @param mtd MTD device structure
1646 static int onenand_verify_oob(struct mtd_info *mtd, const u_char *buf, loff_t to) onenand_verify_oob() argument
1648 struct onenand_chip *this = mtd->priv; onenand_verify_oob()
1654 this->command(mtd, readcmd, to, mtd->oobsize); onenand_verify_oob()
1655 onenand_update_bufferram(mtd, to, 0); onenand_verify_oob()
1656 status = this->wait(mtd, FL_READING); onenand_verify_oob()
1660 this->read_bufferram(mtd, ONENAND_SPARERAM, oob_buf, 0, mtd->oobsize); onenand_verify_oob()
1661 for (i = 0; i < mtd->oobsize; i++) onenand_verify_oob()
1670 * @param mtd MTD device structure
1675 static int onenand_verify(struct mtd_info *mtd, const u_char *buf, loff_t addr, size_t len) onenand_verify() argument
1677 struct onenand_chip *this = mtd->priv; onenand_verify()
1686 this->command(mtd, ONENAND_CMD_READ, addr, this->writesize); onenand_verify()
1688 onenand_update_bufferram(mtd, addr, 0); onenand_verify()
1690 ret = this->wait(mtd, FL_READING); onenand_verify()
1694 onenand_update_bufferram(mtd, addr, 1); onenand_verify()
1696 this->read_bufferram(mtd, ONENAND_DATARAM, this->verify_buf, 0, mtd->writesize); onenand_verify()
1716 static void onenand_panic_wait(struct mtd_info *mtd) onenand_panic_wait() argument
1718 struct onenand_chip *this = mtd->priv; onenand_panic_wait()
1732 * @param mtd MTD device structure
1740 static int onenand_panic_write(struct mtd_info *mtd, loff_t to, size_t len, onenand_panic_write() argument
1743 struct onenand_chip *this = mtd->priv; onenand_panic_write()
1751 onenand_panic_wait(mtd); onenand_panic_write()
1763 column = to & (mtd->writesize - 1); onenand_panic_write()
1767 int thislen = min_t(int, mtd->writesize - column, len - written); onenand_panic_write()
1770 this->command(mtd, ONENAND_CMD_BUFFERRAM, to, thislen); onenand_panic_write()
1773 subpage = thislen < mtd->writesize; onenand_panic_write()
1775 memset(this->page_buf, 0xff, mtd->writesize); onenand_panic_write()
1780 this->write_bufferram(mtd, ONENAND_DATARAM, wbuf, 0, mtd->writesize); onenand_panic_write()
1781 this->write_bufferram(mtd, ONENAND_SPARERAM, ffchars, 0, mtd->oobsize); onenand_panic_write()
1783 this->command(mtd, ONENAND_CMD_PROG, to, mtd->writesize); onenand_panic_write()
1785 onenand_panic_wait(mtd); onenand_panic_write()
1788 onenand_update_bufferram(mtd, to, !subpage); onenand_panic_write()
1791 onenand_update_bufferram(mtd, to + this->writesize, !subpage); onenand_panic_write()
1810 * @param mtd MTD device structure
1816 static int onenand_fill_auto_oob(struct mtd_info *mtd, u_char *oob_buf, onenand_fill_auto_oob() argument
1819 struct onenand_chip *this = mtd->priv; onenand_fill_auto_oob()
1851 * @param mtd MTD device structure
1857 static int onenand_write_ops_nolock(struct mtd_info *mtd, loff_t to, onenand_write_ops_nolock() argument
1860 struct onenand_chip *this = mtd->priv; onenand_write_ops_nolock()
1892 oobsize = mtd->oobsize; onenand_write_ops_nolock()
1894 oobcolumn = to & (mtd->oobsize - 1); onenand_write_ops_nolock()
1896 column = to & (mtd->writesize - 1); onenand_write_ops_nolock()
1903 thislen = min_t(int, mtd->writesize - column, len - written); onenand_write_ops_nolock()
1908 this->command(mtd, ONENAND_CMD_BUFFERRAM, to, thislen); onenand_write_ops_nolock()
1911 subpage = thislen < mtd->writesize; onenand_write_ops_nolock()
1913 memset(this->page_buf, 0xff, mtd->writesize); onenand_write_ops_nolock()
1918 this->write_bufferram(mtd, ONENAND_DATARAM, wbuf, 0, mtd->writesize); onenand_write_ops_nolock()
1925 memset(oobbuf, 0xff, mtd->oobsize); onenand_write_ops_nolock()
1927 onenand_fill_auto_oob(mtd, oobbuf, oob, oobcolumn, thisooblen); onenand_write_ops_nolock()
1937 this->write_bufferram(mtd, ONENAND_SPARERAM, oobbuf, 0, mtd->oobsize); onenand_write_ops_nolock()
1948 ret = this->wait(mtd, FL_WRITING); onenand_write_ops_nolock()
1951 onenand_update_bufferram(mtd, prev, !ret && !prev_subpage); onenand_write_ops_nolock()
1961 ret = onenand_verify(mtd, buf - len, to - len, len); onenand_write_ops_nolock()
1983 this->command(mtd, cmd, to, mtd->writesize); onenand_write_ops_nolock()
1989 ret = this->wait(mtd, FL_WRITING); onenand_write_ops_nolock()
1992 onenand_update_bufferram(mtd, to, !ret && !subpage); onenand_write_ops_nolock()
2000 ret = onenand_verify(mtd, buf, to, thislen); onenand_write_ops_nolock()
2026 onenand_invalidate_bufferram(mtd, 0, -1); onenand_write_ops_nolock()
2037 * @param mtd MTD device structure
2046 static int onenand_write_oob_nolock(struct mtd_info *mtd, loff_t to, onenand_write_oob_nolock() argument
2049 struct onenand_chip *this = mtd->priv; onenand_write_oob_nolock()
2068 oobsize = mtd->oobsize; onenand_write_oob_nolock()
2070 column = to & (mtd->oobsize - 1); onenand_write_oob_nolock()
2086 if (unlikely(to >= mtd->size || onenand_write_oob_nolock()
2087 column + len > ((mtd->size >> this->page_shift) - onenand_write_oob_nolock()
2104 this->command(mtd, ONENAND_CMD_BUFFERRAM, to, mtd->oobsize); onenand_write_oob_nolock()
2108 memset(oobbuf, 0xff, mtd->oobsize); onenand_write_oob_nolock()
2110 onenand_fill_auto_oob(mtd, oobbuf, buf, column, thislen); onenand_write_oob_nolock()
2113 this->write_bufferram(mtd, ONENAND_SPARERAM, oobbuf, 0, mtd->oobsize); onenand_write_oob_nolock()
2117 memset(this->page_buf, 0xff, mtd->writesize); onenand_write_oob_nolock()
2118 this->write_bufferram(mtd, ONENAND_DATARAM, onenand_write_oob_nolock()
2119 this->page_buf, 0, mtd->writesize); onenand_write_oob_nolock()
2122 this->command(mtd, oobcmd, to, mtd->oobsize); onenand_write_oob_nolock()
2124 onenand_update_bufferram(mtd, to, 0); onenand_write_oob_nolock()
2127 onenand_update_bufferram(mtd, to + this->writesize, 0); onenand_write_oob_nolock()
2130 ret = this->wait(mtd, FL_WRITING); onenand_write_oob_nolock()
2136 ret = onenand_verify_oob(mtd, oobbuf, to); onenand_write_oob_nolock()
2147 to += mtd->writesize; onenand_write_oob_nolock()
2159 * @param mtd MTD device structure
2167 static int onenand_write(struct mtd_info *mtd, loff_t to, size_t len, onenand_write() argument
2178 onenand_get_device(mtd, FL_WRITING); onenand_write()
2179 ret = onenand_write_ops_nolock(mtd, to, &ops); onenand_write()
2180 onenand_release_device(mtd); onenand_write()
2188 * @param mtd: MTD device structure
2192 static int onenand_write_oob(struct mtd_info *mtd, loff_t to, onenand_write_oob() argument
2207 onenand_get_device(mtd, FL_WRITING); onenand_write_oob()
2209 ret = onenand_write_ops_nolock(mtd, to, ops); onenand_write_oob()
2211 ret = onenand_write_oob_nolock(mtd, to, ops); onenand_write_oob()
2212 onenand_release_device(mtd); onenand_write_oob()
2219 * @param mtd MTD device structure
2226 static int onenand_block_isbad_nolock(struct mtd_info *mtd, loff_t ofs, int allowbbt) onenand_block_isbad_nolock() argument
2228 struct onenand_chip *this = mtd->priv; onenand_block_isbad_nolock()
2232 return bbm->isbad_bbt(mtd, ofs, allowbbt); onenand_block_isbad_nolock()
2236 static int onenand_multiblock_erase_verify(struct mtd_info *mtd, onenand_multiblock_erase_verify() argument
2239 struct onenand_chip *this = mtd->priv; onenand_multiblock_erase_verify()
2246 this->command(mtd, ONENAND_CMD_ERASE_VERIFY, addr, block_size); onenand_multiblock_erase_verify()
2247 ret = this->wait(mtd, FL_VERIFYING_ERASE); onenand_multiblock_erase_verify()
2263 * @param mtd MTD device structure
2269 static int onenand_multiblock_erase(struct mtd_info *mtd, onenand_multiblock_erase() argument
2273 struct onenand_chip *this = mtd->priv; onenand_multiblock_erase()
2291 if (onenand_block_isbad_nolock(mtd, addr, 0)) { onenand_multiblock_erase()
2326 this->command(mtd, ONENAND_CMD_MULTIBLOCK_ERASE, onenand_multiblock_erase()
2328 onenand_invalidate_bufferram(mtd, addr, block_size); onenand_multiblock_erase()
2330 ret = this->wait(mtd, FL_PREPARING_ERASE); onenand_multiblock_erase()
2347 this->command(mtd, ONENAND_CMD_ERASE, addr, block_size); onenand_multiblock_erase()
2348 onenand_invalidate_bufferram(mtd, addr, block_size); onenand_multiblock_erase()
2350 ret = this->wait(mtd, FL_ERASING); onenand_multiblock_erase()
2366 if (onenand_multiblock_erase_verify(mtd, &verify_instr)) { onenand_multiblock_erase()
2379 * @param mtd MTD device structure
2386 static int onenand_block_by_block_erase(struct mtd_info *mtd, onenand_block_by_block_erase() argument
2391 struct onenand_chip *this = mtd->priv; onenand_block_by_block_erase()
2409 if (onenand_block_isbad_nolock(mtd, addr, 0)) { onenand_block_by_block_erase()
2417 this->command(mtd, ONENAND_CMD_ERASE, addr, block_size); onenand_block_by_block_erase()
2419 onenand_invalidate_bufferram(mtd, addr, block_size); onenand_block_by_block_erase()
2421 ret = this->wait(mtd, FL_ERASING); onenand_block_by_block_erase()
2455 * @param mtd MTD device structure
2460 static int onenand_erase(struct mtd_info *mtd, struct erase_info *instr) onenand_erase() argument
2462 struct onenand_chip *this = mtd->priv; onenand_erase()
2476 int i = flexonenand_region(mtd, addr); onenand_erase()
2478 region = &mtd->eraseregions[i]; onenand_erase()
2501 onenand_get_device(mtd, FL_ERASING); onenand_erase()
2506 ret = onenand_block_by_block_erase(mtd, instr, onenand_erase()
2509 ret = onenand_multiblock_erase(mtd, instr, block_size); onenand_erase()
2513 onenand_release_device(mtd); onenand_erase()
2526 * @param mtd MTD device structure
2530 static void onenand_sync(struct mtd_info *mtd) onenand_sync() argument
2535 onenand_get_device(mtd, FL_SYNCING); onenand_sync()
2538 onenand_release_device(mtd); onenand_sync()
2543 * @param mtd MTD device structure
2544 * @param ofs offset relative to mtd start
2548 static int onenand_block_isbad(struct mtd_info *mtd, loff_t ofs) onenand_block_isbad() argument
2552 onenand_get_device(mtd, FL_READING); onenand_block_isbad()
2553 ret = onenand_block_isbad_nolock(mtd, ofs, 0); onenand_block_isbad()
2554 onenand_release_device(mtd); onenand_block_isbad()
2560 * @param mtd MTD device structure
2566 static int onenand_default_block_markbad(struct mtd_info *mtd, loff_t ofs) onenand_default_block_markbad() argument
2568 struct onenand_chip *this = mtd->priv; onenand_default_block_markbad()
2585 ofs += mtd->oobsize + (bbm->badblockpos & ~0x01); onenand_default_block_markbad()
2590 return onenand_write_oob_nolock(mtd, ofs, &ops); onenand_default_block_markbad()
2595 * @param mtd MTD device structure
2596 * @param ofs offset relative to mtd start
2600 static int onenand_block_markbad(struct mtd_info *mtd, loff_t ofs) onenand_block_markbad() argument
2602 struct onenand_chip *this = mtd->priv; onenand_block_markbad()
2605 ret = onenand_block_isbad(mtd, ofs); onenand_block_markbad()
2613 onenand_get_device(mtd, FL_WRITING); onenand_block_markbad()
2614 ret = this->block_markbad(mtd, ofs); onenand_block_markbad()
2615 onenand_release_device(mtd); onenand_block_markbad()
2621 * @param mtd MTD device structure
2622 * @param ofs offset relative to mtd start
2628 static int onenand_do_lock_cmd(struct mtd_info *mtd, loff_t ofs, size_t len, int cmd) onenand_do_lock_cmd() argument
2630 struct onenand_chip *this = mtd->priv; onenand_do_lock_cmd()
2649 this->command(mtd, cmd, 0, 0); onenand_do_lock_cmd()
2652 this->wait(mtd, FL_LOCKING); onenand_do_lock_cmd()
2679 this->command(mtd, cmd, 0, 0); onenand_do_lock_cmd()
2682 this->wait(mtd, FL_LOCKING); onenand_do_lock_cmd()
2701 * @param mtd MTD device structure
2702 * @param ofs offset relative to mtd start
2707 static int onenand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) onenand_lock() argument
2711 onenand_get_device(mtd, FL_LOCKING); onenand_lock()
2712 ret = onenand_do_lock_cmd(mtd, ofs, len, ONENAND_CMD_LOCK); onenand_lock()
2713 onenand_release_device(mtd); onenand_lock()
2719 * @param mtd MTD device structure
2720 * @param ofs offset relative to mtd start
2725 static int onenand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) onenand_unlock() argument
2729 onenand_get_device(mtd, FL_LOCKING); onenand_unlock()
2730 ret = onenand_do_lock_cmd(mtd, ofs, len, ONENAND_CMD_UNLOCK); onenand_unlock()
2731 onenand_release_device(mtd); onenand_unlock()
2771 * @param mtd MTD device structure
2775 static void onenand_unlock_all(struct mtd_info *mtd) onenand_unlock_all() argument
2777 struct onenand_chip *this = mtd->priv; onenand_unlock_all()
2779 loff_t len = mtd->size; onenand_unlock_all()
2785 this->command(mtd, ONENAND_CMD_UNLOCK_ALL, 0, 0); onenand_unlock_all()
2788 this->wait(mtd, FL_LOCKING); onenand_unlock_all()
2811 onenand_do_lock_cmd(mtd, ofs, len, ONENAND_CMD_UNLOCK); onenand_unlock_all()
2818 * @param mtd MTD device structure
2823 static int onenand_otp_command(struct mtd_info *mtd, int cmd, loff_t addr, onenand_otp_command() argument
2826 struct onenand_chip *this = mtd->priv; onenand_otp_command()
2893 * @param mtd MTD device structure
2901 static int onenand_otp_write_oob_nolock(struct mtd_info *mtd, loff_t to, onenand_otp_write_oob_nolock() argument
2904 struct onenand_chip *this = mtd->priv; onenand_otp_write_oob_nolock()
2917 oobsize = mtd->oobsize; onenand_otp_write_oob_nolock()
2919 column = to & (mtd->oobsize - 1); onenand_otp_write_oob_nolock()
2952 this->command(mtd, ONENAND_CMD_OTP_ACCESS, 0, 0); onenand_otp_write_oob_nolock()
2953 this->wait(mtd, FL_OTPING); onenand_otp_write_oob_nolock()
2965 this->write_bufferram(mtd, ONENAND_SPARERAM, onenand_otp_write_oob_nolock()
2966 oobbuf, 0, mtd->oobsize); onenand_otp_write_oob_nolock()
2968 onenand_otp_command(mtd, ONENAND_CMD_PROGOOB, to, mtd->oobsize); onenand_otp_write_oob_nolock()
2969 onenand_update_bufferram(mtd, to, 0); onenand_otp_write_oob_nolock()
2972 onenand_update_bufferram(mtd, to + this->writesize, 0); onenand_otp_write_oob_nolock()
2975 ret = this->wait(mtd, FL_WRITING); onenand_otp_write_oob_nolock()
2982 this->command(mtd, ONENAND_CMD_RESET, 0, 0); onenand_otp_write_oob_nolock()
2983 this->wait(mtd, FL_RESETING); onenand_otp_write_oob_nolock()
3008 to += mtd->writesize; onenand_otp_write_oob_nolock()
3019 typedef int (*otp_op_t)(struct mtd_info *mtd, loff_t form, size_t len,
3024 * @param mtd MTD device structure
3032 static int do_otp_read(struct mtd_info *mtd, loff_t from, size_t len, do_otp_read() argument
3035 struct onenand_chip *this = mtd->priv; do_otp_read()
3045 this->command(mtd, ONENAND_CMD_OTP_ACCESS, 0, 0); do_otp_read()
3046 this->wait(mtd, FL_OTPING); do_otp_read()
3049 onenand_mlc_read_ops_nolock(mtd, from, &ops) : do_otp_read()
3050 onenand_read_ops_nolock(mtd, from, &ops); do_otp_read()
3053 this->command(mtd, ONENAND_CMD_RESET, 0, 0); do_otp_read()
3054 this->wait(mtd, FL_RESETING); do_otp_read()
3061 * @param mtd MTD device structure
3069 static int do_otp_write(struct mtd_info *mtd, loff_t to, size_t len, do_otp_write() argument
3072 struct onenand_chip *this = mtd->priv; do_otp_write()
3078 if (len < mtd->writesize) { do_otp_write()
3080 memset(this->page_buf + len, 0xff, mtd->writesize - len); do_otp_write()
3082 len = mtd->writesize; do_otp_write()
3086 this->command(mtd, ONENAND_CMD_OTP_ACCESS, 0, 0); do_otp_write()
3087 this->wait(mtd, FL_OTPING); do_otp_write()
3093 ret = onenand_write_ops_nolock(mtd, to, &ops); do_otp_write()
3097 this->command(mtd, ONENAND_CMD_RESET, 0, 0); do_otp_write()
3098 this->wait(mtd, FL_RESETING); do_otp_write()
3105 * @param mtd MTD device structure
3113 static int do_otp_lock(struct mtd_info *mtd, loff_t from, size_t len, do_otp_lock() argument
3116 struct onenand_chip *this = mtd->priv; do_otp_lock()
3123 this->command(mtd, ONENAND_CMD_OTP_ACCESS, 0, 0); do_otp_lock()
3124 this->wait(mtd, FL_OTPING); do_otp_lock()
3129 ops.len = mtd->writesize; do_otp_lock()
3133 ret = onenand_write_ops_nolock(mtd, mtd->writesize * 49, &ops); do_otp_lock()
3137 this->command(mtd, ONENAND_CMD_RESET, 0, 0); do_otp_lock()
3138 this->wait(mtd, FL_RESETING); do_otp_lock()
3144 ret = onenand_otp_write_oob_nolock(mtd, from, &ops); do_otp_lock()
3153 * @param mtd MTD device structure
3163 static int onenand_otp_walk(struct mtd_info *mtd, loff_t from, size_t len, onenand_otp_walk() argument
3167 struct onenand_chip *this = mtd->priv; onenand_otp_walk()
3181 from += mtd->writesize * otp_pages; onenand_otp_walk()
3187 if (mtd->writesize * otp_pages < from + len) onenand_otp_walk()
3190 if (mtd->writesize * otp_pages < len) onenand_otp_walk()
3194 onenand_get_device(mtd, FL_OTPING); onenand_otp_walk()
3207 otpinfo->length = mtd->writesize; onenand_otp_walk()
3210 from += mtd->writesize; onenand_otp_walk()
3216 ret = action(mtd, from, len, &tmp_retlen, buf); onenand_otp_walk()
3227 onenand_release_device(mtd); onenand_otp_walk()
3234 * @param mtd MTD device structure
3241 static int onenand_get_fact_prot_info(struct mtd_info *mtd, size_t len, onenand_get_fact_prot_info() argument
3244 return onenand_otp_walk(mtd, 0, len, retlen, (u_char *) buf, NULL, onenand_get_fact_prot_info()
3250 * @param mtd MTD device structure
3258 static int onenand_read_fact_prot_reg(struct mtd_info *mtd, loff_t from, onenand_read_fact_prot_reg() argument
3261 return onenand_otp_walk(mtd, from, len, retlen, buf, do_otp_read, MTD_OTP_FACTORY); onenand_read_fact_prot_reg()
3266 * @param mtd MTD device structure
3273 static int onenand_get_user_prot_info(struct mtd_info *mtd, size_t len, onenand_get_user_prot_info() argument
3276 return onenand_otp_walk(mtd, 0, len, retlen, (u_char *) buf, NULL, onenand_get_user_prot_info()
3282 * @param mtd MTD device structure
3290 static int onenand_read_user_prot_reg(struct mtd_info *mtd, loff_t from, onenand_read_user_prot_reg() argument
3293 return onenand_otp_walk(mtd, from, len, retlen, buf, do_otp_read, MTD_OTP_USER); onenand_read_user_prot_reg()
3298 * @param mtd MTD device structure
3306 static int onenand_write_user_prot_reg(struct mtd_info *mtd, loff_t from, onenand_write_user_prot_reg() argument
3309 return onenand_otp_walk(mtd, from, len, retlen, buf, do_otp_write, MTD_OTP_USER); onenand_write_user_prot_reg()
3314 * @param mtd MTD device structure
3320 static int onenand_lock_user_prot_reg(struct mtd_info *mtd, loff_t from, onenand_lock_user_prot_reg() argument
3323 struct onenand_chip *this = mtd->priv; onenand_lock_user_prot_reg()
3330 : mtd->oobsize); onenand_lock_user_prot_reg()
3339 len = FLEXONENAND(this) ? mtd->writesize : 16; onenand_lock_user_prot_reg()
3360 ret = onenand_otp_walk(mtd, from, len, &retlen, buf, do_otp_lock, MTD_OTP_USER); onenand_lock_user_prot_reg()
3369 * @param mtd MTD data structure
3375 static void onenand_check_features(struct mtd_info *mtd) onenand_check_features() argument
3377 struct onenand_chip *this = mtd->priv; onenand_check_features()
3512 static int flexonenand_get_boundary(struct mtd_info *mtd) flexonenand_get_boundary() argument
3514 struct onenand_chip *this = mtd->priv; flexonenand_get_boundary()
3523 this->command(mtd, FLEXONENAND_CMD_PI_ACCESS, die, 0); flexonenand_get_boundary()
3524 this->wait(mtd, FL_SYNCING); flexonenand_get_boundary()
3526 this->command(mtd, FLEXONENAND_CMD_READ_PI, die, 0); flexonenand_get_boundary()
3527 this->wait(mtd, FL_READING); flexonenand_get_boundary()
3536 this->command(mtd, ONENAND_CMD_RESET, 0, 0); flexonenand_get_boundary()
3537 this->wait(mtd, FL_RESETING); flexonenand_get_boundary()
3550 * boundary[], diesize[], mtd->size, mtd->erasesize
3551 * @param mtd - MTD device structure
3553 static void flexonenand_get_size(struct mtd_info *mtd) flexonenand_get_size() argument
3555 struct onenand_chip *this = mtd->priv; flexonenand_get_size()
3566 mtd->numeraseregions = this->dies << 1; flexonenand_get_size()
3569 flexonenand_get_boundary(mtd); flexonenand_get_size()
3575 mtd->eraseregions[i].offset = ofs; flexonenand_get_size()
3576 mtd->eraseregions[i].erasesize = 1 << eraseshift; flexonenand_get_size()
3577 mtd->eraseregions[i].numblocks = flexonenand_get_size()
3579 ofs += mtd->eraseregions[i].numblocks << eraseshift; flexonenand_get_size()
3582 mtd->numeraseregions -= 1; flexonenand_get_size()
3583 mtd->eraseregions[i].numblocks += flexonenand_get_size()
3589 mtd->eraseregions[i].offset = ofs; flexonenand_get_size()
3590 mtd->eraseregions[i].erasesize = 1 << eraseshift; flexonenand_get_size()
3591 mtd->eraseregions[i].numblocks = maxbdry ^ flexonenand_get_size()
3593 ofs += mtd->eraseregions[i].numblocks << eraseshift; flexonenand_get_size()
3596 mtd->numeraseregions -= 1; flexonenand_get_size()
3600 mtd->erasesize = 1 << this->erase_shift; flexonenand_get_size()
3601 if (mtd->numeraseregions == 1) flexonenand_get_size()
3602 mtd->erasesize >>= 1; flexonenand_get_size()
3604 printk(KERN_INFO "Device has %d eraseregions\n", mtd->numeraseregions); flexonenand_get_size()
3605 for (i = 0; i < mtd->numeraseregions; i++) flexonenand_get_size()
3608 (unsigned int) mtd->eraseregions[i].offset, flexonenand_get_size()
3609 mtd->eraseregions[i].erasesize, flexonenand_get_size()
3610 mtd->eraseregions[i].numblocks); flexonenand_get_size()
3612 for (die = 0, mtd->size = 0; die < this->dies; die++) { flexonenand_get_size()
3616 mtd->size += this->diesize[die]; flexonenand_get_size()
3622 * @param mtd_info - mtd info structure
3634 static int flexonenand_check_blocks_erased(struct mtd_info *mtd, int start, int end) flexonenand_check_blocks_erased() argument
3636 struct onenand_chip *this = mtd->priv; flexonenand_check_blocks_erased()
3642 .ooblen = mtd->oobsize, flexonenand_check_blocks_erased()
3652 if (onenand_block_isbad_nolock(mtd, addr, 0)) flexonenand_check_blocks_erased()
3659 ret = onenand_read_oob_nolock(mtd, addr, &ops); flexonenand_check_blocks_erased()
3663 for (i = 0; i < mtd->oobsize; i++) flexonenand_check_blocks_erased()
3667 if (i != mtd->oobsize) { flexonenand_check_blocks_erased()
3679 * @param mtd - mtd info structure
3681 static int flexonenand_set_boundary(struct mtd_info *mtd, int die, flexonenand_set_boundary() argument
3684 struct onenand_chip *this = mtd->priv; flexonenand_set_boundary()
3709 ret = flexonenand_check_blocks_erased(mtd, min(old, new) + 1, max(old, new)); flexonenand_set_boundary()
3716 this->command(mtd, FLEXONENAND_CMD_PI_ACCESS, die, 0); flexonenand_set_boundary()
3717 this->wait(mtd, FL_SYNCING); flexonenand_set_boundary()
3720 this->command(mtd, FLEXONENAND_CMD_READ_PI, die, 0); flexonenand_set_boundary()
3721 this->wait(mtd, FL_READING); flexonenand_set_boundary()
3738 this->command(mtd, ONENAND_CMD_ERASE, addr, 0); flexonenand_set_boundary()
3739 ret = this->wait(mtd, FL_ERASING); flexonenand_set_boundary()
3747 this->command(mtd, ONENAND_CMD_PROG, addr, 0); flexonenand_set_boundary()
3748 ret = this->wait(mtd, FL_WRITING); flexonenand_set_boundary()
3755 this->command(mtd, FLEXONENAND_CMD_PI_UPDATE, die, 0); flexonenand_set_boundary()
3756 ret = this->wait(mtd, FL_WRITING); flexonenand_set_boundary()
3759 this->wait(mtd, FL_RESETING); flexonenand_set_boundary()
3762 flexonenand_get_size(mtd); flexonenand_set_boundary()
3769 * @param mtd MTD device structure
3774 static int onenand_chip_probe(struct mtd_info *mtd) onenand_chip_probe() argument
3776 struct onenand_chip *this = mtd->priv; onenand_chip_probe()
3795 this->wait(mtd, FL_RESETING); onenand_chip_probe()
3817 * @param mtd MTD device structure
3819 static int onenand_probe(struct mtd_info *mtd) onenand_probe() argument
3821 struct onenand_chip *this = mtd->priv; onenand_probe()
3826 ret = this->chip_probe(mtd); onenand_probe()
3841 onenand_check_features(mtd); onenand_probe()
3847 mtd->numeraseregions = this->dies << 1; onenand_probe()
3848 mtd->eraseregions = kzalloc(sizeof(struct mtd_erase_region_info) onenand_probe()
3850 if (!mtd->eraseregions) onenand_probe()
3856 * mtd->size represents the actual device size. onenand_probe()
3862 mtd->writesize = this->read_word(this->base + ONENAND_REG_DATA_BUFFER_SIZE); onenand_probe()
3865 mtd->writesize <<= 1; onenand_probe()
3867 mtd->oobsize = mtd->writesize >> 5; onenand_probe()
3869 mtd->erasesize = mtd->writesize << 6; onenand_probe()
3876 mtd->erasesize <<= 1; onenand_probe()
3878 this->erase_shift = ffs(mtd->erasesize) - 1; onenand_probe()
3879 this->page_shift = ffs(mtd->writesize) - 1; onenand_probe()
3885 this->writesize = mtd->writesize; onenand_probe()
3890 flexonenand_get_size(mtd); onenand_probe()
3892 mtd->size = this->chipsize; onenand_probe()
3901 mtd->writesize <<= 1; onenand_probe()
3902 mtd->erasesize <<= 1; onenand_probe()
3910 * @param mtd MTD device structure
3912 static int onenand_suspend(struct mtd_info *mtd) onenand_suspend() argument
3914 return onenand_get_device(mtd, FL_PM_SUSPENDED); onenand_suspend()
3919 * @param mtd MTD device structure
3921 static void onenand_resume(struct mtd_info *mtd) onenand_resume() argument
3923 struct onenand_chip *this = mtd->priv; onenand_resume()
3926 onenand_release_device(mtd); onenand_resume()
3934 * @param mtd MTD device structure
3939 * The flash ID is read and the mtd/chip structures are
3942 int onenand_scan(struct mtd_info *mtd, int maxchips) onenand_scan() argument
3945 struct onenand_chip *this = mtd->priv; onenand_scan()
3955 onenand_setup_wait(mtd); onenand_scan()
3974 if (onenand_probe(mtd)) onenand_scan()
3985 this->page_buf = kzalloc(mtd->writesize, GFP_KERNEL); onenand_scan()
3989 this->verify_buf = kzalloc(mtd->writesize, GFP_KERNEL); onenand_scan()
3998 this->oob_buf = kzalloc(mtd->oobsize, GFP_KERNEL); onenand_scan()
4016 switch (mtd->oobsize) { onenand_scan()
4020 mtd->subpage_sft = 0; onenand_scan()
4023 mtd->subpage_sft = 2; onenand_scan()
4026 mtd->subpage_sft = 0; onenand_scan()
4030 mtd->subpage_sft = 2; onenand_scan()
4035 mtd->subpage_sft = 1; onenand_scan()
4040 __func__, mtd->oobsize); onenand_scan()
4041 mtd->subpage_sft = 0; onenand_scan()
4047 this->subpagesize = mtd->writesize >> mtd->subpage_sft; onenand_scan()
4058 mtd->oobavail = this->ecclayout->oobavail; onenand_scan()
4060 mtd->ecclayout = this->ecclayout; onenand_scan()
4061 mtd->ecc_strength = 1; onenand_scan()
4064 mtd->type = ONENAND_IS_MLC(this) ? MTD_MLCNANDFLASH : MTD_NANDFLASH; onenand_scan()
4065 mtd->flags = MTD_CAP_NANDFLASH; onenand_scan()
4066 mtd->_erase = onenand_erase; onenand_scan()
4067 mtd->_point = NULL; onenand_scan()
4068 mtd->_unpoint = NULL; onenand_scan()
4069 mtd->_read = onenand_read; onenand_scan()
4070 mtd->_write = onenand_write; onenand_scan()
4071 mtd->_read_oob = onenand_read_oob; onenand_scan()
4072 mtd->_write_oob = onenand_write_oob; onenand_scan()
4073 mtd->_panic_write = onenand_panic_write; onenand_scan()
4075 mtd->_get_fact_prot_info = onenand_get_fact_prot_info; onenand_scan()
4076 mtd->_read_fact_prot_reg = onenand_read_fact_prot_reg; onenand_scan()
4077 mtd->_get_user_prot_info = onenand_get_user_prot_info; onenand_scan()
4078 mtd->_read_user_prot_reg = onenand_read_user_prot_reg; onenand_scan()
4079 mtd->_write_user_prot_reg = onenand_write_user_prot_reg; onenand_scan()
4080 mtd->_lock_user_prot_reg = onenand_lock_user_prot_reg; onenand_scan()
4082 mtd->_sync = onenand_sync; onenand_scan()
4083 mtd->_lock = onenand_lock; onenand_scan()
4084 mtd->_unlock = onenand_unlock; onenand_scan()
4085 mtd->_suspend = onenand_suspend; onenand_scan()
4086 mtd->_resume = onenand_resume; onenand_scan()
4087 mtd->_block_isbad = onenand_block_isbad; onenand_scan()
4088 mtd->_block_markbad = onenand_block_markbad; onenand_scan()
4089 mtd->owner = THIS_MODULE; onenand_scan()
4090 mtd->writebufsize = mtd->writesize; onenand_scan()
4094 this->unlock_all(mtd); onenand_scan()
4096 ret = this->scan_bbt(mtd); onenand_scan()
4102 flexonenand_set_boundary(mtd, i, flex_bdry[2 * i], onenand_scan()
4110 * @param mtd MTD device structure
4112 void onenand_release(struct mtd_info *mtd) onenand_release() argument
4114 struct onenand_chip *this = mtd->priv; onenand_release()
4117 mtd_device_unregister(mtd); onenand_release()
4134 kfree(mtd->eraseregions); onenand_release()
H A Dgeneric.c2 * linux/drivers/mtd/onenand/generic.c
18 #include <linux/mtd/mtd.h>
19 #include <linux/mtd/onenand.h>
20 #include <linux/mtd/partitions.h>
33 struct mtd_info mtd; member in struct:onenand_info
63 info->mtd.name = dev_name(&pdev->dev); generic_onenand_probe()
64 info->mtd.priv = &info->onenand; generic_onenand_probe()
65 info->mtd.owner = THIS_MODULE; generic_onenand_probe()
67 if (onenand_scan(&info->mtd, 1)) { generic_onenand_probe()
72 err = mtd_device_parse_register(&info->mtd, NULL, NULL, generic_onenand_probe()
97 onenand_release(&info->mtd); generic_onenand_remove()
H A Donenand_bbt.c2 * linux/drivers/mtd/onenand/onenand_bbt.c
16 #include <linux/mtd/mtd.h>
17 #include <linux/mtd/onenand.h>
48 * @param mtd MTD device structure
57 static int create_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *bd, int chip) create_bbt() argument
59 struct onenand_chip *this = mtd->priv; create_bbt()
95 ret = onenand_bbt_read_oob(mtd, create_bbt()
107 mtd->ecc_stats.badblocks++; create_bbt()
114 rgn = flexonenand_region(mtd, from); create_bbt()
115 from += mtd->eraseregions[rgn].erasesize; create_bbt()
126 * @param mtd MTD device structure
132 static inline int onenand_memory_bbt (struct mtd_info *mtd, struct nand_bbt_descr *bd) onenand_memory_bbt() argument
134 struct onenand_chip *this = mtd->priv; onenand_memory_bbt()
136 return create_bbt(mtd, this->page_buf, bd, -1); onenand_memory_bbt()
141 * @param mtd MTD device structure
145 static int onenand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt) onenand_isbad_bbt() argument
147 struct onenand_chip *this = mtd->priv; onenand_isbad_bbt()
170 * @param mtd MTD device structure
182 int onenand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd) onenand_scan_bbt() argument
184 struct onenand_chip *this = mtd->priv; onenand_scan_bbt()
204 if ((ret = onenand_memory_bbt(mtd, bd))) { onenand_scan_bbt()
228 * @param mtd MTD device structure
233 int onenand_default_bbt(struct mtd_info *mtd) onenand_default_bbt() argument
235 struct onenand_chip *this = mtd->priv; onenand_default_bbt()
248 return onenand_scan_bbt(mtd, bbm->badblock_pattern); onenand_default_bbt()
H A Domap2.c2 * linux/drivers/mtd/onenand/omap2.c
28 #include <linux/mtd/mtd.h>
29 #include <linux/mtd/onenand.h>
30 #include <linux/mtd/partitions.h>
40 #include <linux/platform_data/mtd-onenand-omap2.h>
55 struct mtd_info mtd; member in struct:omap2_onenand
106 static int omap2_onenand_wait(struct mtd_info *mtd, int state) omap2_onenand_wait() argument
108 struct omap2_onenand *c = container_of(mtd, struct omap2_onenand, mtd); omap2_onenand_wait()
109 struct onenand_chip *this = mtd->priv; omap2_onenand_wait()
248 mtd->ecc_stats.failed++; omap2_onenand_wait()
254 mtd->ecc_stats.corrected++; omap2_onenand_wait()
280 static inline int omap2_onenand_bufferram_offset(struct mtd_info *mtd, int area) omap2_onenand_bufferram_offset() argument
282 struct onenand_chip *this = mtd->priv; omap2_onenand_bufferram_offset()
288 return mtd->oobsize; omap2_onenand_bufferram_offset()
296 static int omap3_onenand_read_bufferram(struct mtd_info *mtd, int area, omap3_onenand_read_bufferram() argument
300 struct omap2_onenand *c = container_of(mtd, struct omap2_onenand, mtd); omap3_onenand_read_bufferram()
301 struct onenand_chip *this = mtd->priv; omap3_onenand_read_bufferram()
309 bram_offset = omap2_onenand_bufferram_offset(mtd, area) + area + offset; omap3_onenand_read_bufferram()
374 static int omap3_onenand_write_bufferram(struct mtd_info *mtd, int area, omap3_onenand_write_bufferram() argument
378 struct omap2_onenand *c = container_of(mtd, struct omap2_onenand, mtd); omap3_onenand_write_bufferram()
379 struct onenand_chip *this = mtd->priv; omap3_onenand_write_bufferram()
386 bram_offset = omap2_onenand_bufferram_offset(mtd, area) + area + offset; omap3_onenand_write_bufferram()
447 static int omap3_onenand_read_bufferram(struct mtd_info *mtd, int area, omap3_onenand_read_bufferram() argument
454 static int omap3_onenand_write_bufferram(struct mtd_info *mtd, int area, omap3_onenand_write_bufferram() argument
465 static int omap2_onenand_read_bufferram(struct mtd_info *mtd, int area, omap2_onenand_read_bufferram() argument
469 struct omap2_onenand *c = container_of(mtd, struct omap2_onenand, mtd); omap2_onenand_read_bufferram()
470 struct onenand_chip *this = mtd->priv; omap2_onenand_read_bufferram()
474 bram_offset = omap2_onenand_bufferram_offset(mtd, area) + area + offset; omap2_onenand_read_bufferram()
510 static int omap2_onenand_write_bufferram(struct mtd_info *mtd, int area, omap2_onenand_write_bufferram() argument
514 struct omap2_onenand *c = container_of(mtd, struct omap2_onenand, mtd); omap2_onenand_write_bufferram()
515 struct onenand_chip *this = mtd->priv; omap2_onenand_write_bufferram()
519 bram_offset = omap2_onenand_bufferram_offset(mtd, area) + area + offset; omap2_onenand_write_bufferram()
557 static int omap2_onenand_read_bufferram(struct mtd_info *mtd, int area, omap2_onenand_read_bufferram() argument
564 static int omap2_onenand_write_bufferram(struct mtd_info *mtd, int area, omap2_onenand_write_bufferram() argument
586 static int omap2_onenand_enable(struct mtd_info *mtd) omap2_onenand_enable() argument
589 struct omap2_onenand *c = container_of(mtd, struct omap2_onenand, mtd); omap2_onenand_enable()
598 static int omap2_onenand_disable(struct mtd_info *mtd) omap2_onenand_disable() argument
601 struct omap2_onenand *c = container_of(mtd, struct omap2_onenand, mtd); omap2_onenand_disable()
713 c->mtd.name = dev_name(&pdev->dev); omap2_onenand_probe()
714 c->mtd.priv = &c->onenand; omap2_onenand_probe()
715 c->mtd.owner = THIS_MODULE; omap2_onenand_probe()
717 c->mtd.dev.parent = &pdev->dev; omap2_onenand_probe()
745 if ((r = onenand_scan(&c->mtd, 1)) < 0) omap2_onenand_probe()
749 r = mtd_device_parse_register(&c->mtd, NULL, &ppdata, omap2_onenand_probe()
760 onenand_release(&c->mtd); omap2_onenand_probe()
785 onenand_release(&c->mtd); omap2_onenand_remove()
H A Dsamsung.c21 #include <linux/mtd/mtd.h>
22 #include <linux/mtd/onenand.h>
23 #include <linux/mtd/partitions.h>
128 struct mtd_info *mtd; member in struct:s3c_onenand
226 struct onenand_chip *this = onenand->mtd->priv; s3c_onenand_readw()
276 struct onenand_chip *this = onenand->mtd->priv; s3c_onenand_writew()
318 static int s3c_onenand_wait(struct mtd_info *mtd, int state) s3c_onenand_wait() argument
366 mtd->ecc_stats.failed++; s3c_onenand_wait()
384 static int s3c_onenand_command(struct mtd_info *mtd, int cmd, loff_t addr, s3c_onenand_command() argument
387 struct onenand_chip *this = mtd->priv; s3c_onenand_command()
421 s += (mtd->oobsize >> 2); s3c_onenand_command()
424 mcount = mtd->writesize >> 2; s3c_onenand_command()
425 scount = mtd->oobsize >> 2; s3c_onenand_command()
482 static unsigned char *s3c_get_bufferram(struct mtd_info *mtd, int area) s3c_get_bufferram() argument
484 struct onenand_chip *this = mtd->priv; s3c_get_bufferram()
495 p += mtd->oobsize; s3c_get_bufferram()
501 static int onenand_read_bufferram(struct mtd_info *mtd, int area, onenand_read_bufferram() argument
507 p = s3c_get_bufferram(mtd, area); onenand_read_bufferram()
512 static int onenand_write_bufferram(struct mtd_info *mtd, int area, onenand_write_bufferram() argument
518 p = s3c_get_bufferram(mtd, area); onenand_write_bufferram()
623 static int s5pc110_read_bufferram(struct mtd_info *mtd, int area, s5pc110_read_bufferram() argument
626 struct onenand_chip *this = mtd->priv; s5pc110_read_bufferram()
638 p += mtd->oobsize; s5pc110_read_bufferram()
642 !onenand->dma_addr || count != mtd->writesize) s5pc110_read_bufferram()
684 if (count != mtd->writesize) { s5pc110_read_bufferram()
686 memcpy(this->page_buf, p, mtd->writesize); s5pc110_read_bufferram()
695 static int s5pc110_chip_probe(struct mtd_info *mtd) s5pc110_chip_probe() argument
701 static int s3c_onenand_bbt_wait(struct mtd_info *mtd, int state) s3c_onenand_bbt_wait() argument
734 static void s3c_onenand_check_lock_status(struct mtd_info *mtd) s3c_onenand_check_lock_status() argument
736 struct onenand_chip *this = mtd->priv; s3c_onenand_check_lock_status()
754 static void s3c_onenand_do_lock_cmd(struct mtd_info *mtd, loff_t ofs, s3c_onenand_do_lock_cmd() argument
757 struct onenand_chip *this = mtd->priv; s3c_onenand_do_lock_cmd()
777 this->wait(mtd, FL_LOCKING); s3c_onenand_do_lock_cmd()
780 static void s3c_unlock_all(struct mtd_info *mtd) s3c_unlock_all() argument
782 struct onenand_chip *this = mtd->priv; s3c_unlock_all()
788 this->command(mtd, ONENAND_CMD_UNLOCK_ALL, 0, 0); s3c_unlock_all()
791 this->wait(mtd, FL_LOCKING); s3c_unlock_all()
795 s3c_onenand_check_lock_status(mtd); s3c_unlock_all()
804 s3c_onenand_do_lock_cmd(mtd, ofs, len, ONENAND_CMD_UNLOCK); s3c_unlock_all()
806 s3c_onenand_check_lock_status(mtd); s3c_unlock_all()
809 static void s3c_onenand_setup(struct mtd_info *mtd) s3c_onenand_setup() argument
811 struct onenand_chip *this = mtd->priv; s3c_onenand_setup()
813 onenand->mtd = mtd; s3c_onenand_setup()
846 struct mtd_info *mtd; s3c_onenand_probe() local
854 mtd = kzalloc(size, GFP_KERNEL); s3c_onenand_probe()
855 if (!mtd) s3c_onenand_probe()
864 this = (struct onenand_chip *) &mtd[1]; s3c_onenand_probe()
865 mtd->priv = this; s3c_onenand_probe()
866 mtd->dev.parent = &pdev->dev; s3c_onenand_probe()
867 mtd->owner = THIS_MODULE; s3c_onenand_probe()
871 s3c_onenand_setup(mtd); s3c_onenand_probe()
938 mtd->subpage_sft = 0; s3c_onenand_probe()
939 this->subpagesize = mtd->writesize; s3c_onenand_probe()
981 if (onenand_scan(mtd, 1)) { s3c_onenand_probe()
988 mtd->subpage_sft = 0; s3c_onenand_probe()
989 this->subpagesize = mtd->writesize; s3c_onenand_probe()
995 err = mtd_device_parse_register(mtd, NULL, NULL, s3c_onenand_probe()
999 platform_set_drvdata(pdev, mtd); s3c_onenand_probe()
1030 kfree(mtd); s3c_onenand_probe()
1036 struct mtd_info *mtd = platform_get_drvdata(pdev); s3c_onenand_remove() local
1038 onenand_release(mtd); s3c_onenand_remove()
1057 kfree(mtd); s3c_onenand_remove()
1064 struct mtd_info *mtd = platform_get_drvdata(pdev); s3c_pm_ops_suspend() local
1065 struct onenand_chip *this = mtd->priv; s3c_pm_ops_suspend()
1067 this->wait(mtd, FL_PM_SUSPENDED); s3c_pm_ops_suspend()
1074 struct mtd_info *mtd = platform_get_drvdata(pdev); s3c_pm_ops_resume() local
1075 struct onenand_chip *this = mtd->priv; s3c_pm_ops_resume()
1077 this->unlock_all(mtd); s3c_pm_ops_resume()
/linux-4.1.27/fs/romfs/
H A Dmmap-nommu.c13 #include <linux/mtd/super.h>
29 struct mtd_info *mtd = inode->i_sb->s_mtd; romfs_get_unmapped_area() local
33 if (!mtd) romfs_get_unmapped_area()
48 if (len > mtd->size || pgoff >= (mtd->size >> PAGE_SHIFT)) romfs_get_unmapped_area()
52 if (offset >= mtd->size) romfs_get_unmapped_area()
55 if ((offset + len) > mtd->size) romfs_get_unmapped_area()
56 len = mtd->size - offset; romfs_get_unmapped_area()
58 ret = mtd_get_unmapped_area(mtd, len, offset, flags); romfs_get_unmapped_area()
75 struct mtd_info *mtd = file_inode(file)->i_sb->s_mtd; romfs_mmap_capabilities() local
77 if (!mtd) romfs_mmap_capabilities()
79 return mtd_mmap_capabilities(mtd); romfs_mmap_capabilities()
/linux-4.1.27/arch/arm/mach-omap1/
H A Dflash.c10 #include <linux/mtd/mtd.h>
11 #include <linux/mtd/map.h>
H A Dboard-nand.c18 #include <linux/mtd/mtd.h>
19 #include <linux/mtd/nand.h>
23 void omap1_nand_cmd_ctl(struct mtd_info *mtd, int cmd, unsigned int ctrl) omap1_nand_cmd_ctl() argument
25 struct nand_chip *this = mtd->priv; omap1_nand_cmd_ctl()
H A Dboard-perseus2.c18 #include <linux/mtd/mtd.h>
19 #include <linux/mtd/nand.h>
20 #include <linux/mtd/partitions.h>
21 #include <linux/mtd/physmap.h>
147 static int nand_dev_ready(struct mtd_info *mtd) nand_dev_ready() argument
/linux-4.1.27/arch/mips/cobalt/
H A DMakefile5 obj-y := buttons.o irq.o lcd.o led.o mtd.o reset.o rtc.o serial.o setup.o time.o
/linux-4.1.27/fs/logfs/
H A Ddev_mtd.c19 struct mtd_info *mtd = logfs_super(sb)->s_mtd; logfs_mtd_read() local
23 ret = mtd_read(mtd, ofs, len, &retlen, buf); logfs_mtd_read()
39 struct mtd_info *mtd = super->s_mtd; loffs_mtd_write() local
47 BUG_ON((ofs >= mtd->size) || (len > mtd->size - ofs)); loffs_mtd_write()
52 ret = mtd_write(mtd, ofs, len, &retlen, buf); loffs_mtd_write()
60 * For as long as I can remember (since about 2001) mtd->erase has been an
93 struct mtd_info *mtd = logfs_super(sb)->s_mtd; logfs_mtd_erase() local
98 BUG_ON(len % mtd->erasesize); logfs_mtd_erase()
103 ei.mtd = mtd; logfs_mtd_erase()
108 ret = mtd_erase(mtd, &ei); logfs_mtd_erase()
120 struct mtd_info *mtd = logfs_super(sb)->s_mtd; logfs_mtd_sync() local
122 mtd_sync(mtd); logfs_mtd_sync()
153 struct mtd_info *mtd = super->s_mtd; logfs_mtd_find_first_sb() local
156 while (mtd_block_isbad(mtd, *ofs)) { logfs_mtd_find_first_sb()
157 *ofs += mtd->erasesize; logfs_mtd_find_first_sb()
158 if (*ofs >= mtd->size) logfs_mtd_find_first_sb()
170 struct mtd_info *mtd = super->s_mtd; logfs_mtd_find_last_sb() local
172 *ofs = mtd->size - mtd->erasesize; logfs_mtd_find_last_sb()
173 while (mtd_block_isbad(mtd, *ofs)) { logfs_mtd_find_last_sb()
174 *ofs -= mtd->erasesize; logfs_mtd_find_last_sb()
178 *ofs = *ofs + mtd->erasesize - 0x1000; logfs_mtd_find_last_sb()
266 struct mtd_info *mtd = get_mtd_device(NULL, mtdnr); logfs_get_sb_mtd() local
267 if (IS_ERR(mtd)) logfs_get_sb_mtd()
268 return PTR_ERR(mtd); logfs_get_sb_mtd()
271 s->s_mtd = mtd; logfs_get_sb_mtd()
/linux-4.1.27/include/linux/platform_data/
H A Dmtd-onenand-omap2.h13 #include <linux/mtd/mtd.h>
14 #include <linux/mtd/partitions.h>
H A Dmtd-orion_nand.h15 int (*dev_ready)(struct mtd_info *mtd);
/linux-4.1.27/arch/mips/include/asm/mach-au1x00/
H A Dau1550nd.h8 #include <linux/mtd/partitions.h>
/linux-4.1.27/fs/jffs2/
H A Dwritev.c13 #include <linux/mtd/mtd.h>
29 return mtd_writev(c->mtd, vecs, count, to, retlen); jffs2_flash_direct_writev()
36 ret = mtd_write(c->mtd, ofs, len, retlen, buf); jffs2_flash_direct_write()
H A Dxattr_trusted.c16 #include <linux/mtd/mtd.h>
H A Dxattr_user.c16 #include <linux/mtd/mtd.h>
H A Dos-linux.h79 #define jffs2_flash_read(c, ofs, len, retlen, buf) (mtd_read((c)->mtd, ofs, len, retlen, buf))
107 #define jffs2_can_mark_obsolete(c) (c->mtd->flags & (MTD_BIT_WRITEABLE))
110 #define jffs2_cleanmarker_oob(c) (c->mtd->type == MTD_NANDFLASH)
129 #define jffs2_dataflash(c) (c->mtd->type == MTD_DATAFLASH)
132 #define jffs2_ubivol(c) (c->mtd->type == MTD_UBIVOLUME)
136 #define jffs2_nor_wbuf_flash(c) (c->mtd->type == MTD_NORFLASH && ! (c->mtd->flags & MTD_BIT_WRITEABLE))
/linux-4.1.27/arch/arm/include/asm/
H A Dmtd-xip.h4 * Do not include this file directly. It's included from linux/mtd/xip.h
18 #include <mach/mtd-xip.h>
/linux-4.1.27/drivers/mtd/spi-nor/
H A Dspi-nor.c20 #include <linux/mtd/cfi.h>
21 #include <linux/mtd/mtd.h>
24 #include <linux/mtd/spi-nor.h>
166 static inline struct spi_nor *mtd_to_spi_nor(struct mtd_info *mtd) mtd_to_spi_nor() argument
168 return mtd->priv; mtd_to_spi_nor()
266 dev_dbg(nor->dev, " %lldKiB\n", (long long)(nor->mtd->size >> 10)); erase_chip()
299 static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr) spi_nor_erase() argument
301 struct spi_nor *nor = mtd_to_spi_nor(mtd); spi_nor_erase()
309 div_u64_rem(instr->len, mtd->erasesize, &rem); spi_nor_erase()
321 if (len == mtd->size) { spi_nor_erase()
348 addr += mtd->erasesize; spi_nor_erase()
349 len -= mtd->erasesize; spi_nor_erase()
374 struct mtd_info *mtd = nor->mtd; stm_lock() local
381 if (offset < mtd->size - (mtd->size / 2)) stm_lock()
383 else if (offset < mtd->size - (mtd->size / 4)) stm_lock()
385 else if (offset < mtd->size - (mtd->size / 8)) stm_lock()
387 else if (offset < mtd->size - (mtd->size / 16)) stm_lock()
389 else if (offset < mtd->size - (mtd->size / 32)) stm_lock()
391 else if (offset < mtd->size - (mtd->size / 64)) stm_lock()
408 struct mtd_info *mtd = nor->mtd; stm_unlock() local
415 if (offset+len > mtd->size - (mtd->size / 64)) stm_unlock()
417 else if (offset+len > mtd->size - (mtd->size / 32)) stm_unlock()
419 else if (offset+len > mtd->size - (mtd->size / 16)) stm_unlock()
421 else if (offset+len > mtd->size - (mtd->size / 8)) stm_unlock()
423 else if (offset+len > mtd->size - (mtd->size / 4)) stm_unlock()
425 else if (offset+len > mtd->size - (mtd->size / 2)) stm_unlock()
440 static int spi_nor_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) spi_nor_lock() argument
442 struct spi_nor *nor = mtd_to_spi_nor(mtd); spi_nor_lock()
455 static int spi_nor_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) spi_nor_unlock() argument
457 struct spi_nor *nor = mtd_to_spi_nor(mtd); spi_nor_unlock()
717 static int spi_nor_read(struct mtd_info *mtd, loff_t from, size_t len, spi_nor_read() argument
720 struct spi_nor *nor = mtd_to_spi_nor(mtd); spi_nor_read()
735 static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, sst_write() argument
738 struct spi_nor *nor = mtd_to_spi_nor(mtd); sst_write()
806 static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len, spi_nor_write() argument
809 struct spi_nor *nor = mtd_to_spi_nor(mtd); spi_nor_write()
997 struct mtd_info *mtd = nor->mtd; spi_nor_scan() local
1030 * mtd apply them anyway, since some partitions may be spi_nor_scan()
1055 if (!mtd->name) spi_nor_scan()
1056 mtd->name = dev_name(dev); spi_nor_scan()
1057 mtd->type = MTD_NORFLASH; spi_nor_scan()
1058 mtd->writesize = 1; spi_nor_scan()
1059 mtd->flags = MTD_CAP_NORFLASH; spi_nor_scan()
1060 mtd->size = info->sector_size * info->n_sectors; spi_nor_scan()
1061 mtd->_erase = spi_nor_erase; spi_nor_scan()
1062 mtd->_read = spi_nor_read; spi_nor_scan()
1071 mtd->_lock = spi_nor_lock; spi_nor_scan()
1072 mtd->_unlock = spi_nor_unlock; spi_nor_scan()
1077 mtd->_write = sst_write; spi_nor_scan()
1079 mtd->_write = spi_nor_write; spi_nor_scan()
1088 mtd->erasesize = 4096; spi_nor_scan()
1091 mtd->erasesize = 4096; spi_nor_scan()
1096 mtd->erasesize = info->sector_size; spi_nor_scan()
1100 mtd->flags |= MTD_NO_ERASE; spi_nor_scan()
1102 mtd->dev.parent = dev; spi_nor_scan()
1104 mtd->writebufsize = nor->page_size; spi_nor_scan()
1156 else if (mtd->size > 0x1000000) { spi_nor_scan()
1178 mtd->erasesize = info->sector_size; spi_nor_scan()
1188 (long long)mtd->size >> 10); spi_nor_scan()
1191 "mtd .name = %s, .size = 0x%llx (%lldMiB), " spi_nor_scan()
1193 mtd->name, (long long)mtd->size, (long long)(mtd->size >> 20), spi_nor_scan()
1194 mtd->erasesize, mtd->erasesize / 1024, mtd->numeraseregions); spi_nor_scan()
1196 if (mtd->numeraseregions) spi_nor_scan()
1197 for (i = 0; i < mtd->numeraseregions; i++) spi_nor_scan()
1199 "mtd.eraseregions[%d] = { .offset = 0x%llx, " spi_nor_scan()
1202 i, (long long)mtd->eraseregions[i].offset, spi_nor_scan()
1203 mtd->eraseregions[i].erasesize, spi_nor_scan()
1204 mtd->eraseregions[i].erasesize / 1024, spi_nor_scan()
1205 mtd->eraseregions[i].numblocks); spi_nor_scan()
/linux-4.1.27/drivers/mtd/lpddr/
H A Dlpddr_cmds.c27 #include <linux/mtd/pfow.h>
28 #include <linux/mtd/qinfo.h>
32 static int lpddr_read(struct mtd_info *mtd, loff_t adr, size_t len,
34 static int lpddr_write_buffers(struct mtd_info *mtd, loff_t to,
36 static int lpddr_writev(struct mtd_info *mtd, const struct kvec *vecs,
38 static int lpddr_erase(struct mtd_info *mtd, struct erase_info *instr);
39 static int lpddr_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
40 static int lpddr_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
41 static int lpddr_point(struct mtd_info *mtd, loff_t adr, size_t len,
43 static int lpddr_unpoint(struct mtd_info *mtd, loff_t adr, size_t len);
53 struct mtd_info *mtd; lpddr_cmdset() local
57 mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); lpddr_cmdset()
58 if (!mtd) lpddr_cmdset()
60 mtd->priv = map; lpddr_cmdset()
61 mtd->type = MTD_NORFLASH; lpddr_cmdset()
63 /* Fill in the default mtd operations */ lpddr_cmdset()
64 mtd->_read = lpddr_read; lpddr_cmdset()
65 mtd->type = MTD_NORFLASH; lpddr_cmdset()
66 mtd->flags = MTD_CAP_NORFLASH; lpddr_cmdset()
67 mtd->flags &= ~MTD_BIT_WRITEABLE; lpddr_cmdset()
68 mtd->_erase = lpddr_erase; lpddr_cmdset()
69 mtd->_write = lpddr_write_buffers; lpddr_cmdset()
70 mtd->_writev = lpddr_writev; lpddr_cmdset()
71 mtd->_lock = lpddr_lock; lpddr_cmdset()
72 mtd->_unlock = lpddr_unlock; lpddr_cmdset()
74 mtd->_point = lpddr_point; lpddr_cmdset()
75 mtd->_unpoint = lpddr_unpoint; lpddr_cmdset()
77 mtd->size = 1 << lpddr->qinfo->DevSizeShift; lpddr_cmdset()
78 mtd->erasesize = 1 << lpddr->qinfo->UniformBlockSizeShift; lpddr_cmdset()
79 mtd->writesize = 1 << lpddr->qinfo->BufSizeShift; lpddr_cmdset()
85 kfree(mtd); lpddr_cmdset()
107 return mtd; lpddr_cmdset()
470 static int do_erase_oneblock(struct mtd_info *mtd, loff_t adr) do_erase_oneblock() argument
472 struct map_info *map = mtd->priv; do_erase_oneblock()
497 static int lpddr_read(struct mtd_info *mtd, loff_t adr, size_t len, lpddr_read() argument
500 struct map_info *map = mtd->priv; lpddr_read()
521 static int lpddr_point(struct mtd_info *mtd, loff_t adr, size_t len, lpddr_point() argument
524 struct map_info *map = mtd->priv; lpddr_point()
574 static int lpddr_unpoint (struct mtd_info *mtd, loff_t adr, size_t len) lpddr_unpoint() argument
576 struct map_info *map = mtd->priv; lpddr_unpoint()
619 static int lpddr_write_buffers(struct mtd_info *mtd, loff_t to, size_t len, lpddr_write_buffers() argument
627 return lpddr_writev(mtd, &vec, 1, to, retlen); lpddr_write_buffers()
631 static int lpddr_writev(struct mtd_info *mtd, const struct kvec *vecs, lpddr_writev() argument
634 struct map_info *map = mtd->priv; lpddr_writev()
678 static int lpddr_erase(struct mtd_info *mtd, struct erase_info *instr) lpddr_erase() argument
682 struct map_info *map = mtd->priv; lpddr_erase()
690 ret = do_erase_oneblock(mtd, ofs); lpddr_erase()
704 static int do_xxlock(struct mtd_info *mtd, loff_t adr, uint32_t len, int thunk) do_xxlock() argument
707 struct map_info *map = mtd->priv; do_xxlock()
739 static int lpddr_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) lpddr_lock() argument
741 return do_xxlock(mtd, ofs, len, DO_XXLOCK_LOCK); lpddr_lock()
744 static int lpddr_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) lpddr_unlock() argument
746 return do_xxlock(mtd, ofs, len, DO_XXLOCK_UNLOCK); lpddr_unlock()
H A Dlpddr2_nvm.c28 #include <linux/mtd/map.h>
29 #include <linux/mtd/mtd.h>
30 #include <linux/mtd/partitions.h>
242 static int lpddr2_nvm_do_block_op(struct mtd_info *mtd, loff_t start_add, lpddr2_nvm_do_block_op() argument
245 struct map_info *map = mtd->priv; lpddr2_nvm_do_block_op()
260 add += mtd->erasesize; lpddr2_nvm_do_block_op()
307 static int lpddr2_nvm_read(struct mtd_info *mtd, loff_t start_add, lpddr2_nvm_read() argument
310 struct map_info *map = mtd->priv; lpddr2_nvm_read()
325 static int lpddr2_nvm_write(struct mtd_info *mtd, loff_t start_add, lpddr2_nvm_write() argument
328 struct map_info *map = mtd->priv; lpddr2_nvm_write()
344 if (!(IS_ALIGNED(add, mtd->writesize))) { /* do sw program */ lpddr2_nvm_write()
360 (u_long) mtd->writesize); lpddr2_nvm_write()
381 static int lpddr2_nvm_erase(struct mtd_info *mtd, struct erase_info *instr) lpddr2_nvm_erase() argument
383 int ret = lpddr2_nvm_do_block_op(mtd, instr->addr, instr->len, lpddr2_nvm_erase()
396 static int lpddr2_nvm_unlock(struct mtd_info *mtd, loff_t start_add, lpddr2_nvm_unlock() argument
399 return lpddr2_nvm_do_block_op(mtd, start_add, len, LPDDR2_NVM_UNLOCK); lpddr2_nvm_unlock()
405 static int lpddr2_nvm_lock(struct mtd_info *mtd, loff_t start_add, lpddr2_nvm_lock() argument
408 return lpddr2_nvm_do_block_op(mtd, start_add, len, LPDDR2_NVM_LOCK); lpddr2_nvm_lock()
417 struct mtd_info *mtd; lpddr2_nvm_probe() local
434 mtd = devm_kzalloc(&pdev->dev, sizeof(*mtd), GFP_KERNEL); lpddr2_nvm_probe()
435 if (!mtd) lpddr2_nvm_probe()
462 *mtd = (struct mtd_info) { lpddr2_nvm_probe()
484 return mtd_device_parse_register(mtd, NULL, NULL, NULL, 0); lpddr2_nvm_probe()
H A Dqinfo_probe.c29 #include <linux/mtd/xip.h>
30 #include <linux/mtd/map.h>
31 #include <linux/mtd/pfow.h>
32 #include <linux/mtd/qinfo.h>
200 struct mtd_info *mtd = NULL; lpddr_probe() local
209 mtd = lpddr_cmdset(map); lpddr_probe()
210 if (mtd) { lpddr_probe()
211 if (mtd->size > map->size) { lpddr_probe()
213 "to %ldKiB\n", (unsigned long)mtd->size >> 10, lpddr_probe()
215 mtd->size = map->size; lpddr_probe()
217 return mtd; lpddr_probe()
/linux-4.1.27/drivers/mtd/nand/gpmi-nand/
H A Dgpmi-nand.c25 #include <linux/mtd/partitions.h>
110 struct mtd_info *mtd = &this->mtd; get_ecc_strength() local
113 ecc_strength = ((mtd->oobsize - geo->metadata_size) * 8) get_ecc_strength()
142 struct mtd_info *mtd = &this->mtd; set_geometry_by_ecc_info() local
143 struct nand_chip *chip = mtd->priv; set_geometry_by_ecc_info()
169 if (geo->ecc_chunk_size < mtd->oobsize) { set_geometry_by_ecc_info()
172 chip->ecc_step_ds, mtd->oobsize); set_geometry_by_ecc_info()
179 geo->ecc_chunk_count = mtd->writesize / geo->ecc_chunk_size; set_geometry_by_ecc_info()
229 geo->page_size = mtd->writesize + geo->metadata_size + set_geometry_by_ecc_info()
233 if (geo->page_size < mtd->writesize + mtd->oobsize) { set_geometry_by_ecc_info()
234 of->offset = geo->page_size - mtd->writesize; set_geometry_by_ecc_info()
235 of->length = mtd->oobsize - of->offset; set_geometry_by_ecc_info()
238 geo->payload_size = mtd->writesize; set_geometry_by_ecc_info()
248 block_mark_bit_offset = mtd->writesize * 8 - set_geometry_by_ecc_info()
260 struct mtd_info *mtd = &this->mtd; legacy_set_geometry() local
277 while (geo->ecc_chunk_size < mtd->oobsize) { legacy_set_geometry()
282 geo->ecc_chunk_count = mtd->writesize / geo->ecc_chunk_size; legacy_set_geometry()
294 geo->page_size = mtd->writesize + mtd->oobsize; legacy_set_geometry()
295 geo->payload_size = mtd->writesize; legacy_set_geometry()
358 block_mark_bit_offset = mtd->writesize * 8 - legacy_set_geometry()
807 struct mtd_info *mtd = &this->mtd; gpmi_alloc_dma_buffer() local
822 this->data_buffer_dma = kzalloc(mtd->writesize ?: PAGE_SIZE, gpmi_alloc_dma_buffer()
841 this->raw_buffer = kzalloc(mtd->writesize + mtd->oobsize, GFP_KERNEL); gpmi_alloc_dma_buffer()
857 static void gpmi_cmd_ctrl(struct mtd_info *mtd, int data, unsigned int ctrl) gpmi_cmd_ctrl() argument
859 struct nand_chip *chip = mtd->priv; gpmi_cmd_ctrl()
891 static int gpmi_dev_ready(struct mtd_info *mtd) gpmi_dev_ready() argument
893 struct nand_chip *chip = mtd->priv; gpmi_dev_ready()
899 static void gpmi_select_chip(struct mtd_info *mtd, int chipnr) gpmi_select_chip() argument
901 struct nand_chip *chip = mtd->priv; gpmi_select_chip()
912 static void gpmi_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) gpmi_read_buf() argument
914 struct nand_chip *chip = mtd->priv; gpmi_read_buf()
924 static void gpmi_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) gpmi_write_buf() argument
926 struct nand_chip *chip = mtd->priv; gpmi_write_buf()
936 static uint8_t gpmi_read_byte(struct mtd_info *mtd) gpmi_read_byte() argument
938 struct nand_chip *chip = mtd->priv; gpmi_read_byte()
942 gpmi_read_buf(mtd, buf, 1); gpmi_read_byte()
994 static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip, gpmi_ecc_read_page() argument
1043 mtd->ecc_stats.failed++; gpmi_ecc_read_page()
1046 mtd->ecc_stats.corrected += *status; gpmi_ecc_read_page()
1061 memset(chip->oob_poi, ~0, mtd->oobsize); gpmi_ecc_read_page()
1074 static int gpmi_ecc_read_subpage(struct mtd_info *mtd, struct nand_chip *chip, gpmi_ecc_read_subpage() argument
1110 return gpmi_ecc_read_page(mtd, chip, buf, 0, page); gpmi_ecc_read_subpage()
1117 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, col, -1); gpmi_ecc_read_subpage()
1151 max_bitflips = gpmi_ecc_read_page(mtd, chip, buf, 0, page); gpmi_ecc_read_subpage()
1162 static int gpmi_ecc_write_page(struct mtd_info *mtd, struct nand_chip *chip, gpmi_ecc_write_page() argument
1180 memcpy(this->payload_virt, buf, mtd->writesize); gpmi_ecc_write_page()
1198 buf, mtd->writesize, gpmi_ecc_write_page()
1208 chip->oob_poi, mtd->oobsize, gpmi_ecc_write_page()
1224 send_page_end(this, chip->oob_poi, mtd->oobsize, gpmi_ecc_write_page()
1229 send_page_end(this, buf, mtd->writesize, gpmi_ecc_write_page()
1298 static int gpmi_ecc_read_oob(struct mtd_info *mtd, struct nand_chip *chip, gpmi_ecc_read_oob() argument
1305 memset(chip->oob_poi, ~0, mtd->oobsize); gpmi_ecc_read_oob()
1308 chip->cmdfunc(mtd, NAND_CMD_READ0, mtd->writesize, page); gpmi_ecc_read_oob()
1309 chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); gpmi_ecc_read_oob()
1318 chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page); gpmi_ecc_read_oob()
1319 chip->oob_poi[0] = chip->read_byte(mtd); gpmi_ecc_read_oob()
1326 gpmi_ecc_write_oob(struct mtd_info *mtd, struct nand_chip *chip, int page) gpmi_ecc_write_oob() argument
1328 struct nand_oobfree *of = mtd->ecclayout->oobfree; gpmi_ecc_write_oob()
1338 chip->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->writesize + of->offset, page); gpmi_ecc_write_oob()
1339 chip->write_buf(mtd, chip->oob_poi + of->offset, of->length); gpmi_ecc_write_oob()
1340 chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1); gpmi_ecc_write_oob()
1342 status = chip->waitfunc(mtd, chip); gpmi_ecc_write_oob()
1358 static int gpmi_ecc_read_page_raw(struct mtd_info *mtd, gpmi_ecc_read_page_raw() argument
1373 chip->read_buf(mtd, tmp_buf, gpmi_ecc_read_page_raw()
1374 mtd->writesize + mtd->oobsize); gpmi_ecc_read_page_raw()
1386 tmp_buf[0] = tmp_buf[mtd->writesize]; gpmi_ecc_read_page_raw()
1387 tmp_buf[mtd->writesize] = swap; gpmi_ecc_read_page_raw()
1425 if (oob_byte_off < mtd->oobsize) gpmi_ecc_read_page_raw()
1427 tmp_buf + mtd->writesize + oob_byte_off, gpmi_ecc_read_page_raw()
1428 mtd->oobsize - oob_byte_off); gpmi_ecc_read_page_raw()
1446 static int gpmi_ecc_write_page_raw(struct mtd_info *mtd, gpmi_ecc_write_page_raw() argument
1468 memset(tmp_buf, 0xff, mtd->writesize + mtd->oobsize); gpmi_ecc_write_page_raw()
1500 if (oob_required && oob_byte_off < mtd->oobsize) gpmi_ecc_write_page_raw()
1501 memcpy(tmp_buf + mtd->writesize + oob_byte_off, gpmi_ecc_write_page_raw()
1502 oob + oob_byte_off, mtd->oobsize - oob_byte_off); gpmi_ecc_write_page_raw()
1514 tmp_buf[0] = tmp_buf[mtd->writesize]; gpmi_ecc_write_page_raw()
1515 tmp_buf[mtd->writesize] = swap; gpmi_ecc_write_page_raw()
1518 chip->write_buf(mtd, tmp_buf, mtd->writesize + mtd->oobsize); gpmi_ecc_write_page_raw()
1523 static int gpmi_ecc_read_oob_raw(struct mtd_info *mtd, struct nand_chip *chip, gpmi_ecc_read_oob_raw() argument
1526 chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page); gpmi_ecc_read_oob_raw()
1528 return gpmi_ecc_read_page_raw(mtd, chip, NULL, 1, page); gpmi_ecc_read_oob_raw()
1531 static int gpmi_ecc_write_oob_raw(struct mtd_info *mtd, struct nand_chip *chip, gpmi_ecc_write_oob_raw() argument
1534 chip->cmdfunc(mtd, NAND_CMD_SEQIN, 0, page); gpmi_ecc_write_oob_raw()
1536 return gpmi_ecc_write_page_raw(mtd, chip, NULL, 1); gpmi_ecc_write_oob_raw()
1539 static int gpmi_block_markbad(struct mtd_info *mtd, loff_t ofs) gpmi_block_markbad() argument
1541 struct nand_chip *chip = mtd->priv; gpmi_block_markbad()
1548 chip->select_chip(mtd, chipnr); gpmi_block_markbad()
1550 column = !GPMI_IS_MX23(this) ? mtd->writesize : 0; gpmi_block_markbad()
1559 chip->cmdfunc(mtd, NAND_CMD_SEQIN, column, page); gpmi_block_markbad()
1560 chip->write_buf(mtd, block_mark, 1); gpmi_block_markbad()
1561 chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1); gpmi_block_markbad()
1563 status = chip->waitfunc(mtd, chip); gpmi_block_markbad()
1567 chip->select_chip(mtd, -1); gpmi_block_markbad()
1603 struct mtd_info *mtd = &this->mtd; mx23_check_transcription_stamp() local
1616 chip->select_chip(mtd, 0); mx23_check_transcription_stamp()
1633 chip->cmdfunc(mtd, NAND_CMD_READ0, 12, page); mx23_check_transcription_stamp()
1634 chip->read_buf(mtd, buffer, strlen(fingerprint)); mx23_check_transcription_stamp()
1644 chip->select_chip(mtd, saved_chip_number); mx23_check_transcription_stamp()
1658 struct mtd_info *mtd = &this->mtd; mx23_write_transcription_stamp() local
1672 block_size_in_pages = mtd->erasesize / mtd->writesize; mx23_write_transcription_stamp()
1687 chip->select_chip(mtd, 0); mx23_write_transcription_stamp()
1698 chip->cmdfunc(mtd, NAND_CMD_ERASE1, -1, page); mx23_write_transcription_stamp()
1699 chip->cmdfunc(mtd, NAND_CMD_ERASE2, -1, -1); mx23_write_transcription_stamp()
1702 status = chip->waitfunc(mtd, chip); mx23_write_transcription_stamp()
1708 memset(buffer, ~0, mtd->writesize); mx23_write_transcription_stamp()
1719 chip->cmdfunc(mtd, NAND_CMD_SEQIN, 0x00, page); mx23_write_transcription_stamp()
1720 chip->ecc.write_page_raw(mtd, chip, buffer, 0); mx23_write_transcription_stamp()
1721 chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1); mx23_write_transcription_stamp()
1724 status = chip->waitfunc(mtd, chip); mx23_write_transcription_stamp()
1730 chip->select_chip(mtd, saved_chip_number); mx23_write_transcription_stamp()
1738 struct mtd_info *mtd = &this->mtd; mx23_boot_init() local
1779 chip->select_chip(mtd, chipnr); mx23_boot_init()
1780 chip->cmdfunc(mtd, NAND_CMD_READ0, mtd->writesize, page); mx23_boot_init()
1781 block_mark = chip->read_byte(mtd); mx23_boot_init()
1782 chip->select_chip(mtd, -1); mx23_boot_init()
1791 ret = chip->block_markbad(mtd, byte); mx23_boot_init()
1834 nand_release(&this->mtd); gpmi_nand_exit()
1840 struct mtd_info *mtd = &this->mtd; gpmi_init_last() local
1841 struct nand_chip *chip = mtd->priv; gpmi_init_last()
1889 struct mtd_info *mtd = &this->mtd; gpmi_nand_init() local
1898 mtd->priv = chip; gpmi_nand_init()
1899 mtd->name = "gpmi-nand"; gpmi_nand_init()
1900 mtd->owner = THIS_MODULE; gpmi_nand_init()
1937 ret = nand_scan_ident(mtd, GPMI_IS_MX6(this) ? 2 : 1, NULL); gpmi_nand_init()
1946 ret = nand_scan_tail(mtd); gpmi_nand_init()
1953 ret = chip->scan_bbt(mtd); gpmi_nand_init()
1958 ret = mtd_device_parse_register(mtd, NULL, &ppdata, NULL, 0); gpmi_nand_init()
/linux-4.1.27/arch/sh/boards/mach-rsk/
H A Dsetup.c15 #include <linux/mtd/mtd.h>
16 #include <linux/mtd/partitions.h>
17 #include <linux/mtd/physmap.h>
18 #include <linux/mtd/map.h>
/linux-4.1.27/arch/arm/mach-s3c24xx/
H A Dsimtec-nor.c20 #include <linux/mtd/mtd.h>
21 #include <linux/mtd/map.h>
22 #include <linux/mtd/physmap.h>
23 #include <linux/mtd/partitions.h>
H A Dcommon-smdk.c25 #include <linux/mtd/mtd.h>
26 #include <linux/mtd/nand.h>
27 #include <linux/mtd/nand_ecc.h>
28 #include <linux/mtd/partitions.h>
42 #include <linux/platform_data/mtd-nand-s3c2410.h>
H A Dmach-at2440evb.c40 #include <linux/platform_data/mtd-nand-s3c2410.h>
43 #include <linux/mtd/mtd.h>
44 #include <linux/mtd/nand.h>
45 #include <linux/mtd/nand_ecc.h>
46 #include <linux/mtd/partitions.h>
H A Dmach-rx3715.c29 #include <linux/mtd/mtd.h>
30 #include <linux/mtd/nand.h>
31 #include <linux/mtd/nand_ecc.h>
32 #include <linux/mtd/partitions.h>
38 #include <linux/platform_data/mtd-nand-s3c2410.h>
H A Dmach-vstms.c22 #include <linux/mtd/mtd.h>
23 #include <linux/mtd/nand.h>
24 #include <linux/mtd/nand_ecc.h>
25 #include <linux/mtd/partitions.h>
43 #include <linux/platform_data/mtd-nand-s3c2410.h>
H A Dmach-tct_hammer.c52 #include <linux/mtd/mtd.h>
53 #include <linux/mtd/partitions.h>
54 #include <linux/mtd/map.h>
55 #include <linux/mtd/physmap.h>
/linux-4.1.27/arch/arm/mach-ks8695/
H A Dboard-sg.c13 #include <linux/mtd/mtd.h>
14 #include <linux/mtd/map.h>
15 #include <linux/mtd/physmap.h>
16 #include <linux/mtd/partitions.h>
H A Dboard-dsm320.c20 #include <linux/mtd/mtd.h>
21 #include <linux/mtd/map.h>
22 #include <linux/mtd/physmap.h>
23 #include <linux/mtd/partitions.h>
/linux-4.1.27/arch/avr32/boards/atngw100/
H A Dflash.c12 #include <linux/mtd/mtd.h>
13 #include <linux/mtd/partitions.h>
14 #include <linux/mtd/physmap.h>
/linux-4.1.27/arch/avr32/boards/atstk1000/
H A Dflash.c12 #include <linux/mtd/mtd.h>
13 #include <linux/mtd/partitions.h>
14 #include <linux/mtd/physmap.h>
/linux-4.1.27/arch/avr32/boards/favr-32/
H A Dflash.c12 #include <linux/mtd/mtd.h>
13 #include <linux/mtd/partitions.h>
14 #include <linux/mtd/physmap.h>
/linux-4.1.27/arch/avr32/boards/merisc/
H A Dflash.c12 #include <linux/mtd/mtd.h>
13 #include <linux/mtd/partitions.h>
14 #include <linux/mtd/physmap.h>
/linux-4.1.27/arch/m68k/coldfire/
H A Dfirebee.c15 #include <linux/mtd/mtd.h>
16 #include <linux/mtd/partitions.h>
17 #include <linux/mtd/physmap.h>
/linux-4.1.27/arch/arm/mach-omap1/include/mach/
H A Dflash.h12 #include <linux/mtd/map.h>
/linux-4.1.27/arch/cris/arch-v32/drivers/mach-fs/
H A Dnandflash.c6 * Derived from drivers/mtd/nand/spia.c
18 #include <linux/mtd/mtd.h>
19 #include <linux/mtd/nand.h>
20 #include <linux/mtd/partitions.h>
41 /* Bitmask for mtd nand control bits */
49 static void crisv32_hwcontrol(struct mtd_info *mtd, int cmd, crisv32_hwcontrol() argument
54 struct nand_chip *this = mtd->priv; crisv32_hwcontrol()
91 static int crisv32_device_ready(struct mtd_info *mtd) crisv32_device_ready() argument
/linux-4.1.27/arch/arm/mach-ep93xx/
H A Dsnappercl15.c27 #include <linux/mtd/partitions.h>
28 #include <linux/mtd/nand.h>
49 static void snappercl15_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, snappercl15_nand_cmd_ctrl() argument
52 struct nand_chip *chip = mtd->priv; snappercl15_nand_cmd_ctrl()
77 static int snappercl15_nand_dev_ready(struct mtd_info *mtd) snappercl15_nand_dev_ready() argument
79 struct nand_chip *chip = mtd->priv; snappercl15_nand_dev_ready()
H A Dts72xx.c20 #include <linux/mtd/nand.h>
21 #include <linux/mtd/partitions.h>
74 static void ts72xx_nand_hwcontrol(struct mtd_info *mtd, ts72xx_nand_hwcontrol() argument
77 struct nand_chip *chip = mtd->priv; ts72xx_nand_hwcontrol()
97 static int ts72xx_nand_device_ready(struct mtd_info *mtd) ts72xx_nand_device_ready() argument
99 struct nand_chip *chip = mtd->priv; ts72xx_nand_device_ready()
/linux-4.1.27/arch/mips/bcm47xx/
H A Dnvram.c19 #include <linux/mtd/mtd.h>
114 * On bcm47xx we need access to the NVRAM very early, so we can't use mtd
139 struct mtd_info *mtd; nvram_init() local
144 mtd = get_mtd_device_nm("nvram"); nvram_init()
145 if (IS_ERR(mtd)) nvram_init()
148 err = mtd_read(mtd, 0, sizeof(header), &bytes_read, (uint8_t *)&header); nvram_init()
159 err = mtd_read(mtd, 0, len, &bytes_read, dst); nvram_init()
/linux-4.1.27/arch/mips/include/asm/mach-jz4740/
H A Djz4740_nand.h19 #include <linux/mtd/nand.h>
20 #include <linux/mtd/partitions.h>
/linux-4.1.27/include/uapi/mtd/
H A Dmtd-user.h26 #include <mtd/mtd-abi.h>
/linux-4.1.27/arch/cris/arch-v32/drivers/mach-a3/
H A Dnandflash.c6 * Derived from drivers/mtd/nand/spia.c
18 #include <linux/mtd/mtd.h>
19 #include <linux/mtd/nand.h>
20 #include <linux/mtd/partitions.h>
50 static void crisv32_hwcontrol(struct mtd_info *mtd, int cmd, crisv32_hwcontrol() argument
55 struct nand_chip *this = mtd->priv; crisv32_hwcontrol()
96 static int crisv32_device_ready(struct mtd_info *mtd) crisv32_device_ready() argument
/linux-4.1.27/drivers/staging/mt29f_spinand/
H A Dmt29f_spinand.h24 #include <linux/mtd/mtd.h>
104 extern int spinand_mtd(struct mtd_info *mtd);
105 extern void spinand_mtd_release(struct mtd_info *mtd);
/linux-4.1.27/arch/mips/bcm63xx/
H A Ddev-flash.c16 #include <linux/mtd/mtd.h>
17 #include <linux/mtd/partitions.h>
18 #include <linux/mtd/physmap.h>
/linux-4.1.27/arch/mips/mti-malta/
H A Dmalta-platform.c29 #include <linux/mtd/partitions.h>
30 #include <linux/mtd/physmap.h>
33 #include <mtd/mtd-abi.h>
/linux-4.1.27/arch/avr32/boards/mimc200/
H A Dflash.c12 #include <linux/mtd/mtd.h>
13 #include <linux/mtd/partitions.h>
14 #include <linux/mtd/physmap.h>
/linux-4.1.27/arch/arm/mach-sa1100/
H A Dshannon.c10 #include <linux/mtd/mtd.h>
11 #include <linux/mtd/partitions.h>
/linux-4.1.27/arch/arm/mach-gemini/
H A Dboard-wbd111.c19 #include <linux/mtd/mtd.h>
20 #include <linux/mtd/partitions.h>
H A Dboard-wbd222.c19 #include <linux/mtd/mtd.h>
20 #include <linux/mtd/partitions.h>
/linux-4.1.27/arch/arm/mach-omap2/
H A Dboard-flash.h13 #include <linux/mtd/mtd.h>
14 #include <linux/mtd/partitions.h>
/linux-4.1.27/arch/blackfin/mach-bf561/boards/
H A Dacvilon.c38 #include <linux/mtd/mtd.h>
39 #include <linux/mtd/partitions.h>
40 #include <linux/mtd/physmap.h>
41 #include <linux/mtd/nand.h>
42 #include <linux/mtd/plat-ram.h>
154 .name = "mtd-ram",
267 static void bfin_plat_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, bfin_plat_nand_cmd_ctrl() argument
270 struct nand_chip *this = mtd->priv; bfin_plat_nand_cmd_ctrl()
282 static int bfin_plat_nand_dev_ready(struct mtd_info *mtd) bfin_plat_nand_dev_ready() argument
/linux-4.1.27/arch/mips/netlogic/xlr/
H A Dplatform-flash.c20 #include <linux/mtd/mtd.h>
21 #include <linux/mtd/physmap.h>
22 #include <linux/mtd/nand.h>
23 #include <linux/mtd/partitions.h>
97 static void xlr_nand_ctrl(struct mtd_info *mtd, int cmd, xlr_nand_ctrl() argument
/linux-4.1.27/arch/arm/mach-imx/
H A Dmach-qong.c20 #include <linux/mtd/physmap.h>
21 #include <linux/mtd/nand.h>
132 static void qong_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) qong_nand_cmd_ctrl() argument
134 struct nand_chip *nand_chip = mtd->priv; qong_nand_cmd_ctrl()
148 static int qong_nand_device_ready(struct mtd_info *mtd) qong_nand_device_ready() argument
153 static void qong_nand_select_chip(struct mtd_info *mtd, int chip) qong_nand_select_chip() argument
/linux-4.1.27/arch/arm/mach-ixp4xx/
H A Dixdp425-setup.c19 #include <linux/mtd/mtd.h>
20 #include <linux/mtd/nand.h>
21 #include <linux/mtd/partitions.h>
77 ixdp425_flash_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) ixdp425_flash_nand_cmd_ctrl() argument
79 struct nand_chip *this = mtd->priv; ixdp425_flash_nand_cmd_ctrl()

Completed in 2567 milliseconds

123