1
2
3
4
5
6
7
8
9
10
11
12#ifndef __LINUX_MTD_ONENAND_H
13#define __LINUX_MTD_ONENAND_H
14
15#include <linux/mtd/onenand_regs.h>
16
17
18#include <onenand_uboot.h>
19
20#include <linux/compat.h>
21#include <linux/mtd/bbm.h>
22
23#define MAX_DIES 2
24#define MAX_BUFFERRAM 2
25#define MAX_ONENAND_PAGESIZE (4096 + 128)
26
27
28extern int onenand_scan (struct mtd_info *mtd, int max_chips);
29
30extern void onenand_release (struct mtd_info *mtd);
31
32
33
34
35
36struct onenand_bufferram {
37 int blockpage;
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
71struct onenand_chip {
72 void __iomem *base;
73 unsigned int dies;
74 unsigned int boundary[MAX_DIES];
75 unsigned int diesize[MAX_DIES];
76 unsigned int chipsize;
77 unsigned int device_id;
78 unsigned int version_id;
79 unsigned int technology;
80 unsigned int density_mask;
81 unsigned int options;
82
83 unsigned int erase_shift;
84 unsigned int page_shift;
85 unsigned int ppb_shift;
86 unsigned int page_mask;
87 unsigned int writesize;
88
89 unsigned int bufferram_index;
90 struct onenand_bufferram bufferram[MAX_BUFFERRAM];
91
92 int (*command) (struct mtd_info *mtd, int cmd, loff_t address,
93 size_t len);
94 int (*wait) (struct mtd_info *mtd, int state);
95 int (*bbt_wait) (struct mtd_info *mtd, int state);
96 void (*unlock_all)(struct mtd_info *mtd);
97 int (*read_bufferram) (struct mtd_info *mtd, loff_t addr, int area,
98 unsigned char *buffer, int offset, size_t count);
99 int (*write_bufferram) (struct mtd_info *mtd, loff_t addr, int area,
100 const unsigned char *buffer, int offset,
101 size_t count);
102 unsigned short (*read_word) (void __iomem *addr);
103 void (*write_word) (unsigned short value, void __iomem *addr);
104 int (*chip_probe)(struct mtd_info *mtd);
105 void (*mmcontrol) (struct mtd_info *mtd, int sync_read);
106 int (*block_markbad)(struct mtd_info *mtd, loff_t ofs);
107 int (*scan_bbt)(struct mtd_info *mtd);
108
109 unsigned char *main_buf;
110 unsigned char *spare_buf;
111#ifdef DONT_USE_UBOOT
112 spinlock_t chip_lock;
113 wait_queue_head_t wq;
114#endif
115 int state;
116 unsigned char *page_buf;
117 unsigned char *oob_buf;
118
119 struct nand_oobinfo *autooob;
120 int subpagesize;
121 struct nand_ecclayout *ecclayout;
122
123 void *bbm;
124
125 void *priv;
126};
127
128
129
130
131#define ONENAND_CURRENT_BUFFERRAM(this) (this->bufferram_index)
132#define ONENAND_NEXT_BUFFERRAM(this) (this->bufferram_index ^ 1)
133#define ONENAND_SET_NEXT_BUFFERRAM(this) (this->bufferram_index ^= 1)
134#define ONENAND_SET_PREV_BUFFERRAM(this) (this->bufferram_index ^= 1)
135#define ONENAND_SET_BUFFERRAM0(this) (this->bufferram_index = 0)
136#define ONENAND_SET_BUFFERRAM1(this) (this->bufferram_index = 1)
137
138#define FLEXONENAND(this) (this->device_id & DEVICE_IS_FLEXONENAND)
139#define ONENAND_IS_MLC(this) (this->technology & ONENAND_TECHNOLOGY_IS_MLC)
140#define ONENAND_IS_DDP(this) \
141 (this->device_id & ONENAND_DEVICE_IS_DDP)
142
143#define ONENAND_IS_4KB_PAGE(this) \
144 (this->options & ONENAND_HAS_4KB_PAGE)
145
146#define ONENAND_IS_2PLANE(this) (0)
147
148
149
150
151#define ONENAND_HAS_CONT_LOCK (0x0001)
152#define ONENAND_HAS_UNLOCK_ALL (0x0002)
153#define ONENAND_HAS_2PLANE (0x0004)
154#define ONENAND_HAS_4KB_PAGE (0x0008)
155#define ONENAND_RUNTIME_BADBLOCK_CHECK (0x0200)
156#define ONENAND_PAGEBUF_ALLOC (0x1000)
157#define ONENAND_OOBBUF_ALLOC (0x2000)
158
159
160
161
162#define ONENAND_MFR_NUMONYX 0x20
163#define ONENAND_MFR_SAMSUNG 0xec
164
165
166
167
168
169
170struct onenand_manufacturers {
171 int id;
172 char *name;
173};
174
175int onenand_bbt_read_oob(struct mtd_info *mtd, loff_t from,
176 struct mtd_oob_ops *ops);
177
178unsigned int onenand_block(struct onenand_chip *this, loff_t addr);
179int flexonenand_region(struct mtd_info *mtd, loff_t addr);
180#endif
181