From 5493cf9a2b82da5f45a93798a4aa9c0b0f2ca321 Mon Sep 17 00:00:00 2001 From: Jie Zhang Date: Fri, 11 Apr 2008 10:02:39 +0000 Subject: [PATCH] [ 1939102 ] Add Analog Devices BFIN-UJTAG cable From Michael Hennerich * src/tap/parport/ftdi.c (ftdi_generic_open): Detect BFIN-UJTAG cable. * src/tap/cable.c (ft2232_bfin_ujtag_cable_driver): Declare. (cable_drivers): Add ft2232_bfin_ujtag_cable_driver. * src/tap/cable/ft2232.c (BIT_BFIN_UJTAG_nTRST, BIT_BFIN_UJTAG_nLED, BITMASK_BFIN_UJTAG_nTRST, BITMASK_BFIN_UJTAG_nLED): Define. (ft2232_bfin_ujtag_init): New. (ft2232_bfin_ujtag_done): New. (ft2232_bfin_ujtag_cable_driver): Define. git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1165 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- jtag/ChangeLog | 14 ++++++ jtag/src/tap/cable.c | 2 + jtag/src/tap/cable/ft2232.c | 88 +++++++++++++++++++++++++++++++++++++ jtag/src/tap/parport/ftdi.c | 1 + 4 files changed, 105 insertions(+) diff --git a/jtag/ChangeLog b/jtag/ChangeLog index 593debc5..8d9ed5b3 100644 --- a/jtag/ChangeLog +++ b/jtag/ChangeLog @@ -1,3 +1,17 @@ +2008-04-11 Jie Zhang + + From Michael Hennerich + * src/tap/parport/ftdi.c (ftdi_generic_open): Detect + BFIN-UJTAG cable. + * src/tap/cable.c (ft2232_bfin_ujtag_cable_driver): Declare. + (cable_drivers): Add ft2232_bfin_ujtag_cable_driver. + * src/tap/cable/ft2232.c (BIT_BFIN_UJTAG_nTRST, + BIT_BFIN_UJTAG_nLED, BITMASK_BFIN_UJTAG_nTRST, + BITMASK_BFIN_UJTAG_nLED): Define. + (ft2232_bfin_ujtag_init): New. + (ft2232_bfin_ujtag_done): New. + (ft2232_bfin_ujtag_cable_driver): Define. + 2008-04-10 Jie Zhang * src/flash/flash.c (flashmem): Show the address when verifying. diff --git a/jtag/src/tap/cable.c b/jtag/src/tap/cable.c index 366b22ac..2b89dc93 100644 --- a/jtag/src/tap/cable.c +++ b/jtag/src/tap/cable.c @@ -45,6 +45,7 @@ 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; +extern cable_driver_t ft2232_bfin_ujtag_cable_driver; extern cable_driver_t ft2232_oocdlinks_cable_driver; extern cable_driver_t ft2232_signalyzer_cable_driver; extern cable_driver_t ft2232_turtelizer2_cable_driver; @@ -82,6 +83,7 @@ cable_driver_t *cable_drivers[] = { &ft2232_cable_driver, &ft2232_jtagkey_cable_driver, &ft2232_armusbocd_cable_driver, + &ft2232_bfin_ujtag_cable_driver, &ft2232_oocdlinks_cable_driver, &ft2232_signalyzer_cable_driver, &ft2232_turtelizer2_cable_driver, diff --git a/jtag/src/tap/cable/ft2232.c b/jtag/src/tap/cable/ft2232.c index e8559a25..ed0e382f 100644 --- a/jtag/src/tap/cable/ft2232.c +++ b/jtag/src/tap/cable/ft2232.c @@ -107,6 +107,11 @@ #define BITMASK_ARMUSBOCD_nTSRST (1 << BIT_ARMUSBOCD_nTRST) #define BITMASK_ARMUSBOCD_nTRST_nOE (1 << BIT_ARMUSBOCD_nTRST_nOE) #define BITMASK_ARMUSBOCD_RED_LED (1 << BIT_ARMUSBOCD_RED_LED) +/* bit and bitmask definitions for BFIN-UJTAG */ +#define BIT_BFIN_UJTAG_nTRST 1 +#define BIT_BFIN_UJTAG_nLED 3 +#define BITMASK_BFIN_UJTAG_nTRST (1 << BIT_BFIN_UJTAG_nTRST) +#define BITMASK_BFIN_UJTAG_nLED (1 << BIT_BFIN_UJTAG_nLED) /* bit and bitmask definitions for OOCDLink-s */ #define BIT_OOCDLINKS_nTRST_nOE 0 #define BIT_OOCDLINKS_nTRST 1 @@ -460,6 +465,44 @@ ft2232_armusbocd_init( cable_t *cable ) } +static int +ft2232_bfin_ujtag_init( cable_t *cable ) +{ + parport_t *p = cable->link.port; + params_t *params = (params_t *)cable->params; + + if (parport_open( p )) + return -1; + + /* safe default values */ + params->low_byte_value = 0; + params->low_byte_dir = 0; + + /* Set Data Bits Low Byte + TCK = 0, TMS = 1, TDI = 0 */ + push_to_send( params, SET_BITS_LOW ); + push_to_send( params, params->low_byte_value | BITMASK_TMS ); + push_to_send( params, params->low_byte_dir | BITMASK_TCK | BITMASK_TDI | BITMASK_TMS ); + + /* Set Data Bits High Byte */ + params->high_byte_value_trst_active = BITMASK_BFIN_UJTAG_nLED; + params->high_byte_value_trst_inactive = BITMASK_BFIN_UJTAG_nTRST; + params->high_byte_dir = BITMASK_BFIN_UJTAG_nTRST | BITMASK_BFIN_UJTAG_nLED; + push_to_send( params, SET_BITS_HIGH ); + push_to_send( params, params->high_byte_value_trst_inactive ); + push_to_send( params, 0 ); + push_to_send( params, SET_BITS_HIGH ); + push_to_send( params, params->high_byte_value_trst_inactive ); + push_to_send( params, params->high_byte_dir ); + + ft2232_set_frequency( cable, FT2232_MAX_TCK_FREQ ); + + params->last_tdo_valid = 0; + + return 0; +} + + static int ft2232_oocdlinks_init( cable_t *cable ) { @@ -721,6 +764,33 @@ ft2232_armusbocd_done( cable_t *cable ) parport_close( p ); } +static void +ft2232_bfin_ujtag_done( cable_t *cable ) +{ + parport_t *p = cable->link.port; + params_t *params = (params_t *)cable->params; + + /* Set Data Bits Low Byte + disable output drivers */ + push_to_send( params, SET_BITS_LOW ); + push_to_send( params, 0 ); + push_to_send( params, 0 ); + + /* Set Data Bits High Byte + disable output drivers */ + push_to_send( params, SET_BITS_HIGH ); + push_to_send( params, BITMASK_BFIN_UJTAG_nTRST); + push_to_send( params, BITMASK_BFIN_UJTAG_nTRST | BITMASK_BFIN_UJTAG_nLED); + + /* Set Data Bits High Byte + set all to input */ + push_to_send( params, SET_BITS_HIGH ); + push_to_send( params, BITMASK_BFIN_UJTAG_nTRST); + push_to_send( params, 0 ); + send_and_receive( cable, COMPLETELY ); + + parport_close( p ); +} static void ft2232_oocdlinks_done( cable_t *cable ) @@ -1380,6 +1450,24 @@ cable_driver_t ft2232_armusbocd_cable_driver = { ft2232_usbcable_help }; +cable_driver_t ft2232_bfin_ujtag_cable_driver = { + "BFIN-UJTAG", + N_("Analog Devices BFIN-UJTAG (FT2232) Cable (EXPERIMENTAL)"), + ft2232_connect, + generic_disconnect, + ft2232_cable_free, + ft2232_bfin_ujtag_init, + ft2232_bfin_ujtag_done, + ft2232_set_frequency, + ft2232_clock, + ft2232_get_tdo, + ft2232_transfer, + ft2232_set_trst, + generic_get_trst, + ft2232_flush, + ft2232_usbcable_help +}; + cable_driver_t ft2232_jtagkey_cable_driver = { "JTAGkey", N_("Amontec JTAGkey (FT2232) Cable"), diff --git a/jtag/src/tap/parport/ftdi.c b/jtag/src/tap/parport/ftdi.c index 295c3338..fe17aa09 100644 --- a/jtag/src/tap/parport/ftdi.c +++ b/jtag/src/tap/parport/ftdi.c @@ -229,6 +229,7 @@ ftdi_generic_open( parport_t *parport ) 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 */ if(r<0) r = ftdi_usb_open_desc(fc, 0x0403, 0xBDC8, NULL, p->serial); /* Turtelizer 2 */ + if(r<0) r = ftdi_usb_open_desc(fc, 0x0456, 0xF000, NULL, p->serial); /* Analog Devices BFIN-UJTAG */ }; if(r<0)