From 4a9f18bcf406a4e904bd7718564c61d61decfb94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnim=20L=C3=A4uger?= Date: Wed, 3 Dec 2008 19:46:55 +0000 Subject: [PATCH] [ 2382324 ] Patch to add support for TinCanTools Flyswatter JTAG cable (Mark Norman) git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1393 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- jtag/ChangeLog | 5 ++ jtag/doc/UrJTAG.txt | 1 + jtag/src/tap/cable.c | 2 + jtag/src/tap/cable/ft2232.c | 115 ++++++++++++++++++++++++++- jtag/src/tap/cable/generic_usbconn.c | 4 + 5 files changed, 126 insertions(+), 1 deletion(-) diff --git a/jtag/ChangeLog b/jtag/ChangeLog index e97082a2..a5183f4c 100644 --- a/jtag/ChangeLog +++ b/jtag/ChangeLog @@ -1,5 +1,10 @@ 2008-12-03 Arnim Laeuger + * src/tap/cable/ft2232.c, src/tap/cable/generic_usbconn.c, + src/tap/cable.c, doc/UrJTAG.txt: + [ 2382324 ] Patch to add support for TinCanTools Flyswatter JTAG cable + (Mark Norman) + * include/flash.h, src/flash/amd_flash.c, src/flash/amd.c, src/flash/intel.c, src/flash/flash.c, configure.ac: restructure multi-byte flash programming support diff --git a/jtag/doc/UrJTAG.txt b/jtag/doc/UrJTAG.txt index 00668fd7..e33fa62a 100644 --- a/jtag/doc/UrJTAG.txt +++ b/jtag/doc/UrJTAG.txt @@ -219,6 +219,7 @@ FT2232-based USB cables: * Amontec JTAGkey * Amontec JTAGkey-Tiny (supported as cable "JTAGkey") + * TinCanTools Flyswatter * Olimex ARM-USB-JTAG * Olimex ARM-USB-TINY * OOCDLink-s (experimental) http://www.joernonline.de/dw/doku.php?id=projects:oocdlink:2_oocdlinks diff --git a/jtag/src/tap/cable.c b/jtag/src/tap/cable.c index a1cd863c..0dd590c6 100644 --- a/jtag/src/tap/cable.c +++ b/jtag/src/tap/cable.c @@ -50,6 +50,7 @@ extern cable_driver_t ft2232_oocdlinks_cable_driver; extern cable_driver_t ft2232_signalyzer_cable_driver; extern cable_driver_t ft2232_turtelizer2_cable_driver; extern cable_driver_t ft2232_usbtojtagif_cable_driver; +extern cable_driver_t ft2232_flyswatter_cable_driver; extern cable_driver_t dlc5_cable_driver; extern cable_driver_t ea253_cable_driver; extern cable_driver_t ei012_cable_driver; @@ -89,6 +90,7 @@ cable_driver_t *cable_drivers[] = { &ft2232_signalyzer_cable_driver, &ft2232_turtelizer2_cable_driver, &ft2232_usbtojtagif_cable_driver, + &ft2232_flyswatter_cable_driver, #endif #ifdef ENABLE_CABLE_DLC5 diff --git a/jtag/src/tap/cable/ft2232.c b/jtag/src/tap/cable/ft2232.c index a223a7c3..cae8e4f9 100644 --- a/jtag/src/tap/cable/ft2232.c +++ b/jtag/src/tap/cable/ft2232.c @@ -151,7 +151,17 @@ #define BIT_SIGNALYZER_nSRST 5 #define BITMASK_SIGNALYZER_nTRST (1 << BIT_SIGNALYZER_nTRST) #define BITMASK_SIGNALYZER_nSRST (1 << BIT_SIGNALYZER_nSRST) - +/* bit and bitmask definitions for TinCanTools Flyswatter board*/ +#define BIT_FLYSWATTER_nLED2 3 +#define BIT_FLYSWATTER_nTRST 4 +#define BIT_FLYSWATTER_nSRST 5 +#define BIT_FLYSWATTER_nOE1 6 +#define BIT_FLYSWATTER_nOE2 7 +#define BITMASK_FLYSWATTER_nLED2 (1 << BIT_FLYSWATTER_nLED2) +#define BITMASK_FLYSWATTER_nTRST (1 << BIT_FLYSWATTER_nTRST) +#define BITMASK_FLYSWATTER_nSRST (1 << BIT_FLYSWATTER_nSRST) +#define BITMASK_FLYSWATTER_nOE1 (1 << BIT_FLYSWATTER_nOE1) +#define BITMASK_FLYSWATTER_nOE2 (1 << BIT_FLYSWATTER_nOE2) typedef struct { @@ -557,6 +567,44 @@ ft2232_signalyzer_init( cable_t *cable ) } +static int +ft2232_flyswatter_init( cable_t *cable ) +{ + params_t *params = (params_t *)cable->params; + cx_cmd_root_t *cmd_root = &(params->cmd_root); + + if (usbconn_open( cable->link.usb )) return -1; + + /* static low byte value and direction: + nTRST = 1, set nOE1 and nOE2 to '0' -> activate output enables */ + params->low_byte_value = BITMASK_FLYSWATTER_nTRST; + params->low_byte_dir = BITMASK_FLYSWATTER_nOE1 | BITMASK_FLYSWATTER_nOE2 | + BITMASK_FLYSWATTER_nTRST | BITMASK_FLYSWATTER_nSRST; + + /* Set Data Bits Low Byte + TCK = 0, TMS = 1, TDI = 0 */ + cx_cmd_queue( cmd_root, 0 ); + cx_cmd_push( cmd_root, SET_BITS_LOW ); + cx_cmd_push( cmd_root, params->low_byte_value | BITMASK_TMS ); + cx_cmd_push( cmd_root, params->low_byte_dir | BITMASK_TCK | BITMASK_TDI | BITMASK_TMS ); + + /* Set Data Bits High Byte */ + /* Turn LED2 on */ + params->high_byte_value_trst_active = 0; + params->high_byte_value_trst_inactive = 0; + params->high_byte_dir = BITMASK_FLYSWATTER_nLED2; + cx_cmd_push( cmd_root, SET_BITS_HIGH ); + cx_cmd_push( cmd_root, params->high_byte_value_trst_inactive ); + cx_cmd_push( cmd_root, params->high_byte_dir ); + + ft2232_set_frequency( cable, FT2232_MAX_TCK_FREQ ); + + params->last_tdo_valid = 0; + + return 0; +} + + static void ft2232_generic_done( cable_t *cable ) { @@ -841,6 +889,36 @@ ft2232_signalyzer_done( cable_t *cable ) } +static void +ft2232_flyswatter_done( cable_t *cable ) +{ + params_t *params = (params_t *)cable->params; + cx_cmd_root_t *cmd_root = &(params->cmd_root); + + /* Set Data Bits Low Byte + disable output drivers */ + cx_cmd_queue( cmd_root, 0 ); + cx_cmd_push( cmd_root, SET_BITS_LOW ); + cx_cmd_push( cmd_root, BITMASK_FLYSWATTER_nOE1 | BITMASK_FLYSWATTER_nOE2 ); + cx_cmd_push( cmd_root, BITMASK_FLYSWATTER_nOE1 | BITMASK_FLYSWATTER_nOE2 ); + + /* Set Data Bits Low Byte + set all to input */ + cx_cmd_push( cmd_root, SET_BITS_LOW ); + cx_cmd_push( cmd_root, BITMASK_FLYSWATTER_nOE1 | BITMASK_FLYSWATTER_nOE2 ); + cx_cmd_push( cmd_root, 0 ); + + /* Set Data Bits High Byte + set all to input */ + cx_cmd_push( cmd_root, SET_BITS_HIGH ); + cx_cmd_push( cmd_root, BITMASK_FLYSWATTER_nLED2 ); + cx_cmd_push( cmd_root, 0 ); + cx_xfer( cmd_root, &imm_cmd, cable, COMPLETELY ); + + generic_usbconn_done( cable ); +} + + static void ft2232_clock_schedule( cable_t *cable, int tms, int tdi, int n ) { @@ -1327,6 +1405,7 @@ usbconn_cable_t usbconn_cable_oocdlinks_ftdi; usbconn_cable_t usbconn_cable_turtelizer2_ftdi; usbconn_cable_t usbconn_cable_usbtojtagif_ftdi; usbconn_cable_t usbconn_cable_signalyzer_ftdi; +usbconn_cable_t usbconn_cable_flyswatter_ftdi; static void ft2232_usbcable_help( const char *cablename ) @@ -1352,6 +1431,9 @@ ft2232_usbcable_help( const char *cablename ) if (strcasecmp( conn->name, cablename ) == 0) goto found; conn = &usbconn_cable_signalyzer_ftdi; + if (strcasecmp( conn->name, cablename ) == 0) + goto found; + conn = &usbconn_cable_flyswatter_ftdi; if (strcasecmp( conn->name, cablename ) == 0) goto found; conn = &usbconn_cable_ft2232_ftdi; @@ -1644,6 +1726,37 @@ usbconn_cable_t usbconn_cable_signalyzer_ftd2xx = { 0x0000 /* PID */ }; +cable_driver_t ft2232_flyswatter_cable_driver = { + "Flyswatter", + N_("TinCanTools Flyswatter Cable"), + ft2232_connect, + generic_disconnect, + ft2232_cable_free, + ft2232_flyswatter_init, + ft2232_flyswatter_done, + ft2232_set_frequency, + ft2232_clock, + ft2232_get_tdo, + ft2232_transfer, + ft2232_set_trst, + generic_get_trst, + ft2232_flush, + ft2232_usbcable_help +}; +usbconn_cable_t usbconn_cable_flyswatter_ftdi = { + "Flyswatter", /* cable name */ + NULL, /* string pattern, not used */ + "ftdi-mpsse", /* default usbconn driver */ + 0x0403, /* VID */ + 0x6010 /* PID */ +}; +usbconn_cable_t usbconn_cable_flyswatter_ftd2xx = { + "Flyswatter", /* cable name */ + NULL, /* string pattern, not used */ + "ftd2xx-mpsse", /* default usbconn driver */ + 0x0403, /* VID */ + 0x6010 /* PID */ +}; /* Local Variables: diff --git a/jtag/src/tap/cable/generic_usbconn.c b/jtag/src/tap/cable/generic_usbconn.c index 451680e5..6607fff9 100644 --- a/jtag/src/tap/cable/generic_usbconn.c +++ b/jtag/src/tap/cable/generic_usbconn.c @@ -55,6 +55,7 @@ extern usbconn_cable_t usbconn_cable_oocdlinks_ftd2xx; extern usbconn_cable_t usbconn_cable_turtelizer2_ftd2xx; extern usbconn_cable_t usbconn_cable_usbtojtagif_ftd2xx; extern usbconn_cable_t usbconn_cable_signalyzer_ftd2xx; +extern usbconn_cable_t usbconn_cable_flyswatter_ftd2xx; #endif #ifdef ENABLE_LOWLEVEL_FTDI extern usbconn_cable_t usbconn_cable_ft2232_ftdi; @@ -66,6 +67,7 @@ extern usbconn_cable_t usbconn_cable_oocdlinks_ftdi; extern usbconn_cable_t usbconn_cable_turtelizer2_ftdi; extern usbconn_cable_t usbconn_cable_usbtojtagif_ftdi; extern usbconn_cable_t usbconn_cable_signalyzer_ftdi; +extern usbconn_cable_t usbconn_cable_flyswatter_ftdi; #endif #endif #ifdef ENABLE_CABLE_USBBLASTER @@ -103,6 +105,7 @@ usbconn_cable_t *usbconn_cables[] = &usbconn_cable_turtelizer2_ftd2xx, &usbconn_cable_usbtojtagif_ftd2xx, &usbconn_cable_signalyzer_ftd2xx, + &usbconn_cable_flyswatter_ftd2xx, #endif #ifdef ENABLE_LOWLEVEL_FTDI &usbconn_cable_ft2232_ftdi, @@ -114,6 +117,7 @@ usbconn_cable_t *usbconn_cables[] = &usbconn_cable_turtelizer2_ftdi, &usbconn_cable_usbtojtagif_ftdi, &usbconn_cable_signalyzer_ftdi, + &usbconn_cable_flyswatter_ftdi, #endif #endif #ifdef ENABLE_CABLE_USBBLASTER