blob: 009a8e93e5a5ae5f462c7d4af51982819fd6c477 [file] [log] [blame]
Elliott Hughes180edef2023-11-02 00:08:05 +00001/*
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 */
Ben Cheng655a7c02013-10-16 16:09:24 -07007#ifndef __MTD_ABI_H__
8#define __MTD_ABI_H__
9#include <linux/types.h>
10struct erase_info_user {
Tao Baod7db5942015-01-28 10:07:51 -080011 __u32 start;
12 __u32 length;
Ben Cheng655a7c02013-10-16 16:09:24 -070013};
14struct erase_info_user64 {
Tao Baod7db5942015-01-28 10:07:51 -080015 __u64 start;
16 __u64 length;
Ben Cheng655a7c02013-10-16 16:09:24 -070017};
18struct mtd_oob_buf {
Tao Baod7db5942015-01-28 10:07:51 -080019 __u32 start;
20 __u32 length;
Elliott Hughes0f0c18f2023-03-29 15:53:31 -070021 unsigned char * ptr;
Ben Cheng655a7c02013-10-16 16:09:24 -070022};
Ben Cheng655a7c02013-10-16 16:09:24 -070023struct mtd_oob_buf64 {
Tao Baod7db5942015-01-28 10:07:51 -080024 __u64 start;
25 __u32 pad;
26 __u32 length;
Tao Baod7db5942015-01-28 10:07:51 -080027 __u64 usr_ptr;
Ben Cheng655a7c02013-10-16 16:09:24 -070028};
29enum {
Tao Baod7db5942015-01-28 10:07:51 -080030 MTD_OPS_PLACE_OOB = 0,
Tao Baod7db5942015-01-28 10:07:51 -080031 MTD_OPS_AUTO_OOB = 1,
32 MTD_OPS_RAW = 2,
Ben Cheng655a7c02013-10-16 16:09:24 -070033};
34struct mtd_write_req {
Tao Baod7db5942015-01-28 10:07:51 -080035 __u64 start;
36 __u64 len;
37 __u64 ooblen;
38 __u64 usr_data;
Tao Baod7db5942015-01-28 10:07:51 -080039 __u64 usr_oob;
40 __u8 mode;
41 __u8 padding[7];
Ben Cheng655a7c02013-10-16 16:09:24 -070042};
Christopher Ferris6cd53a52022-12-12 23:39:16 +000043struct mtd_read_req_ecc_stats {
44 __u32 uncorrectable_errors;
45 __u32 corrected_bitflips;
46 __u32 max_bitflips;
47};
48struct 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};
Ben Cheng655a7c02013-10-16 16:09:24 -070058#define MTD_ABSENT 0
59#define MTD_RAM 1
60#define MTD_ROM 2
61#define MTD_NORFLASH 3
Ben Cheng655a7c02013-10-16 16:09:24 -070062#define MTD_NANDFLASH 4
63#define MTD_DATAFLASH 6
64#define MTD_UBIVOLUME 7
65#define MTD_MLCNANDFLASH 8
Ben Cheng655a7c02013-10-16 16:09:24 -070066#define MTD_WRITEABLE 0x400
67#define MTD_BIT_WRITEABLE 0x800
68#define MTD_NO_ERASE 0x1000
69#define MTD_POWERUP_LOCK 0x2000
Christopher Ferris8177cdf2020-08-03 11:53:55 -070070#define MTD_SLC_ON_MLC_EMULATION 0x4000
Ben Cheng655a7c02013-10-16 16:09:24 -070071#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)
Christopher Ferrisba8d4f42014-09-03 19:56:49 -070075#define MTD_CAP_NVRAM (MTD_WRITEABLE | MTD_BIT_WRITEABLE | MTD_NO_ERASE)
Ben Cheng655a7c02013-10-16 16:09:24 -070076#define MTD_NANDECC_OFF 0
77#define MTD_NANDECC_PLACE 1
78#define MTD_NANDECC_AUTOPLACE 2
Christopher Ferrisba8d4f42014-09-03 19:56:49 -070079#define MTD_NANDECC_PLACEONLY 3
Ben Cheng655a7c02013-10-16 16:09:24 -070080#define MTD_NANDECC_AUTOPL_USR 4
81#define MTD_OTP_OFF 0
82#define MTD_OTP_FACTORY 1
Christopher Ferrisba8d4f42014-09-03 19:56:49 -070083#define MTD_OTP_USER 2
Ben Cheng655a7c02013-10-16 16:09:24 -070084struct mtd_info_user {
Tao Baod7db5942015-01-28 10:07:51 -080085 __u8 type;
86 __u32 flags;
Tao Baod7db5942015-01-28 10:07:51 -080087 __u32 size;
88 __u32 erasesize;
89 __u32 writesize;
90 __u32 oobsize;
Tao Baod7db5942015-01-28 10:07:51 -080091 __u64 padding;
Ben Cheng655a7c02013-10-16 16:09:24 -070092};
93struct region_info_user {
Tao Baod7db5942015-01-28 10:07:51 -080094 __u32 offset;
Tao Baod7db5942015-01-28 10:07:51 -080095 __u32 erasesize;
96 __u32 numblocks;
97 __u32 regionindex;
Ben Cheng655a7c02013-10-16 16:09:24 -070098};
Christopher Ferrisba8d4f42014-09-03 19:56:49 -070099struct otp_info {
Tao Baod7db5942015-01-28 10:07:51 -0800100 __u32 start;
101 __u32 length;
102 __u32 locked;
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700103};
Ben Cheng655a7c02013-10-16 16:09:24 -0700104#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)
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700107#define MEMREADOOB _IOWR('M', 4, struct mtd_oob_buf)
Ben Cheng655a7c02013-10-16 16:09:24 -0700108#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)
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700111#define MEMGETREGIONINFO _IOWR('M', 8, struct region_info_user)
Ben Cheng655a7c02013-10-16 16:09:24 -0700112#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)
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700115#define OTPSELECT _IOR('M', 13, int)
Ben Cheng655a7c02013-10-16 16:09:24 -0700116#define OTPGETREGIONCOUNT _IOW('M', 14, int)
117#define OTPGETREGIONINFO _IOW('M', 15, struct otp_info)
118#define OTPLOCK _IOR('M', 16, struct otp_info)
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700119#define ECCGETLAYOUT _IOR('M', 17, struct nand_ecclayout_user)
Ben Cheng655a7c02013-10-16 16:09:24 -0700120#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)
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700123#define MEMWRITEOOB64 _IOWR('M', 21, struct mtd_oob_buf64)
Ben Cheng655a7c02013-10-16 16:09:24 -0700124#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)
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000127#define OTPERASE _IOW('M', 25, struct otp_info)
Christopher Ferris6cd53a52022-12-12 23:39:16 +0000128#define MEMREAD _IOWR('M', 26, struct mtd_read_req)
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700129struct nand_oobinfo {
Tao Baod7db5942015-01-28 10:07:51 -0800130 __u32 useecc;
131 __u32 eccbytes;
132 __u32 oobfree[8][2];
Tao Baod7db5942015-01-28 10:07:51 -0800133 __u32 eccpos[32];
Ben Cheng655a7c02013-10-16 16:09:24 -0700134};
135struct nand_oobfree {
Tao Baod7db5942015-01-28 10:07:51 -0800136 __u32 offset;
Tao Baod7db5942015-01-28 10:07:51 -0800137 __u32 length;
Ben Cheng655a7c02013-10-16 16:09:24 -0700138};
139#define MTD_MAX_OOBFREE_ENTRIES 8
140#define MTD_MAX_ECCPOS_ENTRIES 64
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700141struct nand_ecclayout_user {
Tao Baod7db5942015-01-28 10:07:51 -0800142 __u32 eccbytes;
143 __u32 eccpos[MTD_MAX_ECCPOS_ENTRIES];
144 __u32 oobavail;
Tao Baod7db5942015-01-28 10:07:51 -0800145 struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES];
Ben Cheng655a7c02013-10-16 16:09:24 -0700146};
147struct mtd_ecc_stats {
Tao Baod7db5942015-01-28 10:07:51 -0800148 __u32 corrected;
Tao Baod7db5942015-01-28 10:07:51 -0800149 __u32 failed;
150 __u32 badblocks;
151 __u32 bbtblocks;
Ben Cheng655a7c02013-10-16 16:09:24 -0700152};
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700153enum mtd_file_modes {
Tao Baod7db5942015-01-28 10:07:51 -0800154 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,
Tao Baod7db5942015-01-28 10:07:51 -0800157 MTD_FILE_MODE_RAW,
Ben Cheng655a7c02013-10-16 16:09:24 -0700158};
159#endif