1 |
786 |
skrzyp |
#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 Free Software Foundation, 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
|
18 |
|
|
// version.
|
19 |
|
|
//
|
20 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
21 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
22 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
23 |
|
|
// for more details.
|
24 |
|
|
//
|
25 |
|
|
// You should have received a copy of the GNU General Public License
|
26 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
27 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
28 |
|
|
//
|
29 |
|
|
// As a special exception, if other files instantiate templates or use
|
30 |
|
|
// macros or inline functions from this file, or you compile this file
|
31 |
|
|
// and link it with other works to produce a work based on this file,
|
32 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
33 |
|
|
// the GNU General Public License. However the source code for this file
|
34 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
35 |
|
|
// General Public License v2.
|
36 |
|
|
//
|
37 |
|
|
// This exception does not invalidate any other reasons why a work based
|
38 |
|
|
// on this file might be covered by the GNU General Public License.
|
39 |
|
|
// -------------------------------------------
|
40 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
41 |
|
|
//==========================================================================
|
42 |
|
|
//#####DESCRIPTIONBEGIN####
|
43 |
|
|
//
|
44 |
|
|
// Author(s): gthomas, hmt
|
45 |
|
|
// Contributors: gthomas
|
46 |
|
|
// Date: 2001-02-14
|
47 |
|
|
// Purpose:
|
48 |
|
|
// Description:
|
49 |
|
|
//
|
50 |
|
|
//####DESCRIPTIONEND####
|
51 |
|
|
//
|
52 |
|
|
//==========================================================================
|
53 |
|
|
|
54 |
|
|
#include <pkgconf/system.h>
|
55 |
|
|
#include <pkgconf/devs_flash_strata.h>
|
56 |
|
|
#include CYGDAT_DEVS_FLASH_STRATA_INL
|
57 |
|
|
|
58 |
|
|
// ------------------------------------------------------------------------
|
59 |
|
|
//
|
60 |
|
|
// It is expected that the above include defined all the properties of the
|
61 |
|
|
// device we want to drive: the choices this module supports include:
|
62 |
|
|
//
|
63 |
|
|
// Buffered Read Block
|
64 |
|
|
// write query locking
|
65 |
|
|
// 28FxxxB3 - Bootblock - no no no
|
66 |
|
|
// 28FxxxC3 - StrataFlash - no yes yes
|
67 |
|
|
// 28FxxxJ3 - Advanced StrataFlash - yes yes yes
|
68 |
|
|
// 28FxxxK3 - Synchronous StrataFlash - yes yes yes
|
69 |
|
|
//
|
70 |
|
|
// These options are controlled by defining or not, in that include file,
|
71 |
|
|
// these symbols (not CDL options, just symbols - though they could be CDL
|
72 |
|
|
// in future)
|
73 |
|
|
// CYGOPT_FLASH_IS_BOOTBLOCK - for xxxB3 devices.
|
74 |
|
|
// CYGOPT_FLASH_IS_NOT_ADVANCED - for xxxC3 devices.
|
75 |
|
|
// CYGOPT_FLASH_IS_SYNCHRONOUS - for xxxK3 devices.
|
76 |
|
|
// none of the above - for xxxJ3 devices.
|
77 |
|
|
// (Advanced seems to be usual these days hence the sense of that opt)
|
78 |
|
|
//
|
79 |
|
|
// Other properties are controlled by these symbols:
|
80 |
|
|
// CYGNUM_FLASH_DEVICES number of devices across the databus
|
81 |
|
|
// CYGNUM_FLASH_WIDTH number of bits in each device
|
82 |
|
|
// CYGNUM_FLASH_BLANK 1 if blank is allones, 0 if 0
|
83 |
|
|
// CYGNUM_FLASH_BASE base address
|
84 |
|
|
// CYGNUM_FLASH_BASE_MASK a mask to get base address from any
|
85 |
|
|
//
|
86 |
|
|
// for example, a 32-bit memory could be made from 1x32bit, 2x16bit or
|
87 |
|
|
// 4x8bit devices; usually 16bit ones are chosen in practice, so we would
|
88 |
|
|
// have CYGNUM_FLASH_DEVICES = 2, and CYGNUM_FLASH_WIDTH = 16. Both
|
89 |
|
|
// devices would be handled simulataneously, via 32bit bus operations.
|
90 |
|
|
// Some CPUs can handle a single 16bit device as 32bit memory "by magic".
|
91 |
|
|
// In that case, CYGNUM_FLASH_DEVICES = 1 and CYGNUM_FLASH_WIDTH = 16, and
|
92 |
|
|
// the device is managed using only 16bit bus operations.
|
93 |
|
|
|
94 |
|
|
#define CYGNUM_FLASH_INTERLEAVE CYGNUM_FLASH_DEVICES
|
95 |
|
|
#define _FLASH_PRIVATE_
|
96 |
|
|
#include <cyg/io/flash_dev.h>
|
97 |
|
|
|
98 |
|
|
#define flash_t flash_data_t
|
99 |
|
|
// ------------------------------------------------------------------------
|
100 |
|
|
//
|
101 |
|
|
// This generic code is intended to deal with all shapes and orientations
|
102 |
|
|
// of Intel StrataFlash. Trademarks &c belong to their respective owners.
|
103 |
|
|
//
|
104 |
|
|
// It therefore needs some trickery to define the constants and accessor
|
105 |
|
|
// types that we use to interact with the device or devices.
|
106 |
|
|
//
|
107 |
|
|
// The assumptions are that
|
108 |
|
|
// o Parallel devices, we write to, with the "opcode" replicated per
|
109 |
|
|
// device
|
110 |
|
|
// o The "opcode" and status returns exist only in the low byte of the
|
111 |
|
|
// device's interface regardless of its width.
|
112 |
|
|
// o Hence opcodes and status are only one byte.
|
113 |
|
|
// An exception is the test for succesfully erased data.
|
114 |
|
|
//
|
115 |
|
|
// ------------------------------------------------------------------------
|
116 |
|
|
// ------------------------------------------------------------------------
|
117 |
|
|
|
118 |
|
|
#define FLASH_Read_ID FLASHWORD( 0x90 )
|
119 |
|
|
#ifndef CYGOPT_FLASH_IS_BOOTBLOCK
|
120 |
|
|
#define FLASH_Read_Query FLASHWORD( 0x98 ) // Strata only
|
121 |
|
|
#endif
|
122 |
|
|
#define FLASH_Read_Status FLASHWORD( 0x70 )
|
123 |
|
|
#define FLASH_Clear_Status FLASHWORD( 0x50 )
|
124 |
|
|
#define FLASH_Status_Ready FLASHWORD( 0x80 )
|
125 |
|
|
#ifdef CYGOPT_FLASH_IS_BOOTBLOCK
|
126 |
|
|
#define FLASH_Program FLASHWORD( 0x40 ) // BootBlock only
|
127 |
|
|
#else
|
128 |
|
|
#define FLASH_Program FLASHWORD( 0x10 )
|
129 |
|
|
#endif
|
130 |
|
|
#define FLASH_Block_Erase FLASHWORD( 0x20 )
|
131 |
|
|
#ifndef CYGOPT_FLASH_IS_BOOTBLOCK
|
132 |
|
|
#ifndef CYGOPT_FLASH_IS_NOT_ADVANCED
|
133 |
|
|
#define FLASH_Write_Buffer FLASHWORD( 0xE8 ) // *Advanced* Strata only
|
134 |
|
|
#endif // flash is advanced ie. has Write Buffer command
|
135 |
|
|
#define FLASH_Set_Lock FLASHWORD( 0x60 ) // Strata only
|
136 |
|
|
#define FLASH_Set_Lock_Confirm FLASHWORD( 0x01 ) // Strata only
|
137 |
|
|
#define FLASH_Clear_Locks FLASHWORD( 0x60 ) // Strata only
|
138 |
|
|
#define FLASH_Clear_Locks_Confirm FLASHWORD( 0xD0 ) // Strata only
|
139 |
|
|
#endif
|
140 |
|
|
#define FLASH_Confirm FLASHWORD( 0xD0 )
|
141 |
|
|
//#define FLASH_Configure FLASHWORD( 0xB8 )
|
142 |
|
|
//#define FLASH_Configure_ReadyWait FLASHWORD( 0x00 )
|
143 |
|
|
//#define FLASH_Configure_PulseOnErase FLASHWORD( 0x01 )
|
144 |
|
|
//#define FLASH_Configure_PulseOnProgram FLASHWORD( 0x02 )
|
145 |
|
|
//#define FLASH_Configure_PulseOnBoth FLASHWORD( 0x03 )
|
146 |
|
|
#define FLASH_Reset FLASHWORD( 0xFF )
|
147 |
|
|
|
148 |
|
|
// Status that we read back:
|
149 |
|
|
#define FLASH_ErrorMask FLASHWORD( 0x7E )
|
150 |
|
|
#define FLASH_ErrorProgram FLASHWORD( 0x10 )
|
151 |
|
|
#define FLASH_ErrorErase FLASHWORD( 0x20 )
|
152 |
|
|
|
153 |
|
|
#define FLASH_ErrorNotVerified FLASHWORD( 0x9910 ) // made-up number
|
154 |
|
|
|
155 |
|
|
// ------------------------------------------------------------------------
|
156 |
|
|
|
157 |
|
|
#define FLASH_Intel_code 0x89 // NOT mapped to 16+16
|
158 |
|
|
#define FLASH_STMicro_code 0x20 // NOT mapped to 16+16
|
159 |
|
|
|
160 |
|
|
// Extended query information
|
161 |
|
|
struct FLASH_query {
|
162 |
|
|
unsigned char manuf_code; // FLASH_Intel_code
|
163 |
|
|
unsigned char device_code;
|
164 |
|
|
unsigned char _unused0[14];
|
165 |
|
|
unsigned char id[3]; // Q R Y
|
166 |
|
|
unsigned char _unused1[20];
|
167 |
|
|
unsigned char device_size;
|
168 |
|
|
unsigned char device_interface[2];
|
169 |
|
|
unsigned char buffer_size[2];
|
170 |
|
|
unsigned char is_block_oriented;
|
171 |
|
|
unsigned char num_regions[2];
|
172 |
|
|
unsigned char region_size[2];
|
173 |
|
|
};
|
174 |
|
|
|
175 |
|
|
#endif // CYGONCE_DEVS_FLASH_INTEL_STRATA_FLASH_H
|
176 |
|
|
// ------------------------------------------------------------------------
|
177 |
|
|
// EOF strata.h
|