Lines Matching full:block

3  *   Bad block table support for the NAND driver
13 * When nand_scan_bbt is called, then it tries to find the bad block table
17 * Once a new bad block is discovered then the "factory" information is updated
24 * If the tables are not versioned, then we "or" the bad block information.
27 * good / bad blocks and the bad block tables are created.
32 * The auto generated bad block table is located in the last good blocks
41 * The table uses 2 bits per block
42 * 11b: block is good
43 * 00b: block is factory marked bad
44 * 01b, 10b: block is marked bad due to wear
46 * The memory bad block table uses the following scheme:
47 * 00b: block is good
48 * 01b: block is marked bad due to wear
49 * 10b: block is reserved (to protect the bbt area)
50 * 11b: block is factory marked bad
52 * Multichip devices like DOC store the bad block info per floor.
55 * - bbts start at a page boundary, if autolocated on a block boundary
56 * - the space necessary for a bbt in FLASH does not exceed a block boundary
79 static inline uint8_t bbt_get_entry(struct nand_chip *chip, int block) in bbt_get_entry() argument
81 uint8_t entry = chip->bbt[block >> BBT_ENTRY_SHIFT]; in bbt_get_entry()
82 entry >>= (block & BBT_ENTRY_MASK) * 2; in bbt_get_entry()
86 static inline void bbt_mark_entry(struct nand_chip *chip, int block, in bbt_mark_entry() argument
89 uint8_t msk = (mark & BBT_ENTRY_MASK) << ((block & BBT_ENTRY_MASK) * 2); in bbt_mark_entry()
90 chip->bbt[block >> BBT_ENTRY_SHIFT] |= msk; in bbt_mark_entry()
107 * Check for a pattern at the given place. Used to search bad block tables and
108 * good / bad block identifiers.
127 * Check for a pattern at the given place. Used to search bad block tables and
128 * good / bad block identifiers. Same as check_pattern, but no optional empty
159 * read_bbt - [GENERIC] Read the bad block table starting from page
165 * @offs: block number offset in the table
167 * Read the bad block table starting from page.
220 pr_info("nand_read_bbt: reserved block at 0x%012llx\n", in read_bbt()
232 pr_info("nand_read_bbt: bad block at 0x%012llx\n", in read_bbt()
252 * read_abs_bbt - [GENERIC] Read the bad block table starting at a given page
255 * @td: descriptor for the bad block table
259 * Read the bad block table for all chips starting at a given page. We assume
377 * read_abs_bbts - [GENERIC] Read the bad block table(s) for all chips starting at a given page
380 * @td: descriptor for the bad block table
381 * @md: descriptor for the bad block table mirror
383 * Read the bad block table(s) for all chips starting at a given page. We
396 pr_info("Bad block table at page %d, version 0x%02X\n", in read_abs_bbts()
405 pr_info("Bad block table at page %d, version 0x%02X\n", in read_abs_bbts()
410 /* Scan a given block partially */
442 * create_bbt - [GENERIC] Create a bad block table by scanning the device
445 * @bd: descriptor for the good/bad block search pattern
449 * Create a bad block table by scanning the device for the given good/bad block
508 * search_bbt - [GENERIC] scan the device for a specific bad block table
511 * @td: descriptor for the bad block table
513 * Read the bad block table by searching for a given ident pattern. Search is
515 * downwards. The search starts always at the start of a block. If the option
517 * the bad block information of this chip. This is necessary to provide support
520 * The bbt ident pattern resides in the oob area of the first page in a block.
526 int startblock, block, dir; in search_bbt() local
555 for (block = 0; block < td->maxblocks; block++) { in search_bbt()
557 int actblock = startblock + dir * block; in search_bbt()
576 pr_warn("Bad block table not found for chip %d\n", i); in search_bbt()
578 pr_info("Bad block table found at page %d, version 0x%02X\n", in search_bbt()
585 * search_read_bbts - [GENERIC] scan the device for bad block table(s)
588 * @td: descriptor for the bad block table
589 * @md: descriptor for the bad block table mirror
591 * Search and read the bad block table(s).
606 * write_bbt - [GENERIC] (Re)write the bad block table
609 * @td: descriptor for the bad block table
610 * @md: descriptor for the bad block table mirror
613 * (Re)write the bad block table.
637 /* Write bad block table per chip rather than per device? */ in write_bbt()
665 * Automatic placement of the bad block table. Search direction in write_bbt()
677 int block = startblock + dir * i; in write_bbt() local
678 /* Check, if the block is bad */ in write_bbt()
679 switch (bbt_get_entry(this, block)) { in write_bbt()
684 page = block << in write_bbt()
686 /* Check, if the block is used by the mirror table */ in write_bbt()
690 pr_err("No space left to write bad block table\n"); in write_bbt()
715 /* Must we save the block contents? */ in write_bbt()
717 /* Make it block aligned */ in write_bbt()
723 pr_info("nand_bbt: error reading block for writing the bad block table\n"); in write_bbt()
726 pr_warn("nand_bbt: ECC error while reading block for writing bad block table\n"); in write_bbt()
797 pr_info("Bad block table written to 0x%012llx, version 0x%02X\n", in write_bbt()
806 pr_warn("nand_bbt: error while writing bad block table %d\n", res); in write_bbt()
811 * nand_memory_bbt - [GENERIC] create a memory based bad block table
813 * @bd: descriptor for the good/bad block search pattern
829 * @bd: descriptor for the good/bad block search pattern
890 /* Create the bad block table by scanning the device? */ in check_create()
936 /* Write the bad block table to the device? */ in check_create()
943 /* Write the mirror bad block table to the device? */ in check_create()
954 * mark_bbt_regions - [GENERIC] mark the bad block table regions
956 * @td: bad block table descriptor
958 * The bad block table regions are marked as "bad" to prevent accidental
964 int i, j, chips, block, nrblocks, update; in mark_bbt_region() local
981 block = td->pages[i] >> (this->bbt_erase_shift - this->page_shift); in mark_bbt_region()
982 oldval = bbt_get_entry(this, block); in mark_bbt_region()
983 bbt_mark_entry(this, block, BBT_BLOCK_RESERVED); in mark_bbt_region()
986 nand_update_bbt(mtd, (loff_t)block << in mark_bbt_region()
992 block = ((i + 1) * nrblocks) - td->maxblocks; in mark_bbt_region()
994 block = i * nrblocks; in mark_bbt_region()
996 oldval = bbt_get_entry(this, block); in mark_bbt_region()
997 bbt_mark_entry(this, block, BBT_BLOCK_RESERVED); in mark_bbt_region()
1000 block++; in mark_bbt_region()
1008 nand_update_bbt(mtd, (loff_t)(block - 1) << in mark_bbt_region()
1014 * verify_bbt_descr - verify the bad block description
1018 * This functions performs a few sanity checks on the bad block description
1062 * nand_scan_bbt - [NAND Interface] scan, find, read and maybe create bad block table(s)
1064 * @bd: descriptor for the good/bad block search pattern
1066 * The function checks, if a bad block table(s) is/are already available. If
1068 * the bad block table(s) to the selected place.
1070 * The bad block table memory is allocated here. It must be freed by calling
1083 * Allocate memory (2bit per block) and clear the memory bad block in nand_scan_bbt()
1092 * memory based bad block table. in nand_scan_bbt()
1117 /* Search the bad block table using a pattern in oob */ in nand_scan_bbt()
1140 * nand_update_bbt - update bad block table(s)
1142 * @offs: the offset of the newly marked block
1144 * The function updates the bad block table(s).
1178 /* Write the bad block table to the device? */ in nand_update_bbt()
1184 /* Write the mirror bad block table to the device? */ in nand_update_bbt()
1195 * Define some generic bad / good block scan pattern which are used
1258 pr_warn("Bad block pattern already allocated; not replacing\n"); in nand_create_badblock_pattern()
1274 * nand_default_bbt - [NAND Interface] Select a default bad block table for the device
1277 * This function selects the default bad block table support for the device and
1285 /* Is a flash based bad block table requested? */ in nand_default_bbt()
1312 * nand_isreserved_bbt - [NAND Interface] Check if a block is reserved
1319 int block; in nand_isreserved_bbt() local
1321 block = (int)(offs >> this->bbt_erase_shift); in nand_isreserved_bbt()
1322 return bbt_get_entry(this, block) == BBT_BLOCK_RESERVED; in nand_isreserved_bbt()
1326 * nand_isbad_bbt - [NAND Interface] Check if a block is bad
1329 * @allowbbt: allow access to bad block table region
1334 int block, res; in nand_isbad_bbt() local
1336 block = (int)(offs >> this->bbt_erase_shift); in nand_isbad_bbt()
1337 res = bbt_get_entry(this, block); in nand_isbad_bbt()
1339 pr_debug("nand_isbad_bbt(): bbt info for offs 0x%08x: (block %d) 0x%02x\n", in nand_isbad_bbt()
1340 (unsigned int)offs, block, res); in nand_isbad_bbt()
1354 * nand_markbad_bbt - [NAND Interface] Mark a block bad in the BBT
1356 * @offs: offset of the bad block
1361 int block, ret = 0; in nand_markbad_bbt() local
1363 block = (int)(offs >> this->bbt_erase_shift); in nand_markbad_bbt()
1365 /* Mark bad block in memory */ in nand_markbad_bbt()
1366 bbt_mark_entry(this, block, BBT_BLOCK_WORN); in nand_markbad_bbt()
1368 /* Update flash-based bad block table */ in nand_markbad_bbt()