From 013604ba69a054518e7b58386b2c54f47b6dbd4d Mon Sep 17 00:00:00 2001 From: Kolja Waschk Date: Thu, 24 Jan 2008 20:58:58 +0000 Subject: [PATCH] Added support for Amontec JTAGkey (submitted by Laurent Gauch - Amontec) git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@945 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- jtag/ChangeLog | 5 +++ jtag/src/tap/cable.c | 2 + jtag/src/tap/cable/ft2232.c | 78 +++++++++++++++++++++++++++++++++++++ jtag/src/tap/parport/ftdi.c | 1 + 4 files changed, 86 insertions(+) diff --git a/jtag/ChangeLog b/jtag/ChangeLog index d67d5b9b..e84df27f 100644 --- a/jtag/ChangeLog +++ b/jtag/ChangeLog @@ -1,3 +1,8 @@ +2008-01-24 Kolja Waschk + + * tap/cable/ft2232.c, tap/parport/ftdi.c, tap/cable.c: added support + for Amontec JTAGkey USB cable (submitted by Laurent Gauch - Amontec) + 2008-01-22 Arnim Laeuger * src/bsdl/bsdl_flex.l, src/bsdl/bsdl_bison.y, diff --git a/jtag/src/tap/cable.c b/jtag/src/tap/cable.c index e0afeee2..22274e81 100644 --- a/jtag/src/tap/cable.c +++ b/jtag/src/tap/cable.c @@ -40,6 +40,7 @@ extern cable_driver_t byteblaster_cable_driver; #ifdef HAVE_LIBFTDI extern cable_driver_t usbblaster_cable_driver; extern cable_driver_t ft2232_cable_driver; +extern cable_driver_t ft2232_jtagkey_cable_driver; extern cable_driver_t ft2232_armusbocd_cable_driver; #endif extern cable_driver_t dlc5_cable_driver; @@ -70,6 +71,7 @@ cable_driver_t *cable_drivers[] = { #ifdef HAVE_LIBFTDI &usbblaster_cable_driver, &ft2232_cable_driver, + &ft2232_jtagkey_cable_driver, &ft2232_armusbocd_cable_driver, #endif &dlc5_cable_driver, diff --git a/jtag/src/tap/cable/ft2232.c b/jtag/src/tap/cable/ft2232.c index c6b4d72b..5fd7f380 100644 --- a/jtag/src/tap/cable/ft2232.c +++ b/jtag/src/tap/cable/ft2232.c @@ -20,6 +20,7 @@ * 02111-1307, USA. * * Written by Arnim Laeuger, 2007. + * Support for JTAGkey submitted by Laurent Gauch, 2008. * */ @@ -82,11 +83,13 @@ #define BIT_TDI 1 #define BIT_TDO 2 #define BIT_TMS 3 +#define BIT_JTAGKEY_nOE 4 #define BIT_ARMUSBOCD_nOE 4 #define BITMASK_TDO (1 << BIT_TDO) #define BITMASK_TDI (1 << BIT_TDI) #define BITMASK_TCK (1 << BIT_TCK) #define BITMASK_TMS (1 << BIT_TMS) +#define BITMASK_JTAGKEY_nOE (1 << BIT_JTAGKEY_nOE) #define BITMASK_ARMUSBOCD_nOE (1 << BIT_ARMUSBOCD_nOE) @@ -168,6 +171,41 @@ ft2232_generic_init( cable_t *cable ) return 0; } +static int +ft2232_jtagkey_init( cable_t *cable ) +{ + parport_t *p = cable->port; + + if (parport_open( p )) + return -1; + + /* set loopback off */ + parport_set_data( p, LOOPBACK_END ); + parport_set_control( p, 1 ); // flush + parport_set_control( p, 0 ); // noflush + + /* Set Data Bits Low Byte + TCK = 0, TMS = 1, TDI = 0, nOE = 0 */ + parport_set_data( p, SET_BITS_LOW ); + parport_set_data( p, BITMASK_TMS ); + parport_set_data( p, BITMASK_TCK | BITMASK_TDI | BITMASK_TMS | BITMASK_JTAGKEY_nOE ); + parport_set_control( p, 1 ); // flush + parport_set_control( p, 0 ); // noflush + + /* Set TCK/SK Divisor */ + parport_set_data( p, TCK_DIVISOR ); + parport_set_data( p, 0 ); + parport_set_data( p, 0 ); + parport_set_control( p, 1 ); // flush + parport_set_control( p, 0 ); // noflush + + mpsse_frequency = FT2232_MAX_TCK_FREQ; + + last_tdo_valid = 0; + + return 0; +} + static int ft2232_armusbocd_init( cable_t *cable ) { @@ -219,6 +257,29 @@ ft2232_generic_done( cable_t *cable ) parport_close( p ); } +static void +ft2232_jtagkey_done( cable_t *cable ) +{ + parport_t *p = cable->port; + + /* Set Data Bits Low Byte + disable output drivers */ + parport_set_data( p, SET_BITS_LOW ); + parport_set_data( p, BITMASK_JTAGKEY_nOE ); + parport_set_data( p, BITMASK_JTAGKEY_nOE ); + parport_set_control( p, 1 ); // flush + parport_set_control( p, 0 ); // noflush + /* Set Data Bits Low Byte + set all to input */ + parport_set_data( p, SET_BITS_LOW ); + parport_set_data( p, BITMASK_JTAGKEY_nOE ); + parport_set_data( p, 0 ); + parport_set_control( p, 1 ); // flush + parport_set_control( p, 0 ); // noflush + + parport_close( p ); +} + static void ft2232_armusbocd_done( cable_t *cable ) { @@ -510,6 +571,23 @@ cable_driver_t ft2232_armusbocd_cable_driver = { ft2232_usbcable_help }; +cable_driver_t ft2232_jtagkey_cable_driver = { + "JTAGkey", + N_("Amontec JTAGkey (FT2232) Cable"), + generic_connect, + generic_disconnect, + generic_cable_free, + ft2232_jtagkey_init, + ft2232_jtagkey_done, + ft2232_clock, + ft2232_get_tdo, + ft2232_transfer, + ft2232_set_trst, + generic_get_trst, + ft2232_usbcable_help +}; + + /* Local Variables: diff --git a/jtag/src/tap/parport/ftdi.c b/jtag/src/tap/parport/ftdi.c index 386f263c..1579823c 100644 --- a/jtag/src/tap/parport/ftdi.c +++ b/jtag/src/tap/parport/ftdi.c @@ -224,6 +224,7 @@ ftdi_generic_open( parport_t *parport ) if(r<0) r = ftdi_usb_open_desc(fc, 0x09FB, 0x6002, NULL, p->serial); /* Cubic Cyclonium */ if(r<0) r = ftdi_usb_open_desc(fc, 0x09FB, 0x6003, NULL, p->serial); /* NIOS II Evaluation board */ if(r<0) r = ftdi_usb_open_desc(fc, 0x16C0, 0x06AD, NULL, p->serial); /* http://www.ixo.de/info/usb_jtag/ */ + if(r<0) r = ftdi_usb_open_desc(fc, 0x0403, 0xCFF8, NULL, p->serial); /* Amontec JTAGkey http://www.amontec.com/jtagkey.shtml */ if(r<0) r = ftdi_usb_open_desc(fc, 0x15BA, 0x0003, NULL, p->serial); /* Olimex ARM-USB-OCD */ };