RT-AC66 3.0.0.4.374.130 core
[tomato.git] / release / src-rt-6.x / cfe / cfe / arch / mips / board / bcm96345 / include / cfiflash.h
blob7c3e6bf554c8890f71ad3601e2057b6f68d252d9
1 /************************************************************************/
2 /* */
3 /* AMD CFI Enabled Flash Memory Drivers */
4 /* File name: CFIFLASH.H */
5 /* Revision: 1.0 5/07/98 */
6 /* */
7 /* Copyright (c) 1998 ADVANCED MICRO DEVICES, INC. All Rights Reserved. */
8 /* This software is unpublished and contains the trade secrets and */
9 /* confidential proprietary information of AMD. Unless otherwise */
10 /* provided in the Software Agreement associated herewith, it is */
11 /* licensed in confidence "AS IS" and is not to be reproduced in whole */
12 /* or part by any means except for backup. Use, duplication, or */
13 /* disclosure by the Government is subject to the restrictions in */
14 /* paragraph (b) (3) (B) of the Rights in Technical Data and Computer */
15 /* Software clause in DFAR 52.227-7013 (a) (Oct 1988). */
16 /* Software owned by */
17 /* Advanced Micro Devices, Inc., */
18 /* One AMD Place, */
19 /* P.O. Box 3453 */
20 /* Sunnyvale, CA 94088-3453. */
21 /************************************************************************/
22 /* This software constitutes a basic shell of source code for */
23 /* programming all AMD Flash components. AMD */
24 /* will not be responsible for misuse or illegal use of this */
25 /* software for devices not supported herein. AMD is providing */
26 /* this source code "AS IS" and will not be responsible for */
27 /* issues arising from incorrect user implementation of the */
28 /* source code herein. It is the user's responsibility to */
29 /* properly design-in this source code. */
30 /* */
31 /************************************************************************/
32 #ifndef _CFIFLASH_H
33 #define _CFIFLASH_H
35 #if defined __cplusplus
36 extern "C" {
37 #endif
39 /* include board/CPU specific definitions */
40 #include "bcmtypes.h"
41 #include "board.h"
43 #define FLASH_BASE_ADDR_REG FLASH_BASE
45 #define FAR
47 #ifndef NULL
48 #define NULL 0
49 #endif
51 #define MAXSECTORS 128 /* maximum number of sectors supported */
53 /* A structure for identifying a flash part. There is one for each
54 * of the flash part definitions. We need to keep track of the
55 * sector organization, the address register used, and the size
56 * of the sectors.
58 struct flashinfo {
59 char *name; /* "Am29DL800T", etc. */
60 unsigned long addr; /* physical address, once translated */
61 int areg; /* Can be set to zero for all parts */
62 int nsect; /* # of sectors -- 19 in LV, 22 in DL */
63 int bank1start; /* first sector # in bank 1 */
64 int bank2start; /* first sector # in bank 2, if DL part */
65 struct {
66 long size; /* # of bytes in this sector */
67 long base; /* offset from beginning of device */
68 int bank; /* 1 or 2 for DL; 1 for LV */
69 } sec[MAXSECTORS]; /* per-sector info */
73 * This structure holds all CFI query information as defined
74 * in the JEDEC standard. All information up to
75 * primary_extended_query is standard among all amnufactures
76 * with CFI enabled devices.
79 struct cfi_query {
80 char query_string[4]; /* Should be 'QRY' */
81 WORD oem_command_set; /* Command set */
82 WORD primary_table_address; /* Addy of entended table */
83 WORD alt_command_set; /* Alt table */
84 WORD alt_table_address; /* Alt table addy */
85 int vcc_min; /* Vcc minimum */
86 int vcc_max; /* Vcc maximum */
87 int vpp_min; /* Vpp minimum, if supported */
88 int vpp_max; /* Vpp maximum, if supported */
89 int timeout_single_write; /* Time of single write */
90 int timeout_buffer_write; /* Time of buffer write */
91 int timeout_block_erase; /* Time of sector erase */
92 int timeout_chip_erase; /* Time of chip erase */
93 int max_timeout_single_write; /* Max time of single write */
94 int max_timeout_buffer_write; /* Max time of buffer write */
95 int max_timeout_block_erase; /* Max time of sector erase */
96 int max_timeout_chip_erase; /* Max time of chip erase */
97 long device_size; /* Device size in bytes */
98 WORD interface_description; /* Interface description */
99 int max_multi_byte_write; /* Time of multi-byte write */
100 int num_erase_blocks; /* Number of sector defs. */
101 struct {
102 unsigned long sector_size; /* byte size of sector */
103 int num_sectors; /* Num sectors of this size */
104 } erase_block[8]; /* Max of 256, but 8 is good */
105 char primary_extended_query[4]; /* Vendor specific info here */
106 WORD major_version; /* Major code version */
107 WORD minor_version; /* Minor code version */
108 BYTE sensitive_unlock; /* Is byte sensitive unlock? */
109 BYTE erase_suspend; /* Capable of erase suspend? */
110 BYTE sector_protect; /* Can Sector protect? */
111 BYTE sector_temp_unprotect; /* Can we temporarily unprotect? */
112 BYTE protect_scheme; /* Scheme of unprotection */
113 BYTE is_simultaneous; /* Is a smulataneous part? */
114 BYTE is_burst; /* Is a burst mode part? */
115 BYTE is_page; /* Is a page mode part? */
118 /* Standard Boolean declarations */
119 #define TRUE 1
120 #define FALSE 0
122 /* Command codes for the flash_command routine */
123 #define FLASH_SELECT 0 /* no command; just perform the mapping */
124 #define FLASH_RESET 1 /* reset to read mode */
125 #define FLASH_READ 1 /* reset to read mode, by any other name */
126 #define FLASH_AUTOSEL 2 /* autoselect (fake Vid on pin 9) */
127 #define FLASH_PROG 3 /* program a word */
128 #define FLASH_CERASE 4 /* chip erase */
129 #define FLASH_SERASE 5 /* sector erase */
130 #define FLASH_ESUSPEND 6 /* suspend sector erase */
131 #define FLASH_ERESUME 7 /* resume sector erase */
132 #define FLASH_UB 8 /* go into unlock bypass mode */
133 #define FLASH_UBPROG 9 /* program a word using unlock bypass */
134 #define FLASH_UBRESET 10 /* reset to read mode from unlock bypass mode */
135 #define FLASH_CFIQUERY 11 /* CFI query */
136 #define FLASH_LASTCMD 11 /* used for parameter checking */
138 /* Return codes from flash_status */
139 #define STATUS_READY 0 /* ready for action */
140 #define STATUS_BUSY 1 /* operation in progress */
141 #define STATUS_ERSUSP 2 /* erase suspended */
142 #define STATUS_TIMEOUT 3 /* operation timed out */
143 #define STATUS_ERROR 4 /* unclassified but unhappy status */
145 /* Used to mask of bytes from word data */
146 #define HIGH_BYTE(a) (a >> 8)
147 #define LOW_BYTE(a) (a & 0xFF)
149 /* AMD's manufacturer ID */
150 #define AMDPART 0x01
152 /* A list of 4 AMD device ID's - add others as needed */
153 #define ID_AM29DL800T 0x224A
154 #define ID_AM29DL800B 0x22CB
155 #define ID_AM29LV800T 0x22DA
156 #define ID_AM29LV800B 0x225B
157 #define ID_AM29LV400B 0x22BA
159 #define ID_AM29LV160B 0x2249 // 2MG R board BottomBoot
160 #define ID_AM29LV160T 0x22C4 // 2MG R board topboot
161 #define ID_AM29LV320T 0x22F6 // 4MG SV board TB
162 #define ID_AM29LV320B 0x22F9 // 4MG SV baord BB
164 /* An index into the memdesc organization array. Is set by init_flash */
165 /* so the proper sector tables are used in the correct device */
166 /* Add others as needed, and as added to the device ID section */
168 #define AM29DL800T 0
169 #define AM29DL800B 1
170 #define AM29LV800T 2
171 #define AM29LV800B 3
172 #define AM29LV160B 4
173 #define AM29LV400B 5
176 extern BYTE flash_init(void);
177 extern BYTE flash_reset(void);
179 extern BYTE flash_ub(BYTE sector);
180 extern int flash_write_buf_ub(BYTE sector, int offset,
181 BYTE *buffer, int numbytes);
182 extern BYTE flash_reset_ub(void);
184 extern BYTE flash_write_word(BYTE sector, int offset, WORD data);
185 extern int flash_write_buf(BYTE sector, int offset,
186 BYTE *buffer, int numbytes);
187 extern BYTE flash_sector_erase(BYTE sector);
188 extern BYTE flash_erase_suspend(BYTE sector);
189 extern BYTE flash_erase_resume(BYTE sector);
191 extern BYTE flash_sector_erase_int(BYTE sector);
193 extern int flash_get_numsectors(void);
194 extern int flash_get_sector_size(BYTE sector);
195 extern int flash_get_total_size(void);
196 extern BYTE flash_sector_protect_verify(BYTE sector);
197 extern int flash_read_buf(byte sector, int offset, byte *buffer, int numbytes);
198 extern unsigned char *flash_get_memptr(byte sector);
199 extern int flash_get_blk(int addr);
201 #if defined __cplusplus
203 #endif
205 #endif