OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [devs/] [flash/] [intel/] [strata/] [v2_0/] [src/] [strata.h] - Blame information for rev 27

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
#ifndef CYGONCE_DEVS_FLASH_INTEL_STRATA_FLASH_H
2
#define CYGONCE_DEVS_FLASH_INTEL_STRATA_FLASH_H
3
//==========================================================================
4
//
5
//      strata.h
6
//
7
//      strataFlash programming - device constants, etc.
8
//
9
//==========================================================================
10
//####ECOSGPLCOPYRIGHTBEGIN####
11
// -------------------------------------------
12
// This file is part of eCos, the Embedded Configurable Operating System.
13
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
14
//
15
// eCos is free software; you can redistribute it and/or modify it under
16
// the terms of the GNU General Public License as published by the Free
17
// Software Foundation; either version 2 or (at your option) any later version.
18
//
19
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
20
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
21
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
22
// for more details.
23
//
24
// You should have received a copy of the GNU General Public License along
25
// with eCos; if not, write to the Free Software Foundation, Inc.,
26
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
27
//
28
// As a special exception, if other files instantiate templates or use macros
29
// or inline functions from this file, or you compile this file and link it
30
// with other works to produce a work based on this file, this file does not
31
// by itself cause the resulting work to be covered by the GNU General Public
32
// License. However the source code for this file must still be made available
33
// in accordance with section (3) of the GNU General Public License.
34
//
35
// This exception does not invalidate any other reasons why a work based on
36
// this file might be covered by the GNU General Public License.
37
//
38
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
39
// at http://sources.redhat.com/ecos/ecos-license/
40
// -------------------------------------------
41
//####ECOSGPLCOPYRIGHTEND####
42
//==========================================================================
43
//#####DESCRIPTIONBEGIN####
44
//
45
// Author(s):    gthomas, hmt
46
// Contributors: gthomas
47
// Date:         2001-02-14
48
// Purpose:      
49
// Description:  
50
//              
51
//####DESCRIPTIONEND####
52
//
53
//==========================================================================
54
 
55
#include <pkgconf/system.h>
56
#include <pkgconf/devs_flash_strata.h>
57
#include CYGDAT_DEVS_FLASH_STRATA_INL
58
 
59
// ------------------------------------------------------------------------
60
// 
61
// It is expected that the above include defined all the properties of the
62
// device we want to drive: the choices this module supports include:
63
//
64
//                                    Buffered  Read     Block
65
//                                     write    query    locking
66
// 28FxxxB3 - Bootblock               - no      no       no
67
// 28FxxxC3 - StrataFlash             - no      yes      yes
68
// 28FxxxJ3 - Advanced StrataFlash    - yes     yes      yes
69
// 28FxxxK3 - Synchronous StrataFlash - yes     yes      yes
70
// 
71
// These options are controlled by defining or not, in that include file,
72
// these symbols (not CDL options, just symbols - though they could be CDL
73
// in future)
74
//         CYGOPT_FLASH_IS_BOOTBLOCK     - for xxxB3 devices.
75
//         CYGOPT_FLASH_IS_NOT_ADVANCED  - for xxxC3 devices.
76
//         CYGOPT_FLASH_IS_SYNCHRONOUS   - for xxxK3 devices.
77
//         none of the above             - for xxxJ3 devices.  
78
// (Advanced seems to be usual these days hence the sense of that opt)
79
//
80
// Other properties are controlled by these symbols:
81
//         CYGNUM_FLASH_DEVICES         number of devices across the databus
82
//         CYGNUM_FLASH_WIDTH           number of bits in each device
83
//         CYGNUM_FLASH_BLANK           1 if blank is allones, 0 if 0
84
//         CYGNUM_FLASH_BASE            base address
85
//         CYGNUM_FLASH_BASE_MASK       a mask to get base address from any
86
// 
87
// for example, a 32-bit memory could be made from 1x32bit, 2x16bit or
88
// 4x8bit devices; usually 16bit ones are chosen in practice, so we would
89
// have CYGNUM_FLASH_DEVICES = 2, and CYGNUM_FLASH_WIDTH = 16.  Both
90
// devices would be handled simulataneously, via 32bit bus operations.
91
// Some CPUs can handle a single 16bit device as 32bit memory "by magic".
92
// In that case, CYGNUM_FLASH_DEVICES = 1 and CYGNUM_FLASH_WIDTH = 16, and
93
// the device is managed using only 16bit bus operations.
94
 
