aboutsummaryrefslogtreecommitdiff
path: root/src/platforms/dev2/jtagtap.c
diff options
context:
space:
mode:
authorNicolas Schodet2013-04-03 23:17:59 +0200
committerNicolas Schodet2013-04-03 23:17:59 +0200
commit7b230c04b3d4be2ac4d78414efe201dc11415c7c (patch)
tree6f9120ac9bdcafb587d036ef5991c560e0fc2a90 /src/platforms/dev2/jtagtap.c
parent46898a71cea16b5e8159816f6c0a57e989900a3b (diff)
Add dev2 support.
This is used for APBTeam dev2 board. Black Magic runs on computer system and communicates with dev2 over usb, giving simple orders.
Diffstat (limited to 'src/platforms/dev2/jtagtap.c')
-rw-r--r--src/platforms/dev2/jtagtap.c79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/platforms/dev2/jtagtap.c b/src/platforms/dev2/jtagtap.c
new file mode 100644
index 0000000..30cf9f8
--- /dev/null
+++ b/src/platforms/dev2/jtagtap.c
@@ -0,0 +1,79 @@
+/*
+ * This file is part of the Black Magic Debug project.
+ *
+ * Copyright (C) 2011 Black Sphere Technologies Ltd.
+ * Written by Gareth McMullin <gareth@blacksphere.co.nz>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* This file implements the low-level JTAG TAP interface. */
+
+#include <stdio.h>
+
+#include "general.h"
+
+#include "jtagtap.h"
+#include "platform.h"
+
+int jtagtap_init(void)
+{
+ /* Make sure TMS is still output (shared with SWDIO). */
+ uint8_t cmd[] = { DEV2_OP_DIR_OUT, TMS_PIN };
+ platform_buffer_write (cmd, sizeof (cmd));
+
+ /* Go to JTAG mode for SWJ-DP */
+ for(int i = 0; i <= 50; i++) jtagtap_next(1, 0); /* Reset SW-DP */
+ jtagtap_tms_seq(0xE73C, 16); /* SWD to JTAG sequence */
+ jtagtap_soft_reset();
+
+ return 0;
+}
+
+void jtagtap_reset(void)
+{
+ jtagtap_soft_reset();
+}
+
+void jtagtap_srst(void)
+{
+}
+
+inline uint8_t jtagtap_next(uint8_t dTMS, uint8_t dTDO)
+{
+ uint8_t cmd[] = {
+ DEV2_OP_OUT_CHANGE, TMS_PIN | TDI_PIN,
+ (dTMS ? TMS_PIN : 0) | (dTDO ? TDI_PIN : 0),
+ DEV2_OP_OUT_SET, TCK_PIN,
+ DEV2_OP_IN,
+ DEV2_OP_OUT_RESET, TCK_PIN,
+ };
+ platform_buffer_write (cmd, sizeof (cmd));
+ uint8_t rep[1];
+ platform_buffer_read (rep, sizeof (rep));
+ int ret = rep[0] & TDO_PIN;
+
+ DEBUG("jtagtap_next(TMS = %d, TDO = %d) = %d\n", dTMS, dTDO, ret);
+
+ return ret != 0;
+}
+
+
+
+#define PROVIDE_GENERIC_JTAGTAP_TMS_SEQ
+#define PROVIDE_GENERIC_JTAGTAP_TDI_TDO_SEQ
+#define PROVIDE_GENERIC_JTAGTAP_TDI_SEQ
+
+#include "jtagtap_generic.c"
+