1 /*
2 * This header was generated from the Linux kernel headers by update_headers.py,
3 * to provide necessary information from kernel to userspace, such as constants,
4 * structures, and macros, and thus, contains no copyrightable information.
5 */
6 #ifndef __MTD_ABI_H__
7 #define __MTD_ABI_H__
8 #include <linux/types.h>
9 struct erase_info_user {
10 __u32 start;
11 __u32 length;
12 };
13 struct erase_info_user64 {
14 __u64 start;
15 __u64 length;
16 };
17 struct mtd_oob_buf {
18 __u32 start;
19 __u32 length;
20 unsigned char __user *ptr;
21 };
22 struct mtd_oob_buf64 {
23 __u64 start;
24 __u32 pad;
25 __u32 length;
26 __u64 usr_ptr;
27 };
28 enum {
29 MTD_OPS_PLACE_OOB = 0,
30 MTD_OPS_AUTO_OOB = 1,
31 MTD_OPS_RAW = 2,
32 };
33 struct mtd_write_req {
34 __u64 start;
35 __u64 len;
36 __u64 ooblen;
37 __u64 usr_data;
38 __u64 usr_oob;
39 __u8 mode;
40 __u8 padding[7];
41 };
42 #define MTD_ABSENT 0
43 #define MTD_RAM 1
44 #define MTD_ROM 2
45 #define MTD_NORFLASH 3
46 #define MTD_NANDFLASH 4
47 #define MTD_DATAFLASH 6
48 #define MTD_UBIVOLUME 7
49 #define MTD_MLCNANDFLASH 8
50 #define MTD_WRITEABLE 0x400
51 #define MTD_BIT_WRITEABLE 0x800
52 #define MTD_NO_ERASE 0x1000
53 #define MTD_POWERUP_LOCK 0x2000
54 #define MTD_CAP_ROM 0
55 #define MTD_CAP_RAM (MTD_WRITEABLE | MTD_BIT_WRITEABLE | MTD_NO_ERASE)
56 #define MTD_CAP_NORFLASH (MTD_WRITEABLE | MTD_BIT_WRITEABLE)
57 #define MTD_CAP_NANDFLASH (MTD_WRITEABLE)
58 #define MTD_CAP_NVRAM (MTD_WRITEABLE | MTD_BIT_WRITEABLE | MTD_NO_ERASE)
59 #define MTD_NANDECC_OFF 0
60 #define MTD_NANDECC_PLACE 1
61 #define MTD_NANDECC_AUTOPLACE 2
62 #define MTD_NANDECC_PLACEONLY 3
63 #define MTD_NANDECC_AUTOPL_USR 4
64 #define MTD_OTP_OFF 0
65 #define MTD_OTP_FACTORY 1
66 #define MTD_OTP_USER 2
67 struct mtd_info_user {
68 __u8 type;
69 __u32 flags;
70 __u32 size;
71 __u32 erasesize;
72 __u32 writesize;
73 __u32 oobsize;
74 __u64 padding;
75 };
76 struct region_info_user {
77 __u32 offset;
78 __u32 erasesize;
79 __u32 numblocks;
80 __u32 regionindex;
81 };
82 struct otp_info {
83 __u32 start;
84 __u32 length;
85 __u32 locked;
86 };
87 #define MEMGETINFO _IOR('M', 1, struct mtd_info_user)
88 #define MEMERASE _IOW('M', 2, struct erase_info_user)
89 #define MEMWRITEOOB _IOWR('M', 3, struct mtd_oob_buf)
90 #define MEMREADOOB _IOWR('M', 4, struct mtd_oob_buf)
91 #define MEMLOCK _IOW('M', 5, struct erase_info_user)
92 #define MEMUNLOCK _IOW('M', 6, struct erase_info_user)
93 #define MEMGETREGIONCOUNT _IOR('M', 7, int)
94 #define MEMGETREGIONINFO _IOWR('M', 8, struct region_info_user)
95 #define MEMGETOOBSEL _IOR('M', 10, struct nand_oobinfo)
96 #define MEMGETBADBLOCK _IOW('M', 11, __kernel_loff_t)
97 #define MEMSETBADBLOCK _IOW('M', 12, __kernel_loff_t)
98 #define OTPSELECT _IOR('M', 13, int)
99 #define OTPGETREGIONCOUNT _IOW('M', 14, int)
100 #define OTPGETREGIONINFO _IOW('M', 15, struct otp_info)
101 #define OTPLOCK _IOR('M', 16, struct otp_info)
102 #define ECCGETLAYOUT _IOR('M', 17, struct nand_ecclayout_user)
103 #define ECCGETSTATS _IOR('M', 18, struct mtd_ecc_stats)
104 #define MTDFILEMODE _IO('M', 19)
105 #define MEMERASE64 _IOW('M', 20, struct erase_info_user64)
106 #define MEMWRITEOOB64 _IOWR('M', 21, struct mtd_oob_buf64)
107 #define MEMREADOOB64 _IOWR('M', 22, struct mtd_oob_buf64)
108 #define MEMISLOCKED _IOR('M', 23, struct erase_info_user)
109 #define MEMWRITE _IOWR('M', 24, struct mtd_write_req)
110 struct nand_oobinfo {
111 __u32 useecc;
112 __u32 eccbytes;
113 __u32 oobfree[8][2];
114 __u32 eccpos[32];
115 };
116 struct nand_oobfree {
117 __u32 offset;
118 __u32 length;
119 };
120 #define MTD_MAX_OOBFREE_ENTRIES 8
121 #define MTD_MAX_ECCPOS_ENTRIES 64
122 struct nand_ecclayout_user {
123 __u32 eccbytes;
124 __u32 eccpos[MTD_MAX_ECCPOS_ENTRIES];
125 __u32 oobavail;
126 struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES];
127 };
128 struct mtd_ecc_stats {
129 __u32 corrected;
130 __u32 failed;
131 __u32 badblocks;
132 __u32 bbtblocks;
133 };
134 enum mtd_file_modes {
135 MTD_FILE_MODE_NORMAL = MTD_OTP_OFF,
136 MTD_FILE_MODE_OTP_FACTORY = MTD_OTP_FACTORY,
137 MTD_FILE_MODE_OTP_USER = MTD_OTP_USER,
138 MTD_FILE_MODE_RAW,
139 };
mtd_type_is_nand_user(const struct mtd_info_user * mtd)140 static inline int mtd_type_is_nand_user(const struct mtd_info_user *mtd)
141 {
142 return mtd->type == MTD_NANDFLASH || mtd->type == MTD_MLCNANDFLASH;
143 }
144 #endif
145