http://www.usr.com/support/gpl/USR9107_release1.1.tar.gz
[bcm963xx.git] / bcmdrivers / opensource / char / board / bcm963xx / impl1 / cfiflash.h
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
34
35 #if defined __cplusplus
36 extern "C" {
37 #endif
38
39 /* include board/CPU specific definitions */
40 #include "bcmtypes.h"
41 #include "board.h"
42
43 #define FLASH_BASE_ADDR_REG FLASH_BASE
44
45 #ifndef NULL
46 #define NULL 0
47 #endif
48
49 #define MAXSECTORS  1024      /* maximum number of sectors supported */
50
51 /* A structure for identifying a flash part.  There is one for each
52  * of the flash part definitions.  We need to keep track of the
53  * sector organization, the address register used, and the size
54  * of the sectors.
55  */
56 struct flashinfo {
57          char *name;         /* "Am29DL800T", etc. */
58          unsigned long addr; /* physical address, once translated */
59          int areg;           /* Can be set to zero for all parts */
60          int nsect;          /* # of sectors -- 19 in LV, 22 in DL */
61          int bank1start;     /* first sector # in bank 1 */
62          int bank2start;     /* first sector # in bank 2, if DL part */
63  struct {
64         long size;           /* # of bytes in this sector */
65         long base;           /* offset from beginning of device */
66         int bank;            /* 1 or 2 for DL; 1 for LV */
67          } sec[MAXSECTORS];  /* per-sector info */
68 };
69
70 /*
71  * This structure holds all CFI query information as defined
72  * in the JEDEC standard. All information up to 
73  * primary_extended_query is standard among all manufactures
74  * with CFI enabled devices.
75  */
76
77 struct cfi_query {
78         int num_erase_blocks;           /* Number of sector defs. */
79         struct {
80           unsigned long sector_size;    /* byte size of sector */
81           int num_sectors;              /* Num sectors of this size */
82         } erase_block[8];               /* Max of 256, but 8 is good */
83 };
84
85 /* Standard Boolean declarations */
86 #define TRUE                            1
87 #define FALSE                           0
88
89 /* Define different type of flash */
90 #define FLASH_UNDEFINED 0
91 #define FLASH_AMD       1
92 #define FLASH_INTEL     2
93 #define FLASH_SST       3
94
95 /* Command codes for the flash_command routine */
96 #define FLASH_RESET     0       /* reset to read mode */
97 #define FLASH_READ_ID   1       /* read device ID */
98 #define FLASH_CFIQUERY  2       /* CFI query */
99 #define FLASH_UB        3       /* go into unlock bypass mode */
100 #define FLASH_PROG      4       /* program a word */
101 #define FLASH_UBRESET   5       /* reset to read mode from unlock bypass mode */
102 #define FLASH_SERASE    6       /* sector erase */
103
104 /* Return codes from flash_status */
105 #define STATUS_READY    0       /* ready for action */
106 #define STATUS_TIMEOUT  1       /* operation timed out */
107
108 /* A list of AMD compatible device ID's - add others as needed */
109 #define ID_AM29DL800T   0x224A
110 #define ID_AM29DL800B   0x22CB
111 #define ID_AM29LV800T   0x22DA
112 #define ID_AM29LV800B   0x225B
113 #define ID_AM29LV400B   0x22BA
114
115 #define ID_AM29LV160B   0x2249
116 #define ID_AM29LV160T   0x22C4
117
118 #define ID_AM29LV320T   0x22F6
119 #define ID_MX29LV320AT  0x22A7
120 #define ID_AM29LV320B   0x22F9
121 #define ID_MX29LV320AB  0x22A8
122
123 #define ID_AM29LV320M   0x227E
124 #define ID_AM29LV320MB  0x2200
125 #define ID_AM29LV320MT  0x2201
126
127 #define ID_SST39VF1601  0x234B
128 #define ID_SST39VF3201  0x235B
129     //  add SST and ST flash device id  here   
130 #define ID_M29W320ET    0x2256
131 #define ID_SST39VF3202  0x235A
132     //  add SST and ST flash device id  here   
133 /* A list of Intel compatible device ID's - add others as needed */
134 #define ID_I28F160C3T   0x88C2
135 #define ID_I28F160C3B   0x88C3
136 #define ID_I28F320C3T   0x88C4
137 #define ID_I28F320C3B   0x88C5
138
139 extern byte flash_init(void);
140 extern int flash_write_buf(WORD sector, int offset, byte *buffer, int numbytes);
141 extern int flash_read_buf(WORD sector, int offset, byte *buffer, int numbytes);
142 extern byte flash_sector_erase_int(WORD sector);
143 extern int flash_get_numsectors(void);
144 extern int flash_get_sector_size(WORD sector);
145 extern int flash_get_total_size(void);
146 extern unsigned char *flash_get_memptr(WORD sector);
147 extern int flash_get_blk(int addr);
148
149 #if defined __cplusplus
150 }
151 #endif
152
153 #endif