From e3042a86ede3e50e3852268a4957c3c2d43f794f Mon Sep 17 00:00:00 2001 From: Oleksij Rempel Date: Fri, 28 Jun 2013 22:49:48 +0200 Subject: [PATCH] mips_ejtag: cache ejtag version to avoid recalculation Some parts of code are version specific. It will be easier if we extract ejtag version and store it some where. Change-Id: I8f9addc42108cba5ae9d61b8ade8f9d7f02a0fb5 Signed-off-by: Oleksij Rempel Reviewed-on: http://openocd.zylin.com/1462 Tested-by: jenkins Reviewed-by: Spencer Oliver --- src/target/mips_ejtag.c | 17 ++++++++--------- src/target/mips_ejtag.h | 8 ++++++++ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/target/mips_ejtag.c b/src/target/mips_ejtag.c index 2f0dfde9c..372619127 100644 --- a/src/target/mips_ejtag.c +++ b/src/target/mips_ejtag.c @@ -273,7 +273,6 @@ int mips_ejtag_exit_debug(struct mips_ejtag *ejtag_info) int mips_ejtag_init(struct mips_ejtag *ejtag_info) { - uint32_t ejtag_version; int retval; retval = mips_ejtag_get_impcode(ejtag_info, &ejtag_info->impcode); @@ -282,25 +281,25 @@ int mips_ejtag_init(struct mips_ejtag *ejtag_info) LOG_DEBUG("impcode: 0x%8.8" PRIx32 "", ejtag_info->impcode); /* get ejtag version */ - ejtag_version = ((ejtag_info->impcode >> 29) & 0x07); + ejtag_info->ejtag_version = ((ejtag_info->impcode >> 29) & 0x07); - switch (ejtag_version) { - case 0: + switch (ejtag_info->ejtag_version) { + case EJTAG_VERSION_20: LOG_DEBUG("EJTAG: Version 1 or 2.0 Detected"); break; - case 1: + case EJTAG_VERSION_25: LOG_DEBUG("EJTAG: Version 2.5 Detected"); break; - case 2: + case EJTAG_VERSION_26: LOG_DEBUG("EJTAG: Version 2.6 Detected"); break; - case 3: + case EJTAG_VERSION_31: LOG_DEBUG("EJTAG: Version 3.1 Detected"); break; - case 4: + case EJTAG_VERSION_41: LOG_DEBUG("EJTAG: Version 4.1 Detected"); break; - case 5: + case EJTAG_VERSION_51: LOG_DEBUG("EJTAG: Version 5.1 Detected"); break; default: diff --git a/src/target/mips_ejtag.h b/src/target/mips_ejtag.h index 59f91b50b..19b2c7574 100644 --- a/src/target/mips_ejtag.h +++ b/src/target/mips_ejtag.h @@ -122,6 +122,13 @@ #define EJTAG_DBCn_BLM_SHIFT 4 #define EJTAG_DBCn_BE (1 << 0) +#define EJTAG_VERSION_20 0 +#define EJTAG_VERSION_25 1 +#define EJTAG_VERSION_26 2 +#define EJTAG_VERSION_31 3 +#define EJTAG_VERSION_41 4 +#define EJTAG_VERSION_51 5 + struct mips_ejtag { struct jtag_tap *tap; uint32_t impcode; @@ -132,6 +139,7 @@ struct mips_ejtag { uint32_t reg9; unsigned scan_delay; int mode; + unsigned int ejtag_version; }; void mips_ejtag_set_instr(struct mips_ejtag *ejtag_info,