• Home
  • Raw
  • Download

Lines Matching refs:mtd

143 static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num,  in read_bbt()  argument
147 struct nand_chip *this = mtd->priv; in read_bbt()
157 res = mtd->read(mtd, from, len, &retlen, buf); in read_bbt()
177 mtd->ecc_stats.bbtblocks++; in read_bbt()
189 mtd->ecc_stats.badblocks++; in read_bbt()
209 static int read_abs_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *td, int chip) in read_abs_bbt() argument
211 struct nand_chip *this = mtd->priv; in read_abs_bbt()
220 …res = read_bbt (mtd, buf, td->pages[i], this->chipsize >> this->bbt_erase_shift, bits, offs, td->r… in read_abs_bbt()
226 …res = read_bbt (mtd, buf, td->pages[0], mtd->size >> this->bbt_erase_shift, bits, 0, td->reserved_… in read_abs_bbt()
236 static int scan_read_raw(struct mtd_info *mtd, uint8_t *buf, loff_t offs, in scan_read_raw() argument
243 ops.ooblen = mtd->oobsize; in scan_read_raw()
248 return mtd->read_oob(mtd, offs, &ops); in scan_read_raw()
254 static int scan_write_bbt(struct mtd_info *mtd, loff_t offs, size_t len, in scan_write_bbt() argument
261 ops.ooblen = mtd->oobsize; in scan_write_bbt()
266 return mtd->write_oob(mtd, offs, &ops); in scan_write_bbt()
280 static int read_abs_bbts(struct mtd_info *mtd, uint8_t *buf, in read_abs_bbts() argument
283 struct nand_chip *this = mtd->priv; in read_abs_bbts()
287 scan_read_raw(mtd, buf, (loff_t)td->pages[0] << this->page_shift, in read_abs_bbts()
288 mtd->writesize); in read_abs_bbts()
289 td->version[0] = buf[mtd->writesize + td->veroffs]; in read_abs_bbts()
296 scan_read_raw(mtd, buf, (loff_t)md->pages[0] << this->page_shift, in read_abs_bbts()
297 mtd->writesize); in read_abs_bbts()
298 md->version[0] = buf[mtd->writesize + md->veroffs]; in read_abs_bbts()
308 static int scan_block_full(struct mtd_info *mtd, struct nand_bbt_descr *bd, in scan_block_full() argument
314 ret = scan_read_raw(mtd, buf, offs, readlen); in scan_block_full()
319 if (check_pattern(buf, scanlen, mtd->writesize, bd)) in scan_block_full()
328 static int scan_block_fast(struct mtd_info *mtd, struct nand_bbt_descr *bd, in scan_block_fast() argument
334 ops.ooblen = mtd->oobsize; in scan_block_fast()
346 ret = mtd->read_oob(mtd, offs, &ops); in scan_block_fast()
353 offs += mtd->writesize; in scan_block_fast()
369 static int create_bbt(struct mtd_info *mtd, uint8_t *buf, in create_bbt() argument
372 struct nand_chip *this = mtd->priv; in create_bbt()
395 scanlen = mtd->writesize + mtd->oobsize; in create_bbt()
396 readlen = len * mtd->writesize; in create_bbt()
402 numblocks = mtd->size >> (this->bbt_erase_shift - 1); in create_bbt()
421 ret = scan_block_full(mtd, bd, from, buf, readlen, in create_bbt()
424 ret = scan_block_fast(mtd, bd, from, buf, len); in create_bbt()
433 mtd->ecc_stats.badblocks++; in create_bbt()
459 static int search_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *td) in search_bbt() argument
461 struct nand_chip *this = mtd->priv; in search_bbt()
464 int scanlen = mtd->writesize + mtd->oobsize; in search_bbt()
470 startblock = (mtd->size >> this->bbt_erase_shift) - 1; in search_bbt()
484 bbtblocks = mtd->size >> this->bbt_erase_shift; in search_bbt()
501 scan_read_raw(mtd, buf, offs, mtd->writesize); in search_bbt()
502 if (!check_pattern(buf, scanlen, mtd->writesize, td)) { in search_bbt()
505 td->version[i] = buf[mtd->writesize + td->veroffs]; in search_bbt()
532 static int search_read_bbts(struct mtd_info *mtd, uint8_t * buf, struct nand_bbt_descr *td, struct … in search_read_bbts() argument
535 search_bbt(mtd, buf, td); in search_read_bbts()
539 search_bbt(mtd, buf, md); in search_read_bbts()
557 static int write_bbt(struct mtd_info *mtd, uint8_t *buf, in write_bbt() argument
561 struct nand_chip *this = mtd->priv; in write_bbt()
572 ops.ooblen = mtd->oobsize; in write_bbt()
590 numblocks = (int)(mtd->size >> this->bbt_erase_shift); in write_bbt()
663 res = mtd->read(mtd, to, len, &retlen, buf); in write_bbt()
676 ops.ooblen = (len >> this->page_shift) * mtd->oobsize; in write_bbt()
678 res = mtd->read_oob(mtd, to + mtd->writesize, &ops); in write_bbt()
687 ooboffs = len + (pageoffs * mtd->oobsize); in write_bbt()
693 len = (len + (mtd->writesize - 1)) & in write_bbt()
694 ~(mtd->writesize - 1); in write_bbt()
697 (len >> this->page_shift)* mtd->oobsize); in write_bbt()
721 einfo.mtd = mtd; in write_bbt()
724 res = nand_erase_nand(mtd, &einfo, 1); in write_bbt()
728 res = scan_write_bbt(mtd, to, len, buf, &buf[len]); in write_bbt()
754 static inline int nand_memory_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd) in nand_memory_bbt() argument
756 struct nand_chip *this = mtd->priv; in nand_memory_bbt()
759 return create_bbt(mtd, this->buffers->databuf, bd, -1); in nand_memory_bbt()
774 static int check_create(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *bd) in check_create() argument
777 struct nand_chip *this = mtd->priv; in check_create()
848 create_bbt(mtd, buf, bd, chipsel); in check_create()
856 read_abs_bbt(mtd, buf, rd, chipsel); in check_create()
859 read_abs_bbt(mtd, buf, rd2, chipsel); in check_create()
863 res = write_bbt(mtd, buf, td, md, chipsel); in check_create()
870 res = write_bbt(mtd, buf, md, td, chipsel); in check_create()
887 static void mark_bbt_region(struct mtd_info *mtd, struct nand_bbt_descr *td) in mark_bbt_region() argument
889 struct nand_chip *this = mtd->priv; in mark_bbt_region()
899 nrblocks = (int)(mtd->size >> this->bbt_erase_shift); in mark_bbt_region()
913 nand_update_bbt(mtd, (loff_t)block << (this->bbt_erase_shift - 1)); in mark_bbt_region()
934 nand_update_bbt(mtd, (loff_t)(block - 2) << (this->bbt_erase_shift - 1)); in mark_bbt_region()
952 int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd) in nand_scan_bbt() argument
954 struct nand_chip *this = mtd->priv; in nand_scan_bbt()
960 len = mtd->size >> (this->bbt_erase_shift + 2); in nand_scan_bbt()
972 if ((res = nand_memory_bbt(mtd, bd))) { in nand_scan_bbt()
982 len += (len >> this->page_shift) * mtd->oobsize; in nand_scan_bbt()
993 res = read_abs_bbts(mtd, buf, td, md); in nand_scan_bbt()
996 res = search_read_bbts(mtd, buf, td, md); in nand_scan_bbt()
1000 res = check_create(mtd, buf, bd); in nand_scan_bbt()
1003 mark_bbt_region(mtd, td); in nand_scan_bbt()
1005 mark_bbt_region(mtd, md); in nand_scan_bbt()
1018 int nand_update_bbt(struct mtd_info *mtd, loff_t offs) in nand_update_bbt() argument
1020 struct nand_chip *this = mtd->priv; in nand_update_bbt()
1032 len += (len >> this->page_shift) * mtd->oobsize; in nand_update_bbt()
1056 res = write_bbt(mtd, buf, td, md, chipsel); in nand_update_bbt()
1062 res = write_bbt(mtd, buf, md, td, chipsel); in nand_update_bbt()
1144 int nand_default_bbt(struct mtd_info *mtd) in nand_default_bbt() argument
1146 struct nand_chip *this = mtd->priv; in nand_default_bbt()
1162 return nand_scan_bbt(mtd, &agand_flashbased); in nand_default_bbt()
1173 this->badblock_pattern = (mtd->writesize > 512) ? &largepage_flashbased : &smallpage_flashbased; in nand_default_bbt()
1179 this->badblock_pattern = (mtd->writesize > 512) ? in nand_default_bbt()
1183 return nand_scan_bbt(mtd, this->badblock_pattern); in nand_default_bbt()
1193 int nand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt) in nand_isbad_bbt() argument
1195 struct nand_chip *this = mtd->priv; in nand_isbad_bbt()