diff --git a/jtag/ChangeLog b/jtag/ChangeLog index bbed2c9e..1507b763 100644 --- a/jtag/ChangeLog +++ b/jtag/ChangeLog @@ -1,3 +1,10 @@ +2009-01-03 Arnim Laeuger + + * configure.ac, src/bus/bscoach.c, src/bus/buses.c, + src/bus/buses.h, src/bus/Makefile.am: + [ 2187115 ] Bus driver for Goepel Boundary Scan Coach + (by Markus Schneider) + 2008-12-23 Arnim Laeuger * src/svf/svf.c: added debug output for svf_compare_tdo() diff --git a/jtag/THANKS b/jtag/THANKS index dc9d2781..0741f158 100644 --- a/jtag/THANKS +++ b/jtag/THANKS @@ -65,14 +65,15 @@ Michel Robitaille Hein Roehrig Marko Rößler Frantisek Rysanek -Marcel Telka -Mike Tesch Benedikt Sauter +Markus Schneider Holger Schurig Robert Sedevici Stanislav Sinyagin Juergen Stuber Hartley Sweeten +Marcel Telka +Mike Tesch Ville Voipio David Vrabel Alan Wallace diff --git a/jtag/configure.ac b/jtag/configure.ac index c3bbcdf5..c72bb146 100644 --- a/jtag/configure.ac +++ b/jtag/configure.ac @@ -411,7 +411,7 @@ AC_DEFUN([CHECK_DRIVER], [ # Enable bus drivers AC_DEFUN([DEF_ENABLE_BUSDRIVERS], [\ -au1500 avr32 bcm1250 bf526_ezkit bf527_ezkit bf533_stamp bf533_ezkit bf537_stamp bf537_ezkit bf538f_ezkit bf548_ezkit bf561_ezkit ejtag ejtag_dma\ +au1500 avr32 bcm1250 bf526_ezkit bf527_ezkit bf533_stamp bf533_ezkit bf537_stamp bf537_ezkit bf538f_ezkit bf548_ezkit bf561_ezkit bscoach ejtag ejtag_dma\ fjmem ixp425 jopcyc h7202 lh7a400 mpc5200 mpc824x ppc405ep ppc440gx_ebc8 prototype pxa2x0 pxa27x \ s3c4510 sa1110 sh7727 sh7750r sh7751r sharc_21065L slsup3 tx4925 zefant_xs3]) AC_ARG_ENABLE(bus, @@ -441,6 +441,7 @@ CHECK_DRIVER([$busdrivers], [enabled_bus_drivers], [bf537_ezkit], [ENABLE_BUS_ CHECK_DRIVER([$busdrivers], [enabled_bus_drivers], [bf538f_ezkit], [ENABLE_BUS_BF538F_EZKIT]) CHECK_DRIVER([$busdrivers], [enabled_bus_drivers], [bf548_ezkit], [ENABLE_BUS_BF548_EZKIT]) CHECK_DRIVER([$busdrivers], [enabled_bus_drivers], [bf561_ezkit], [ENABLE_BUS_BF561_EZKIT]) +CHECK_DRIVER([$busdrivers], [enabled_bus_drivers], [bscoach], [ENABLE_BUS_BSCOACH]) CHECK_DRIVER([$busdrivers], [enabled_bus_drivers], [ejtag], [ENABLE_BUS_EJTAG]) CHECK_DRIVER([$busdrivers], [enabled_bus_drivers], [ejtag_dma], [ENABLE_BUS_EJTAG_DMA]) CHECK_DRIVER([$busdrivers], [enabled_bus_drivers], [fjmem], [ENABLE_BUS_FJMEM]) diff --git a/jtag/src/bus/Makefile.am b/jtag/src/bus/Makefile.am index 9f7e8415..7c3c8881 100644 --- a/jtag/src/bus/Makefile.am +++ b/jtag/src/bus/Makefile.am @@ -82,6 +82,10 @@ if ENABLE_BUS_BF561_EZKIT libbus_a_SOURCES += bf561_ezkit.c endif +if ENABLE_BUS_BSCOACH +libbus_a_SOURCES += bscoach.c +endif + if ENABLE_BUS_EJTAG libbus_a_SOURCES += ejtag.c endif diff --git a/jtag/src/bus/bscoach.c b/jtag/src/bus/bscoach.c new file mode 100644 index 00000000..1517f017 --- /dev/null +++ b/jtag/src/bus/bscoach.c @@ -0,0 +1,386 @@ +/* + * $Id$ + * + * Busdriver for flashaccess on the Goepel "Boundary Scan Coach" training board + * www.goepel.com + * The flash has 1Mbit but only 15 address lines are connected. + * So only 4Kbit can be accessed. + * Erfurt, Oct. 10th M. Schneider www.masla.de + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + */ + +#include "sysdep.h" + +#include +#include +#include + +#include "part.h" +#include "bus.h" +#include "chain.h" +#include "bssignal.h" +#include "jtag.h" +#include "buses.h" +#include "generic_bus.h" + + +typedef struct{ + uint32_t last_adr; + signal_t *adr[15]; + signal_t *d[8]; + signal_t *deca; + signal_t *decb; + signal_t *decc; + signal_t *we_f; + signal_t *oe_f; +} bus_params_t; + +#define LAST_ADR ((bus_params_t *) bus->params)->last_adr +#define ADR ((bus_params_t *) bus->params)->adr +#define D ((bus_params_t *) bus->params)->d +#define DECA ((bus_params_t *) bus->params)->deca +#define DECB ((bus_params_t *) bus->params)->decb +#define DECC ((bus_params_t *) bus->params)->decc +#define WE_F ((bus_params_t *) bus->params)->we_f +#define OE_F ((bus_params_t *) bus->params)->oe_f + + +/** + * bus->driver->(*new_bus) + * + */ +static bus_t * +flashbscoach_bus_new( chain_t *chain, const bus_driver_t *driver, char *cmd_params[] ) +{ + bus_t *bus; + part_t *part; + int failed = 0; + + bus = calloc( 1, sizeof (bus_t) ); + if (!bus) + return NULL; + + bus->driver = driver; + bus->params = calloc( 1, sizeof (bus_params_t) ); + if (!bus->params) { + free( bus );\ + return NULL; + } + + CHAIN = chain; + PART = part = chain->parts->parts[chain->active_part]; + //OE & WE + failed |= generic_bus_attach_sig( part, &(OE_F), "PB02_00" ); + failed |= generic_bus_attach_sig( part, &(WE_F), "PB02_08" ); + //Decoder + failed |= generic_bus_attach_sig( part, &(DECA), "PB02_04" ); + failed |= generic_bus_attach_sig( part, &(DECB), "PB00_12" ); + failed |= generic_bus_attach_sig( part, &(DECC), "PB02_07" ); + //Adressbus + failed |= generic_bus_attach_sig( part, &(ADR[0]), "PB01_09" ); + failed |= generic_bus_attach_sig( part, &(ADR[1]), "PB01_06" ); + failed |= generic_bus_attach_sig( part, &(ADR[2]), "PB01_10" ); + failed |= generic_bus_attach_sig( part, &(ADR[3]), "PB01_11" ); + failed |= generic_bus_attach_sig( part, &(ADR[4]), "PB01_12" ); + failed |= generic_bus_attach_sig( part, &(ADR[5]), "PB01_13" ); + failed |= generic_bus_attach_sig( part, &(ADR[6]), "PB01_15" ); + failed |= generic_bus_attach_sig( part, &(ADR[7]), "PB01_14" ); + failed |= generic_bus_attach_sig( part, &(ADR[8]), "PB01_16" ); + failed |= generic_bus_attach_sig( part, &(ADR[9]), "PB00_01" ); + failed |= generic_bus_attach_sig( part, &(ADR[10]), "PB00_04" ); + failed |= generic_bus_attach_sig( part, &(ADR[11]), "PB00_05" ); + failed |= generic_bus_attach_sig( part, &(ADR[12]), "PB00_00" ); + failed |= generic_bus_attach_sig( part, &(ADR[13]), "PB00_07" ); + failed |= generic_bus_attach_sig( part, &(ADR[14]), "PB00_02" ); + //Datenbus + failed |= generic_bus_attach_sig( part, &(D[0]), "PB00_10" ); + failed |= generic_bus_attach_sig( part, &(D[1]), "PB00_06" ); + failed |= generic_bus_attach_sig( part, &(D[2]), "PB00_13" ); + failed |= generic_bus_attach_sig( part, &(D[3]), "PB00_09" ); + failed |= generic_bus_attach_sig( part, &(D[4]), "PB00_14" ); + failed |= generic_bus_attach_sig( part, &(D[5]), "PB00_16" ); + failed |= generic_bus_attach_sig( part, &(D[6]), "PB02_01" ); + failed |= generic_bus_attach_sig( part, &(D[7]), "PB00_11" ); + + + + + if (failed) { + free( bus->params ); + free ( bus ); + return NULL; + } + + + return bus; +} + +/** + * bus->driver->(*printinfo) + * + */ +static void +flashbscoach_bus_printinfo( bus_t *bus ) +{ + int i; + + for (i = 0; i < CHAIN->parts->len; i++) + if (PART == CHAIN->parts->parts[i]) + break; + printf( _("Goepel electronic Boundary Scan Coach compatible bus driver via BSR (JTAG part No. %d)\n"), i ); +} + + + + + + + +/** + * bus->driver->(*init) + * + */ +static int +flashbscoach_bus_init( bus_t *bus ) +{ + part_t *p = PART; + chain_t *chain = CHAIN; + int i=0; + + + + part_set_instruction( p, "SAMPLE/PRELOAD" ); + chain_shift_instructions( chain ); + + part_set_signal( p, DECA, 1, 1 ); + part_set_signal( p, DECB, 1, 1 ); + part_set_signal( p, DECC, 1, 1 ); + part_set_signal( p, OE_F, 1, 1 ); //OE_F low aktiv + part_set_signal( p, WE_F, 1, 1 ); //WE_F low aktiv + + for(i = 0; i < 15; i++) + part_set_signal( p, ADR[i], 1, 1); + + part_set_signal( p, D[0], 1, 0 ); + part_set_signal( p, D[1], 1, 0 ); + part_set_signal( p, D[2], 1, 0 ); + part_set_signal( p, D[3], 1, 0 ); + part_set_signal( p, D[4], 1, 0 ); + part_set_signal( p, D[5], 1, 0 ); + part_set_signal( p, D[6], 1, 0 ); + part_set_signal( p, D[7], 1, 0 ); + + chain_shift_data_registers( chain, 0 ); + + INITIALIZED = 1; + + return 0; +} + + +/** + * bus->driver->(*area) + * + */ +static int +flashbscoach_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) +{ + area->description = NULL; + area->start = UINT32_C(0x00000000); + area->length = UINT64_C(0x00100000000); + area->width = 8; +// area->width = part_get_signal( PART, part_find_signal( PART, "ROMSIZ" ) ) ? 16 : 32; + + + return 0; + + +} +static void +setup_data( bus_t *bus, uint32_t d ) +{ + int i; + part_t *p = PART; + bus_area_t area; + + flashbscoach_bus_area( bus, 0, &area); + + + + for (i = 0; i < area.width; i++) + part_set_signal( p, D[i], 1, (d >> i) & 1 ); +} + +static void +set_data_in( bus_t *bus ) +{ + + part_t *p = PART; + bus_area_t area; + + flashbscoach_bus_area( bus, 0, &area); + + part_set_signal( p, D[0], 0, 0 ); + part_set_signal( p, D[1], 0, 0 ); + part_set_signal( p, D[2], 0, 0 ); + part_set_signal( p, D[3], 0, 0 ); + part_set_signal( p, D[4], 0, 0 ); + part_set_signal( p, D[5], 0, 0 ); + part_set_signal( p, D[6], 0, 0 ); + part_set_signal( p, D[7], 0, 0 ); +} +static void +setup_address( bus_t *bus, uint32_t a) +{ + int i; + part_t *p = PART; + + for( i = 0; i < 15; i++) + part_set_signal( p, ADR[i], 1, (a >>i) & 1); +} +static uint32_t +get_data_out( bus_t *bus ) +{ + int i; + part_t *p = PART; + bus_area_t area; + uint32_t d = 0; + + flashbscoach_bus_area( bus, 0, &area); + + for( i = 0; i < area.width; i++ ) + d |= (uint32_t)(part_get_signal( p, D[i] ) << i); + + return d; +} +/** + * bus->driver->(*read_start) + * + */ +static void +flashbscoach_bus_read_start( bus_t *bus, uint32_t adr ) +{ + part_t *p = PART; + chain_t *chain = CHAIN; + + LAST_ADR = adr; + + part_set_signal( p, DECA, 1, 0 ); + part_set_signal( p, DECB, 1, 1 ); + part_set_signal( p, DECC, 1, 1 ); + part_set_signal( p, OE_F, 1, 0 ); //OE_F low aktiv + part_set_signal( p, WE_F, 1, 1); //WE_F low aktiv + + setup_address( bus, adr); + set_data_in( bus ); + + chain_shift_data_registers( chain, 0 ); + +} + +/** + * bus->driver->(*read_next) + * + */ +static uint32_t +flashbscoach_bus_read_next( bus_t *bus, uint32_t adr ) +{ +// part_t *p = PART; + chain_t *chain = CHAIN; + + + setup_address( bus, adr ); + chain_shift_data_registers( chain, 1 ); + +// d = get_data_out( bus ); +// LAST_ADR = adr; + return get_data_out( bus ); + +} + +/** + * bus->driver->(*read_end) + * + */ +static uint32_t +flashbscoach_bus_read_end( bus_t *bus ) +{ + part_t *p = PART; + chain_t *chain = CHAIN; + + + + part_set_signal( p, DECA, 1, 1 ); + part_set_signal( p, DECB, 1, 1 ); + part_set_signal( p, DECC, 1, 1 ); + part_set_signal( p, OE_F, 1, 1 ); //OE_F low aktiv + part_set_signal( p, WE_F, 1, 1 ); //WE_F low aktiv + + chain_shift_data_registers( chain, 1 ); + + return get_data_out( bus ); + +} + +/** + * bus->driver->(*write) + * + */ +static void +flashbscoach_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) +{ + part_t *p = PART; + chain_t *chain = CHAIN; + part_set_signal( p, DECA, 1, 0 ); + part_set_signal( p, DECB, 1, 1 ); + part_set_signal( p, DECC, 1, 1 ); + part_set_signal( p, OE_F, 1, 1 ); //OE_F low aktiv + part_set_signal( p, WE_F, 1, 1); //WE_F low aktiv + + setup_address( bus, adr ); + setup_data( bus, data ); + + chain_shift_data_registers( chain, 0 ); + + part_set_signal( p, WE_F, 1, 0); + chain_shift_data_registers( chain, 0 ); + + part_set_signal( p, DECA, 1, 1 ); + part_set_signal( p, DECB, 1, 1 ); + part_set_signal( p, DECC, 1, 1 ); + part_set_signal( p, OE_F, 1, 1 ); //OE_F low aktiv + part_set_signal( p, WE_F, 1, 1); //WE_F low aktiv + + chain_shift_data_registers( chain, 0); +} + +const bus_driver_t bscoach_bus = { + "flashbscoach", + N_("Bustreiber für Flashprogrammierung auf Goepel Boundary Scan Coach via BSR"), + flashbscoach_bus_new, + generic_bus_free, + flashbscoach_bus_printinfo, + generic_bus_prepare_extest, + flashbscoach_bus_area, + flashbscoach_bus_read_start, + flashbscoach_bus_read_next, + flashbscoach_bus_read_end, + generic_bus_read, + flashbscoach_bus_write, + flashbscoach_bus_init +}; diff --git a/jtag/src/bus/buses.c b/jtag/src/bus/buses.c index ad82e8d3..a249eeee 100644 --- a/jtag/src/bus/buses.c +++ b/jtag/src/bus/buses.c @@ -66,6 +66,9 @@ const bus_driver_t *bus_drivers[] = { #ifdef ENABLE_BUS_BF561_EZKIT &bf561_ezkit_bus, #endif +#ifdef ENABLE_BUS_BSCOACH + &bscoach_bus, +#endif #ifdef ENABLE_BUS_EJTAG &ejtag_bus, &ejtag_dma_bus, diff --git a/jtag/src/bus/buses.h b/jtag/src/bus/buses.h index 9ba35592..33f97c8b 100644 --- a/jtag/src/bus/buses.h +++ b/jtag/src/bus/buses.h @@ -37,6 +37,7 @@ extern const bus_driver_t bf537_ezkit_bus; extern const bus_driver_t bf538f_ezkit_bus; extern const bus_driver_t bf548_ezkit_bus; extern const bus_driver_t bf561_ezkit_bus; +extern const bus_driver_t bscoach_bus; extern const bus_driver_t ejtag_bus; extern const bus_driver_t fjmem_bus; extern const bus_driver_t h7202_bus;