]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - packages/devs/flash/intel/strata/v2_0/src/strata.h
Initial revision
[karo-tx-redboot.git] / packages / devs / flash / intel / strata / v2_0 / src / strata.h
1 #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 #define CYGNUM_FLASH_INTERLEAVE CYGNUM_FLASH_DEVICES
96 #define _FLASH_PRIVATE_
97 #include <cyg/io/flash_dev.h>
98
99 #define flash_t flash_data_t
100 // ------------------------------------------------------------------------
101 //
102 // This generic code is intended to deal with all shapes and orientations
103 // of Intel StrataFlash.  Trademarks &c belong to their respective owners.
104 //
105 // It therefore needs some trickery to define the constants and accessor
106 // types that we use to interact with the device or devices.
107 //
108 // The assumptions are that
109 //  o Parallel devices, we write to, with the "opcode" replicated per
110 //    device
111 //  o The "opcode" and status returns exist only in the low byte of the
112 //    device's interface regardless of its width.
113 //  o Hence opcodes and status are only one byte.
114 // An exception is the test for succesfully erased data.
115 //
116 // ------------------------------------------------------------------------
117 // ------------------------------------------------------------------------
118
119 #define FLASH_Read_ID                   FLASHWORD( 0x90 )
120 #ifndef CYGOPT_FLASH_IS_BOOTBLOCK
121 #define FLASH_Read_Query                FLASHWORD( 0x98 ) // Strata only
122 #endif
123 #define FLASH_Read_Status               FLASHWORD( 0x70 )
124 #define FLASH_Clear_Status              FLASHWORD( 0x50 )
125 #define FLASH_Status_Ready              FLASHWORD( 0x80 )
126 #ifdef CYGOPT_FLASH_IS_BOOTBLOCK
127 #define FLASH_Program                   FLASHWORD( 0x40 ) // BootBlock only
128 #else
129 #define FLASH_Program                   FLASHWORD( 0x10 )
130 #endif
131 #define FLASH_Block_Erase               FLASHWORD( 0x20 )
132 #ifndef CYGOPT_FLASH_IS_BOOTBLOCK
133 #ifndef CYGOPT_FLASH_IS_NOT_ADVANCED
134 #define FLASH_Write_Buffer              FLASHWORD( 0xE8 ) // *Advanced* Strata only
135 #endif // flash is advanced ie. has Write Buffer command
136 #define FLASH_Set_Lock                  FLASHWORD( 0x60 ) // Strata only
137 #define FLASH_Set_Lock_Confirm          FLASHWORD( 0x01 ) // Strata only
138 #define FLASH_Clear_Locks               FLASHWORD( 0x60 ) // Strata only
139 #define FLASH_Clear_Locks_Confirm       FLASHWORD( 0xD0 ) // Strata only
140 #endif
141 #define FLASH_Confirm                   FLASHWORD( 0xD0 )
142 //#define FLASH_Configure                       FLASHWORD( 0xB8 )
143 //#define FLASH_Configure_ReadyWait             FLASHWORD( 0x00 )
144 //#define FLASH_Configure_PulseOnErase          FLASHWORD( 0x01 )
145 //#define FLASH_Configure_PulseOnProgram        FLASHWORD( 0x02 )
146 //#define FLASH_Configure_PulseOnBoth           FLASHWORD( 0x03 )
147 #define FLASH_Reset                     FLASHWORD( 0xFF )
148                                                      
149 // Status that we read back:                         
150 #define FLASH_ErrorMask                 FLASHWORD( 0x7E )
151 #define FLASH_ErrorProgram              FLASHWORD( 0x10 )
152 #define FLASH_ErrorErase                FLASHWORD( 0x20 )
153
154 #define FLASH_ErrorNotVerified          FLASHWORD( 0x9910 ) // made-up number
155
156 // ------------------------------------------------------------------------
157
158 #define FLASH_Intel_code   0x89 // NOT mapped to 16+16
159 #define FLASH_STMicro_code 0x20 // NOT mapped to 16+16
160
161 // Extended query information
162 struct FLASH_query {
163     unsigned char manuf_code;    // FLASH_Intel_code
164     unsigned char device_code;
165     unsigned char _unused0[14];
166     unsigned char id[3];  // Q R Y
167     unsigned char _unused1[20];
168     unsigned char device_size;
169     unsigned char device_interface[2];
170     unsigned char buffer_size[2];
171     unsigned char is_block_oriented;
172     unsigned char num_regions[2];
173     unsigned char region_size[2];
174 };
175
176 #endif  // CYGONCE_DEVS_FLASH_INTEL_STRATA_FLASH_H
177 // ------------------------------------------------------------------------
178 // EOF strata.h