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);
451 static int bbt_block_checkbad(struct nand_chip *this, struct nand_bbt_descr *td,
454 struct nand_bbt_descr *bd = this->badblock_pattern;
469 if (this->bbt_options & NAND_BBT_NO_OOB_BBM ||
470 this->options & NAND_NO_BBM_QUIRK)
473 if (scan_block_fast(this, bd, offs, buf) > 0)
481 * @this: NAND chip object
490 static int create_bbt(struct nand_chip *this, uint8_t *buf,
493 u64 targetsize = nanddev_target_size(&this->base);
494 struct mtd_info *mtd = nand_to_mtd(this);
501 numblocks = mtd->size >> this->bbt_erase_shift;
505 if (chip >= nanddev_ntargets(&this->base)) {
507 chip + 1, nanddev_ntargets(&this->base));
510 numblocks = targetsize >> this->bbt_erase_shift;
513 from = (loff_t)startblock << this->bbt_erase_shift;
521 ret = scan_block_fast(this, bd, from, buf);
526 bbt_mark_entry(this, i, BBT_BLOCK_FACTORY_BAD);
532 from += (1 << this->bbt_erase_shift);
539 * @this: NAND chip object
547 * the bad block information of this chip. This is necessary to provide support
552 static int search_bbt(struct nand_chip *this, uint8_t *buf,
555 u64 targetsize = nanddev_target_size(&this->base);
556 struct mtd_info *mtd = nand_to_mtd(this);
561 int blocktopage = this->bbt_erase_shift - this->page_shift;
565 startblock = (mtd->size >> this->bbt_erase_shift) - 1;
574 chips = nanddev_ntargets(&this->base);
575 bbtblocks = targetsize >> this->bbt_erase_shift;
579 bbtblocks = mtd->size >> this->bbt_erase_shift;
590 loff_t offs = (loff_t)actblock << this->bbt_erase_shift;
593 if (bbt_block_checkbad(this, td, offs, buf))
597 scan_read(this, buf, offs, mtd->writesize, td);
601 offs = bbt_get_ver_offs(this, td);
607 startblock += targetsize >> this->bbt_erase_shift;
622 * @this: NAND chip object
629 static void search_read_bbts(struct nand_chip *this, uint8_t *buf,
634 search_bbt(this, buf, td);
638 search_bbt(this, buf, md);
643 * @this: the NAND device
654 static int get_bbt_block(struct nand_chip *this, struct nand_bbt_descr *td,
657 u64 targetsize = nanddev_target_size(&this->base);
667 (this->bbt_erase_shift - this->page_shift);
669 numblocks = (int)(targetsize >> this->bbt_erase_shift);
671 numblocks *= nanddev_ntargets(&this->base);
689 switch (bbt_get_entry(this, block)) {
695 page = block << (this->bbt_erase_shift - this->page_shift);
707 * @this: the NAND device
717 static void mark_bbt_block_bad(struct nand_chip *this,
724 bbt_mark_entry(this, block, BBT_BLOCK_WORN);
726 to = (loff_t)block << this->bbt_erase_shift;
727 res = nand_markbad_bbm(this, to);
737 * @this: NAND chip object
745 static int write_bbt(struct nand_chip *this, uint8_t *buf,
749 u64 targetsize = nanddev_target_size(&this->base);
750 struct mtd_info *mtd = nand_to_mtd(this);
770 numblocks = (int)(targetsize >> this->bbt_erase_shift);
773 nrchips = nanddev_ntargets(&this->base);
779 numblocks = (int)(mtd->size >> this->bbt_erase_shift);
787 block = get_bbt_block(this, td, md, chip);
798 page = block << (this->bbt_erase_shift - this->page_shift);
819 to = ((loff_t)page) << this->page_shift;
824 to &= ~(((loff_t)1 << this->bbt_erase_shift) - 1);
825 len = 1 << this->bbt_erase_shift;
835 ops.ooblen = (len >> this->page_shift) * mtd->oobsize;
842 pageoffs = page - (int)(to >> this->page_shift);
843 offs = pageoffs << this->page_shift;
870 (len >> this->page_shift)* mtd->oobsize);
884 dat = bbt_get_entry(this, chip * numblocks + i);
891 einfo.len = 1 << this->bbt_erase_shift;
892 res = nand_erase_nand(this, &einfo, 1);
896 mark_bbt_block_bad(this, td, chip, block);
900 res = scan_write_bbt(this, to, len, buf,
906 mark_bbt_block_bad(this, td, chip, block);
925 * @this: NAND chip object
931 static inline int nand_memory_bbt(struct nand_chip *this,
934 u8 *pagebuf = nand_get_data_buf(this);
936 return create_bbt(this, pagebuf, bd, -1);
941 * @this: the NAND device
950 static int check_create(struct nand_chip *this, uint8_t *buf,
954 struct nand_bbt_descr *td = this->bbt_td;
955 struct nand_bbt_descr *md = this->bbt_md;
960 chips = nanddev_ntargets(&this->base);
1009 if (!(this->bbt_options & NAND_BBT_CREATE_EMPTY))
1010 create_bbt(this, buf, bd, chipsel);
1019 res = read_abs_bbt(this, buf, rd, chipsel);
1030 res2 = read_abs_bbt(this, buf, rd2, chipsel);
1052 res = write_bbt(this, buf, td, md, chipsel);
1059 res = write_bbt(this, buf, md, td, chipsel);
1069 * @this: the NAND device
1074 static int nand_update_bbt(struct nand_chip *this, loff_t offs)
1076 struct mtd_info *mtd = nand_to_mtd(this);
1080 struct nand_bbt_descr *td = this->bbt_td;
1081 struct nand_bbt_descr *md = this->bbt_md;
1083 if (!this->bbt || !td)
1087 len = (1 << this->bbt_erase_shift);
1088 len += (len >> this->page_shift) * mtd->oobsize;
1095 chip = (int)(offs >> this->chip_shift);
1108 res = write_bbt(this, buf, td, md, chipsel);
1114 res = write_bbt(this, buf, md, td, chipsel);
1124 * @this: the NAND device
1130 static void mark_bbt_region(struct nand_chip *this, struct nand_bbt_descr *td)
1132 u64 targetsize = nanddev_target_size(&this->base);
1133 struct mtd_info *mtd = nand_to_mtd(this);
1139 chips = nanddev_ntargets(&this->base);
1140 nrblocks = (int)(targetsize >> this->bbt_erase_shift);
1143 nrblocks = (int)(mtd->size >> this->bbt_erase_shift);
1151 block = td->pages[i] >> (this->bbt_erase_shift - this->page_shift);
1152 oldval = bbt_get_entry(this, block);
1153 bbt_mark_entry(this, block, BBT_BLOCK_RESERVED);
1156 nand_update_bbt(this, (loff_t)block <<
1157 this->bbt_erase_shift);
1166 oldval = bbt_get_entry(this, block);
1167 bbt_mark_entry(this, block, BBT_BLOCK_RESERVED);
1178 nand_update_bbt(this, (loff_t)(block - 1) <<
1179 this->bbt_erase_shift);
1185 * @this: the NAND device
1191 static void verify_bbt_descr(struct nand_chip *this, struct nand_bbt_descr *bd)
1193 u64 targetsize = nanddev_target_size(&this->base);
1194 struct mtd_info *mtd = nand_to_mtd(this);
1205 BUG_ON((this->bbt_options & NAND_BBT_NO_OOB) &&
1206 !(this->bbt_options & NAND_BBT_USE_FLASH));
1213 BUG_ON(!(this->bbt_options & NAND_BBT_USE_FLASH));
1214 BUG_ON(!(this->bbt_options & NAND_BBT_NO_OOB));
1222 table_size = targetsize >> this->bbt_erase_shift;
1224 table_size = mtd->size >> this->bbt_erase_shift;
1229 BUG_ON(table_size > (1 << this->bbt_erase_shift));
1234 * @this: the NAND device
1244 static int nand_scan_bbt(struct nand_chip *this, struct nand_bbt_descr *bd)
1246 struct mtd_info *mtd = nand_to_mtd(this);
1249 struct nand_bbt_descr *td = this->bbt_td;
1250 struct nand_bbt_descr *md = this->bbt_md;
1252 len = (mtd->size >> (this->bbt_erase_shift + 2)) ? : 1;
1257 this->bbt = kzalloc(len, GFP_KERNEL);
1258 if (!this->bbt)
1266 if ((res = nand_memory_bbt(this, bd))) {
1272 verify_bbt_descr(this, td);
1273 verify_bbt_descr(this, md);
1276 len = (1 << this->bbt_erase_shift);
1277 len += (len >> this->page_shift) * mtd->oobsize;
1286 read_abs_bbts(this, buf, td, md);
1289 search_read_bbts(this, buf, td, md);
1292 res = check_create(this, buf, bd);
1297 mark_bbt_region(this, td);
1299 mark_bbt_region(this, md);
1307 kfree(this->bbt);
1308 this->bbt = NULL;
1365 * @this: NAND chip to create descriptor for
1368 * based on the properties of @this. The new descriptor is stored in
1369 * this->badblock_pattern. Thus, this->badblock_pattern should be NULL when
1370 * passed to this function.
1372 static int nand_create_badblock_pattern(struct nand_chip *this)
1375 if (this->badblock_pattern) {
1382 bd->options = this->bbt_options & BADBLOCK_SCAN_MASK;
1383 bd->offs = this->badblockpos;
1384 bd->len = (this->options & NAND_BUSWIDTH_16) ? 2 : 1;
1387 this->badblock_pattern = bd;
1393 * @this: NAND chip object
1398 int nand_create_bbt(struct nand_chip *this)
1403 if (this->bbt_options & NAND_BBT_USE_FLASH) {
1405 if (!this->bbt_td) {
1406 if (this->bbt_options & NAND_BBT_NO_OOB) {
1407 this->bbt_td = &bbt_main_no_oob_descr;
1408 this->bbt_md = &bbt_mirror_no_oob_descr;
1410 this->bbt_td = &bbt_main_descr;
1411 this->bbt_md = &bbt_mirror_descr;
1415 this->bbt_td = NULL;
1416 this->bbt_md = NULL;
1419 if (!this->badblock_pattern) {
1420 ret = nand_create_badblock_pattern(this);
1425 return nand_scan_bbt(this, this->badblock_pattern);
1431 * @this: NAND chip object
1434 int nand_isreserved_bbt(struct nand_chip *this, loff_t offs)
1438 block = (int)(offs >> this->bbt_erase_shift);
1439 return bbt_get_entry(this, block) == BBT_BLOCK_RESERVED;
1444 * @this: NAND chip object
1448 int nand_isbad_bbt(struct nand_chip *this, loff_t offs, int allowbbt)
1452 block = (int)(offs >> this->bbt_erase_shift);
1453 res = bbt_get_entry(this, block);
1474 * @this: NAND chip object
1477 int nand_markbad_bbt(struct nand_chip *this, loff_t offs)
1481 block = (int)(offs >> this->bbt_erase_shift);
1484 bbt_mark_entry(this, block, BBT_BLOCK_WORN);
1487 if (this->bbt_options & NAND_BBT_USE_FLASH)
1488 ret = nand_update_bbt(this, offs);