Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 1 | /**************************************************************************** |
| 2 | **************************************************************************** |
| 3 | *** |
| 4 | *** This header was automatically generated from a Linux kernel header |
| 5 | *** of the same name, to make information necessary for userspace to |
| 6 | *** call into the kernel available to libc. It contains only constants, |
| 7 | *** structures, and macros generated from the original header, and thus, |
| 8 | *** contains no copyrightable information. |
| 9 | *** |
| 10 | *** To edit the content of this header, modify the corresponding |
| 11 | *** source file (e.g. under external/kernel-headers/original/) then |
| 12 | *** run bionic/libc/kernel/tools/update_all.py |
| 13 | *** |
| 14 | *** Any manual change here will be lost the next time this script will |
| 15 | *** be run. You've been warned! |
| 16 | *** |
| 17 | **************************************************************************** |
| 18 | ****************************************************************************/ |
| 19 | #ifndef __MTD_ABI_H__ |
| 20 | #define __MTD_ABI_H__ |
| 21 | #include <linux/types.h> |
| 22 | struct erase_info_user { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 23 | __u32 start; |
| 24 | __u32 length; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 25 | }; |
| 26 | struct erase_info_user64 { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 27 | __u64 start; |
| 28 | __u64 length; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 29 | }; |
| 30 | struct mtd_oob_buf { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 31 | __u32 start; |
| 32 | __u32 length; |
| 33 | unsigned char __user * ptr; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 34 | }; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 35 | struct mtd_oob_buf64 { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 36 | __u64 start; |
| 37 | __u32 pad; |
| 38 | __u32 length; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 39 | __u64 usr_ptr; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 40 | }; |
| 41 | enum { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 42 | MTD_OPS_PLACE_OOB = 0, |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 43 | MTD_OPS_AUTO_OOB = 1, |
| 44 | MTD_OPS_RAW = 2, |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 45 | }; |
| 46 | struct mtd_write_req { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 47 | __u64 start; |
| 48 | __u64 len; |
| 49 | __u64 ooblen; |
| 50 | __u64 usr_data; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 51 | __u64 usr_oob; |
| 52 | __u8 mode; |
| 53 | __u8 padding[7]; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 54 | }; |
Christopher Ferris | 6cd53a5 | 2022-12-12 23:39:16 +0000 | [diff] [blame] | 55 | struct mtd_read_req_ecc_stats { |
| 56 | __u32 uncorrectable_errors; |
| 57 | __u32 corrected_bitflips; |
| 58 | __u32 max_bitflips; |
| 59 | }; |
| 60 | struct mtd_read_req { |
| 61 | __u64 start; |
| 62 | __u64 len; |
| 63 | __u64 ooblen; |
| 64 | __u64 usr_data; |
| 65 | __u64 usr_oob; |
| 66 | __u8 mode; |
| 67 | __u8 padding[7]; |
| 68 | struct mtd_read_req_ecc_stats ecc_stats; |
| 69 | }; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 70 | #define MTD_ABSENT 0 |
| 71 | #define MTD_RAM 1 |
| 72 | #define MTD_ROM 2 |
| 73 | #define MTD_NORFLASH 3 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 74 | #define MTD_NANDFLASH 4 |
| 75 | #define MTD_DATAFLASH 6 |
| 76 | #define MTD_UBIVOLUME 7 |
| 77 | #define MTD_MLCNANDFLASH 8 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 78 | #define MTD_WRITEABLE 0x400 |
| 79 | #define MTD_BIT_WRITEABLE 0x800 |
| 80 | #define MTD_NO_ERASE 0x1000 |
| 81 | #define MTD_POWERUP_LOCK 0x2000 |
Christopher Ferris | 8177cdf | 2020-08-03 11:53:55 -0700 | [diff] [blame] | 82 | #define MTD_SLC_ON_MLC_EMULATION 0x4000 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 83 | #define MTD_CAP_ROM 0 |
| 84 | #define MTD_CAP_RAM (MTD_WRITEABLE | MTD_BIT_WRITEABLE | MTD_NO_ERASE) |
| 85 | #define MTD_CAP_NORFLASH (MTD_WRITEABLE | MTD_BIT_WRITEABLE) |
| 86 | #define MTD_CAP_NANDFLASH (MTD_WRITEABLE) |
Christopher Ferris | ba8d4f4 | 2014-09-03 19:56:49 -0700 | [diff] [blame] | 87 | #define MTD_CAP_NVRAM (MTD_WRITEABLE | MTD_BIT_WRITEABLE | MTD_NO_ERASE) |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 88 | #define MTD_NANDECC_OFF 0 |
| 89 | #define MTD_NANDECC_PLACE 1 |
| 90 | #define MTD_NANDECC_AUTOPLACE 2 |
Christopher Ferris | ba8d4f4 | 2014-09-03 19:56:49 -0700 | [diff] [blame] | 91 | #define MTD_NANDECC_PLACEONLY 3 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 92 | #define MTD_NANDECC_AUTOPL_USR 4 |
| 93 | #define MTD_OTP_OFF 0 |
| 94 | #define MTD_OTP_FACTORY 1 |
Christopher Ferris | ba8d4f4 | 2014-09-03 19:56:49 -0700 | [diff] [blame] | 95 | #define MTD_OTP_USER 2 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 96 | struct mtd_info_user { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 97 | __u8 type; |
| 98 | __u32 flags; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 99 | __u32 size; |
| 100 | __u32 erasesize; |
| 101 | __u32 writesize; |
| 102 | __u32 oobsize; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 103 | __u64 padding; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 104 | }; |
| 105 | struct region_info_user { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 106 | __u32 offset; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 107 | __u32 erasesize; |
| 108 | __u32 numblocks; |
| 109 | __u32 regionindex; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 110 | }; |
Christopher Ferris | ba8d4f4 | 2014-09-03 19:56:49 -0700 | [diff] [blame] | 111 | struct otp_info { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 112 | __u32 start; |
| 113 | __u32 length; |
| 114 | __u32 locked; |
Christopher Ferris | ba8d4f4 | 2014-09-03 19:56:49 -0700 | [diff] [blame] | 115 | }; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 116 | #define MEMGETINFO _IOR('M', 1, struct mtd_info_user) |
| 117 | #define MEMERASE _IOW('M', 2, struct erase_info_user) |
| 118 | #define MEMWRITEOOB _IOWR('M', 3, struct mtd_oob_buf) |
Christopher Ferris | ba8d4f4 | 2014-09-03 19:56:49 -0700 | [diff] [blame] | 119 | #define MEMREADOOB _IOWR('M', 4, struct mtd_oob_buf) |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 120 | #define MEMLOCK _IOW('M', 5, struct erase_info_user) |
| 121 | #define MEMUNLOCK _IOW('M', 6, struct erase_info_user) |
| 122 | #define MEMGETREGIONCOUNT _IOR('M', 7, int) |
Christopher Ferris | ba8d4f4 | 2014-09-03 19:56:49 -0700 | [diff] [blame] | 123 | #define MEMGETREGIONINFO _IOWR('M', 8, struct region_info_user) |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 124 | #define MEMGETOOBSEL _IOR('M', 10, struct nand_oobinfo) |
| 125 | #define MEMGETBADBLOCK _IOW('M', 11, __kernel_loff_t) |
| 126 | #define MEMSETBADBLOCK _IOW('M', 12, __kernel_loff_t) |
Christopher Ferris | ba8d4f4 | 2014-09-03 19:56:49 -0700 | [diff] [blame] | 127 | #define OTPSELECT _IOR('M', 13, int) |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 128 | #define OTPGETREGIONCOUNT _IOW('M', 14, int) |
| 129 | #define OTPGETREGIONINFO _IOW('M', 15, struct otp_info) |
| 130 | #define OTPLOCK _IOR('M', 16, struct otp_info) |
Christopher Ferris | ba8d4f4 | 2014-09-03 19:56:49 -0700 | [diff] [blame] | 131 | #define ECCGETLAYOUT _IOR('M', 17, struct nand_ecclayout_user) |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 132 | #define ECCGETSTATS _IOR('M', 18, struct mtd_ecc_stats) |
| 133 | #define MTDFILEMODE _IO('M', 19) |
| 134 | #define MEMERASE64 _IOW('M', 20, struct erase_info_user64) |
Christopher Ferris | ba8d4f4 | 2014-09-03 19:56:49 -0700 | [diff] [blame] | 135 | #define MEMWRITEOOB64 _IOWR('M', 21, struct mtd_oob_buf64) |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 136 | #define MEMREADOOB64 _IOWR('M', 22, struct mtd_oob_buf64) |
| 137 | #define MEMISLOCKED _IOR('M', 23, struct erase_info_user) |
| 138 | #define MEMWRITE _IOWR('M', 24, struct mtd_write_req) |
Christopher Ferris | fcc3b4f | 2021-07-01 01:30:21 +0000 | [diff] [blame] | 139 | #define OTPERASE _IOW('M', 25, struct otp_info) |
Christopher Ferris | 6cd53a5 | 2022-12-12 23:39:16 +0000 | [diff] [blame] | 140 | #define MEMREAD _IOWR('M', 26, struct mtd_read_req) |
Christopher Ferris | ba8d4f4 | 2014-09-03 19:56:49 -0700 | [diff] [blame] | 141 | struct nand_oobinfo { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 142 | __u32 useecc; |
| 143 | __u32 eccbytes; |
| 144 | __u32 oobfree[8][2]; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 145 | __u32 eccpos[32]; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 146 | }; |
| 147 | struct nand_oobfree { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 148 | __u32 offset; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 149 | __u32 length; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 150 | }; |
| 151 | #define MTD_MAX_OOBFREE_ENTRIES 8 |
| 152 | #define MTD_MAX_ECCPOS_ENTRIES 64 |
Christopher Ferris | ba8d4f4 | 2014-09-03 19:56:49 -0700 | [diff] [blame] | 153 | struct nand_ecclayout_user { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 154 | __u32 eccbytes; |
| 155 | __u32 eccpos[MTD_MAX_ECCPOS_ENTRIES]; |
| 156 | __u32 oobavail; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 157 | struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES]; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 158 | }; |
| 159 | struct mtd_ecc_stats { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 160 | __u32 corrected; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 161 | __u32 failed; |
| 162 | __u32 badblocks; |
| 163 | __u32 bbtblocks; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 164 | }; |
Christopher Ferris | ba8d4f4 | 2014-09-03 19:56:49 -0700 | [diff] [blame] | 165 | enum mtd_file_modes { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 166 | MTD_FILE_MODE_NORMAL = MTD_OTP_OFF, |
| 167 | MTD_FILE_MODE_OTP_FACTORY = MTD_OTP_FACTORY, |
| 168 | MTD_FILE_MODE_OTP_USER = MTD_OTP_USER, |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 169 | MTD_FILE_MODE_RAW, |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 170 | }; |
| 171 | #endif |