Lines Matching refs:this
157 * @this: NAND chip object
166 static int read_bbt(struct nand_chip *this, uint8_t *buf, int page, int num,
169 struct mtd_info *mtd = nand_to_mtd(this);
180 from = ((loff_t)page) << this->page_shift;
183 len = min(totlen, (size_t)(1 << this->bbt_erase_shift));
219 this->bbt_erase_shift);
220 bbt_mark_entry(this, offs + act,
227 * move this message to pr_debug.
231 this->bbt_erase_shift);
234 bbt_mark_entry(this, offs + act,
237 bbt_mark_entry(this, offs + act,
250 * @this: NAND chip object
259 static int read_abs_bbt(struct nand_chip *this, uint8_t *buf,
262 struct mtd_info *mtd = nand_to_mtd(this);
263 u64 targetsize = nanddev_target_size(&this->base);
268 for (i = 0; i < nanddev_ntargets(&this->base); i++) {
270 res = read_bbt(this, buf, td->pages[i],
271 targetsize >> this->bbt_erase_shift,
275 offs += targetsize >> this->bbt_erase_shift;
278 res = read_bbt(this, buf, td->pages[0],
279 mtd->size >> this->bbt_erase_shift, td, 0);
287 static int scan_read_data(struct nand_chip *this, uint8_t *buf, loff_t offs,
290 struct mtd_info *mtd = nand_to_mtd(this);
303 * @this: NAND chip object
312 static int scan_read_oob(struct nand_chip *this, uint8_t *buf, loff_t offs,
315 struct mtd_info *mtd = nand_to_mtd(this);
343 static int scan_read(struct nand_chip *this, uint8_t *buf, loff_t offs,
347 return scan_read_data(this, buf, offs, td);
349 return scan_read_oob(this, buf, offs, len);
353 static int scan_write_bbt(struct nand_chip *this, loff_t offs, size_t len,
356 struct mtd_info *mtd = nand_to_mtd(this);
369 static u32 bbt_get_ver_offs(struct nand_chip *this, struct nand_bbt_descr *td)
371 struct mtd_info *mtd = nand_to_mtd(this);
381 * @this: NAND chip object
389 static void read_abs_bbts(struct nand_chip *this, uint8_t *buf,
392 struct mtd_info *mtd = nand_to_mtd(this);
396 scan_read(this, buf, (loff_t)td->pages[0] << this->page_shift,
398 td->version[0] = buf[bbt_get_ver_offs(this, td)];
405 scan_read(this, buf, (loff_t)md->pages[0] << this->page_shift,
407 md->version[0] = buf[bbt_get_ver_offs(this, md)];
414 static int scan_block_fast(struct nand_chip *this, struct nand_bbt_descr *bd,
417 struct mtd_info *mtd = nand_to_mtd(this);
428 page_offset = nand_bbm_get_next_page(this, 0);
444 page_offset = nand_bbm_get_next_page(this, page_offset + 1);
452 * @this: NAND chip object
461 static int create_bbt(struct nand_chip *this, uint8_t *buf,
464 u64 targetsize = nanddev_target_size(&this->base);
465 struct mtd_info *mtd = nand_to_mtd(this);
472 numblocks = mtd->size >> this->bbt_erase_shift;
476 if (chip >= nanddev_ntargets(&this->base)) {
478 chip + 1, nanddev_ntargets(&this->base));
481 numblocks = targetsize >> this->bbt_erase_shift;
484 from = (loff_t)startblock << this->bbt_erase_shift;
492 ret = scan_block_fast(this, bd, from, buf);
497 bbt_mark_entry(this, i, BBT_BLOCK_FACTORY_BAD);
503 from += (1 << this->bbt_erase_shift);
510 * @this: NAND chip object
518 * the bad block information of this chip. This is necessary to provide support
523 static int search_bbt(struct nand_chip *this, uint8_t *buf,
526 u64 targetsize = nanddev_target_size(&this->base);
527 struct mtd_info *mtd = nand_to_mtd(this);
532 int blocktopage = this->bbt_erase_shift - this->page_shift;
536 startblock = (mtd->size >> this->bbt_erase_shift) - 1;
545 chips = nanddev_ntargets(&this->base);
546 bbtblocks = targetsize >> this->bbt_erase_shift;
550 bbtblocks = mtd->size >> this->bbt_erase_shift;
561 loff_t offs = (loff_t)actblock << this->bbt_erase_shift;
564 scan_read(this, buf, offs, mtd->writesize, td);
568 offs = bbt_get_ver_offs(this, td);
574 startblock += targetsize >> this->bbt_erase_shift;
589 * @this: NAND chip object
596 static void search_read_bbts(struct nand_chip *this, uint8_t *buf,
601 search_bbt(this, buf, td);
605 search_bbt(this, buf, md);
610 * @this: the NAND device
621 static int get_bbt_block(struct nand_chip *this, struct nand_bbt_descr *td,
624 u64 targetsize = nanddev_target_size(&this->base);
634 (this->bbt_erase_shift - this->page_shift);
636 numblocks = (int)(targetsize >> this->bbt_erase_shift);
638 numblocks *= nanddev_ntargets(&this->base);
656 switch (bbt_get_entry(this, block)) {
662 page = block << (this->bbt_erase_shift - this->page_shift);
674 * @this: the NAND device
684 static void mark_bbt_block_bad(struct nand_chip *this,
691 bbt_mark_entry(this, block, BBT_BLOCK_WORN);
693 to = (loff_t)block << this->bbt_erase_shift;
694 res = nand_markbad_bbm(this, to);
704 * @this: NAND chip object
712 static int write_bbt(struct nand_chip *this, uint8_t *buf,
716 u64 targetsize = nanddev_target_size(&this->base);
717 struct mtd_info *mtd = nand_to_mtd(this);
737 numblocks = (int)(targetsize >> this->bbt_erase_shift);
740 nrchips = nanddev_ntargets(&this->base);
746 numblocks = (int)(mtd->size >> this->bbt_erase_shift);
754 block = get_bbt_block(this, td, md, chip);
765 page = block << (this->bbt_erase_shift - this->page_shift);
786 to = ((loff_t)page) << this->page_shift;
791 to &= ~(((loff_t)1 << this->bbt_erase_shift) - 1);
792 len = 1 << this->bbt_erase_shift;
802 ops.ooblen = (len >> this->page_shift) * mtd->oobsize;
809 pageoffs = page - (int)(to >> this->page_shift);
810 offs = pageoffs << this->page_shift;
837 (len >> this->page_shift)* mtd->oobsize);
851 dat = bbt_get_entry(this, chip * numblocks + i);
858 einfo.len = 1 << this->bbt_erase_shift;
859 res = nand_erase_nand(this, &einfo, 1);
863 mark_bbt_block_bad(this, td, chip, block);
867 res = scan_write_bbt(this, to, len, buf,
873 mark_bbt_block_bad(this, td, chip, block);
892 * @this: NAND chip object
898 static inline int nand_memory_bbt(struct nand_chip *this,
901 u8 *pagebuf = nand_get_data_buf(this);
903 return create_bbt(this, pagebuf, bd, -1);
908 * @this: the NAND device
917 static int check_create(struct nand_chip *this, uint8_t *buf,
921 struct nand_bbt_descr *td = this->bbt_td;
922 struct nand_bbt_descr *md = this->bbt_md;
927 chips = nanddev_ntargets(&this->base);
976 if (!(this->bbt_options & NAND_BBT_CREATE_EMPTY))
977 create_bbt(this, buf, bd, chipsel);
986 res = read_abs_bbt(this, buf, rd, chipsel);
997 res2 = read_abs_bbt(this, buf, rd2, chipsel);
1019 res = write_bbt(this, buf, td, md, chipsel);
1026 res = write_bbt(this, buf, md, td, chipsel);
1036 * @this: the NAND device
1041 static int nand_update_bbt(struct nand_chip *this, loff_t offs)
1043 struct mtd_info *mtd = nand_to_mtd(this);
1047 struct nand_bbt_descr *td = this->bbt_td;
1048 struct nand_bbt_descr *md = this->bbt_md;
1050 if (!this->bbt || !td)
1054 len = (1 << this->bbt_erase_shift);
1055 len += (len >> this->page_shift) * mtd->oobsize;
1062 chip = (int)(offs >> this->chip_shift);
1075 res = write_bbt(this, buf, td, md, chipsel);
1081 res = write_bbt(this, buf, md, td, chipsel);
1091 * @this: the NAND device
1097 static void mark_bbt_region(struct nand_chip *this, struct nand_bbt_descr *td)
1099 u64 targetsize = nanddev_target_size(&this->base);
1100 struct mtd_info *mtd = nand_to_mtd(this);
1106 chips = nanddev_ntargets(&this->base);
1107 nrblocks = (int)(targetsize >> this->bbt_erase_shift);
1110 nrblocks = (int)(mtd->size >> this->bbt_erase_shift);
1118 block = td->pages[i] >> (this->bbt_erase_shift - this->page_shift);
1119 oldval = bbt_get_entry(this, block);
1120 bbt_mark_entry(this, block, BBT_BLOCK_RESERVED);
1123 nand_update_bbt(this, (loff_t)block <<
1124 this->bbt_erase_shift);
1133 oldval = bbt_get_entry(this, block);
1134 bbt_mark_entry(this, block, BBT_BLOCK_RESERVED);
1145 nand_update_bbt(this, (loff_t)(block - 1) <<
1146 this->bbt_erase_shift);
1152 * @this: the NAND device
1158 static void verify_bbt_descr(struct nand_chip *this, struct nand_bbt_descr *bd)
1160 u64 targetsize = nanddev_target_size(&this->base);
1161 struct mtd_info *mtd = nand_to_mtd(this);
1172 BUG_ON((this->bbt_options & NAND_BBT_NO_OOB) &&
1173 !(this->bbt_options & NAND_BBT_USE_FLASH));
1180 BUG_ON(!(this->bbt_options & NAND_BBT_USE_FLASH));
1181 BUG_ON(!(this->bbt_options & NAND_BBT_NO_OOB));
1189 table_size = targetsize >> this->bbt_erase_shift;
1191 table_size = mtd->size >> this->bbt_erase_shift;
1196 BUG_ON(table_size > (1 << this->bbt_erase_shift));
1201 * @this: the NAND device
1211 static int nand_scan_bbt(struct nand_chip *this, struct nand_bbt_descr *bd)
1213 struct mtd_info *mtd = nand_to_mtd(this);
1216 struct nand_bbt_descr *td = this->bbt_td;
1217 struct nand_bbt_descr *md = this->bbt_md;
1219 len = (mtd->size >> (this->bbt_erase_shift + 2)) ? : 1;
1224 this->bbt = kzalloc(len, GFP_KERNEL);
1225 if (!this->bbt)
1233 if ((res = nand_memory_bbt(this, bd))) {
1239 verify_bbt_descr(this, td);
1240 verify_bbt_descr(this, md);
1243 len = (1 << this->bbt_erase_shift);
1244 len += (len >> this->page_shift) * mtd->oobsize;
1253 read_abs_bbts(this, buf, td, md);
1256 search_read_bbts(this, buf, td, md);
1259 res = check_create(this, buf, bd);
1264 mark_bbt_region(this, td);
1266 mark_bbt_region(this, md);
1274 kfree(this->bbt);
1275 this->bbt = NULL;
1332 * @this: NAND chip to create descriptor for
1335 * based on the properties of @this. The new descriptor is stored in
1336 * this->badblock_pattern. Thus, this->badblock_pattern should be NULL when
1337 * passed to this function.
1339 static int nand_create_badblock_pattern(struct nand_chip *this)
1342 if (this->badblock_pattern) {
1349 bd->options = this->bbt_options & BADBLOCK_SCAN_MASK;
1350 bd->offs = this->badblockpos;
1351 bd->len = (this->options & NAND_BUSWIDTH_16) ? 2 : 1;
1354 this->badblock_pattern = bd;
1360 * @this: NAND chip object
1365 int nand_create_bbt(struct nand_chip *this)
1370 if (this->bbt_options & NAND_BBT_USE_FLASH) {
1372 if (!this->bbt_td) {
1373 if (this->bbt_options & NAND_BBT_NO_OOB) {
1374 this->bbt_td = &bbt_main_no_oob_descr;
1375 this->bbt_md = &bbt_mirror_no_oob_descr;
1377 this->bbt_td = &bbt_main_descr;
1378 this->bbt_md = &bbt_mirror_descr;
1382 this->bbt_td = NULL;
1383 this->bbt_md = NULL;
1386 if (!this->badblock_pattern) {
1387 ret = nand_create_badblock_pattern(this);
1392 return nand_scan_bbt(this, this->badblock_pattern);
1398 * @this: NAND chip object
1401 int nand_isreserved_bbt(struct nand_chip *this, loff_t offs)
1405 block = (int)(offs >> this->bbt_erase_shift);
1406 return bbt_get_entry(this, block) == BBT_BLOCK_RESERVED;
1411 * @this: NAND chip object
1415 int nand_isbad_bbt(struct nand_chip *this, loff_t offs, int allowbbt)
1419 block = (int)(offs >> this->bbt_erase_shift);
1420 res = bbt_get_entry(this, block);
1438 * @this: NAND chip object
1441 int nand_markbad_bbt(struct nand_chip *this, loff_t offs)
1445 block = (int)(offs >> this->bbt_erase_shift);
1448 bbt_mark_entry(this, block, BBT_BLOCK_WORN);
1451 if (this->bbt_options & NAND_BBT_USE_FLASH)
1452 ret = nand_update_bbt(this, offs);