Use the same memory initialization for compressed and uncompressed version, some...
[oweals/u-boot_mod.git] / u-boot / include / flash.h
1 /*
2  * (C) Copyright 2000-2005
3  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4  *
5  * See file CREDITS for list of people who contributed to this
6  * project.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License as
10  * published by the Free Software Foundation; either version 2 of
11  * the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21  * MA 02111-1307 USA
22  */
23
24 #ifndef _FLASH_H_
25 #define _FLASH_H_
26
27 #ifndef CFG_NO_FLASH
28 /*-----------------------------------------------------------------------
29  * FLASH Info: contains chip specific data, per FLASH bank
30  */
31
32 typedef struct {
33         ulong   size;                                                   /* total bank size in bytes             */
34         ulong   sector_size;                                    /* size of erase unit in bytes */
35         ushort  sector_count;                                   /* number of erase units                */
36         ulong   flash_id;                                               /* combined device & manufacturer code  */
37         ulong   start[CFG_MAX_FLASH_SECT];              /* physical sector start addresses */
38         uchar   protect[CFG_MAX_FLASH_SECT];    /* sector protection status     */
39 } flash_info_t;
40
41
42 /* Prototypes */
43 extern unsigned long flash_init (void);
44 extern int flash_erase(flash_info_t *, int, int);
45 extern int flash_sect_erase(ulong addr_first, ulong addr_last);
46 extern int flash_sect_protect(int flag, ulong addr_first, ulong addr_last);
47
48 /* common/flash.c */
49 extern int flash_write(char *, ulong, ulong);
50 extern flash_info_t *addr2info(ulong);
51 extern int write_buff(flash_info_t *info, uchar *src, ulong addr, ulong cnt);
52
53 /*-----------------------------------------------------------------------
54  * return codes from flash_write():
55  */
56 #define ERR_OK                                          0
57 #define ERR_TIMOUT                                      1
58 #define ERR_NOT_ERASED                          2
59 #define ERR_PROTECTED                           4
60 #define ERR_INVAL                                       8
61 #define ERR_ALIGN                                       16
62 #define ERR_UNKNOWN_FLASH_VENDOR        32
63 #define ERR_UNKNOWN_FLASH_TYPE          64
64 #define ERR_PROG_ERROR                          128
65
66 /*-----------------------------------------------------------------------
67  * Device IDs
68  */
69 #define FLASH_CUSTOM    0x1111
70 #define FLASH_UNKNOWN   0xFFFF          /* unknown flash type */
71
72 #endif /* !CFG_NO_FLASH */
73
74 #endif /* _FLASH_H_ */