Commit f77d92a3f56d88e63cc02226a1204b3bdbac6961

Authored by Sergey Lapin
Committed by Jean-Christophe PLAGNIOL-VILLARD
1 parent 81091f58f0

DataFlash: AT45DB021 fix and AT45DB081 support

Fix for page size of AT45DB021. Also adding bigger AT45DB081
which comes with some newer boards.

Signed-off-by: Sergey Lapin <slapin@ossfans.org>

Showing 2 changed files with 15 additions and 2 deletions Inline Diff

drivers/mtd/dataflash.c
1 /* LowLevel function for ATMEL DataFlash support 1 /* LowLevel function for ATMEL DataFlash support
2 * Author : Hamid Ikdoumi (Atmel) 2 * Author : Hamid Ikdoumi (Atmel)
3 * 3 *
4 * This program is free software; you can redistribute it and/or 4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as 5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of 6 * published by the Free Software Foundation; either version 2 of
7 * the License, or (at your option) any later version. 7 * the License, or (at your option) any later version.
8 * 8 *
9 * This program is distributed in the hope that it will be useful, 9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
17 * MA 02111-1307 USA 17 * MA 02111-1307 USA
18 * 18 *
19 */ 19 */
20 #include <common.h> 20 #include <common.h>
21 #include <config.h> 21 #include <config.h>
22 #include <asm/hardware.h> 22 #include <asm/hardware.h>
23 #include <dataflash.h> 23 #include <dataflash.h>
24 24
25 static AT91S_DataFlash DataFlashInst; 25 static AT91S_DataFlash DataFlashInst;
26 26
27 extern void AT91F_SpiInit (void); 27 extern void AT91F_SpiInit (void);
28 extern int AT91F_DataflashProbe (int i, AT91PS_DataflashDesc pDesc); 28 extern int AT91F_DataflashProbe (int i, AT91PS_DataflashDesc pDesc);
29 extern int AT91F_DataFlashRead (AT91PS_DataFlash pDataFlash, 29 extern int AT91F_DataFlashRead (AT91PS_DataFlash pDataFlash,
30 unsigned long addr, 30 unsigned long addr,
31 unsigned long size, char *buffer); 31 unsigned long size, char *buffer);
32 extern int AT91F_DataFlashWrite( AT91PS_DataFlash pDataFlash, 32 extern int AT91F_DataFlashWrite( AT91PS_DataFlash pDataFlash,
33 unsigned char *src, 33 unsigned char *src,
34 int dest, 34 int dest,
35 int size ); 35 int size );
36 36
37 int AT91F_DataflashInit (void) 37 int AT91F_DataflashInit (void)
38 { 38 {
39 int i, j; 39 int i, j;
40 int dfcode; 40 int dfcode;
41 int part; 41 int part;
42 int last_part; 42 int last_part;
43 int found[CFG_MAX_DATAFLASH_BANKS]; 43 int found[CFG_MAX_DATAFLASH_BANKS];
44 unsigned char protected; 44 unsigned char protected;
45 45
46 AT91F_SpiInit (); 46 AT91F_SpiInit ();
47 47
48 for (i = 0; i < CFG_MAX_DATAFLASH_BANKS; i++) { 48 for (i = 0; i < CFG_MAX_DATAFLASH_BANKS; i++) {
49 found[i] = 0; 49 found[i] = 0;
50 dataflash_info[i].Desc.state = IDLE; 50 dataflash_info[i].Desc.state = IDLE;
51 dataflash_info[i].id = 0; 51 dataflash_info[i].id = 0;
52 dataflash_info[i].Device.pages_number = 0; 52 dataflash_info[i].Device.pages_number = 0;
53 dfcode = AT91F_DataflashProbe (cs[i].cs, 53 dfcode = AT91F_DataflashProbe (cs[i].cs,
54 &dataflash_info[i].Desc); 54 &dataflash_info[i].Desc);
55 55
56 switch (dfcode) { 56 switch (dfcode) {
57 case AT45DB021: 57 case AT45DB021:
58 dataflash_info[i].Device.pages_number = 1024; 58 dataflash_info[i].Device.pages_number = 1024;
59 dataflash_info[i].Device.pages_size = 263; 59 dataflash_info[i].Device.pages_size = 264;
60 dataflash_info[i].Device.page_offset = 9; 60 dataflash_info[i].Device.page_offset = 9;
61 dataflash_info[i].Device.byte_mask = 0x300; 61 dataflash_info[i].Device.byte_mask = 0x300;
62 dataflash_info[i].Device.cs = cs[i].cs; 62 dataflash_info[i].Device.cs = cs[i].cs;
63 dataflash_info[i].Desc.DataFlash_state = IDLE; 63 dataflash_info[i].Desc.DataFlash_state = IDLE;
64 dataflash_info[i].logical_address = cs[i].addr; 64 dataflash_info[i].logical_address = cs[i].addr;
65 dataflash_info[i].id = dfcode; 65 dataflash_info[i].id = dfcode;
66 found[i] += dfcode;; 66 found[i] += dfcode;;
67 break; 67 break;
68
69 case AT45DB081:
70 dataflash_info[i].Device.pages_number = 4096;
71 dataflash_info[i].Device.pages_size = 264;
72 dataflash_info[i].Device.page_offset = 9;
73 dataflash_info[i].Device.byte_mask = 0x300;
74 dataflash_info[i].Device.cs = cs[i].cs;
75 dataflash_info[i].Desc.DataFlash_state = IDLE;
76 dataflash_info[i].logical_address = cs[i].addr;
77 dataflash_info[i].id = dfcode;
78 found[i] += dfcode;;
79 break;
80
68 case AT45DB161: 81 case AT45DB161:
69 dataflash_info[i].Device.pages_number = 4096; 82 dataflash_info[i].Device.pages_number = 4096;
70 dataflash_info[i].Device.pages_size = 528; 83 dataflash_info[i].Device.pages_size = 528;
71 dataflash_info[i].Device.page_offset = 10; 84 dataflash_info[i].Device.page_offset = 10;
72 dataflash_info[i].Device.byte_mask = 0x300; 85 dataflash_info[i].Device.byte_mask = 0x300;
73 dataflash_info[i].Device.cs = cs[i].cs; 86 dataflash_info[i].Device.cs = cs[i].cs;
74 dataflash_info[i].Desc.DataFlash_state = IDLE; 87 dataflash_info[i].Desc.DataFlash_state = IDLE;
75 dataflash_info[i].logical_address = cs[i].addr; 88 dataflash_info[i].logical_address = cs[i].addr;
76 dataflash_info[i].id = dfcode; 89 dataflash_info[i].id = dfcode;
77 found[i] += dfcode;; 90 found[i] += dfcode;;
78 break; 91 break;
79 92
80 case AT45DB321: 93 case AT45DB321:
81 dataflash_info[i].Device.pages_number = 8192; 94 dataflash_info[i].Device.pages_number = 8192;
82 dataflash_info[i].Device.pages_size = 528; 95 dataflash_info[i].Device.pages_size = 528;
83 dataflash_info[i].Device.page_offset = 10; 96 dataflash_info[i].Device.page_offset = 10;
84 dataflash_info[i].Device.byte_mask = 0x300; 97 dataflash_info[i].Device.byte_mask = 0x300;
85 dataflash_info[i].Device.cs = cs[i].cs; 98 dataflash_info[i].Device.cs = cs[i].cs;
86 dataflash_info[i].Desc.DataFlash_state = IDLE; 99 dataflash_info[i].Desc.DataFlash_state = IDLE;
87 dataflash_info[i].logical_address = cs[i].addr; 100 dataflash_info[i].logical_address = cs[i].addr;
88 dataflash_info[i].id = dfcode; 101 dataflash_info[i].id = dfcode;
89 found[i] += dfcode;; 102 found[i] += dfcode;;
90 break; 103 break;
91 104
92 case AT45DB642: 105 case AT45DB642:
93 dataflash_info[i].Device.pages_number = 8192; 106 dataflash_info[i].Device.pages_number = 8192;
94 dataflash_info[i].Device.pages_size = 1056; 107 dataflash_info[i].Device.pages_size = 1056;
95 dataflash_info[i].Device.page_offset = 11; 108 dataflash_info[i].Device.page_offset = 11;
96 dataflash_info[i].Device.byte_mask = 0x700; 109 dataflash_info[i].Device.byte_mask = 0x700;
97 dataflash_info[i].Device.cs = cs[i].cs; 110 dataflash_info[i].Device.cs = cs[i].cs;
98 dataflash_info[i].Desc.DataFlash_state = IDLE; 111 dataflash_info[i].Desc.DataFlash_state = IDLE;
99 dataflash_info[i].logical_address = cs[i].addr; 112 dataflash_info[i].logical_address = cs[i].addr;
100 dataflash_info[i].id = dfcode; 113 dataflash_info[i].id = dfcode;
101 found[i] += dfcode;; 114 found[i] += dfcode;;
102 break; 115 break;
103 116
104 case AT45DB128: 117 case AT45DB128:
105 dataflash_info[i].Device.pages_number = 16384; 118 dataflash_info[i].Device.pages_number = 16384;
106 dataflash_info[i].Device.pages_size = 1056; 119 dataflash_info[i].Device.pages_size = 1056;
107 dataflash_info[i].Device.page_offset = 11; 120 dataflash_info[i].Device.page_offset = 11;
108 dataflash_info[i].Device.byte_mask = 0x700; 121 dataflash_info[i].Device.byte_mask = 0x700;
109 dataflash_info[i].Device.cs = cs[i].cs; 122 dataflash_info[i].Device.cs = cs[i].cs;
110 dataflash_info[i].Desc.DataFlash_state = IDLE; 123 dataflash_info[i].Desc.DataFlash_state = IDLE;
111 dataflash_info[i].logical_address = cs[i].addr; 124 dataflash_info[i].logical_address = cs[i].addr;
112 dataflash_info[i].id = dfcode; 125 dataflash_info[i].id = dfcode;
113 found[i] += dfcode;; 126 found[i] += dfcode;;
114 break; 127 break;
115 128
116 default: 129 default:
117 dfcode = 0; 130 dfcode = 0;
118 break; 131 break;
119 } 132 }
120 /* set the last area end to the dataflash size*/ 133 /* set the last area end to the dataflash size*/
121 area_list[NB_DATAFLASH_AREA -1].end = 134 area_list[NB_DATAFLASH_AREA -1].end =
122 (dataflash_info[i].Device.pages_number * 135 (dataflash_info[i].Device.pages_number *
123 dataflash_info[i].Device.pages_size)-1; 136 dataflash_info[i].Device.pages_size)-1;
124 137
125 part = 0; 138 part = 0;
126 last_part = 0; 139 last_part = 0;
127 /* set the area addresses */ 140 /* set the area addresses */
128 for(j = 0; j<NB_DATAFLASH_AREA; j++) { 141 for(j = 0; j<NB_DATAFLASH_AREA; j++) {
129 if(found[i]!=0) { 142 if(found[i]!=0) {
130 dataflash_info[i].Device.area_list[j].start = 143 dataflash_info[i].Device.area_list[j].start =
131 area_list[part].start + 144 area_list[part].start +
132 dataflash_info[i].logical_address; 145 dataflash_info[i].logical_address;
133 if(area_list[part].end == 0xffffffff) { 146 if(area_list[part].end == 0xffffffff) {
134 dataflash_info[i].Device.area_list[j].end = 147 dataflash_info[i].Device.area_list[j].end =
135 dataflash_info[i].end_address + 148 dataflash_info[i].end_address +
136 dataflash_info [i].logical_address; 149 dataflash_info [i].logical_address;
137 last_part = 1; 150 last_part = 1;
138 } else { 151 } else {
139 dataflash_info[i].Device.area_list[j].end = 152 dataflash_info[i].Device.area_list[j].end =
140 area_list[part].end + 153 area_list[part].end +
141 dataflash_info[i].logical_address; 154 dataflash_info[i].logical_address;
142 } 155 }
143 protected = area_list[part].protected; 156 protected = area_list[part].protected;
144 /* Set the environment according to the label...*/ 157 /* Set the environment according to the label...*/
145 if(protected == FLAG_PROTECT_INVALID) { 158 if(protected == FLAG_PROTECT_INVALID) {
146 dataflash_info[i].Device.area_list[j].protected = 159 dataflash_info[i].Device.area_list[j].protected =
147 FLAG_PROTECT_INVALID; 160 FLAG_PROTECT_INVALID;
148 } else { 161 } else {
149 dataflash_info[i].Device.area_list[j].protected = 162 dataflash_info[i].Device.area_list[j].protected =
150 protected; 163 protected;
151 } 164 }
152 strcpy((char*)(dataflash_info[i].Device.area_list[j].label), 165 strcpy((char*)(dataflash_info[i].Device.area_list[j].label),
153 (const char *)area_list[part].label); 166 (const char *)area_list[part].label);
154 } 167 }
155 part++; 168 part++;
156 } 169 }
157 } 170 }
158 return found[0]; 171 return found[0];
159 } 172 }
160 173
161 void AT91F_DataflashSetEnv (void) 174 void AT91F_DataflashSetEnv (void)
162 { 175 {
163 int i, j; 176 int i, j;
164 int part; 177 int part;
165 unsigned char env; 178 unsigned char env;
166 unsigned char s[32]; /* Will fit a long int in hex */ 179 unsigned char s[32]; /* Will fit a long int in hex */
167 unsigned long start; 180 unsigned long start;
168 181
169 for (i = 0, part= 0; i < CFG_MAX_DATAFLASH_BANKS; i++) { 182 for (i = 0, part= 0; i < CFG_MAX_DATAFLASH_BANKS; i++) {
170 for(j = 0; j<NB_DATAFLASH_AREA; j++) { 183 for(j = 0; j<NB_DATAFLASH_AREA; j++) {
171 env = area_list[part].setenv; 184 env = area_list[part].setenv;
172 /* Set the environment according to the label...*/ 185 /* Set the environment according to the label...*/
173 if((env & FLAG_SETENV) == FLAG_SETENV) { 186 if((env & FLAG_SETENV) == FLAG_SETENV) {
174 start = 187 start =
175 dataflash_info[i].Device.area_list[j].start; 188 dataflash_info[i].Device.area_list[j].start;
176 sprintf((char*) s,"%lX",start); 189 sprintf((char*) s,"%lX",start);
177 setenv((char*) area_list[part].label,(char*) s); 190 setenv((char*) area_list[part].label,(char*) s);
178 } 191 }
179 part++; 192 part++;
180 } 193 }
181 } 194 }
182 } 195 }
183 196
184 void dataflash_print_info (void) 197 void dataflash_print_info (void)
185 { 198 {
186 int i, j; 199 int i, j;
187 200
188 for (i = 0; i < CFG_MAX_DATAFLASH_BANKS; i++) { 201 for (i = 0; i < CFG_MAX_DATAFLASH_BANKS; i++) {
189 if (dataflash_info[i].id != 0) { 202 if (dataflash_info[i].id != 0) {
190 printf("DataFlash:"); 203 printf("DataFlash:");
191 switch (dataflash_info[i].id) { 204 switch (dataflash_info[i].id) {
192 case AT45DB021: 205 case AT45DB021:
193 printf("AT45DB021\n"); 206 printf("AT45DB021\n");
194 break; 207 break;
195 case AT45DB161: 208 case AT45DB161:
196 printf("AT45DB161\n"); 209 printf("AT45DB161\n");
197 break; 210 break;
198 211
199 case AT45DB321: 212 case AT45DB321:
200 printf("AT45DB321\n"); 213 printf("AT45DB321\n");
201 break; 214 break;
202 215
203 case AT45DB642: 216 case AT45DB642:
204 printf("AT45DB642\n"); 217 printf("AT45DB642\n");
205 break; 218 break;
206 case AT45DB128: 219 case AT45DB128:
207 printf("AT45DB128\n"); 220 printf("AT45DB128\n");
208 break; 221 break;
209 } 222 }
210 223
211 printf("Nb pages: %6d\n" 224 printf("Nb pages: %6d\n"
212 "Page Size: %6d\n" 225 "Page Size: %6d\n"
213 "Size=%8d bytes\n" 226 "Size=%8d bytes\n"
214 "Logical address: 0x%08X\n", 227 "Logical address: 0x%08X\n",
215 (unsigned int) dataflash_info[i].Device.pages_number, 228 (unsigned int) dataflash_info[i].Device.pages_number,
216 (unsigned int) dataflash_info[i].Device.pages_size, 229 (unsigned int) dataflash_info[i].Device.pages_size,
217 (unsigned int) dataflash_info[i].Device.pages_number * 230 (unsigned int) dataflash_info[i].Device.pages_number *
218 dataflash_info[i].Device.pages_size, 231 dataflash_info[i].Device.pages_size,
219 (unsigned int) dataflash_info[i].logical_address); 232 (unsigned int) dataflash_info[i].logical_address);
220 for (j=0; j< NB_DATAFLASH_AREA; j++) { 233 for (j=0; j< NB_DATAFLASH_AREA; j++) {
221 switch(dataflash_info[i].Device.area_list[j].protected) { 234 switch(dataflash_info[i].Device.area_list[j].protected) {
222 case FLAG_PROTECT_SET: 235 case FLAG_PROTECT_SET:
223 case FLAG_PROTECT_CLEAR: 236 case FLAG_PROTECT_CLEAR:
224 printf("Area %i:\t%08lX to %08lX %s", j, 237 printf("Area %i:\t%08lX to %08lX %s", j,
225 dataflash_info[i].Device.area_list[j].start, 238 dataflash_info[i].Device.area_list[j].start,
226 dataflash_info[i].Device.area_list[j].end, 239 dataflash_info[i].Device.area_list[j].end,
227 (dataflash_info[i].Device.area_list[j].protected==FLAG_PROTECT_SET) ? "(RO)" : " "); 240 (dataflash_info[i].Device.area_list[j].protected==FLAG_PROTECT_SET) ? "(RO)" : " ");
228 printf(" %s\n", dataflash_info[i].Device.area_list[j].label); 241 printf(" %s\n", dataflash_info[i].Device.area_list[j].label);
229 break; 242 break;
230 case FLAG_PROTECT_INVALID: 243 case FLAG_PROTECT_INVALID:
231 break; 244 break;
232 } 245 }
233 } 246 }
234 } 247 }
235 } 248 }
236 } 249 }
237 250
238 /*---------------------------------------------------------------------------*/ 251 /*---------------------------------------------------------------------------*/
239 /* Function Name : AT91F_DataflashSelect */ 252 /* Function Name : AT91F_DataflashSelect */
240 /* Object : Select the correct device */ 253 /* Object : Select the correct device */
241 /*---------------------------------------------------------------------------*/ 254 /*---------------------------------------------------------------------------*/
242 AT91PS_DataFlash AT91F_DataflashSelect (AT91PS_DataFlash pFlash, 255 AT91PS_DataFlash AT91F_DataflashSelect (AT91PS_DataFlash pFlash,
243 unsigned long *addr) 256 unsigned long *addr)
244 { 257 {
245 char addr_valid = 0; 258 char addr_valid = 0;
246 int i; 259 int i;
247 260
248 for (i = 0; i < CFG_MAX_DATAFLASH_BANKS; i++) 261 for (i = 0; i < CFG_MAX_DATAFLASH_BANKS; i++)
249 if ( dataflash_info[i].id 262 if ( dataflash_info[i].id
250 && ((((int) *addr) & 0xFF000000) == 263 && ((((int) *addr) & 0xFF000000) ==
251 dataflash_info[i].logical_address)) { 264 dataflash_info[i].logical_address)) {
252 addr_valid = 1; 265 addr_valid = 1;
253 break; 266 break;
254 } 267 }
255 if (!addr_valid) { 268 if (!addr_valid) {
256 pFlash = (AT91PS_DataFlash) 0; 269 pFlash = (AT91PS_DataFlash) 0;
257 return pFlash; 270 return pFlash;
258 } 271 }
259 pFlash->pDataFlashDesc = &(dataflash_info[i].Desc); 272 pFlash->pDataFlashDesc = &(dataflash_info[i].Desc);
260 pFlash->pDevice = &(dataflash_info[i].Device); 273 pFlash->pDevice = &(dataflash_info[i].Device);
261 *addr -= dataflash_info[i].logical_address; 274 *addr -= dataflash_info[i].logical_address;
262 return (pFlash); 275 return (pFlash);
263 } 276 }
264 277
265 /*---------------------------------------------------------------------------*/ 278 /*---------------------------------------------------------------------------*/
266 /* Function Name : addr_dataflash */ 279 /* Function Name : addr_dataflash */
267 /* Object : Test if address is valid */ 280 /* Object : Test if address is valid */
268 /*---------------------------------------------------------------------------*/ 281 /*---------------------------------------------------------------------------*/
269 int addr_dataflash (unsigned long addr) 282 int addr_dataflash (unsigned long addr)
270 { 283 {
271 int addr_valid = 0; 284 int addr_valid = 0;
272 int i; 285 int i;
273 286
274 for (i = 0; i < CFG_MAX_DATAFLASH_BANKS; i++) { 287 for (i = 0; i < CFG_MAX_DATAFLASH_BANKS; i++) {
275 if ((((int) addr) & 0xFF000000) == 288 if ((((int) addr) & 0xFF000000) ==
276 dataflash_info[i].logical_address) { 289 dataflash_info[i].logical_address) {
277 addr_valid = 1; 290 addr_valid = 1;
278 break; 291 break;
279 } 292 }
280 } 293 }
281 294
282 return addr_valid; 295 return addr_valid;
283 } 296 }
284 297
285 /*---------------------------------------------------------------------------*/ 298 /*---------------------------------------------------------------------------*/
286 /* Function Name : size_dataflash */ 299 /* Function Name : size_dataflash */
287 /* Object : Test if address is valid regarding the size */ 300 /* Object : Test if address is valid regarding the size */
288 /*---------------------------------------------------------------------------*/ 301 /*---------------------------------------------------------------------------*/
289 int size_dataflash (AT91PS_DataFlash pdataFlash, unsigned long addr, 302 int size_dataflash (AT91PS_DataFlash pdataFlash, unsigned long addr,
290 unsigned long size) 303 unsigned long size)
291 { 304 {
292 /* is outside the dataflash */ 305 /* is outside the dataflash */
293 if (((int)addr & 0x0FFFFFFF) > (pdataFlash->pDevice->pages_size * 306 if (((int)addr & 0x0FFFFFFF) > (pdataFlash->pDevice->pages_size *
294 pdataFlash->pDevice->pages_number)) return 0; 307 pdataFlash->pDevice->pages_number)) return 0;
295 /* is too large for the dataflash */ 308 /* is too large for the dataflash */
296 if (size > ((pdataFlash->pDevice->pages_size * 309 if (size > ((pdataFlash->pDevice->pages_size *
297 pdataFlash->pDevice->pages_number) - 310 pdataFlash->pDevice->pages_number) -
298 ((int)addr & 0x0FFFFFFF))) return 0; 311 ((int)addr & 0x0FFFFFFF))) return 0;
299 312
300 return 1; 313 return 1;
301 } 314 }
302 315
303 /*---------------------------------------------------------------------------*/ 316 /*---------------------------------------------------------------------------*/
304 /* Function Name : prot_dataflash */ 317 /* Function Name : prot_dataflash */
305 /* Object : Test if destination area is protected */ 318 /* Object : Test if destination area is protected */
306 /*---------------------------------------------------------------------------*/ 319 /*---------------------------------------------------------------------------*/
307 int prot_dataflash (AT91PS_DataFlash pdataFlash, unsigned long addr) 320 int prot_dataflash (AT91PS_DataFlash pdataFlash, unsigned long addr)
308 { 321 {
309 int area; 322 int area;
310 323
311 /* find area */ 324 /* find area */
312 for (area=0; area < NB_DATAFLASH_AREA; area++) { 325 for (area=0; area < NB_DATAFLASH_AREA; area++) {
313 if ((addr >= pdataFlash->pDevice->area_list[area].start) && 326 if ((addr >= pdataFlash->pDevice->area_list[area].start) &&
314 (addr < pdataFlash->pDevice->area_list[area].end)) 327 (addr < pdataFlash->pDevice->area_list[area].end))
315 break; 328 break;
316 } 329 }
317 if (area == NB_DATAFLASH_AREA) 330 if (area == NB_DATAFLASH_AREA)
318 return -1; 331 return -1;
319 332
320 /*test protection value*/ 333 /*test protection value*/
321 if (pdataFlash->pDevice->area_list[area].protected == FLAG_PROTECT_SET) 334 if (pdataFlash->pDevice->area_list[area].protected == FLAG_PROTECT_SET)
322 return 0; 335 return 0;
323 if (pdataFlash->pDevice->area_list[area].protected == FLAG_PROTECT_INVALID) 336 if (pdataFlash->pDevice->area_list[area].protected == FLAG_PROTECT_INVALID)
324 return 0; 337 return 0;
325 338
326 return 1; 339 return 1;
327 } 340 }
328 341
329 /*--------------------------------------------------------------------------*/ 342 /*--------------------------------------------------------------------------*/
330 /* Function Name : dataflash_real_protect */ 343 /* Function Name : dataflash_real_protect */
331 /* Object : protect/unprotect area */ 344 /* Object : protect/unprotect area */
332 /*--------------------------------------------------------------------------*/ 345 /*--------------------------------------------------------------------------*/
333 int dataflash_real_protect (int flag, unsigned long start_addr, 346 int dataflash_real_protect (int flag, unsigned long start_addr,
334 unsigned long end_addr) 347 unsigned long end_addr)
335 { 348 {
336 int i,j, area1, area2, addr_valid = 0; 349 int i,j, area1, area2, addr_valid = 0;
337 350
338 /* find dataflash */ 351 /* find dataflash */
339 for (i = 0; i < CFG_MAX_DATAFLASH_BANKS; i++) { 352 for (i = 0; i < CFG_MAX_DATAFLASH_BANKS; i++) {
340 if ((((int) start_addr) & 0xF0000000) == 353 if ((((int) start_addr) & 0xF0000000) ==
341 dataflash_info[i].logical_address) { 354 dataflash_info[i].logical_address) {
342 addr_valid = 1; 355 addr_valid = 1;
343 break; 356 break;
344 } 357 }
345 } 358 }
346 if (!addr_valid) { 359 if (!addr_valid) {
347 return -1; 360 return -1;
348 } 361 }
349 /* find start area */ 362 /* find start area */
350 for (area1=0; area1 < NB_DATAFLASH_AREA; area1++) { 363 for (area1=0; area1 < NB_DATAFLASH_AREA; area1++) {
351 if (start_addr == dataflash_info[i].Device.area_list[area1].start) 364 if (start_addr == dataflash_info[i].Device.area_list[area1].start)
352 break; 365 break;
353 } 366 }
354 if (area1 == NB_DATAFLASH_AREA) return -1; 367 if (area1 == NB_DATAFLASH_AREA) return -1;
355 /* find end area */ 368 /* find end area */
356 for (area2=0; area2 < NB_DATAFLASH_AREA; area2++) { 369 for (area2=0; area2 < NB_DATAFLASH_AREA; area2++) {
357 if (end_addr == dataflash_info[i].Device.area_list[area2].end) 370 if (end_addr == dataflash_info[i].Device.area_list[area2].end)
358 break; 371 break;
359 } 372 }
360 if (area2 == NB_DATAFLASH_AREA) 373 if (area2 == NB_DATAFLASH_AREA)
361 return -1; 374 return -1;
362 375
363 /*set protection value*/ 376 /*set protection value*/
364 for(j = area1; j < area2+1 ; j++) 377 for(j = area1; j < area2+1 ; j++)
365 if(dataflash_info[i].Device.area_list[j].protected 378 if(dataflash_info[i].Device.area_list[j].protected
366 != FLAG_PROTECT_INVALID) { 379 != FLAG_PROTECT_INVALID) {
367 if (flag == 0) { 380 if (flag == 0) {
368 dataflash_info[i].Device.area_list[j].protected 381 dataflash_info[i].Device.area_list[j].protected
369 = FLAG_PROTECT_CLEAR; 382 = FLAG_PROTECT_CLEAR;
370 } else { 383 } else {
371 dataflash_info[i].Device.area_list[j].protected 384 dataflash_info[i].Device.area_list[j].protected
372 = FLAG_PROTECT_SET; 385 = FLAG_PROTECT_SET;
373 } 386 }
374 } 387 }
375 388
376 return (area2-area1+1); 389 return (area2-area1+1);
377 } 390 }
378 391
379 /*---------------------------------------------------------------------------*/ 392 /*---------------------------------------------------------------------------*/
380 /* Function Name : read_dataflash */ 393 /* Function Name : read_dataflash */
381 /* Object : dataflash memory read */ 394 /* Object : dataflash memory read */
382 /*---------------------------------------------------------------------------*/ 395 /*---------------------------------------------------------------------------*/
383 int read_dataflash (unsigned long addr, unsigned long size, char *result) 396 int read_dataflash (unsigned long addr, unsigned long size, char *result)
384 { 397 {
385 unsigned long AddrToRead = addr; 398 unsigned long AddrToRead = addr;
386 AT91PS_DataFlash pFlash = &DataFlashInst; 399 AT91PS_DataFlash pFlash = &DataFlashInst;
387 400
388 pFlash = AT91F_DataflashSelect (pFlash, &AddrToRead); 401 pFlash = AT91F_DataflashSelect (pFlash, &AddrToRead);
389 402
390 if (pFlash == 0) 403 if (pFlash == 0)
391 return ERR_UNKNOWN_FLASH_TYPE; 404 return ERR_UNKNOWN_FLASH_TYPE;
392 405
393 if (size_dataflash(pFlash,addr,size) == 0) 406 if (size_dataflash(pFlash,addr,size) == 0)
394 return ERR_INVAL; 407 return ERR_INVAL;
395 408
396 return (AT91F_DataFlashRead (pFlash, AddrToRead, size, result)); 409 return (AT91F_DataFlashRead (pFlash, AddrToRead, size, result));
397 } 410 }
398 411
399 /*---------------------------------------------------------------------------*/ 412 /*---------------------------------------------------------------------------*/
400 /* Function Name : write_dataflash */ 413 /* Function Name : write_dataflash */
401 /* Object : write a block in dataflash */ 414 /* Object : write a block in dataflash */
402 /*---------------------------------------------------------------------------*/ 415 /*---------------------------------------------------------------------------*/
403 int write_dataflash (unsigned long addr_dest, unsigned long addr_src, 416 int write_dataflash (unsigned long addr_dest, unsigned long addr_src,
404 unsigned long size) 417 unsigned long size)
405 { 418 {
406 unsigned long AddrToWrite = addr_dest; 419 unsigned long AddrToWrite = addr_dest;
407 AT91PS_DataFlash pFlash = &DataFlashInst; 420 AT91PS_DataFlash pFlash = &DataFlashInst;
408 421
409 pFlash = AT91F_DataflashSelect (pFlash, &AddrToWrite); 422 pFlash = AT91F_DataflashSelect (pFlash, &AddrToWrite);
410 423
411 if (pFlash == 0) 424 if (pFlash == 0)
412 return ERR_UNKNOWN_FLASH_TYPE; 425 return ERR_UNKNOWN_FLASH_TYPE;
413 426
414 if (size_dataflash(pFlash,addr_dest,size) == 0) 427 if (size_dataflash(pFlash,addr_dest,size) == 0)
415 return ERR_INVAL; 428 return ERR_INVAL;
416 429
417 if (prot_dataflash(pFlash,addr_dest) == 0) 430 if (prot_dataflash(pFlash,addr_dest) == 0)
418 return ERR_PROTECTED; 431 return ERR_PROTECTED;
419 432
420 if (AddrToWrite == -1) 433 if (AddrToWrite == -1)
421 return -1; 434 return -1;
422 435
423 return AT91F_DataFlashWrite (pFlash, (uchar *)addr_src, 436 return AT91F_DataFlashWrite (pFlash, (uchar *)addr_src,
424 AddrToWrite, size); 437 AddrToWrite, size);
425 } 438 }
426 439
427 void dataflash_perror (int err) 440 void dataflash_perror (int err)
428 { 441 {
429 switch (err) { 442 switch (err) {
430 case ERR_OK: 443 case ERR_OK:
431 break; 444 break;
432 case ERR_TIMOUT: 445 case ERR_TIMOUT:
433 printf("Timeout writing to DataFlash\n"); 446 printf("Timeout writing to DataFlash\n");
434 break; 447 break;
435 case ERR_PROTECTED: 448 case ERR_PROTECTED:
436 printf("Can't write to protected/invalid DataFlash sectors\n"); 449 printf("Can't write to protected/invalid DataFlash sectors\n");
437 break; 450 break;
438 case ERR_INVAL: 451 case ERR_INVAL:
439 printf("Outside available DataFlash\n"); 452 printf("Outside available DataFlash\n");
440 break; 453 break;
441 case ERR_UNKNOWN_FLASH_TYPE: 454 case ERR_UNKNOWN_FLASH_TYPE:
442 printf("Unknown Type of DataFlash\n"); 455 printf("Unknown Type of DataFlash\n");
443 break; 456 break;
444 case ERR_PROG_ERROR: 457 case ERR_PROG_ERROR:
445 printf("General DataFlash Programming Error\n"); 458 printf("General DataFlash Programming Error\n");
446 break; 459 break;
447 default: 460 default:
448 printf("%s[%d] FIXME: rc=%d\n", __FILE__, __LINE__, err); 461 printf("%s[%d] FIXME: rc=%d\n", __FILE__, __LINE__, err);
449 break; 462 break;
450 } 463 }
451 } 464 }
452 465
1 /* 1 /*
2 * (C) Copyright 2003 2 * (C) Copyright 2003
3 * Data Flash Atmel Description File 3 * Data Flash Atmel Description File
4 * Author : Hamid Ikdoumi (Atmel) 4 * Author : Hamid Ikdoumi (Atmel)
5 * 5 *
6 * See file CREDITS for list of people who contributed to this 6 * See file CREDITS for list of people who contributed to this
7 * project. 7 * project.
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as 10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of 11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version. 12 * the License, or (at your option) any later version.
13 * 13 *
14 * This program is distributed in the hope that it will be useful, 14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 * 18 *
19 * You should have received a copy of the GNU General Public License 19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software 20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22 * MA 02111-1307 USA 22 * MA 02111-1307 USA
23 */ 23 */
24 24
25 /* File Name : dataflash.h */ 25 /* File Name : dataflash.h */
26 /* Object : Data Flash Atmel Description File */ 26 /* Object : Data Flash Atmel Description File */
27 /* Translator : */ 27 /* Translator : */
28 /* */ 28 /* */
29 /* 1.0 03/04/01 HI : Creation */ 29 /* 1.0 03/04/01 HI : Creation */
30 /* 1.2 20/10/02 FB : Adapatation Service and Lib v3 */ 30 /* 1.2 20/10/02 FB : Adapatation Service and Lib v3 */
31 /*----------------------------------------------------------------------*/ 31 /*----------------------------------------------------------------------*/
32 32
33 #ifndef _DataFlash_h 33 #ifndef _DataFlash_h
34 #define _DataFlash_h 34 #define _DataFlash_h
35 35
36 36
37 #include <asm/arch/hardware.h> 37 #include <asm/arch/hardware.h>
38 #include "config.h" 38 #include "config.h"
39 39
40 /*number of protected area*/ 40 /*number of protected area*/
41 #define NB_DATAFLASH_AREA 5 41 #define NB_DATAFLASH_AREA 5
42 42
43 #ifdef CFG_NO_FLASH 43 #ifdef CFG_NO_FLASH
44 44
45 /*----------------------------------------------------------------------- 45 /*-----------------------------------------------------------------------
46 * return codes from flash_write(): 46 * return codes from flash_write():
47 */ 47 */
48 # define ERR_OK 0 48 # define ERR_OK 0
49 # define ERR_TIMOUT 1 49 # define ERR_TIMOUT 1
50 # define ERR_NOT_ERASED 2 50 # define ERR_NOT_ERASED 2
51 # define ERR_PROTECTED 4 51 # define ERR_PROTECTED 4
52 # define ERR_INVAL 8 52 # define ERR_INVAL 8
53 # define ERR_ALIGN 16 53 # define ERR_ALIGN 16
54 # define ERR_UNKNOWN_FLASH_VENDOR 32 54 # define ERR_UNKNOWN_FLASH_VENDOR 32
55 # define ERR_UNKNOWN_FLASH_TYPE 64 55 # define ERR_UNKNOWN_FLASH_TYPE 64
56 # define ERR_PROG_ERROR 128 56 # define ERR_PROG_ERROR 128
57 57
58 /*----------------------------------------------------------------------- 58 /*-----------------------------------------------------------------------
59 * Protection Flags for flash_protect(): 59 * Protection Flags for flash_protect():
60 */ 60 */
61 # define FLAG_PROTECT_SET 0x01 61 # define FLAG_PROTECT_SET 0x01
62 # define FLAG_PROTECT_CLEAR 0x02 62 # define FLAG_PROTECT_CLEAR 0x02
63 # define FLAG_PROTECT_INVALID 0x03 63 # define FLAG_PROTECT_INVALID 0x03
64 64
65 /*----------------------------------------------------------------------- 65 /*-----------------------------------------------------------------------
66 * Set Environment according to label: 66 * Set Environment according to label:
67 */ 67 */
68 # define FLAG_SETENV 0x80 68 # define FLAG_SETENV 0x80
69 #endif /* CFG_NO_FLASH */ 69 #endif /* CFG_NO_FLASH */
70 70
71 /*define the area structure*/ 71 /*define the area structure*/
72 typedef struct { 72 typedef struct {
73 unsigned long start; 73 unsigned long start;
74 unsigned long end; 74 unsigned long end;
75 unsigned char protected; 75 unsigned char protected;
76 unsigned char setenv; 76 unsigned char setenv;
77 unsigned char label[20]; 77 unsigned char label[20];
78 } dataflash_protect_t; 78 } dataflash_protect_t;
79 79
80 typedef unsigned int AT91S_DataFlashStatus; 80 typedef unsigned int AT91S_DataFlashStatus;
81 81
82 /*----------------------------------------------------------------------*/ 82 /*----------------------------------------------------------------------*/
83 /* DataFlash Structures */ 83 /* DataFlash Structures */
84 /*----------------------------------------------------------------------*/ 84 /*----------------------------------------------------------------------*/
85 85
86 /*---------------------------------------------*/ 86 /*---------------------------------------------*/
87 /* DataFlash Descriptor Structure Definition */ 87 /* DataFlash Descriptor Structure Definition */
88 /*---------------------------------------------*/ 88 /*---------------------------------------------*/
89 typedef struct _AT91S_DataflashDesc { 89 typedef struct _AT91S_DataflashDesc {
90 unsigned char *tx_cmd_pt; 90 unsigned char *tx_cmd_pt;
91 unsigned int tx_cmd_size; 91 unsigned int tx_cmd_size;
92 unsigned char *rx_cmd_pt; 92 unsigned char *rx_cmd_pt;
93 unsigned int rx_cmd_size; 93 unsigned int rx_cmd_size;
94 unsigned char *tx_data_pt; 94 unsigned char *tx_data_pt;
95 unsigned int tx_data_size; 95 unsigned int tx_data_size;
96 unsigned char *rx_data_pt; 96 unsigned char *rx_data_pt;
97 unsigned int rx_data_size; 97 unsigned int rx_data_size;
98 volatile unsigned char state; 98 volatile unsigned char state;
99 volatile unsigned char DataFlash_state; 99 volatile unsigned char DataFlash_state;
100 unsigned char command[8]; 100 unsigned char command[8];
101 } AT91S_DataflashDesc, *AT91PS_DataflashDesc; 101 } AT91S_DataflashDesc, *AT91PS_DataflashDesc;
102 102
103 /*---------------------------------------------*/ 103 /*---------------------------------------------*/
104 /* DataFlash device definition structure */ 104 /* DataFlash device definition structure */
105 /*---------------------------------------------*/ 105 /*---------------------------------------------*/
106 typedef struct _AT91S_Dataflash { 106 typedef struct _AT91S_Dataflash {
107 int pages_number; /* dataflash page number */ 107 int pages_number; /* dataflash page number */
108 int pages_size; /* dataflash page size */ 108 int pages_size; /* dataflash page size */
109 int page_offset; /* page offset in command */ 109 int page_offset; /* page offset in command */
110 int byte_mask; /* byte mask in command */ 110 int byte_mask; /* byte mask in command */
111 int cs; 111 int cs;
112 dataflash_protect_t area_list[NB_DATAFLASH_AREA]; /* area protection status */ 112 dataflash_protect_t area_list[NB_DATAFLASH_AREA]; /* area protection status */
113 } AT91S_DataflashFeatures, *AT91PS_DataflashFeatures; 113 } AT91S_DataflashFeatures, *AT91PS_DataflashFeatures;
114 114
115 /*---------------------------------------------*/ 115 /*---------------------------------------------*/
116 /* DataFlash Structure Definition */ 116 /* DataFlash Structure Definition */
117 /*---------------------------------------------*/ 117 /*---------------------------------------------*/
118 typedef struct _AT91S_DataFlash { 118 typedef struct _AT91S_DataFlash {
119 AT91PS_DataflashDesc pDataFlashDesc; /* dataflash descriptor */ 119 AT91PS_DataflashDesc pDataFlashDesc; /* dataflash descriptor */
120 AT91PS_DataflashFeatures pDevice; /* Pointer on a dataflash features array */ 120 AT91PS_DataflashFeatures pDevice; /* Pointer on a dataflash features array */
121 } AT91S_DataFlash, *AT91PS_DataFlash; 121 } AT91S_DataFlash, *AT91PS_DataFlash;
122 122
123 123
124 typedef struct _AT91S_DATAFLASH_INFO { 124 typedef struct _AT91S_DATAFLASH_INFO {
125 125
126 AT91S_DataflashDesc Desc; 126 AT91S_DataflashDesc Desc;
127 AT91S_DataflashFeatures Device; /* Pointer on a dataflash features array */ 127 AT91S_DataflashFeatures Device; /* Pointer on a dataflash features array */
128 unsigned long logical_address; 128 unsigned long logical_address;
129 unsigned long end_address; 129 unsigned long end_address;
130 unsigned int id; /* device id */ 130 unsigned int id; /* device id */
131 } AT91S_DATAFLASH_INFO, *AT91PS_DATAFLASH_INFO; 131 } AT91S_DATAFLASH_INFO, *AT91PS_DATAFLASH_INFO;
132 132
133 struct dataflash_addr { 133 struct dataflash_addr {
134 unsigned long addr; 134 unsigned long addr;
135 int cs; 135 int cs;
136 }; 136 };
137 /*-------------------------------------------------------------------------------------------------*/ 137 /*-------------------------------------------------------------------------------------------------*/
138
139 #define AT45DB161 0x2c 138 #define AT45DB161 0x2c
140 #define AT45DB021 0x14 139 #define AT45DB021 0x14
140 #define AT45DB081 0x24
141 #define AT45DB321 0x34 141 #define AT45DB321 0x34
142 #define AT45DB642 0x3c 142 #define AT45DB642 0x3c
143 #define AT45DB128 0x10 143 #define AT45DB128 0x10
144 #define PAGES_PER_BLOCK 8 144 #define PAGES_PER_BLOCK 8
145 145
146 #define AT91C_DATAFLASH_TIMEOUT 10000 /* For AT91F_DataFlashWaitReady */ 146 #define AT91C_DATAFLASH_TIMEOUT 10000 /* For AT91F_DataFlashWaitReady */
147 147
148 /* DataFlash return value */ 148 /* DataFlash return value */
149 #define DATAFLASH_BUSY 0x00 149 #define DATAFLASH_BUSY 0x00
150 #define DATAFLASH_OK 0x01 150 #define DATAFLASH_OK 0x01
151 #define DATAFLASH_ERROR 0x02 151 #define DATAFLASH_ERROR 0x02
152 #define DATAFLASH_MEMORY_OVERFLOW 0x03 152 #define DATAFLASH_MEMORY_OVERFLOW 0x03
153 #define DATAFLASH_BAD_COMMAND 0x04 153 #define DATAFLASH_BAD_COMMAND 0x04
154 #define DATAFLASH_BAD_ADDRESS 0x05 154 #define DATAFLASH_BAD_ADDRESS 0x05
155 155
156 156
157 /* Driver State */ 157 /* Driver State */
158 #define IDLE 0x0 158 #define IDLE 0x0
159 #define BUSY 0x1 159 #define BUSY 0x1
160 #define ERROR 0x2 160 #define ERROR 0x2
161 161
162 /* DataFlash Driver State */ 162 /* DataFlash Driver State */
163 #define GET_STATUS 0x0F 163 #define GET_STATUS 0x0F
164 164
165 /*-------------------------------------------------------------------------------------------------*/ 165 /*-------------------------------------------------------------------------------------------------*/
166 /* Command Definition */ 166 /* Command Definition */
167 /*-------------------------------------------------------------------------------------------------*/ 167 /*-------------------------------------------------------------------------------------------------*/
168 168
169 /* READ COMMANDS */ 169 /* READ COMMANDS */
170 #define DB_CONTINUOUS_ARRAY_READ 0xE8 /* Continuous array read */ 170 #define DB_CONTINUOUS_ARRAY_READ 0xE8 /* Continuous array read */
171 #define DB_BURST_ARRAY_READ 0xE8 /* Burst array read */ 171 #define DB_BURST_ARRAY_READ 0xE8 /* Burst array read */
172 #define DB_PAGE_READ 0xD2 /* Main memory page read */ 172 #define DB_PAGE_READ 0xD2 /* Main memory page read */
173 #define DB_BUF1_READ 0xD4 /* Buffer 1 read */ 173 #define DB_BUF1_READ 0xD4 /* Buffer 1 read */
174 #define DB_BUF2_READ 0xD6 /* Buffer 2 read */ 174 #define DB_BUF2_READ 0xD6 /* Buffer 2 read */
175 #define DB_STATUS 0xD7 /* Status Register */ 175 #define DB_STATUS 0xD7 /* Status Register */
176 176
177 /* PROGRAM and ERASE COMMANDS */ 177 /* PROGRAM and ERASE COMMANDS */
178 #define DB_BUF1_WRITE 0x84 /* Buffer 1 write */ 178 #define DB_BUF1_WRITE 0x84 /* Buffer 1 write */
179 #define DB_BUF2_WRITE 0x87 /* Buffer 2 write */ 179 #define DB_BUF2_WRITE 0x87 /* Buffer 2 write */
180 #define DB_BUF1_PAGE_ERASE_PGM 0x83 /* Buffer 1 to main memory page program with built-In erase */ 180 #define DB_BUF1_PAGE_ERASE_PGM 0x83 /* Buffer 1 to main memory page program with built-In erase */
181 #define DB_BUF1_PAGE_ERASE_FASTPGM 0x93 /* Buffer 1 to main memory page program with built-In erase, Fast program */ 181 #define DB_BUF1_PAGE_ERASE_FASTPGM 0x93 /* Buffer 1 to main memory page program with built-In erase, Fast program */
182 #define DB_BUF2_PAGE_ERASE_PGM 0x86 /* Buffer 2 to main memory page program with built-In erase */ 182 #define DB_BUF2_PAGE_ERASE_PGM 0x86 /* Buffer 2 to main memory page program with built-In erase */
183 #define DB_BUF2_PAGE_ERASE_FASTPGM 0x96 /* Buffer 1 to main memory page program with built-In erase, Fast program */ 183 #define DB_BUF2_PAGE_ERASE_FASTPGM 0x96 /* Buffer 1 to main memory page program with built-In erase, Fast program */
184 #define DB_BUF1_PAGE_PGM 0x88 /* Buffer 1 to main memory page program without built-In erase */ 184 #define DB_BUF1_PAGE_PGM 0x88 /* Buffer 1 to main memory page program without built-In erase */
185 #define DB_BUF1_PAGE_FASTPGM 0x98 /* Buffer 1 to main memory page program without built-In erase, Fast program */ 185 #define DB_BUF1_PAGE_FASTPGM 0x98 /* Buffer 1 to main memory page program without built-In erase, Fast program */
186 #define DB_BUF2_PAGE_PGM 0x89 /* Buffer 2 to main memory page program without built-In erase */ 186 #define DB_BUF2_PAGE_PGM 0x89 /* Buffer 2 to main memory page program without built-In erase */
187 #define DB_BUF2_PAGE_FASTPGM 0x99 /* Buffer 1 to main memory page program without built-In erase, Fast program */ 187 #define DB_BUF2_PAGE_FASTPGM 0x99 /* Buffer 1 to main memory page program without built-In erase, Fast program */
188 #define DB_PAGE_ERASE 0x81 /* Page Erase */ 188 #define DB_PAGE_ERASE 0x81 /* Page Erase */
189 #define DB_BLOCK_ERASE 0x50 /* Block Erase */ 189 #define DB_BLOCK_ERASE 0x50 /* Block Erase */
190 #define DB_PAGE_PGM_BUF1 0x82 /* Main memory page through buffer 1 */ 190 #define DB_PAGE_PGM_BUF1 0x82 /* Main memory page through buffer 1 */
191 #define DB_PAGE_FASTPGM_BUF1 0x92 /* Main memory page through buffer 1, Fast program */ 191 #define DB_PAGE_FASTPGM_BUF1 0x92 /* Main memory page through buffer 1, Fast program */
192 #define DB_PAGE_PGM_BUF2 0x85 /* Main memory page through buffer 2 */ 192 #define DB_PAGE_PGM_BUF2 0x85 /* Main memory page through buffer 2 */
193 #define DB_PAGE_FastPGM_BUF2 0x95 /* Main memory page through buffer 2, Fast program */ 193 #define DB_PAGE_FastPGM_BUF2 0x95 /* Main memory page through buffer 2, Fast program */
194 194
195 /* ADDITIONAL COMMANDS */ 195 /* ADDITIONAL COMMANDS */
196 #define DB_PAGE_2_BUF1_TRF 0x53 /* Main memory page to buffer 1 transfert */ 196 #define DB_PAGE_2_BUF1_TRF 0x53 /* Main memory page to buffer 1 transfert */
197 #define DB_PAGE_2_BUF2_TRF 0x55 /* Main memory page to buffer 2 transfert */ 197 #define DB_PAGE_2_BUF2_TRF 0x55 /* Main memory page to buffer 2 transfert */
198 #define DB_PAGE_2_BUF1_CMP 0x60 /* Main memory page to buffer 1 compare */ 198 #define DB_PAGE_2_BUF1_CMP 0x60 /* Main memory page to buffer 1 compare */
199 #define DB_PAGE_2_BUF2_CMP 0x61 /* Main memory page to buffer 2 compare */ 199 #define DB_PAGE_2_BUF2_CMP 0x61 /* Main memory page to buffer 2 compare */
200 #define DB_AUTO_PAGE_PGM_BUF1 0x58 /* Auto page rewrite throught buffer 1 */ 200 #define DB_AUTO_PAGE_PGM_BUF1 0x58 /* Auto page rewrite throught buffer 1 */
201 #define DB_AUTO_PAGE_PGM_BUF2 0x59 /* Auto page rewrite throught buffer 2 */ 201 #define DB_AUTO_PAGE_PGM_BUF2 0x59 /* Auto page rewrite throught buffer 2 */
202 202
203 /*-------------------------------------------------------------------------------------------------*/ 203 /*-------------------------------------------------------------------------------------------------*/
204 204
205 extern int size_dataflash (AT91PS_DataFlash pdataFlash, unsigned long addr, unsigned long size); 205 extern int size_dataflash (AT91PS_DataFlash pdataFlash, unsigned long addr, unsigned long size);
206 extern int prot_dataflash (AT91PS_DataFlash pdataFlash, unsigned long addr); 206 extern int prot_dataflash (AT91PS_DataFlash pdataFlash, unsigned long addr);
207 extern int addr2ram(ulong addr); 207 extern int addr2ram(ulong addr);
208 extern int dataflash_real_protect (int flag, unsigned long start_addr, unsigned long end_addr); 208 extern int dataflash_real_protect (int flag, unsigned long start_addr, unsigned long end_addr);
209 extern int addr_dataflash (unsigned long addr); 209 extern int addr_dataflash (unsigned long addr);
210 extern int read_dataflash (unsigned long addr, unsigned long size, char *result); 210 extern int read_dataflash (unsigned long addr, unsigned long size, char *result);
211 extern int write_dataflash (unsigned long addr, unsigned long dest, unsigned long size); 211 extern int write_dataflash (unsigned long addr, unsigned long dest, unsigned long size);
212 extern void dataflash_print_info (void); 212 extern void dataflash_print_info (void);
213 extern void dataflash_perror (int err); 213 extern void dataflash_perror (int err);
214 extern void AT91F_DataflashSetEnv (void); 214 extern void AT91F_DataflashSetEnv (void);
215 215
216 extern struct dataflash_addr cs[CFG_MAX_DATAFLASH_BANKS]; 216 extern struct dataflash_addr cs[CFG_MAX_DATAFLASH_BANKS];
217 extern dataflash_protect_t area_list[NB_DATAFLASH_AREA]; 217 extern dataflash_protect_t area_list[NB_DATAFLASH_AREA];
218 extern AT91S_DATAFLASH_INFO dataflash_info[]; 218 extern AT91S_DATAFLASH_INFO dataflash_info[];
219 #endif 219 #endif