This is an automated email from Gerrit. Peter Lawrence ([email protected]) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/4856
-- gerrit commit 1a69e6d41526d67c9bb708afba5317ad630320fe Author: Peter Lawrence <[email protected]> Date: Wed Jan 16 21:42:17 2019 -0600 arm_adi_v5: added detection of implemented JTAG-AP ports This allows "dap info" to discern the presence of JTAG-AP devices JTAG-AP allows up to eight distinct legacy JTAG chains to be individually accessed over a CoreSight bus. Nominally, this would be one ARM TAP on each port, but this is not a hard requirement. I'd welcome some helpful feedback if there is a preferred approach to plug in these new JTAG scan chains into the OpenOCD architecture. In the interim, if you get a PORTCONNECTED and are curious as to what is present, here is a manual method of reading the IDCODE. This example assumes: - a dap named foo.dap (command "dap names" gives list) - a single ARM TAP (with 4-bit IR) - port 1 (last argument 0x01 of first command) - ap_num 2 (second argument of all commands) foo.dap apreg 2 0x4 0x01 foo.dap apreg 2 0x0 0x2 foo.dap apreg 2 0x10 0x3F foo.dap apreg 2 0x0 0x0 foo.dap apreg 2 0x0 foo.dap apreg 2 0x1C 0x139E8826 foo.dap apreg 2 0x0 foo.dap apreg 2 0x14 0x1F8D foo.dap apreg 2 0x0 foo.dap apreg 2 0x1C Change-Id: I68562095086964bbf633b7cd95681f0ad2051c76 Signed-off-by: Peter Lawrence <[email protected]> diff --git a/src/target/arm_adi_v5.c b/src/target/arm_adi_v5.c index 03e642b..d225063 100644 --- a/src/target/arm_adi_v5.c +++ b/src/target/arm_adi_v5.c @@ -1371,6 +1371,54 @@ static int dap_rom_display(struct command_context *cmd_ctx, return ERROR_OK; } +static int dap_jtag_ap_display(struct command_context *cmd_ctx, struct adiv5_ap *ap) +{ + uint32_t value, backup_psel; + int retval; + + /* backup existing PSEL so that we can later restore it */ + retval = dap_queue_ap_read(ap, JTAG_AP_REG_PSEL, &backup_psel); + + if (ERROR_OK == retval) + retval = dap_run(ap->dap); + + if (ERROR_OK != retval) + return retval; + + /* for each of the eight ports, see if something is connected */ + for (int port = 0; port < 8; port++) + { + retval = dap_queue_ap_write(ap, JTAG_AP_REG_PSEL, 1UL << port); + + if (ERROR_OK == retval) + retval = dap_run(ap->dap); + + if (ERROR_OK != retval) + return retval; + + retval = dap_queue_ap_read(ap, JTAG_AP_REG_CSW, &value); + + if (ERROR_OK == retval) + retval = dap_run(ap->dap); + + if (ERROR_OK != retval) + return retval; + + if (value & (CSW_PORTCONNECTED_MASK | CSW_SRSTCONNECTED_MASK)) + command_print(cmd_ctx, "\t\tPort %d:%s%s", port, + (value & CSW_PORTCONNECTED_MASK) ? " PORTCONNECTED" : "", + (value & CSW_SRSTCONNECTED_MASK) ? " SRSTCONNECTED" : ""); + } + + /* restore PSEL to its previous state */ + retval = dap_queue_ap_write(ap, JTAG_AP_REG_PSEL, backup_psel); + + if (ERROR_OK == retval) + retval = dap_run(ap->dap); + + return retval; +} + int dap_info_command(struct command_context *cmd_ctx, struct adiv5_ap *ap) { @@ -1426,6 +1474,11 @@ int dap_info_command(struct command_context *cmd_ctx, } } + if (AP_TYPE_JTAG_AP == (apid & IDR_CLASS)) + { + dap_jtag_ap_display(cmd_ctx, ap); + } + return ERROR_OK; } diff --git a/src/target/arm_adi_v5.h b/src/target/arm_adi_v5.h index a340b76..54c0acf 100644 --- a/src/target/arm_adi_v5.h +++ b/src/target/arm_adi_v5.h @@ -139,6 +139,30 @@ #define DP_APSEL_MAX (255) #define DP_APSEL_INVALID (-1) +/* JTAG-AP register addresses */ +#define JTAG_AP_REG_CSW 0x00 +#define JTAG_AP_REG_PSEL 0x04 +#define JTAG_AP_REG_PSTA 0x08 +#define JTAG_AP_REG_BRFIFO1 0x10 +#define JTAG_AP_REG_BWFIFO1 0x10 +#define JTAG_AP_REG_BRFIFO2 0x14 +#define JTAG_AP_REG_BWFIFO2 0x14 +#define JTAG_AP_REG_BRFIFO3 0x18 +#define JTAG_AP_REG_BWFIFO3 0x18 +#define JTAG_AP_REG_BRFIFO4 0x1C +#define JTAG_AP_REG_BWFIFO4 0x1C + +/* Fields of the JTAG-AP's CSW register */ +#define CSW_SERACTV_MASK (1UL << 31) +#define CSW_WFIFOCNT_POS 28 +#define CSW_WFIFOCNT_MASK (7UL << CSW_WFIFOCNT_POS) +#define CSW_RFIFOCNT_POS 24 +#define CSW_RFIFOCNT_MASK (7UL << CSW_RFIFOCNT_POS) +#define CSW_PORTCONNECTED_MASK (1UL << 3) +#define CSW_SRSTCONNECTED_MASK (1UL << 2) +#define CSW_TRST_OUT_MASK (1UL << 1) +#define CSW_SRST_OUT_MASK (1UL << 0) + /** * This represents an ARM Debug Interface (v5) Access Port (AP). * Most common is a MEM-AP, for memory access. -- _______________________________________________ OpenOCD-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openocd-devel
