allow coexistance of N build and AC build.
[tomato.git] / release / src-rt-6.x / cfe / cfe / include / dev_flash.h
blob8cbce486a1611e4533b1d8a600e22a8a70cd572e
1 /* *********************************************************************
2 * Broadcom Common Firmware Environment (CFE)
3 *
4 * Flash memory definitions File: dev_flash.h
5 *
6 * Stuff we use when manipulating flash memory devices.
7 *
8 * Author: Mitch Lichtenberg (mpl@broadcom.com)
9 *
10 *********************************************************************
12 * Copyright 2000,2001,2002,2003
13 * Broadcom Corporation. All rights reserved.
15 * This software is furnished under license and may be used and
16 * copied only in accordance with the following terms and
17 * conditions. Subject to these conditions, you may download,
18 * copy, install, use, modify and distribute modified or unmodified
19 * copies of this software in source and/or binary form. No title
20 * or ownership is transferred hereby.
22 * 1) Any source code used, modified or distributed must reproduce
23 * and retain this copyright notice and list of conditions
24 * as they appear in the source file.
26 * 2) No right is granted to use any trade name, trademark, or
27 * logo of Broadcom Corporation. The "Broadcom Corporation"
28 * name may not be used to endorse or promote products derived
29 * from this software without the prior written permission of
30 * Broadcom Corporation.
32 * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
33 * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
34 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
35 * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
36 * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
37 * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
38 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
39 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
40 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
41 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
42 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
43 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
44 * THE POSSIBILITY OF SUCH DAMAGE.
45 ********************************************************************* */
48 * AMD Flash commands and magic offsets
51 #define AMD_FLASH_MAGIC_ADDR_1 0x555 /* AAA for 16-bit devices in 8-bit mode */
52 #define AMD_FLASH_MAGIC_ADDR_2 0x2AA /* 554 for 16-bit devices in 8-bit mode */
54 #define AMD_FLASH_RESET 0xF0
55 #define AMD_FLASH_MAGIC_1 0xAA
56 #define AMD_FLASH_MAGIC_2 0x55
57 #define AMD_FLASH_AUTOSEL 0x90
58 #define AMD_FLASH_PROGRAM 0xA0
59 #define AMD_FLASH_UNLOCK_BYPASS 0x20
60 #define AMD_FLASH_ERASE_3 0x80
61 #define AMD_FLASH_ERASE_4 0xAA
62 #define AMD_FLASH_ERASE_5 0x55
63 #define AMD_FLASH_ERASE_ALL_6 0x10
64 #define AMD_FLASH_ERASE_SEC_6 0x30
67 * INTEL Flash commands and magic offsets
70 #define INTEL_FLASH_READ_MODE 0xFF
71 #define INTEL_FLASH_ERASE_BLOCK 0x20
72 #define INTEL_FLASH_ERASE_CONFIRM 0xD0
73 #define INTEL_FLASH_PROGRAM 0x40
75 /* INTEL Flash commands for 16-bit mode */
76 #define INTEL_FLASH_16BIT_READ_MODE 0xFF00
77 #define INTEL_FLASH_16BIT_ERASE_BLOCK 0x2000
78 #define INTEL_FLASH_16BIT_ERASE_CONFIRM 0xD000
79 #define INTEL_FLASH_16BIT_PROGRAM 0x4000
80 #define INTEL_FLASH_8BIT 0
81 #define INTEL_FLASH_16BIT 1
85 * Common Flash Interface (CFI) commands and offsets
88 #define FLASH_CFI_QUERY_ADDR 0x55
89 #define FLASH_CFI_QUERY_MODE 0x98
90 #define FLASH_CFI_QUERY_EXIT 0xFF
92 #define FLASH_CFI_MANUFACTURER 0x00
93 #define FLASH_CFI_DEVICE 0x01
94 #define FLASH_CFI_SIGNATURE 0x10
95 #define FLASH_CFI_QUERY_STRING 0x10
96 #define FLASH_CFI_COMMAND_SET 0x13
97 #define FLASH_CFI_DEVICE_SIZE 0x27
98 #define FLASH_CFI_DEVICE_INTERFACE 0x28
99 #define FLASH_CFI_REGION_COUNT 0x2C
100 #define FLASH_CFI_REGION_TABLE 0x2D
102 #define FLASH_CFI_CMDSET_INTEL_ECS 0x0001 /* Intel extended */
103 #define FLASH_CFI_CMDSET_AMD_STD 0x0002 /* AMD Standard */
104 #define FLASH_CFI_CMDSET_INTEL_STD 0x0003 /* Intel Standard */
105 #define FLASH_CFI_CMDSET_AMD_ECS 0x0004 /* AMD Extended */
107 #define FLASH_CFI_DEVIF_X8 0x0000 /* 8-bit asynchronous */
108 #define FLASH_CFI_DEVIF_X16 0x0001 /* 16-bit asynchronous */
109 #define FLASH_CFI_DEVIF_X8X16 0x0002 /* 8 or 16-bit with BYTE# pin */
110 #define FLASH_CFI_DEVIF_X32 0x0003 /* 32-bit asynchronous */
113 * JEDEC offsets
116 #define FLASH_JEDEC_OFFSET_MFR 0
117 #define FLASH_JEDEC_OFFSET_DEV 1
119 /* Vendor-specific flash identifiers */
121 #define FLASH_MFR_HYUNDAI 0xAD
123 /* *********************************************************************
124 * Macros for defining custom sector tables
125 ********************************************************************* */
127 #define FLASH_SECTOR_RANGE(nblks,size) (((nblks)-1) << 16) + ((size)/256)
128 #define FLASH_SECTOR_NBLKS(x) (((x) >> 16)+1)
129 #define FLASH_SECTOR_SIZE(x) (((x) & 0xFFFF)*256)
130 #define FLASH_MAXSECTORS 8
133 /* *********************************************************************
134 * Structures
135 ********************************************************************* */
138 * This structure is passed in the "probe_ptr" field of the
139 * flash's probe routines and can be used for advanced
140 * configuration. If you pass this structure, probe_a and
141 * probe_b will be ignored by the driver
143 * flash_prog_phys is the base address you use for flash commands -
144 * you can put 0 here if it's the same as flash_phys. some boards,
145 * like the Algor P5064, have a different PA region used for doing
146 * byte accesses to the flash. In this case the special
147 * "flash_prog_phys" field is used for that.
151 #define FLASH_FLG_NVRAM 0x00000001 /* Reserve space for NVRAM */
152 #define FLASH_FLG_AUTOSIZE 0x00000002 /* resize to actual device size */
153 #define FLASH_FLG_16BIT 0x00000004 /* it's a 16-bit ROM in 16-bit mode */
154 #define FLASH_FLG_MANUAL 0x00000008 /* Not CFI, manual sectoring */
155 #define FLASH_FLG_WIDE 0x00000010 /* must shift control addresses left one bit */
157 #ifndef __ASSEMBLER__
158 typedef struct flash_probe_t {
159 long flash_phys;
160 long flash_prog_phys; /* base address for programming, if different */
161 int flash_size; /* total flash size */
162 int flash_flags;
163 /* The following are used when manually sectoring */
164 int flash_cmdset;
165 int flash_nsectors; /* number of ranges */
166 int flash_sectors[FLASH_MAXSECTORS];
167 } flash_probe_t;
168 #endif