diff options
Diffstat (limited to 'include/mtd/mtd-abi.h')
-rw-r--r-- | include/mtd/mtd-abi.h | 90 |
1 files changed, 64 insertions, 26 deletions
diff --git a/include/mtd/mtd-abi.h b/include/mtd/mtd-abi.h index b5994ea56a5a..ee2afbaefe1b 100644 --- a/include/mtd/mtd-abi.h +++ b/include/mtd/mtd-abi.h | |||
@@ -28,28 +28,17 @@ struct mtd_oob_buf { | |||
28 | #define MTD_ROM 2 | 28 | #define MTD_ROM 2 |
29 | #define MTD_NORFLASH 3 | 29 | #define MTD_NORFLASH 3 |
30 | #define MTD_NANDFLASH 4 | 30 | #define MTD_NANDFLASH 4 |
31 | #define MTD_PEROM 5 | ||
32 | #define MTD_DATAFLASH 6 | 31 | #define MTD_DATAFLASH 6 |
33 | #define MTD_OTHER 14 | 32 | |
34 | #define MTD_UNKNOWN 15 | 33 | #define MTD_WRITEABLE 0x400 /* Device is writeable */ |
35 | 34 | #define MTD_BIT_WRITEABLE 0x800 /* Single bits can be flipped */ | |
36 | #define MTD_CLEAR_BITS 1 // Bits can be cleared (flash) | 35 | #define MTD_NO_ERASE 0x1000 /* No erase necessary */ |
37 | #define MTD_SET_BITS 2 // Bits can be set | ||
38 | #define MTD_ERASEABLE 4 // Has an erase function | ||
39 | #define MTD_WRITEB_WRITEABLE 8 // Direct IO is possible | ||
40 | #define MTD_VOLATILE 16 // Set for RAMs | ||
41 | #define MTD_XIP 32 // eXecute-In-Place possible | ||
42 | #define MTD_OOB 64 // Out-of-band data (NAND flash) | ||
43 | #define MTD_ECC 128 // Device capable of automatic ECC | ||
44 | #define MTD_NO_VIRTBLOCKS 256 // Virtual blocks not allowed | ||
45 | #define MTD_PROGRAM_REGIONS 512 // Configurable Programming Regions | ||
46 | 36 | ||
47 | // Some common devices / combinations of capabilities | 37 | // Some common devices / combinations of capabilities |
48 | #define MTD_CAP_ROM 0 | 38 | #define MTD_CAP_ROM 0 |
49 | #define MTD_CAP_RAM (MTD_CLEAR_BITS|MTD_SET_BITS|MTD_WRITEB_WRITEABLE) | 39 | #define MTD_CAP_RAM (MTD_WRITEABLE | MTD_BIT_WRITEABLE | MTD_NO_ERASE) |
50 | #define MTD_CAP_NORFLASH (MTD_CLEAR_BITS|MTD_ERASEABLE) | 40 | #define MTD_CAP_NORFLASH (MTD_WRITEABLE | MTD_BIT_WRITEABLE) |
51 | #define MTD_CAP_NANDFLASH (MTD_CLEAR_BITS|MTD_ERASEABLE|MTD_OOB) | 41 | #define MTD_CAP_NANDFLASH (MTD_WRITEABLE) |
52 | #define MTD_WRITEABLE (MTD_CLEAR_BITS|MTD_SET_BITS) | ||
53 | 42 | ||
54 | 43 | ||
55 | // Types of automatic ECC/Checksum available | 44 | // Types of automatic ECC/Checksum available |
@@ -74,7 +63,7 @@ struct mtd_info_user { | |||
74 | uint32_t flags; | 63 | uint32_t flags; |
75 | uint32_t size; // Total size of the MTD | 64 | uint32_t size; // Total size of the MTD |
76 | uint32_t erasesize; | 65 | uint32_t erasesize; |
77 | uint32_t oobblock; // Size of OOB blocks (e.g. 512) | 66 | uint32_t writesize; |
78 | uint32_t oobsize; // Amount of OOB data per block (e.g. 16) | 67 | uint32_t oobsize; // Amount of OOB data per block (e.g. 16) |
79 | uint32_t ecctype; | 68 | uint32_t ecctype; |
80 | uint32_t eccsize; | 69 | uint32_t eccsize; |
@@ -94,12 +83,12 @@ struct otp_info { | |||
94 | uint32_t locked; | 83 | uint32_t locked; |
95 | }; | 84 | }; |
96 | 85 | ||
97 | #define MEMGETINFO _IOR('M', 1, struct mtd_info_user) | 86 | #define MEMGETINFO _IOR('M', 1, struct mtd_info_user) |
98 | #define MEMERASE _IOW('M', 2, struct erase_info_user) | 87 | #define MEMERASE _IOW('M', 2, struct erase_info_user) |
99 | #define MEMWRITEOOB _IOWR('M', 3, struct mtd_oob_buf) | 88 | #define MEMWRITEOOB _IOWR('M', 3, struct mtd_oob_buf) |
100 | #define MEMREADOOB _IOWR('M', 4, struct mtd_oob_buf) | 89 | #define MEMREADOOB _IOWR('M', 4, struct mtd_oob_buf) |
101 | #define MEMLOCK _IOW('M', 5, struct erase_info_user) | 90 | #define MEMLOCK _IOW('M', 5, struct erase_info_user) |
102 | #define MEMUNLOCK _IOW('M', 6, struct erase_info_user) | 91 | #define MEMUNLOCK _IOW('M', 6, struct erase_info_user) |
103 | #define MEMGETREGIONCOUNT _IOR('M', 7, int) | 92 | #define MEMGETREGIONCOUNT _IOR('M', 7, int) |
104 | #define MEMGETREGIONINFO _IOWR('M', 8, struct region_info_user) | 93 | #define MEMGETREGIONINFO _IOWR('M', 8, struct region_info_user) |
105 | #define MEMSETOOBSEL _IOW('M', 9, struct nand_oobinfo) | 94 | #define MEMSETOOBSEL _IOW('M', 9, struct nand_oobinfo) |
@@ -109,8 +98,15 @@ struct otp_info { | |||
109 | #define OTPSELECT _IOR('M', 13, int) | 98 | #define OTPSELECT _IOR('M', 13, int) |
110 | #define OTPGETREGIONCOUNT _IOW('M', 14, int) | 99 | #define OTPGETREGIONCOUNT _IOW('M', 14, int) |
111 | #define OTPGETREGIONINFO _IOW('M', 15, struct otp_info) | 100 | #define OTPGETREGIONINFO _IOW('M', 15, struct otp_info) |
112 | #define OTPLOCK _IOR('M', 16, struct otp_info) | 101 | #define OTPLOCK _IOR('M', 16, struct otp_info) |
102 | #define ECCGETLAYOUT _IOR('M', 17, struct nand_ecclayout) | ||
103 | #define ECCGETSTATS _IOR('M', 18, struct mtd_ecc_stats) | ||
104 | #define MTDFILEMODE _IO('M', 19) | ||
113 | 105 | ||
106 | /* | ||
107 | * Obsolete legacy interface. Keep it in order not to break userspace | ||
108 | * interfaces | ||
109 | */ | ||
114 | struct nand_oobinfo { | 110 | struct nand_oobinfo { |
115 | uint32_t useecc; | 111 | uint32_t useecc; |
116 | uint32_t eccbytes; | 112 | uint32_t eccbytes; |
@@ -118,4 +114,46 @@ struct nand_oobinfo { | |||
118 | uint32_t eccpos[32]; | 114 | uint32_t eccpos[32]; |
119 | }; | 115 | }; |
120 | 116 | ||
117 | struct nand_oobfree { | ||
118 | uint32_t offset; | ||
119 | uint32_t length; | ||
120 | }; | ||
121 | |||
122 | #define MTD_MAX_OOBFREE_ENTRIES 8 | ||
123 | /* | ||
124 | * ECC layout control structure. Exported to userspace for | ||
125 | * diagnosis and to allow creation of raw images | ||
126 | */ | ||
127 | struct nand_ecclayout { | ||
128 | uint32_t eccbytes; | ||
129 | uint32_t eccpos[64]; | ||
130 | uint32_t oobavail; | ||
131 | struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES]; | ||
132 | }; | ||
133 | |||
134 | /** | ||
135 | * struct mtd_ecc_stats - error correction status | ||
136 | * | ||
137 | * @corrected: number of corrected bits | ||
138 | * @failed: number of uncorrectable errors | ||
139 | * @badblocks: number of bad blocks in this partition | ||
140 | * @bbtblocks: number of blocks reserved for bad block tables | ||
141 | */ | ||
142 | struct mtd_ecc_stats { | ||
143 | uint32_t corrected; | ||
144 | uint32_t failed; | ||
145 | uint32_t badblocks; | ||
146 | uint32_t bbtblocks; | ||
147 | }; | ||
148 | |||
149 | /* | ||
150 | * Read/write file modes for access to MTD | ||
151 | */ | ||
152 | enum mtd_file_modes { | ||
153 | MTD_MODE_NORMAL = MTD_OTP_OFF, | ||
154 | MTD_MODE_OTP_FACTORY = MTD_OTP_FACTORY, | ||
155 | MTD_MODE_OTP_USER = MTD_OTP_USER, | ||
156 | MTD_MODE_RAW, | ||
157 | }; | ||
158 | |||
121 | #endif /* __MTD_ABI_H__ */ | 159 | #endif /* __MTD_ABI_H__ */ |