diff --git a/jtag/ChangeLog b/jtag/ChangeLog index ae345ddb..d4e2cd3a 100644 --- a/jtag/ChangeLog +++ b/jtag/ChangeLog @@ -1,3 +1,22 @@ +2003-05-19 Marcel Telka + + * src/tap/parport/ppdev.c (ppdev_get_status): Inverted BUSY signal value. + + * include/cfi.h (cfi_chip_t, cfi_array_t): New typedefs. + (cfi_array_free): New function prototype. + (detect_cfi): Changed function prototype. + * include/flash.h (set_flash_driver): Removed function prototype. + * src/flash/cfi.c (BW16): Macro removed. + (read2): Function removed. + (cfi_array_free): New function. + (detect_cfi): Added code to detect all CFI chips on the data bus. + * src/flash.c (flashcheck): Removed bus width checking. Updated due changes in src/flash/cfi.c. + (flashmsbin): Updated due changes in src/flash/cfi.c. Removed memory leak. + * src/readmem.c: Added l10n support. Marked messages for translation. + (detectflash): Updated due changes in src/flash/cfi.c. Removed memory leak. + Removed flash driver setup. + * po/POTFILES.in: Added src/readmem.c. + 2003-05-16 Marcel Telka * include/part.h (part_print): New function declaration. @@ -22,7 +41,7 @@ * src/bus/pxa2x0.c (bus_params_t): Added last_adr and MC_registers structure members. (LAST_ADR, MC_pointer): New macros. (pxa250_bus_read_start, pxa250_bus_read_next, pxa250_bus_read_end, pxa250_bus_write): Disabled - external bus cycles for addresses above 0x0400000. + external bus cycles for addresses above 0x04000000. (pxa250_bus_width): Removed some output messages. Implemented BOOT_DEF emulation. (new_pxa250_bus): Implemented BOOT_DEF emulation. diff --git a/jtag/NEWS b/jtag/NEWS index b83ccdbd..1ea7e82c 100644 --- a/jtag/NEWS +++ b/jtag/NEWS @@ -3,6 +3,8 @@ $Id$ * Added new manufacturer: DEC. * Added support for executing scripts directly from stdin (parameter '-'). * Disabled external bus cycles for PXA250 for addresses above 0x04000000. + * Fixed bug in BUSY signal handling in Linux ppdev driver. + * Minor bugs fixed. jtag-0.3.2 (2003-04-04): diff --git a/jtag/include/cfi.h b/jtag/include/cfi.h index bb355859..58894764 100644 --- a/jtag/include/cfi.h +++ b/jtag/include/cfi.h @@ -30,6 +30,19 @@ #include "bus.h" -cfi_query_structure_t *detect_cfi( bus_t *bus, uint32_t adr ); +typedef struct { + int width; /* 1 for 8 bits, 2 for 16 bits, 4 for 32 bits, etc. */ + cfi_query_structure_t cfi; +} cfi_chip_t; + +typedef struct { + bus_t *bus; + uint32_t address; + int bus_width; /* in cfi_chips, e.g. 4 for 32 bits */ + cfi_chip_t **cfi_chips; +} cfi_array_t; + +void cfi_array_free( cfi_array_t *cfi_array ); +int detect_cfi( bus_t *bus, uint32_t adr, cfi_array_t **cfi_array ); #endif /* CFI_H */ diff --git a/jtag/include/flash.h b/jtag/include/flash.h index faa05b73..11146eb5 100644 --- a/jtag/include/flash.h +++ b/jtag/include/flash.h @@ -53,8 +53,6 @@ extern flash_driver_t *flash_drivers[]; #define flash_program flash_driver->flash_program #define flash_readarray flash_driver->flash_readarray -extern void set_flash_driver( bus_t *bus, cfi_query_structure_t *cfi ); - #define CFI_INTEL_ERROR_UNKNOWN 1 #define CFI_INTEL_ERROR_UNSUPPORTED 2 #define CFI_INTEL_ERROR_LOW_VPEN 3 diff --git a/jtag/po/POTFILES.in b/jtag/po/POTFILES.in index 34980bb0..e477e4c7 100644 --- a/jtag/po/POTFILES.in +++ b/jtag/po/POTFILES.in @@ -2,6 +2,7 @@ src/help.c src/jtag.c +src/readmem.c src/part/part.c src/tap/chain.c src/tap/parport/direct.c diff --git a/jtag/src/flash.c b/jtag/src/flash.c index f2a76e1f..3d4ce197 100644 --- a/jtag/src/flash.c +++ b/jtag/src/flash.c @@ -58,7 +58,7 @@ flash_driver_t *flash_drivers[] = { flash_driver_t *flash_driver = NULL; -void +static void set_flash_driver( bus_t *bus, cfi_query_structure_t *cfi ) { int i; @@ -77,33 +77,22 @@ set_flash_driver( bus_t *bus, cfi_query_structure_t *cfi ) /* check for flashmem - set driver */ static void -flashcheck( bus_t *bus, cfi_query_structure_t **cfi ) +flashcheck( bus_t *bus, cfi_array_t **cfi_array ) { - int o = 0; flash_driver = NULL; bus_prepare( bus ); printf( "Note: Supported configuration is 2 x 16 bit or 1 x 16 bit only\n" ); - switch (bus_width( bus, 0 )) { - case 16: - o = 1; - break; - case 32: - o = 2; - break; - default: - printf( "Error: Unknown bus width!\n" ); - return; - } - - *cfi = detect_cfi( bus, 0 ); - if (!*cfi) { + *cfi_array = NULL; + if (detect_cfi( bus, 0, cfi_array )) { + cfi_array_free( *cfi_array ); printf( "Flash not found!\n" ); return; } - set_flash_driver( bus, *cfi ); + + set_flash_driver( bus, &(*cfi_array)->cfi_chips[0]->cfi ); if (!flash_driver) { printf( "Flash not supported!\n" ); return; @@ -115,13 +104,15 @@ void flashmsbin( bus_t *bus, FILE *f ) { uint32_t adr; - cfi_query_structure_t *cfi = NULL; + cfi_query_structure_t *cfi; + cfi_array_t *cfi_array; - flashcheck( bus, &cfi ); - if (!cfi || !flash_driver) { + flashcheck( bus, &cfi_array ); + if (!cfi_array || !flash_driver) { printf( "no flash driver found\n" ); return; } + cfi = &cfi_array->cfi_chips[0]->cfi; /* test sync bytes */ { @@ -229,21 +220,25 @@ flashmsbin( bus_t *bus, FILE *f ) printf( "\n" ); printf( "Done.\n" ); + + cfi_array_free( cfi_array ); } void flashmem( bus_t *bus, FILE *f, uint32_t addr ) { uint32_t adr; - cfi_query_structure_t *cfi = NULL; + cfi_query_structure_t *cfi; + cfi_array_t *cfi_array; int *erased; int i; - flashcheck( bus, &cfi ); - if (!cfi || !flash_driver) { + flashcheck( bus, &cfi_array ); + if (!cfi_array || !flash_driver) { printf( "no flash driver found\n" ); return; } + cfi = &cfi_array->cfi_chips[0]->cfi; erased = malloc( cfi->device_geometry.erase_block_regions[0].number_of_erase_blocks * sizeof *erased ); if (!erased) { @@ -318,4 +313,6 @@ flashmem( bus_t *bus, FILE *f, uint32_t addr ) printf( "TODO: Verify is not available in 1 x 16 bit mode.\n" ); free( erased ); + + cfi_array_free( cfi_array ); } diff --git a/jtag/src/flash/cfi.c b/jtag/src/flash/cfi.c index 859ce9eb..14e68d98 100644 --- a/jtag/src/flash/cfi.c +++ b/jtag/src/flash/cfi.c @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) 2002 ETC s.r.o. + * Copyright (C) 2002, 2003 ETC s.r.o. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. * - * Written by Marcel Telka , 2002. + * Written by Marcel Telka , 2002, 2003. * * Documentation: * [1] JEDEC Solid State Technology Association, "Common Flash Interface (CFI)", @@ -35,133 +35,219 @@ #include "cfi.h" #include "bus.h" -/* function to cover 2x16 and 1x16 modes */ -#define BW16(x) ( (bus_width(bus, 0) == 16) ? x : ( (x<<16) | x ) ) - -static uint16_t -read2( bus_t *bus, uint32_t adr, int o ) +void +cfi_array_free( cfi_array_t *cfi_array ) { - uint16_t r; + if (!cfi_array) + return; + + if (cfi_array->cfi_chips) { + int i; + + for (i = 0; i < cfi_array->bus_width; i++) { + if (!cfi_array->cfi_chips[i]) + continue; + + free( cfi_array->cfi_chips[i]->cfi.device_geometry.erase_block_regions ); + free( cfi_array->cfi_chips[i] ); + } + free( cfi_array->cfi_chips ); + } - bus_read_start( bus, adr << o ); - r = bus_read_next( bus, (adr + 1) << o ); - return ((bus_read_end( bus ) & 0xFF) << 8) | (r & 0xFF); + free( cfi_array ); } -cfi_query_structure_t * -detect_cfi( bus_t *bus, uint32_t adr ) +int +detect_cfi( bus_t *bus, uint32_t adr, cfi_array_t **cfi_array ) { - cfi_query_structure_t *cfi; - int o = 2; - uint32_t tmp; - - if (bus_width( bus, 0 ) == 16) - o = 1; - - /* detect CFI capable devices - see Table 1 in [1] */ - bus_write( bus, CFI_CMD_QUERY_OFFSET << o, BW16(CFI_CMD_QUERY) ); - if (bus_read( bus, CFI_QUERY_ID_OFFSET << o ) != BW16('Q')) { - printf( "No CFI device detected (Q)!\n" ); - return NULL; - } - if (bus_read( bus, (CFI_QUERY_ID_OFFSET + 1) << o ) != BW16('R')) { - printf( "No CFI device detected (R)!\n" ); - return NULL; - } - if (bus_read( bus, (CFI_QUERY_ID_OFFSET + 2) << o ) != BW16('Y')) { - printf( "No CFI device detected (Y)!\n" ); - return NULL; - } + int bw; /* bus width */ + int d; /* data offset */ + int ba; /* bus width address multiplier */ + int ma; /* flash mode address multiplier */ + + if (!cfi_array || !bus) + return -1; /* invalid parameters */ + + *cfi_array = calloc( 1, sizeof (cfi_array_t) ); + if (!*cfi_array) + return -2; /* out of memory */ + + (*cfi_array)->bus = bus; + (*cfi_array)->address = adr; + bw = bus_width( bus, adr ); + if (bw != 8 && bw != 16 && bw != 32) + return -3; /* invalid bus width */ + (*cfi_array)->bus_width = ba = bw / 8; + (*cfi_array)->cfi_chips = calloc( ba, sizeof (cfi_chip_t *) ); + if (!(*cfi_array)->cfi_chips) + return -2; /* out of memory */ + + for (d = 0; d < bw; d += 8) { +#define A(off) (adr + (off) * ba * ma) +#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 write1(off,data) bus_write( bus, A(off), D(data) ) + + cfi_query_structure_t *cfi; + uint32_t tmp; + ma = 1; + + /* detect CFI capable devices - see Table 1 in [1] */ + 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) */ + } - printf( "\n%d x 16 bit CFI devices detected (QRY ok)!\n\n", o); + 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) */ + } - cfi = malloc( sizeof *cfi ); - if (!cfi) - return NULL; + if (read1(CFI_QUERY_ID_OFFSET + 2) != 'Y') { + write1( 0, CFI_CMD_READ_ARRAY1 ); + return -6; /* CFI not detected (Y) */ + } - /* TODO: Low chip only (bits 15:0) */ + (*cfi_array)->cfi_chips[d / 8] = calloc( 1, sizeof (cfi_chip_t) ); + if (!(*cfi_array)->cfi_chips[d / 8]) { + write1( 0, CFI_CMD_READ_ARRAY1 ); + return -2; /* out of memory */ + } + cfi = &(*cfi_array)->cfi_chips[d / 8]->cfi; - /* Identification string - see Table 6 in [1] */ - cfi->identification_string.pri_id_code = read2( bus, PRI_VENDOR_ID_OFFSET, o ); - cfi->identification_string.pri_vendor_tbl = NULL; - cfi->identification_string.alt_id_code = read2( bus, ALT_VENDOR_ID_OFFSET, o ); - cfi->identification_string.alt_vendor_tbl = NULL; + /* Identification string - see Table 6 in [1] */ + cfi->identification_string.pri_id_code = read2(PRI_VENDOR_ID_OFFSET); + cfi->identification_string.pri_vendor_tbl = NULL; + cfi->identification_string.alt_id_code = read2(ALT_VENDOR_ID_OFFSET); + cfi->identification_string.alt_vendor_tbl = NULL; - /* System interface information - see Table 7 in [1] */ - tmp = bus_read( bus, VCC_MIN_WEV_OFFSET << o ); - cfi->system_interface_info.vcc_min_wev = ((tmp >> 4) & 0xF) * 1000 + (tmp & 0xF) * 100; - tmp = bus_read( bus, VCC_MAX_WEV_OFFSET << o ); - cfi->system_interface_info.vcc_max_wev = ((tmp >> 4) & 0xF) * 1000 + (tmp & 0xF) * 100; - tmp = bus_read( bus, VPP_MIN_WEV_OFFSET << o ); - cfi->system_interface_info.vpp_min_wev = ((tmp >> 4) & 0xF) * 1000 + (tmp & 0xF) * 100; - tmp = bus_read( bus, VPP_MAX_WEV_OFFSET << o ); - cfi->system_interface_info.vpp_max_wev = ((tmp >> 4) & 0xF) * 1000 + (tmp & 0xF) * 100; + /* System interface information - see Table 7 in [1] */ + tmp = read1(VCC_MIN_WEV_OFFSET); + cfi->system_interface_info.vcc_min_wev = ((tmp >> 4) & 0xF) * 1000 + (tmp & 0xF) * 100; + tmp = read1(VCC_MAX_WEV_OFFSET); + cfi->system_interface_info.vcc_max_wev = ((tmp >> 4) & 0xF) * 1000 + (tmp & 0xF) * 100; + tmp = read1(VPP_MIN_WEV_OFFSET); + cfi->system_interface_info.vpp_min_wev = ((tmp >> 4) & 0xF) * 1000 + (tmp & 0xF) * 100; + tmp = read1(VPP_MAX_WEV_OFFSET); + cfi->system_interface_info.vpp_max_wev = ((tmp >> 4) & 0xF) * 1000 + (tmp & 0xF) * 100; - /* TODO: Add out of range checks for timeouts */ - tmp = bus_read( bus, TYP_SINGLE_WRITE_TIMEOUT_OFFSET << o ) & 0xFF; - cfi->system_interface_info.typ_single_write_timeout = tmp ? (1 << tmp) : 0; + /* TODO: Add out of range checks for timeouts */ + tmp = read1(TYP_SINGLE_WRITE_TIMEOUT_OFFSET); + cfi->system_interface_info.typ_single_write_timeout = tmp ? (1 << tmp) : 0; - tmp = bus_read( bus, TYP_BUFFER_WRITE_TIMEOUT_OFFSET << o ) & 0xFF; - cfi->system_interface_info.typ_buffer_write_timeout = tmp ? (1 << tmp) : 0; + tmp = read1(TYP_BUFFER_WRITE_TIMEOUT_OFFSET); + cfi->system_interface_info.typ_buffer_write_timeout = tmp ? (1 << tmp) : 0; - tmp = bus_read( bus, TYP_BLOCK_ERASE_TIMEOUT_OFFSET << o ) & 0xFF; - cfi->system_interface_info.typ_block_erase_timeout = tmp ? (1 << tmp) : 0; + tmp = read1(TYP_BLOCK_ERASE_TIMEOUT_OFFSET); + cfi->system_interface_info.typ_block_erase_timeout = tmp ? (1 << tmp) : 0; - tmp = bus_read( bus, TYP_CHIP_ERASE_TIMEOUT_OFFSET << o ) & 0xFF; - cfi->system_interface_info.typ_chip_erase_timeout = tmp ? (1 << tmp) : 0; + tmp = read1(TYP_CHIP_ERASE_TIMEOUT_OFFSET); + cfi->system_interface_info.typ_chip_erase_timeout = tmp ? (1 << tmp) : 0; - tmp = bus_read( bus, MAX_SINGLE_WRITE_TIMEOUT_OFFSET << o ) & 0xFF; - cfi->system_interface_info.max_single_write_timeout = - (tmp ? (1 << tmp) : 0) * cfi->system_interface_info.typ_single_write_timeout; + tmp = read1(MAX_SINGLE_WRITE_TIMEOUT_OFFSET); + cfi->system_interface_info.max_single_write_timeout = + (tmp ? (1 << tmp) : 0) * cfi->system_interface_info.typ_single_write_timeout; - tmp = bus_read( bus, MAX_BUFFER_WRITE_TIMEOUT_OFFSET << o ) & 0xFF; - cfi->system_interface_info.max_buffer_write_timeout = - (tmp ? (1 << tmp) : 0) * cfi->system_interface_info.typ_buffer_write_timeout; + tmp = read1(MAX_BUFFER_WRITE_TIMEOUT_OFFSET); + cfi->system_interface_info.max_buffer_write_timeout = + (tmp ? (1 << tmp) : 0) * cfi->system_interface_info.typ_buffer_write_timeout; - tmp = bus_read( bus, MAX_BLOCK_ERASE_TIMEOUT_OFFSET << o ) & 0xFF; - cfi->system_interface_info.max_block_erase_timeout = - (tmp ? (1 << tmp) : 0) * cfi->system_interface_info.typ_block_erase_timeout; + tmp = read1(MAX_BLOCK_ERASE_TIMEOUT_OFFSET); + cfi->system_interface_info.max_block_erase_timeout = + (tmp ? (1 << tmp) : 0) * cfi->system_interface_info.typ_block_erase_timeout; - tmp = bus_read( bus, MAX_CHIP_ERASE_TIMEOUT_OFFSET << o ) & 0xFF; - cfi->system_interface_info.max_chip_erase_timeout = - (tmp ? (1 << tmp) : 0) * cfi->system_interface_info.typ_chip_erase_timeout; + tmp = read1(MAX_CHIP_ERASE_TIMEOUT_OFFSET); + cfi->system_interface_info.max_chip_erase_timeout = + (tmp ? (1 << tmp) : 0) * cfi->system_interface_info.typ_chip_erase_timeout; - /* Device geometry - see Table 8 in [1] */ - /* TODO: Add out of range check */ - cfi->device_geometry.device_size = 1 << (bus_read( bus, DEVICE_SIZE_OFFSET << o ) & 0xFF); + /* Device geometry - see Table 8 in [1] */ + /* TODO: Add out of range check */ + cfi->device_geometry.device_size = 1 << read1(DEVICE_SIZE_OFFSET); - cfi->device_geometry.device_interface = read2( bus, FLASH_DEVICE_INTERFACE_OFFSET, o ); + cfi->device_geometry.device_interface = read2(FLASH_DEVICE_INTERFACE_OFFSET); - /* TODO: Add out of range check */ - cfi->device_geometry.max_bytes_write = 1 << read2( bus, MAX_BYTES_WRITE_OFFSET, o ); + /* TODO: Add out of range check */ + cfi->device_geometry.max_bytes_write = 1 << read2(MAX_BYTES_WRITE_OFFSET); - tmp = bus_read( bus, NUMBER_OF_ERASE_REGIONS_OFFSET << o ) & 0xFF; - cfi->device_geometry.number_of_erase_regions = tmp; + tmp = cfi->device_geometry.number_of_erase_regions = read1(NUMBER_OF_ERASE_REGIONS_OFFSET); - cfi->device_geometry.erase_block_regions = malloc( tmp * sizeof (cfi_erase_block_region_t) ); - if (!cfi->device_geometry.erase_block_regions) { - free( cfi ); - return NULL; - } - - { - int a = ERASE_BLOCK_REGION_OFFSET; - int i; + cfi->device_geometry.erase_block_regions = malloc( tmp * sizeof (cfi_erase_block_region_t) ); + if (!cfi->device_geometry.erase_block_regions) { + write1( 0, CFI_CMD_READ_ARRAY1 ); + return -2; /* out of memory */ + } + + { + int a; + int i; + + for (i = 0, a = ERASE_BLOCK_REGION_OFFSET; i < tmp; i++, a += 4) { + uint32_t y = read2(a); + uint32_t z = read2(a + 2) << 8; + if (z == 0) + z = 128; + cfi->device_geometry.erase_block_regions[i].erase_block_size = z; + cfi->device_geometry.erase_block_regions[i].number_of_erase_blocks = y + 1; + } + } - for (i = 0, a = ERASE_BLOCK_REGION_OFFSET; i < tmp; i++, a += 4) { - uint32_t y = read2( bus, a, o ); - uint32_t z = read2( bus, a + 2, o ) << 8; - if (z == 0) - z = 128; - cfi->device_geometry.erase_block_regions[i].erase_block_size = z; - cfi->device_geometry.erase_block_regions[i].number_of_erase_blocks = y + 1; + /* TODO: Intel Primary Algorithm Extended Query Table - see Table 5. in [2] */ + + /* Read Array */ + write1( 0, CFI_CMD_READ_ARRAY1 ); + +#undef A +#undef D +#undef gD +#undef read1 +#undef read2 +#undef write1 + + switch (cfi->device_geometry.device_interface) { + case CFI_INTERFACE_X8: + if (ma != 1) + return -7; /* error in device detection */ + (*cfi_array)->cfi_chips[d / 8]->width = 1; + break; + case CFI_INTERFACE_X16: + if (ma != 1) + return -7; /* error in device detection */ + (*cfi_array)->cfi_chips[d / 8]->width = 2; + d += 8; + break; + case CFI_INTERFACE_X8_X16: + if (ma != 1 && ma != 2) + return -7; /* error in device detection */ + (*cfi_array)->cfi_chips[d / 8]->width = 2 / ma; + if (ma == 1) + d += 8; + break; + case CFI_INTERFACE_X32: + if (ma != 1) + return -7; /* error in device detection */ + (*cfi_array)->cfi_chips[d / 8]->width = 4; + d += 24; + break; + case CFI_INTERFACE_X16_X32: + if (ma != 1 && ma != 2) + return -7; /* error in device detection */ + (*cfi_array)->cfi_chips[d / 8]->width = 4 / ma; + if (ma == 1) + d += 24; + else + d += 8; + break; + default: + return -7; /* error in device detection */ } } - /* TODO: Intel Primary Algorithm Extended Query Table - see Table 5. in [2] */ - - /* Read Array */ - bus_write( bus, 0, (CFI_CMD_READ_ARRAY1 << 16) | CFI_CMD_READ_ARRAY1 ); - - return cfi; + return 0; } diff --git a/jtag/src/readmem.c b/jtag/src/readmem.c index fd48bc1e..fd8df841 100644 --- a/jtag/src/readmem.c +++ b/jtag/src/readmem.c @@ -21,17 +21,22 @@ * Written by Marcel Telka , 2002. * * Documentation: - * [1] Advanced Micro Devices, "Common Flash Memory Interface Specification Release 2.0", - * December 1, 2001 - * [2] Intel Corporation, "Intel PXA250 and PXA210 Application Processors - * Developer's Manual", February 2002, Order Number: 278522-001 - * [3] Intel Corporation, "Common Flash Interface (CFI) and Command Sets - * Application Note 646", April 2000, Order Number: 292204-004 - * [4] Advanced Micro Devices, "Common Flash Memory Interface Publication 100 Vendor & Device - * ID Code Assignments", December 1, 2001, Volume Number: 96.1 + * [1] JEDEC Solid State Technology Association, "Common Flash Interface (CFI)", + * September 1999, Order Number: JESD68 + * [2] JEDEC Solid State Technology Association, "Common Flash Interface (CFI) ID Codes", + * September 2001, Order Number: JEP137-A * */ +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "gettext.h" +#define _(s) gettext(s) +#define N_(s) gettext_noop(s) +#define P_(s,p,n) ngettext(s,p,n) + #include #include #include @@ -48,165 +53,150 @@ void detectflash( bus_t *bus ) { - int o = 0; + cfi_array_t *cfi_array = NULL; cfi_query_structure_t *cfi; + char *s; if (!bus) { - printf( "Error: Missing bus driver!\n" ); + printf( _("Error: Missing bus driver!\n") ); return; } bus_prepare( bus ); - printf( "Note: Supported configuration is 2 x 16 bit or 1 x 16 bit only\n" ); - - switch (bus_width( bus, 0 )) { - case 16: - o = 1; - break; - case 32: - o = 2; - break; - default: - printf( "Error: Unknown bus width!\n" ); - return; - } - - cfi = detect_cfi( bus, 0 ); - if (!cfi) { - printf( "Flash not found!\n" ); + if (detect_cfi( bus, 0, &cfi_array )) { + cfi_array_free( cfi_array ); + printf( _("Flash not found!\n") ); return; } + cfi = &cfi_array->cfi_chips[0]->cfi; + /* detect CFI capable devices */ /* TODO: Low chip only */ - /* see 3.3.2 in [1] */ - printf( "CFI Query Identification String:\n" ); - printf( "\tPrimary Vendor Command Set and Control Interface ID Code: 0x%04X ", cfi->identification_string.pri_id_code ); - /* see Section 1. in [4] */ + /* see 4.3.2 in [1] */ + printf( _("Query identification string:\n") ); + /* see section 2 in [2] */ switch (cfi->identification_string.pri_id_code) { case CFI_VENDOR_NULL: - printf( "(null)\n" ); + s = _("null"); break; case CFI_VENDOR_INTEL_ECS: - printf( "(Intel/Sharp Extended Command Set)\n" ); + s = _("Intel/Sharp Extended Command Set"); break; case CFI_VENDOR_AMD_SCS: - printf( "(AMD/Fujitsu Standard Commanf Set)\n" ); + s = _("AMD/Fujitsu Standard Commanf Set"); break; case CFI_VENDOR_INTEL_SCS: - printf( "(Intel Standard Command Set)\n" ); + s = _("Intel Standard Command Set"); break; case CFI_VENDOR_AMD_ECS: - printf( "(AMD/Fujitsu Extended Command Set)\n" ); + s = _("AMD/Fujitsu Extended Command Set"); break; case CFI_VENDOR_MITSUBISHI_SCS: - printf( "(Mitsubishi Standard Command Set)\n" ); + s = _("Mitsubishi Standard Command Set"); break; case CFI_VENDOR_MITSUBISHI_ECS: - printf( "(Mitsubishi Extended Command Set)\n" ); + s = _("Mitsubishi Extended Command Set"); break; case CFI_VENDOR_SST_PWCS: - printf( "(Page Write Command Set)\n" ); + s = _("Page Write Command Set"); break; default: - printf( "(unknown!!!)\n" ); + s = _("unknown!!!"); break; } - printf( "\tAddress of Primary Algorithm extended Query table: P = 0x????\n" ); - printf( "\tAlternate Vendor Command Set and Control Interface ID Code: 0x%04X ", cfi->identification_string.alt_id_code ); + printf( _("\tPrimary Algorithm Command Set and Control Interface ID Code: 0x%04X (%s)\n"), cfi->identification_string.pri_id_code, s ); switch (cfi->identification_string.alt_id_code) { case CFI_VENDOR_NULL: - printf( "(null)\n" ); + s = _("null"); break; case CFI_VENDOR_INTEL_ECS: - printf( "(Intel/Sharp Extended Command Set)\n" ); + s = _("Intel/Sharp Extended Command Set"); break; case CFI_VENDOR_AMD_SCS: - printf( "(AMD/Fujitsu Standard Commanf Set)\n" ); + s = _("AMD/Fujitsu Standard Commanf Set"); break; case CFI_VENDOR_INTEL_SCS: - printf( "(Intel Standard Command Set)\n" ); + s = _("Intel Standard Command Set"); break; case CFI_VENDOR_AMD_ECS: - printf( "(AMD/Fujitsu Extended Command Set)\n" ); + s = _("AMD/Fujitsu Extended Command Set"); break; case CFI_VENDOR_MITSUBISHI_SCS: - printf( "(Mitsubishi Standard Command Set)\n" ); + s = _("Mitsubishi Standard Command Set"); break; case CFI_VENDOR_MITSUBISHI_ECS: - printf( "(Mitsubishi Extended Command Set)\n" ); + s = _("Mitsubishi Extended Command Set"); break; case CFI_VENDOR_SST_PWCS: - printf( "(Page Write Command Set)\n" ); + s = _("Page Write Command Set"); break; default: - printf( "(unknown!!!)\n" ); + s = _("unknown!!!"); break; } - printf( "\tAddress of Alternate Algorithm extended Query table: A = 0x????\n" ); + printf( _("\tAlternate Algorithm Command Set and Control Interface ID Code: 0x%04X (%s)\n"), cfi->identification_string.alt_id_code, s ); - /* see 3.3.3 in [1] */ - printf( "CFI Query System Interface Information:\n" ); - printf( "\tVcc Logic Supply Minimum Write/Erase voltage: %d mV\n", cfi->system_interface_info.vcc_min_wev ); - printf( "\tVcc Logic Supply Maximum Write/Erase voltage: %d mV\n", cfi->system_interface_info.vcc_max_wev ); - printf( "\tVpp [Programming] Logic Supply Minimum Write/Erase voltage: %d mV\n", cfi->system_interface_info.vpp_min_wev ); - printf( "\tVpp [Programming] Logic Supply Maximum Write/Erase voltage: %d mV\n", cfi->system_interface_info.vpp_max_wev ); - printf( "\tTypical timeout per single byte/word write: %d us\n", cfi->system_interface_info.typ_single_write_timeout ); - printf( "\tTypical timeout for minimum-size buffer write: %d us\n", cfi->system_interface_info.typ_buffer_write_timeout ); - printf( "\tTypical timeout per individual block erase: %d ms\n", cfi->system_interface_info.typ_block_erase_timeout ); - printf( "\tTypical timeout for full chip erase: %d ms\n", cfi->system_interface_info.typ_chip_erase_timeout ); - printf( "\tMaximum timeout for byte/word write: %d us\n", cfi->system_interface_info.max_single_write_timeout ); - printf( "\tMaximum timeout for buffer write: %d us\n", cfi->system_interface_info.max_buffer_write_timeout ); - printf( "\tMaximum timeout per individual block erase: %d ms\n", cfi->system_interface_info.max_block_erase_timeout ); - printf( "\tMaximum timeout for chip erase: %d ms\n", cfi->system_interface_info.max_chip_erase_timeout ); + /* see 4.3.3 in [1] */ + printf( _("Query system interface information:\n") ); + printf( _("\tVcc Logic Supply Minimum Write/Erase or Write voltage: %d mV\n"), cfi->system_interface_info.vcc_min_wev ); + printf( _("\tVcc Logic Supply Maximum Write/Erase or Write voltage: %d mV\n"), cfi->system_interface_info.vcc_max_wev ); + printf( _("\tVpp [Programming] Supply Minimum Write/Erase voltage: %d mV\n"), cfi->system_interface_info.vpp_min_wev ); + printf( _("\tVpp [Programming] Supply Maximum Write/Erase voltage: %d mV\n"), cfi->system_interface_info.vpp_max_wev ); + printf( _("\tTypical timeout per single byte/word program: %d us\n"), cfi->system_interface_info.typ_single_write_timeout ); + printf( _("\tTypical timeout for maximum-size multi-byte program: %d us\n"), cfi->system_interface_info.typ_buffer_write_timeout ); + printf( _("\tTypical timeout per individual block erase: %d ms\n"), cfi->system_interface_info.typ_block_erase_timeout ); + printf( _("\tTypical timeout for full chip erase: %d ms\n"), cfi->system_interface_info.typ_chip_erase_timeout ); + printf( _("\tMaximum timeout for byte/word program: %d us\n"), cfi->system_interface_info.max_single_write_timeout ); + printf( _("\tMaximum timeout for multi-byte program: %d us\n"), cfi->system_interface_info.max_buffer_write_timeout ); + printf( _("\tMaximum timeout per individual block erase: %d ms\n"), cfi->system_interface_info.max_block_erase_timeout ); + printf( _("\tMaximum timeout for chip erase: %d ms\n"), cfi->system_interface_info.max_chip_erase_timeout ); - /* see 3.3.4 in [1] */ - printf( "Device Geometry Definition:\n" ); - printf( "\tDevice Size: %d B (%d KiB, %d MiB)\n", + /* see 4.3.4 in [1] */ + printf( _("Device geometry definition:\n") ); + printf( _("\tDevice Size: %d B (%d KiB, %d MiB)\n"), cfi->device_geometry.device_size, cfi->device_geometry.device_size / 1024, cfi->device_geometry.device_size / (1024 * 1024) ); - printf( "\tFlash Device Interface description: 0x%04X ", cfi->device_geometry.device_interface ); - /* see Section 2. in [4] */ + /* see section 4 in [2] */ switch (cfi->device_geometry.device_interface) { case CFI_INTERFACE_X8: - printf( "(x8)\n" ); + s = _("x8"); break; case CFI_INTERFACE_X16: - printf( "(x16)\n" ); + s = _("x16"); break; case CFI_INTERFACE_X8_X16: - printf( "(x8/x16)\n" ); + s = _("x8/x16"); break; case CFI_INTERFACE_X32: - printf( "(x32)\n" ); + s = _("x32"); break; case CFI_INTERFACE_X16_X32: - printf( "(x16/x32)\n" ); + s = _("x16/x32"); break; default: - printf( "(unknown!!!)\n" ); + s = _("unknown!!!"); break; } - printf( "\tMaximum number of bytes in multi-byte write: %d\n", cfi->device_geometry.max_bytes_write ); - printf( "\tNumber of Erase Block Regions within device: %d\n", cfi->device_geometry.number_of_erase_regions ); - printf( "\tErase Block Region Information:\n" ); + printf( _("\tFlash Device Interface Code description: 0x%04X (%s)\n"), cfi->device_geometry.device_interface, s ); + printf( _("\tMaximum number of bytes in multi-byte program: %d\n"), cfi->device_geometry.max_bytes_write ); + printf( _("\tNumber of Erase Block Regions within device: %d\n"), cfi->device_geometry.number_of_erase_regions ); + printf( _("\tErase Block Region Information:\n") ); { int i; for (i = 0; i < cfi->device_geometry.number_of_erase_regions; i++) { - printf( "\t\tRegion %d:\n", i ); - printf( "\t\t\tErase Block Size: %d B (%d KiB)\n", + printf( _("\t\tRegion %d:\n"), i ); + printf( _("\t\t\tErase Block Size: %d B (%d KiB)\n"), cfi->device_geometry.erase_block_regions[i].erase_block_size, cfi->device_geometry.erase_block_regions[i].erase_block_size / 1024 ); - printf( "\t\t\tNumber of Erase Blocks: %d\n", cfi->device_geometry.erase_block_regions[i].number_of_erase_blocks ); + printf( _("\t\t\tNumber of Erase Blocks: %d\n"), cfi->device_geometry.erase_block_regions[i].number_of_erase_blocks ); } } - set_flash_driver( bus, cfi ); - if (flash_driver) - flash_driver->flash_print_info( bus ); + cfi_array_free( cfi_array ); } void diff --git a/jtag/src/tap/parport/ppdev.c b/jtag/src/tap/parport/ppdev.c index 85b589e5..3e47abd6 100644 --- a/jtag/src/tap/parport/ppdev.c +++ b/jtag/src/tap/parport/ppdev.c @@ -228,7 +228,7 @@ ppdev_get_status( parport_t *parport ) if (ioctl( p->fd, PPRSTATUS, &d ) == -1) return -1; - return d; + return d ^ 0x80; /* BUSY is inverted */ } static int