From 0da6084704dfe6241c7e06651d66623d91ecf4e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnim=20L=C3=A4uger?= Date: Tue, 12 Feb 2008 22:21:45 +0000 Subject: [PATCH] statically set GPIO high byte with product-specific values git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1008 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- jtag/ChangeLog | 6 +++ jtag/src/tap/cable/ft2232.c | 92 ++++++++++++++++++++++++++++++++++--- 2 files changed, 92 insertions(+), 6 deletions(-) diff --git a/jtag/ChangeLog b/jtag/ChangeLog index be0b7227..22d02966 100644 --- a/jtag/ChangeLog +++ b/jtag/ChangeLog @@ -1,3 +1,9 @@ +2008-02-12 Arnim Laeuger + + * src/tap/cable/ft2232.c: statically set GPIO high byte with product-specific values + first step of + [ 1891845 ] Add support for TRST/SRST/LEDs to FT2232 cable driver + 2008-02-11 Arnim Laeuger * src/bsdl/bsdl_bison.y (Store_Text): removed function Make_String() diff --git a/jtag/src/tap/cable/ft2232.c b/jtag/src/tap/cable/ft2232.c index ac25c97b..6905d892 100644 --- a/jtag/src/tap/cable/ft2232.c +++ b/jtag/src/tap/cable/ft2232.c @@ -81,13 +81,30 @@ #define BIT_TDO 2 #define BIT_TMS 3 #define BIT_JTAGKEY_nOE 4 +#define BIT_JTAGKEY_TRST_N_OUT 0 +#define BIT_JTAGKEY_SRST_N_OUT 1 +#define BIT_JTAGKEY_TRST_N_OE_N 2 +#define BIT_JTAGKEY_SRST_N_OE_N 3 #define BIT_ARMUSBOCD_nOE 4 +#define BIT_ARMUSBOCD_nTRST 0 +#define BIT_ARMUSBOCD_nTSRST 1 +#define BIT_ARMUSBOCD_nTRST_nOE 2 +#define BIT_ARMUSBOCD_RED_LED 3 + #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_JTAGKEY_TRST_N_OUT (1 << BIT_JTAGKEY_TRST_N_OUT) +#define BITMASK_JTAGKEY_SRST_N_OUT (1 << BIT_JTAGKEY_SRST_N_OUT) +#define BITMASK_JTAGKEY_TRST_N_OE_N (1 << BIT_JTAGKEY_TRST_N_OE_N) +#define BITMASK_JTAGKEY_SRST_N_OE_N (1 << BIT_JTAGKEY_SRST_N_OE_N) #define BITMASK_ARMUSBOCD_nOE (1 << BIT_ARMUSBOCD_nOE) +#define BITMASK_ARMUSBOCD_nTRST (1 << BIT_ARMUSBOCD_nTRST) +#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) typedef struct { @@ -286,12 +303,16 @@ ft2232_generic_init( cable_t *cable ) 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 ); - send_and_receive( cable ); /* Set TCK/SK Divisor to max frequency */ push_to_send( params, TCK_DIVISOR ); push_to_send( params, 0 ); push_to_send( params, 0 ); + + /* Set Data Bits High Byte */ + push_to_send( params, SET_BITS_HIGH ); + push_to_send( params, 0 ); + push_to_send( params, 0 ); send_and_receive( cable ); params->mpsse_frequency = FT2232_MAX_TCK_FREQ; @@ -324,12 +345,23 @@ ft2232_jtagkey_init( cable_t *cable ) 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 ); - send_and_receive( cable ); /* Set TCK/SK Divisor to max frequency */ push_to_send( params, TCK_DIVISOR ); push_to_send( params, 0 ); push_to_send( params, 0 ); + + /* Set Data Bits High Byte + static low byte value and direction: + TRST_N_OUT = 1 + TRST_N_OE_N = 0 + SRST_N_OUT = 1 + SRST_N_OE_N = 0 */ + push_to_send( params, SET_BITS_HIGH ); + push_to_send( params, BITMASK_JTAGKEY_TRST_N_OUT | + BITMASK_JTAGKEY_SRST_N_OUT ); + push_to_send( params, BITMASK_JTAGKEY_TRST_N_OUT | BITMASK_JTAGKEY_TRST_N_OE_N | + BITMASK_JTAGKEY_SRST_N_OUT | BITMASK_JTAGKEY_SRST_N_OE_N ); send_and_receive( cable ); params->mpsse_frequency = FT2232_MAX_TCK_FREQ; @@ -363,12 +395,23 @@ ft2232_armusbocd_init( cable_t *cable ) 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 ); - send_and_receive( cable ); /* Set TCK/SK Divisor */ push_to_send( params, TCK_DIVISOR ); push_to_send( params, 0 ); push_to_send( params, 0 ); + + /* Set Data Bits High Byte + TRST = 1 + TRST buffer enable = 0 + TSRST = 1 + RED LED on */ + push_to_send( params, SET_BITS_HIGH ); + push_to_send( params, BITMASK_ARMUSBOCD_nTRST | + BITMASK_ARMUSBOCD_RED_LED ); + push_to_send( params, BITMASK_ARMUSBOCD_nTRST | BITMASK_ARMUSBOCD_nTRST_nOE | + BITMASK_ARMUSBOCD_nTSRST | + BITMASK_ARMUSBOCD_RED_LED ); send_and_receive( cable ); params->mpsse_frequency = FT2232_MAX_TCK_FREQ; @@ -390,6 +433,12 @@ ft2232_generic_done( cable_t *cable ) push_to_send( params, SET_BITS_LOW ); push_to_send( params, 0 ); push_to_send( params, 0 ); + + /* Set Data Bits High Byte + set all to input */ + push_to_send( params, SET_BITS_HIGH ); + push_to_send( params, 0 ); + push_to_send( params, 0 ); send_and_receive( cable ); parport_close( p ); @@ -407,12 +456,27 @@ ft2232_jtagkey_done( cable_t *cable ) push_to_send( params, SET_BITS_LOW ); push_to_send( params, BITMASK_JTAGKEY_nOE ); push_to_send( params, BITMASK_JTAGKEY_nOE ); - send_and_receive( cable ); + /* Set Data Bits Low Byte set all to input */ push_to_send( params, SET_BITS_LOW ); push_to_send( params, BITMASK_JTAGKEY_nOE ); 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_JTAGKEY_TRST_N_OUT | BITMASK_JTAGKEY_TRST_N_OE_N | + BITMASK_JTAGKEY_SRST_N_OUT | BITMASK_JTAGKEY_SRST_N_OE_N ); + push_to_send( params, BITMASK_JTAGKEY_TRST_N_OUT | BITMASK_JTAGKEY_TRST_N_OE_N | + BITMASK_JTAGKEY_SRST_N_OUT | BITMASK_JTAGKEY_SRST_N_OE_N ); + + /* Set Data Bits High Byte + set all to input */ + push_to_send( params, SET_BITS_HIGH ); + push_to_send( params, BITMASK_JTAGKEY_TRST_N_OUT | BITMASK_JTAGKEY_TRST_N_OE_N | + BITMASK_JTAGKEY_SRST_N_OUT | BITMASK_JTAGKEY_SRST_N_OE_N ); + push_to_send( params, 0 ); send_and_receive( cable ); parport_close( p ); @@ -430,12 +494,28 @@ ft2232_armusbocd_done( cable_t *cable ) push_to_send( params, SET_BITS_LOW ); push_to_send( params, BITMASK_ARMUSBOCD_nOE ); push_to_send( params, BITMASK_ARMUSBOCD_nOE ); - send_and_receive( cable ); + /* Set Data Bits Low Byte set all to input */ push_to_send( params, SET_BITS_LOW ); push_to_send( params, BITMASK_ARMUSBOCD_nOE ); 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_ARMUSBOCD_nTRST | BITMASK_ARMUSBOCD_nTRST_nOE | + BITMASK_ARMUSBOCD_nTSRST ); + push_to_send( params, BITMASK_ARMUSBOCD_nTRST | BITMASK_ARMUSBOCD_nTRST_nOE | + BITMASK_ARMUSBOCD_nTSRST | + BITMASK_ARMUSBOCD_RED_LED ); + + /* Set Data Bits High Byte + set all to input */ + push_to_send( params, SET_BITS_HIGH ); + push_to_send( params, BITMASK_ARMUSBOCD_nTRST | BITMASK_ARMUSBOCD_nTRST_nOE | + BITMASK_ARMUSBOCD_nTSRST ); + push_to_send( params, 0 ); send_and_receive( cable ); parport_close( p ); @@ -705,7 +785,7 @@ ft2232_flush( cable_t *cable, cable_flush_amount_t how_much ) { params_t *params = (params_t *)cable->params; - if( how_much == OPTIONALLY ) return; + if( how_much == OPTIONALLY ) return; while (cable->todo.num_items > 0) {