diff --git a/jtag/ChangeLog b/jtag/ChangeLog index fbf5c764..9d1cafe4 100644 --- a/jtag/ChangeLog +++ b/jtag/ChangeLog @@ -1,3 +1,21 @@ +2003-05-21 Marcel Telka + + * include/part.h (part_find_signal): New function declaration. + (part_set_signal, part_get_signal): Changed parameter signal name to signal pointer. + * src/part/part.c (part_find_signal): New function. + (part_set_signal, part_get_signal): Removed signal searching, used supplied pointer to signal. + * po/POTFILES.in: Added src/bus/ixp425.c, src/bus/pxa2x0.c, and src/bus/sa1110.c. + * src/bus/ixp425.c (bus_params_t, select_flash, unselect_flash, setup_address, set_data_in) + (setup_data, ixp425_bus_read_start, ixp425_bus_read_next, ixp425_bus_read_end, ixp425_bus_write) + (new_ixp425_bus): Optimized signal searching to increase bus access speed. + * src/bus/pxa2x0.c (bus_params_t, setup_address, set_data_in, setup_data, pxa250_bus_read_start) + (pxa250_bus_read_next, pxa250_bus_read_end, pxa250_bus_write, new_pxa250_bus): Ditto. + * src/bus/sa1110.c (bus_params_t, setup_address, set_data_in, setup_data, sa1110_bus_read_start) + (sa1110_bus_read_next, sa1110_bus_read_end, sa1110_bus_write, new_sa1110_bus): Ditto. + (sa1110_bus_width): Updated part_get_signal() function call. Added explicit signal search. + * src/cmd/get.c (cmd_get_run): Ditto. + * src/cmd/set.c (cmd_set_run): Updated part_set_signal() function call. Added explicit signal search. + 2003-05-20 Marcel Telka * configure.ac (AC_CONFIG_FILES): Added src/cmd/Makefile. diff --git a/jtag/NEWS b/jtag/NEWS index 1ea7e82c..5d2fbff2 100644 --- a/jtag/NEWS +++ b/jtag/NEWS @@ -4,6 +4,7 @@ $Id$ * 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. + * Optimized bus drivers to increase bus access speed (readmem, flashmem, ...). * Minor bugs fixed. jtag-0.3.2 (2003-04-04): diff --git a/jtag/include/part.h b/jtag/include/part.h index 04856955..a8b2630a 100644 --- a/jtag/include/part.h +++ b/jtag/include/part.h @@ -56,9 +56,10 @@ void part_free( part_t *p ); part_t *read_part( FILE *f, tap_register_t *idr ); instruction *part_find_instruction( part_t *p, const char *iname ); data_register *part_find_data_register( part_t *p, const char *drname ); +signal_t *part_find_signal( part_t *p, const char *signalname ); void part_set_instruction( part_t *p, const char *iname ); -void part_set_signal( part_t *p, const char *pname, int out, int val ); -int part_get_signal( part_t *p, const char *pname ); +void part_set_signal( part_t *p, signal_t *s, int out, int val ); +int part_get_signal( part_t *p, signal_t *s ); void part_print( part_t *p ); typedef struct parts parts_t; diff --git a/jtag/po/POTFILES.in b/jtag/po/POTFILES.in index a85501ed..aee3b001 100644 --- a/jtag/po/POTFILES.in +++ b/jtag/po/POTFILES.in @@ -2,6 +2,9 @@ src/jtag.c src/readmem.c +src/bus/ixp425.c +src/bus/pxa2x0.c +src/bus/sa1110.c src/cmd/cmd.c src/cmd/frequency.c src/cmd/help.c diff --git a/jtag/src/bus/ixp425.c b/jtag/src/bus/ixp425.c index 53623073..291bd1f4 100644 --- a/jtag/src/bus/ixp425.c +++ b/jtag/src/bus/ixp425.c @@ -19,9 +19,19 @@ * 02111-1307, USA. * * Written by Christian Pellegrin , 2003. + * Modified by Marcel Telka , 2003. * */ +#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 @@ -29,75 +39,84 @@ #include "part.h" #include "bus.h" #include "chain.h" +#include "signal.h" typedef struct { chain_t *chain; part_t *part; + signal_t *ex_cs[8]; + signal_t *ex_addr[24]; + signal_t *ex_data[16]; + signal_t *ex_wr; + signal_t *ex_rd; } bus_params_t; #define CHAIN ((bus_params_t *) bus->params)->chain #define PART ((bus_params_t *) bus->params)->part +#define EX_CS ((bus_params_t *) bus->params)->ex_cs +#define EX_ADDR ((bus_params_t *) bus->params)->ex_addr +#define EX_DATA ((bus_params_t *) bus->params)->ex_data +#define EX_WR ((bus_params_t *) bus->params)->ex_wr +#define EX_RD ((bus_params_t *) bus->params)->ex_rd static void -select_flash( part_t *p) +select_flash( bus_t *bus ) { - part_set_signal( p, "EX_CS[0]", 1, 0 ); - part_set_signal( p, "EX_CS[1]", 1, 1 ); - part_set_signal( p, "EX_CS[2]", 1, 1 ); - part_set_signal( p, "EX_CS[3]", 1, 1 ); - part_set_signal( p, "EX_CS[4]", 1, 1 ); - part_set_signal( p, "EX_CS[5]", 1, 1 ); - part_set_signal( p, "EX_CS[6]", 1, 1 ); - part_set_signal( p, "EX_CS[7]", 1, 1 ); + part_t *p = PART; + + part_set_signal( p, EX_CS[0], 1, 0 ); + part_set_signal( p, EX_CS[1], 1, 1 ); + part_set_signal( p, EX_CS[2], 1, 1 ); + part_set_signal( p, EX_CS[3], 1, 1 ); + part_set_signal( p, EX_CS[4], 1, 1 ); + part_set_signal( p, EX_CS[5], 1, 1 ); + part_set_signal( p, EX_CS[6], 1, 1 ); + part_set_signal( p, EX_CS[7], 1, 1 ); } static void -unselect_flash( part_t *p) +unselect_flash( bus_t *bus ) { - part_set_signal( p, "EX_CS[0]", 1, 1 ); - part_set_signal( p, "EX_CS[1]", 1, 1 ); - part_set_signal( p, "EX_CS[2]", 1, 1 ); - part_set_signal( p, "EX_CS[3]", 1, 1 ); - part_set_signal( p, "EX_CS[4]", 1, 1 ); - part_set_signal( p, "EX_CS[5]", 1, 1 ); - part_set_signal( p, "EX_CS[6]", 1, 1 ); - part_set_signal( p, "EX_CS[7]", 1, 1 ); + part_t *p = PART; + + part_set_signal( p, EX_CS[0], 1, 1 ); + part_set_signal( p, EX_CS[1], 1, 1 ); + part_set_signal( p, EX_CS[2], 1, 1 ); + part_set_signal( p, EX_CS[3], 1, 1 ); + part_set_signal( p, EX_CS[4], 1, 1 ); + part_set_signal( p, EX_CS[5], 1, 1 ); + part_set_signal( p, EX_CS[6], 1, 1 ); + part_set_signal( p, EX_CS[7], 1, 1 ); } static void -setup_address( part_t *p, uint32_t a ) +setup_address( bus_t *bus, uint32_t a ) { int i; - char buff[15]; + part_t *p = PART; - for (i = 0; i < 24; i++) { - sprintf( buff, "EX_ADDR[%d]", i ); - part_set_signal( p, buff, 1, (a >> i) & 1 ); - } + for (i = 0; i < 24; i++) + part_set_signal( p, EX_ADDR[i], 1, (a >> i) & 1 ); } static void -set_data_in( part_t *p ) +set_data_in( bus_t *bus ) { int i; - char buff[15]; + part_t *p = PART; - for (i = 0; i < 16; i++) { - sprintf( buff, "EX_DATA[%d]", i ); - part_set_signal( p, buff, 0, 0 ); - } + for (i = 0; i < 16; i++) + part_set_signal( p, EX_DATA[i], 0, 0 ); } static void -setup_data( part_t *p, uint32_t d ) +setup_data( bus_t *bus, uint32_t d ) { int i; - char buff[15]; + part_t *p = PART; - for (i = 0; i < 16; i++) { - sprintf( buff, "EX_DATA[%d]", i ); - part_set_signal( p, buff, 1, (d >> i) & 1 ); - } + for (i = 0; i < 16; i++) + part_set_signal( p, EX_DATA[i], 1, (d >> i) & 1 ); } static void @@ -113,12 +132,12 @@ ixp425_bus_read_start( bus_t *bus, uint32_t adr ) part_t *p = PART; chain_t *chain = CHAIN; - select_flash( p ); - part_set_signal( p, "EX_RD", 1, 0 ); - part_set_signal( p, "EX_WR", 1, 1 ); + select_flash( bus ); + part_set_signal( p, EX_RD, 1, 0 ); + part_set_signal( p, EX_WR, 1, 1 ); - setup_address( p, adr ); - set_data_in( p ); + setup_address( bus, adr ); + set_data_in( bus ); chain_shift_data_registers( chain ); } @@ -128,22 +147,16 @@ ixp425_bus_read_next( bus_t *bus, uint32_t adr ) { part_t *p = PART; chain_t *chain = CHAIN; + int i; + uint32_t d = 0; - setup_address( p, adr ); + setup_address( bus, adr ); chain_shift_data_registers( chain ); - { - int i; - char buff[15]; - uint32_t d = 0; - - for (i = 0; i < 16; i++) { - sprintf( buff, "EX_DATA[%d]", i ); - d |= (uint32_t) (part_get_signal( p, buff ) << i); - } + for (i = 0; i < 16; i++) + d |= (uint32_t) (part_get_signal( p, EX_DATA[i] ) << i); - return d; - } + return d; } static uint32_t @@ -151,25 +164,19 @@ ixp425_bus_read_end( bus_t *bus ) { part_t *p = PART; chain_t *chain = CHAIN; + int i; + uint32_t d = 0; - unselect_flash( p ); - part_set_signal( p, "EX_RD", 1, 1 ); - part_set_signal( p, "EX_WR", 1, 1 ); + unselect_flash( bus ); + part_set_signal( p, EX_RD, 1, 1 ); + part_set_signal( p, EX_WR, 1, 1 ); chain_shift_data_registers( chain ); - { - int i; - char buff[15]; - uint32_t d = 0; - - for (i = 0; i < 16; i++) { - sprintf( buff, "EX_DATA[%d]", i ); - d |= (uint32_t) (part_get_signal( p, buff ) << i); - } + for (i = 0; i < 16; i++) + d |= (uint32_t) (part_get_signal( p, EX_DATA[i] ) << i); - return d; - } + return d; } static uint32_t @@ -185,18 +192,18 @@ ixp425_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) part_t *p = PART; chain_t *chain = CHAIN; - select_flash( p ); - part_set_signal( p, "EX_RD", 1, 1 ); + select_flash( bus ); + part_set_signal( p, EX_RD, 1, 1 ); - setup_address( p, adr ); - setup_data( p, data ); + setup_address( bus, adr ); + setup_data( bus, data ); chain_shift_data_registers( chain ); - part_set_signal( p, "EX_WR", 1, 0 ); + part_set_signal( p, EX_WR, 1, 0 ); chain_shift_data_registers( chain ); - part_set_signal( p, "EX_WR", 1, 1 ); - unselect_flash( p ); + part_set_signal( p, EX_WR, 1, 1 ); + unselect_flash( bus ); chain_shift_data_registers( chain ); } @@ -230,6 +237,9 @@ bus_t * new_ixp425_bus( chain_t *chain, int pn ) { bus_t *bus; + char buff[15]; + int i; + int failed = 0; if (!chain || !chain->parts || chain->parts->len <= pn || pn < 0) return NULL; @@ -249,5 +259,49 @@ new_ixp425_bus( chain_t *chain, int pn ) CHAIN = chain; PART = chain->parts->parts[pn]; + for (i = 0; i < 8; i++) { + sprintf( buff, "EX_CS[%d]", i ); + EX_CS[i] = part_find_signal( PART, buff ); + if (!EX_CS[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + for (i = 0; i < 24; i++) { + sprintf( buff, "EX_ADDR[%d]", i ); + EX_ADDR[i] = part_find_signal( PART, buff ); + if (!EX_ADDR[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + for (i = 0; i < 16; i++) { + sprintf( buff, "EX_DATA[%d]", i ); + EX_DATA[i] = part_find_signal( PART, buff ); + if (!EX_DATA[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + EX_WR = part_find_signal( PART, "EX_WR" ); + if (!EX_WR) { + printf( _("signal '%s' not found\n"), "EX_WR" ); + failed = 1; + } + EX_RD = part_find_signal( PART, "EX_RD" ); + if (!EX_RD) { + printf( _("signal '%s' not found\n"), "EX_RD" ); + failed = 1; + } + + if (failed) { + free( bus->params ); + free( bus ); + return NULL; + } + return bus; } diff --git a/jtag/src/bus/pxa2x0.c b/jtag/src/bus/pxa2x0.c index 69aaf323..1e36056c 100644 --- a/jtag/src/bus/pxa2x0.c +++ b/jtag/src/bus/pxa2x0.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] Intel Corporation, "Intel PXA250 and PXA210 Application Processors @@ -26,6 +26,15 @@ * */ +#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 @@ -34,54 +43,65 @@ #include "part.h" #include "bus.h" +#include "signal.h" typedef struct { chain_t *chain; part_t *part; uint32_t last_adr; + signal_t *ma[26]; + signal_t *md[32]; + signal_t *ncs[1]; + signal_t *dqm[4]; + signal_t *rdnwr; + signal_t *nwe; + signal_t *noe; + signal_t *nsdcas; MC_registers_t MC_registers; } bus_params_t; #define CHAIN ((bus_params_t *) bus->params)->chain #define PART ((bus_params_t *) bus->params)->part #define LAST_ADR ((bus_params_t *) bus->params)->last_adr +#define MA ((bus_params_t *) bus->params)->ma +#define MD ((bus_params_t *) bus->params)->md +#define nCS ((bus_params_t *) bus->params)->ncs +#define DQM ((bus_params_t *) bus->params)->dqm +#define RDnWR ((bus_params_t *) bus->params)->rdnwr +#define nWE ((bus_params_t *) bus->params)->nwe +#define nOE ((bus_params_t *) bus->params)->noe +#define nSDCAS ((bus_params_t *) bus->params)->nsdcas #define MC_pointer (&((bus_params_t *) bus->params)->MC_registers) static void -setup_address( part_t *p, uint32_t a ) +setup_address( bus_t *bus, uint32_t a ) { int i; - char buff[10]; + part_t *p = PART; - for (i = 0; i < 26; i++) { - sprintf( buff, "MA[%d]", i ); - part_set_signal( p, buff, 1, (a >> i) & 1 ); - } + for (i = 0; i < 26; i++) + part_set_signal( p, MA[i], 1, (a >> i) & 1 ); } static void -set_data_in( part_t *p ) +set_data_in( bus_t *bus ) { int i; - char buff[10]; + part_t *p = PART; - for (i = 0; i < 32; i++) { - sprintf( buff, "MD[%d]", i ); - part_set_signal( p, buff, 0, 0 ); - } + for (i = 0; i < 32; i++) + part_set_signal( p, MD[i], 0, 0 ); } static void -setup_data( part_t *p, uint32_t d ) +setup_data( bus_t *bus, uint32_t d ) { int i; - char buff[10]; + part_t *p = PART; - for (i = 0; i < 32; i++) { - sprintf( buff, "MD[%d]", i ); - part_set_signal( p, buff, 1, (d >> i) & 1 ); - } + for (i = 0; i < 32; i++) + part_set_signal( p, MD[i], 1, (d >> i) & 1 ); } static void @@ -102,18 +122,18 @@ pxa250_bus_read_start( bus_t *bus, uint32_t adr ) return; /* see Figure 6-13 in [1] */ - part_set_signal( p, "nCS[0]", 1, 0 ); - part_set_signal( p, "DQM[0]", 1, 0 ); - part_set_signal( p, "DQM[1]", 1, 0 ); - part_set_signal( p, "DQM[2]", 1, 0 ); - part_set_signal( p, "DQM[3]", 1, 0 ); - part_set_signal( p, "RDnWR", 1, 1 ); - part_set_signal( p, "nWE", 1, 1 ); - part_set_signal( p, "nOE", 1, 0 ); - part_set_signal( p, "nSDCAS", 1, 0 ); - - setup_address( p, adr ); - set_data_in( p ); + part_set_signal( p, nCS[0], 1, 0 ); + part_set_signal( p, DQM[0], 1, 0 ); + part_set_signal( p, DQM[1], 1, 0 ); + part_set_signal( p, DQM[2], 1, 0 ); + part_set_signal( p, DQM[3], 1, 0 ); + part_set_signal( p, RDnWR, 1, 1 ); + part_set_signal( p, nWE, 1, 1 ); + part_set_signal( p, nOE, 1, 0 ); + part_set_signal( p, nSDCAS, 1, 0 ); + + setup_address( bus, adr ); + set_data_in( bus ); chain_shift_data_registers( chain ); } @@ -125,6 +145,8 @@ pxa250_bus_read_next( bus_t *bus, uint32_t adr ) { part_t *p = PART; chain_t *chain = CHAIN; + int i; + uint32_t d = 0; if (LAST_ADR >= 0x04000000) pxa250_bus_read_start( bus, adr ); @@ -133,21 +155,13 @@ pxa250_bus_read_next( bus_t *bus, uint32_t adr ) LAST_ADR = adr; /* see Figure 6-13 in [1] */ - setup_address( p, adr ); + setup_address( bus, adr ); chain_shift_data_registers( chain ); - { - int i; - char buff[10]; - uint32_t d = 0; + for (i = 0; i < 32; i++) + d |= (uint32_t) (part_get_signal( p, MD[i] ) << i); - for (i = 0; i < 32; i++) { - sprintf( buff, "MD[%d]", i ); - d |= (uint32_t) (part_get_signal( p, buff ) << i); - } - - return d; - } + return d; } static uint32_t @@ -155,29 +169,23 @@ pxa250_bus_read_end( bus_t *bus ) { part_t *p = PART; chain_t *chain = CHAIN; + int i; + uint32_t d = 0; if (LAST_ADR >= 0x04000000) return 0; /* see Figure 6-13 in [1] */ - part_set_signal( p, "nCS[0]", 1, 1 ); - part_set_signal( p, "nOE", 1, 1 ); - part_set_signal( p, "nSDCAS", 1, 1 ); + part_set_signal( p, nCS[0], 1, 1 ); + part_set_signal( p, nOE, 1, 1 ); + part_set_signal( p, nSDCAS, 1, 1 ); chain_shift_data_registers( chain ); - { - int i; - char buff[10]; - uint32_t d = 0; - - for (i = 0; i < 32; i++) { - sprintf( buff, "MD[%d]", i ); - d |= (uint32_t) (part_get_signal( p, buff ) << i); - } + for (i = 0; i < 32; i++) + d |= (uint32_t) (part_get_signal( p, MD[i] ) << i); - return d; - } + return d; } static uint32_t @@ -197,24 +205,24 @@ pxa250_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) if (adr >= 0x04000000) return; - part_set_signal( p, "nCS[0]", 1, 0 ); - part_set_signal( p, "DQM[0]", 1, 0 ); - part_set_signal( p, "DQM[1]", 1, 0 ); - part_set_signal( p, "DQM[2]", 1, 0 ); - part_set_signal( p, "DQM[3]", 1, 0 ); - part_set_signal( p, "RDnWR", 1, 0 ); - part_set_signal( p, "nWE", 1, 1 ); - part_set_signal( p, "nOE", 1, 1 ); - part_set_signal( p, "nSDCAS", 1, 0 ); + part_set_signal( p, nCS[0], 1, 0 ); + part_set_signal( p, DQM[0], 1, 0 ); + part_set_signal( p, DQM[1], 1, 0 ); + part_set_signal( p, DQM[2], 1, 0 ); + part_set_signal( p, DQM[3], 1, 0 ); + part_set_signal( p, RDnWR, 1, 0 ); + part_set_signal( p, nWE, 1, 1 ); + part_set_signal( p, nOE, 1, 1 ); + part_set_signal( p, nSDCAS, 1, 0 ); - setup_address( p, adr ); - setup_data( p, data ); + setup_address( bus, adr ); + setup_data( bus, data ); chain_shift_data_registers( chain ); - part_set_signal( p, "nWE", 1, 0 ); + part_set_signal( p, nWE, 1, 0 ); chain_shift_data_registers( chain ); - part_set_signal( p, "nWE", 1, 1 ); + part_set_signal( p, nWE, 1, 1 ); chain_shift_data_registers( chain ); } @@ -267,6 +275,9 @@ bus_t * new_pxa250_bus( chain_t *chain, int pn ) { bus_t *bus; + char buff[10]; + int i; + int failed = 0; if (!chain || !chain->parts || chain->parts->len <= pn || pn < 0) return NULL; @@ -286,9 +297,72 @@ new_pxa250_bus( chain_t *chain, int pn ) CHAIN = chain; PART = chain->parts->parts[pn]; - BOOT_DEF = BOOT_DEF_PKG_TYPE | BOOT_DEF_BOOT_SEL(part_get_signal( PART, "BOOT_SEL[2]" ) << 2 - | part_get_signal( PART, "BOOT_SEL[1]" ) << 1 - | part_get_signal( PART, "BOOT_SEL[0]" )); + for (i = 0; i < 26; i++) { + sprintf( buff, "MA[%d]", i ); + MA[i] = part_find_signal( PART, buff ); + if (!MA[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + for (i = 0; i < 32; i++) { + sprintf( buff, "MD[%d]", i ); + MD[i] = part_find_signal( PART, buff ); + if (!MD[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + for (i = 0; i < 1; i++) { + sprintf( buff, "nCS[%d]", i ); + nCS[i] = part_find_signal( PART, buff ); + if (!nCS[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + for (i = 0; i < 4; i++) { + sprintf( buff, "DQM[%d]", i ); + DQM[i] = part_find_signal( PART, buff ); + if (!DQM[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + RDnWR = part_find_signal( PART, "RDnWR" ); + if (!RDnWR) { + printf( _("signal '%s' not found\n"), "RDnWR" ); + failed = 1; + } + nWE = part_find_signal( PART, "nWE" ); + if (!nWE) { + printf( _("signal '%s' not found\n"), "nWE" ); + failed = 1; + } + nOE = part_find_signal( PART, "nOE" ); + if (!nOE) { + printf( _("signal '%s' not found\n"), "nOE" ); + failed = 1; + } + nSDCAS = part_find_signal( PART, "nSDCAS" ); + if (!nSDCAS) { + printf( _("signal '%s' not found\n"), "nSDCAS" ); + failed = 1; + } + + if (failed) { + free( bus->params ); + free( bus ); + return NULL; + } + + BOOT_DEF = BOOT_DEF_PKG_TYPE | BOOT_DEF_BOOT_SEL(part_get_signal( PART, part_find_signal( PART, "BOOT_SEL[2]" ) ) << 2 + | part_get_signal( PART, part_find_signal( PART, "BOOT_SEL[1]" ) ) << 1 + | part_get_signal( PART, part_find_signal( PART, "BOOT_SEL[0]" ) )); return bus; } diff --git a/jtag/src/bus/sa1110.c b/jtag/src/bus/sa1110.c index 5a32df1c..575218fa 100644 --- a/jtag/src/bus/sa1110.c +++ b/jtag/src/bus/sa1110.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] Intel Corporation, "Intel StrongARM SA-1110 Microprocessor @@ -26,6 +26,15 @@ * */ +#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 @@ -33,49 +42,56 @@ #include "part.h" #include "bus.h" #include "chain.h" +#include "signal.h" typedef struct { chain_t *chain; part_t *part; + signal_t *a[26]; + signal_t *d[32]; + signal_t *ncs[6]; + signal_t *rd_nwr; + signal_t *nwe; + signal_t *noe; } bus_params_t; #define CHAIN ((bus_params_t *) bus->params)->chain #define PART ((bus_params_t *) bus->params)->part +#define A ((bus_params_t *) bus->params)->a +#define D ((bus_params_t *) bus->params)->d +#define nCS ((bus_params_t *) bus->params)->ncs +#define RD_nWR ((bus_params_t *) bus->params)->rd_nwr +#define nWE ((bus_params_t *) bus->params)->nwe +#define nOE ((bus_params_t *) bus->params)->noe static void -setup_address( part_t *p, uint32_t a ) +setup_address( bus_t *bus, uint32_t a ) { int i; - char buff[10]; + part_t *p = PART; - for (i = 0; i < 26; i++) { - sprintf( buff, "A%d", i ); - part_set_signal( p, buff, 1, (a >> i) & 1 ); - } + for (i = 0; i < 26; i++) + part_set_signal( p, A[i], 1, (a >> i) & 1 ); } static void -set_data_in( part_t *p ) +set_data_in( bus_t *bus ) { int i; - char buff[10]; + part_t *p = PART; - for (i = 0; i < 32; i++) { - sprintf( buff, "D%d", i ); - part_set_signal( p, buff, 0, 0 ); - } + for (i = 0; i < 32; i++) + part_set_signal( p, D[i], 0, 0 ); } static void -setup_data( part_t *p, uint32_t d ) +setup_data( bus_t *bus, uint32_t d ) { int i; - char buff[10]; + part_t *p = PART; - for (i = 0; i < 32; i++) { - sprintf( buff, "D%d", i ); - part_set_signal( p, buff, 1, (d >> i) & 1 ); - } + for (i = 0; i < 32; i++) + part_set_signal( p, D[i], 1, (d >> i) & 1 ); } static void @@ -92,18 +108,18 @@ sa1110_bus_read_start( bus_t *bus, uint32_t adr ) part_t *p = PART; chain_t *chain = CHAIN; - part_set_signal( p, "nCS0", 1, (adr >> 27) != 0 ); - part_set_signal( p, "nCS1", 1, (adr >> 27) != 1 ); - part_set_signal( p, "nCS2", 1, (adr >> 27) != 2 ); - part_set_signal( p, "nCS3", 1, (adr >> 27) != 3 ); - part_set_signal( p, "nCS4", 1, (adr >> 27) != 8 ); - part_set_signal( p, "nCS5", 1, (adr >> 27) != 9 ); - part_set_signal( p, "RD_nWR", 1, 1 ); - part_set_signal( p, "nWE", 1, 1 ); - part_set_signal( p, "nOE", 1, 0 ); + part_set_signal( p, nCS[0], 1, (adr >> 27) != 0 ); + part_set_signal( p, nCS[1], 1, (adr >> 27) != 1 ); + part_set_signal( p, nCS[2], 1, (adr >> 27) != 2 ); + part_set_signal( p, nCS[3], 1, (adr >> 27) != 3 ); + part_set_signal( p, nCS[4], 1, (adr >> 27) != 8 ); + part_set_signal( p, nCS[5], 1, (adr >> 27) != 9 ); + part_set_signal( p, RD_nWR, 1, 1 ); + part_set_signal( p, nWE, 1, 1 ); + part_set_signal( p, nOE, 1, 0 ); - setup_address( p, adr ); - set_data_in( p ); + setup_address( bus, adr ); + set_data_in( bus ); chain_shift_data_registers( chain ); } @@ -114,22 +130,16 @@ sa1110_bus_read_next( bus_t *bus, uint32_t adr ) /* see Figure 10-12 in [1] */ part_t *p = PART; chain_t *chain = CHAIN; + int i; + uint32_t d = 0; - setup_address( p, adr ); + setup_address( bus, adr ); chain_shift_data_registers( chain ); - { - int i; - char buff[10]; - uint32_t d = 0; + for (i = 0; i < 32; i++) + d |= (uint32_t) (part_get_signal( p, D[i] ) << i); - for (i = 0; i < 32; i++) { - sprintf( buff, "D%d", i ); - d |= (uint32_t) (part_get_signal( p, buff ) << i); - } - - return d; - } + return d; } static uint32_t @@ -138,28 +148,22 @@ sa1110_bus_read_end( bus_t *bus ) /* see Figure 10-12 in [1] */ part_t *p = PART; chain_t *chain = CHAIN; - - part_set_signal( p, "nCS0", 1, 1 ); - part_set_signal( p, "nCS1", 1, 1 ); - part_set_signal( p, "nCS2", 1, 1 ); - part_set_signal( p, "nCS3", 1, 1 ); - part_set_signal( p, "nCS4", 1, 1 ); - part_set_signal( p, "nCS5", 1, 1 ); - part_set_signal( p, "nOE", 1, 1 ); + int i; + uint32_t d = 0; + + part_set_signal( p, nCS[0], 1, 1 ); + part_set_signal( p, nCS[1], 1, 1 ); + part_set_signal( p, nCS[2], 1, 1 ); + part_set_signal( p, nCS[3], 1, 1 ); + part_set_signal( p, nCS[4], 1, 1 ); + part_set_signal( p, nCS[5], 1, 1 ); + part_set_signal( p, nOE, 1, 1 ); chain_shift_data_registers( chain ); - { - int i; - char buff[10]; - uint32_t d = 0; + for (i = 0; i < 32; i++) + d |= (uint32_t) (part_get_signal( p, D[i] ) << i); - for (i = 0; i < 32; i++) { - sprintf( buff, "D%d", i ); - d |= (uint32_t) (part_get_signal( p, buff ) << i); - } - - return d; - } + return d; } static uint32_t @@ -176,37 +180,37 @@ sa1110_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) part_t *p = PART; chain_t *chain = CHAIN; - part_set_signal( p, "nCS0", 1, (adr >> 27) != 0 ); - part_set_signal( p, "nCS1", 1, (adr >> 27) != 1 ); - part_set_signal( p, "nCS2", 1, (adr >> 27) != 2 ); - part_set_signal( p, "nCS3", 1, (adr >> 27) != 3 ); - part_set_signal( p, "nCS4", 1, (adr >> 27) != 8 ); - part_set_signal( p, "nCS5", 1, (adr >> 27) != 9 ); - part_set_signal( p, "RD_nWR", 1, 0 ); - part_set_signal( p, "nWE", 1, 1 ); - part_set_signal( p, "nOE", 1, 1 ); + part_set_signal( p, nCS[0], 1, (adr >> 27) != 0 ); + part_set_signal( p, nCS[1], 1, (adr >> 27) != 1 ); + part_set_signal( p, nCS[2], 1, (adr >> 27) != 2 ); + part_set_signal( p, nCS[3], 1, (adr >> 27) != 3 ); + part_set_signal( p, nCS[4], 1, (adr >> 27) != 8 ); + part_set_signal( p, nCS[5], 1, (adr >> 27) != 9 ); + part_set_signal( p, RD_nWR, 1, 0 ); + part_set_signal( p, nWE, 1, 1 ); + part_set_signal( p, nOE, 1, 1 ); - setup_address( p, adr ); - setup_data( p, data ); + setup_address( bus, adr ); + setup_data( bus, data ); chain_shift_data_registers( chain ); - part_set_signal( p, "nWE", 1, 0 ); + part_set_signal( p, nWE, 1, 0 ); chain_shift_data_registers( chain ); - part_set_signal( p, "nWE", 1, 1 ); - part_set_signal( p, "nCS0", 1, 1 ); - part_set_signal( p, "nCS1", 1, 1 ); - part_set_signal( p, "nCS2", 1, 1 ); - part_set_signal( p, "nCS3", 1, 1 ); - part_set_signal( p, "nCS4", 1, 1 ); - part_set_signal( p, "nCS5", 1, 1 ); + part_set_signal( p, nWE, 1, 1 ); + part_set_signal( p, nCS[0], 1, 1 ); + part_set_signal( p, nCS[1], 1, 1 ); + part_set_signal( p, nCS[2], 1, 1 ); + part_set_signal( p, nCS[3], 1, 1 ); + part_set_signal( p, nCS[4], 1, 1 ); + part_set_signal( p, nCS[5], 1, 1 ); chain_shift_data_registers( chain ); } static int sa1110_bus_width( bus_t *bus, uint32_t adr ) { - if (part_get_signal( PART, "ROM_SEL" )) { + if (part_get_signal( PART, part_find_signal( PART, "ROM_SEL" ) )) { printf( "ROM_SEL: 32 bits\n" ); return 32; } else { @@ -238,6 +242,9 @@ bus_t * new_sa1110_bus( chain_t *chain, int pn ) { bus_t *bus; + char buff[10]; + int i; + int failed = 0; if (!chain || !chain->parts || chain->parts->len <= pn || pn < 0) return NULL; @@ -257,6 +264,55 @@ new_sa1110_bus( chain_t *chain, int pn ) CHAIN = chain; PART = chain->parts->parts[pn]; + for (i = 0; i < 26; i++) { + sprintf( buff, "A%d", i ); + A[i] = part_find_signal( PART, buff ); + if (!A[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + for (i = 0; i < 32; i++) { + sprintf( buff, "D%d", i ); + D[i] = part_find_signal( PART, buff ); + if (!D[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + for (i = 0; i < 6; i++) { + sprintf( buff, "nCS%d", i ); + nCS[i] = part_find_signal( PART, buff ); + if (!nCS[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + RD_nWR = part_find_signal( PART, "RD_nWR" ); + if (!RD_nWR) { + printf( _("signal '%s' not found\n"), "RD_nWR" ); + failed = 1; + } + nWE = part_find_signal( PART, "nWE" ); + if (!nWE) { + printf( _("signal '%s' not found\n"), "nWE" ); + failed = 1; + } + nOE = part_find_signal( PART, "nOE" ); + if (!nOE) { + printf( _("signal '%s' not found\n"), "nOE" ); + failed = 1; + } + + if (failed) { + free( bus->params ); + free( bus ); + return NULL; + } + return bus; } diff --git a/jtag/src/cmd/get.c b/jtag/src/cmd/get.c index 01b89244..a54f3143 100644 --- a/jtag/src/cmd/get.c +++ b/jtag/src/cmd/get.c @@ -35,6 +35,7 @@ #include #include "part.h" +#include "signal.h" #include "jtag.h" #include "cmd.h" @@ -44,6 +45,7 @@ cmd_get_run( char *params[] ) { unsigned int n; int data; + signal_t *s; if (cmd_params( params ) != 4) return -1; @@ -67,7 +69,12 @@ cmd_get_run( char *params[] ) return 1; } - data = part_get_signal( chain->parts->parts[n], params[3] ); + s = part_find_signal( chain->parts->parts[n], params[3] ); + if (!s) { + printf( _("signal '%s' not found\n"), params[3] ); + return 1; + } + data = part_get_signal( chain->parts->parts[n], s ); if (data != -1) printf( _("%s = %d\n"), params[3], data ); diff --git a/jtag/src/cmd/set.c b/jtag/src/cmd/set.c index 2eeceeb4..44db851f 100644 --- a/jtag/src/cmd/set.c +++ b/jtag/src/cmd/set.c @@ -35,6 +35,7 @@ #include #include "part.h" +#include "signal.h" #include "jtag.h" #include "cmd.h" @@ -45,6 +46,7 @@ cmd_set_run( char *params[] ) unsigned int n; int dir; unsigned int data = 0; + signal_t *s; if (cmd_params( params ) < 5 || cmd_params( params ) > 6) return -1; @@ -81,7 +83,12 @@ cmd_set_run( char *params[] ) return -1; } - part_set_signal( chain->parts->parts[n], params[3], dir, data ); + s = part_find_signal( chain->parts->parts[n], params[3] ); + if (!s) { + printf( _("signal '%s' not found\n"), params[3] ); + return 1; + } + part_set_signal( chain->parts->parts[n], s, dir, data ); return 1; } diff --git a/jtag/src/part/part.c b/jtag/src/part/part.c index a716eda9..c62505fd 100644 --- a/jtag/src/part/part.c +++ b/jtag/src/part/part.c @@ -132,16 +132,36 @@ part_find_data_register( part_t *p, const char *drname ) return dr; } -void part_set_instruction( part_t *p, const char *iname ) +signal_t * +part_find_signal( part_t *p, const char *signalname ) +{ + signal_t *s; + + if (!p || !signalname) + return NULL; + + s = p->signals; + while (s) { + if (strcmp( signalname, s->name ) == 0) + break; + s = s->next; + } + + return s; +} + +void +part_set_instruction( part_t *p, const char *iname ) { if (p) p->active_instruction = part_find_instruction( p, iname ); } void -part_set_signal( part_t *p, const char *pname, int out, int val ) +part_set_signal( part_t *p, signal_t *s, int out, int val ) { - signal_t *s; + if (!p || !s) + return; /* search for Boundary Scan Register */ data_register *bsr = part_find_data_register( p, "BSR" ); @@ -150,24 +170,11 @@ part_set_signal( part_t *p, const char *pname, int out, int val ) return; } - /* search signal */ - s = p->signals; - while (s) { - if (strcmp( pname, s->name ) == 0) - break; - s = s->next; - } - - if (!s) { - printf( _("signal %s not found\n"), pname ); - return; - } - - /*setup signal */ + /* setup signal */ if (out) { int control; if (!s->output) { - printf( _("signal %s cannot be set as output\n"), pname ); + printf( _("signal '%s' cannot be set as output\n"), s->name ); return; } bsr->in->data[s->output->bit] = val & 1; @@ -177,7 +184,7 @@ part_set_signal( part_t *p, const char *pname, int out, int val ) bsr->in->data[control] = p->bsbits[s->output->bit]->control_value ^ 1; } else { if (!s->input) { - printf( _("signal %s cannot be set as input\n"), pname ); + printf( _("signal '%s' cannot be set as input\n"), s->name ); return; } if (s->output) @@ -186,9 +193,10 @@ part_set_signal( part_t *p, const char *pname, int out, int val ) } int -part_get_signal( part_t *p, const char *pname ) +part_get_signal( part_t *p, signal_t *s ) { - signal_t *s; + if (!p || !s) + return -1; /* search for Boundary Scan Register */ data_register *bsr = part_find_data_register( p, "BSR" ); @@ -197,21 +205,8 @@ part_get_signal( part_t *p, const char *pname ) return -1; } - /* search signal */ - s = p->signals; - while (s) { - if (strcmp( pname, s->name ) == 0) - break; - s = s->next; - } - - if (!s) { - printf( _("signal %s not found\n"), pname ); - return -1; - } - if (!s->input) { - printf( _("signal %s is not input signal\n"), pname ); + printf( _("signal '%s' is not input signal\n"), s->name ); return -1; }