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 ****************************************************************************
11 ****************************************************************************/
12#ifndef __MTD_MTD_H__
13#define __MTD_MTD_H__
14
15#error This is a kernel header. Perhaps include mtd-user.h instead?
16
17#include <linux/types.h>
18#include <linux/module.h>
19#include <linux/uio.h>
20#include <linux/notifier.h>
21
22#include <linux/mtd/compatmac.h>
23#include <mtd/mtd-abi.h>
24
25#define MTD_CHAR_MAJOR 90
26#define MTD_BLOCK_MAJOR 31
27#define MAX_MTD_DEVICES 16
28
29#define MTD_ERASE_PENDING 0x01
30#define MTD_ERASING 0x02
31#define MTD_ERASE_SUSPEND 0x04
32#define MTD_ERASE_DONE 0x08
33#define MTD_ERASE_FAILED 0x10
34
35struct erase_info {
36 struct mtd_info *mtd;
37 u_int32_t addr;
38 u_int32_t len;
39 u_int32_t fail_addr;
40 u_long time;
41 u_long retries;
42 u_int dev;
43 u_int cell;
44 void (*callback) (struct erase_info *self);
45 u_long priv;
46 u_char state;
47 struct erase_info *next;
48};
49
50struct mtd_erase_region_info {
51 u_int32_t offset;
52 u_int32_t erasesize;
53 u_int32_t numblocks;
54};
55
56typedef enum {
57 MTD_OOB_PLACE,
58 MTD_OOB_AUTO,
59 MTD_OOB_RAW,
60} mtd_oob_mode_t;
61
62struct mtd_oob_ops {
63 mtd_oob_mode_t mode;
64 size_t len;
65 size_t retlen;
66 size_t ooblen;
67 uint32_t ooboffs;
68 uint8_t *datbuf;
69 uint8_t *oobbuf;
70};
71
72struct mtd_info {
73 u_char type;
74 u_int32_t flags;
75 u_int32_t size;
76
77 u_int32_t erasesize;
78
79 u_int32_t writesize;
80
81 u_int32_t oobsize;
82 u_int32_t ecctype;
83 u_int32_t eccsize;
84
85#define MTD_PROGREGION_CTRLMODE_VALID(mtd) (mtd)->oobsize
86#define MTD_PROGREGION_CTRLMODE_INVALID(mtd) (mtd)->ecctype
87
88 char *name;
89 int index;
90
91 struct nand_ecclayout *ecclayout;
92
93 int numeraseregions;
94 struct mtd_erase_region_info *eraseregions;
95
96 u_int32_t bank_size;
97
98 int (*erase) (struct mtd_info *mtd, struct erase_info *instr);
99
100 int (*point) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char **mtdbuf);
101
102 void (*unpoint) (struct mtd_info *mtd, u_char * addr, loff_t from, size_t len);
103
104 int (*read) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf);
105 int (*write) (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf);
106
107 int (*read_oob) (struct mtd_info *mtd, loff_t from,
108 struct mtd_oob_ops *ops);
109 int (*write_oob) (struct mtd_info *mtd, loff_t to,
110 struct mtd_oob_ops *ops);
111
112 int (*get_fact_prot_info) (struct mtd_info *mtd, struct otp_info *buf, size_t len);
113 int (*read_fact_prot_reg) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf);
114 int (*get_user_prot_info) (struct mtd_info *mtd, struct otp_info *buf, size_t len);
115 int (*read_user_prot_reg) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf);
116 int (*write_user_prot_reg) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf);
117 int (*lock_user_prot_reg) (struct mtd_info *mtd, loff_t from, size_t len);
118
119 int (*writev) (struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, loff_t to, size_t *retlen);
120
121 void (*sync) (struct mtd_info *mtd);
122
123 int (*lock) (struct mtd_info *mtd, loff_t ofs, size_t len);
124 int (*unlock) (struct mtd_info *mtd, loff_t ofs, size_t len);
125
126 int (*suspend) (struct mtd_info *mtd);
127 void (*resume) (struct mtd_info *mtd);
128
129 int (*block_isbad) (struct mtd_info *mtd, loff_t ofs);
130 int (*block_markbad) (struct mtd_info *mtd, loff_t ofs);
131
132 struct notifier_block reboot_notifier;
133
134 struct mtd_ecc_stats ecc_stats;
135
136 void *priv;
137
138 struct module *owner;
139 int usecount;
140};
141
142struct mtd_notifier {
143 void (*add)(struct mtd_info *mtd);
144 void (*remove)(struct mtd_info *mtd);
145 struct list_head list;
146};
147
148#define MTD_DEBUG_LEVEL0 (0)
149#define MTD_DEBUG_LEVEL1 (1)
150#define MTD_DEBUG_LEVEL2 (2)
151#define MTD_DEBUG_LEVEL3 (3)
152#define DEBUG(n, args...) do { } while(0)
153#endif
154