![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0-or-later */ 0002 /* 0003 * NAND family Bad Block Management (BBM) header file 0004 * - Bad Block Table (BBT) implementation 0005 * 0006 * Copyright © 2005 Samsung Electronics 0007 * Kyungmin Park <kyungmin.park@samsung.com> 0008 * 0009 * Copyright © 2000-2005 0010 * Thomas Gleixner <tglx@linuxtronix.de> 0011 */ 0012 #ifndef __LINUX_MTD_BBM_H 0013 #define __LINUX_MTD_BBM_H 0014 0015 /* The maximum number of NAND chips in an array */ 0016 #define NAND_MAX_CHIPS 8 0017 0018 /** 0019 * struct nand_bbt_descr - bad block table descriptor 0020 * @options: options for this descriptor 0021 * @pages: the page(s) where we find the bbt, used with option BBT_ABSPAGE 0022 * when bbt is searched, then we store the found bbts pages here. 0023 * Its an array and supports up to 8 chips now 0024 * @offs: offset of the pattern in the oob area of the page 0025 * @veroffs: offset of the bbt version counter in the oob are of the page 0026 * @version: version read from the bbt page during scan 0027 * @len: length of the pattern, if 0 no pattern check is performed 0028 * @maxblocks: maximum number of blocks to search for a bbt. This number of 0029 * blocks is reserved at the end of the device where the tables are 0030 * written. 0031 * @reserved_block_code: if non-0, this pattern denotes a reserved (rather than 0032 * bad) block in the stored bbt 0033 * @pattern: pattern to identify bad block table or factory marked good / 0034 * bad blocks, can be NULL, if len = 0 0035 * 0036 * Descriptor for the bad block table marker and the descriptor for the 0037 * pattern which identifies good and bad blocks. The assumption is made 0038 * that the pattern and the version count are always located in the oob area 0039 * of the first block. 0040 */ 0041 struct nand_bbt_descr { 0042 int options; 0043 int pages[NAND_MAX_CHIPS]; 0044 int offs; 0045 int veroffs; 0046 uint8_t version[NAND_MAX_CHIPS]; 0047 int len; 0048 int maxblocks; 0049 int reserved_block_code; 0050 uint8_t *pattern; 0051 }; 0052 0053 /* Options for the bad block table descriptors */ 0054 0055 /* The number of bits used per block in the bbt on the device */ 0056 #define NAND_BBT_NRBITS_MSK 0x0000000F 0057 #define NAND_BBT_1BIT 0x00000001 0058 #define NAND_BBT_2BIT 0x00000002 0059 #define NAND_BBT_4BIT 0x00000004 0060 #define NAND_BBT_8BIT 0x00000008 0061 /* The bad block table is in the last good block of the device */ 0062 #define NAND_BBT_LASTBLOCK 0x00000010 0063 /* The bbt is at the given page, else we must scan for the bbt */ 0064 #define NAND_BBT_ABSPAGE 0x00000020 0065 /* bbt is stored per chip on multichip devices */ 0066 #define NAND_BBT_PERCHIP 0x00000080 0067 /* bbt has a version counter at offset veroffs */ 0068 #define NAND_BBT_VERSION 0x00000100 0069 /* Create a bbt if none exists */ 0070 #define NAND_BBT_CREATE 0x00000200 0071 /* 0072 * Create an empty BBT with no vendor information. Vendor's information may be 0073 * unavailable, for example, if the NAND controller has a different data and OOB 0074 * layout or if this information is already purged. Must be used in conjunction 0075 * with NAND_BBT_CREATE. 0076 */ 0077 #define NAND_BBT_CREATE_EMPTY 0x00000400 0078 /* Write bbt if neccecary */ 0079 #define NAND_BBT_WRITE 0x00002000 0080 /* Read and write back block contents when writing bbt */ 0081 #define NAND_BBT_SAVECONTENT 0x00004000 0082 0083 /* 0084 * Use a flash based bad block table. By default, OOB identifier is saved in 0085 * OOB area. This option is passed to the default bad block table function. 0086 */ 0087 #define NAND_BBT_USE_FLASH 0x00020000 0088 /* 0089 * Do not store flash based bad block table marker in the OOB area; store it 0090 * in-band. 0091 */ 0092 #define NAND_BBT_NO_OOB 0x00040000 0093 /* 0094 * Do not write new bad block markers to OOB; useful, e.g., when ECC covers 0095 * entire spare area. Must be used with NAND_BBT_USE_FLASH. 0096 */ 0097 #define NAND_BBT_NO_OOB_BBM 0x00080000 0098 0099 /* 0100 * Flag set by nand_create_default_bbt_descr(), marking that the nand_bbt_descr 0101 * was allocated dynamicaly and must be freed in nand_cleanup(). Has no meaning 0102 * in nand_chip.bbt_options. 0103 */ 0104 #define NAND_BBT_DYNAMICSTRUCT 0x80000000 0105 0106 /* The maximum number of blocks to scan for a bbt */ 0107 #define NAND_BBT_SCAN_MAXBLOCKS 4 0108 0109 /* 0110 * Bad block scanning errors 0111 */ 0112 #define ONENAND_BBT_READ_ERROR 1 0113 #define ONENAND_BBT_READ_ECC_ERROR 2 0114 #define ONENAND_BBT_READ_FATAL_ERROR 4 0115 0116 /** 0117 * struct bbm_info - [GENERIC] Bad Block Table data structure 0118 * @bbt_erase_shift: [INTERN] number of address bits in a bbt entry 0119 * @options: options for this descriptor 0120 * @bbt: [INTERN] bad block table pointer 0121 * @isbad_bbt: function to determine if a block is bad 0122 * @badblock_pattern: [REPLACEABLE] bad block scan pattern used for 0123 * initial bad block scan 0124 * @priv: [OPTIONAL] pointer to private bbm date 0125 */ 0126 struct bbm_info { 0127 int bbt_erase_shift; 0128 int options; 0129 0130 uint8_t *bbt; 0131 0132 int (*isbad_bbt)(struct mtd_info *mtd, loff_t ofs, int allowbbt); 0133 0134 /* TODO Add more NAND specific fileds */ 0135 struct nand_bbt_descr *badblock_pattern; 0136 0137 void *priv; 0138 }; 0139 0140 /* OneNAND BBT interface */ 0141 extern int onenand_default_bbt(struct mtd_info *mtd); 0142 0143 #endif /* __LINUX_MTD_BBM_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |