summaryrefslogtreecommitdiffstats
path: root/9/platforms/android-12/arch-mips/usr/include/linux/mtd/mtd.h
blob: 300813c9344853b5e015c8cba6147651342cb8a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/****************************************************************************
 ****************************************************************************
 ***
 ***   This header was automatically generated from a Linux kernel header
 ***   of the same name, to make information necessary for userspace to
 ***   call into the kernel available to libc.  It contains only constants,
 ***   structures, and macros generated from the original header, and thus,
 ***   contains no copyrightable information.
 ***
 ****************************************************************************
 ****************************************************************************/
#ifndef __MTD_MTD_H__
#define __MTD_MTD_H__

#error This is a kernel header. Perhaps include mtd-user.h instead?

#include <linux/types.h>
#include <linux/module.h>
#include <linux/uio.h>
#include <linux/notifier.h>

#include <linux/mtd/compatmac.h>
#include <mtd/mtd-abi.h>

#define MTD_CHAR_MAJOR 90
#define MTD_BLOCK_MAJOR 31
#define MAX_MTD_DEVICES 16

#define MTD_ERASE_PENDING 0x01
#define MTD_ERASING 0x02
#define MTD_ERASE_SUSPEND 0x04
#define MTD_ERASE_DONE 0x08
#define MTD_ERASE_FAILED 0x10

struct erase_info {
 struct mtd_info *mtd;
 u_int32_t addr;
 u_int32_t len;
 u_int32_t fail_addr;
 u_long time;
 u_long retries;
 u_int dev;
 u_int cell;
 void (*callback) (struct erase_info *self);
 u_long priv;
 u_char state;
 struct erase_info *next;
};

struct mtd_erase_region_info {
 u_int32_t offset;
 u_int32_t erasesize;
 u_int32_t numblocks;
};

typedef enum {
 MTD_OOB_PLACE,
 MTD_OOB_AUTO,
 MTD_OOB_RAW,
} mtd_oob_mode_t;

struct mtd_oob_ops {
 mtd_oob_mode_t mode;
 size_t len;
 size_t retlen;
 size_t ooblen;
 uint32_t ooboffs;
 uint8_t *datbuf;
 uint8_t *oobbuf;
};

struct mtd_info {
 u_char type;
 u_int32_t flags;
 u_int32_t size;

 u_int32_t erasesize;

 u_int32_t writesize;

 u_int32_t oobsize;
 u_int32_t ecctype;
 u_int32_t eccsize;

#define MTD_PROGREGION_CTRLMODE_VALID(mtd) (mtd)->oobsize
#define MTD_PROGREGION_CTRLMODE_INVALID(mtd) (mtd)->ecctype

 char *name;
 int index;

 struct nand_ecclayout *ecclayout;

 int numeraseregions;
 struct mtd_erase_region_info *eraseregions;

 u_int32_t bank_size;

 int (*erase) (struct mtd_info *mtd, struct erase_info *instr);

 int (*point) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char **mtdbuf);

 void (*unpoint) (struct mtd_info *mtd, u_char * addr, loff_t from, size_t len);

 int (*read) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf);
 int (*write) (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf);

 int (*read_oob) (struct mtd_info *mtd, loff_t from,
 struct mtd_oob_ops *ops);
 int (*write_oob) (struct mtd_info *mtd, loff_t to,
 struct mtd_oob_ops *ops);

 int (*get_fact_prot_info) (struct mtd_info *mtd, struct otp_info *buf, size_t len);
 int (*read_fact_prot_reg) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf);
 int (*get_user_prot_info) (struct mtd_info *mtd, struct otp_info *buf, size_t len);
 int (*read_user_prot_reg) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf);
 int (*write_user_prot_reg) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf);
 int (*lock_user_prot_reg) (struct mtd_info *mtd, loff_t from, size_t len);

 int (*writev) (struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, loff_t to, size_t *retlen);

 void (*sync) (struct mtd_info *mtd);

 int (*lock) (struct mtd_info *mtd, loff_t ofs, size_t len);
 int (*unlock) (struct mtd_info *mtd, loff_t ofs, size_t len);

 int (*suspend) (struct mtd_info *mtd);
 void (*resume) (struct mtd_info *mtd);

 int (*block_isbad) (struct mtd_info *mtd, loff_t ofs);
 int (*block_markbad) (struct mtd_info *mtd, loff_t ofs);

 struct notifier_block reboot_notifier;

 struct mtd_ecc_stats ecc_stats;

 void *priv;

 struct module *owner;
 int usecount;
};

struct mtd_notifier {
 void (*add)(struct mtd_info *mtd);
 void (*remove)(struct mtd_info *mtd);
 struct list_head list;
};

#define MTD_DEBUG_LEVEL0 (0)  
#define MTD_DEBUG_LEVEL1 (1)  
#define MTD_DEBUG_LEVEL2 (2)  
#define MTD_DEBUG_LEVEL3 (3)  
#define DEBUG(n, args...) do { } while(0)
#endif