Lines Matching +full:nand +full:- +full:on +full:- +full:flash +full:- +full:bbt

1 // SPDX-License-Identifier: GPL-2.0-only
4 * Bad block table support for the NAND driver
11 * depending on the options in the BBT descriptor(s). If no flash based BBT
13 * marked good / bad blocks. This information is used to create a memory BBT.
15 * on the device.
16 * If a flash based BBT is specified then the function first tries to find the
17 * BBT on flash. If a BBT is found then the contents are read and the memory
18 * based BBT is created. If a mirrored BBT is selected then the mirror is
20 * version number, then the mirror BBT is used to build the memory based BBT.
23 * If no BBT exists at all then the device is scanned for factory marked
26 * For manufacturer created BBTs like the one found on M-SYS DOC devices
27 * the BBT is searched and read but never created
32 * number which indicates which of both tables is more up to date. If the NAND
46 * 10b: block is reserved (to protect the bbt area)
52 * - bbts start at a page boundary, if autolocated on a block boundary
53 * - the space necessary for a bbt in FLASH does not exceed a block boundary
78 uint8_t entry = chip->bbt[block >> BBT_ENTRY_SHIFT]; in bbt_get_entry()
87 chip->bbt[block >> BBT_ENTRY_SHIFT] |= msk; in bbt_mark_entry()
92 if (memcmp(buf, td->pattern, td->len)) in check_pattern_no_oob()
93 return -1; in check_pattern_no_oob()
98 * check_pattern - [GENERIC] check if a pattern is in the buffer
109 if (td->options & NAND_BBT_NO_OOB) in check_pattern()
113 if (memcmp(buf + paglen + td->offs, td->pattern, td->len)) in check_pattern()
114 return -1; in check_pattern()
120 * check_short_pattern - [GENERIC] check if a pattern is in the buffer
131 if (memcmp(buf + td->offs, td->pattern, td->len)) in check_short_pattern()
132 return -1; in check_short_pattern()
137 * add_marker_len - compute the length of the marker in data area
138 * @td: BBT descriptor used for computation
146 if (!(td->options & NAND_BBT_NO_OOB)) in add_marker_len()
149 len = td->len; in add_marker_len()
150 if (td->options & NAND_BBT_VERSION) in add_marker_len()
156 * read_bbt - [GENERIC] Read the bad block table starting from page
157 * @this: NAND chip object
160 * @num: the number of bbt descriptors to read
161 * @td: the bbt describtion table
173 int bits = td->options & NAND_BBT_NRBITS_MSK; in read_bbt()
174 uint8_t msk = (uint8_t)((1 << bits) - 1); in read_bbt()
176 int reserved_block_code = td->reserved_block_code; in read_bbt()
180 from = ((loff_t)page) << this->page_shift; in read_bbt()
183 len = min(totlen, (size_t)(1 << this->bbt_erase_shift)); in read_bbt()
186 * In case the BBT marker is not in the OOB area it in read_bbt()
189 len -= marker_len; in read_bbt()
196 pr_info("nand_bbt: ECC error in BBT at 0x%012llx\n", in read_bbt()
197 from & ~mtd->writesize); in read_bbt()
200 pr_info("nand_bbt: corrected error in BBT at 0x%012llx\n", in read_bbt()
201 from & ~mtd->writesize); in read_bbt()
204 pr_info("nand_bbt: error reading BBT\n"); in read_bbt()
219 this->bbt_erase_shift); in read_bbt()
222 mtd->ecc_stats.bbtblocks++; in read_bbt()
231 this->bbt_erase_shift); in read_bbt()
239 mtd->ecc_stats.badblocks++; in read_bbt()
242 totlen -= len; in read_bbt()
249 * read_abs_bbt - [GENERIC] Read the bad block table starting at a given page
250 * @this: NAND chip object
253 * @chip: read the table for a specific chip, -1 read all chips; applies only if
257 * that the bbt bits are in consecutive order.
263 u64 targetsize = nanddev_target_size(&this->base); in read_abs_bbt()
266 if (td->options & NAND_BBT_PERCHIP) { in read_abs_bbt()
268 for (i = 0; i < nanddev_ntargets(&this->base); i++) { in read_abs_bbt()
269 if (chip == -1 || chip == i) in read_abs_bbt()
270 res = read_bbt(this, buf, td->pages[i], in read_abs_bbt()
271 targetsize >> this->bbt_erase_shift, in read_abs_bbt()
275 offs += targetsize >> this->bbt_erase_shift; in read_abs_bbt()
278 res = read_bbt(this, buf, td->pages[0], in read_abs_bbt()
279 mtd->size >> this->bbt_erase_shift, td, 0); in read_abs_bbt()
286 /* BBT marker is in the first page, no OOB */
294 len = td->len; in scan_read_data()
295 if (td->options & NAND_BBT_VERSION) in scan_read_data()
302 * scan_read_oob - [GENERIC] Scan data+OOB region to buffer
303 * @this: NAND chip object
310 * ECC condition (error or bitflip). May quit on the first (non-ECC) error.
321 ops.ooblen = mtd->oobsize; in scan_read_oob()
325 ops.len = min(len, (size_t)mtd->writesize); in scan_read_oob()
336 buf += mtd->oobsize + mtd->writesize; in scan_read_oob()
337 len -= mtd->writesize; in scan_read_oob()
338 offs += mtd->writesize; in scan_read_oob()
346 if (td->options & NAND_BBT_NO_OOB) in scan_read()
352 /* Scan write data with oob to flash */
361 ops.ooblen = mtd->oobsize; in scan_write_bbt()
372 u32 ver_offs = td->veroffs; in bbt_get_ver_offs()
374 if (!(td->options & NAND_BBT_NO_OOB)) in bbt_get_ver_offs()
375 ver_offs += mtd->writesize; in bbt_get_ver_offs()
380 * read_abs_bbts - [GENERIC] Read the bad block table(s) for all chips starting at a given page
381 * @this: NAND chip object
387 * assume that the bbt bits are in consecutive order.
395 if (td->options & NAND_BBT_VERSION) { in read_abs_bbts()
396 scan_read(this, buf, (loff_t)td->pages[0] << this->page_shift, in read_abs_bbts()
397 mtd->writesize, td); in read_abs_bbts()
398 td->version[0] = buf[bbt_get_ver_offs(this, td)]; in read_abs_bbts()
400 td->pages[0], td->version[0]); in read_abs_bbts()
404 if (md && (md->options & NAND_BBT_VERSION)) { in read_abs_bbts()
405 scan_read(this, buf, (loff_t)md->pages[0] << this->page_shift, in read_abs_bbts()
406 mtd->writesize, md); in read_abs_bbts()
407 md->version[0] = buf[bbt_get_ver_offs(this, md)]; in read_abs_bbts()
409 md->pages[0], md->version[0]); in read_abs_bbts()
422 ops.ooblen = mtd->oobsize; in scan_block_fast()
435 ret = mtd_read_oob(mtd, offs + (page_offset * mtd->writesize), in scan_block_fast()
450 /* Check if a potential BBT block is marked as bad */
454 struct nand_bbt_descr *bd = this->badblock_pattern; in bbt_block_checkbad()
457 * No need to check for a bad BBT block if the BBM area overlaps with in bbt_block_checkbad()
461 if (!(td->options & NAND_BBT_NO_OOB) && in bbt_block_checkbad()
462 td->offs >= bd->offs && td->offs < bd->offs + bd->len) in bbt_block_checkbad()
469 if (this->bbt_options & NAND_BBT_NO_OOB_BBM || in bbt_block_checkbad()
470 this->options & NAND_NO_BBM_QUIRK) in bbt_block_checkbad()
480 * create_bbt - [GENERIC] Create a bad block table by scanning the device
481 * @this: NAND chip object
484 * @chip: create the table for a specific chip, -1 read all chips; applies only
493 u64 targetsize = nanddev_target_size(&this->base); in create_bbt()
500 if (chip == -1) { in create_bbt()
501 numblocks = mtd->size >> this->bbt_erase_shift; in create_bbt()
505 if (chip >= nanddev_ntargets(&this->base)) { in create_bbt()
507 chip + 1, nanddev_ntargets(&this->base)); in create_bbt()
508 return -EINVAL; in create_bbt()
510 numblocks = targetsize >> this->bbt_erase_shift; in create_bbt()
513 from = (loff_t)startblock << this->bbt_erase_shift; in create_bbt()
519 BUG_ON(bd->options & NAND_BBT_NO_OOB); in create_bbt()
529 mtd->ecc_stats.badblocks++; in create_bbt()
532 from += (1 << this->bbt_erase_shift); in create_bbt()
538 * search_bbt - [GENERIC] scan the device for a specific bad block table
539 * @this: NAND chip object
546 * NAND_BBT_PERCHIP is given, each chip is searched for a bbt, which contains
550 * The bbt ident pattern resides in the oob area of the first page in a block.
555 u64 targetsize = nanddev_target_size(&this->base); in search_bbt()
559 int scanlen = mtd->writesize + mtd->oobsize; in search_bbt()
561 int blocktopage = this->bbt_erase_shift - this->page_shift; in search_bbt()
563 /* Search direction top -> down? */ in search_bbt()
564 if (td->options & NAND_BBT_LASTBLOCK) { in search_bbt()
565 startblock = (mtd->size >> this->bbt_erase_shift) - 1; in search_bbt()
566 dir = -1; in search_bbt()
572 /* Do we have a bbt per chip? */ in search_bbt()
573 if (td->options & NAND_BBT_PERCHIP) { in search_bbt()
574 chips = nanddev_ntargets(&this->base); in search_bbt()
575 bbtblocks = targetsize >> this->bbt_erase_shift; in search_bbt()
576 startblock &= bbtblocks - 1; in search_bbt()
583 td->version[i] = 0; in search_bbt()
584 td->pages[i] = -1; in search_bbt()
586 for (block = 0; block < td->maxblocks; block++) { in search_bbt()
589 loff_t offs = (loff_t)actblock << this->bbt_erase_shift; in search_bbt()
596 scan_read(this, buf, offs, mtd->writesize, td); in search_bbt()
597 if (!check_pattern(buf, scanlen, mtd->writesize, td)) { in search_bbt()
598 td->pages[i] = actblock << blocktopage; in search_bbt()
599 if (td->options & NAND_BBT_VERSION) { in search_bbt()
601 td->version[i] = buf[offs]; in search_bbt()
606 startblock += targetsize >> this->bbt_erase_shift; in search_bbt()
608 /* Check, if we found a bbt for each requested chip */ in search_bbt()
610 if (td->pages[i] == -1) in search_bbt()
614 td->pages[i], td->version[i]); in search_bbt()
620 * search_read_bbts - [GENERIC] scan the device for bad block table(s)
621 * @this: NAND chip object
641 * get_bbt_block - Get the first valid eraseblock suitable to store a BBT
642 * @this: the NAND device
643 * @td: the BBT description
644 * @md: the mirror BBT descriptor
648 * suitable to store a BBT (i.e. in the range reserved for BBT), or -ENOSPC if
649 * all blocks are already used of marked bad. If td->pages[chip] was already
650 * pointing to a valid block we re-use it, otherwise we search for the next
656 u64 targetsize = nanddev_target_size(&this->base); in get_bbt_block()
662 * td->pages. in get_bbt_block()
664 if (td->pages[chip] != -1) in get_bbt_block()
665 return td->pages[chip] >> in get_bbt_block()
666 (this->bbt_erase_shift - this->page_shift); in get_bbt_block()
668 numblocks = (int)(targetsize >> this->bbt_erase_shift); in get_bbt_block()
669 if (!(td->options & NAND_BBT_PERCHIP)) in get_bbt_block()
670 numblocks *= nanddev_ntargets(&this->base); in get_bbt_block()
674 * top -> down? in get_bbt_block()
676 if (td->options & NAND_BBT_LASTBLOCK) { in get_bbt_block()
677 startblock = numblocks * (chip + 1) - 1; in get_bbt_block()
678 dir = -1; in get_bbt_block()
684 for (i = 0; i < td->maxblocks; i++) { in get_bbt_block()
694 page = block << (this->bbt_erase_shift - this->page_shift); in get_bbt_block()
697 if (!md || md->pages[chip] != page) in get_bbt_block()
701 return -ENOSPC; in get_bbt_block()
705 * mark_bbt_block_bad - Mark one of the block reserved for BBT bad
706 * @this: the NAND device
707 * @td: the BBT description
709 * @block: the BBT block to mark
711 * Blocks reserved for BBT can become bad. This functions is an helper to mark
712 * such blocks as bad. It takes care of updating the in-memory BBT, marking the
714 * td->pages[] entry.
725 to = (loff_t)block << this->bbt_erase_shift; in mark_bbt_block_bad()
731 td->pages[chip] = -1; in mark_bbt_block_bad()
735 * write_bbt - [GENERIC] (Re)write the bad block table
736 * @this: NAND chip object
740 * @chipsel: selector for a specific chip, -1 for all
748 u64 targetsize = nanddev_target_size(&this->base); in write_bbt()
755 uint8_t rcode = td->reserved_block_code; in write_bbt()
760 ops.ooblen = mtd->oobsize; in write_bbt()
768 if (td->options & NAND_BBT_PERCHIP) { in write_bbt()
769 numblocks = (int)(targetsize >> this->bbt_erase_shift); in write_bbt()
771 if (chipsel == -1) { in write_bbt()
772 nrchips = nanddev_ntargets(&this->base); in write_bbt()
778 numblocks = (int)(mtd->size >> this->bbt_erase_shift); in write_bbt()
797 page = block << (this->bbt_erase_shift - this->page_shift); in write_bbt()
799 /* Set up shift count and masks for the flash table */ in write_bbt()
800 bits = td->options & NAND_BBT_NRBITS_MSK; in write_bbt()
815 default: return -EINVAL; in write_bbt()
818 to = ((loff_t)page) << this->page_shift; in write_bbt()
821 if (td->options & NAND_BBT_SAVECONTENT) { in write_bbt()
823 to &= ~(((loff_t)1 << this->bbt_erase_shift) - 1); in write_bbt()
824 len = 1 << this->bbt_erase_shift; in write_bbt()
834 ops.ooblen = (len >> this->page_shift) * mtd->oobsize; in write_bbt()
836 res = mtd_read_oob(mtd, to + mtd->writesize, &ops); in write_bbt()
841 pageoffs = page - (int)(to >> this->page_shift); in write_bbt()
842 offs = pageoffs << this->page_shift; in write_bbt()
843 /* Preset the bbt area with 0xff */ in write_bbt()
845 ooboffs = len + (pageoffs * mtd->oobsize); in write_bbt()
847 } else if (td->options & NAND_BBT_NO_OOB) { in write_bbt()
849 offs = td->len; in write_bbt()
851 if (td->options & NAND_BBT_VERSION) in write_bbt()
857 len = ALIGN(len, mtd->writesize); in write_bbt()
861 memcpy(buf, td->pattern, td->len); in write_bbt()
866 len = ALIGN(len, mtd->writesize); in write_bbt()
869 (len >> this->page_shift)* mtd->oobsize); in write_bbt()
873 memcpy(&buf[ooboffs + td->offs], td->pattern, td->len); in write_bbt()
876 if (td->options & NAND_BBT_VERSION) in write_bbt()
877 buf[ooboffs + td->veroffs] = td->version[chip]; in write_bbt()
882 int sftcnt = (i << (3 - sft)) & sftmsk; in write_bbt()
884 /* Do not store the reserved bbt blocks! */ in write_bbt()
890 einfo.len = 1 << this->bbt_erase_shift; in write_bbt()
893 pr_warn("nand_bbt: error while erasing BBT block %d\n", in write_bbt()
900 td->options & NAND_BBT_NO_OOB ? in write_bbt()
903 pr_warn("nand_bbt: error while writing BBT block %d\n", in write_bbt()
910 (unsigned long long)to, td->version[chip]); in write_bbt()
913 td->pages[chip++] = page; in write_bbt()
923 * nand_memory_bbt - [GENERIC] create a memory based bad block table
924 * @this: NAND chip object
927 * The function creates a memory based bbt by scanning the device for
935 return create_bbt(this, pagebuf, bd, -1); in nand_memory_bbt()
939 * check_create - [GENERIC] create and write bbt(s) if necessary
940 * @this: the NAND device
945 * / updates the bbt(s) if necessary. Creation is necessary if no bbt was found
953 struct nand_bbt_descr *td = this->bbt_td; in check_create()
954 struct nand_bbt_descr *md = this->bbt_md; in check_create()
957 /* Do we have a bbt per chip? */ in check_create()
958 if (td->options & NAND_BBT_PERCHIP) in check_create()
959 chips = nanddev_ntargets(&this->base); in check_create()
970 chipsel = (td->options & NAND_BBT_PERCHIP) ? i : -1; in check_create()
973 if (td->pages[i] == -1 && md->pages[i] == -1) { in check_create()
976 } else if (td->pages[i] == -1) { in check_create()
979 } else if (md->pages[i] == -1) { in check_create()
982 } else if (td->version[i] == md->version[i]) { in check_create()
984 if (!(td->options & NAND_BBT_VERSION)) in check_create()
986 } else if (((int8_t)(td->version[i] - md->version[i])) > 0) { in check_create()
994 if (td->pages[i] == -1) { in check_create()
1004 if (!(td->options & NAND_BBT_CREATE)) in check_create()
1008 if (!(this->bbt_options & NAND_BBT_CREATE_EMPTY)) in check_create()
1011 td->version[i] = 1; in check_create()
1013 md->version[i] = 1; in check_create()
1021 rd->pages[i] = -1; in check_create()
1022 rd->version[i] = 0; in check_create()
1023 i--; in check_create()
1032 rd2->pages[i] = -1; in check_create()
1033 rd2->version[i] = 0; in check_create()
1034 i--; in check_create()
1039 /* Scrub the flash table(s)? */ in check_create()
1045 td->version[i] = max(td->version[i], md->version[i]); in check_create()
1046 md->version[i] = td->version[i]; in check_create()
1050 if ((writeops & 0x01) && (td->options & NAND_BBT_WRITE)) { in check_create()
1057 if ((writeops & 0x02) && md && (md->options & NAND_BBT_WRITE)) { in check_create()
1067 * nand_update_bbt - update bad block table(s)
1068 * @this: the NAND device
1079 struct nand_bbt_descr *td = this->bbt_td; in nand_update_bbt()
1080 struct nand_bbt_descr *md = this->bbt_md; in nand_update_bbt()
1082 if (!this->bbt || !td) in nand_update_bbt()
1083 return -EINVAL; in nand_update_bbt()
1086 len = (1 << this->bbt_erase_shift); in nand_update_bbt()
1087 len += (len >> this->page_shift) * mtd->oobsize; in nand_update_bbt()
1090 return -ENOMEM; in nand_update_bbt()
1092 /* Do we have a bbt per chip? */ in nand_update_bbt()
1093 if (td->options & NAND_BBT_PERCHIP) { in nand_update_bbt()
1094 chip = (int)(offs >> this->chip_shift); in nand_update_bbt()
1098 chipsel = -1; in nand_update_bbt()
1101 td->version[chip]++; in nand_update_bbt()
1103 md->version[chip]++; in nand_update_bbt()
1106 if (td->options & NAND_BBT_WRITE) { in nand_update_bbt()
1112 if (md && (md->options & NAND_BBT_WRITE)) { in nand_update_bbt()
1122 * mark_bbt_region - [GENERIC] mark the bad block table regions
1123 * @this: the NAND device
1131 u64 targetsize = nanddev_target_size(&this->base); in mark_bbt_region()
1136 /* Do we have a bbt per chip? */ in mark_bbt_region()
1137 if (td->options & NAND_BBT_PERCHIP) { in mark_bbt_region()
1138 chips = nanddev_ntargets(&this->base); in mark_bbt_region()
1139 nrblocks = (int)(targetsize >> this->bbt_erase_shift); in mark_bbt_region()
1142 nrblocks = (int)(mtd->size >> this->bbt_erase_shift); in mark_bbt_region()
1146 if ((td->options & NAND_BBT_ABSPAGE) || in mark_bbt_region()
1147 !(td->options & NAND_BBT_WRITE)) { in mark_bbt_region()
1148 if (td->pages[i] == -1) in mark_bbt_region()
1150 block = td->pages[i] >> (this->bbt_erase_shift - this->page_shift); in mark_bbt_region()
1154 td->reserved_block_code) in mark_bbt_region()
1156 this->bbt_erase_shift); in mark_bbt_region()
1160 if (td->options & NAND_BBT_LASTBLOCK) in mark_bbt_region()
1161 block = ((i + 1) * nrblocks) - td->maxblocks; in mark_bbt_region()
1164 for (j = 0; j < td->maxblocks; j++) { in mark_bbt_region()
1172 * If we want reserved blocks to be recorded to flash, and some in mark_bbt_region()
1176 if (update && td->reserved_block_code) in mark_bbt_region()
1177 nand_update_bbt(this, (loff_t)(block - 1) << in mark_bbt_region()
1178 this->bbt_erase_shift); in mark_bbt_region()
1183 * verify_bbt_descr - verify the bad block description
1184 * @this: the NAND device
1187 * This functions performs a few sanity checks on the bad block description
1192 u64 targetsize = nanddev_target_size(&this->base); in verify_bbt_descr()
1201 pattern_len = bd->len; in verify_bbt_descr()
1202 bits = bd->options & NAND_BBT_NRBITS_MSK; in verify_bbt_descr()
1204 BUG_ON((this->bbt_options & NAND_BBT_NO_OOB) && in verify_bbt_descr()
1205 !(this->bbt_options & NAND_BBT_USE_FLASH)); in verify_bbt_descr()
1208 if (bd->options & NAND_BBT_VERSION) in verify_bbt_descr()
1211 if (bd->options & NAND_BBT_NO_OOB) { in verify_bbt_descr()
1212 BUG_ON(!(this->bbt_options & NAND_BBT_USE_FLASH)); in verify_bbt_descr()
1213 BUG_ON(!(this->bbt_options & NAND_BBT_NO_OOB)); in verify_bbt_descr()
1214 BUG_ON(bd->offs); in verify_bbt_descr()
1215 if (bd->options & NAND_BBT_VERSION) in verify_bbt_descr()
1216 BUG_ON(bd->veroffs != bd->len); in verify_bbt_descr()
1217 BUG_ON(bd->options & NAND_BBT_SAVECONTENT); in verify_bbt_descr()
1220 if (bd->options & NAND_BBT_PERCHIP) in verify_bbt_descr()
1221 table_size = targetsize >> this->bbt_erase_shift; in verify_bbt_descr()
1223 table_size = mtd->size >> this->bbt_erase_shift; in verify_bbt_descr()
1226 if (bd->options & NAND_BBT_NO_OOB) in verify_bbt_descr()
1228 BUG_ON(table_size > (1 << this->bbt_erase_shift)); in verify_bbt_descr()
1232 * nand_scan_bbt - [NAND Interface] scan, find, read and maybe create bad block table(s)
1233 * @this: the NAND device
1248 struct nand_bbt_descr *td = this->bbt_td; in nand_scan_bbt()
1249 struct nand_bbt_descr *md = this->bbt_md; in nand_scan_bbt()
1251 len = (mtd->size >> (this->bbt_erase_shift + 2)) ? : 1; in nand_scan_bbt()
1256 this->bbt = kzalloc(len, GFP_KERNEL); in nand_scan_bbt()
1257 if (!this->bbt) in nand_scan_bbt()
1258 return -ENOMEM; in nand_scan_bbt()
1266 pr_err("nand_bbt: can't scan flash and build the RAM-based BBT\n"); in nand_scan_bbt()
1275 len = (1 << this->bbt_erase_shift); in nand_scan_bbt()
1276 len += (len >> this->page_shift) * mtd->oobsize; in nand_scan_bbt()
1279 res = -ENOMEM; in nand_scan_bbt()
1283 /* Is the bbt at a given page? */ in nand_scan_bbt()
1284 if (td->options & NAND_BBT_ABSPAGE) { in nand_scan_bbt()
1295 /* Prevent the bbt regions from erasing / writing */ in nand_scan_bbt()
1306 kfree(this->bbt); in nand_scan_bbt()
1307 this->bbt = NULL; in nand_scan_bbt()
1317 /* Generic flash bbt descriptors */
1363 * nand_create_badblock_pattern - [INTERN] Creates a BBT descriptor structure
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
1374 if (this->badblock_pattern) { in nand_create_badblock_pattern()
1376 return -EINVAL; in nand_create_badblock_pattern()
1380 return -ENOMEM; in nand_create_badblock_pattern()
1381 bd->options = this->bbt_options & BADBLOCK_SCAN_MASK; in nand_create_badblock_pattern()
1382 bd->offs = this->badblockpos; in nand_create_badblock_pattern()
1383 bd->len = (this->options & NAND_BUSWIDTH_16) ? 2 : 1; in nand_create_badblock_pattern()
1384 bd->pattern = scan_ff_pattern; in nand_create_badblock_pattern()
1385 bd->options |= NAND_BBT_DYNAMICSTRUCT; in nand_create_badblock_pattern()
1386 this->badblock_pattern = bd; in nand_create_badblock_pattern()
1391 * nand_create_bbt - [NAND Interface] Select a default bad block table for the device
1392 * @this: NAND chip object
1401 /* Is a flash based bad block table requested? */ in nand_create_bbt()
1402 if (this->bbt_options & NAND_BBT_USE_FLASH) { in nand_create_bbt()
1404 if (!this->bbt_td) { in nand_create_bbt()
1405 if (this->bbt_options & NAND_BBT_NO_OOB) { in nand_create_bbt()
1406 this->bbt_td = &bbt_main_no_oob_descr; in nand_create_bbt()
1407 this->bbt_md = &bbt_mirror_no_oob_descr; in nand_create_bbt()
1409 this->bbt_td = &bbt_main_descr; in nand_create_bbt()
1410 this->bbt_md = &bbt_mirror_descr; in nand_create_bbt()
1414 this->bbt_td = NULL; in nand_create_bbt()
1415 this->bbt_md = NULL; in nand_create_bbt()
1418 if (!this->badblock_pattern) { in nand_create_bbt()
1424 return nand_scan_bbt(this, this->badblock_pattern); in nand_create_bbt()
1429 * nand_isreserved_bbt - [NAND Interface] Check if a block is reserved
1430 * @this: NAND chip object
1437 block = (int)(offs >> this->bbt_erase_shift); in nand_isreserved_bbt()
1442 * nand_isbad_bbt - [NAND Interface] Check if a block is bad
1443 * @this: NAND chip object
1451 block = (int)(offs >> this->bbt_erase_shift); in nand_isbad_bbt()
1454 pr_debug("nand_isbad_bbt(): bbt info for offs 0x%08x: (block %d) 0x%02x\n", in nand_isbad_bbt()
1472 * nand_markbad_bbt - [NAND Interface] Mark a block bad in the BBT
1473 * @this: NAND chip object
1480 block = (int)(offs >> this->bbt_erase_shift); in nand_markbad_bbt()
1485 /* Update flash-based bad block table */ in nand_markbad_bbt()
1486 if (this->bbt_options & NAND_BBT_USE_FLASH) in nand_markbad_bbt()