• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * This file is auto-generated. Modifications will be lost.
3  *
4  * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/
5  * for more information.
6  */
7 #ifndef __MTD_ABI_H__
8 #define __MTD_ABI_H__
9 #include <linux/types.h>
10 struct erase_info_user {
11   __u32 start;
12   __u32 length;
13 };
14 struct erase_info_user64 {
15   __u64 start;
16   __u64 length;
17 };
18 struct mtd_oob_buf {
19   __u32 start;
20   __u32 length;
21   unsigned char  * ptr;
22 };
23 struct mtd_oob_buf64 {
24   __u64 start;
25   __u32 pad;
26   __u32 length;
27   __u64 usr_ptr;
28 };
29 enum {
30   MTD_OPS_PLACE_OOB = 0,
31   MTD_OPS_AUTO_OOB = 1,
32   MTD_OPS_RAW = 2,
33 };
34 struct mtd_write_req {
35   __u64 start;
36   __u64 len;
37   __u64 ooblen;
38   __u64 usr_data;
39   __u64 usr_oob;
40   __u8 mode;
41   __u8 padding[7];
42 };
43 struct mtd_read_req_ecc_stats {
44   __u32 uncorrectable_errors;
45   __u32 corrected_bitflips;
46   __u32 max_bitflips;
47 };
48 struct mtd_read_req {
49   __u64 start;
50   __u64 len;
51   __u64 ooblen;
52   __u64 usr_data;
53   __u64 usr_oob;
54   __u8 mode;
55   __u8 padding[7];
56   struct mtd_read_req_ecc_stats ecc_stats;
57 };
58 #define MTD_ABSENT 0
59 #define MTD_RAM 1
60 #define MTD_ROM 2
61 #define MTD_NORFLASH 3
62 #define MTD_NANDFLASH 4
63 #define MTD_DATAFLASH 6
64 #define MTD_UBIVOLUME 7
65 #define MTD_MLCNANDFLASH 8
66 #define MTD_WRITEABLE 0x400
67 #define MTD_BIT_WRITEABLE 0x800
68 #define MTD_NO_ERASE 0x1000
69 #define MTD_POWERUP_LOCK 0x2000
70 #define MTD_SLC_ON_MLC_EMULATION 0x4000
71 #define MTD_CAP_ROM 0
72 #define MTD_CAP_RAM (MTD_WRITEABLE | MTD_BIT_WRITEABLE | MTD_NO_ERASE)
73 #define MTD_CAP_NORFLASH (MTD_WRITEABLE | MTD_BIT_WRITEABLE)
74 #define MTD_CAP_NANDFLASH (MTD_WRITEABLE)
75 #define MTD_CAP_NVRAM (MTD_WRITEABLE | MTD_BIT_WRITEABLE | MTD_NO_ERASE)
76 #define MTD_NANDECC_OFF 0
77 #define MTD_NANDECC_PLACE 1
78 #define MTD_NANDECC_AUTOPLACE 2
79 #define MTD_NANDECC_PLACEONLY 3
80 #define MTD_NANDECC_AUTOPL_USR 4
81 #define MTD_OTP_OFF 0
82 #define MTD_OTP_FACTORY 1
83 #define MTD_OTP_USER 2
84 struct mtd_info_user {
85   __u8 type;
86   __u32 flags;
87   __u32 size;
88   __u32 erasesize;
89   __u32 writesize;
90   __u32 oobsize;
91   __u64 padding;
92 };
93 struct region_info_user {
94   __u32 offset;
95   __u32 erasesize;
96   __u32 numblocks;
97   __u32 regionindex;
98 };
99 struct otp_info {
100   __u32 start;
101   __u32 length;
102   __u32 locked;
103 };
104 #define MEMGETINFO _IOR('M', 1, struct mtd_info_user)
105 #define MEMERASE _IOW('M', 2, struct erase_info_user)
106 #define MEMWRITEOOB _IOWR('M', 3, struct mtd_oob_buf)
107 #define MEMREADOOB _IOWR('M', 4, struct mtd_oob_buf)
108 #define MEMLOCK _IOW('M', 5, struct erase_info_user)
109 #define MEMUNLOCK _IOW('M', 6, struct erase_info_user)
110 #define MEMGETREGIONCOUNT _IOR('M', 7, int)
111 #define MEMGETREGIONINFO _IOWR('M', 8, struct region_info_user)
112 #define MEMGETOOBSEL _IOR('M', 10, struct nand_oobinfo)
113 #define MEMGETBADBLOCK _IOW('M', 11, __kernel_loff_t)
114 #define MEMSETBADBLOCK _IOW('M', 12, __kernel_loff_t)
115 #define OTPSELECT _IOR('M', 13, int)
116 #define OTPGETREGIONCOUNT _IOW('M', 14, int)
117 #define OTPGETREGIONINFO _IOW('M', 15, struct otp_info)
118 #define OTPLOCK _IOR('M', 16, struct otp_info)
119 #define ECCGETLAYOUT _IOR('M', 17, struct nand_ecclayout_user)
120 #define ECCGETSTATS _IOR('M', 18, struct mtd_ecc_stats)
121 #define MTDFILEMODE _IO('M', 19)
122 #define MEMERASE64 _IOW('M', 20, struct erase_info_user64)
123 #define MEMWRITEOOB64 _IOWR('M', 21, struct mtd_oob_buf64)
124 #define MEMREADOOB64 _IOWR('M', 22, struct mtd_oob_buf64)
125 #define MEMISLOCKED _IOR('M', 23, struct erase_info_user)
126 #define MEMWRITE _IOWR('M', 24, struct mtd_write_req)
127 #define OTPERASE _IOW('M', 25, struct otp_info)
128 #define MEMREAD _IOWR('M', 26, struct mtd_read_req)
129 struct nand_oobinfo {
130   __u32 useecc;
131   __u32 eccbytes;
132   __u32 oobfree[8][2];
133   __u32 eccpos[32];
134 };
135 struct nand_oobfree {
136   __u32 offset;
137   __u32 length;
138 };
139 #define MTD_MAX_OOBFREE_ENTRIES 8
140 #define MTD_MAX_ECCPOS_ENTRIES 64
141 struct nand_ecclayout_user {
142   __u32 eccbytes;
143   __u32 eccpos[MTD_MAX_ECCPOS_ENTRIES];
144   __u32 oobavail;
145   struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES];
146 };
147 struct mtd_ecc_stats {
148   __u32 corrected;
149   __u32 failed;
150   __u32 badblocks;
151   __u32 bbtblocks;
152 };
153 enum mtd_file_modes {
154   MTD_FILE_MODE_NORMAL = MTD_OTP_OFF,
155   MTD_FILE_MODE_OTP_FACTORY = MTD_OTP_FACTORY,
156   MTD_FILE_MODE_OTP_USER = MTD_OTP_USER,
157   MTD_FILE_MODE_RAW,
158 };
159 #endif
160