From 8e58ac6d1cb165edfe5e9c33f0e4dd1077cc1448 Mon Sep 17 00:00:00 2001 From: Marcel Telka Date: Wed, 18 Jun 2003 09:48:44 +0000 Subject: [PATCH] 2003-06-18 Marcel Telka * flash/cfi.c (read2): Fixed operator precedence in macro. (cfi_detect): Fixed CFI detection code (based on patch 753295, Matan Ziv-Av). * flash/intel.c (intel_flash_autodetect8): New function (patch 753295, Matan Ziv-Av). (intel_8_flash_driver): New driver (patch 753295, Matan Ziv-Av). git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@486 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- libbrux/ChangeLog | 7 +++++++ libbrux/NEWS | 3 +++ libbrux/flash/cfi.c | 24 ++++++++++++------------ libbrux/flash/intel.c | 18 ++++++++++++++++++ 4 files changed, 40 insertions(+), 12 deletions(-) diff --git a/libbrux/ChangeLog b/libbrux/ChangeLog index 3aefea9f..195768a1 100644 --- a/libbrux/ChangeLog +++ b/libbrux/ChangeLog @@ -1,3 +1,10 @@ +2003-06-18 Marcel Telka + + * flash/cfi.c (read2): Fixed operator precedence in macro. + (cfi_detect): Fixed CFI detection code (based on patch 753295, Matan Ziv-Av). + * flash/intel.c (intel_flash_autodetect8): New function (patch 753295, Matan Ziv-Av). + (intel_8_flash_driver): New driver (patch 753295, Matan Ziv-Av). + 2003-06-12 Marcel Telka * flash/amd.c (amd_flash_autodetect, amd_flash_print_info, amd_flash_erase_block) diff --git a/libbrux/NEWS b/libbrux/NEWS index e69de29b..f7f92c92 100644 --- a/libbrux/NEWS +++ b/libbrux/NEWS @@ -0,0 +1,3 @@ +$Id$ + +2003-06-18: Added support for 1 x 8 bit Intel Flash (patch 753295, Matan Ziv-Av). diff --git a/libbrux/flash/cfi.c b/libbrux/flash/cfi.c index d573fe1c..94177978 100644 --- a/libbrux/flash/cfi.c +++ b/libbrux/flash/cfi.c @@ -87,29 +87,29 @@ cfi_detect( bus_t *bus, uint32_t adr, cfi_array_t **cfi_array ) #define D(data) ((data) << d) #define gD(data) (((data) >> d) & 0xFF) #define read1(off) gD(bus_read( bus, A(off) )) -#define read2(off) (bus_read_start( bus, A(off) ), gD(bus_read_next( bus, A(off + 1) )) | gD(bus_read_end( bus )) << 8) +#define read2(off) (bus_read_start( bus, A(off) ), gD(bus_read_next( bus, A((off) + 1) )) | gD(bus_read_end( bus )) << 8) #define write1(off,data) bus_write( bus, A(off), D(data) ) cfi_query_structure_t *cfi; uint32_t tmp; - ma = 1; + int ret = -4; /* CFI not detected (Q) */ /* detect CFI capable devices - see Table 1 in [1] */ - write1( CFI_CMD_QUERY_OFFSET, CFI_CMD_QUERY ); + for (ma = 1; ma <= 4; ma *= 2) { + write1( CFI_CMD_QUERY_OFFSET, CFI_CMD_QUERY ); - if (read1(CFI_QUERY_ID_OFFSET) != 'Q') { - write1( 0, CFI_CMD_READ_ARRAY1 ); - return -4; /* CFI not detected (Q) */ - } + if (read1(CFI_QUERY_ID_OFFSET) == 'Q') { + ret = -5; /* CFI not detected (R) */ + if (read1(CFI_QUERY_ID_OFFSET + 1) == 'R') + break; + } - for (; ma <= 4; ma *= 2) - if (read1(CFI_QUERY_ID_OFFSET + 1) == 'R') - break; - if (ma > 4) { write1( 0, CFI_CMD_READ_ARRAY1 ); - return -5; /* CFI not detected (R) */ } + if (ma > 4) + return ret; /* CFI not detected (Q or R) */ + if (read1(CFI_QUERY_ID_OFFSET + 2) != 'Y') { write1( 0, CFI_CMD_READ_ARRAY1 ); return -6; /* CFI not detected (Y) */ diff --git a/libbrux/flash/intel.c b/libbrux/flash/intel.c index 16bfe6a3..3b949829 100644 --- a/libbrux/flash/intel.c +++ b/libbrux/flash/intel.c @@ -67,6 +67,12 @@ intel_flash_autodetect( cfi_array_t *cfi_array ) return (cfi_array->cfi_chips[0]->cfi.identification_string.pri_id_code == CFI_VENDOR_INTEL_ECS) && (bus_width( cfi_array->bus, 0 ) == 16); } +static int +intel_flash_autodetect8( cfi_array_t *cfi_array ) +{ + return (cfi_array->cfi_chips[0]->cfi.identification_string.pri_id_code == CFI_VENDOR_INTEL_ECS) && (bus_width( cfi_array->bus, 0 ) == 8); +} + static void _intel_flash_print_info( bus_t *bus, int o ) { @@ -319,3 +325,15 @@ flash_driver_t intel_16_flash_driver = { intel_flash_program, intel_flash_readarray, }; + +flash_driver_t intel_8_flash_driver = { + 1, /* buswidth */ + N_("Intel Standard Command Set"), + N_("supported: 28Fxxxx, 1 x 8 bit"), + intel_flash_autodetect8, + intel_flash_print_info, + intel_flash_erase_block, + intel_flash_unlock_block, + intel_flash_program, + intel_flash_readarray, +};