blob: 50ae56514f19bc2182b42051dce23dde1a840d12 [file] [log] [blame]
Ben Cheng655a7c02013-10-16 16:09:24 -07001/****************************************************************************
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>
22struct erase_info_user {
Tao Baod7db5942015-01-28 10:07:51 -080023 __u32 start;
24 __u32 length;
Ben Cheng655a7c02013-10-16 16:09:24 -070025};
26struct erase_info_user64 {
Tao Baod7db5942015-01-28 10:07:51 -080027 __u64 start;
28 __u64 length;
Ben Cheng655a7c02013-10-16 16:09:24 -070029};
30struct mtd_oob_buf {
Tao Baod7db5942015-01-28 10:07:51 -080031 __u32 start;
32 __u32 length;
33 unsigned char __user * ptr;
Ben Cheng655a7c02013-10-16 16:09:24 -070034};
Ben Cheng655a7c02013-10-16 16:09:24 -070035struct mtd_oob_buf64 {
Tao Baod7db5942015-01-28 10:07:51 -080036 __u64 start;
37 __u32 pad;
38 __u32 length;
Tao Baod7db5942015-01-28 10:07:51 -080039 __u64 usr_ptr;
Ben Cheng655a7c02013-10-16 16:09:24 -070040};
41enum {
Tao Baod7db5942015-01-28 10:07:51 -080042 MTD_OPS_PLACE_OOB = 0,
Tao Baod7db5942015-01-28 10:07:51 -080043 MTD_OPS_AUTO_OOB = 1,
44 MTD_OPS_RAW = 2,
Ben Cheng655a7c02013-10-16 16:09:24 -070045};
46struct mtd_write_req {
Tao Baod7db5942015-01-28 10:07:51 -080047 __u64 start;
48 __u64 len;
49 __u64 ooblen;
50 __u64 usr_data;
Tao Baod7db5942015-01-28 10:07:51 -080051 __u64 usr_oob;
52 __u8 mode;
53 __u8 padding[7];
Ben Cheng655a7c02013-10-16 16:09:24 -070054};
Ben Cheng655a7c02013-10-16 16:09:24 -070055#define MTD_ABSENT 0
56#define MTD_RAM 1
57#define MTD_ROM 2
58#define MTD_NORFLASH 3
Ben Cheng655a7c02013-10-16 16:09:24 -070059#define MTD_NANDFLASH 4
60#define MTD_DATAFLASH 6
61#define MTD_UBIVOLUME 7
62#define MTD_MLCNANDFLASH 8
Ben Cheng655a7c02013-10-16 16:09:24 -070063#define MTD_WRITEABLE 0x400
64#define MTD_BIT_WRITEABLE 0x800
65#define MTD_NO_ERASE 0x1000
66#define MTD_POWERUP_LOCK 0x2000
Christopher Ferris8177cdf2020-08-03 11:53:55 -070067#define MTD_SLC_ON_MLC_EMULATION 0x4000
Ben Cheng655a7c02013-10-16 16:09:24 -070068#define MTD_CAP_ROM 0
69#define MTD_CAP_RAM (MTD_WRITEABLE | MTD_BIT_WRITEABLE | MTD_NO_ERASE)
70#define MTD_CAP_NORFLASH (MTD_WRITEABLE | MTD_BIT_WRITEABLE)
71#define MTD_CAP_NANDFLASH (MTD_WRITEABLE)
Christopher Ferrisba8d4f42014-09-03 19:56:49 -070072#define MTD_CAP_NVRAM (MTD_WRITEABLE | MTD_BIT_WRITEABLE | MTD_NO_ERASE)
Ben Cheng655a7c02013-10-16 16:09:24 -070073#define MTD_NANDECC_OFF 0
74#define MTD_NANDECC_PLACE 1
75#define MTD_NANDECC_AUTOPLACE 2
Christopher Ferrisba8d4f42014-09-03 19:56:49 -070076#define MTD_NANDECC_PLACEONLY 3
Ben Cheng655a7c02013-10-16 16:09:24 -070077#define MTD_NANDECC_AUTOPL_USR 4
78#define MTD_OTP_OFF 0
79#define MTD_OTP_FACTORY 1
Christopher Ferrisba8d4f42014-09-03 19:56:49 -070080#define MTD_OTP_USER 2
Ben Cheng655a7c02013-10-16 16:09:24 -070081struct mtd_info_user {
Tao Baod7db5942015-01-28 10:07:51 -080082 __u8 type;
83 __u32 flags;
Tao Baod7db5942015-01-28 10:07:51 -080084 __u32 size;
85 __u32 erasesize;
86 __u32 writesize;
87 __u32 oobsize;
Tao Baod7db5942015-01-28 10:07:51 -080088 __u64 padding;
Ben Cheng655a7c02013-10-16 16:09:24 -070089};
90struct region_info_user {
Tao Baod7db5942015-01-28 10:07:51 -080091 __u32 offset;
Tao Baod7db5942015-01-28 10:07:51 -080092 __u32 erasesize;
93 __u32 numblocks;
94 __u32 regionindex;
Ben Cheng655a7c02013-10-16 16:09:24 -070095};
Christopher Ferrisba8d4f42014-09-03 19:56:49 -070096struct otp_info {
Tao Baod7db5942015-01-28 10:07:51 -080097 __u32 start;
98 __u32 length;
99 __u32 locked;
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700100};
Ben Cheng655a7c02013-10-16 16:09:24 -0700101#define MEMGETINFO _IOR('M', 1, struct mtd_info_user)
102#define MEMERASE _IOW('M', 2, struct erase_info_user)
103#define MEMWRITEOOB _IOWR('M', 3, struct mtd_oob_buf)
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700104#define MEMREADOOB _IOWR('M', 4, struct mtd_oob_buf)
Ben Cheng655a7c02013-10-16 16:09:24 -0700105#define MEMLOCK _IOW('M', 5, struct erase_info_user)
106#define MEMUNLOCK _IOW('M', 6, struct erase_info_user)
107#define MEMGETREGIONCOUNT _IOR('M', 7, int)
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700108#define MEMGETREGIONINFO _IOWR('M', 8, struct region_info_user)
Ben Cheng655a7c02013-10-16 16:09:24 -0700109#define MEMGETOOBSEL _IOR('M', 10, struct nand_oobinfo)
110#define MEMGETBADBLOCK _IOW('M', 11, __kernel_loff_t)
111#define MEMSETBADBLOCK _IOW('M', 12, __kernel_loff_t)
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700112#define OTPSELECT _IOR('M', 13, int)
Ben Cheng655a7c02013-10-16 16:09:24 -0700113#define OTPGETREGIONCOUNT _IOW('M', 14, int)
114#define OTPGETREGIONINFO _IOW('M', 15, struct otp_info)
115#define OTPLOCK _IOR('M', 16, struct otp_info)
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700116#define ECCGETLAYOUT _IOR('M', 17, struct nand_ecclayout_user)
Ben Cheng655a7c02013-10-16 16:09:24 -0700117#define ECCGETSTATS _IOR('M', 18, struct mtd_ecc_stats)
118#define MTDFILEMODE _IO('M', 19)
119#define MEMERASE64 _IOW('M', 20, struct erase_info_user64)
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700120#define MEMWRITEOOB64 _IOWR('M', 21, struct mtd_oob_buf64)
Ben Cheng655a7c02013-10-16 16:09:24 -0700121#define MEMREADOOB64 _IOWR('M', 22, struct mtd_oob_buf64)
122#define MEMISLOCKED _IOR('M', 23, struct erase_info_user)
123#define MEMWRITE _IOWR('M', 24, struct mtd_write_req)
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000124#define OTPERASE _IOW('M', 25, struct otp_info)
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700125struct nand_oobinfo {
Tao Baod7db5942015-01-28 10:07:51 -0800126 __u32 useecc;
127 __u32 eccbytes;
128 __u32 oobfree[8][2];
Tao Baod7db5942015-01-28 10:07:51 -0800129 __u32 eccpos[32];
Ben Cheng655a7c02013-10-16 16:09:24 -0700130};
131struct nand_oobfree {
Tao Baod7db5942015-01-28 10:07:51 -0800132 __u32 offset;
Tao Baod7db5942015-01-28 10:07:51 -0800133 __u32 length;
Ben Cheng655a7c02013-10-16 16:09:24 -0700134};
135#define MTD_MAX_OOBFREE_ENTRIES 8
136#define MTD_MAX_ECCPOS_ENTRIES 64
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700137struct nand_ecclayout_user {
Tao Baod7db5942015-01-28 10:07:51 -0800138 __u32 eccbytes;
139 __u32 eccpos[MTD_MAX_ECCPOS_ENTRIES];
140 __u32 oobavail;
Tao Baod7db5942015-01-28 10:07:51 -0800141 struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES];
Ben Cheng655a7c02013-10-16 16:09:24 -0700142};
143struct mtd_ecc_stats {
Tao Baod7db5942015-01-28 10:07:51 -0800144 __u32 corrected;
Tao Baod7db5942015-01-28 10:07:51 -0800145 __u32 failed;
146 __u32 badblocks;
147 __u32 bbtblocks;
Ben Cheng655a7c02013-10-16 16:09:24 -0700148};
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700149enum mtd_file_modes {
Tao Baod7db5942015-01-28 10:07:51 -0800150 MTD_FILE_MODE_NORMAL = MTD_OTP_OFF,
151 MTD_FILE_MODE_OTP_FACTORY = MTD_OTP_FACTORY,
152 MTD_FILE_MODE_OTP_USER = MTD_OTP_USER,
Tao Baod7db5942015-01-28 10:07:51 -0800153 MTD_FILE_MODE_RAW,
Ben Cheng655a7c02013-10-16 16:09:24 -0700154};
155#endif