summaryrefslogtreecommitdiff
path: root/src/jtag
diff options
context:
space:
mode:
authordrath <drath@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2006-08-17 14:53:15 +0000
committerdrath <drath@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2006-08-17 14:53:15 +0000
commit5fcd1d704cea078f6651e8e928ce7ff67b283882 (patch)
tree2adc2d71513793359bef126d05448f0e22a259be /src/jtag
parent9a830747b2324cc1f319c32399e76f759bd5f0e6 (diff)
downloadopenocd_libswd-5fcd1d704cea078f6651e8e928ce7ff67b283882.tar.gz
openocd_libswd-5fcd1d704cea078f6651e8e928ce7ff67b283882.tar.bz2
openocd_libswd-5fcd1d704cea078f6651e8e928ce7ff67b283882.tar.xz
openocd_libswd-5fcd1d704cea078f6651e8e928ce7ff67b283882.zip
- renamed jtag_interface_t.support_statemove to jtag_interface_t.support_pathmove (it is used to indicate jtag_add_pathmove support)
- fixed small bug in str7x.c that printed an address instead of the target number in an error message - added support for Olimex ARM-USB-OCD. The new ft2232 layout is called "olimex-jtag" git-svn-id: svn://svn.berlios.de/openocd/trunk@87 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/jtag')
-rw-r--r--src/jtag/amt_jtagaccel.c2
-rw-r--r--src/jtag/bitbang.c6
-rw-r--r--src/jtag/ep93xx.c2
-rw-r--r--src/jtag/ft2232.c147
-rw-r--r--src/jtag/jtag.c2
-rw-r--r--src/jtag/jtag.h4
-rw-r--r--src/jtag/parport.c2
7 files changed, 152 insertions, 13 deletions
diff --git a/src/jtag/amt_jtagaccel.c b/src/jtag/amt_jtagaccel.c
index d788728b..dde09ff5 100644
--- a/src/jtag/amt_jtagaccel.c
+++ b/src/jtag/amt_jtagaccel.c
@@ -117,7 +117,7 @@ jtag_interface_t amt_jtagaccel_interface =
.execute_queue = amt_jtagaccel_execute_queue,
- .support_statemove = 0,
+ .support_pathmove = 0,
.speed = amt_jtagaccel_speed,
.register_commands = amt_jtagaccel_register_commands,
diff --git a/src/jtag/bitbang.c b/src/jtag/bitbang.c
index 3d49d186..2065f62a 100644
--- a/src/jtag/bitbang.c
+++ b/src/jtag/bitbang.c
@@ -142,7 +142,11 @@ void bitbang_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size)
for (bit_cnt = 0; bit_cnt < scan_size; bit_cnt++)
{
- if ((buffer[bit_cnt/8] >> (bit_cnt % 8)) & 0x1) {
+ /* if we're just reading the scan, but don't care about the output
+ * default to outputting 'low', this also makes valgrind traces more readable,
+ * as it removes the dependency on an uninitialised value
+ */
+ if ((type != SCAN_IN) && ((buffer[bit_cnt/8] >> (bit_cnt % 8)) & 0x1)) {
bitbang_interface->write(0, (bit_cnt==scan_size-1) ? 1 : 0, 1);
bitbang_interface->write(1, (bit_cnt==scan_size-1) ? 1 : 0, 1);
} else {
diff --git a/src/jtag/ep93xx.c b/src/jtag/ep93xx.c
index e68e3d15..38763d2e 100644
--- a/src/jtag/ep93xx.c
+++ b/src/jtag/ep93xx.c
@@ -67,7 +67,7 @@ jtag_interface_t ep93xx_interface =
.execute_queue = bitbang_execute_queue,
- .support_statemove = 0,
+ .support_pathmove = 0,
.speed = ep93xx_speed,
.register_commands = ep93xx_register_commands,
diff --git a/src/jtag/ft2232.c b/src/jtag/ft2232.c
index 862003f5..7d2fac08 100644
--- a/src/jtag/ft2232.c
+++ b/src/jtag/ft2232.c
@@ -83,19 +83,29 @@ typedef struct ft2232_layout_s
char* name;
int(*init)(void);
void(*reset)(int trst, int srst);
+ void(*blink)(void);
} ft2232_layout_t;
+/* init procedures for supported layouts */
int usbjtag_init(void);
int jtagkey_init(void);
+int olimex_jtag_init(void);
+
+/* reset procedures for supported layouts */
void usbjtag_reset(int trst, int srst);
void jtagkey_reset(int trst, int srst);
+void olimex_jtag_reset(int trst, int srst);
+
+/* blink procedures for layouts that support a blinking led */
+void olimex_jtag_blink(void);
ft2232_layout_t ft2232_layouts[] =
{
- {"usbjtag", usbjtag_init, usbjtag_reset},
- {"jtagkey", jtagkey_init, jtagkey_reset},
- {"jtagkey_prototype_v1", jtagkey_init, jtagkey_reset},
- {"signalyzer", usbjtag_init, usbjtag_reset},
+ {"usbjtag", usbjtag_init, usbjtag_reset, NULL},
+ {"jtagkey", jtagkey_init, jtagkey_reset, NULL},
+ {"jtagkey_prototype_v1", jtagkey_init, jtagkey_reset, NULL},
+ {"signalyzer", usbjtag_init, usbjtag_reset, NULL},
+ {"olimex-jtag", olimex_jtag_init, olimex_jtag_reset, olimex_jtag_blink},
{NULL, NULL, NULL},
};
@@ -128,7 +138,7 @@ jtag_interface_t ft2232_interface =
.execute_queue = ft2232_execute_queue,
- .support_statemove = 1,
+ .support_pathmove = 1,
.speed = ft2232_speed,
.register_commands = ft2232_register_commands,
@@ -674,6 +684,40 @@ void jtagkey_reset(int trst, int srst)
DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output, high_direction);
}
+void olimex_jtag_reset(int trst, int srst)
+{
+ if (trst == 1)
+ {
+ cur_state = TAP_TLR;
+ if (jtag_reset_config & RESET_TRST_OPEN_DRAIN)
+ high_output &= ~nTRSTnOE;
+ else
+ high_output &= ~nTRST;
+ }
+ else if (trst == 0)
+ {
+ if (jtag_reset_config & RESET_TRST_OPEN_DRAIN)
+ high_output |= nTRSTnOE;
+ else
+ high_output |= nTRST;
+ }
+
+ if (srst == 1)
+ {
+ high_output |= nSRST;
+ }
+ else if (srst == 0)
+ {
+ high_output &= ~nSRST;
+ }
+
+ /* command "set data bits high byte" */
+ BUFFER_ADD = 0x82;
+ BUFFER_ADD = high_output;
+ BUFFER_ADD = high_direction;
+ DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output, high_direction);
+}
+
int ft2232_execute_queue()
{
jtag_command_t *cmd = jtag_command_queue; /* currently processed command */
@@ -687,6 +731,10 @@ int ft2232_execute_queue()
ft2232_buffer_size = 0;
ft2232_expect_read = 0;
+
+ /* blink, if the current layout has that feature */
+ if (layout->blink)
+ layout->blink();
while (cmd)
{
@@ -1170,7 +1218,7 @@ int jtagkey_init(void)
}
/* initialize high port */
- buf[0] = 0x82; /* command "set data bits low byte" */
+ buf[0] = 0x82; /* command "set data bits high byte" */
buf[1] = high_output; /* value */
buf[2] = high_direction; /* all outputs (xRST and xRSTnOE) */
DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
@@ -1184,6 +1232,93 @@ int jtagkey_init(void)
return ERROR_OK;
}
+int olimex_jtag_init(void)
+{
+ u8 buf[3];
+ u32 bytes_written;
+
+ low_output = 0x08;
+ low_direction = 0x1b;
+
+ /* initialize low byte for jtag */
+ buf[0] = 0x80; /* command "set data bits low byte" */
+ buf[1] = low_output; /* value (TMS=1,TCK=0, TDI=0, nOE=0) */
+ buf[2] = low_direction; /* dir (output=1), TCK/TDI/TMS=out, TDO=in, nOE=out */
+ DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
+
+ if (((ft2232_write(buf, 3, &bytes_written)) != ERROR_OK) || (bytes_written != 3))
+ {
+ ERROR("couldn't initialize FT2232 with 'JTAGkey' layout");
+ return ERROR_JTAG_INIT_FAILED;
+ }
+
+ nTRST = 0x01;
+ nTRSTnOE = 0x4;
+ nSRST = 0x02;
+ nSRSTnOE = 0x00; /* no output enable for nSRST */
+
+ high_output = 0x0;
+ high_direction = 0x0f;
+
+ if (jtag_reset_config & RESET_TRST_OPEN_DRAIN)
+ {
+ high_output |= nTRSTnOE;
+ high_output &= ~nTRST;
+ }
+ else
+ {
+ high_output &= ~nTRSTnOE;
+ high_output |= nTRST;
+ }
+
+ if (jtag_reset_config & RESET_SRST_PUSH_PULL)
+ {
+ ERROR("can't set nSRST to push-pull on the Olimex ARM-USB-OCD");
+ }
+ else
+ {
+ high_output &= ~nSRST;
+ }
+
+ /* turn red LED on */
+ high_output |= 0x08;
+
+ /* initialize high port */
+ buf[0] = 0x82; /* command "set data bits high byte" */
+ buf[1] = high_output; /* value */
+ buf[2] = high_direction; /* all outputs (xRST and xRSTnOE) */
+ DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
+
+ if (((ft2232_write(buf, 3, &bytes_written)) != ERROR_OK) || (bytes_written != 3))
+ {
+ ERROR("couldn't initialize FT2232 with 'JTAGkey' layout");
+ return ERROR_JTAG_INIT_FAILED;
+ }
+
+ return ERROR_OK;
+}
+
+void olimex_jtag_blink(void)
+{
+ /* Olimex ARM-USB-OCD has a LED connected to ACBUS3
+ * ACBUS3 is bit 3 of the GPIOH port
+ */
+ if (high_output & 0x08)
+ {
+ /* set port pin high */
+ high_output &= 0x07;
+ }
+ else
+ {
+ /* set port pin low */
+ high_output |= 0x08;
+ }
+
+ BUFFER_ADD = 0x82;
+ BUFFER_ADD = high_output;
+ BUFFER_ADD = high_direction;
+}
+
int ft2232_quit(void)
{
#if BUILD_FT2232_FTD2XX == 1
diff --git a/src/jtag/jtag.c b/src/jtag/jtag.c
index a60aacd0..95818f07 100644
--- a/src/jtag/jtag.c
+++ b/src/jtag/jtag.c
@@ -694,7 +694,7 @@ int jtag_add_pathmove(int num_states, enum tap_state *path)
return ERROR_JTAG_NOT_IMPLEMENTED;
}
- if (jtag->support_statemove)
+ if (jtag->support_pathmove)
{
/* allocate memory for a new list member */
*last_cmd = cmd_queue_alloc(sizeof(jtag_command_t));
diff --git a/src/jtag/jtag.h b/src/jtag/jtag.h
index 0d71301f..19f81ce6 100644
--- a/src/jtag/jtag.h
+++ b/src/jtag/jtag.h
@@ -25,7 +25,7 @@
#include "command.h"
-#if 0
+#if 1
#define _DEBUG_JTAG_IO_
#endif
@@ -180,7 +180,7 @@ typedef struct jtag_interface_s
/* optional command support
*/
- int support_statemove;
+ int support_pathmove;
/* interface initalization
*/
diff --git a/src/jtag/parport.c b/src/jtag/parport.c
index 4b0b193c..c87f98e4 100644
--- a/src/jtag/parport.c
+++ b/src/jtag/parport.c
@@ -138,7 +138,7 @@ jtag_interface_t parport_interface =
.execute_queue = bitbang_execute_queue,
- .support_statemove = 0,
+ .support_pathmove = 1,
.speed = parport_speed,
.register_commands = parport_register_commands,