diff --git a/jtag/ChangeLog b/jtag/ChangeLog index 80836a5a..3e7d0591 100644 --- a/jtag/ChangeLog +++ b/jtag/ChangeLog @@ -1,3 +1,11 @@ +2003-01-08 Marcel Telka + + * include/cable.h: Added cable driver for Xilinx DLC5 JTAG Parallel Cable III. + * src/help.c (help): Ditto. + * src/jtag.c (main): Ditto. + * src/tap/Makefile.am: Ditto. + * src/tap/cable/dlc5.c: Ditto. + 2003-01-08 Marcel Telka * include/Makefile.am: Removed ctrl.h, added cable.h. @@ -6,8 +14,8 @@ * src/detect.c: Replaced ctrl.h include with cable.h (JTAG cable driver support). * src/discovery.c: Ditto. * src/tap/tap.c: Ditto. - * src/help.c: Added help for new command 'cable'. - * src/jtag.c: Added support for JTAG cable drivers, added new command 'cable'. + * src/help.c (help): Added help for new command 'cable'. + * src/jtag.c (main): Added support for JTAG cable drivers, added new command 'cable'. * src/tap/Makefile.am: Removed ctrl.c, added cable/ea253.c, updated includes. * src/tap/ctrl.c: Removed obsolete file. * src/tap/state.c: Changed default TRST state to 1. diff --git a/jtag/README b/jtag/README index c6764cbe..805dbe89 100644 --- a/jtag/README +++ b/jtag/README @@ -34,9 +34,9 @@ Tested operating systems: Supported hardware ------------------ -JTAG adapters: -- various parallel port JTAG adapters/cables (for complete list see - 'help cable' command) +JTAG adapters/cables (see 'help cable' command for more info): +- Xilinx DLC5 JTAG Parallel Cable III +- ETC EA253 JTAG Cable JTAG-aware parts (chips): - Atmel ATmega128 (partial support) diff --git a/jtag/include/cable.h b/jtag/include/cable.h index f90abd16..fc96674a 100644 --- a/jtag/include/cable.h +++ b/jtag/include/cable.h @@ -42,5 +42,6 @@ extern cable_driver_t *cable; #define tap_set_trst cable->set_trst extern cable_driver_t ea253_cable_driver; +extern cable_driver_t dlc5_cable_driver; #endif /* CABLE_H */ diff --git a/jtag/src/help.c b/jtag/src/help.c index 8be28485..2157dc6c 100644 --- a/jtag/src/help.c +++ b/jtag/src/help.c @@ -71,7 +71,9 @@ help( const char *cmd ) "CABLE cable type\n" "\n" "List of supported cables:\n" - "none, EA253\n" + "none No cable connected\n" + "DLC5 Xilinx DLC5 JTAG Parallel Cable III\n" + "EA253 ETC EA253 JTAG Cable\n" ); else if (strcmp( cmd, "detect" ) == 0) printf( diff --git a/jtag/src/jtag.c b/jtag/src/jtag.c index fbdf5d79..69c0ef75 100644 --- a/jtag/src/jtag.c +++ b/jtag/src/jtag.c @@ -137,12 +137,16 @@ main( void ) if (strcmp( t, "none" ) == 0) { printf( "Changed cable to 'none'\n" ); cable = NULL; + } else if (strcmp( t, "DLC5" ) == 0) { + cable = &dlc5_cable_driver; + + if (!cable->init( port )) + cable = NULL; } else if (strcmp( t, "EA253" ) == 0) { cable = &ea253_cable_driver; - if (!cable->init( port )) { + if (!cable->init( port )) cable = NULL; - } } else { printf( "Unknown cable: %s\n", t ); continue; diff --git a/jtag/src/tap/Makefile.am b/jtag/src/tap/Makefile.am index f53fa2b9..ff96248d 100644 --- a/jtag/src/tap/Makefile.am +++ b/jtag/src/tap/Makefile.am @@ -27,6 +27,7 @@ libtap_a_SOURCES = \ tap.c \ register.c \ state.c \ + cable/dlc5.c \ cable/ea253.c INCLUDES = -I$(top_srcdir)/include $(OPENWINCE_INC) diff --git a/jtag/src/tap/cable/dlc5.c b/jtag/src/tap/cable/dlc5.c new file mode 100644 index 00000000..4b27b25f --- /dev/null +++ b/jtag/src/tap/cable/dlc5.c @@ -0,0 +1,110 @@ +/* + * $Id$ + * + * Xilinx DLC5 JTAG Parallel Cable III Driver + * 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 + * 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. + * + * Written by Marcel Telka , 2002, 2003. + * + * Documentation: + * [1] Xilinx, Inc., "JTAG Programmer Guide", + * http://toolbox.xilinx.com/docsan/3_1i/pdf/docs/jtg/jtg.pdf + * + */ + +#include +#include + +#include "cable.h" +#include "state.h" + +/* see Figure B-1 in [1] */ + +/* + * data D[7:0] (pins 9:2) + */ +#define TDI 0 +#define TCK 1 +#define TMS 2 +#define CTRL 3 +#define PROG 4 + +/* + * 7 - BUSY (pin 11) + * 6 - ACK (pin 10) + * 5 - PE (pin 12) + * 4 - SEL (pin 13) + * 3 - ERROR (pin 15) + */ +#define TDO 4 + +static unsigned int port; + +static int +dlc5_init( unsigned int aport ) +{ + tap_state_init(); + port = aport; + printf( "Initilizing Xilinx DLC5 JTAG Parallel Cable III on parallel port at 0x%x\n", port ); + if (ioperm( port, 2, 1 )) { + printf( "Error: Initialization failed!\n" ); + return 0; + } + + return 1; +} + +static void +dlc5_done( void ) +{ + ioperm( port, 2, 0 ); + + tap_state_done(); +} + +static void +dlc5_clock( int tms, int tdi ) +{ + tms &= 1; + tdi &= 1; + + outb( (1 << PROG) | (0 << TCK) | (tms << TMS) | (tdi << TDI), port ); + outb( (1 << PROG) | (1 << TCK) | (tms << TMS) | (tdi << TDI), port ); + + tap_state_clock( tms ); +} + +static int +dlc5_get_tdo( void ) +{ + outb( (1 << PROG) | (0 << TCK), port ); + return ((inb( port + 1 ) ^ 0x80) >> TDO) & 1; /* BUSY is inverted */ +} + +static void +dlc5_set_trst( int new_trst ) +{ +} + +cable_driver_t dlc5_cable_driver = { + dlc5_init, + dlc5_done, + dlc5_clock, + dlc5_get_tdo, + dlc5_set_trst +};