diff -urN linux-2.4.0-test8-rmk2-np1-org/drivers/block/flash_mem.c linux-2.4.0-test8-rmk2-np1-flash/drivers/block/flash_mem.c --- linux-2.4.0-test8-rmk2-np1-org/drivers/block/flash_mem.c Thu Sep 21 17:58:44 2000 +++ linux-2.4.0-test8-rmk2-np1-flash/drivers/block/flash_mem.c Thu Sep 21 17:51:10 2000 @@ -2,12 +2,10 @@ * Flash block driver * Copyright (C) 1999 Nicolas Pitre * - * Portions are Copyright (C) 2000 Lernout & Hauspie Speech Products, N.V. + * Portions are: + * Copyright (C) 2000 Lernout & Hauspie Speech Products, N.V. * released under GNU Public Licence (GPL) version 2. * - * Portions are (C) 2000 The Delft University of Technology - * released under GNU GPL version 2 or higher. - * * This is a block device driver for Intel Flash memory. * * 1999-02-21 Stephane Dalton Added write functions @@ -22,11 +20,8 @@ * retrieve chip type and verify * flash sector size. * - * 30-jul-2000 Erik Mouw Added LART Flash support - * Minor module cleanup - * (yes, I like unambiguous date entries) - * 2000-08-21 Erik Bunce Slightly more flexible flash handling - * + * 2000-7-25 Chester Kuo Modify timeout value for 28F128J3A flash + * for write_sector */ @@ -61,7 +56,7 @@ /* Flash mapping start */ -#define FLASH_START 0xe8000000 +#define FLASH_START 0xd0000000 static unsigned char *flash_start[FLASH_PARTITIONS]; @@ -73,12 +68,10 @@ /* features*/ #define USE_WRITE_BUFFER #define WRITE_VERIFY -#if 0 -#define FLASH_DEBUG_CFI -#if 0 +#if 1 #define FLASH_VERBOSE -#define FLASH_DEBUG -#endif +#undef FLASH_DEBUG +//#define FLASH_DEBUG #endif /* cache structure */ @@ -160,8 +153,11 @@ static int flash_status_check( volatile FLASH_t *flash_ptr ) { FLASH_t status; +#if 0 int timeout = POLL_LOOP_LIMIT; - +#else + int timeout = POLL_LOOP_LIMIT*16; +#endif /* just to be sure status is actually updated */ { FLASH_t x; @@ -272,7 +268,11 @@ i = 0; while( i < flash_sectsize ) { #ifdef USE_WRITE_BUFFER +#if 0 int pollmax = 1<<20; +#else + int pollmax = (1<<20)*2; +#endif int cnt = FLASH_WR_BUFF_SIZE; flash_ptr = FLASH_PTR(flash_addr, i); @@ -301,7 +301,7 @@ if( error ) break; #endif } - + printk("end of while loop on write sector\n"); flash_ptr = FLASH_PTR(flash_addr, 0); *flash_ptr = FLASH_CMD_READ; WP_VPP_OFF(); @@ -616,7 +616,7 @@ FLASH_t* flash_ptr = FLASH_PTR((char*)FLASH_START, 0 * sizeof(FLASH_t)); #define FLASH_LOBYTE(x) (flash_ptr[(x)] & 0x000000FFL) -#ifdef FLASH_DEBUG_CFI +#ifdef FLASH_DEBUG u8 testmanid; u8 testdevid; #endif @@ -644,7 +644,7 @@ flash_ptr = FLASH_PTR((char*)FLASH_START, 0 * sizeof(FLASH_t)); -#ifdef FLASH_DEBUG_CFI +#ifdef FLASH_DEBUG testmanid = FLASH_LOBYTE(0x00); testdevid = FLASH_LOBYTE(0x01); #endif @@ -711,7 +711,7 @@ (FLASH_LOBYTE(0x30) << 8); } -#ifdef FLASH_DEBUG_CFI +#ifdef FLASH_DEBUG printk("Flash CFI Info: ****************************\n"); printk("\tmanufacturer_code = %#04x (%#04x)\n", flash_info.manufacturer_code, testmanid); @@ -722,7 +722,6 @@ if (flash_info.is_cfi_supported != 0) { int tmpval1, tmpval2; -#ifdef FLASH_DEBUG /* Print rest of CFI Ident */ printk("\tprimary_vendor_command_code = %#04x\n", flash_info.primary_vendor_command_code); @@ -732,7 +731,6 @@ flash_info.alternate_vendor_command_code); printk("\talternate_extended_query_table = %#04x\n", flash_info.alternate_extended_query_table); -#endif /* Print CFI Geometry Info */ tmpval1 = 1 << flash_info.device_size; @@ -740,13 +738,10 @@ printk("\tdevice_size = %#02x (%d bytes, %d MB, %d Mb)\n", flash_info.device_size, tmpval1, tmpval2, tmpval2 * 8); -#ifdef FLASH_VERBOSE printk("\tx8_async_ifc = %#02x\n", flash_info.x8_async_ifc); printk("\tx16_async_ifc = %#02x\n", flash_info.x16_async_ifc); -#endif - printk("\tmax_write_buffer_size = %d (%d bytes)\n", flash_info.max_write_buffer_size, 1 << flash_info.max_write_buffer_size); @@ -758,8 +753,7 @@ printk("\tsize_erase_blocks_r1 = %#04x (%d bytes)\n", flash_info.size_erase_blocks_r1, flash_info.size_erase_blocks_r1 * 256); - -#ifdef FLASH_VERBOSE + /* System Interface Information */ printk("\tvcc_min_program_erase = %d.%d V\n", (flash_info.vcc_min_program_erase & 0xF0) >> 4, @@ -803,7 +797,6 @@ flash_info.max_chip_erase_timeout, ((1 << flash_info.max_chip_erase_timeout) * (1 << flash_info.typ_full_chip_erase_timeout))); -#endif } #endif /* FLASH_DEBUG */ @@ -828,45 +821,45 @@ flash_sectsize = SECTSIZE_FROM_CFI( FLASH_CHIPS_PER_BUS, flash_info.size_erase_blocks_r1); - /* find appropriate flash */ - for (i = 0; flashInfoList[i] != NULL; ++i) { - if ((flash_info.manufacturer_code == - flashInfoList[i]->manufacturer_code) && - (flash_info.device_code == - flashInfoList[i]->device_code)) { - /* Found flash */ - printk("FLASH Driver: using %s devices\n", - flashInfoList[i]->deviceName); - - memcpy(flash_length, - flashInfoList[i]->flash_length, + /* Attempt to determine chip used if on Assabet */ + if (machine_is_assabet()) { + /* determine type of chip on Assabet */ + if ((flash_info.manufacturer_code == 0xB0) && + (flash_info.device_code == 0xD0)) { + /* is Intel 28F160S3 FastFlash chips, + * use their partition table. + */ + memcpy((void*)flash_length, + (void*)flash_length_28F160S3, + sizeof(flash_length)); +#ifdef FLASH_DEBUG + printk("FLASH Driver: using 2 x 28F160S3 16Mb devices\n"); +#endif + } + else if ((flash_info.manufacturer_code == 0x89) && + (flash_info.device_code == 0x18)) { + /* is Intel 28F128J3A StrataFlash chips, + * use their partition table. + */ + memcpy((void*)flash_length, + (void*)flash_length_28F128J3A, sizeof(flash_length)); - break; +#ifdef FLASH_DEBUG + printk("FLASH Driver: using 2 x 28F128J3A 128Mb devices\n"); +#endif } + else + printk(KERN_WARNING + "FLASH Driver: Unknown flash type (manufacturer = %#04x, device_code = %#04x!\n", + flash_info.manufacturer_code, + flash_info.device_code); } - /* verify flash */ - if (flashInfoList[i] == NULL) { - memcpy((void*)flash_length, - (void*)flash_length_default, - sizeof(flash_length_default)); - - printk(KERN_WARNING - "FLASH Driver: Unknown flash type (manufacturer = %#04x, device_code = %#04x!\n", - flash_info.manufacturer_code, - flash_info.device_code); - } - #ifdef FLASH_DEBUG printk("FLASH Driver: flash_sectsize = %d bytes (%d KB)\n", flash_sectsize, flash_sectsize / 1024); #endif - } -#else - /* use default flash partitioning */ - memcpy((void*)flash_length, - (void*)flash_length_default, - sizeof(flash_length_default)); + } #endif /* FLASH_HAS_CFI */ if (register_blkdev(MAJOR_NR, DEVICE_NAME, &flash_fops)) { @@ -930,13 +923,14 @@ } +#ifdef MODULE /* * Function: init_module * Author: Stephane Dalton * Abstract: Flash module initialisation function */ -static int __init flash_init_module(void) +int init_module(void) { return( flash_mem_init() ); } @@ -949,7 +943,7 @@ * function and frees the memory associated with the * caching system */ -static void __exit flash_cleanup_module(void) +void cleanup_module(void) { int i; @@ -957,26 +951,13 @@ destroy_buffers(MKDEV(MAJOR_NR, i)); unregister_blkdev(MAJOR_NR, DEVICE_NAME); blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR)); - flash_hardsec[i] = (int)NULL; + flash_hardsec[i] = NULL; blk_size[MAJOR_NR] = NULL; blksize_size[MAJOR_NR] = NULL; if( flash_cache.buf ) - free_pages((void*)flash_cache.buf, get_order(flash_sectsize)); + free_pages(flash_cache.buf, get_order(flash_sectsize)); flash_cache.buf = NULL; } - -#ifdef MODULE - -/* The default module stuff */ -module_init(flash_init_module); -module_exit(flash_cleanup_module); - -MODULE_AUTHOR("Nicolas Pitre"); -MODULE_DESCRIPTION("Intel Flash memory driver"); - -EXPORT_NO_SYMBOLS; - #endif - diff -urN linux-2.4.0-test8-rmk2-np1-org/drivers/block/flash_mem.h linux-2.4.0-test8-rmk2-np1-flash/drivers/block/flash_mem.h --- linux-2.4.0-test8-rmk2-np1-org/drivers/block/flash_mem.h Thu Sep 21 17:58:44 2000 +++ linux-2.4.0-test8-rmk2-np1-flash/drivers/block/flash_mem.h Thu Sep 21 17:51:03 2000 @@ -5,17 +5,6 @@ * This is a block device driver for Intel Flash memory. */ -#define MAX_FLASH_PARTITIONS 8 - -typedef struct FlashInfo { - char* deviceName; - u8 manufacturer_code; - u8 device_code; - int flash_length[MAX_FLASH_PARTITIONS]; -} FlashInfo; - -static int flash_length[MAX_FLASH_PARTITIONS] = { 0, 0, 0, 0, 0, - 0, 0, 0 }; /* * Partition definitions... @@ -23,124 +12,59 @@ #if defined( CONFIG_SA1100_VICTOR ) #define FLASH_PARTITIONS 4 -static int flash_length_default[FLASH_PARTITIONS] = { 0x10000, 0x40000, 0x1a0000, 0x10000 }; +static int flash_length[FLASH_PARTITIONS] = { 0x10000, 0x40000, 0x1a0000, 0x10000 }; #elif defined( CONFIG_SA1100_THINCLIENT ) || (CONFIG_SA1100_GRAPHICSCLIENT) #define FLASH_PARTITIONS 3 // static int flash_length[FLASH_PARTITIONS] = { 0x80000, 0x780000, 0x800000 }; -static int flash_length_default[FLASH_PARTITIONS] = { 0x100000, 0x300000, 0xc00000 }; +static int flash_length[FLASH_PARTITIONS] = { 0x100000, 0x300000, 0xc00000 }; #elif defined( CONFIG_VIPCI ) #define FLASH_PARTITIONS 4 -static int flash_length_default[FLASH_PARTITIONS] = { 0x10000, 0x80000, 0x730000, 0x40000 }; +static int flash_length[FLASH_PARTITIONS] = { 0x10000, 0x80000, 0x730000, 0x40000 }; #elif defined( CONFIG_SA1100_ASSABET ) -#define FLASH_PARTITIONS 5 +//#define FLASH_PARTITIONS 2 +#define FLASH_PARTITIONS 4 /* * Memory config with 28F160S3 FastFlash (As comes on Phase 4 Assabet) - * (Align @ 2 x 65K = 128K boundaries) - * Angel 1.2 <= 128 K + * Angel 1.2 <= 65 K * zImage 2.3.99-pre8 <= 768 K - * ramdisk_img <= 3 M - * smalldisk <= 128 K - * EMPTY = 0 + * ramdisk_img <= 2.5 M + * bigdisk <= 28.6875 M */ -static FlashInfo flash_28F160S3 = { - "28F160S3", - 0xB0, 0xD0, - { 0x00020000, 0x000c0000, 0x00300000, 0x00020000, - 0x0, 0x0, 0x0, 0x0 } -}; +static int flash_length_28F160S3[FLASH_PARTITIONS] = { 0x10000,0xc0000, 0x280000, 0xb0000 }; /* - * Memory config with 28F128J3A StrataFlash - * (Align @ 2 x 128K = 256K boundaries) - * Angel 1.2 <= 256 K - * initrd <= 256K - * zImage 2.4.0-test1 <= 768 K - * root <= 14 M - * bigdisk <= 16.75 M + * Memory config with 28F128J3A StrataFlash + * Angel 1.2 <= 65 K + * zImage 2.3.99-pre8 <= 768 K + * ramdisk_img <= 2.5 M + * bigdisk <= 28.6875 M */ -static FlashInfo flash_28F128J3A = { - "28F128J3A", - 0x89, 0x18, - { 0x00040000, 0x000c0000, 0x00040000, 0x00e00000, 0x010c0000, - 0x0, 0x0, 0x0 } -}; +static int flash_length_28F128J3A[FLASH_PARTITIONS] = { 0x10000, 0xc0000, 0x380000, 0x1bb0000 }; -static FlashInfo* flashInfoList[] = { - &flash_28F160S3, - &flash_28F128J3A, - NULL -}; - -static int flash_length_default[FLASH_PARTITIONS] = { 0, 0, 0, 0, 0 }; - -#define FLASH_HAS_CFI +//static int flash_length[FLASH_PARTITIONS] = { 0 ,0}; +static int flash_length[FLASH_PARTITIONS] = { 0, 0, 0, 0 }; #elif defined( CONFIG_SA1100_BITSY ) -#define FLASH_PARTITIONS 7 - -/* - * Memory config with 28F128J3A StrataFlash - * (Align @ 2 x 128K = 256K boundaries) - * bootldr <= 256 K - * kernel <= 512K - * params <= 256 K - * ramdisk <= 3 M - * cramfs <= 4M - * cramfs-usr <= 8 M - * other5 <= 16 M - */ -static FlashInfo flash_28F128J3A = { - "28F128J3A", - 0x89, 0x18, - { 0x00040000, 0x00080000, 0x00040000, 0x00300000, 0x00400000, - 0x00800000, 0x01000000, 0x0 } -}; - -/* - * Memory config with 28F640J3A StrataFlash - * (Align @ 2 x 128K = 256K boundaries) - * bootldr <= 256 K - * kernel <= 512K - * params <= 256 K - * ramdisk <= 3 M - * cramfs <= 4M - * cramfs-usr <= 8 M - * - */ -static FlashInfo flash_28F640J3A = { - "28F640J3A", - 0x89, 0x17, - { 0x00040000, 0x00080000, 0x00040000, 0x00300000, 0x00400000, - 0x0800000, 0x0, 0x0 } -}; - - -static FlashInfo* flashInfoList[] = { - &flash_28F128J3A, - &flash_28F640J3A, - NULL -}; -static int flash_length_default[FLASH_PARTITIONS] = { 0, 0, 0, 0, 0, 0, 0 }; - -#define FLASH_HAS_CFI +#define FLASH_PARTITIONS 6 +static int flash_length[FLASH_PARTITIONS] = { 0x00040000, 0x00080000, 0x00040000, 0x00700000, 0x00800000, 0x01000000 }; #elif defined( CONFIG_SA1100_CERF ) #define FLASH_PARTITIONS 2 -static int flash_length_default[FLASH_PARTITIONS] = { 0x00800000, 0x00800000 }; +static int flash_length[FLASH_PARTITIONS] = { 0x00800000, 0x00800000 }; #elif defined( CONFIG_ARCH_PERSONAL_SERVER ) #define FLASH_PARTITIONS 4 -static int flash_length_default[FLASH_PARTITIONS] = { 0x00020000, 0x000e0000, 0x00600000, 0x00200000 }; +static int flash_length[FLASH_PARTITIONS] = { 0x00020000, 0x000e0000, 0x00600000, 0x00200000 }; #elif defined( CONFIG_SA1100_LART ) /* @@ -152,7 +76,7 @@ #define FLASH_PARTITIONS 3 -static int flash_length_default[FLASH_PARTITIONS] = { 0x020000, 0x0e0000, 0x300000 }; +static int flash_length[FLASH_PARTITIONS] = { 0x020000, 0x0e0000, 0x300000 }; #else #error Missing partition definition #endif @@ -232,6 +156,7 @@ #define FLASH_SECTSIZE SECTSIZE_FROM_K( FLASH_CHIPS_PER_BUS, 128 ) #endif #define _CMD( x ) ((x)|((x)<<16)) +#define FLASH_HAS_CFI typedef unsigned int FLASH_t; @@ -362,3 +287,4 @@ u8 page_mode_read; /* P+0x13 size of page mode reads in 2^n bytes */ }; #endif +