OMAP3: SR: Fix init voltage on OPP change
[linux-ginger.git] / include / linux / mtd / bbm.h
blobfff8c53e54341a106592f210fe8fc78bfb170967
1 /*
2 * linux/include/linux/mtd/bbm.h
4 * NAND family Bad Block Management (BBM) header file
5 * - Bad Block Table (BBT) implementation
7 * Copyright (c) 2005 Samsung Electronics
8 * Kyungmin Park <kyungmin.park@samsung.com>
10 * Copyright (c) 2000-2005
11 * Thomas Gleixner <tglx@linuxtronix.de>
14 #ifndef __LINUX_MTD_BBM_H
15 #define __LINUX_MTD_BBM_H
17 /* The maximum number of NAND chips in an array */
18 #define NAND_MAX_CHIPS 8
20 /**
21 * struct nand_bbt_descr - bad block table descriptor
22 * @options: options for this descriptor
23 * @pages: the page(s) where we find the bbt, used with
24 * option BBT_ABSPAGE when bbt is searched,
25 * then we store the found bbts pages here.
26 * Its an array and supports up to 8 chips now
27 * @offs: offset of the pattern in the oob area of the page
28 * @veroffs: offset of the bbt version counter in the oob area of the page
29 * @version: version read from the bbt page during scan
30 * @len: length of the pattern, if 0 no pattern check is performed
31 * @maxblocks: maximum number of blocks to search for a bbt. This
32 * number of blocks is reserved at the end of the device
33 * where the tables are written.
34 * @reserved_block_code: if non-0, this pattern denotes a reserved
35 * (rather than bad) block in the stored bbt
36 * @pattern: pattern to identify bad block table or factory marked
37 * good / bad blocks, can be NULL, if len = 0
39 * Descriptor for the bad block table marker and the descriptor for the
40 * pattern which identifies good and bad blocks. The assumption is made
41 * that the pattern and the version count are always located in the oob area
42 * of the first block.
44 struct nand_bbt_descr {
45 int options;
46 int pages[NAND_MAX_CHIPS];
47 int offs;
48 int veroffs;
49 uint8_t version[NAND_MAX_CHIPS];
50 int len;
51 int maxblocks;
52 int reserved_block_code;
53 uint8_t *pattern;
56 /* Options for the bad block table descriptors */
58 /* The number of bits used per block in the bbt on the device */
59 #define NAND_BBT_NRBITS_MSK 0x0000000F
60 #define NAND_BBT_1BIT 0x00000001
61 #define NAND_BBT_2BIT 0x00000002
62 #define NAND_BBT_4BIT 0x00000004
63 #define NAND_BBT_8BIT 0x00000008
64 /* The bad block table is in the last good block of the device */
65 #define NAND_BBT_LASTBLOCK 0x00000010
66 /* The bbt is at the given page, else we must scan for the bbt */
67 #define NAND_BBT_ABSPAGE 0x00000020
68 /* The bbt is at the given page, else we must scan for the bbt */
69 #define NAND_BBT_SEARCH 0x00000040
70 /* bbt is stored per chip on multichip devices */
71 #define NAND_BBT_PERCHIP 0x00000080
72 /* bbt has a version counter at offset veroffs */
73 #define NAND_BBT_VERSION 0x00000100
74 /* Create a bbt if none axists */
75 #define NAND_BBT_CREATE 0x00000200
76 /* Search good / bad pattern through all pages of a block */
77 #define NAND_BBT_SCANALLPAGES 0x00000400
78 /* Scan block empty during good / bad block scan */
79 #define NAND_BBT_SCANEMPTY 0x00000800
80 /* Write bbt if neccecary */
81 #define NAND_BBT_WRITE 0x00001000
82 /* Read and write back block contents when writing bbt */
83 #define NAND_BBT_SAVECONTENT 0x00002000
84 /* Search good / bad pattern on the first and the second page */
85 #define NAND_BBT_SCAN2NDPAGE 0x00004000
87 /* The maximum number of blocks to scan for a bbt */
88 #define NAND_BBT_SCAN_MAXBLOCKS 4
91 * Constants for oob configuration
93 #define ONENAND_BADBLOCK_POS 0
96 * Bad block scanning errors
98 #define ONENAND_BBT_READ_ERROR 1
99 #define ONENAND_BBT_READ_ECC_ERROR 2
100 #define ONENAND_BBT_READ_FATAL_ERROR 4
103 * struct bbm_info - [GENERIC] Bad Block Table data structure
104 * @bbt_erase_shift: [INTERN] number of address bits in a bbt entry
105 * @badblockpos: [INTERN] position of the bad block marker in the oob area
106 * @options: options for this descriptor
107 * @bbt: [INTERN] bad block table pointer
108 * @isbad_bbt: function to determine if a block is bad
109 * @badblock_pattern: [REPLACEABLE] bad block scan pattern used for
110 * initial bad block scan
111 * @priv: [OPTIONAL] pointer to private bbm date
113 struct bbm_info {
114 int bbt_erase_shift;
115 int badblockpos;
116 int options;
118 uint8_t *bbt;
120 int (*isbad_bbt)(struct mtd_info *mtd, loff_t ofs, int allowbbt);
122 /* TODO Add more NAND specific fileds */
123 struct nand_bbt_descr *badblock_pattern;
125 void *priv;
128 /* OneNAND BBT interface */
129 extern int onenand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd);
130 extern int onenand_default_bbt(struct mtd_info *mtd);
132 #endif /* __LINUX_MTD_BBM_H */