95
 
96
// ------------------------------------------------------------------------
97
//
98
// No mapping on this target - but these casts would be needed if some
99
// manipulation did occur.  An example of this might be:
100
// // First 4K page of flash at physical address zero is
101
// // virtually mapped at address 0xa0000000.
102
// #define FLASH_P2V(x) ((volatile flash_t *)(((unsigned)(x) < 0x1000) ?
103
//                            ((unsigned)(x) | 0xa0000000) :
104
//                            (unsigned)(x)))
105
 
106
#ifndef FLASH_P2V
107
#define FLASH_P2V( _a_ ) ((volatile flash_t *)((unsigned int)(_a_)))
108
#endif
109
 
110
// ------------------------------------------------------------------------
111
//
112
// This generic code is intended to deal with all shapes and orientations
113
// of Intel StrataFlash.  Trademarks &c belong to their respective owners.
114
//
115
// It therefore needs some trickery to define the constants and accessor
116
// types that we use to interact with the device or devices.
117
//
118
// The assumptions are that
119
//  o Parallel devices, we write to, with the "opcode" replicated per
120
//    device
121
//  o The "opcode" and status returns exist only in the low byte of the
122
//    device's interface regardless of its width.
123
//  o Hence opcodes and status are only one byte.
124
// An exception is the test for succesfully erased data.
125
//
126
// ------------------------------------------------------------------------
127
 
128
#if 8 == CYGNUM_FLASH_WIDTH
129
 
130
# if 1 == CYGNUM_FLASH_DEVICES
131
#  define FLASHWORD( k ) ((flash_t)(k)) // To narrow a 16-bit constant
132
typedef unsigned char flash_t;
133
# elif 2 == CYGNUM_FLASH_DEVICES
134
// 2 devices to make 16-bit
135
#  define FLASHWORD( k ) ((k)+((k)<<8))
136
typedef unsigned short flash_t;
137
# elif 4 == CYGNUM_FLASH_DEVICES
138
// 4 devices to make 32-bit
139
#  define FLASHWORD( k ) ((k)+((k)<<8)+((k)<<16)+((k)<<24))
140
typedef unsigned long flash_t;
141
# elif 8 == CYGNUM_FLASH_DEVICES
142
// 8 devices to make 64-bit - intermediate requires explicit widening
143
#  define FLASHWORD32( k ) ((flash_t)((k)+((k)<<8)+((k)<<16)+((k)<<24)))
144
#  define FLASHWORD( k ) (FLASHWORD32( k ) + (FLASHWORD32( k ) << 32));
145
typedef unsigned long long flash_t;
146
# else
147
#  error How many 8-bit flash devices?
148
# endif
149
 
150
#elif 16 == CYGNUM_FLASH_WIDTH
151
 
152
# if 1 == CYGNUM_FLASH_DEVICES
153
#  define FLASHWORD( k ) (k)
154
typedef unsigned short flash_t;
155
# elif 2 == CYGNUM_FLASH_DEVICES
156
// 2 devices to make 32-bit
157
#  define FLASHWORD( k ) ((k)+((k)<<16))
158
typedef unsigned long flash_t;
159
# elif 2 == CYGNUM_FLASH_DEVICES
160
// 4 devices to make 64-bit - intermediate requires explicit widening
161
#  define FLASHWORD32( k ) ((flash_t)((k)+((k)<<16)))
162
#  define FLASHWORD( k ) (FLASHWORD32( k ) + (FLASHWORD32( k ) << 32));
163
typedef unsigned long long flash_t;
164
# else
165
#  error How many 16-bit flash devices?
166
# endif
167
 
168
#elif 32 == CYGNUM_FLASH_WIDTH
169
 
170
# if 1 == CYGNUM_FLASH_DEVICES
171
#  define FLASHWORD( k ) (k)
172
typedef unsigned long flash_t;
173
# elif 2 == CYGNUM_FLASH_DEVICES
174
// 2 devices to make 64-bit - intermediate requires explicit widening
175
#  define FLASHWORD32( k ) ((flash_t)(k))
176
#  define FLASHWORD( k ) (FLASHWORD32( k ) + (FLASHWORD32( k ) << 32));
177
typedef unsigned long long flash_t;
178
# else
179
#  error How many 32-bit flash devices?
180
# endif
181
 
