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;
589 loff_t offs = (loff_t)actblock << this->bbt_erase_shift;
592 if (bbt_block_checkbad(this, td, offs, buf))
596 scan_read(this, buf, offs, mtd->writesize, td);
600 offs = bbt_get_ver_offs(this, td);
606 startblock += targetsize >> this->bbt_erase_shift;
621 * @this: NAND chip object
628 static void search_read_bbts(struct nand_chip *this, uint8_t *buf,
633 search_bbt(this, buf, td);
637 search_bbt(this, buf, md);
642 * @this: the NAND device
653 static int get_bbt_block(struct nand_chip *this, struct nand_bbt_descr *td,
656 u64 targetsize = nanddev_target_size(&this->base);
666 (this->bbt_erase_shift - this->page_shift);
668 numblocks = (int)(targetsize >> this->bbt_erase_shift);
670 numblocks *= nanddev_ntargets(&this->base);
688 switch (bbt_get_entry(this, block)) {
694 page = block << (this->bbt_erase_shift - this->page_shift);
706 * @this: the NAND device
716 static void mark_bbt_block_bad(struct nand_chip *this,
723 bbt_mark_entry(this, block, BBT_BLOCK_WORN);
725 to = (loff_t)block << this->bbt_erase_shift;
726 res = nand_markbad_bbm(this, to);
736 * @this: NAND chip object
744 static int write_bbt(struct nand_chip *this, uint8_t *buf,
748 u64 targetsize = nanddev_target_size(&this->base);
749 struct mtd_info *mtd = nand_to_mtd(this);
769 numblocks = (int)(targetsize >> this->bbt_erase_shift);
772 nrchips = nanddev_ntargets(&this->base);
778 numblocks = (int)(mtd->size >> this->bbt_erase_shift);
786 block = get_bbt_block(this, td, md, chip);
797 page = block << (this->bbt_erase_shift - this->page_shift);
818 to = ((loff_t)page) << this->page_shift;
823 to &= ~(((loff_t)1 << this->bbt_erase_shift) - 1);
824 len = 1 << this->bbt_erase_shift;
834 ops.ooblen = (len >> this->page_shift) * mtd->oobsize;
841 pageoffs = page - (int)(to >> this->page_shift);
842 offs = pageoffs << this->page_shift;
869 (len >> this->page_shift)* mtd->oobsize);
883 dat = bbt_get_entry(this, chip * numblocks + i);
890 einfo.len = 1 << this->bbt_erase_shift;
891 res = nand_erase_nand(this, &einfo, 1);
895 mark_bbt_block_bad(this, td, chip, block);
899 res = scan_write_bbt(this, to, len, buf,
905 mark_bbt_block_bad(this, td, chip, block);
924 * @this: NAND chip object
930 static inline int nand_memory_bbt(struct nand_chip *this,
933 u8 *pagebuf = nand_get_data_buf(this);
935 return create_bbt(this, pagebuf, bd, -1);
940 * @this: the NAND device
949 static int check_create(struct nand_chip *this, uint8_t *buf,
953 struct nand_bbt_descr *td = this->bbt_td;
954 struct nand_bbt_descr *md = this->bbt_md;
959 chips = nanddev_ntargets(&this->base);
1008 if (!(this->bbt_options & NAND_BBT_CREATE_EMPTY))
1009 create_bbt(this, buf, bd, chipsel);
1018 res = read_abs_bbt(this, buf, rd, chipsel);
1029 res2 = read_abs_bbt(this, buf, rd2, chipsel);
1051 res = write_bbt(this, buf, td, md, chipsel);
1058 res = write_bbt(this, buf, md, td, chipsel);
1068 * @this: the NAND device
1073 static int nand_update_bbt(struct nand_chip *this, loff_t offs)
1075 struct mtd_info *mtd = nand_to_mtd(this);
1079 struct nand_bbt_descr *td = this->bbt_td;
1080 struct nand_bbt_descr *md = this->bbt_md;
1082 if (!this->bbt || !td)
1086 len = (1 << this->bbt_erase_shift);
1087 len += (len >> this->page_shift) * mtd->oobsize;
1094 chip = (int)(offs >> this->chip_shift);
1107 res = write_bbt(this, buf, td, md, chipsel);
1113 res = write_bbt(this, buf, md, td, chipsel);
1123 * @this: the NAND device
1129 static void mark_bbt_region(struct nand_chip *this, struct nand_bbt_descr *td)
1131 u64 targetsize = nanddev_target_size(&this->base);
1132 struct mtd_info *mtd = nand_to_mtd(this);
1138 chips = nanddev_ntargets(&this->base);
1139 nrblocks = (int)(targetsize >> this->bbt_erase_shift);
1142 nrblocks = (int)(mtd->size >> this->bbt_erase_shift);
1150 block = td->pages[i] >> (this->bbt_erase_shift - this->page_shift);
1151 oldval = bbt_get_entry(this, block);
1152 bbt_mark_entry(this, block, BBT_BLOCK_RESERVED);
1155 nand_update_bbt(this, (loff_t)block <<
1156 this->bbt_erase_shift);
1165 oldval = bbt_get_entry(this, block);
1166 bbt_mark_entry(this, block, BBT_BLOCK_RESERVED);
1177 nand_update_bbt(this, (loff_t)(block - 1) <<
1178 this->bbt_erase_shift);
1184 * @this: the NAND device
1190 static void verify_bbt_descr(struct nand_chip *this, struct nand_bbt_descr *bd)
1192 u64 targetsize = nanddev_target_size(&this->base);
1193 struct mtd_info *mtd = nand_to_mtd(this);
1204 BUG_ON((this->bbt_options & NAND_BBT_NO_OOB) &&
1205 !(this->bbt_options & NAND_BBT_USE_FLASH));
1212 BUG_ON(!(this->bbt_options & NAND_BBT_USE_FLASH));
1213 BUG_ON(!(this->bbt_options & NAND_BBT_NO_OOB));
1221 table_size = targetsize >> this->bbt_erase_shift;
1223 table_size = mtd->size >> this->bbt_erase_shift;
1228 BUG_ON(table_size > (1 << this->bbt_erase_shift));
1233 * @this: the NAND device
1243 static int nand_scan_bbt(struct nand_chip *this, struct nand_bbt_descr *bd)
1245 struct mtd_info *mtd = nand_to_mtd(this);
1248 struct nand_bbt_descr *td = this->bbt_td;
1249 struct nand_bbt_descr *md = this->bbt_md;
1251 len = (mtd->size >> (this->bbt_erase_shift + 2)) ? : 1;
1256 this->bbt = kzalloc(len, GFP_KERNEL);
1257 if (!this->bbt)
1265 if ((res = nand_memory_bbt(this, bd))) {
1271 verify_bbt_descr(this, td);
1272 verify_bbt_descr(this, md);
1275 len = (1 << this->bbt_erase_shift);
1276 len += (len >> this->page_shift) * mtd->oobsize;
1285 read_abs_bbts(this, buf, td, md);
1288 search_read_bbts(this, buf, td, md);
1291 res = check_create(this, buf, bd);
1296 mark_bbt_region(this, td);
1298 mark_bbt_region(this, md);
1306 kfree(this->bbt);
1307 this->bbt = NULL;
1364 * @this: NAND chip to create descriptor for
1367 * based on the properties of @this. The new descriptor is stored in
1368 * this->badblock_pattern. Thus, this->badblock_pattern should be NULL when
1369 * passed to this function.
1371 static int nand_create_badblock_pattern(struct nand_chip *this)
1374 if (this->badblock_pattern) {
1381 bd->options = this->bbt_options & BADBLOCK_SCAN_MASK;
1382 bd->offs = this->badblockpos;
1383 bd->len = (this->options & NAND_BUSWIDTH_16) ? 2 : 1;
1386 this->badblock_pattern = bd;
1392 * @this: NAND chip object
1397 int nand_create_bbt(struct nand_chip *this)
1402 if (this->bbt_options & NAND_BBT_USE_FLASH) {
1404 if (!this->bbt_td) {
1405 if (this->bbt_options & NAND_BBT_NO_OOB) {
1406 this->bbt_td = &bbt_main_no_oob_descr;
1407 this->bbt_md = &bbt_mirror_no_oob_descr;
1409 this->bbt_td = &bbt_main_descr;
1410 this->bbt_md = &bbt_mirror_descr;
1414 this->bbt_td = NULL;
1415 this->bbt_md = NULL;
1418 if (!this->badblock_pattern) {
1419 ret = nand_create_badblock_pattern(this);
1424 return nand_scan_bbt(this, this->badblock_pattern);
1430 * @this: NAND chip object
1433 int nand_isreserved_bbt(struct nand_chip *this, loff_t offs)
1437 block = (int)(offs >> this->bbt_erase_shift);
1438 return bbt_get_entry(this, block) == BBT_BLOCK_RESERVED;
1443 * @this: NAND chip object
1447 int nand_isbad_bbt(struct nand_chip *this, loff_t offs, int allowbbt)
1451 block = (int)(offs >> this->bbt_erase_shift);
1452 res = bbt_get_entry(this, block);
1473 * @this: NAND chip object
1476 int nand_markbad_bbt(struct nand_chip *this, loff_t offs)
1480 block = (int)(offs >> this->bbt_erase_shift);
1483 bbt_mark_entry(this, block, BBT_BLOCK_WORN);
1486 if (this->bbt_options & NAND_BBT_USE_FLASH)
1487 ret = nand_update_bbt(this, offs);