Index: devs/flash/intel/strata/current/src/strata.h =================================================================== RCS file: /cvs/ecos/ecos/packages/devs/flash/intel/strata/current/src/strata.h,v retrieving revision 1.5 diff -u -5 -p -r1.5 strata.h --- devs/flash/intel/strata/current/src/strata.h 12 Apr 2003 02:47:46 -0000 1.5 +++ devs/flash/intel/strata/current/src/strata.h 7 Oct 2003 14:24:25 -0000 @@ -41,11 +41,11 @@ //####ECOSGPLCOPYRIGHTEND#### //========================================================================== //#####DESCRIPTIONBEGIN#### // // Author(s): gthomas, hmt -// Contributors: gthomas +// Contributors: gthomas, wpd, jani // Date: 2001-02-14 // Purpose: // Description: // //####DESCRIPTIONEND#### @@ -59,42 +59,120 @@ // ------------------------------------------------------------------------ // // It is expected that the above include defined all the properties of the // device we want to drive: the choices this module supports include: // +// The following table may be of historical value. The current incarnation +// of the driver is not limited to these specific devices. +// // Buffered Read Block // write query locking -// 28FxxxB3 - Bootblock - no no no -// 28FxxxC3 - StrataFlash - no yes yes -// 28FxxxJ3 - Advanced StrataFlash - yes yes yes +// 28FxxxB3 - Advanced Bootblock - no no no +// 28FxxxC3 - Advanced+ Bootblock - no yes yes +// 28FxxxJ3 - StrataFlash - yes yes yes // 28FxxxK3 - Synchronous StrataFlash - yes yes yes +// 28FxxxW3 - Wireless Flash - no yes yes +// 28FxxxL3 - Wireless StrataFlash - no yes yes // -// These options are controlled by defining or not, in that include file, -// these symbols (not CDL options, just symbols - though they could be CDL -// in future) -// CYGOPT_FLASH_IS_BOOTBLOCK - for xxxB3 devices. -// CYGOPT_FLASH_IS_NOT_ADVANCED - for xxxC3 devices. -// CYGOPT_FLASH_IS_SYNCHRONOUS - for xxxK3 devices. -// none of the above - for xxxJ3 devices. -// (Advanced seems to be usual these days hence the sense of that opt) +// Various options in this driver are controlled by defining or not, +// in that include file, these symbols (not CDL options, just symbols +// - though they could be CDL in future) +// +// CYGOPT_FLASH_NO_CFI +// - define this if the device does not support the +// "Common Flash Interface". If this is defined, you +// must define CYGOPT_FLASH_SYNTHETIC_CFI to contain the +// information that is parsed from the CFI. See the +// definition of 'struct FLASH_parsed_CFI' at the end of +// this file. Alternatively, you may define the +// CYGOPT_FLASH_IS_BOOTBLOCK symbol if your device matches +// the narrow set of parameters encompassed by the xxxB3 +// devices. +// +// CYGOPT_FLASH_SYNTHETIC_CFI +// - This should contain the static CFI information for a +// device that does not support the CFI. (Are there any +// such devices? -- perhaps). +// +// CYGOPT_FLASH_IS_BOOTBLOCK +// - Define this symbol for xxxB3 devices, which this driver +// continues to support. +// +// CYGOPT_FLASH_UNLOCKS_SINGLE_BLOCKS +// - Define this symbol if the device unlocks individual +// blocks in response to the 'FLASH_Clear_Locks' (0x60) +// Most modern devices should will probably require this. +// The xxxJ3 and xxxB3 devices do not require this. // // Other properties are controlled by these symbols: -// CYGNUM_FLASH_DEVICES number of devices across the databus +// CYGNUM_FLASH_INTERLEAVE number of devices across the databus +// CYGNUM_FLASH_SERIES number of devices that occupy +// consecutive (virtual) addresses +// CYGNUM_FLASH_SIZE When 'CYGNUM_FLASH_SERIES' is > 1, +// this specifies the size (in +// bytes) of each device in +// series. (This should be fixed +// someday so that +// 'flash_query()' determines the +// size automatically based on +// the CFI read from the device.) // CYGNUM_FLASH_WIDTH number of bits in each device // CYGNUM_FLASH_BLANK 1 if blank is allones, 0 if 0 // CYGNUM_FLASH_BASE base address // CYGNUM_FLASH_BASE_MASK a mask to get base address from any // // for example, a 32-bit memory could be made from 1x32bit, 2x16bit or // 4x8bit devices; usually 16bit ones are chosen in practice, so we would -// have CYGNUM_FLASH_DEVICES = 2, and CYGNUM_FLASH_WIDTH = 16. Both +// have CYGNUM_FLASH_INTERLEAVE = 2, and CYGNUM_FLASH_WIDTH = 16. Both // devices would be handled simulataneously, via 32bit bus operations. // Some CPUs can handle a single 16bit device as 32bit memory "by magic". -// In that case, CYGNUM_FLASH_DEVICES = 1 and CYGNUM_FLASH_WIDTH = 16, and +// In that case, CYGNUM_FLASH_INTERLEAVE = 1 and CYGNUM_FLASH_WIDTH = 16, and // the device is managed using only 16bit bus operations. +// +// +// Obsolete Properties: +// CYGOPT_FLASH_IS_NOT_ADVANCED +// - This used to control whether the 'FLASH_Write_Buffer' +// command was defined (and, hence, used). Now, write +// buffering is used only if the device indicates that it +// supports write buffering via the CFI. +// +// CYGOPT_FLASH_IS_SYNCHRONOUS +// - This used to force 'flash_unlock_block()' to assume that +// the 'FLASH_Clear_Locks' command cleared all of the locks. +// This has been renamed to be 'CYGOPT_FLASH_UNLOCKS_ALL_BLOCKS'. +// + +#ifdef CYGNUM_FLASH_DEVICES +# warning "Definition of CYGNUM_FLASH_DEVICES in strata driver is deprecated" +# define CYGNUM_FLASH_INTERLEAVE CYGNUM_FLASH_DEVICES +#endif + +#ifndef CYGNUM_FLASH_INTERLEAVE +# define CYGNUM_FLASH_INTERLEAVE 1 +#endif + +#ifndef CYGNUM_FLASH_SERIES +# define CYGNUM_FLASH_SERIES 1 +#endif + +#ifndef CYGNUM_FLASH_SIZE +# if CYGNUM_FLASH_SERIES > 1 +# error "Must define CYGNUM_FLASH_SIZE as well as CYGNUM_FLASH_SERIES" +# else +# define CYGNUM_FLASH_SIZE 0 +# endif +#endif + +#ifdef CYGOPT_FLASH_IS_BOOTBLOCK +// The only time this should be defined is on platforms that use the +// xxxB3 part, which does not support CFI +# ifndef CYGOPT_FLASH_NO_CFI +# define CYGOPT_FLASH_NO_CFI +# endif +#endif -#define CYGNUM_FLASH_INTERLEAVE CYGNUM_FLASH_DEVICES #define _FLASH_PRIVATE_ #include #define flash_t flash_data_t // ------------------------------------------------------------------------ @@ -115,31 +193,21 @@ // // ------------------------------------------------------------------------ // ------------------------------------------------------------------------ #define FLASH_Read_ID FLASHWORD( 0x90 ) -#ifndef CYGOPT_FLASH_IS_BOOTBLOCK -#define FLASH_Read_Query FLASHWORD( 0x98 ) // Strata only -#endif +#define FLASH_Read_Query FLASHWORD( 0x98 ) #define FLASH_Read_Status FLASHWORD( 0x70 ) #define FLASH_Clear_Status FLASHWORD( 0x50 ) #define FLASH_Status_Ready FLASHWORD( 0x80 ) -#ifdef CYGOPT_FLASH_IS_BOOTBLOCK -#define FLASH_Program FLASHWORD( 0x40 ) // BootBlock only -#else -#define FLASH_Program FLASHWORD( 0x10 ) -#endif +#define FLASH_Program FLASHWORD( 0x40 ) #define FLASH_Block_Erase FLASHWORD( 0x20 ) -#ifndef CYGOPT_FLASH_IS_BOOTBLOCK -#ifndef CYGOPT_FLASH_IS_NOT_ADVANCED -#define FLASH_Write_Buffer FLASHWORD( 0xE8 ) // *Advanced* Strata only -#endif // flash is advanced ie. has Write Buffer command -#define FLASH_Set_Lock FLASHWORD( 0x60 ) // Strata only -#define FLASH_Set_Lock_Confirm FLASHWORD( 0x01 ) // Strata only -#define FLASH_Clear_Locks FLASHWORD( 0x60 ) // Strata only -#define FLASH_Clear_Locks_Confirm FLASHWORD( 0xD0 ) // Strata only -#endif +#define FLASH_Write_Buffer FLASHWORD( 0xE8 ) +#define FLASH_Set_Lock FLASHWORD( 0x60 ) +#define FLASH_Set_Lock_Confirm FLASHWORD( 0x01 ) +#define FLASH_Clear_Locks FLASHWORD( 0x60 ) +#define FLASH_Clear_Locks_Confirm FLASHWORD( 0xD0 ) #define FLASH_Confirm FLASHWORD( 0xD0 ) //#define FLASH_Configure FLASHWORD( 0xB8 ) //#define FLASH_Configure_ReadyWait FLASHWORD( 0x00 ) //#define FLASH_Configure_PulseOnErase FLASHWORD( 0x01 ) //#define FLASH_Configure_PulseOnProgram FLASHWORD( 0x02 ) @@ -156,22 +224,46 @@ // ------------------------------------------------------------------------ #define FLASH_Intel_code 0x89 // NOT mapped to 16+16 // Extended query information +#define MAX_NUM_ERASE_BLOCK_REGIONS 3 struct FLASH_query { unsigned char manuf_code; // FLASH_Intel_code unsigned char device_code; unsigned char _unused0[14]; unsigned char id[3]; // Q R Y unsigned char _unused1[20]; unsigned char device_size; unsigned char device_interface[2]; unsigned char buffer_size[2]; - unsigned char is_block_oriented; - unsigned char num_regions[2]; - unsigned char region_size[2]; + unsigned char num_erase_block_regions; + struct { + unsigned char num[2]; + unsigned char size[2]; + } __attribute__((packed)) regions[MAX_NUM_ERASE_BLOCK_REGIONS]; }; +#define FLASH_MAX_REGIONS (MAX_NUM_ERASE_BLOCK_REGIONS * CYGNUM_FLASH_SERIES) + +struct FLASH_parsed_CFI { + int manuf_code; + int device_code; + unsigned write_buffer_size; // 0 => no write buffer + unsigned num_regions; + struct region { + unsigned num_blocks; + unsigned total_size; + unsigned block_size; + } region[FLASH_MAX_REGIONS]; + unsigned max_block_size; +}; + +extern struct FLASH_parsed_CFI flash_cfi; + +extern int flash_block_op(volatile flash_t *block, + unsigned int block_size, + flash_t opcode, + flash_t confirm); #endif // CYGONCE_DEVS_FLASH_INTEL_STRATA_FLASH_H // ------------------------------------------------------------------------ // EOF strata.h