182
#else
183
# error What flash width?
184
#endif
185
 
186
// Data (not) that we read back:
187
#if 0 == CYGNUM_FLASH_BLANK
188
# define FLASH_BlankValue ((flash_t)0)
189
#elif 1 == CYGNUM_FLASH_BLANK
190
# define FLASH_BlankValue ((flash_t)(-1ll))
191
#else
192
# error What blank value?
193
#endif
194
 
195
// ------------------------------------------------------------------------
196
 
197
#define FLASH_Read_ID                   FLASHWORD( 0x90 )
198
#ifndef CYGOPT_FLASH_IS_BOOTBLOCK
199
#define FLASH_Read_Query                FLASHWORD( 0x98 ) // Strata only
200
#endif
201
#define FLASH_Read_Status               FLASHWORD( 0x70 )
202
#define FLASH_Clear_Status              FLASHWORD( 0x50 )
203
#define FLASH_Status_Ready              FLASHWORD( 0x80 )
204
#ifdef CYGOPT_FLASH_IS_BOOTBLOCK
205
#define FLASH_Program                   FLASHWORD( 0x40 ) // BootBlock only
206
#else
207
#define FLASH_Program                   FLASHWORD( 0x10 )
208
#endif
209
#define FLASH_Block_Erase               FLASHWORD( 0x20 )
210
#ifndef CYGOPT_FLASH_IS_BOOTBLOCK
211
#ifndef CYGOPT_FLASH_IS_NOT_ADVANCED
212
#define FLASH_Write_Buffer              FLASHWORD( 0xE8 ) // *Advanced* Strata only
213
#endif // flash is advanced ie. has Write Buffer command
214
#define FLASH_Set_Lock                  FLASHWORD( 0x60 ) // Strata only
215
#define FLASH_Set_Lock_Confirm          FLASHWORD( 0x01 ) // Strata only
216
#define FLASH_Clear_Locks               FLASHWORD( 0x60 ) // Strata only
217
#define FLASH_Clear_Locks_Confirm       FLASHWORD( 0xD0 ) // Strata only
218
#endif
219
#define FLASH_Confirm                   FLASHWORD( 0xD0 )
220
//#define FLASH_Configure                       FLASHWORD( 0xB8 )
221
//#define FLASH_Configure_ReadyWait             FLASHWORD( 0x00 )
222
//#define FLASH_Configure_PulseOnErase          FLASHWORD( 0x01 )
223
//#define FLASH_Configure_PulseOnProgram        FLASHWORD( 0x02 )
224
//#define FLASH_Configure_PulseOnBoth           FLASHWORD( 0x03 )
225
#define FLASH_Reset                     FLASHWORD( 0xFF )
226
 
227
// Status that we read back:                         
228
#define FLASH_ErrorMask                 FLASHWORD( 0x7E )
229
#define FLASH_ErrorProgram              FLASHWORD( 0x10 )
230
#define FLASH_ErrorErase                FLASHWORD( 0x20 )
231
 
232
#define FLASH_ErrorNotVerified          FLASHWORD( 0x9910 ) // made-up number
233
 
234
// ------------------------------------------------------------------------
235
 
236
#define FLASH_Intel_code   0x89 // NOT mapped to 16+16
237
 
238
// Extended query information
239
struct FLASH_query {
240
    unsigned char manuf_code;    // FLASH_Intel_code
241
    unsigned char device_code;
242
    unsigned char _unused0[14];
243
    unsigned char id[3];  // Q R Y
244
    unsigned char _unused1[20];
245
    unsigned char device_size;
246
    unsigned char device_interface[2];
247
    unsigned char buffer_size[2];
248
    unsigned char is_block_oriented;
249
    unsigned char num_regions[2];
250
    unsigned char region_size[2];
251
};
252
 
253
#endif  // CYGONCE_DEVS_FLASH_INTEL_STRATA_FLASH_H
254
// ------------------------------------------------------------------------
255
// EOF strata.h

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.