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