Lines Matching defs:block

4  *   Bad block table support for the NAND driver
10 * When nand_scan_bbt is called, then it tries to find the bad block table
14 * Once a new bad block is discovered then the "factory" information is updated
21 * If the tables are not versioned, then we "or" the bad block information.
24 * good / bad blocks and the bad block tables are created.
29 * The auto generated bad block table is located in the last good blocks
38 * The table uses 2 bits per block
39 * 11b: block is good
40 * 00b: block is factory marked bad
41 * 01b, 10b: block is marked bad due to wear
43 * The memory bad block table uses the following scheme:
44 * 00b: block is good
45 * 01b: block is marked bad due to wear
46 * 10b: block is reserved (to protect the bbt area)
47 * 11b: block is factory marked bad
49 * Multichip devices like DOC store the bad block info per floor.
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
76 static inline uint8_t bbt_get_entry(struct nand_chip *chip, int block)
78 uint8_t entry = chip->bbt[block >> BBT_ENTRY_SHIFT];
79 entry >>= (block & BBT_ENTRY_MASK) * 2;
83 static inline void bbt_mark_entry(struct nand_chip *chip, int block,
86 uint8_t msk = (mark & BBT_ENTRY_MASK) << ((block & BBT_ENTRY_MASK) * 2);
87 chip->bbt[block >> BBT_ENTRY_SHIFT] |= msk;
104 * Check for a pattern at the given place. Used to search bad block tables and
105 * good / bad block identifiers.
124 * Check for a pattern at the given place. Used to search bad block tables and
125 * good / bad block identifiers. Same as check_pattern, but no optional empty
156 * read_bbt - [GENERIC] Read the bad block table starting from page
162 * @offs: block number offset in the table
164 * Read the bad block table starting from page.
217 pr_info("nand_read_bbt: reserved block at 0x%012llx\n",
229 pr_info("nand_read_bbt: bad block at 0x%012llx\n",
249 * read_abs_bbt - [GENERIC] Read the bad block table starting at a given page
252 * @td: descriptor for the bad block table
256 * Read the bad block table for all chips starting at a given page. We assume
380 * read_abs_bbts - [GENERIC] Read the bad block table(s) for all chips starting at a given page
383 * @td: descriptor for the bad block table
384 * @md: descriptor for the bad block table mirror
386 * Read the bad block table(s) for all chips starting at a given page. We
399 pr_info("Bad block table at page %d, version 0x%02X\n",
408 pr_info("Bad block table at page %d, version 0x%02X\n",
413 /* Scan a given block partially */
450 /* Check if a potential BBT block is marked as bad */
457 * No need to check for a bad BBT block if the BBM area overlaps with
458 * the bad block table marker area in OOB since writing a BBM here
459 * invalidates the bad block table marker anyway.
466 * There is no point in checking for a bad block marker if writing
480 * create_bbt - [GENERIC] Create a bad block table by scanning the device
483 * @bd: descriptor for the good/bad block search pattern
487 * Create a bad block table by scanning the device for the given good/bad block
538 * search_bbt - [GENERIC] scan the device for a specific bad block table
541 * @td: descriptor for the bad block table
543 * Read the bad block table by searching for a given ident pattern. Search is
545 * downwards. The search starts always at the start of a block. If the option
547 * the bad block information of this chip. This is necessary to provide support
550 * The bbt ident pattern resides in the oob area of the first page in a block.
558 int startblock, block, dir;
587 for (block = 0; block < td->maxblocks; block++) {
589 int actblock = startblock + dir * block;
592 /* Check if block is marked bad */
612 pr_warn("Bad block table not found for chip %d\n", i);
614 pr_info("Bad block table found at page %d, version 0x%02X\n",
621 * search_read_bbts - [GENERIC] scan the device for bad block table(s)
624 * @td: descriptor for the bad block table
625 * @md: descriptor for the bad block table mirror
627 * Search and read the bad block table(s).
648 * This functions returns a positive block number pointing a valid eraseblock
651 * pointing to a valid block we re-use it, otherwise we search for the next
674 * Automatic placement of the bad block table. Search direction
686 int block = startblock + dir * i;
688 /* Check, if the block is bad */
689 switch (bbt_get_entry(this, block)) {
695 page = block << (this->bbt_erase_shift - this->page_shift);
697 /* Check, if the block is used by the mirror table */
699 return block;
706 * mark_bbt_block_bad - Mark one of the block reserved for BBT bad
710 * @block: the BBT block to mark
714 * block as bad using a bad block marker and invalidating the associated
719 int chip, int block)
724 bbt_mark_entry(this, block, BBT_BLOCK_WORN);
726 to = (loff_t)block << this->bbt_erase_shift;
729 pr_warn("nand_bbt: error %d while marking block %d bad\n",
730 res, block);
736 * write_bbt - [GENERIC] (Re)write the bad block table
739 * @td: descriptor for the bad block table
740 * @md: descriptor for the bad block table mirror
743 * (Re)write the bad block table.
768 /* Write bad block table per chip rather than per device? */
785 int block;
787 block = get_bbt_block(this, td, md, chip);
788 if (block < 0) {
789 pr_err("No space left to write bad block table\n");
790 res = block;
795 * get_bbt_block() returns a block number, shift the value to
798 page = block << (this->bbt_erase_shift - this->page_shift);
821 /* Must we save the block contents? */
823 /* Make it block aligned */
829 pr_info("nand_bbt: error reading block for writing the bad block table\n");
832 pr_warn("nand_bbt: ECC error while reading block for writing bad block table\n");
894 pr_warn("nand_bbt: error while erasing BBT block %d\n",
896 mark_bbt_block_bad(this, td, chip, block);
904 pr_warn("nand_bbt: error while writing BBT block %d\n",
906 mark_bbt_block_bad(this, td, chip, block);
910 pr_info("Bad block table written to 0x%012llx, version 0x%02X\n",
919 pr_warn("nand_bbt: error while writing bad block table %d\n", res);
924 * nand_memory_bbt - [GENERIC] create a memory based bad block table
926 * @bd: descriptor for the good/bad block search pattern
943 * @bd: descriptor for the good/bad block search pattern
1004 /* Create the bad block table by scanning the device? */
1050 /* Write the bad block table to the device? */
1057 /* Write the mirror bad block table to the device? */
1068 * nand_update_bbt - update bad block table(s)
1070 * @offs: the offset of the newly marked block
1072 * The function updates the bad block table(s).
1106 /* Write the bad block table to the device? */
1112 /* Write the mirror bad block table to the device? */
1123 * mark_bbt_region - [GENERIC] mark the bad block table regions
1125 * @td: bad block table descriptor
1127 * The bad block table regions are marked as "bad" to prevent accidental
1134 int i, j, chips, block, nrblocks, update;
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 <<
1162 block = ((i + 1) * nrblocks) - td->maxblocks;
1164 block = i * nrblocks;
1166 oldval = bbt_get_entry(this, block);
1167 bbt_mark_entry(this, block, BBT_BLOCK_RESERVED);
1170 block++;
1178 nand_update_bbt(this, (loff_t)(block - 1) <<
1184 * verify_bbt_descr - verify the bad block description
1188 * This functions performs a few sanity checks on the bad block description
1233 * nand_scan_bbt - [NAND Interface] scan, find, read and maybe create bad block table(s)
1235 * @bd: descriptor for the good/bad block search pattern
1237 * The function checks, if a bad block table(s) is/are already available. If
1239 * the bad block table(s) to the selected place.
1241 * The bad block table memory is allocated here. It must be freed by calling
1254 * Allocate memory (2bit per block) and clear the memory bad block
1263 * memory based bad block table.
1288 /* Search the bad block table using a pattern in oob */
1313 * Define some generic bad / good block scan pattern which are used
1376 pr_warn("Bad block pattern already allocated; not replacing\n");
1392 * nand_create_bbt - [NAND Interface] Select a default bad block table for the device
1395 * This function selects the default bad block table support for the device and
1402 /* Is a flash based bad block table requested? */
1430 * nand_isreserved_bbt - [NAND Interface] Check if a block is reserved
1436 int block;
1438 block = (int)(offs >> this->bbt_erase_shift);
1439 return bbt_get_entry(this, block) == BBT_BLOCK_RESERVED;
1443 * nand_isbad_bbt - [NAND Interface] Check if a block is bad
1446 * @allowbbt: allow access to bad block table region
1450 int block, res;
1452 block = (int)(offs >> this->bbt_erase_shift);
1453 res = bbt_get_entry(this, block);
1455 pr_debug("nand_isbad_bbt(): bbt info for offs 0x%08x: (block %d) 0x%02x\n",
1456 (unsigned int)offs, block, res);
1473 * nand_markbad_bbt - [NAND Interface] Mark a block bad in the BBT
1475 * @offs: offset of the bad block
1479 int block, ret = 0;
1481 block = (int)(offs >> this->bbt_erase_shift);
1483 /* Mark bad block in memory */
1484 bbt_mark_entry(this, block, BBT_BLOCK_WORN);
1486 /* Update flash-based bad block table */