Skip to content

Instantly share code, notes, and snippets.

@jkent
Created November 13, 2012 16:47
Show Gist options
  • Save jkent/4066901 to your computer and use it in GitHub Desktop.
Save jkent/4066901 to your computer and use it in GitHub Desktop.
OpenOCD: adds proper TIAO USB Multi-Protocol Adapter (TUMPA) support
diff --git a/src/jtag/drivers/ft2232.c b/src/jtag/drivers/ft2232.c
index 6758dc7..091c396 100644
--- a/src/jtag/drivers/ft2232.c
+++ b/src/jtag/drivers/ft2232.c
@@ -194,6 +194,7 @@ static int lisa_l_init(void);
static int flossjtag_init(void);
static int xds100v2_init(void);
static int digilent_hs1_init(void);
+static int tumpa_init(void);
/* reset procedures for supported layouts */
static void ftx23_reset(int trst, int srst);
@@ -213,6 +214,7 @@ static void ktlink_reset(int trst, int srst);
static void redbee_reset(int trst, int srst);
static void xds100v2_reset(int trst, int srst);
static void digilent_hs1_reset(int trst, int srst);
+static void tumpa_reset(int trst, int srst);
/* blink procedures for layouts that support a blinking led */
static void olimex_jtag_blink(void);
@@ -344,6 +346,11 @@ static const struct ft2232_layout ft2232_layouts[] = {
.reset = digilent_hs1_reset,
.channel = INTERFACE_A,
},
+ { .name = "tumpa",
+ .init = tumpa_init,
+ .reset = tumpa_reset,
+ .channel = INTERFACE_A,
+ },
{ .name = NULL, /* END OF TABLE */ },
};
@@ -1637,6 +1644,32 @@ static void xds100v2_reset(int trst, int srst)
high_direction);
}
+static void tumpa_reset(int trst, int srst)
+{
+ if (trst == 1) {
+ tap_set_state(TAP_RESET);
+ low_output &= ~nTRST;
+ } else if (trst == 0) {
+ low_output |= nTRST;
+ }
+
+ if (srst == 1) {
+ low_output &= ~nSRST;
+ } else if (srst == 0) {
+ low_output |= nSRST;
+ }
+
+ /* command "set data bits low byte" */
+ buffer_write(0x80);
+ buffer_write(low_output);
+ buffer_write(low_direction);
+ LOG_DEBUG("trst: %i, srst: %i, low_output: 0x%2.2x, low_direction: 0x%2.2x",
+ trst,
+ srst,
+ low_output,
+ low_direction);
+}
+
static int ft2232_execute_runtest(struct jtag_command *cmd)
{
int retval;
@@ -3049,6 +3082,33 @@ static int xds100v2_init(void)
return ERROR_OK;
}
+static int tumpa_init(void)
+{
+
+ nTRST = 0x20;
+ nSRST = 0x10;
+
+ low_output = 0x08 | nTRST | 0x40;
+ low_direction = 0x0b | nTRST | nSRST;
+
+ /* initialize low byte for jtag */
+ if (ft2232_set_data_bits_low_byte(low_output, low_direction) != ERROR_OK) {
+ LOG_ERROR("couldn't initialize FT2232 with 'tumpa' layout");
+ return ERROR_JTAG_INIT_FAILED;
+ }
+
+ high_output = 0x0;
+ high_direction = 0x08;
+
+ /* initialize high byte for jtag */
+ if (ft2232_set_data_bits_high_byte(high_output, high_direction) != ERROR_OK) {
+ LOG_ERROR("couldn't initialize FT2232 with 'tumpa' layout");
+ return ERROR_JTAG_INIT_FAILED;
+ }
+
+ return ERROR_OK;
+}
+
static void olimex_jtag_blink(void)
{
/* Olimex ARM-USB-OCD has a LED connected to ACBUS3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment